WSdev Wiki
nesdev_db
https://ws.nesdev.org/wiki/WSdev_Wiki
MediaWiki 1.43.1
first-letter
Media
Special
Talk
User
User talk
Ws wiki
Ws wiki talk
File
File talk
MediaWiki
MediaWiki talk
Template
Template talk
Help
Help talk
Category
Category talk
WSdev Wiki
0
1
1
2022-04-12T23:50:02Z
MediaWiki default
2
wikitext
text/x-wiki
<strong>MediaWiki has been installed.</strong>
Consult the [https://www.mediawiki.org/wiki/Special:MyLanguage/Help:Contents User's Guide] for information on using the wiki software.
== Getting started ==
* [https://www.mediawiki.org/wiki/Special:MyLanguage/Manual:Configuration_settings Configuration settings list]
* [https://www.mediawiki.org/wiki/Special:MyLanguage/Manual:FAQ MediaWiki FAQ]
* [https://lists.wikimedia.org/postorius/lists/mediawiki-announce.lists.wikimedia.org/ MediaWiki release mailing list]
* [https://www.mediawiki.org/wiki/Special:MyLanguage/Localisation#Translation_resources Localise MediaWiki for your language]
* [https://www.mediawiki.org/wiki/Special:MyLanguage/Manual:Combating_spam Learn how to combat spam on your wiki]
11cef88175cf81168a86e7c0327a5b2d7a1920f5
3
1
2023-08-15T01:36:31Z
Fiskbit
37
Main page skeleton so there's something.
wikitext
text/x-wiki
'''WonderSwan Development Wiki'''
== Reference ==
29ed002989d0e68a0b9780b30f247a56f77f5095
8
3
2023-08-15T05:16:32Z
Asie
351
Initial landing page.
wikitext
text/x-wiki
'''WonderSwan Development Wiki'''
== Reference ==
=== General ===
* [[Memory map]]
* [[I/O port map]]
* [[Cartridge]]
* [[ROM header]]
* [[NEC V30MZ]] - the WonderSwan CPU (80186-compatible)
=== Components ===
* [[Display]]
* [[Sound]]
* [[Timers]]
* [[Interrupts]]
* [[Serial port]]
* [[DMA]] (WonderSwan Color only)
=== Pinouts ===
* [[Accessory port pinout]]
* [[2001 Mapper pinout]]
* [[2003 Mapper pinout]]
=== Accessories ===
* [[WonderBeat 9480]] headphone adapter
* [[WonderBorg]] robot
* [[WonderGate]] mobile adapter
* [[WonderWave]] infrared adapter
== Links ==
* [https://github.com/WonderfulToolchain/awesome-wsdev awesome-wsdev] - curated documentation/tools/source code link list
== MediaWiki ==
* [https://www.mediawiki.org/wiki/Special:MyLanguage/Help:Contents User's Guide]
* [https://www.mediawiki.org/wiki/Special:MyLanguage/Manual:FAQ MediaWiki FAQ]
* [[:Category:Deletion requests|Deletion requests]]
2be56d670a847fadb6e86249497f4d5c60b2a7bf
10
8
2023-08-15T06:09:29Z
Asie
351
add start of WonderWitch section
wikitext
text/x-wiki
'''WonderSwan Development Wiki'''
== Reference ==
=== General ===
* [[Memory map]]
* [[I/O port map]]
* [[Cartridge]]
* [[ROM header]]
* [[NEC V30MZ]] - the WonderSwan CPU (80186-compatible)
=== Components ===
* [[Display]]
* [[Sound]]
* [[Timers]]
* [[Interrupts]]
* [[Serial port]]
* [[DMA]] (WonderSwan Color only)
=== Pinouts ===
* [[Accessory port pinout]]
* [[2001 Mapper pinout]]
* [[2003 Mapper pinout]]
=== Accessories ===
* [[WonderBeat 9480]] headphone adapter
* [[WonderBorg]] robot
* [[WonderGate]] mobile adapter
* [[WonderWave]] infrared adapter
=== WonderWitch ===
* [[FreyaBIOS interrupt list]]
* [[WonderWitch .fx files|.fx files]]
== Links ==
* [https://github.com/WonderfulToolchain/awesome-wsdev awesome-wsdev] - curated documentation/tools/source code link list
== MediaWiki ==
* [https://www.mediawiki.org/wiki/Special:MyLanguage/Help:Contents User's Guide]
* [https://www.mediawiki.org/wiki/Special:MyLanguage/Manual:FAQ MediaWiki FAQ]
* [[:Category:Deletion requests|Deletion requests]]
cc84191a68583bb8d956cfc9ec99083af96db825
17
10
2023-08-15T13:10:18Z
Asie
351
add timing sub-page
wikitext
text/x-wiki
'''WonderSwan Development Wiki'''
== Reference ==
=== General ===
* [[Memory map]]
* [[I/O port map]]
* [[Cartridge]]
* [[ROM header]]
* [[NEC V30MZ]] - the WonderSwan CPU (80186-compatible)
* [[Timing]]
=== Components ===
* [[Display]]
* [[Sound]]
* [[Timers]]
* [[Interrupts]]
* [[Serial port]]
* [[DMA]] (WonderSwan Color only)
=== Pinouts ===
* [[Accessory port pinout]]
* [[2001 Mapper pinout]]
* [[2003 Mapper pinout]]
=== Accessories ===
* [[WonderBeat 9480]] headphone adapter
* [[WonderBorg]] robot
* [[WonderGate]] mobile adapter
* [[WonderWave]] infrared adapter
=== WonderWitch ===
* [[FreyaBIOS interrupt list]]
* [[WonderWitch .fx files|.fx files]]
== Links ==
* [https://github.com/WonderfulToolchain/awesome-wsdev awesome-wsdev] - curated documentation/tools/source code link list
== MediaWiki ==
* [https://www.mediawiki.org/wiki/Special:MyLanguage/Help:Contents User's Guide]
* [https://www.mediawiki.org/wiki/Special:MyLanguage/Manual:FAQ MediaWiki FAQ]
* [[:Category:Deletion requests|Deletion requests]]
cdc2c7b75ad93df4070b5f7905a6ff9fbfb61621
19
17
2023-08-15T13:19:31Z
Asie
351
add EEPROM, Mapper URLs
wikitext
text/x-wiki
'''WonderSwan Development Wiki'''
== Reference ==
=== General ===
* [[Memory map]]
* [[I/O port map]]
* [[Cartridge]]
* [[ROM header]]
* [[NEC V30MZ]] - the WonderSwan CPU (80186-compatible)
* [[Timing]]
=== Components ===
* [[Display]]
* [[Sound]]
* [[Timers]]
* [[Interrupts]]
* [[Serial port]]
* [[EEPROM]]
* [[DMA]] (WonderSwan Color only)
* [[Mapper]]
=== Pinouts ===
* [[Accessory port pinout]]
* [[2001 Mapper pinout]]
* [[2003 Mapper pinout]]
=== Accessories ===
* [[WonderBeat 9480]] headphone adapter
* [[WonderBorg]] robot
* [[WonderGate]] mobile adapter
* [[WonderWave]] infrared adapter
=== WonderWitch ===
* [[FreyaBIOS interrupt list]]
* [[WonderWitch .fx files|.fx files]]
== Links ==
* [https://github.com/WonderfulToolchain/awesome-wsdev awesome-wsdev] - curated documentation/tools/source code link list
== MediaWiki ==
* [https://www.mediawiki.org/wiki/Special:MyLanguage/Help:Contents User's Guide]
* [https://www.mediawiki.org/wiki/Special:MyLanguage/Manual:FAQ MediaWiki FAQ]
* [[:Category:Deletion requests|Deletion requests]]
137a5a03b3a9f8fa17239723c251aed67ae14f83
20
19
2023-08-15T13:21:27Z
Asie
351
add more URLs
wikitext
text/x-wiki
'''WonderSwan Development Wiki'''
== Reference ==
=== General ===
* [[Memory map]]
* [[I/O port map]]
* [[Cartridge]]
* [[ROM header]]
* [[NEC V30MZ]] - the WonderSwan CPU (80186-compatible)
* [[Timing]]
=== Components ===
* [[Display]]
* [[Sound]]
* [[Keypad]]
* [[Timers]]
* [[Interrupts]]
* [[Serial port]]
* [[EEPROM]]
* [[DMA]] (WonderSwan Color only)
* [[Mapper]]
* [[Real-Time Clock]] (2003)
=== Pinouts ===
* [[Accessory port pinout]]
* [[2001 Mapper pinout]]
* [[2003 Mapper pinout]]
=== Accessories ===
* [[WonderBeat 9480]] headphone adapter
* [[WonderBorg]] robot
* [[WonderGate]] mobile adapter
* [[WonderWave]] infrared adapter
=== WonderWitch ===
* [[FreyaBIOS]]
* [[WonderWitch .fx files|.fx file format]]
== Links ==
* [https://github.com/WonderfulToolchain/awesome-wsdev awesome-wsdev] - curated documentation/tools/source code link list
== MediaWiki ==
* [https://www.mediawiki.org/wiki/Special:MyLanguage/Help:Contents User's Guide]
* [https://www.mediawiki.org/wiki/Special:MyLanguage/Manual:FAQ MediaWiki FAQ]
* [[:Category:Deletion requests|Deletion requests]]
8ef262ac35e2ecb78b138dd02bef4a2fc5761bc7
21
20
2023-08-15T13:21:42Z
Asie
351
wikitext
text/x-wiki
'''WonderSwan Development Wiki'''
== Reference ==
=== General ===
* [[Memory map]]
* [[I/O port map]]
* [[Cartridge]]
* [[ROM header]]
* [[NEC V30MZ]] - the WonderSwan CPU (80186-compatible)
* [[Timing]]
=== Components ===
* [[Display]]
* [[Sound]]
* [[Keypad]]
* [[Timers]]
* [[Interrupts]]
* [[Serial port]]
* [[EEPROM]]
* [[DMA]] (WonderSwan Color only)
* [[Mapper]]
** [[Real-Time Clock]] (2003)
=== Pinouts ===
* [[Accessory port pinout]]
* [[2001 Mapper pinout]]
* [[2003 Mapper pinout]]
=== Accessories ===
* [[WonderBeat 9480]] headphone adapter
* [[WonderBorg]] robot
* [[WonderGate]] mobile adapter
* [[WonderWave]] infrared adapter
=== WonderWitch ===
* [[FreyaBIOS]]
* [[WonderWitch .fx files|.fx file format]]
== Links ==
* [https://github.com/WonderfulToolchain/awesome-wsdev awesome-wsdev] - curated documentation/tools/source code link list
== MediaWiki ==
* [https://www.mediawiki.org/wiki/Special:MyLanguage/Help:Contents User's Guide]
* [https://www.mediawiki.org/wiki/Special:MyLanguage/Manual:FAQ MediaWiki FAQ]
* [[:Category:Deletion requests|Deletion requests]]
cc4488eea5ac82239ba85446753b7df8a73ccac4
MediaWiki:Common.css
8
2
2
2023-08-15T01:13:55Z
Brizzo
1
Created page with "/* CSS placed here will be applied to all skins */ /* If a table is actually a table, you can add attractive borders and dark gray TH by changing the first line to {| class="tabular" */ table.tabular { margin: 1em 1em 1em 0; background: #f9f9f9; border: 1px solid #aaa; border-collapse: collapse } table.tabular th, table.tabular td { border: 1px solid #aaaaaa; padding: 0.2em } table.tabular th { background: #f2f2f2; text-align: center } table.tabular caption..."
css
text/css
/* CSS placed here will be applied to all skins */
/* If a table is actually a table, you can add attractive borders
and dark gray TH by changing the first line to
{| class="tabular"
*/
table.tabular {
margin: 1em 1em 1em 0; background: #f9f9f9; border: 1px solid #aaa; border-collapse: collapse
}
table.tabular th, table.tabular td {
border: 1px solid #aaaaaa; padding: 0.2em
}
table.tabular th {
background: #f2f2f2; text-align: center
}
table.tabular caption {
margin-left: inherit; margin-right: inherit
}
table.oddf0 tr:nth-of-type(odd) {
background: #F0F0F0;
}
table.evenf0 tr:nth-of-type(even) {
background: #F0F0F0;
}
/*
* Below taken directly from:
* http://www.mediawiki.org/wiki/MediaWiki:Common.css
*/
/*
This is the CSS for all skins (for all users) on MediaWiki.org.
SECTIONS:
1. Indication of namespaces
2. Color classes for content
3. Special pages
4. Main page styling
5. Sidebar external links
6. Extension:Matrix stuff
7. Wikitables, infobox templates, warnings, and other such stylings
8. Some other small things
*/
/** 1. INDICATION OF NAMESPACES **/
/* Pseudo NS Special (light grey) */
.ns--2 #content { background-color: #f4f4f4; }
.ns--2 div.thumb { border-color: #f4f4f4; }
/* NS Project + Project_talk (light sky blue) */
.ns-4 #content, .ns-5 #content { background-color: #f8fcff; }
.ns-4 div.thumb, .ns-5 div.thumb { border-color: #f8fcff; }
/* NS MediaWiki + MediaWiki_talk (light grey) */
.ns-8 #content, .ns-9 #content { background-color: #f4f4f4; }
.ns-8 div.thumb, .ns-9 div.thumb { border-color: #f4f4f4; }
/* NS Manual + Manual_talk (light bluish violet) */
.ns-100 #content, .ns-101 #content { background-color: #f3f3ff; }
.ns-100 div.thumb, .ns-101 div.thumb { border-color: #f3f3ff; }
/* NS Help (but NOT Help_talk) (blue border and Public Domain icon) */
.ns-12 #content {
border: 2px solid #0000cc;
border-right: none;
background-image: url(http://upload.wikimedia.org/wikipedia/mediawiki/b/b8/PD-banner.png);
background-repeat: no-repeat;
background-position: right top;
}
.ns-12 #bodyContent {
background-image: url(http://upload.wikimedia.org/wikipedia/mediawiki/6/67/PD-icon-faded.png);
background-repeat: no-repeat;
background-position: right 5em;
}
/***** 2. COLOR CLASSES FOR CONTENT *****/
/* Border colors */
.borderc1 { border-color: #e9e9e9; border-width: thin; }
.borderc2 { border-color: #aaaaaa; border-width: thin; }
.borderc3 { border-color: #777777; border-width: thin; }
.borderc4 { border-color: #000000; border-width: thin; }
.borderc5 { border-color: #c00000; border-width: thin; }
.borderc6 { border-color: #025e9d; border-width: thin; }
.borderc7 { border-color: #008040; border-width: thin; }
.borderc8 { border-color: #ffcc00; border-width: thin; } /* Used by: [[Template:Welcome]]. */
/* Background colors */
.backgroundc1 { background-color: #ffffff; } /* Used by: [[Template:Welcome]]. */
.backgroundc2 { background-color: #f9f9f9; }
.backgroundc3 { background-color: #eeeeee; }
.backgroundc4 { background-color: #e0e0e0; }
.backgroundc5 { background-color: #d2d2d2; }
.backgroundc6 { background-color: #b7b7b7; }
.backgroundc7 { background-color: #a3a3a3; }
.backgroundc8 { background-color: #444455; }
/** 3. SPECIAL PAGES **/
/* Consistent special page navigation */
.SpecialPageInfo {
background-color: #f9f9f9;
background-image: url(http://upload.wikimedia.org/wikipedia/commons/thumb/8/89/Exquisite-khelpcenter.png/35px-Exquisite-khelpcenter.png);
background-position: 0.8em 0.5em;
background-repeat: no-repeat;
padding: 0.3em 0.5em 0.3em 5.0em;
border-color: #025e9d;
border-width: 1px;
border-style: solid;
border-bottom-width: medium;
margin-bottom: 1em;
}
.mw-viewprevnext {
display: block;
border: 1px solid #cccccc;
background-color: #f9f9f2;
padding: 0.2em 0.4em;
}
/** 4. MAIN PAGE STYLING **/
#mainpage_topbox {
background: #f9f9f9;
padding: 0px;
border: 1px solid #aaaaaa;
margin: 0.2em 10px 10px;
}
.mainpage_boxtitle, .mainpage_hubtitle, #mainpage_pagetitle {
font-size: 105%;
padding: 0.4em;
background-color: #eeeeee;
border-bottom: 1px solid #aaaaaa;
}
.mainpage_boxtitle {
line-height: 120%;
}
#mainpage_pagetitle {
color: #cf7606;
font-size: 200% !important;
}
#mainpage_sitelinks {
padding: 0.2em;
text-align: center;
background-color: white;
}
.mainpage_hubtitle {
text-align: center;
}
.mainpage_boxcontents, .mainpage_boxcontents_small {
background: #ffffff;
padding: 0.2em 0.4em;
}
.mainpage_boxcontents_small {
font-size: 95%;
}
.mainpage_hubbox, #mainpage_newscell, #mainpage_downloadcell {
padding: 0;
border: 1px solid #aaaaaa;
}
.mainpage_hubbox {
margin-bottom: 0;
}
#mainpage_newscell {
margin-bottom: 15px;
margin-top: 0 !important;
}
#mainpage_newscell .mainpage_boxtitle {
background-image: url(http://upload.wikimedia.org/wikipedia/commons/thumb/8/89/Exquisite-khelpcenter.png/20px-Exquisite-khelpcenter.png);
background-repeat: no-repeat;
background-position: 99% 0.3em;
padding-right: 25px;
}
#mainpage_downloadcell {
width: 17em;
margin-bottom: 5px;
}
#mainpage_downloadcell .mainpage_boxtitle {
background-image: url(http://upload.wikimedia.org/wikipedia/commons/thumb/5/5d/Crystal_Clear_action_build.png/18px-Crystal_Clear_action_build.png);
background-repeat: no-repeat;
background-position: 96% 0.33em;
padding-right: 25px;
}
#mainpage_mwtitle { color: #005288; } /* The words 'MediaWiki.org' in the title. */
/* The "mainpage" class is added to the body with JavaScript for the main page in all */
/* languages, so we can style things that apppear on the main page and also elsewhere. */
.mainpage #lastmod,
.mainpage #siteSub,
.mainpage h1.firstHeading {
display: none !important;
}
.mainpage #content {
padding-top: 1em;
}
/** 5. SIDEBAR EXTERNAL LINKS **/
#n-blog-text a, #n-browse-svn a, #n-Statistics-for-SVN a, #n-phpdoc a, #n-svn-statistics a {
background: url(/skins-1.5/monobook/external.png) center right no-repeat;
padding-right: 13px;
color: #3366bb;
}
/** 7. WIKITABLES, INFOBOX TEMPLATES, WARNINGS AND OTHER SUCH STYLINGS **/
/* Give wikitables blue headings */
.wikitable th, .wikitable td.hl3, .wikitable th.hl3 {
background: #8da7d6;
}
.wikitable td.hl1, .wikitable th.hl1 {
background: #c5d8fc;
}
.wikitable td.hl2, .wikitable th.hl2 {
background: #a7c1f2;
}
/**
* Make entire table valign=top,
* To replace the |valign=top| on every cell.
*/
.vatop tr, tr.vatop, .vatop td, .vatop th {
vertical-align: top;
}
/* General purpose "pretty (data) tables" */
table.datatable {
background-color: transparent;
}
table.datatable th, table.datatable td {
padding: 4px;
}
table.datatable th {
text-align: left;
background-color: #999999;
}
table.datatable tr {
background-color: #cccccc;
}
table.datatable tr:hover {
background-color: #ffffcc;
}
/* SideBox styling */
div.sideBox {
position: relative;
float: right;
background: white;
margin-left: 1em;
border: 1px solid gray;
padding: 0.3em;
width: 200px;
overflow: hidden;
clear: right;
}
div.sideBox dl {
padding: 0;
margin: 0 0 0.3em 0;
font-size: 96%;
}
div.sideBox dl dt {
background: none;
margin: 0.4em 0 0 0;
}
div.sideBox dl dd {
margin: 0.1em 0 0 1.1em;
background-color: #f3f3f3;
}
/* Extension infobox styling */
.ext-infobox {
border: 2px solid #aaaaaa;
width: 272px;
float: right;
margin: 0 0 0.5em 0.5em;
border-collapse: collapse;
background-color: white;
}
.ext-infobox td {
border: 2px none #aaaaaa;
padding: 0.2em 0.5em;
border-bottom: 1px solid #f0f0f0 !important;
}
.ext-header {
background-color: #aaaaaa;
color: white;
text-align: left;
}
.ext-header td { padding-top: 0.5em; }
.ext-header img { padding: 0 0.2em 0 0.5em; }
.ext-status-unstable, .ext-status-unstable td { border-color: #990000; }
.ext-status-unstable .ext-header { background-color: #990000; color: #ffff00; }
.ext-status-experimental, .ext-status-experimental td { border-color: #ff4500; }
.ext-status-experimental .ext-header { background-color: #ff4500; }
.ext-status-beta, .ext-status-beta td { border-color: #ffba01; }
.ext-status-beta .ext-header { background-color: #ffba01; }
.ext-status-stable, .ext-status-stable td { border-color: #32cd32; }
.ext-status-stable .ext-header { background-color: #32cd32; }
/* Version box on [[Manual:Downloading MediaWiki]] */
#DownloadVersionBox {
border: 2px solid black;
border-collapse: collapse;
margin: auto;
width: 50%;
color: black;
}
#DownloadVersionBox td {
border: 2px solid black;
padding: 20px;
}
/* Major warning - used on the main page template to warn against editing carelessly, but can be used elsewhere as well */
.majorwarning {
background: yellow;
padding: 0.3em;
text-align: center;
font-size: 125%;
border: 2px solid red;
}
/* Page headings used throughout the wiki (though not very much at the time of writing…) */
.page-notice, .page-warning {
border-width: 1px;
border-style: solid;
padding: 0.3em 0.5em;
margin-bottom: 1em;
width: 95%;
margin-left: auto;
margin-right: auto;
text-align: center;
}
/* Informative notices at the top of pages (blue) */
.page-notice {
background-color: #f9f9f9;
border-color: #025e9d;
text-align: left;
}
/* Warning information at the top of pages (red) */
.page-warning {
background-color: #ffffff;
border-color: #c51919;
border-width: 2px;
}
.pw-head {
color: #c51919;
font-weight: bold;
}
/* Used in Template:Notice */
.block-note {
background-image: url(http://upload.wikimedia.org/wikipedia/commons/thumb/6/60/Bulbgraph.png/18px-Bulbgraph.png);
background-position: top left;
background-repeat: no-repeat;
}
/*
Using block-contents in the hope that it can apply to all block-level warning templates,
with different images applied as backgrounds to the wrapping DIV.
*/
.block-contents {
display: block;
padding-left: 20px;
}
/* Template documentation ([[Template:Documentation]]) */
.template-documentation {
clear: both;
margin: 1em 0 0 0;
border: 1px solid #aaa;
background-color: #ecfcf4;
padding: 5px;
}
/** 8. SOME OTHER SMALL THINGS **/
/* Give a bit of space to the TOC */
#toc { margin: 1em 0; }
/* Allow limiting of which header levels are shown in a TOC;
<div class="toclimit-3">, for instance, will limit to
showing ==headings== and ===headings=== but no further.
Used in [[Template:TOCright]]
*/
.toclimit-2 .toclevel-1 ul,
.toclimit-3 .toclevel-2 ul,
.toclimit-4 .toclevel-3 ul,
.toclimit-5 .toclevel-4 ul,
.toclimit-6 .toclevel-5 ul,
.toclimit-7 .toclevel-6 ul {
display: none;
}
/* make the list of references look smaller and highlight clicked reference in blue */
ol.references { font-size: 100%; }
.references-small { font-size: 90%; }
ol.references > li:target { background-color: #ddeeff; }
sup.reference:target { background-color: #ddeeff; }
/* extra buttons for edit dialog (from commons:MediaWiki:Common.css) */
.my-buttons {
padding: .5em;
}
.my-buttons a {
color: black;
background-color: #cde !important;
font-weight: bold;
font-size: .9em;
text-decoration: none;
border: thin #069 outset;
padding: 0 .1em .1em;
}
.my-buttons a:hover, .my-buttons a:active {
background-color: #bcd;
border-style: inset;
}
/* from [[User:Splarka/Help:Linked images]] */
.imagelink_wikilogo a {
width: 135px;
height: 135px;
display: block;
text-decoration: none;
background-image: url("http://upload.wikimedia.org/wikipedia/mediawiki/b/bc/Wiki.png");
}
/** reduced subset of the mbox styles from enwiki, mainly for the nice boxflow **/
table.mbox {
margin: 4px 10%;
border-collapse: collapse;
border: 1px solid #aaa; /* Default "notice" gray */
background: #f9f9f9;
}
table.mbox-wide {
margin: 4px 0;
}
th.mbox-text, td.mbox-text { /* The message body cell(s) */
border: none;
padding: 0.25em 0.9em; /* 0.9em left/right */
width: 100%; /* Make all mboxes the same width regardless of text length */
}
td.mbox-image { /* The left image cell */
border: none;
padding: 2px 0 2px 0.9em; /* 0.9em left, 0px right */
text-align: center;
}
td.mbox-imageright { /* The right image cell */
border: none;
padding: 2px 0.9em 2px 0; /* 0px left, 0.9em right */
text-align: center;
}
td.mbox-empty-cell { /* An empty narrow cell */
border: none;
padding: 0px;
width: 1px;
}
/* These mbox-small classes must be placed after all other
ambox/tmbox/ombox etc classes. "body.mediawiki" is so
they override "table.ambox + table.ambox" above. */
body.mediawiki table.mbox-small { /* For the "small=yes" option. */
clear: right;
float: right;
margin: 4px 0 4px 1em;
width: 238px;
font-size: 88%;
line-height: 1.25em;
}
body.mediawiki table.mbox-small-left { /* For the "small=left" option. */
margin: 4px 1em 4px 0;
width: 238px;
border-collapse: collapse;
font-size: 88%;
line-height: 1.25em;
}
/* These are the same colours as the enwiki
'cmbox' styles; just with different names. */
table.mbox-critical {
border: 4px solid #b22222; /* Red */
background: #FFDBDB; /* Pink */
}
table.mbox-important {
background: #FFDBDB; /* Red */
}
table.mbox-warning {
background: #FFE7CE; /* Orange */
}
table.mbox-caution {
background: #FFF9DB; /* Yellow */
}
table.mbox-notice {
background: #D8E8FF; /* Blue */
}
table.mbox-move {
background: #E4D8FF; /* Purple */
}
table.mbox-protection {
background: #EFEFE1; /* Gray-gold */
}
/**
* Infoboxes
*/
.infobox {
float: right;
clear: right;
margin-bottom: 0.5em;
margin-left: 1em;
padding: 0.2em;
border: 1px solid #AAA;
background: #F9F9F9;
color: black;
}
.infobox td,
.infobox th {
vertical-align: top;
}
.infobox caption {
margin-left: inherit;
font-size: larger;
}
.infobox.bordered {
border-collapse: collapse;
}
.infobox.bordered td,
.infobox.bordered th {
border: 1px solid #AAA;
}
.infobox.bordered .borderless td,
.infobox.bordered .borderless th {
border: 0;
}
/* Apparently the namespaces parameter
for inputbox forces a checkbox.
Let's hide it in the API sidebar */
.mw-inputbox-hideapicheck label[for=mw-inputbox-ns104],
#mw-inputbox-ns104 {
display: none;
}
/** Testing for code review **/
div.mw-wordcloud {
width: 100%;
text-align: justify;
}
.mw-wordcloud-size-1 {
color: #222;
font-size: 2.4em;
}
.mw-wordcloud-size-2 {
color: #333;
font-size:2.2em;
}
.mw-wordcloud-size-3 {
color: #444;
font-size: 2.0em;
}
.mw-wordcloud-size-4 {
color: #555;
font-size: 1.8em;
}
.mw-wordcloud-size-5 {
color: #666;
font-size: 1.6em;
}
.mw-wordcloud-size-6 {
color: #777;
font-size: 1.4em;
}
.mw-wordcloud-size-7 {
color: #888;
font-size: 1.2em;
}
.mw-wordcloud-size-8 {
color: #999;
font-size: 1em;
}
.mw-wordcloud-size-9 {
color: #aaa;
font-size: 0.8em;
letter-spacing: 3px;
}
.mw-wordcloud-size-10, .mw-wordcloud-size-0 {
color: #bbb;
font-size: 0.8em;
}
/* Styling for related links and disambiguation links */
.rellink, .dablink {
font-style: italic;
margin-bottom: 0.5em;
padding-left: 2em;
}
/* @todo FIXME: document me :) */
#signuptopbox li {
float: left;
list-style: none;
font-family: sans-serif;
}
#signuptopbox li {
color: #3ca7d4;
background: #c2e1f9;
line-height: 2.8em;
margin-right: .25em;
padding-right: .5em;
}
#signuptopbox li.pr-active, #signuptopbox li.pr-active div {
color: #67ca36;
background: #d4f9c2;
border-color: #fff #fff #fff #67ca36;
}
#signuptopbox li div{
width: 0;
height: 0;
border-color: #fff #fff #fff #3CA7D4;
border-style: solid;
border-width: 1.4em .3em 1.4em 1.4em;
float: left;
}
#signuptopbox li span.pr-number{
display: block;
width: 1.8em;
line-height: 1.8em;
background: #3ca7d4;
color: #c2e1f9;
text-align: center;
margin: .5em;
-webkit-border-radius: 50%;
-moz-border-radius: 50%;
-ms-border-radius: 50%;
-o-border-radius: 50%;
border-radius: 50%;
font-weight: 600;
float: left;
}
#signuptopbox li.pr-active span.pr-number {
background: #67ca36;
color: #d4f9c2;
}
#signuptopbox li span {
float: left;
}
#signuptopbox li.pr-spacer {
padding: 0;
}
/* BREADCRUMB CODE */
.breadcrumb {
list-style: none;
overflow: hidden;
font: 14px Helvetica, Arial, Sans-Serif;
}
.breadcrumb li {
float: left;
margin-bottom: 0;
}
.breadcrumb li a {
color: white;
text-decoration: none;
padding: 10px 0 10px 45px;
position: relative;
display: block;
float: left;
}
.breadcrumb li a:after {
content: " ";
display: block;
width: 0;
height: 0;
border-top: 50px solid transparent; /* Go big on the size, and let overflow hide */
border-bottom: 50px solid transparent;
position: absolute;
top: 50%;
margin-top: -50px;
left: 100%;
z-index: 2;
}
.breadcrumb li a:before {
content: " ";
display: block;
width: 0;
height: 0;
border-top: 50px solid transparent;
border-bottom: 50px solid transparent;
border-left: 31px solid white;
position: absolute;
top: 50%;
margin-top: -50px;
margin-left: 1px;
left: 100%;
z-index: 1;
}
.breadcrumb li:first-child a {
padding-left: 20px;
}
.currentcrumb a {
background: #069;
}
.currentcrumb a:after {
border-left: 30px solid #069;
}
.currentcrumb a:hover, .prevcrumb a:hover, .nextcrumb a:hover {
background: #002d44;
}
.currentcrumb a:hover:after, .prevcrumb a:hover:after, .nextcrumb a:hover:after { border-left-color: #002d44 !important; }
.prevcrumb a {
background: #396;
}
.prevcrumb a:after {
border-left: 30px solid #396;
}
.nextcrumb a {
background: #999;
}
.nextcrumb a:after {
border-left: 30px solid #999;
}
/* bug 27375, To go in ext.codereview */
.mw-codereview-diff ins {
background: #EDFFED;
}
.mw-codereview-diff del {
background: #FFEDED;
}
/* bug 29307, awaiting deployment */
pre {
line-height: 1.3em;
}
/*
* End mediawiki.org import
*/
pre,.mw-code { white-space:pre; overflow-x: auto; }
7b014c1d6648715d37f0e5bdbc8085bd023638be
MediaWiki:Loginprompt
8
3
4
2023-08-15T01:46:21Z
Fiskbit
37
Adds log-in prompt explaining how to register an account.
wikitext
text/x-wiki
Looking to register an account? Because of spam, accounts are currently created manually by request. Please reach out to Fiskbit or lidnariq on the [http://forums.nesdev.org/ NESdev forums] or [https://discord.gg/JSG4kuF8EK NESdev Discord server] if you'd like to contribute to the wiki.
250f3ff9f50ef5476c10ce328ab8981594ebfd68
MediaWiki:Sidebar
8
4
5
2023-08-15T01:55:43Z
Fiskbit
37
Updates the sidebar.
wikitext
text/x-wiki
* navigation
** mainpage|Wiki main page
** http://forums.nesdev.org/ | NESdev Forums
** https://discord.gg/JSG4kuF8EK | NESdev Discord
** recentchanges-url|recentchanges
* SEARCH
* TOOLBOX
* LANGUAGES
d3889c8a1c188f221c689d5bb4dca061db57ed59
6
5
2023-08-15T02:13:47Z
Fiskbit
37
Adds WonderSwan Discord invite.
wikitext
text/x-wiki
* navigation
** mainpage|Wiki main page
** http://forums.nesdev.org/ | NESdev Forums
** https://discord.gg/JSG4kuF8EK | NESdev Discord
** https://discord.gg/6hFZY5ce | WS Discord
** recentchanges-url|recentchanges
* SEARCH
* TOOLBOX
* LANGUAGES
4a4323f9a6c0ecb3be9558fe10332aceef5d03ce
7
6
2023-08-15T02:29:24Z
Fiskbit
37
Swaps out WS Discord link for hopefully-permanent version.
wikitext
text/x-wiki
* navigation
** mainpage|Wiki main page
** http://forums.nesdev.org/ | NESdev Forums
** https://discord.gg/JSG4kuF8EK | NESdev Discord
** https://discord.gg/7rmX2QJ | WS Discord
** recentchanges-url|recentchanges
* SEARCH
* TOOLBOX
* LANGUAGES
822d68b76e3bb3a1837509e8f7956610cca52a9c
ROM header
0
5
9
2023-08-15T06:04:43Z
Asie
351
Created page with "Every WonderSwan ROM contains a header. It is stored at the end - final sixteen bytes - of the ROM image. == ROM header == Parts of this header are validated or otherwise used by the console's [[boot ROM]] - they are marked in '''bold'''. {| class="wikitable" |+ Header contents |- ! Offset !! Length !! Contents |- | '''$0''' || '''5''' || Far jump instruction: '''0xEA''', offset, segment. |- | '''$5''' || '''1''' || '''Maintenance''' |- | $6 || 1 || Developer/Publishe..."
wikitext
text/x-wiki
Every WonderSwan ROM contains a header. It is stored at the end - final sixteen bytes - of the ROM image.
== ROM header ==
Parts of this header are validated or otherwise used by the console's [[boot ROM]] - they are marked in '''bold'''.
{| class="wikitable"
|+ Header contents
|-
! Offset !! Length !! Contents
|-
| '''$0''' || '''5''' || Far jump instruction: '''0xEA''', offset, segment.
|-
| '''$5''' || '''1''' || '''Maintenance'''
|-
| $6 || 1 || Developer/Publisher ID
|-
| $7 || 1 || Color
|-
| $8 || 1 || Game ID (binary-coded decimal)
|-
| '''$9''' || '''1''' || '''Game version? / Safe mode'''
|-
| $A || 1 || ROM size
|-
| $B || 1 || Save type/size
|-
| '''$C''' || '''1''' || '''Flags'''
|-
| $D || 1 || Mapper type
|-
| $E || 2 || Checksum (sum of all ROM bytes excluding the checksum)
|}
=== $5 - Maintenance ===
<pre>
s...0000
| ++++- Must be zero; otherwise the console will prohibit execution.
| Purpose unknown.
+-------- (Color) Splash bypass: 0 = Disable, 1 = Enable.
Bypasses the custom boot splash stored in the console's
internal EEPROM; presumably used for bricked console recovery.
</pre>
=== $6 - Developer/Publisher ID ===
{| class="wikitable"
|+ Known official developer/publisher IDs
|-
! ID !! Publisher
|-
| $01 || Bandai
|-
| $02 || Taito
|-
| $03 || ?
|-
| $04 || Koei
|-
| $05 || Data East
|-
| $06 || Asmik Ace
|-
| $07 || Media Entertainment
|-
| $08 || Nichibutsu
|-
| $0A || Coconuts Japan
|-
| $0B || Sammy
|-
| $0C || Sunsoft
|-
| $0D || ?
|-
| $0E || Banpresto
|-
| $10 || Jaleco
|-
| $11 || Imagineer
|-
| $12 || Konami
|-
| $16 || Kobunsha
|-
| $17 || Bottom Up
|-
| $18 || ?
|-
| $19 || Sunrise
|-
| $1A || Cyber Front
|-
| $1B || Megahouse
|-
| $1D || Interbec
|-
| $1E || ?
|-
| $1F || ?
|-
| $20 || Athena
|-
| $21 || KID
|-
| $22 || ?
|-
| $23 || ?
|-
| $24 || Omega Micott
|-
| $25 || ?
|-
| $26 || ?
|-
| $27 || ?
|-
| $28 || Squaresoft
|-
| $2A || ?
|-
| $2B || ?
|-
| $2D || Namco
|-
| $2E || ?
|-
| $2F || ?
|-
| $31 || ?
|-
| $32 || ?
|-
| $33 || ?
|-
| $36 || ?
|}
Note that IDs $00 and $01 are used across a variety of commercial games. Homebrew is known to use arbitrary values in this field.
=== $7 - Color ===
<pre>
???????c
+- 0 = Monochrome only, 1 = Supports Color mode.
</pre>
=== $9 - Game version? / Safe mode ===
<pre>
pvvvvvvv
|+++++++- Game version?
+-------- Internal EEPROM write protect: 0 = Enable, 1 = Disable.
This prohibits writing to the internal EEPROM for addresses
0x60 and above (user settings, custom splash screen).
Games are expected to enable write protection; however, the
WonderWitch is factory configured with it disabled.
</pre>
=== $A - ROM size ===
Unofficial ROM size values are marked in ''italic''.
{| class="wikitable"
|+ ROM size values
|-
! ID !! Size
|-
| ''$00'' || ''1 Mbit (128 KiB)''
|-
| ''$01'' || ''2 Mbit (256 KiB)''
|-
| $02 || 4 Mbit (512 KiB)
|-
| $03 || 8 Mbit (1 MiB)
|-
| $04 || 16 Mbit (2 MiB)
|-
| ''$05'' || ''24 Mbit (3 MiB)''
|-
| $06 || 32 Mbit (4 MiB)
|-
| ''$07'' || ''48 Mbit (6 MiB)''
|-
| $08 || 64 Mbit (8 MiB)
|-
| $09 || 128 Mbit (16 MiB)
|-
| ''$0A'' || ''256 Mbit (32 MiB)''<ref name="2003only">Not supported by the [[Bandai 2001]] mapper, which is limited to 16 MiB. The [[Bandai 2003]] mapper is limited to 64 MiB.</ref>
|-
| ''$0B'' || ''512 Mbit (64 MiB)''<ref name="2003only"/>
|}
=== $B - Save type/size ===
{| class="wikitable"
|+ Save type values
|-
! ID !! Type !! Size
|-
| $00 || colspan="2" style="text-align:center;" | None
|-
| $01 || rowspan="5" | SRAM || 64 Kbit (8 KiB)
|-
| $02 || 256 Kbit (32 KiB)
|-
| $03 || 1 Mbit (128 KiB)
|-
| $04 || 2 Mbit (256 KiB)
|-
| $05 || 4 Mbit (512 KiB)
|-
| $10 || rowspan="3" | EEPROM || 1 Kbit (128 B)
|-
| $20 || 16 Kbit (2 KiB)
|-
| $50 || 8 Kbit (1 KiB)
|}
=== $C - Flags ===
<pre>
?????SBv
||+- Starting screen orientation: 0 = Horizontal, 1 = Vertical.
|| Controls the splash screen's orientation.
|+-- ROM bus width: 0 = 16-bit, 1 = 8-bit.
+--- ROM access time: 0 = 3 CPU cycles, 1 = 1 CPU cycle.
</pre>
=== $D - Mapper type ===
{| class="wikitable"
|+ Known mapper types
|-
! ID !! Mapper
|-
| $00 || [[Bandai 2001]]
|-
| $01 || [[Bandai 2003]]
|-
| $02 || [[KARNAK]] (Pocket Challenge V2)
|}
f4cf7c069d1cce48e80e1b798b3f4746c8d3182f
11
9
2023-08-15T06:11:55Z
Fiskbit
37
Adds byte bit markings.
wikitext
text/x-wiki
Every WonderSwan ROM contains a header. It is stored at the end - final sixteen bytes - of the ROM image.
== ROM header ==
Parts of this header are validated or otherwise used by the console's [[boot ROM]] - they are marked in '''bold'''.
{| class="wikitable"
|+ Header contents
|-
! Offset !! Length !! Contents
|-
| '''$0''' || '''5''' || Far jump instruction: '''0xEA''', offset, segment.
|-
| '''$5''' || '''1''' || '''Maintenance'''
|-
| $6 || 1 || Developer/Publisher ID
|-
| $7 || 1 || Color
|-
| $8 || 1 || Game ID (binary-coded decimal)
|-
| '''$9''' || '''1''' || '''Game version? / Safe mode'''
|-
| $A || 1 || ROM size
|-
| $B || 1 || Save type/size
|-
| '''$C''' || '''1''' || '''Flags'''
|-
| $D || 1 || Mapper type
|-
| $E || 2 || Checksum (sum of all ROM bytes excluding the checksum)
|}
=== $5 - Maintenance ===
<pre>
7 bit 0
---- ----
s... 0000
| ||||
| ++++- Must be zero; otherwise the console will prohibit execution.
| Purpose unknown.
+--------- (Color) Splash bypass: 0 = Disable, 1 = Enable.
Bypasses the custom boot splash stored in the console's
internal EEPROM; presumably used for bricked console recovery.
</pre>
=== $6 - Developer/Publisher ID ===
{| class="wikitable"
|+ Known official developer/publisher IDs
|-
! ID !! Publisher
|-
| $01 || Bandai
|-
| $02 || Taito
|-
| $03 || ?
|-
| $04 || Koei
|-
| $05 || Data East
|-
| $06 || Asmik Ace
|-
| $07 || Media Entertainment
|-
| $08 || Nichibutsu
|-
| $0A || Coconuts Japan
|-
| $0B || Sammy
|-
| $0C || Sunsoft
|-
| $0D || ?
|-
| $0E || Banpresto
|-
| $10 || Jaleco
|-
| $11 || Imagineer
|-
| $12 || Konami
|-
| $16 || Kobunsha
|-
| $17 || Bottom Up
|-
| $18 || ?
|-
| $19 || Sunrise
|-
| $1A || Cyber Front
|-
| $1B || Megahouse
|-
| $1D || Interbec
|-
| $1E || ?
|-
| $1F || ?
|-
| $20 || Athena
|-
| $21 || KID
|-
| $22 || ?
|-
| $23 || ?
|-
| $24 || Omega Micott
|-
| $25 || ?
|-
| $26 || ?
|-
| $27 || ?
|-
| $28 || Squaresoft
|-
| $2A || ?
|-
| $2B || ?
|-
| $2D || Namco
|-
| $2E || ?
|-
| $2F || ?
|-
| $31 || ?
|-
| $32 || ?
|-
| $33 || ?
|-
| $36 || ?
|}
Note that IDs $00 and $01 are used across a variety of commercial games. Homebrew is known to use arbitrary values in this field.
=== $7 - Color ===
<pre>
7 bit 0
---- ----
???? ???c
|
+- 0 = Monochrome only, 1 = Supports Color mode.
</pre>
=== $9 - Game version? / Safe mode ===
<pre>
7 bit 0
---- ----
pvvv vvvv
|||| ||||
|+++ ++++- Game version?
+--------- Internal EEPROM write protect: 0 = Enable, 1 = Disable.
This prohibits writing to the internal EEPROM for addresses
0x60 and above (user settings, custom splash screen).
Games are expected to enable write protection; however, the
WonderWitch is factory configured with it disabled.
</pre>
=== $A - ROM size ===
Unofficial ROM size values are marked in ''italic''.
{| class="wikitable"
|+ ROM size values
|-
! ID !! Size
|-
| ''$00'' || ''1 Mbit (128 KiB)''
|-
| ''$01'' || ''2 Mbit (256 KiB)''
|-
| $02 || 4 Mbit (512 KiB)
|-
| $03 || 8 Mbit (1 MiB)
|-
| $04 || 16 Mbit (2 MiB)
|-
| ''$05'' || ''24 Mbit (3 MiB)''
|-
| $06 || 32 Mbit (4 MiB)
|-
| ''$07'' || ''48 Mbit (6 MiB)''
|-
| $08 || 64 Mbit (8 MiB)
|-
| $09 || 128 Mbit (16 MiB)
|-
| ''$0A'' || ''256 Mbit (32 MiB)''<ref name="2003only">Not supported by the [[Bandai 2001]] mapper, which is limited to 16 MiB. The [[Bandai 2003]] mapper is limited to 64 MiB.</ref>
|-
| ''$0B'' || ''512 Mbit (64 MiB)''<ref name="2003only"/>
|}
=== $B - Save type/size ===
{| class="wikitable"
|+ Save type values
|-
! ID !! Type !! Size
|-
| $00 || colspan="2" style="text-align:center;" | None
|-
| $01 || rowspan="5" | SRAM || 64 Kbit (8 KiB)
|-
| $02 || 256 Kbit (32 KiB)
|-
| $03 || 1 Mbit (128 KiB)
|-
| $04 || 2 Mbit (256 KiB)
|-
| $05 || 4 Mbit (512 KiB)
|-
| $10 || rowspan="3" | EEPROM || 1 Kbit (128 B)
|-
| $20 || 16 Kbit (2 KiB)
|-
| $50 || 8 Kbit (1 KiB)
|}
=== $C - Flags ===
<pre>
7 bit 0
---- ----
???? ?SBv
|||
||+- Starting screen orientation: 0 = Horizontal, 1 = Vertical.
|| Controls the splash screen's orientation.
|+-- ROM bus width: 0 = 16-bit, 1 = 8-bit.
+--- ROM access time: 0 = 3 CPU cycles, 1 = 1 CPU cycle.
</pre>
=== $D - Mapper type ===
{| class="wikitable"
|+ Known mapper types
|-
! ID !! Mapper
|-
| $00 || [[Bandai 2001]]
|-
| $01 || [[Bandai 2003]]
|-
| $02 || [[KARNAK]] (Pocket Challenge V2)
|}
d49fc9d8b2d6d10c390e8679f09105ad969e5894
12
11
2023-08-15T06:14:59Z
Fiskbit
37
Manually adds horizontal lines to try to break up the page a bit.
wikitext
text/x-wiki
Every WonderSwan ROM contains a header. It is stored at the end - final sixteen bytes - of the ROM image.
== ROM header ==
Parts of this header are validated or otherwise used by the console's [[boot ROM]] - they are marked in '''bold'''.
{| class="wikitable"
|+ Header contents
|-
! Offset !! Length !! Contents
|-
| '''$0''' || '''5''' || Far jump instruction: '''0xEA''', offset, segment.
|-
| '''$5''' || '''1''' || '''Maintenance'''
|-
| $6 || 1 || Developer/Publisher ID
|-
| $7 || 1 || Color
|-
| $8 || 1 || Game ID (binary-coded decimal)
|-
| '''$9''' || '''1''' || '''Game version? / Safe mode'''
|-
| $A || 1 || ROM size
|-
| $B || 1 || Save type/size
|-
| '''$C''' || '''1''' || '''Flags'''
|-
| $D || 1 || Mapper type
|-
| $E || 2 || Checksum (sum of all ROM bytes excluding the checksum)
|}
=== $5 - Maintenance ===
----
<pre>
7 bit 0
---- ----
s... 0000
| ||||
| ++++- Must be zero; otherwise the console will prohibit execution.
| Purpose unknown.
+--------- (Color) Splash bypass: 0 = Disable, 1 = Enable.
Bypasses the custom boot splash stored in the console's
internal EEPROM; presumably used for bricked console recovery.
</pre>
=== $6 - Developer/Publisher ID ===
----
{| class="wikitable"
|+ Known official developer/publisher IDs
|-
! ID !! Publisher
|-
| $01 || Bandai
|-
| $02 || Taito
|-
| $03 || ?
|-
| $04 || Koei
|-
| $05 || Data East
|-
| $06 || Asmik Ace
|-
| $07 || Media Entertainment
|-
| $08 || Nichibutsu
|-
| $0A || Coconuts Japan
|-
| $0B || Sammy
|-
| $0C || Sunsoft
|-
| $0D || ?
|-
| $0E || Banpresto
|-
| $10 || Jaleco
|-
| $11 || Imagineer
|-
| $12 || Konami
|-
| $16 || Kobunsha
|-
| $17 || Bottom Up
|-
| $18 || ?
|-
| $19 || Sunrise
|-
| $1A || Cyber Front
|-
| $1B || Megahouse
|-
| $1D || Interbec
|-
| $1E || ?
|-
| $1F || ?
|-
| $20 || Athena
|-
| $21 || KID
|-
| $22 || ?
|-
| $23 || ?
|-
| $24 || Omega Micott
|-
| $25 || ?
|-
| $26 || ?
|-
| $27 || ?
|-
| $28 || Squaresoft
|-
| $2A || ?
|-
| $2B || ?
|-
| $2D || Namco
|-
| $2E || ?
|-
| $2F || ?
|-
| $31 || ?
|-
| $32 || ?
|-
| $33 || ?
|-
| $36 || ?
|}
Note that IDs $00 and $01 are used across a variety of commercial games. Homebrew is known to use arbitrary values in this field.
=== $7 - Color ===
----
<pre>
7 bit 0
---- ----
???? ???c
|
+- 0 = Monochrome only, 1 = Supports Color mode.
</pre>
=== $9 - Game version? / Safe mode ===
----
<pre>
7 bit 0
---- ----
pvvv vvvv
|||| ||||
|+++ ++++- Game version?
+--------- Internal EEPROM write protect: 0 = Enable, 1 = Disable.
This prohibits writing to the internal EEPROM for addresses
0x60 and above (user settings, custom splash screen).
Games are expected to enable write protection; however, the
WonderWitch is factory configured with it disabled.
</pre>
=== $A - ROM size ===
----
Unofficial ROM size values are marked in ''italic''.
{| class="wikitable"
|+ ROM size values
|-
! ID !! Size
|-
| ''$00'' || ''1 Mbit (128 KiB)''
|-
| ''$01'' || ''2 Mbit (256 KiB)''
|-
| $02 || 4 Mbit (512 KiB)
|-
| $03 || 8 Mbit (1 MiB)
|-
| $04 || 16 Mbit (2 MiB)
|-
| ''$05'' || ''24 Mbit (3 MiB)''
|-
| $06 || 32 Mbit (4 MiB)
|-
| ''$07'' || ''48 Mbit (6 MiB)''
|-
| $08 || 64 Mbit (8 MiB)
|-
| $09 || 128 Mbit (16 MiB)
|-
| ''$0A'' || ''256 Mbit (32 MiB)''<ref name="2003only">Not supported by the [[Bandai 2001]] mapper, which is limited to 16 MiB. The [[Bandai 2003]] mapper is limited to 64 MiB.</ref>
|-
| ''$0B'' || ''512 Mbit (64 MiB)''<ref name="2003only"/>
|}
=== $B - Save type/size ===
----
{| class="wikitable"
|+ Save type values
|-
! ID !! Type !! Size
|-
| $00 || colspan="2" style="text-align:center;" | None
|-
| $01 || rowspan="5" | SRAM || 64 Kbit (8 KiB)
|-
| $02 || 256 Kbit (32 KiB)
|-
| $03 || 1 Mbit (128 KiB)
|-
| $04 || 2 Mbit (256 KiB)
|-
| $05 || 4 Mbit (512 KiB)
|-
| $10 || rowspan="3" | EEPROM || 1 Kbit (128 B)
|-
| $20 || 16 Kbit (2 KiB)
|-
| $50 || 8 Kbit (1 KiB)
|}
=== $C - Flags ===
----
<pre>
7 bit 0
---- ----
???? ?SBv
|||
||+- Starting screen orientation: 0 = Horizontal, 1 = Vertical.
|| Controls the splash screen's orientation.
|+-- ROM bus width: 0 = 16-bit, 1 = 8-bit.
+--- ROM access time: 0 = 3 CPU cycles, 1 = 1 CPU cycle.
</pre>
=== $D - Mapper type ===
----
{| class="wikitable"
|+ Known mapper types
|-
! ID !! Mapper
|-
| $00 || [[Bandai 2001]]
|-
| $01 || [[Bandai 2003]]
|-
| $02 || [[KARNAK]] (Pocket Challenge V2)
|}
fa0f7ba0dbbbb05654a5132b6c4cae654497fa41
14
12
2023-08-15T06:18:21Z
Asie
351
remove references in ROM type section
wikitext
text/x-wiki
Every WonderSwan ROM contains a header. It is stored at the end - final sixteen bytes - of the ROM image.
== ROM header ==
Parts of this header are validated or otherwise used by the console's [[boot ROM]] - they are marked in '''bold'''.
{| class="wikitable"
|+ Header contents
|-
! Offset !! Length !! Contents
|-
| '''$0''' || '''5''' || Far jump instruction: '''0xEA''', offset, segment.
|-
| '''$5''' || '''1''' || '''Maintenance'''
|-
| $6 || 1 || Developer/Publisher ID
|-
| $7 || 1 || Color
|-
| $8 || 1 || Game ID (binary-coded decimal)
|-
| '''$9''' || '''1''' || '''Game version? / Safe mode'''
|-
| $A || 1 || ROM size
|-
| $B || 1 || Save type/size
|-
| '''$C''' || '''1''' || '''Flags'''
|-
| $D || 1 || Mapper type
|-
| $E || 2 || Checksum (sum of all ROM bytes excluding the checksum)
|}
=== $5 - Maintenance ===
----
<pre>
7 bit 0
---- ----
s... 0000
| ||||
| ++++- Must be zero; otherwise the console will prohibit execution.
| Purpose unknown.
+--------- (Color) Splash bypass: 0 = Disable, 1 = Enable.
Bypasses the custom boot splash stored in the console's
internal EEPROM; presumably used for bricked console recovery.
</pre>
=== $6 - Developer/Publisher ID ===
----
{| class="wikitable"
|+ Known official developer/publisher IDs
|-
! ID !! Publisher
|-
| $01 || Bandai
|-
| $02 || Taito
|-
| $03 || ?
|-
| $04 || Koei
|-
| $05 || Data East
|-
| $06 || Asmik Ace
|-
| $07 || Media Entertainment
|-
| $08 || Nichibutsu
|-
| $0A || Coconuts Japan
|-
| $0B || Sammy
|-
| $0C || Sunsoft
|-
| $0D || ?
|-
| $0E || Banpresto
|-
| $10 || Jaleco
|-
| $11 || Imagineer
|-
| $12 || Konami
|-
| $16 || Kobunsha
|-
| $17 || Bottom Up
|-
| $18 || ?
|-
| $19 || Sunrise
|-
| $1A || Cyber Front
|-
| $1B || Megahouse
|-
| $1D || Interbec
|-
| $1E || ?
|-
| $1F || ?
|-
| $20 || Athena
|-
| $21 || KID
|-
| $22 || ?
|-
| $23 || ?
|-
| $24 || Omega Micott
|-
| $25 || ?
|-
| $26 || ?
|-
| $27 || ?
|-
| $28 || Squaresoft
|-
| $2A || ?
|-
| $2B || ?
|-
| $2D || Namco
|-
| $2E || ?
|-
| $2F || ?
|-
| $31 || ?
|-
| $32 || ?
|-
| $33 || ?
|-
| $36 || ?
|}
Note that IDs $00 and $01 are used across a variety of commercial games. Homebrew is known to use arbitrary values in this field.
=== $7 - Color ===
----
<pre>
7 bit 0
---- ----
???? ???c
|
+- 0 = Monochrome only, 1 = Supports Color mode.
</pre>
=== $9 - Game version? / Safe mode ===
----
<pre>
7 bit 0
---- ----
pvvv vvvv
|||| ||||
|+++ ++++- Game version?
+--------- Internal EEPROM write protect: 0 = Enable, 1 = Disable.
This prohibits writing to the internal EEPROM for addresses
0x60 and above (user settings, custom splash screen).
Games are expected to enable write protection; however, the
WonderWitch is factory configured with it disabled.
</pre>
=== $A - ROM size ===
----
Unofficial ROM size values are marked in ''italic''.
{| class="wikitable"
|+ ROM size values
|-
! ID !! Size
|-
| ''$00'' || ''1 Mbit (128 KiB)''
|-
| ''$01'' || ''2 Mbit (256 KiB)''
|-
| $02 || 4 Mbit (512 KiB)
|-
| $03 || 8 Mbit (1 MiB)
|-
| $04 || 16 Mbit (2 MiB)
|-
| ''$05'' || ''24 Mbit (3 MiB)''
|-
| $06 || 32 Mbit (4 MiB)
|-
| ''$07'' || ''48 Mbit (6 MiB)''
|-
| $08 || 64 Mbit (8 MiB)
|-
| $09 || 128 Mbit (16 MiB)
|-
| ''$0A'' || ''256 Mbit (32 MiB)''
|-
| ''$0B'' || ''512 Mbit (64 MiB)''
|}
Note that ROM sizes over 16 MiB are not supported by the [[Bandai 2001]] mapperr. The [[Bandai 2003]] mapper is limited to 64 MiB.
=== $B - Save type/size ===
----
{| class="wikitable"
|+ Save type values
|-
! ID !! Type !! Size
|-
| $00 || colspan="2" style="text-align:center;" | None
|-
| $01 || rowspan="5" | SRAM || 64 Kbit (8 KiB)
|-
| $02 || 256 Kbit (32 KiB)
|-
| $03 || 1 Mbit (128 KiB)
|-
| $04 || 2 Mbit (256 KiB)
|-
| $05 || 4 Mbit (512 KiB)
|-
| $10 || rowspan="3" | EEPROM || 1 Kbit (128 B)
|-
| $20 || 16 Kbit (2 KiB)
|-
| $50 || 8 Kbit (1 KiB)
|}
=== $C - Flags ===
----
<pre>
7 bit 0
---- ----
???? ?SBv
|||
||+- Starting screen orientation: 0 = Horizontal, 1 = Vertical.
|| Controls the splash screen's orientation.
|+-- ROM bus width: 0 = 16-bit, 1 = 8-bit.
+--- ROM access time: 0 = 3 CPU cycles, 1 = 1 CPU cycle.
</pre>
=== $D - Mapper type ===
----
{| class="wikitable"
|+ Known mapper types
|-
! ID !! Mapper
|-
| $00 || [[Bandai 2001]]
|-
| $01 || [[Bandai 2003]]
|-
| $02 || [[KARNAK]] (Pocket Challenge V2)
|}
eb6c403dab6aaac4f237252f252f389cf14f73e6
15
14
2023-08-15T06:18:32Z
Asie
351
fix typo
wikitext
text/x-wiki
Every WonderSwan ROM contains a header. It is stored at the end - final sixteen bytes - of the ROM image.
== ROM header ==
Parts of this header are validated or otherwise used by the console's [[boot ROM]] - they are marked in '''bold'''.
{| class="wikitable"
|+ Header contents
|-
! Offset !! Length !! Contents
|-
| '''$0''' || '''5''' || Far jump instruction: '''0xEA''', offset, segment.
|-
| '''$5''' || '''1''' || '''Maintenance'''
|-
| $6 || 1 || Developer/Publisher ID
|-
| $7 || 1 || Color
|-
| $8 || 1 || Game ID (binary-coded decimal)
|-
| '''$9''' || '''1''' || '''Game version? / Safe mode'''
|-
| $A || 1 || ROM size
|-
| $B || 1 || Save type/size
|-
| '''$C''' || '''1''' || '''Flags'''
|-
| $D || 1 || Mapper type
|-
| $E || 2 || Checksum (sum of all ROM bytes excluding the checksum)
|}
=== $5 - Maintenance ===
----
<pre>
7 bit 0
---- ----
s... 0000
| ||||
| ++++- Must be zero; otherwise the console will prohibit execution.
| Purpose unknown.
+--------- (Color) Splash bypass: 0 = Disable, 1 = Enable.
Bypasses the custom boot splash stored in the console's
internal EEPROM; presumably used for bricked console recovery.
</pre>
=== $6 - Developer/Publisher ID ===
----
{| class="wikitable"
|+ Known official developer/publisher IDs
|-
! ID !! Publisher
|-
| $01 || Bandai
|-
| $02 || Taito
|-
| $03 || ?
|-
| $04 || Koei
|-
| $05 || Data East
|-
| $06 || Asmik Ace
|-
| $07 || Media Entertainment
|-
| $08 || Nichibutsu
|-
| $0A || Coconuts Japan
|-
| $0B || Sammy
|-
| $0C || Sunsoft
|-
| $0D || ?
|-
| $0E || Banpresto
|-
| $10 || Jaleco
|-
| $11 || Imagineer
|-
| $12 || Konami
|-
| $16 || Kobunsha
|-
| $17 || Bottom Up
|-
| $18 || ?
|-
| $19 || Sunrise
|-
| $1A || Cyber Front
|-
| $1B || Megahouse
|-
| $1D || Interbec
|-
| $1E || ?
|-
| $1F || ?
|-
| $20 || Athena
|-
| $21 || KID
|-
| $22 || ?
|-
| $23 || ?
|-
| $24 || Omega Micott
|-
| $25 || ?
|-
| $26 || ?
|-
| $27 || ?
|-
| $28 || Squaresoft
|-
| $2A || ?
|-
| $2B || ?
|-
| $2D || Namco
|-
| $2E || ?
|-
| $2F || ?
|-
| $31 || ?
|-
| $32 || ?
|-
| $33 || ?
|-
| $36 || ?
|}
Note that IDs $00 and $01 are used across a variety of commercial games. Homebrew is known to use arbitrary values in this field.
=== $7 - Color ===
----
<pre>
7 bit 0
---- ----
???? ???c
|
+- 0 = Monochrome only, 1 = Supports Color mode.
</pre>
=== $9 - Game version? / Safe mode ===
----
<pre>
7 bit 0
---- ----
pvvv vvvv
|||| ||||
|+++ ++++- Game version?
+--------- Internal EEPROM write protect: 0 = Enable, 1 = Disable.
This prohibits writing to the internal EEPROM for addresses
0x60 and above (user settings, custom splash screen).
Games are expected to enable write protection; however, the
WonderWitch is factory configured with it disabled.
</pre>
=== $A - ROM size ===
----
Unofficial ROM size values are marked in ''italic''.
{| class="wikitable"
|+ ROM size values
|-
! ID !! Size
|-
| ''$00'' || ''1 Mbit (128 KiB)''
|-
| ''$01'' || ''2 Mbit (256 KiB)''
|-
| $02 || 4 Mbit (512 KiB)
|-
| $03 || 8 Mbit (1 MiB)
|-
| $04 || 16 Mbit (2 MiB)
|-
| ''$05'' || ''24 Mbit (3 MiB)''
|-
| $06 || 32 Mbit (4 MiB)
|-
| ''$07'' || ''48 Mbit (6 MiB)''
|-
| $08 || 64 Mbit (8 MiB)
|-
| $09 || 128 Mbit (16 MiB)
|-
| ''$0A'' || ''256 Mbit (32 MiB)''
|-
| ''$0B'' || ''512 Mbit (64 MiB)''
|}
Note that ROM sizes over 16 MiB are not supported by the [[Bandai 2001]] mapper. The [[Bandai 2003]] mapper is limited to 64 MiB.
=== $B - Save type/size ===
----
{| class="wikitable"
|+ Save type values
|-
! ID !! Type !! Size
|-
| $00 || colspan="2" style="text-align:center;" | None
|-
| $01 || rowspan="5" | SRAM || 64 Kbit (8 KiB)
|-
| $02 || 256 Kbit (32 KiB)
|-
| $03 || 1 Mbit (128 KiB)
|-
| $04 || 2 Mbit (256 KiB)
|-
| $05 || 4 Mbit (512 KiB)
|-
| $10 || rowspan="3" | EEPROM || 1 Kbit (128 B)
|-
| $20 || 16 Kbit (2 KiB)
|-
| $50 || 8 Kbit (1 KiB)
|}
=== $C - Flags ===
----
<pre>
7 bit 0
---- ----
???? ?SBv
|||
||+- Starting screen orientation: 0 = Horizontal, 1 = Vertical.
|| Controls the splash screen's orientation.
|+-- ROM bus width: 0 = 16-bit, 1 = 8-bit.
+--- ROM access time: 0 = 3 CPU cycles, 1 = 1 CPU cycle.
</pre>
=== $D - Mapper type ===
----
{| class="wikitable"
|+ Known mapper types
|-
! ID !! Mapper
|-
| $00 || [[Bandai 2001]]
|-
| $01 || [[Bandai 2003]]
|-
| $02 || [[KARNAK]] (Pocket Challenge V2)
|}
d71bd563a6e4fd796717380ef1d8c461dfa31d70
27
15
2023-08-18T08:42:19Z
Asie
351
add missing developer/publisher IDs (from up-n-atom)
wikitext
text/x-wiki
Every WonderSwan ROM contains a header. It is stored at the end - final sixteen bytes - of the ROM image.
== ROM header ==
Parts of this header are validated or otherwise used by the console's [[boot ROM]] - they are marked in '''bold'''.
{| class="wikitable"
|+ Header contents
|-
! Offset !! Length !! Contents
|-
| '''$0''' || '''5''' || Far jump instruction: '''0xEA''', offset, segment.
|-
| '''$5''' || '''1''' || '''Maintenance'''
|-
| $6 || 1 || Developer/Publisher ID
|-
| $7 || 1 || Color
|-
| $8 || 1 || Game ID (binary-coded decimal)
|-
| '''$9''' || '''1''' || '''Game version? / Safe mode'''
|-
| $A || 1 || ROM size
|-
| $B || 1 || Save type/size
|-
| '''$C''' || '''1''' || '''Flags'''
|-
| $D || 1 || Mapper type
|-
| $E || 2 || Checksum (sum of all ROM bytes excluding the checksum)
|}
=== $5 - Maintenance ===
----
<pre>
7 bit 0
---- ----
s... 0000
| ||||
| ++++- Must be zero; otherwise the console will prohibit execution.
| Purpose unknown.
+--------- (Color) Splash bypass: 0 = Disable, 1 = Enable.
Bypasses the custom boot splash stored in the console's
internal EEPROM; presumably used for bricked console recovery.
</pre>
=== $6 - Developer/Publisher ID ===
----
{| class="wikitable"
|+ Known official developer/publisher IDs
|-
! ID !! Publisher code !! Publisher
|-
| $01 || BAN || Bandai
|-
| $02 || TAT || Taito
|-
| $03 || TMY || Tomy
|-
| $04 || KEX || Koei
|-
| $05 || DTE || Data East
|-
| $06 || AAE || Asmik Ace
|-
| $07 || MDE || Media Entertainment
|-
| $08 || NHB || Nichibutsu
|-
| $0A || CCJ || Coconuts Japan
|-
| $0B || SUM || Sammy
|-
| $0C || SUN || Sunsoft
|-
| $0D || PAW || Mebius
|-
| $0E || BPR || Banpresto
|-
| $10 || JLC || Jaleco
|-
| $11 || MGA || Imagineer
|-
| $12 || KNM || Konami
|-
| $16 || KBS || Kobunsha
|-
| $17 || BTM || Bottom Up
|-
| $18 || KGT || Kaga Tech
|-
| $19 || SRV || Sunrise
|-
| $1A || CFT || Cyber Front
|-
| $1B || MGH || Megahouse
|-
| $1D || BEC || Interbec
|-
| $1E || NAP || Nihon Application
|-
| $1F || BVL || Bandai Visual
|-
| $20 || ATN || Athena
|-
| $21 || KDX || KID
|-
| $22 || HAL || HAL Corporation
|-
| $23 || YKE || Yuki Enterprise
|-
| $24 || OMN || Omega Micott
|-
| $25 || LAY || Layup
|-
| $26 || KDK || Kadokawa Shoten
|-
| $27 || SHL || Shall Luck
|-
| $28 || SQR || Squaresoft
|-
| $2A || SCC || ?
|-
| $2B || TMC || Tom Create
|-
| $2D || NMC || Namco
|-
| $2E || SES || ?
|-
| $2F || HTR || ?
|-
| $31 || VGD || Vanguard
|-
| $32 || MGT || Megatron
|-
| $33 || WIZ || Wiz
|-
| $35 || TAN || Tanita
|-
| $36 || CPC || Capcom
|}
Note that IDs $00 and $01 are used across a variety of commercial games. Homebrew is known to use arbitrary values in this field.
=== $7 - Color ===
----
<pre>
7 bit 0
---- ----
???? ???c
|
+- 0 = Monochrome only, 1 = Supports Color mode.
</pre>
=== $9 - Game version? / Safe mode ===
----
<pre>
7 bit 0
---- ----
pvvv vvvv
|||| ||||
|+++ ++++- Game version?
+--------- Internal EEPROM write protect: 0 = Enable, 1 = Disable.
This prohibits writing to the internal EEPROM for addresses
0x60 and above (user settings, custom splash screen).
Games are expected to enable write protection; however, the
WonderWitch is factory configured with it disabled.
</pre>
=== $A - ROM size ===
----
Unofficial ROM size values are marked in ''italic''.
{| class="wikitable"
|+ ROM size values
|-
! ID !! Size
|-
| ''$00'' || ''1 Mbit (128 KiB)''
|-
| ''$01'' || ''2 Mbit (256 KiB)''
|-
| $02 || 4 Mbit (512 KiB)
|-
| $03 || 8 Mbit (1 MiB)
|-
| $04 || 16 Mbit (2 MiB)
|-
| ''$05'' || ''24 Mbit (3 MiB)''
|-
| $06 || 32 Mbit (4 MiB)
|-
| ''$07'' || ''48 Mbit (6 MiB)''
|-
| $08 || 64 Mbit (8 MiB)
|-
| $09 || 128 Mbit (16 MiB)
|-
| ''$0A'' || ''256 Mbit (32 MiB)''
|-
| ''$0B'' || ''512 Mbit (64 MiB)''
|}
Note that ROM sizes over 16 MiB are not supported by the [[Bandai 2001]] mapper. The [[Bandai 2003]] mapper is limited to 64 MiB.
=== $B - Save type/size ===
----
{| class="wikitable"
|+ Save type values
|-
! ID !! Type !! Size
|-
| $00 || colspan="2" style="text-align:center;" | None
|-
| $01 || rowspan="5" | SRAM || 64 Kbit (8 KiB)
|-
| $02 || 256 Kbit (32 KiB)
|-
| $03 || 1 Mbit (128 KiB)
|-
| $04 || 2 Mbit (256 KiB)
|-
| $05 || 4 Mbit (512 KiB)
|-
| $10 || rowspan="3" | EEPROM || 1 Kbit (128 B)
|-
| $20 || 16 Kbit (2 KiB)
|-
| $50 || 8 Kbit (1 KiB)
|}
=== $C - Flags ===
----
<pre>
7 bit 0
---- ----
???? ?SBv
|||
||+- Starting screen orientation: 0 = Horizontal, 1 = Vertical.
|| Controls the splash screen's orientation.
|+-- ROM bus width: 0 = 16-bit, 1 = 8-bit.
+--- ROM access time: 0 = 3 CPU cycles, 1 = 1 CPU cycle.
</pre>
=== $D - Mapper type ===
----
{| class="wikitable"
|+ Known mapper types
|-
! ID !! Mapper
|-
| $00 || [[Bandai 2001]]
|-
| $01 || [[Bandai 2003]]
|-
| $02 || [[KARNAK]] (Pocket Challenge V2)
|}
e48ca0e20772b24b508358358f7db5a544b2f78f
WonderWitch .fx files
0
6
13
2023-08-15T06:17:13Z
Asie
351
Created page with "[[FreyaOS]] uses [[XMODEM]] transfers to send and receive files through the serial port. These transfers do not include any file metadata by default - such as the file's name, size, permissions or creation date. As such, .fx files are used - binary files with a special 128-byte header<ref>XMODEM transfers are performed in 128-byte blocks; this allows fetching the file's metadata as the first block</ref>. == Format == {| class="wikitable" |+ Header contents |- ! Offset..."
wikitext
text/x-wiki
[[FreyaOS]] uses [[XMODEM]] transfers to send and receive files through the serial port. These transfers do not include any file metadata by default - such as the file's name, size, permissions or creation date. As such, .fx files are used - binary files with a special 128-byte header<ref>XMODEM transfers are performed in 128-byte blocks; this allows fetching the file's metadata as the first block</ref>.
== Format ==
{| class="wikitable"
|+ Header contents
|-
! Offset !! Length !! Contents
|-
| $00 || 4 || Magic string: <code>#!ws</code>
|-
| $04 || 60 || Padding; unused.
|-
| $40 || 16 || File name; zero-terminated Shift-JIS string.
|-
| $50 || 24 || User-friendly file name; zero-terminated Shift-JIS string.
FreyaOS displays the first 12 characters in its file selector.
|-
| $68 || 4 || ?
|-
| $6C || 4 || Total file size, in bytes, excluding the header.
|-
| $70 || 2 || XMODEM chunk count - above file size divided by 128, then rounded up.
|-
| $72 || 2 || File mode
|-
| $74 || 4 || Modification time - seconds since January 1st, 2000.
|-
| $78 || 4 || ?
|-
| $7C || 4 || Offset to resource data, bytes excluding header; -1 if not present.
|}
=== File mode ===
----
<pre>
15 bit 0
---- ---- ---- ----
???? ???? ??i? ?rwx
| ||+- Execute
| |+-- Write
| +--- Read
+------- Intermediate library
</pre>
4aea7eb5b6d30ce32c95c383a36adfbf5703174f
16
13
2023-08-15T06:19:02Z
Asie
351
clarify padding format
wikitext
text/x-wiki
[[FreyaOS]] uses [[XMODEM]] transfers to send and receive files through the serial port. These transfers do not include any file metadata by default - such as the file's name, size, permissions or creation date. As such, .fx files are used - binary files with a special 128-byte header<ref>XMODEM transfers are performed in 128-byte blocks; this allows fetching the file's metadata as the first block</ref>.
== Format ==
{| class="wikitable"
|+ Header contents
|-
! Offset !! Length !! Contents
|-
| $00 || 4 || Magic string: <code>#!ws</code>
|-
| $04 || 60 || Padding; typically 0xFF.
|-
| $40 || 16 || File name; zero-terminated Shift-JIS string.
|-
| $50 || 24 || User-friendly file name; zero-terminated Shift-JIS string.
FreyaOS displays the first 12 characters in its file selector.
|-
| $68 || 4 || ?
|-
| $6C || 4 || Total file size, in bytes, excluding the header.
|-
| $70 || 2 || XMODEM chunk count - above file size divided by 128, then rounded up.
|-
| $72 || 2 || File mode
|-
| $74 || 4 || Modification time - seconds since January 1st, 2000.
|-
| $78 || 4 || ?
|-
| $7C || 4 || Offset to resource data, bytes excluding header; -1 if not present.
|}
=== File mode ===
----
<pre>
15 bit 0
---- ---- ---- ----
???? ???? ??i? ?rwx
| ||+- Execute
| |+-- Write
| +--- Read
+------- Intermediate library
</pre>
aadb0b65daa3b66207b9d9e69ce04a847f834fd3
Timing
0
7
18
2023-08-15T13:17:54Z
Asie
351
Created page with "== Clocks == The WonderSwan is clocked with a master clock of approximately 12288000 Hz (= 12.288 MHz). This clock is split into four internal memory access quadrants, running at 3072000 Hz (= 3.072 MHz) each. Three of those are used by the console in "mono" mode: [[CPU|NEC V30MZ]], [[Display]] and [[Sound]]. On the WonderSwan Color, the fourth quadrant is used to handle color palette reads during display drawing. Out of those, only the CPU quadrant can access the car..."
wikitext
text/x-wiki
== Clocks ==
The WonderSwan is clocked with a master clock of approximately 12288000 Hz (= 12.288 MHz).
This clock is split into four internal memory access quadrants, running at 3072000 Hz (= 3.072 MHz) each. Three of those are used by the console in "mono" mode: [[CPU|NEC V30MZ]], [[Display]] and [[Sound]]. On the WonderSwan Color, the fourth quadrant is used to handle color palette reads during display drawing.
Out of those, only the CPU quadrant can access the cartridge bus. It can be additionally configured to use one of two wait states:
* 1 cycle access - an effective bus speed of 3072000 Hz, same as the CPU,
* 3 cycle access - an effective bus speed of 1024000 Hz.
== Display ==
By default, a WonderSwan frame consists of 159 lines, 144 of which are visible. Each line consists of 256 clock cycles, of which 224 are used to draw a pixel at a time. This leads to a total duration of 40704 clock cycles per frame, for an effective default refresh rate of approximately 75.472 Hz.
ef2d69d3b48f50e99434f7337ecad113a492d7d3
I/O port map
0
8
22
2023-08-16T22:31:29Z
Asie
351
Created page with "* Superscripts are used to mark ports specific to a given mode or platform: ** Color mode: <sup>(color)</sup>. ** WS/WSC/SC console: <sup>(WS)</sup>, <sup>(WSC)</sup>, <sup>(SC)</sup>. * If two Bits rows are provided, the second one refers to the "Color" mode. * The Type can be: R - readable, W - writable, L - writable before boot ROM lockout, 8/16 - width (byte/word). {| class="wikitable" ! Category ! Port ! Description ! Bits ! Type ! Notes |- ! rowspan="45" | Displ..."
wikitext
text/x-wiki
* Superscripts are used to mark ports specific to a given mode or platform:
** Color mode: <sup>(color)</sup>.
** WS/WSC/SC console: <sup>(WS)</sup>, <sup>(WSC)</sup>, <sup>(SC)</sup>.
* If two Bits rows are provided, the second one refers to the "Color" mode.
* The Type can be: R - readable, W - writable, L - writable before boot ROM lockout, 8/16 - width (byte/word).
{| class="wikitable"
! Category
! Port
! Description
! Bits
! Type
! Notes
|-
! rowspan="45" | [[Display]]
! $00
| [[Display#Display Control|Display Control]]
| style="text-align: right" | <tt style="white-space: nowrap">..ow Ws21</tt>
| RW8
|
|-
! $01
| [[Display#Display Background|Display Background]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .sss</tt>
<tt style="white-space: nowrap">pppp iiii</tt>
| RW8
| Shade (s)
Palette (p), Index (i)
|-
! $02
| [[Display#Current Line|Display Current Line]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll</tt>
| R8
| Line (l)
|-
! $03
| [[Display#Interrupt Line|Display Interrupt Line]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll</tt>
| RW8
| Line (l)
|-
! $04
| [[Display#Sprite Table Address|Sprite Table Address]]
| style="text-align: right" | <tt style="white-space: nowrap">...a aaaa</tt>
<tt style="white-space: nowrap">..aa aaaa</tt>
| RW8
| Address >> 9 (a)
|-
! $05
| [[Display#Sprite Table First|Sprite Table First]]
| style="text-align: right" | <tt style="white-space: nowrap">.iii iiii</tt>
| RW8
| Index (i)
|-
! $06
| [[Display#Sprite Table Count|Sprite Table Count]]
| style="text-align: right" | <tt style="white-space: nowrap">cccc cccc</tt>
| RW8
| Count (c)
|-
! $07
| [[Display#Screen Address|Screen Address]]
| style="text-align: right" | <tt style="white-space: nowrap">.222 .111</tt>
<tt style="white-space: nowrap">2222 1111</tt>
| RW8
| Screen 1 address >> 11 (1)
Screen 2 address >> 11 (2)
|-
! $08
| [[Display#Screen 2 Window|Screen 2 Window Left]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $09
| [[Display#Screen 2 Window|Screen 2 Window Top]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $0A
| [[Display#Screen 2 Window|Screen 2 Window Right]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $0B
| [[Display#Screen 2 Window|Screen 2 Window Bottom]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $0B
| [[Display#Sprite Window|Sprite Window Left]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $0C
| [[Display#Sprite Window|Sprite Window Top]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $0E
| [[Display#Sprite Window|Sprite Window Right]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $0F
| [[Display#Sprite Window|Sprite Window Bottom]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $10
| [[Display#Screen Scroll|Screen 1 Scroll X]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $11
| [[Display#Screen Scroll|Screen 1 Scroll Y]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $12
| [[Display#Screen Scroll|Screen 2 Scroll X]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $13
| [[Display#Screen Scroll|Screen 2 Scroll Y]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $14
| [[Display#LCD Control|LCD Control]]
| style="text-align: right" | <tt style="white-space: nowrap">.... ..Ce</tt>
| RW8
| Contrast (C)<sup>(WSC)</sup>, Enable (e)
|-
! $15
| [[Display#LCD Icon Control|LCD Icon Control]]
| style="text-align: right" | <tt style="white-space: nowrap">..32 1hvs</tt>
| RW8
| Auxillary 3 (3), Auxillary 2 (2), Auxillary 1 (1),
Horizontal (h), Vertical (v), Sleep (s)
|-
! $16
| [[Display#LCD Final Line|LCD Final Line]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll</tt>
| RW8
| Line (l)
|-
! $17
| [[Display#LCD Back Porch Line|LCD Back Porch Line]]<sup>(WSC)</sup>
| style="text-align: right" | <tt style="white-space: nowrap">llll llll</tt>
| RW8
| Line (l)
|-
! $1A
| [[Display#LCD Status|LCD Status]]
| style="text-align: right" | <tt style="white-space: nowrap">...v vv.e</tt>
| RW8
| Volume segment status (v), Enable (e)
|-
! $1C
| [[Display#LCD Shade LUT|LCD Shade LUT 0/1]]
| style="text-align: right" | <tt style="white-space: nowrap">1111 0000</tt>
| RW8
| Shade index
|-
! $1D
| [[Display#LCD Shade LUT|LCD Shade LUT 2/3]]
| style="text-align: right" | <tt style="white-space: nowrap">3333 2222</tt>
| RW8
| Shade index
|-
! $1E
| [[Display#LCD Shade LUT|LCD Shade LUT 4/5]]
| style="text-align: right" | <tt style="white-space: nowrap">5555 4444</tt>
| RW8
| Shade index
|-
! $1F
| [[Display#LCD Shade LUT|LCD Shade LUT 6/7]]
| style="text-align: right" | <tt style="white-space: nowrap">7777 6666</tt>
| RW8
| Shade index
|-
! $20
| [[Display#LCD Mono Palette|LCD Mono Palette 0]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $22
| [[Display#LCD Mono Palette|LCD Mono Palette 1]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $24
| [[Display#LCD Mono Palette|LCD Mono Palette 2]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $26
| [[Display#LCD Mono Palette|LCD Mono Palette 3]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $28
| [[Display#LCD Mono Palette|LCD Mono Palette 4]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $2A
| [[Display#LCD Mono Palette|LCD Mono Palette 5]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $2C
| [[Display#LCD Mono Palette|LCD Mono Palette 6]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $2E
| [[Display#LCD Mono Palette|LCD Mono Palette 7]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $30
| [[Display#LCD Mono Palette|LCD Mono Palette 8]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $32
| [[Display#LCD Mono Palette|LCD Mono Palette 9]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $34
| [[Display#LCD Mono Palette|LCD Mono Palette 10]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $36
| [[Display#LCD Mono Palette|LCD Mono Palette 11]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $38
| [[Display#LCD Mono Palette|LCD Mono Palette 12]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $3A
| [[Display#LCD Mono Palette|LCD Mono Palette 13]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $3C
| [[Display#LCD Mono Palette|LCD Mono Palette 14]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $3E
| [[Display#LCD Mono Palette|LCD Mono Palette 15]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! rowspan="10" | [[DMA]]<sup>(color)</sup>
! $40
| [[DMA#General DMA|GDMA Source Address Low]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll llll llll</tt>
| RW16
| Linear address, low 16 bits (l)
|-
! $42
| [[DMA#General DMA|GDMA Source Address High]]
| style="text-align: right" | <tt style="white-space: nowrap">.... hhhh</tt>
| RW8
| Linear address, high 4 bits (h)
|-
! $44
| [[DMA#General DMA|GDMA Destination Address]]
| style="text-align: right" | <tt style="white-space: nowrap">aaaa aaaa aaaa aaaa</tt>
| RW16
| IRAM address (a)
|-
! $46
| [[DMA#General DMA|GDMA Length]]
| style="text-align: right" | <tt style="white-space: nowrap">bbbb bbbb bbbb bbbb</tt>
| RW16
| Bytes (b)
|-
! $48
| [[DMA#General DMA|GDMA Control]]
| style="text-align: right" | <tt style="white-space: nowrap">ed.. ....</tt>
| RW8
| Enable (e), Decrement (d)
|-
! $4A
| [[DMA#Sound DMA|SDMA Source Address Low]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll llll llll</tt>
| RW16
| Linear address, low 16 bits (l)
|-
! $4C
| [[DMA#Sound DMA|SDMA Source Address High]]
| style="text-align: right" | <tt style="white-space: nowrap">.... hhhh</tt>
| RW8
| Linear address, high 4 bits (h)
|-
! $4E
| [[DMA#Sound DMA|SDMA Length Low]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll llll llll</tt>
| RW16
| Length, low 16 bits (l)
|-
! $50
| [[DMA#Sound DMA|SDMA Length High]]
| style="text-align: right" | <tt style="white-space: nowrap">.... hhhh</tt>
| RW8
| Length, high 4 bits (h)
|-
! $52
| [[DMA#Sound DMA|SDMA Control]]
| style="text-align: right" | <tt style="white-space: nowrap">ed.t r?ff</tt>
| RW8
| Enable (e), Decrement (d), Target (t),
Repeat (r), Frequency (f)
|-
! rowspan="2" | System<sup>(color)</sup>
! $60
| System Control 2
| style="text-align: right" | <tt style="white-space: nowrap">c4C. ?.??</tt>
| RW8
| Color (c), 4BPP (4), Chunky (C)
|-
! $62
| System Control 3
| style="text-align: right" | <tt style="white-space: nowrap">S... ...p</tt>
| RW8
| SwanCrystal (S), Power off (p)
|-
! rowspan="5" | [[Hyper Voice]]<sup>(color)</sup>
! $64
| Hyper Voice Left Output
| style="text-align: right" | <tt style="white-space: nowrap">ssss ssss ssss ssss</tt>
| W16
| Raw sample (s)
|-
! $66
| Hyper Voice Right Output
| style="text-align: right" | <tt style="white-space: nowrap">ssss ssss ssss ssss</tt>
| W16
| Raw sample (s)
|-
! $68
| Hyper Voice Left Input
| style="text-align: right" | <tt style="white-space: nowrap">ssss ssss</tt>
| 8
| Sample (s)
|-
! $69
| Hyper Voice Right Input
| style="text-align: right" | <tt style="white-space: nowrap">ssss ssss</tt>
| 8
| Sample (s)
|-
! $6A
| Hyper Voice Control
| style="text-align: right" | <tt style="white-space: nowrap">.mmc .... errr ffss</tt>
| RW16
| Mask (m), Channel (c), Enable (e),
Rate (r), Format (f), Shift (s)
|-
! rowspan="8" | [[Display]]<sup>(SC)</sup>
! $70
| LCD Timing Configuration 1?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $71
| LCD Timing Configuration 2?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $72
| LCD Timing Configuration 3?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $73
| LCD Timing Configuration 4?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $74
| LCD Timing Configuration 5?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $75
| LCD Timing Configuration 6?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $76
| LCD Timing Configuration 7?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $77
| LCD Timing Configuration 8?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! rowspan="20" | [[Sound]]
! $80
| Sound Channel 1 Frequency
| style="text-align: right" | <tt style="white-space: nowrap">.... .ddd dddd dddd</tt>
| RW16
| Divider (d)
|-
! $82
| Sound Channel 2 Frequency
| style="text-align: right" | <tt style="white-space: nowrap">.... .ddd dddd dddd</tt>
| RW16
| Divider (d)
|-
! $84
| Sound Channel 3 Frequency
| style="text-align: right" | <tt style="white-space: nowrap">.... .ddd dddd dddd</tt>
| RW16
| Divider (d)
|-
! $86
| Sound Channel 4 Frequency
| style="text-align: right" | <tt style="white-space: nowrap">.... .ddd dddd dddd</tt>
| RW16
| Divider (d)
|-
! $88
| Sound Channel 1 Volume
| style="text-align: right" | <tt style="white-space: nowrap">llll rrrr</tt>
| RW8
| Left (l), Right (r)
|-
! rowspan="2" | $89
| Sound Channel 2 Volume
| style="text-align: right" | <tt style="white-space: nowrap">llll rrrr</tt>
| RW8
| Left (l), Right (r)
|-
| Sound Channel 2 Voice Sample
| style="text-align: right" | <tt style="white-space: nowrap">ssss ssss</tt>
| RW8
| Sample (s)
|-
! $8A
| Sound Channel 3 Volume
| style="text-align: right" | <tt style="white-space: nowrap">llll rrrr</tt>
| RW8
| Left (l), Right (r)
|-
! $8B
| Sound Channel 4 Volume
| style="text-align: right" | <tt style="white-space: nowrap">llll rrrr</tt>
| RW8
| Left (l), Right (r)
|-
! $8C
| Sound Channel 3 Sweep Amount
| style="text-align: right" | <tt style="white-space: nowrap">vvvv vvvv</tt>
| RW8
| Value (v)
|-
! $8D
| Sound Channel 3 Sweep Ticks
| style="text-align: right" | <tt style="white-space: nowrap">...t tttt</tt>
| RW8
| Ticks (t)
|-
! $8E
| Sound Channel 4 Noise Control
| style="text-align: right" | <tt style="white-space: nowrap">...e rttt</tt>
| RW8
| Enable (e), Reset (r), Tap (t)
|-
! $8F
| Sound Wavetable Address
| style="text-align: right" | <tt style="white-space: nowrap">wwww wwww</tt>
| RW8
| Address >> 6 (w)
|-
! $90
| Sound Channel Control
| style="text-align: right" | <tt style="white-space: nowrap">nsv. 4321</tt>
| RW8
| Channel enable (1234)
Noise (n), Sweep (s), Voice (v)
|-
! $91
| Sound Output Control
| style="text-align: right" | <tt style="white-space: nowrap">H... hrrs</tt>
| RW8
| Headphones connected (H)
Headphone output (h)
Speaker output (s), range (r)
|-
! $92
| Sound Channel 4 LFSR
| style="text-align: right" | <tt style="white-space: nowrap">.rrr rrrr rrrr rrrr</tt>
| R16
| PRNG state (r)
|-
! $94
| Sound Channel 2 Voice Volume
| style="text-align: right" | <tt style="white-space: nowrap">.... lLrR</tt>
| RW8
| Left Half (l), Full (L)
Right Half (r), Full (R)
|-
! $96
| Sound Sequencer Output Right
| style="text-align: right" | <tt style="white-space: nowrap">.... ..ss ssss ssss</tt>
| R16
| Sample (s)
|-
! $98
| Sound Sequencer Output Left
| style="text-align: right" | <tt style="white-space: nowrap">.... ..ss ssss ssss</tt>
| R16
| Sample (s)
|-
! $9A
| Sound Sequencer Output Sum
| style="text-align: right" | <tt style="white-space: nowrap">.... .sss ssss ssss</tt>
| R16
| Sample (s)
|-
! System
! $A0
| System Control
| style="text-align: right" | <tt style="white-space: nowrap">t??? swcl</tt>
| RW8
| Test OK (t), ROM speed (s), ROM width (w),
Color system (c), Boot ROM lockout (l)
|-
! rowspan="5" | Timers
! $A2
| Timer Control
| style="text-align: right" | <tt style="white-space: nowrap">.... VvHh</tt>
| RW8
| Horizontal enable (h), auto reload (H)
Vertical enable (v), auto reload (V)
|-
! $A4
| Horizontal Blank Timer Reload
| style="text-align: right" | <tt style="white-space: nowrap">tttt tttt tttt tttt</tt>
| RW16
| Ticks (t)
|-
! $A6
| Vertical Blank Timer Reload
| style="text-align: right" | <tt style="white-space: nowrap">tttt tttt tttt tttt</tt>
| RW16
| Ticks (t)
|-
! $A8
| Horizontal Blank Timer Counter
| style="text-align: right" | <tt style="white-space: nowrap">tttt tttt tttt tttt</tt>
| R16
| Ticks (t)
|-
! $AA
| Vertical Blank Timer Counter
| style="text-align: right" | <tt style="white-space: nowrap">tttt tttt tttt tttt</tt>
| R16
| Ticks (t)
|-
! Interrupts
! $B0
| Interrupt Vector
| style="text-align: right" | <tt style="white-space: nowrap">vvvv v...</tt>
| RW8
| Vector offset (v)
|-
! UART
! $B1
| Serial Data
| style="text-align: right" | <tt style="white-space: nowrap">dddd dddd</tt>
| RW8
| Data (d)
|-
! Interrupts
! $B2
| Interrupt Enable
|
| RW8
|
|-
! UART
! $B3
| Serial Control
| style="text-align: right" | <tt style="white-space: nowrap">ebO. .rot</tt>
| RW8
| Enable (e), Baud rate (b), Reset Overrun (O),
Receive ready (r), Overrun (o), Transfer ready (t)
|-
! Interrupts
! $B4
| Interrupt Status
|
| RW8
|
|-
! Keypad
! $B5
| Keypad
|
| RW8
|
|-
! rowspan="2" | Interrupts
! $B6
| Interrupt Acknowledge
|
| RW8
|
|-
! $B7
| Interrupt NMI Control
| style="text-align: right" | <tt style="white-space: nowrap">...b ....</tt>
| RW8
| Low battery (b)
|-
! rowspan="3" | Internal EEPROM
! $BA
| Internal EEPROM Data
| style="text-align: right" | <tt style="white-space: nowrap">dddd dddd dddd dddd</tt>
| RW16
| Data (d)
|-
! $BC
| Internal EEPROM Command
|
| RW16
|
|-
! $BE
| Internal EEPROM Control
| style="text-align: right" | <tt style="white-space: nowrap">.... .... PEWR ..rd</tt>
| RW16
| Protect (P), Erase (E), Write (W), Read (R),
Ready (r), Done (d)
|-
|}
b361ace8489a13c4588fc34ea6733bfe33c5b64c
23
22
2023-08-16T22:33:04Z
Asie
351
Mono Shade LUT
wikitext
text/x-wiki
* Superscripts are used to mark ports specific to a given mode or platform:
** Color mode: <sup>(color)</sup>.
** WS/WSC/SC console: <sup>(WS)</sup>, <sup>(WSC)</sup>, <sup>(SC)</sup>.
* If two Bits rows are provided, the second one refers to the "Color" mode.
* The Type can be: R - readable, W - writable, L - writable before boot ROM lockout, 8/16 - width (byte/word).
{| class="wikitable"
! Category
! Port
! Description
! Bits
! Type
! Notes
|-
! rowspan="45" | [[Display]]
! $00
| [[Display#Display Control|Display Control]]
| style="text-align: right" | <tt style="white-space: nowrap">..ow Ws21</tt>
| RW8
|
|-
! $01
| [[Display#Display Background|Display Background]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .sss</tt>
<tt style="white-space: nowrap">pppp iiii</tt>
| RW8
| Shade (s)
Palette (p), Index (i)
|-
! $02
| [[Display#Current Line|Display Current Line]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll</tt>
| R8
| Line (l)
|-
! $03
| [[Display#Interrupt Line|Display Interrupt Line]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll</tt>
| RW8
| Line (l)
|-
! $04
| [[Display#Sprite Table Address|Sprite Table Address]]
| style="text-align: right" | <tt style="white-space: nowrap">...a aaaa</tt>
<tt style="white-space: nowrap">..aa aaaa</tt>
| RW8
| Address >> 9 (a)
|-
! $05
| [[Display#Sprite Table First|Sprite Table First]]
| style="text-align: right" | <tt style="white-space: nowrap">.iii iiii</tt>
| RW8
| Index (i)
|-
! $06
| [[Display#Sprite Table Count|Sprite Table Count]]
| style="text-align: right" | <tt style="white-space: nowrap">cccc cccc</tt>
| RW8
| Count (c)
|-
! $07
| [[Display#Screen Address|Screen Address]]
| style="text-align: right" | <tt style="white-space: nowrap">.222 .111</tt>
<tt style="white-space: nowrap">2222 1111</tt>
| RW8
| Screen 1 address >> 11 (1)
Screen 2 address >> 11 (2)
|-
! $08
| [[Display#Screen 2 Window|Screen 2 Window Left]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $09
| [[Display#Screen 2 Window|Screen 2 Window Top]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $0A
| [[Display#Screen 2 Window|Screen 2 Window Right]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $0B
| [[Display#Screen 2 Window|Screen 2 Window Bottom]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $0B
| [[Display#Sprite Window|Sprite Window Left]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $0C
| [[Display#Sprite Window|Sprite Window Top]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $0E
| [[Display#Sprite Window|Sprite Window Right]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $0F
| [[Display#Sprite Window|Sprite Window Bottom]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $10
| [[Display#Screen Scroll|Screen 1 Scroll X]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $11
| [[Display#Screen Scroll|Screen 1 Scroll Y]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $12
| [[Display#Screen Scroll|Screen 2 Scroll X]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $13
| [[Display#Screen Scroll|Screen 2 Scroll Y]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $14
| [[Display#LCD Control|LCD Control]]
| style="text-align: right" | <tt style="white-space: nowrap">.... ..Ce</tt>
| RW8
| Contrast (C)<sup>(WSC)</sup>, Enable (e)
|-
! $15
| [[Display#LCD Icon Control|LCD Icon Control]]
| style="text-align: right" | <tt style="white-space: nowrap">..32 1hvs</tt>
| RW8
| Auxillary 3 (3), Auxillary 2 (2), Auxillary 1 (1),
Horizontal (h), Vertical (v), Sleep (s)
|-
! $16
| [[Display#LCD Final Line|LCD Final Line]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll</tt>
| RW8
| Line (l)
|-
! $17
| [[Display#LCD Back Porch Line|LCD Back Porch Line]]<sup>(WSC)</sup>
| style="text-align: right" | <tt style="white-space: nowrap">llll llll</tt>
| RW8
| Line (l)
|-
! $1A
| [[Display#LCD Status|LCD Status]]
| style="text-align: right" | <tt style="white-space: nowrap">...v vv.e</tt>
| RW8
| Volume segment status (v), Enable (e)
|-
! $1C
| [[Display#LCD Mono Shade LUT|LCD Mono Shade LUT 0/1]]
| style="text-align: right" | <tt style="white-space: nowrap">1111 0000</tt>
| RW8
| Shade index
|-
! $1D
| [[Display#LCD Mono Shade LUT|LCD Mono Shade LUT 2/3]]
| style="text-align: right" | <tt style="white-space: nowrap">3333 2222</tt>
| RW8
| Shade index
|-
! $1E
| [[Display#LCD Mono Shade LUT|LCD Mono Shade LUT 4/5]]
| style="text-align: right" | <tt style="white-space: nowrap">5555 4444</tt>
| RW8
| Shade index
|-
! $1F
| [[Display#LCD Mono Shade LUT|LCD Mono Shade LUT 6/7]]
| style="text-align: right" | <tt style="white-space: nowrap">7777 6666</tt>
| RW8
| Shade index
|-
! $20
| [[Display#LCD Mono Palette|LCD Mono Palette 0]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $22
| [[Display#LCD Mono Palette|LCD Mono Palette 1]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $24
| [[Display#LCD Mono Palette|LCD Mono Palette 2]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $26
| [[Display#LCD Mono Palette|LCD Mono Palette 3]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $28
| [[Display#LCD Mono Palette|LCD Mono Palette 4]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $2A
| [[Display#LCD Mono Palette|LCD Mono Palette 5]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $2C
| [[Display#LCD Mono Palette|LCD Mono Palette 6]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $2E
| [[Display#LCD Mono Palette|LCD Mono Palette 7]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $30
| [[Display#LCD Mono Palette|LCD Mono Palette 8]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $32
| [[Display#LCD Mono Palette|LCD Mono Palette 9]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $34
| [[Display#LCD Mono Palette|LCD Mono Palette 10]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $36
| [[Display#LCD Mono Palette|LCD Mono Palette 11]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $38
| [[Display#LCD Mono Palette|LCD Mono Palette 12]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $3A
| [[Display#LCD Mono Palette|LCD Mono Palette 13]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $3C
| [[Display#LCD Mono Palette|LCD Mono Palette 14]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $3E
| [[Display#LCD Mono Palette|LCD Mono Palette 15]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! rowspan="10" | [[DMA]]<sup>(color)</sup>
! $40
| [[DMA#General DMA|GDMA Source Address Low]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll llll llll</tt>
| RW16
| Linear address, low 16 bits (l)
|-
! $42
| [[DMA#General DMA|GDMA Source Address High]]
| style="text-align: right" | <tt style="white-space: nowrap">.... hhhh</tt>
| RW8
| Linear address, high 4 bits (h)
|-
! $44
| [[DMA#General DMA|GDMA Destination Address]]
| style="text-align: right" | <tt style="white-space: nowrap">aaaa aaaa aaaa aaaa</tt>
| RW16
| IRAM address (a)
|-
! $46
| [[DMA#General DMA|GDMA Length]]
| style="text-align: right" | <tt style="white-space: nowrap">bbbb bbbb bbbb bbbb</tt>
| RW16
| Bytes (b)
|-
! $48
| [[DMA#General DMA|GDMA Control]]
| style="text-align: right" | <tt style="white-space: nowrap">ed.. ....</tt>
| RW8
| Enable (e), Decrement (d)
|-
! $4A
| [[DMA#Sound DMA|SDMA Source Address Low]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll llll llll</tt>
| RW16
| Linear address, low 16 bits (l)
|-
! $4C
| [[DMA#Sound DMA|SDMA Source Address High]]
| style="text-align: right" | <tt style="white-space: nowrap">.... hhhh</tt>
| RW8
| Linear address, high 4 bits (h)
|-
! $4E
| [[DMA#Sound DMA|SDMA Length Low]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll llll llll</tt>
| RW16
| Length, low 16 bits (l)
|-
! $50
| [[DMA#Sound DMA|SDMA Length High]]
| style="text-align: right" | <tt style="white-space: nowrap">.... hhhh</tt>
| RW8
| Length, high 4 bits (h)
|-
! $52
| [[DMA#Sound DMA|SDMA Control]]
| style="text-align: right" | <tt style="white-space: nowrap">ed.t r?ff</tt>
| RW8
| Enable (e), Decrement (d), Target (t),
Repeat (r), Frequency (f)
|-
! rowspan="2" | System<sup>(color)</sup>
! $60
| System Control 2
| style="text-align: right" | <tt style="white-space: nowrap">c4C. ?.??</tt>
| RW8
| Color (c), 4BPP (4), Chunky (C)
|-
! $62
| System Control 3
| style="text-align: right" | <tt style="white-space: nowrap">S... ...p</tt>
| RW8
| SwanCrystal (S), Power off (p)
|-
! rowspan="5" | [[Hyper Voice]]<sup>(color)</sup>
! $64
| Hyper Voice Left Output
| style="text-align: right" | <tt style="white-space: nowrap">ssss ssss ssss ssss</tt>
| W16
| Raw sample (s)
|-
! $66
| Hyper Voice Right Output
| style="text-align: right" | <tt style="white-space: nowrap">ssss ssss ssss ssss</tt>
| W16
| Raw sample (s)
|-
! $68
| Hyper Voice Left Input
| style="text-align: right" | <tt style="white-space: nowrap">ssss ssss</tt>
| 8
| Sample (s)
|-
! $69
| Hyper Voice Right Input
| style="text-align: right" | <tt style="white-space: nowrap">ssss ssss</tt>
| 8
| Sample (s)
|-
! $6A
| Hyper Voice Control
| style="text-align: right" | <tt style="white-space: nowrap">.mmc .... errr ffss</tt>
| RW16
| Mask (m), Channel (c), Enable (e),
Rate (r), Format (f), Shift (s)
|-
! rowspan="8" | [[Display]]<sup>(SC)</sup>
! $70
| LCD Timing Configuration 1?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $71
| LCD Timing Configuration 2?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $72
| LCD Timing Configuration 3?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $73
| LCD Timing Configuration 4?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $74
| LCD Timing Configuration 5?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $75
| LCD Timing Configuration 6?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $76
| LCD Timing Configuration 7?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $77
| LCD Timing Configuration 8?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! rowspan="20" | [[Sound]]
! $80
| Sound Channel 1 Frequency
| style="text-align: right" | <tt style="white-space: nowrap">.... .ddd dddd dddd</tt>
| RW16
| Divider (d)
|-
! $82
| Sound Channel 2 Frequency
| style="text-align: right" | <tt style="white-space: nowrap">.... .ddd dddd dddd</tt>
| RW16
| Divider (d)
|-
! $84
| Sound Channel 3 Frequency
| style="text-align: right" | <tt style="white-space: nowrap">.... .ddd dddd dddd</tt>
| RW16
| Divider (d)
|-
! $86
| Sound Channel 4 Frequency
| style="text-align: right" | <tt style="white-space: nowrap">.... .ddd dddd dddd</tt>
| RW16
| Divider (d)
|-
! $88
| Sound Channel 1 Volume
| style="text-align: right" | <tt style="white-space: nowrap">llll rrrr</tt>
| RW8
| Left (l), Right (r)
|-
! rowspan="2" | $89
| Sound Channel 2 Volume
| style="text-align: right" | <tt style="white-space: nowrap">llll rrrr</tt>
| RW8
| Left (l), Right (r)
|-
| Sound Channel 2 Voice Sample
| style="text-align: right" | <tt style="white-space: nowrap">ssss ssss</tt>
| RW8
| Sample (s)
|-
! $8A
| Sound Channel 3 Volume
| style="text-align: right" | <tt style="white-space: nowrap">llll rrrr</tt>
| RW8
| Left (l), Right (r)
|-
! $8B
| Sound Channel 4 Volume
| style="text-align: right" | <tt style="white-space: nowrap">llll rrrr</tt>
| RW8
| Left (l), Right (r)
|-
! $8C
| Sound Channel 3 Sweep Amount
| style="text-align: right" | <tt style="white-space: nowrap">vvvv vvvv</tt>
| RW8
| Value (v)
|-
! $8D
| Sound Channel 3 Sweep Ticks
| style="text-align: right" | <tt style="white-space: nowrap">...t tttt</tt>
| RW8
| Ticks (t)
|-
! $8E
| Sound Channel 4 Noise Control
| style="text-align: right" | <tt style="white-space: nowrap">...e rttt</tt>
| RW8
| Enable (e), Reset (r), Tap (t)
|-
! $8F
| Sound Wavetable Address
| style="text-align: right" | <tt style="white-space: nowrap">wwww wwww</tt>
| RW8
| Address >> 6 (w)
|-
! $90
| Sound Channel Control
| style="text-align: right" | <tt style="white-space: nowrap">nsv. 4321</tt>
| RW8
| Channel enable (1234)
Noise (n), Sweep (s), Voice (v)
|-
! $91
| Sound Output Control
| style="text-align: right" | <tt style="white-space: nowrap">H... hrrs</tt>
| RW8
| Headphones connected (H)
Headphone output (h)
Speaker output (s), range (r)
|-
! $92
| Sound Channel 4 LFSR
| style="text-align: right" | <tt style="white-space: nowrap">.rrr rrrr rrrr rrrr</tt>
| R16
| PRNG state (r)
|-
! $94
| Sound Channel 2 Voice Volume
| style="text-align: right" | <tt style="white-space: nowrap">.... lLrR</tt>
| RW8
| Left Half (l), Full (L)
Right Half (r), Full (R)
|-
! $96
| Sound Sequencer Output Right
| style="text-align: right" | <tt style="white-space: nowrap">.... ..ss ssss ssss</tt>
| R16
| Sample (s)
|-
! $98
| Sound Sequencer Output Left
| style="text-align: right" | <tt style="white-space: nowrap">.... ..ss ssss ssss</tt>
| R16
| Sample (s)
|-
! $9A
| Sound Sequencer Output Sum
| style="text-align: right" | <tt style="white-space: nowrap">.... .sss ssss ssss</tt>
| R16
| Sample (s)
|-
! System
! $A0
| System Control
| style="text-align: right" | <tt style="white-space: nowrap">t??? swcl</tt>
| RW8
| Test OK (t), ROM speed (s), ROM width (w),
Color system (c), Boot ROM lockout (l)
|-
! rowspan="5" | Timers
! $A2
| Timer Control
| style="text-align: right" | <tt style="white-space: nowrap">.... VvHh</tt>
| RW8
| Horizontal enable (h), auto reload (H)
Vertical enable (v), auto reload (V)
|-
! $A4
| Horizontal Blank Timer Reload
| style="text-align: right" | <tt style="white-space: nowrap">tttt tttt tttt tttt</tt>
| RW16
| Ticks (t)
|-
! $A6
| Vertical Blank Timer Reload
| style="text-align: right" | <tt style="white-space: nowrap">tttt tttt tttt tttt</tt>
| RW16
| Ticks (t)
|-
! $A8
| Horizontal Blank Timer Counter
| style="text-align: right" | <tt style="white-space: nowrap">tttt tttt tttt tttt</tt>
| R16
| Ticks (t)
|-
! $AA
| Vertical Blank Timer Counter
| style="text-align: right" | <tt style="white-space: nowrap">tttt tttt tttt tttt</tt>
| R16
| Ticks (t)
|-
! Interrupts
! $B0
| Interrupt Vector
| style="text-align: right" | <tt style="white-space: nowrap">vvvv v...</tt>
| RW8
| Vector offset (v)
|-
! UART
! $B1
| Serial Data
| style="text-align: right" | <tt style="white-space: nowrap">dddd dddd</tt>
| RW8
| Data (d)
|-
! Interrupts
! $B2
| Interrupt Enable
|
| RW8
|
|-
! UART
! $B3
| Serial Control
| style="text-align: right" | <tt style="white-space: nowrap">ebO. .rot</tt>
| RW8
| Enable (e), Baud rate (b), Reset Overrun (O),
Receive ready (r), Overrun (o), Transfer ready (t)
|-
! Interrupts
! $B4
| Interrupt Status
|
| RW8
|
|-
! Keypad
! $B5
| Keypad
|
| RW8
|
|-
! rowspan="2" | Interrupts
! $B6
| Interrupt Acknowledge
|
| RW8
|
|-
! $B7
| Interrupt NMI Control
| style="text-align: right" | <tt style="white-space: nowrap">...b ....</tt>
| RW8
| Low battery (b)
|-
! rowspan="3" | Internal EEPROM
! $BA
| Internal EEPROM Data
| style="text-align: right" | <tt style="white-space: nowrap">dddd dddd dddd dddd</tt>
| RW16
| Data (d)
|-
! $BC
| Internal EEPROM Command
|
| RW16
|
|-
! $BE
| Internal EEPROM Control
| style="text-align: right" | <tt style="white-space: nowrap">.... .... PEWR ..rd</tt>
| RW16
| Protect (P), Erase (E), Write (W), Read (R),
Ready (r), Done (d)
|-
|}
1f2d621f492beead934b0c7775392bb4b83e27b0
24
23
2023-08-17T09:18:49Z
Asie
351
clarify keypad port
wikitext
text/x-wiki
* Superscripts are used to mark ports specific to a given mode or platform:
** Color mode: <sup>(color)</sup>.
** WS/WSC/SC console: <sup>(WS)</sup>, <sup>(WSC)</sup>, <sup>(SC)</sup>.
* If two Bits rows are provided, the second one refers to the "Color" mode.
* The Type can be: R - readable, W - writable, L - writable before boot ROM lockout, 8/16 - width (byte/word).
{| class="wikitable"
! Category
! Port
! Description
! Bits
! Type
! Notes
|-
! rowspan="45" | [[Display]]
! $00
| [[Display#Display Control|Display Control]]
| style="text-align: right" | <tt style="white-space: nowrap">..ow Ws21</tt>
| RW8
|
|-
! $01
| [[Display#Display Background|Display Background]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .sss</tt>
<tt style="white-space: nowrap">pppp iiii</tt>
| RW8
| Shade (s)
Palette (p), Index (i)
|-
! $02
| [[Display#Current Line|Display Current Line]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll</tt>
| R8
| Line (l)
|-
! $03
| [[Display#Interrupt Line|Display Interrupt Line]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll</tt>
| RW8
| Line (l)
|-
! $04
| [[Display#Sprite Table Address|Sprite Table Address]]
| style="text-align: right" | <tt style="white-space: nowrap">...a aaaa</tt>
<tt style="white-space: nowrap">..aa aaaa</tt>
| RW8
| Address >> 9 (a)
|-
! $05
| [[Display#Sprite Table First|Sprite Table First]]
| style="text-align: right" | <tt style="white-space: nowrap">.iii iiii</tt>
| RW8
| Index (i)
|-
! $06
| [[Display#Sprite Table Count|Sprite Table Count]]
| style="text-align: right" | <tt style="white-space: nowrap">cccc cccc</tt>
| RW8
| Count (c)
|-
! $07
| [[Display#Screen Address|Screen Address]]
| style="text-align: right" | <tt style="white-space: nowrap">.222 .111</tt>
<tt style="white-space: nowrap">2222 1111</tt>
| RW8
| Screen 1 address >> 11 (1)
Screen 2 address >> 11 (2)
|-
! $08
| [[Display#Screen 2 Window|Screen 2 Window Left]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $09
| [[Display#Screen 2 Window|Screen 2 Window Top]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $0A
| [[Display#Screen 2 Window|Screen 2 Window Right]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $0B
| [[Display#Screen 2 Window|Screen 2 Window Bottom]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $0B
| [[Display#Sprite Window|Sprite Window Left]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $0C
| [[Display#Sprite Window|Sprite Window Top]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $0E
| [[Display#Sprite Window|Sprite Window Right]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $0F
| [[Display#Sprite Window|Sprite Window Bottom]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $10
| [[Display#Screen Scroll|Screen 1 Scroll X]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $11
| [[Display#Screen Scroll|Screen 1 Scroll Y]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $12
| [[Display#Screen Scroll|Screen 2 Scroll X]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $13
| [[Display#Screen Scroll|Screen 2 Scroll Y]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $14
| [[Display#LCD Control|LCD Control]]
| style="text-align: right" | <tt style="white-space: nowrap">.... ..Ce</tt>
| RW8
| Contrast (C)<sup>(WSC)</sup>, Enable (e)
|-
! $15
| [[Display#LCD Icon Control|LCD Icon Control]]
| style="text-align: right" | <tt style="white-space: nowrap">..32 1hvs</tt>
| RW8
| Auxillary 3 (3), Auxillary 2 (2), Auxillary 1 (1),
Horizontal (h), Vertical (v), Sleep (s)
|-
! $16
| [[Display#LCD Final Line|LCD Final Line]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll</tt>
| RW8
| Line (l)
|-
! $17
| [[Display#LCD Back Porch Line|LCD Back Porch Line]]<sup>(WSC)</sup>
| style="text-align: right" | <tt style="white-space: nowrap">llll llll</tt>
| RW8
| Line (l)
|-
! $1A
| [[Display#LCD Status|LCD Status]]
| style="text-align: right" | <tt style="white-space: nowrap">...v vv.e</tt>
| RW8
| Volume segment status (v), Enable (e)
|-
! $1C
| [[Display#LCD Mono Shade LUT|LCD Mono Shade LUT 0/1]]
| style="text-align: right" | <tt style="white-space: nowrap">1111 0000</tt>
| RW8
| Shade index
|-
! $1D
| [[Display#LCD Mono Shade LUT|LCD Mono Shade LUT 2/3]]
| style="text-align: right" | <tt style="white-space: nowrap">3333 2222</tt>
| RW8
| Shade index
|-
! $1E
| [[Display#LCD Mono Shade LUT|LCD Mono Shade LUT 4/5]]
| style="text-align: right" | <tt style="white-space: nowrap">5555 4444</tt>
| RW8
| Shade index
|-
! $1F
| [[Display#LCD Mono Shade LUT|LCD Mono Shade LUT 6/7]]
| style="text-align: right" | <tt style="white-space: nowrap">7777 6666</tt>
| RW8
| Shade index
|-
! $20
| [[Display#LCD Mono Palette|LCD Mono Palette 0]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $22
| [[Display#LCD Mono Palette|LCD Mono Palette 1]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $24
| [[Display#LCD Mono Palette|LCD Mono Palette 2]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $26
| [[Display#LCD Mono Palette|LCD Mono Palette 3]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $28
| [[Display#LCD Mono Palette|LCD Mono Palette 4]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $2A
| [[Display#LCD Mono Palette|LCD Mono Palette 5]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $2C
| [[Display#LCD Mono Palette|LCD Mono Palette 6]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $2E
| [[Display#LCD Mono Palette|LCD Mono Palette 7]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $30
| [[Display#LCD Mono Palette|LCD Mono Palette 8]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $32
| [[Display#LCD Mono Palette|LCD Mono Palette 9]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $34
| [[Display#LCD Mono Palette|LCD Mono Palette 10]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $36
| [[Display#LCD Mono Palette|LCD Mono Palette 11]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $38
| [[Display#LCD Mono Palette|LCD Mono Palette 12]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $3A
| [[Display#LCD Mono Palette|LCD Mono Palette 13]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $3C
| [[Display#LCD Mono Palette|LCD Mono Palette 14]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $3E
| [[Display#LCD Mono Palette|LCD Mono Palette 15]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! rowspan="10" | [[DMA]]<sup>(color)</sup>
! $40
| [[DMA#General DMA|GDMA Source Address Low]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll llll llll</tt>
| RW16
| Linear address, low 16 bits (l)
|-
! $42
| [[DMA#General DMA|GDMA Source Address High]]
| style="text-align: right" | <tt style="white-space: nowrap">.... hhhh</tt>
| RW8
| Linear address, high 4 bits (h)
|-
! $44
| [[DMA#General DMA|GDMA Destination Address]]
| style="text-align: right" | <tt style="white-space: nowrap">aaaa aaaa aaaa aaaa</tt>
| RW16
| IRAM address (a)
|-
! $46
| [[DMA#General DMA|GDMA Length]]
| style="text-align: right" | <tt style="white-space: nowrap">bbbb bbbb bbbb bbbb</tt>
| RW16
| Bytes (b)
|-
! $48
| [[DMA#General DMA|GDMA Control]]
| style="text-align: right" | <tt style="white-space: nowrap">ed.. ....</tt>
| RW8
| Enable (e), Decrement (d)
|-
! $4A
| [[DMA#Sound DMA|SDMA Source Address Low]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll llll llll</tt>
| RW16
| Linear address, low 16 bits (l)
|-
! $4C
| [[DMA#Sound DMA|SDMA Source Address High]]
| style="text-align: right" | <tt style="white-space: nowrap">.... hhhh</tt>
| RW8
| Linear address, high 4 bits (h)
|-
! $4E
| [[DMA#Sound DMA|SDMA Length Low]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll llll llll</tt>
| RW16
| Length, low 16 bits (l)
|-
! $50
| [[DMA#Sound DMA|SDMA Length High]]
| style="text-align: right" | <tt style="white-space: nowrap">.... hhhh</tt>
| RW8
| Length, high 4 bits (h)
|-
! $52
| [[DMA#Sound DMA|SDMA Control]]
| style="text-align: right" | <tt style="white-space: nowrap">ed.t r?ff</tt>
| RW8
| Enable (e), Decrement (d), Target (t),
Repeat (r), Frequency (f)
|-
! rowspan="2" | System<sup>(color)</sup>
! $60
| System Control 2
| style="text-align: right" | <tt style="white-space: nowrap">c4C. ?.??</tt>
| RW8
| Color (c), 4BPP (4), Chunky (C)
|-
! $62
| System Control 3
| style="text-align: right" | <tt style="white-space: nowrap">S... ...p</tt>
| RW8
| SwanCrystal (S), Power off (p)
|-
! rowspan="5" | [[Hyper Voice]]<sup>(color)</sup>
! $64
| Hyper Voice Left Output
| style="text-align: right" | <tt style="white-space: nowrap">ssss ssss ssss ssss</tt>
| W16
| Raw sample (s)
|-
! $66
| Hyper Voice Right Output
| style="text-align: right" | <tt style="white-space: nowrap">ssss ssss ssss ssss</tt>
| W16
| Raw sample (s)
|-
! $68
| Hyper Voice Left Input
| style="text-align: right" | <tt style="white-space: nowrap">ssss ssss</tt>
| 8
| Sample (s)
|-
! $69
| Hyper Voice Right Input
| style="text-align: right" | <tt style="white-space: nowrap">ssss ssss</tt>
| 8
| Sample (s)
|-
! $6A
| Hyper Voice Control
| style="text-align: right" | <tt style="white-space: nowrap">.mmc .... errr ffss</tt>
| RW16
| Mask (m), Channel (c), Enable (e),
Rate (r), Format (f), Shift (s)
|-
! rowspan="8" | [[Display]]<sup>(SC)</sup>
! $70
| LCD Timing Configuration 1?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $71
| LCD Timing Configuration 2?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $72
| LCD Timing Configuration 3?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $73
| LCD Timing Configuration 4?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $74
| LCD Timing Configuration 5?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $75
| LCD Timing Configuration 6?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $76
| LCD Timing Configuration 7?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $77
| LCD Timing Configuration 8?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! rowspan="20" | [[Sound]]
! $80
| Sound Channel 1 Frequency
| style="text-align: right" | <tt style="white-space: nowrap">.... .ddd dddd dddd</tt>
| RW16
| Divider (d)
|-
! $82
| Sound Channel 2 Frequency
| style="text-align: right" | <tt style="white-space: nowrap">.... .ddd dddd dddd</tt>
| RW16
| Divider (d)
|-
! $84
| Sound Channel 3 Frequency
| style="text-align: right" | <tt style="white-space: nowrap">.... .ddd dddd dddd</tt>
| RW16
| Divider (d)
|-
! $86
| Sound Channel 4 Frequency
| style="text-align: right" | <tt style="white-space: nowrap">.... .ddd dddd dddd</tt>
| RW16
| Divider (d)
|-
! $88
| Sound Channel 1 Volume
| style="text-align: right" | <tt style="white-space: nowrap">llll rrrr</tt>
| RW8
| Left (l), Right (r)
|-
! rowspan="2" | $89
| Sound Channel 2 Volume
| style="text-align: right" | <tt style="white-space: nowrap">llll rrrr</tt>
| RW8
| Left (l), Right (r)
|-
| Sound Channel 2 Voice Sample
| style="text-align: right" | <tt style="white-space: nowrap">ssss ssss</tt>
| RW8
| Sample (s)
|-
! $8A
| Sound Channel 3 Volume
| style="text-align: right" | <tt style="white-space: nowrap">llll rrrr</tt>
| RW8
| Left (l), Right (r)
|-
! $8B
| Sound Channel 4 Volume
| style="text-align: right" | <tt style="white-space: nowrap">llll rrrr</tt>
| RW8
| Left (l), Right (r)
|-
! $8C
| Sound Channel 3 Sweep Amount
| style="text-align: right" | <tt style="white-space: nowrap">vvvv vvvv</tt>
| RW8
| Value (v)
|-
! $8D
| Sound Channel 3 Sweep Ticks
| style="text-align: right" | <tt style="white-space: nowrap">...t tttt</tt>
| RW8
| Ticks (t)
|-
! $8E
| Sound Channel 4 Noise Control
| style="text-align: right" | <tt style="white-space: nowrap">...e rttt</tt>
| RW8
| Enable (e), Reset (r), Tap (t)
|-
! $8F
| Sound Wavetable Address
| style="text-align: right" | <tt style="white-space: nowrap">wwww wwww</tt>
| RW8
| Address >> 6 (w)
|-
! $90
| Sound Channel Control
| style="text-align: right" | <tt style="white-space: nowrap">nsv. 4321</tt>
| RW8
| Channel enable (1234)
Noise (n), Sweep (s), Voice (v)
|-
! $91
| Sound Output Control
| style="text-align: right" | <tt style="white-space: nowrap">H... hrrs</tt>
| RW8
| Headphones connected (H)
Headphone output (h)
Speaker output (s), range (r)
|-
! $92
| Sound Channel 4 LFSR
| style="text-align: right" | <tt style="white-space: nowrap">.rrr rrrr rrrr rrrr</tt>
| R16
| PRNG state (r)
|-
! $94
| Sound Channel 2 Voice Volume
| style="text-align: right" | <tt style="white-space: nowrap">.... lLrR</tt>
| RW8
| Left Half (l), Full (L)
Right Half (r), Full (R)
|-
! $96
| Sound Sequencer Output Right
| style="text-align: right" | <tt style="white-space: nowrap">.... ..ss ssss ssss</tt>
| R16
| Sample (s)
|-
! $98
| Sound Sequencer Output Left
| style="text-align: right" | <tt style="white-space: nowrap">.... ..ss ssss ssss</tt>
| R16
| Sample (s)
|-
! $9A
| Sound Sequencer Output Sum
| style="text-align: right" | <tt style="white-space: nowrap">.... .sss ssss ssss</tt>
| R16
| Sample (s)
|-
! System
! $A0
| System Control
| style="text-align: right" | <tt style="white-space: nowrap">t??? swcl</tt>
| RW8
| Test OK (t), ROM speed (s), ROM width (w),
Color system (c), Boot ROM lockout (l)
|-
! rowspan="5" | Timers
! $A2
| Timer Control
| style="text-align: right" | <tt style="white-space: nowrap">.... VvHh</tt>
| RW8
| Horizontal enable (h), auto reload (H)
Vertical enable (v), auto reload (V)
|-
! $A4
| Horizontal Blank Timer Reload
| style="text-align: right" | <tt style="white-space: nowrap">tttt tttt tttt tttt</tt>
| RW16
| Ticks (t)
|-
! $A6
| Vertical Blank Timer Reload
| style="text-align: right" | <tt style="white-space: nowrap">tttt tttt tttt tttt</tt>
| RW16
| Ticks (t)
|-
! $A8
| Horizontal Blank Timer Counter
| style="text-align: right" | <tt style="white-space: nowrap">tttt tttt tttt tttt</tt>
| R16
| Ticks (t)
|-
! $AA
| Vertical Blank Timer Counter
| style="text-align: right" | <tt style="white-space: nowrap">tttt tttt tttt tttt</tt>
| R16
| Ticks (t)
|-
! Interrupts
! $B0
| Interrupt Vector
| style="text-align: right" | <tt style="white-space: nowrap">vvvv v...</tt>
| RW8
| Vector offset (v)
|-
! UART
! $B1
| Serial Data
| style="text-align: right" | <tt style="white-space: nowrap">dddd dddd</tt>
| RW8
| Data (d)
|-
! Interrupts
! $B2
| Interrupt Enable
|
| RW8
|
|-
! UART
! $B3
| Serial Control
| style="text-align: right" | <tt style="white-space: nowrap">ebO. .rot</tt>
| RW8
| Enable (e), Baud rate (b), Reset Overrun (O),
Receive ready (r), Overrun (o), Transfer ready (t)
|-
! Interrupts
! $B4
| Interrupt Status
|
| RW8
|
|-
! [[Keypad]]
! $B5
| [[Keypad|Keypad Scan]]
| style="text-align: right" | <tt style="white-space: nowrap">.iii oooo</tt>
| RW8
| Input row (i), Output column (o)
|-
! rowspan="2" | Interrupts
! $B6
| Interrupt Acknowledge
|
| RW8
|
|-
! $B7
| Interrupt NMI Control
| style="text-align: right" | <tt style="white-space: nowrap">...b ....</tt>
| RW8
| Low battery (b)
|-
! rowspan="3" | Internal EEPROM
! $BA
| Internal EEPROM Data
| style="text-align: right" | <tt style="white-space: nowrap">dddd dddd dddd dddd</tt>
| RW16
| Data (d)
|-
! $BC
| Internal EEPROM Command
|
| RW16
|
|-
! $BE
| Internal EEPROM Control
| style="text-align: right" | <tt style="white-space: nowrap">.... .... PEWR ..rd</tt>
| RW16
| Protect (P), Erase (E), Write (W), Read (R),
Ready (r), Done (d)
|-
|}
4ceb54e7c335f905aa2606f4ac2877f1b09282e5
Keypad
0
9
25
2023-08-17T09:28:08Z
Asie
351
Created page with "The WonderSwan SoC features a 4 by 3 keypad matrix. == Scanning == Scanning is done via writing to and reading from port $B5. <pre> 7 bit 0 ---- ---- .iii oooo ||| ++++- Output rows (0-3) +++------ Input rows (4-6) </pre> The standard procedure is to read rows 4, 5 and 6 in order, shifting their values into one twelve-bit mask like so: <pre> 15 bit 0 ---- ---- ---- ---- .... 4444 5555 6666 </pre> Typical keypad scanning implementations introduce a d..."
wikitext
text/x-wiki
The WonderSwan SoC features a 4 by 3 keypad matrix.
== Scanning ==
Scanning is done via writing to and reading from port $B5.
<pre>
7 bit 0
---- ----
.iii oooo
||| ++++- Output rows (0-3)
+++------ Input rows (4-6)
</pre>
The standard procedure is to read rows 4, 5 and 6 in order, shifting their values into one twelve-bit mask like so:
<pre>
15 bit 0
---- ---- ---- ----
.... 4444 5555 6666
</pre>
Typical keypad scanning implementations introduce a delay between writing to and reading from the matrix, allowing the scanned values to stabilize. For example, one can use the DAA opcode for doing so.
== Startup override ==
On startup, the [[boot ROM]] checks whether or not certain output rows are forced high when all input rows are disabled. This triggers a startup override:
* Input row 0 - jump to 4000:0000,
* Input row 1 - jump to 4000:0010.
As this override is done before boot ROM lockout, it can be used to dump the boot ROM.
== Keypad arrangement ==
=== WonderSwan ===
==== Layout ====
<pre>
Y1
Y4 Y2
Y3
X1
X4 X2 A
X3 Sound Start Power B
(St)
</pre>
Sound and Power buttons are not exposed directly to software.
==== Matrix ====
<pre>
Bit O 3 2 1 0
I | | | |
| | | |
4--- Y4 - Y3 - Y2 - Y1 -
| | | |
5--- X4 - X3 - X2 - X1 -
| | | |
6--- B - A - St ---+--
| | | |
</pre>
==== Bit mask ====
<pre>
15 bit 0
---- ---- ---- ----
.... yyyy xxxx bas.
|||| |||| ||+- Start
|||| |||| |+-- A
|||| |||| +--- B
|||| ++++----- X4, X3, X2, X1
++++---------- Y4, Y3, Y2, Y1
</pre>
=== Pocket Challenge V2 ===
==== Layout ====
<pre>
Power
Esc
View
Up Clear
(Clr)
Lft Rgh Circle
(Crc)
Dwn Pass
(Pas)
</pre>
The Power switch is not exposed directly to software.
==== Matrix ====
<pre>
Bit O 3 2 1 0
I | | | |
| | | |
4--- Pas Crc --+-- Clr -
| | | |
5--- Rgh Esc --+- View -
| | | |
6--- Up - Dwn --+-- Lft -
| | | |
[1]
</pre>
==== Bit mask ====
<pre>
15 bit 0
---- ---- ---- ----
.... pc1C re1v ud1l
|| | || | || +- Left
|| | || | |+--- Down
|| | || | +---- Up
|| | || +------ View
|| | |+-------- Esc
|| | +--------- Right
|| +----------- Clear
|+------------- Circle
+-------------- Pass
</pre>
fe46d407e6eb1e22394371c3de7eeaf27b823ac2
26
25
2023-08-17T09:29:06Z
Asie
351
wikitext
text/x-wiki
The WonderSwan SoC features a 4 by 3 keypad matrix.
== Scanning ==
Scanning is done via writing to and reading from port $B5.
<pre>
7 bit 0
---- ----
.iii oooo
||| ++++- Output rows (0-3)
+++------ Input rows (4-6)
</pre>
The standard procedure is to read rows 4, 5 and 6 in order, shifting their values into one twelve-bit mask like so:
<pre>
15 bit 0
---- ---- ---- ----
.... 4444 5555 6666
</pre>
Typical keypad scanning implementations introduce a delay between writing to and reading from the matrix, allowing the scanned values to stabilize. For example, one can use the DAA opcode for doing so.
== Startup override ==
On startup, the [[boot ROM]] checks whether or not certain output rows are forced high when all input rows are disabled. This triggers a startup override prior to the boot logo:
* Input row 0 - jump to 4000:0000,
* Input row 1 - jump to 4000:0010.
As this override is done before boot ROM lockout, it can be used to dump the boot ROM.
== Keypad arrangement ==
=== WonderSwan ===
==== Layout ====
<pre>
Y1
Y4 Y2
Y3
X1
X4 X2 A
X3 Sound Start Power B
(St)
</pre>
Sound and Power buttons are not exposed directly to software.
==== Matrix ====
<pre>
Bit O 3 2 1 0
I | | | |
| | | |
4--- Y4 - Y3 - Y2 - Y1 -
| | | |
5--- X4 - X3 - X2 - X1 -
| | | |
6--- B - A - St ---+--
| | | |
</pre>
==== Bit mask ====
<pre>
15 bit 0
---- ---- ---- ----
.... yyyy xxxx bas.
|||| |||| ||+- Start
|||| |||| |+-- A
|||| |||| +--- B
|||| ++++----- X4, X3, X2, X1
++++---------- Y4, Y3, Y2, Y1
</pre>
=== Pocket Challenge V2 ===
==== Layout ====
<pre>
Power
Esc
View
Up Clear
(Clr)
Lft Rgh Circle
(Crc)
Dwn Pass
(Pas)
</pre>
The Power switch is not exposed directly to software.
==== Matrix ====
<pre>
Bit O 3 2 1 0
I | | | |
| | | |
4--- Pas Crc --+-- Clr -
| | | |
5--- Rgh Esc --+- View -
| | | |
6--- Up - Dwn --+-- Lft -
| | | |
[1]
</pre>
==== Bit mask ====
<pre>
15 bit 0
---- ---- ---- ----
.... pc1C re1v ud1l
|| | || | || +- Left
|| | || | |+--- Down
|| | || | +---- Up
|| | || +------ View
|| | |+-------- Esc
|| | +--------- Right
|| +----------- Clear
|+------------- Circle
+-------------- Pass
</pre>
3a184f11a68c50935f97eb559a5bf7242c178e94
2001 Mapper pinout
0
10
28
2023-08-18T21:56:26Z
Lidnariq
7
from my notes
wikitext
text/x-wiki
2001: 48-pin 0.6mm pitch TQFP
D4 <> /01 o 25\ ?? Gnd
D3 <> /02 26\ ?? Gnd
D2 <> /03 27\ ?? Gnd
D1 <> /04 28\ ?? Gnd
D0 <> /05 29\ -> Microwire SK
Gnd -- /06 30\ -- Vcc
A0 -> /07 /| 31\ <- Microwire DO
A1 -> /08 / |/ 32\ -> Microwire DI
Vcc -- /09 / 33\ -> Microwire CS
A2 -> /10 /\ \ 34\ -- nc
A3 -> /11 \/ L\ 35\ -> ROM A22
CPU A19 -> /12 /\ \ L\ 36\ -> ROM A17
CPU A18 -> \13 \/ \/\ 37/ -> ROM A16
CPU A17 -> \14 \ \ \/ 38/ -> ROM A20
CPU A16 -> \15 \ \_\ 39/ -> ROM A21
Vcc -- \16 |\ \ 40/ -- Gnd
/Reset ?> \17 |_\ 41/ -> ROM A19
/MBC <- \18 \ 42/ -> ROM A18
M/IO -> \19 \/\ 43/ -> ROM /CS
/RD -> \20 \ \/ 44/ -- Vcc
/WR -> \21 \ 45/ -> SRAM /CS
/SEL -> \22 46/ <> D7
CLK -> \23 47/ <> D6
Gnd -- \24 O 48/ <> D5
466e4ce751f28bd07775962feeb86b2ade301a64
29
28
2023-08-18T21:57:01Z
Lidnariq
7
orientation
wikitext
text/x-wiki
2001: 48-pin 0.6mm pitch TQFP
D4 <> /01 o 25\ ?? Gnd
D3 <> /02 26\ ?? Gnd
D2 <> /03 27\ ?? Gnd
D1 <> /04 28\ ?? Gnd
D0 <> /05 29\ -> Microwire SK
Gnd -- /06 30\ -- Vcc
A0 -> /07 /| 31\ <- Microwire DO
A1 -> /08 / |/ 32\ -> Microwire DI
Vcc -- /09 / 33\ -> Microwire CS
A2 -> /10 /\ \ 34\ -- nc
A3 -> /11 \/ L\ 35\ -> ROM A22
CPU A19 -> /12 /\ \ L\ 36\ -> ROM A17
CPU A18 -> \13 \/ \/\ 37/ -> ROM A16
CPU A17 -> \14 \ \ \/ 38/ -> ROM A20
CPU A16 -> \15 \ \_\ 39/ -> ROM A21
Vcc -- \16 |\ \ 40/ -- Gnd
/Reset ?> \17 |_\ 41/ -> ROM A19
/MBC <- \18 \ 42/ -> ROM A18
M/IO -> \19 \/\ 43/ -> ROM /CS
/RD -> \20 \ \/ 44/ -- Vcc
/WR -> \21 \ 45/ -> SRAM /CS
/SEL -> \22 46/ <> D7
CLK -> \23 47/ <> D6
Gnd -- \24 O 48/ <> D5
Note the orientation of the text: "Bandai 2001" when viewed upright specifies pin 1 is bottom face, leftmost.
c4d7e94ab6b8f532e2962e6ab46ff05abc2aa272
34
29
2023-08-19T06:08:59Z
Lidnariq
7
pitch
wikitext
text/x-wiki
2001: 48-pin 0.5mm pitch TQFP
D4 <> /01 o 25\ ?? Gnd
D3 <> /02 26\ ?? Gnd
D2 <> /03 27\ ?? Gnd
D1 <> /04 28\ ?? Gnd
D0 <> /05 29\ -> Microwire SK
Gnd -- /06 30\ -- Vcc
A0 -> /07 /| 31\ <- Microwire DO
A1 -> /08 / |/ 32\ -> Microwire DI
Vcc -- /09 / 33\ -> Microwire CS
A2 -> /10 /\ \ 34\ -- nc
A3 -> /11 \/ L\ 35\ -> ROM A22
CPU A19 -> /12 /\ \ L\ 36\ -> ROM A17
CPU A18 -> \13 \/ \/\ 37/ -> ROM A16
CPU A17 -> \14 \ \ \/ 38/ -> ROM A20
CPU A16 -> \15 \ \_\ 39/ -> ROM A21
Vcc -- \16 |\ \ 40/ -- Gnd
/Reset ?> \17 |_\ 41/ -> ROM A19
/MBC <- \18 \ 42/ -> ROM A18
M/IO -> \19 \/\ 43/ -> ROM /CS
/RD -> \20 \ \/ 44/ -- Vcc
/WR -> \21 \ 45/ -> SRAM /CS
/SEL -> \22 46/ <> D7
CLK -> \23 47/ <> D6
Gnd -- \24 O 48/ <> D5
Note the orientation of the text: "Bandai 2001" when viewed upright specifies pin 1 is bottom face, leftmost.
a47ab56b418801050d72bf1fdfe8c396c284674e
50
34
2023-08-20T07:12:54Z
Lidnariq
7
had the entire right half upside-down
wikitext
text/x-wiki
2001: 48-pin 0.5mm pitch TQFP
D4 <> /01 o 48\ <> D5
D3 <> /02 47\ <> D6
D2 <> /03 46\ <> D7
D1 <> /04 45\ -> SRAM /CS
D0 <> /05 44\ -- Vcc
Gnd -- /06 43\ -> ROM /CS
A0 -> /07 42\ -> ROM A18
A1 -> /08 41\ -> ROM A19
Vcc -- /09 40\ -- Gnd
A2 -> /10 39\ -> ROM A21
A3 -> /11 38\ -> ROM A20
CPU A19 -> /12 BANDAI 37\ -> ROM A16
CPU A18 -> \13 2001 36/ -> ROM A17
CPU A17 -> \14 35/ -> ROM A22
CPU A16 -> \15 34/ -- nc
Vcc -- \16 33/ -> Microwire CS
/Reset ?> \17 32/ -> Microwire DI
/MBC <- \18 31/ <- Microwire DO
M/IO -> \19 30/ -- Vcc
/RD -> \20 29/ -> Microwire SK
/WR -> \21 28/ ?? Gnd
/SEL -> \22 27/ ?? Gnd
CLK -> \23 26/ ?? Gnd
Gnd -- \24 O 25/ ?? Gnd
Note the orientation of the text: "Bandai 2001" when viewed upright specifies pin 1 is bottom face, leftmost.
4045cda402aecefd24c395a675eab6cd7ae894d7
2003 Mapper pinout
0
11
30
2023-08-18T22:10:22Z
Lidnariq
7
create from my notes
wikitext
text/x-wiki
2003: 48-pin 0.6mm pitch TQFP
Gnd -- /01 o 25\ <> D7
GPO 3 <? /02 26\ <> D6
GPO 2 <? /03 27\ <> D5
GPO 1 <? /04 28\ <> D4
GPO 0 <? /05 29\ <> D3
Gnd -- /06 30\ -- Vcc
RTC SIO <> /07 /| 31\ <> D2
RTC SCK <- /08 / |/ 32\ <> D1
RTC CS <- /09 / 33\ <> D0
ROM A25 <- /10 /\ \ 34\ <- A0
ROM A24 <- /11 \/ L\ 35\ <- A1
ROM A23 <- /12 /\ \ L\ 36\ <- A2
ROM A22 <- \13 / \/ \/\ 37/ <- A3
ROM A17 <- \14 \/ \ \/ 38/ <- CPU A19
ROM A16 <- \15 \/ \_\ 39/ <- CPU A18
Gnd -- \16 |\ \ 40/ <- CPU A17
ROM A20 <- \17 |_\ 41/ <- CPU A16
ROM A21 <- \18 \ 42/ <- /Reset
ROM A19 <- \19 \/\ 43/ -> /MBC
ROM A18 <- \20 \ \/ 44/ <- M/IO
SRAM /CS <- \21 \ 45/ <- /RD
ROM /CS <- \22 46/ <- /WR
ROM /BYTE <- \23 47/ <- /SEL
D15 (A-1) <Z \24 O 48/ <- CLK
Note the orientation of the text: "Bandai 2003" when viewed upright specifies pin 1 is bottom face, leftmost.
b743a842d081cbc33ada662e56b0936ba673a07a
35
30
2023-08-19T06:09:06Z
Lidnariq
7
pitch
wikitext
text/x-wiki
2003: 48-pin 0.5mm pitch TQFP
Gnd -- /01 o 25\ <> D7
GPO 3 <? /02 26\ <> D6
GPO 2 <? /03 27\ <> D5
GPO 1 <? /04 28\ <> D4
GPO 0 <? /05 29\ <> D3
Gnd -- /06 30\ -- Vcc
RTC SIO <> /07 /| 31\ <> D2
RTC SCK <- /08 / |/ 32\ <> D1
RTC CS <- /09 / 33\ <> D0
ROM A25 <- /10 /\ \ 34\ <- A0
ROM A24 <- /11 \/ L\ 35\ <- A1
ROM A23 <- /12 /\ \ L\ 36\ <- A2
ROM A22 <- \13 / \/ \/\ 37/ <- A3
ROM A17 <- \14 \/ \ \/ 38/ <- CPU A19
ROM A16 <- \15 \/ \_\ 39/ <- CPU A18
Gnd -- \16 |\ \ 40/ <- CPU A17
ROM A20 <- \17 |_\ 41/ <- CPU A16
ROM A21 <- \18 \ 42/ <- /Reset
ROM A19 <- \19 \/\ 43/ -> /MBC
ROM A18 <- \20 \ \/ 44/ <- M/IO
SRAM /CS <- \21 \ 45/ <- /RD
ROM /CS <- \22 46/ <- /WR
ROM /BYTE <- \23 47/ <- /SEL
D15 (A-1) <Z \24 O 48/ <- CLK
Note the orientation of the text: "Bandai 2003" when viewed upright specifies pin 1 is bottom face, leftmost.
a624b0f87dd8bda88995e50a79b467adc904a670
49
35
2023-08-20T07:11:14Z
Lidnariq
7
had the entire right half upside-down
wikitext
text/x-wiki
2003: 48-pin 0.5mm pitch TQFP
Gnd -- /01 o 48\ <- CLK
GPO 3 <? /02 47\ <- /SEL
GPO 2 <? /03 46\ <- /WR
GPO 1 <? /04 45\ <- /RD
GPO 0 <? /05 44\ <- M/IO
Gnd -- /06 43\ -> /MBC
RTC SIO <> /07 42\ <- /Reset
RTC SCK <- /08 41\ <- CPU A16
RTC CS <- /09 40\ <- CPU A17
ROM A25 <- /10 39\ <- CPU A18
ROM A24 <- /11 BANDAI 38\ <- CPU A19
ROM A23 <- /12 2003 37\ <- A3
ROM A22 <- \13 36/ <- A2
ROM A17 <- \14 35/ <- A1
ROM A16 <- \15 34/ <- A0
Gnd -- \16 33/ <> D0
ROM A20 <- \17 32/ <> D1
ROM A21 <- \18 31/ <> D2
ROM A19 <- \19 30/ -- Vcc
ROM A18 <- \20 29/ <> D3
SRAM /CS <- \21 28/ <> D4
ROM /CS <- \22 27/ <> D5
ROM /BYTE <- \23 26/ <> D6
D15 (A-1) <Z \24 O 25/ <> D7
Note the orientation of the text: "Bandai 2003" when viewed upright specifies pin 1 is bottom face, leftmost.
cede91ff05d5bb0d5de1e5b60bfe1613be2ac9d9
Bandai 2001
0
12
31
2023-08-18T22:30:22Z
Lidnariq
7
create from my notes
wikitext
text/x-wiki
In addition to the normal [[Cartridge]] banking interface, Bandai's 2001 adds three registers for interacting with a Microwire EEPROM:
{| class="wikitable"
! Category
! Port
! Description
! Bits
! Type
! Notes
|-
! rowspan="4" | External EEPROM
! $C4
| External EEPROM Data
| style="text-align: right" | <tt style="white-space: nowrap">dddd dddd dddd dddd</tt>
| RW16
| Data (d)
|-
! $C6
| External EEPROM Command
| style="text-align: right" | <tt style="white-space: nowrap">0001 CCaa aaaa aaaa</tt>
or <tt style="white-space: nowrap">0000 0001 CCaa aaaa</tt>
| RW16
| Command and address
|-
! $C8
| External EEPROM Command
| style="text-align: right" | <tt style="white-space: nowrap">.... .... ACWR ....</tt>
| W8
| Abort (A), Command (C), Write (W), Read (R)
|-
! $C8
| External EEPROM Status
| style="text-align: right" | <tt style="white-space: nowrap">.... .... .... ..rd</tt>
| R8
| Ready (r), Done (d)
|-
|}
The specific meaning of the "Command" register depends on the model of EEPROM on the PCB. Only three Microwire EEPROMs have been seen used (equivalent to 93C46, 93C76, and 93C86)
On the 2001, the EEPROM "done" bit is buggy and doesn't have useful information. It's set when a Read completes, but is only cleared when a Command or Write is started. (To be useful it would need to also be cleared when a Read is started).
If more than ACWR bit is set at the same time, the 2001 ignores it.
The CWR bits specify how many data bits are sent/received. C: No data bits. W: Send Data register after command register. R: Receive data register after sending command register.
If the A bit is set, the transaction immediately stops.
(Upload logic analyzer traces here)
f633ef5d0eac455579d0a1c950a2b10d87cf9bb1
32
31
2023-08-18T22:32:18Z
Lidnariq
7
if I say $C8 is byte-wide, only talk about 8 bits
wikitext
text/x-wiki
In addition to the normal [[Cartridge]] banking interface, Bandai's 2001 adds three registers for interacting with a Microwire EEPROM:
{| class="wikitable"
! Category
! Port
! Description
! Bits
! Type
! Notes
|-
! rowspan="4" | External EEPROM
! $C4
| External EEPROM Data
| style="text-align: right" | <tt style="white-space: nowrap">dddd dddd dddd dddd</tt>
| RW16
| Data (d)
|-
! $C6
| External EEPROM Command
| style="text-align: right" | <tt style="white-space: nowrap">0001 CCaa aaaa aaaa</tt>
or <tt style="white-space: nowrap">0000 0001 CCaa aaaa</tt>
| RW16
| Command and address
|-
! $C8
| External EEPROM Command
| style="text-align: right" | <tt style="white-space: nowrap">ACWR ....</tt>
| W8
| Abort (A), Command (C), Write (W), Read (R)
|-
! $C8
| External EEPROM Status
| style="text-align: right" | <tt style="white-space: nowrap">.... ..rd</tt>
| R8
| Ready (r), Done (d)
|-
|}
The specific meaning of the "Command" register depends on the model of EEPROM on the PCB. Only three Microwire EEPROMs have been seen used (equivalent to 93C46, 93C76, and 93C86)
On the 2001, the EEPROM "done" bit is buggy and doesn't have useful information. It's set when a Read completes, but is only cleared when a Command or Write is started. (To be useful it would need to also be cleared when a Read is started).
If more than ACWR bit is set at the same time, the 2001 ignores it.
The CWR bits specify how many data bits are sent/received. C: No data bits. W: Send Data register after command register. R: Receive data register after sending command register.
If the A bit is set, the transaction immediately stops.
(Upload logic analyzer traces here)
7995fe2b17b0c07c5f1aa4d429c2df59860bd312
48
32
2023-08-19T21:49:57Z
Lidnariq
7
merge cells
wikitext
text/x-wiki
In addition to the normal [[Cartridge]] banking interface, Bandai's 2001 adds three registers for interacting with a Microwire EEPROM:
{| class="wikitable"
! Category
! Port
! Description
! Bits
! Type
! Notes
|-
! rowspan="4" | External EEPROM
! $C4
| External EEPROM Data
| style="text-align: right" | <tt style="white-space: nowrap">dddd dddd dddd dddd</tt>
| RW16
| Data (d)
|-
! $C6
| External EEPROM Command
| style="text-align: right" | <tt style="white-space: nowrap">0001 CCaa aaaa aaaa</tt>
or <tt style="white-space: nowrap">0000 0001 CCaa aaaa</tt>
| RW16
| Command and address
|-
! rowspan=2|$C8
| External EEPROM Command
| style="text-align: right" | <tt style="white-space: nowrap">ACWR ....</tt>
| W8
| Abort (A), Command (C), Write (W), Read (R)
|-
| External EEPROM Status
| style="text-align: right" | <tt style="white-space: nowrap">.... ..rd</tt>
| R8
| Ready (r), Done (d)
|-
|}
The specific meaning of the "Command" register depends on the model of EEPROM on the PCB. Only three Microwire EEPROMs have been seen used (equivalent to 93C46, 93C76, and 93C86)
On the 2001, the EEPROM "done" bit is buggy and doesn't have useful information. It's set when a Read completes, but is only cleared when a Command or Write is started. (To be useful it would need to also be cleared when a Read is started).
If more than ACWR bit is set at the same time, the 2001 ignores it.
The CWR bits specify how many data bits are sent/received. C: No data bits. W: Send Data register after command register. R: Receive data register after sending command register.
If the A bit is set, the transaction immediately stops.
(Upload logic analyzer traces here)
84182607bf0a4e666fd85f9158905f274e36cc39
Bandai 2003
0
13
33
2023-08-18T22:46:29Z
Lidnariq
7
create from my notes
wikitext
text/x-wiki
In addition to the normal [[Cartridge]] banking interface, Bandai's 2003 adds registers for an RTC interface, GPO pins, self flashing, and accessing more than 16MiB of ROM.
{| class="wikitable"
! Category
! Port
! Description
! Bits
! Type
! Notes
|-
! rowspan="3" | RTC
! $CA
| RTC Command
| style="text-align: right" | <tt style="white-space: nowrap">...1 CCCC</tt>
| W8
| Command (C)
|-
! $CA
| RTC Status
| style="text-align: right" | <tt style="white-space: nowrap">D..B CCCC</tt>
| R8
| Busy (B), Command (C), Data needed (D)
|-
! $CB
| RTC Payload
| style="text-align: right" | <tt style="white-space: nowrap">dddd dddd</tt>
| RW8
| Data (d)
|-
! rowspan="2" | GPO
! $CC
| Data direction
| style="text-align: right" | <tt style="white-space: nowrap">0000 oooo</tt>
| RW8
| 1 = output, 0 = high-impedance (weak pull-down)
|-
! $CD
| GPO Data
| style="text-align: right" | <tt style="white-space: nowrap">0000 dddd</tt>
| RW8
| 1 = 3V, if enabled by data direction
|-
! Self-flashing
! $CE
| Enable
| style="text-align: right" | <tt style="white-space: nowrap">0000 000r</tt>
| RW8
| 1 = ROM is accessible at segment 0x1000;
0 = RAM instead.
|-
! rowspan="4" | Extended bankswitching
! $CF
| ROMEX bank
| style="text-align: right" | <tt style="white-space: nowrap">00bb bbbb</tt>
| RW8
| Selects a 1MiB bank accessed via segments 0x4000 through 0xF000. Identical to the register at 0xC0.
|-
! $D0
| ROM0 bank
| style="text-align: right" | <tt style="white-space: nowrap">0000 00bb bbbb bbbb</tt>
| RW16
| Selects a 64KiB bank accessed via segment 0x1000. Lower 8 bits are identical to the register at 0xC1.
|-
! $D2
| ROM1 bank
| style="text-align: right" | <tt style="white-space: nowrap">0000 00bb bbbb bbbb</tt>
| RW16
| Selects a 64KiB bank accessed via segment 0x2000. Lower 8 bits are identical to the register at 0xC2.
|-
! $D4
| ROM2 bank
| style="text-align: right" | <tt style="white-space: nowrap">0000 00bb bbbb bbbb</tt>
| RW16
| Selects a 64KiB bank accessed via segment 0x3000. Lower 8 bits are identical to the register at 0xC3.
|}
Not all PCBs are wired to support self-flashing. Not all ROMs have the needed /BYTE pin. Even on PCBs without support, ROM can still be enabled by writing to port $CE.
e4866d7241b2c3b60bbfe40ee27583630f862288
39
33
2023-08-19T13:11:28Z
Asie
351
make it clearer that RTC Command and Status are the same port, unify capitalization
wikitext
text/x-wiki
In addition to the normal [[Cartridge]] banking interface, Bandai's 2003 adds registers for an RTC interface, GPO pins, self flashing, and accessing more than 16MiB of ROM.
{| class="wikitable"
! Category
! Port
! Description
! Bits
! Type
! Notes
|-
! rowspan="3" | RTC
! rowspan="2" | $CA
| RTC Command
| style="text-align: right" | <tt style="white-space: nowrap">...1 CCCC</tt>
| W8
| Command (C)
|-
| RTC Status
| style="text-align: right" | <tt style="white-space: nowrap">D..B CCCC</tt>
| R8
| Busy (B), Command (C), Data needed (D)
|-
! $CB
| RTC Payload
| style="text-align: right" | <tt style="white-space: nowrap">dddd dddd</tt>
| RW8
| Data (d)
|-
! rowspan="2" | GPO
! $CC
| GPO Data Direction
| style="text-align: right" | <tt style="white-space: nowrap">0000 oooo</tt>
| RW8
| 1 = output, 0 = high-impedance (weak pull-down)
|-
! $CD
| GPO Data
| style="text-align: right" | <tt style="white-space: nowrap">0000 dddd</tt>
| RW8
| 1 = 3V, if enabled by data direction
|-
! Self-Flash
! $CE
| Self-Flash Control
| style="text-align: right" | <tt style="white-space: nowrap">0000 000r</tt>
| RW8
| 1 = ROM is accessible at segment 0x1000;
0 = RAM instead.
|-
! rowspan="4" | Extended bankswitching
! $CF
| ROM Linear (EX) Bank
| style="text-align: right" | <tt style="white-space: nowrap">00bb bbbb</tt>
| RW8
| Selects a 1MiB bank accessed via segments 0x4000 through 0xF000. Identical to the register at 0xC0.
|-
! $D0
| RAM(/ROM) Bank
| style="text-align: right" | <tt style="white-space: nowrap">0000 00bb bbbb bbbb</tt>
| RW16
| Selects a 64KiB bank accessed via segment 0x1000. Lower 8 bits are identical to the register at 0xC1.
|-
! $D2
| ROM0 Bank
| style="text-align: right" | <tt style="white-space: nowrap">0000 00bb bbbb bbbb</tt>
| RW16
| Selects a 64KiB bank accessed via segment 0x2000. Lower 8 bits are identical to the register at 0xC2.
|-
! $D4
| ROM1 Bank
| style="text-align: right" | <tt style="white-space: nowrap">0000 00bb bbbb bbbb</tt>
| RW16
| Selects a 64KiB bank accessed via segment 0x3000. Lower 8 bits are identical to the register at 0xC3.
|}
Not all PCBs are wired to support self-flashing. Not all ROMs have the needed /BYTE pin. Even on PCBs without support, ROM can still be enabled by writing to port $CE.
d5e8e9e637f1a84d7dfc4e85241bd039db829a2c
WonderGate
0
14
36
2023-08-19T11:07:55Z
Asie
351
Created page with "== WonderGate == TODO === Servers === {| class="wikitable" |+ WonderGate servers |- ! Hostname !! Software |- | [[WonderGate/bplXX.mopera.ne.jp|bplXX.mopera.ne.jp]] || MobileWonderGate (browser) |}"
wikitext
text/x-wiki
== WonderGate ==
TODO
=== Servers ===
{| class="wikitable"
|+ WonderGate servers
|-
! Hostname !! Software
|-
| [[WonderGate/bplXX.mopera.ne.jp|bplXX.mopera.ne.jp]] || MobileWonderGate (browser)
|}
91ae80b6f5add0dd4ac9501c54f137855bdea885
46
36
2023-08-19T18:09:37Z
Asie
351
wikitext
text/x-wiki
== WonderGate ==
TODO
=== Servers ===
{| class="wikitable"
|+ WonderGate servers
|-
! Software !! Hostname
|-
| rowspan="2" | MobileWonderGate (web browser)
| [[WonderGate/bplXX.mopera.ne.jp|bpl01.mopera.ne.jp]]
|-
| [[WonderGate/bplXX.mopera.ne.jp|bpl02.mopera.ne.jp]]
|-
| Terrors 2
| [[WonderGate/terrors2.wgg.channel.or.jp|terrors2.wgg.channel.or.jp]]
|}
a543b6a77463a6450d62c5dc9fa1d7701f503fd7
47
46
2023-08-19T18:12:02Z
Asie
351
wikitext
text/x-wiki
== WonderGate ==
TODO
=== Servers ===
{| class="wikitable"
|+ WonderGate servers
|-
! Software !! Hostname
|-
| rowspan="2" | MobileWonderGate (web browser)
| [[WonderGate/bplXX.mopera.ne.jp|bpl01.mopera.ne.jp]]
|-
| [[WonderGate/bplXX.mopera.ne.jp|bpl02.mopera.ne.jp]]
|-
| Pocket Fighter
|
|-
| Rainbow Islands - Putty's Party
|
|-
| Star Hearts
|
|-
| Terrors 2
| [[WonderGate/terrors2.wgg.channel.or.jp|terrors2.wgg.channel.or.jp]]
|-
| Wizardry
|
|}
c370c3e1d26dcd0809c48cbf03c6a8f0d60413fd
WonderGate/bplXX.mopera.ne.jp
0
15
37
2023-08-19T11:17:25Z
Asie
351
Created page with "For the MobileWonderGate software, NTT DoCoMo operated network servers for validating and redirecting URL requests: * <code>bpl01.mopera.ne.jp</code> * <code>bpl02.mopera.ne.jp</code> == Packet format == Every packet sent from and to the server follows the same format: a global header, followed by an arbitrary number of blocks with their respective headers. The client expects one block in response from the server. === Header === {| class="wikitable" ! Offset ! Leng..."
wikitext
text/x-wiki
For the MobileWonderGate software, NTT DoCoMo operated network servers for validating and redirecting URL requests:
* <code>bpl01.mopera.ne.jp</code>
* <code>bpl02.mopera.ne.jp</code>
== Packet format ==
Every packet sent from and to the server follows the same format: a global header, followed by an arbitrary number of blocks with their respective headers.
The client expects one block in response from the server.
=== Header ===
{| class="wikitable"
! Offset
! Length
! Description
|-
| 0x00 || 1 || Unknown, always 0x01
|-
| 0x01 || 1 || Header size in bytes, always 0x18
|-
| 0x02 || 2 || Response type:
* 0x0000 - not a response
* 0x0010 - allow
* 0x0012 - deny
* 0x0021 - require ID/password
* 0x0023 - unknown (too large?)
|-
| 0x04 || 4 || Total packet size in bytes, including all headers and blocks
|-
| 0x08 || 4 || Unknown
|-
| 0x0C || 4 || Unknown
|-
| 0x10 || 4 || Unknown (216.0.192.1?)
|-
| 0x14 || 4 || Unknown (255.255.0.0?)
|}
=== Block header ===
Blocks typically consist of zero-terminated strings - a final zero appears to be omitted.
{| class="wikitable"
! Offset
! Length
! Description
|-
| 0x00 || 2 || Block size in bytes, including header
|-
| 0x02 || 1 || Block type:
* 0x01 - 0x00? byte, followed by requested URL string
* 0x03 - 0x00? byte, followed by previous URL string (referrer?)
* 0x11 - ID string, followed by PASS string
* 0x22 - 0x00? byte, followed by query field name string, followed by query field value string
|}
ce2cb671662916111e93d683380c9e2a4023f79f
38
37
2023-08-19T12:05:11Z
Asie
351
wikitext
text/x-wiki
For the MobileWonderGate software, NTT DoCoMo operated network servers for validating and redirecting URL requests:
* <code>bpl01.mopera.ne.jp</code>
* <code>bpl02.mopera.ne.jp</code>
These servers listened on TCP port 5555 for request packets in the following format, and issued a response in the same format.
== Packet format ==
Every packet sent from and to the server follows the same format: a global header, followed by an arbitrary number of blocks with their respective headers.
The client expects one block in response from the server.
=== Header ===
{| class="wikitable"
! Offset
! Length
! Description
|-
| 0x00 || 1 || Unknown, always 0x01
|-
| 0x01 || 1 || Header size in bytes, always 0x18
|-
| 0x02 || 2 || Response type:
* 0x0000 - not a response
* 0x0010 - allow
* 0x0012 - deny
* 0x0021 - require ID/password
* 0x0023 - unknown (too large?)
|-
| 0x04 || 4 || Total packet size in bytes, including all headers and blocks
|-
| 0x08 || 4 || Unknown
|-
| 0x0C || 4 || Unknown
|-
| 0x10 || 4 || Unknown (216.0.192.1?)
|-
| 0x14 || 4 || Unknown (255.255.0.0?)
|}
=== Block header ===
Blocks typically consist of zero-terminated strings - a final zero appears to be omitted.
{| class="wikitable"
! Offset
! Length
! Description
|-
| 0x00 || 2 || Block size in bytes, including header
|-
| 0x02 || 1 || Block type:
* 0x01 - 0x00? byte, followed by requested URL string
* 0x03 - 0x00? byte, followed by previous URL string (referrer?)
* 0x11 - ID string, followed by PASS string
* 0x22 - 0x00? byte, followed by query field name string, followed by query field value string
|}
b8bda6949d5f4a87b8e2e2c23d39f3325936e041
40
38
2023-08-19T13:57:39Z
Asie
351
wikitext
text/x-wiki
For the MobileWonderGate software, NTT DoCoMo operated network servers for validating and redirecting URL requests:
* <code>bpl01.mopera.ne.jp</code>
* <code>bpl02.mopera.ne.jp</code>
These servers listened on TCP port 5555 for request packets in the following format, and issued a response in the same format.
== Packet format ==
Every packet sent from and to the server follows the same format: a global header, followed by an arbitrary number of blocks with their respective headers.
=== Header ===
{| class="wikitable"
! Offset
! Length
! Description
|-
| 0x00 || 1 || Unknown, always 0x01
|-
| 0x01 || 1 || Header size in bytes, always 0x18
|-
| 0x02 || 2 || Response type:
* 0x0000 - not a response
* 0x0010 - allow + 0 blocks
* 0x0012 - deny + 1 block
* 0x0021 - require ID/password + 1 block
* 0x0023 - unknown (too large?) + 0 blocks
|-
| 0x04 || 4 || Total packet size in bytes, including all headers and blocks
|-
| 0x08 || 4 || Unknown
|-
| 0x0C || 4 || Unknown
|-
| 0x10 || 4 || Unknown (216.0.192.1?)
|-
| 0x14 || 4 || Unknown (255.255.0.0?)
|}
=== Block header ===
Blocks typically consist of zero-terminated strings - a final zero appears to be omitted.
{| class="wikitable"
! Offset
! Length
! Description
|-
| 0x00 || 2 || Block size in bytes, including header
|-
| 0x02 || 1 || Block type:
* 0x01 - 0x00? byte, followed by requested URL string
* 0x03 - 0x00? byte, followed by previous URL string (referrer?)
* 0x11 - ID string, followed by PASS string
* 0x22 - 0x00? byte, followed by query field name string, followed by query field value string
|}
2a1734f699502726c1cf339076a893fdd2ee450b
41
40
2023-08-19T15:04:04Z
Asie
351
wikitext
text/x-wiki
For the MobileWonderGate software, NTT DoCoMo operated network servers for validating and redirecting URL requests:
* <code>bpl01.mopera.ne.jp</code>
* <code>bpl02.mopera.ne.jp</code>
These servers listened on TCP port 5555 for request packets in the following format, and issued a response in the same format.
== Packet format ==
Every packet sent from and to the server follows the same format: a global header, followed by an arbitrary number of blocks with their respective headers.
=== Header ===
{| class="wikitable"
! Offset
! Length
! Description
|-
| 0x00 || 1 || Unknown, always 0x01
|-
| 0x01 || 1 || Header size in bytes, always 0x18
|-
| 0x02 || 2 || Message type:
* 0x0000 - request: GET
* 0x0002 - request: POST
* 0x0010 - response: allow + 0 blocks
* 0x0012 - response: deny + 1 block
* 0x0021 - response: require ID/password + 1 block
* 0x0023 - response: unknown (too large?) + 0 blocks
|-
| 0x04 || 4 || Total packet size in bytes, including all headers and blocks
|-
| 0x08 || 4 || Unknown
|-
| 0x0C || 4 || Unknown
|-
| 0x10 || 4 || Unknown (216.0.192.1?)
|-
| 0x14 || 4 || Unknown (255.255.0.0?)
|}
=== Block header ===
Blocks typically consist of zero-terminated strings - a final zero appears to be omitted.
{| class="wikitable"
! Offset
! Length
! Description
|-
| 0x00 || 2 || Block size in bytes, including header
|-
| 0x02 || 1 || Block type:
* 0x01 - 0x00? byte, followed by requested URL string
* 0x03 - 0x00? byte, followed by previous URL string (referrer?)
* 0x11 - ID string, followed by PASS string
* 0x22 - 0x00? byte, followed by query field name string, followed by query field value string
|}
2eb5a3dbd6cbab0b8aa6a6f79b219d7649c6f91e
42
41
2023-08-19T15:15:09Z
Asie
351
wikitext
text/x-wiki
For the MobileWonderGate software, NTT DoCoMo operated network servers for validating and redirecting URL requests:
* <code>bpl01.mopera.ne.jp</code>
* <code>bpl02.mopera.ne.jp</code>
These servers listened on TCP port 5555 for request packets in the following format, and issued a response in the same format.
== Packet format ==
Every packet sent from and to the server follows the same format: a global header, followed by an arbitrary number of blocks with their respective headers.
=== Header ===
{| class="wikitable"
! Offset
! Length
! Description
|-
| 0x00 || 1 || Unknown, always 0x01
|-
| 0x01 || 1 || Header size in bytes, always 0x18
|-
| rowspan="2" | 0x02
| rowspan="2" | 2
| Request type/Browser configuration:
<pre>
ee?i ?s?w ???? ??p?
|| | | | +- POST request
|| | | +---------- Width: 0 = 1-screen, 1 = 2-screen
|| | +------------ Image size: 0 = 50%, 1 = 100%
|| +--------------- Images: 0 = enabled, 1 = disabled
++----------------- Encoding: 0 = auto, 1 = S-JIS, 2 = EUC
</pre>
|-
| Response type:
* 0x0010 - response: allow + 0 blocks
* 0x0012 - response: deny + 1 block
* 0x0021 - response: require ID/password + 1 block
* 0x0023 - response: unknown (too large?) + 0 blocks
|-
| 0x04 || 4 || Total packet size in bytes, including all headers and blocks
|-
| 0x08 || 4 || Unknown
|-
| 0x0C || 4 || Unknown
|-
| 0x10 || 4 || Unknown (216.0.192.1?)
|-
| 0x14 || 4 || Unknown (255.255.0.0?)
|}
=== Block header ===
Blocks typically consist of zero-terminated strings - a final zero appears to be omitted.
{| class="wikitable"
! Offset
! Length
! Description
|-
| 0x00 || 2 || Block size in bytes, including header
|-
| 0x02 || 1 || Block type:
* 0x01 - 0x00? byte, followed by requested URL string
* 0x03 - 0x00? byte, followed by previous URL string (referrer?)
* 0x11 - ID string, followed by PASS string
* 0x22 - 0x00? byte, followed by query field name string, followed by query field value string
|}
21023a54ea4b1d4a16c6e4a28f43f1a62ea15e76
43
42
2023-08-19T15:44:18Z
Asie
351
wikitext
text/x-wiki
For the MobileWonderGate software, NTT DoCoMo operated network servers for validating and redirecting URL requests:
* <code>bpl01.mopera.ne.jp</code>
* <code>bpl02.mopera.ne.jp</code>
These servers listened on TCP port 5555 for request packets in the following format, and issued a response in the same format.
== Packet format ==
Every packet sent from and to the server follows the same format: a global header, followed by an arbitrary number of blocks with their respective headers.
=== Header ===
{| class="wikitable"
! Offset
! Length
! Description
|-
| 0x00 || 1 || Unknown, always 0x01
|-
| 0x01 || 1 || Header size in bytes, always 0x18
|-
| rowspan="2" | 0x02
| rowspan="2" | 2
| Request type/Browser configuration:
<pre>
ee?i ?s?w ???? ??p?
|| | | | +- POST request
|| | | +---------- Width: 0 = 1-screen, 1 = 2-screen
|| | +------------ Image size: 0 = 50%, 1 = 100%
|| +--------------- Images: 0 = enabled, 1 = disabled
++----------------- Encoding: 0 = auto, 1 = S-JIS, 2 = EUC
</pre>
|-
| Response type:
* 0x0010 - response: allow + 0 blocks
* 0x0012 - response: deny + 1 block
* 0x0021 - response: require ID/password + 1 block
* 0x0023 - response: unknown (too large?) + 0 blocks
|-
| 0x04 || 4? (>= 2) || Total packet size in bytes, including all headers and blocks
|-
| 0x08 || 4 || Unknown
|-
| 0x0C || 4 || Unknown
|-
| 0x10 || 4 || Unknown (216.0.192.1?)
|-
| 0x14 || 4 || Unknown (255.255.0.0?)
|}
=== Block header ===
Blocks typically consist of zero-terminated strings - a final zero appears to be omitted.
{| class="wikitable"
! Offset
! Length
! Description
|-
| 0x00 || 2 || Block size in bytes, including header
|-
| 0x02 || 1 || Block type:
* 0x01 - 0x00? byte, followed by requested URL string
* 0x03 - 0x00? byte, followed by previous URL string (referrer?)
* 0x11 - ID string, followed by PASS string
* 0x22 - 0x00? byte, followed by query field name string, followed by query field value string
|}
2b46fdf698d2af8f51b63ca3eea0a7fe625b327c
44
43
2023-08-19T15:47:31Z
Asie
351
wikitext
text/x-wiki
For the MobileWonderGate software, NTT DoCoMo operated network servers for validating and redirecting URL requests:
* <code>bpl01.mopera.ne.jp</code>
* <code>bpl02.mopera.ne.jp</code>
These servers listened on TCP port 5555 for request packets in the following format, and issued a response in the same format.
== Packet format ==
Every packet sent from and to the server follows the same format: a global header, followed by an arbitrary number of blocks with their respective headers.
=== Header ===
{| class="wikitable"
! Offset
! Length
! Description
|-
| 0x00 || 1 || Unknown, always 0x01
|-
| 0x01 || 1 || Header size in bytes, always 0x18
|-
| rowspan="2" | 0x02
| rowspan="2" | 2
| Request type/Browser configuration:
<pre>
ee?i ?s?w ???? ??p?
|| | | | +- POST request
|| | | +---------- Width: 0 = 1-screen, 1 = 2-screen
|| | +------------ Image size: 0 = 50%, 1 = 100%
|| +--------------- Images: 0 = enabled, 1 = disabled
++----------------- Encoding: 0 = auto, 1 = S-JIS, 2 = EUC
</pre>
|-
| Response type:
* 0x0010 - response: allow + 0 blocks
* 0x0012 - response: deny + 1 block
* 0x0021 - response: require ID/password + 1 block
* 0x0023 - response: unknown (too large?) + 0 blocks
|-
| 0x04 || 4? (>= 2) || Total packet size in bytes, including all headers and blocks
|-
| 0x08 || 4 || Unknown
|-
| 0x0C || 4 || Unknown
|-
| 0x10 || 4 || Unknown (216.0.192.1?)
|-
| 0x14 || 4 || Unknown (255.255.0.0?)
|}
=== Block header ===
Blocks typically consist of zero-terminated strings - a final zero appears to be omitted.
{| class="wikitable"
! Offset
! Length
! Description
|-
| 0x00 || 2 || Block size in bytes, including header
|-
| 0x02 || 1 || Block type:
* 0x01 - 0x00? byte, followed by requested URL string
* 0x03 - 0x00? byte, followed by previous URL string (referrer?)
* 0x11 - ID string, followed by PASS string
* 0x22 - 0x00? byte, followed by query field name string, followed by query field value string
|}
== TODO ==
* Why does the browser not send POST queries despite using an "allow" command? Is there a related Mopera flag?
3e920b927a6fd521c15a2573f96507b48b193c3f
WonderWave
0
16
45
2023-08-19T18:07:15Z
Asie
351
Created page with "The WonderWave is an infrared adapter for the WonderSwan. It is implemented as a bi-directional 9600 bps converter between IrDA and the WonderSwan's UART <ref>[http://www.wonderwitch.com/neta/waza035/index.html 技その35「WonderWaveでファイル転送」]</ref>. == Notes == <references />"
wikitext
text/x-wiki
The WonderWave is an infrared adapter for the WonderSwan. It is implemented as a bi-directional 9600 bps converter between IrDA and the WonderSwan's UART <ref>[http://www.wonderwitch.com/neta/waza035/index.html 技その35「WonderWaveでファイル転送」]</ref>.
== Notes ==
<references />
62706590fab7fbf72310df0dd5904cf24b8221fc
Bandai 2001
0
12
51
48
2023-08-20T18:35:26Z
Lidnariq
7
better target
wikitext
text/x-wiki
In addition to the normal [[Mapper]] banking interface, Bandai's 2001 adds three registers for interacting with a Microwire EEPROM:
{| class="wikitable"
! Category
! Port
! Description
! Bits
! Type
! Notes
|-
! rowspan="4" | External EEPROM
! $C4
| External EEPROM Data
| style="text-align: right" | <tt style="white-space: nowrap">dddd dddd dddd dddd</tt>
| RW16
| Data (d)
|-
! $C6
| External EEPROM Command
| style="text-align: right" | <tt style="white-space: nowrap">0001 CCaa aaaa aaaa</tt>
or <tt style="white-space: nowrap">0000 0001 CCaa aaaa</tt>
| RW16
| Command and address
|-
! rowspan=2|$C8
| External EEPROM Command
| style="text-align: right" | <tt style="white-space: nowrap">ACWR ....</tt>
| W8
| Abort (A), Command (C), Write (W), Read (R)
|-
| External EEPROM Status
| style="text-align: right" | <tt style="white-space: nowrap">.... ..rd</tt>
| R8
| Ready (r), Done (d)
|-
|}
The specific meaning of the "Command" register depends on the model of EEPROM on the PCB. Only three Microwire EEPROMs have been seen used (equivalent to 93C46, 93C76, and 93C86)
On the 2001, the EEPROM "done" bit is buggy and doesn't have useful information. It's set when a Read completes, but is only cleared when a Command or Write is started. (To be useful it would need to also be cleared when a Read is started).
If more than ACWR bit is set at the same time, the 2001 ignores it.
The CWR bits specify how many data bits are sent/received. C: No data bits. W: Send Data register after command register. R: Receive data register after sending command register.
If the A bit is set, the transaction immediately stops.
(Upload logic analyzer traces here)
249e0c1e131629cfd316417728016df85da170fa
Bandai 2003
0
13
52
39
2023-08-20T18:42:06Z
Lidnariq
7
better link target
wikitext
text/x-wiki
In addition to the normal [[Mapper]] banking interface, Bandai's 2003 adds registers for an RTC interface, GPO pins, self flashing, and accessing more than 16MiB of ROM.
{| class="wikitable"
! Category
! Port
! Description
! Bits
! Type
! Notes
|-
! rowspan="3" | RTC
! rowspan="2" | $CA
| RTC Command
| style="text-align: right" | <tt style="white-space: nowrap">...1 CCCC</tt>
| W8
| Command (C)
|-
| RTC Status
| style="text-align: right" | <tt style="white-space: nowrap">D..B CCCC</tt>
| R8
| Busy (B), Command (C), Data needed (D)
|-
! $CB
| RTC Payload
| style="text-align: right" | <tt style="white-space: nowrap">dddd dddd</tt>
| RW8
| Data (d)
|-
! rowspan="2" | GPO
! $CC
| GPO Data Direction
| style="text-align: right" | <tt style="white-space: nowrap">0000 oooo</tt>
| RW8
| 1 = output, 0 = high-impedance (weak pull-down)
|-
! $CD
| GPO Data
| style="text-align: right" | <tt style="white-space: nowrap">0000 dddd</tt>
| RW8
| 1 = 3V, if enabled by data direction
|-
! Self-Flash
! $CE
| Self-Flash Control
| style="text-align: right" | <tt style="white-space: nowrap">0000 000r</tt>
| RW8
| 1 = ROM is accessible at segment 0x1000;
0 = RAM instead.
|-
! rowspan="4" | Extended bankswitching
! $CF
| ROM Linear (EX) Bank
| style="text-align: right" | <tt style="white-space: nowrap">00bb bbbb</tt>
| RW8
| Selects a 1MiB bank accessed via segments 0x4000 through 0xF000. Identical to the register at 0xC0.
|-
! $D0
| RAM(/ROM) Bank
| style="text-align: right" | <tt style="white-space: nowrap">0000 00bb bbbb bbbb</tt>
| RW16
| Selects a 64KiB bank accessed via segment 0x1000. Lower 8 bits are identical to the register at 0xC1.
|-
! $D2
| ROM0 Bank
| style="text-align: right" | <tt style="white-space: nowrap">0000 00bb bbbb bbbb</tt>
| RW16
| Selects a 64KiB bank accessed via segment 0x2000. Lower 8 bits are identical to the register at 0xC2.
|-
! $D4
| ROM1 Bank
| style="text-align: right" | <tt style="white-space: nowrap">0000 00bb bbbb bbbb</tt>
| RW16
| Selects a 64KiB bank accessed via segment 0x3000. Lower 8 bits are identical to the register at 0xC3.
|}
Not all PCBs are wired to support self-flashing. Not all ROMs have the needed /BYTE pin. Even on PCBs without support, ROM can still be enabled by writing to port $CE.
ad71476be4c8352f9668b164f527fc78ad5f9dc2
73
52
2023-08-21T21:06:27Z
Lidnariq
7
wikitext
text/x-wiki
In addition to the normal [[Mapper]] banking interface, Bandai's 2003 adds registers for an RTC interface, GPO pins, self flashing, and accessing more than 16MiB of ROM.
{| class="wikitable"
! Category
! Port
! Description
! Bits
! Type
! Notes
|-
! rowspan="3" | RTC
! rowspan="2" | $CA
| RTC Command
| style="text-align: right" | <tt style="white-space: nowrap">...1 CCCC</tt>
| W8
| Command (C)
|-
| RTC Status
| style="text-align: right" | <tt style="white-space: nowrap">D00B CCCC</tt>
| R8
| Busy (B), Command (C), Data needed (D)
|-
! $CB
| RTC Payload
| style="text-align: right" | <tt style="white-space: nowrap">dddd dddd</tt>
| RW8
| Data (d)
|-
! rowspan="2" | GPO
! $CC
| GPO Data Direction
| style="text-align: right" | <tt style="white-space: nowrap">0000 oooo</tt>
| RW8
| 1 = output, 0 = high-impedance (weak pull-down)
|-
! $CD
| GPO Data
| style="text-align: right" | <tt style="white-space: nowrap">0000 dddd</tt>
| RW8
| 1 = 3V, if enabled by data direction
|-
! Self-Flash
! $CE
| Self-Flash Control
| style="text-align: right" | <tt style="white-space: nowrap">0000 000r</tt>
| RW8
| 1 = ROM is accessible at segment 0x1000;
0 = RAM instead.
|-
! rowspan="4" | Extended bankswitching
! $CF
| ROM Linear (EX) Bank
| style="text-align: right" | <tt style="white-space: nowrap">00bb bbbb</tt>
| RW8
| Selects a 1MiB bank accessed via segments 0x4000 through 0xF000. Identical to the register at 0xC0.
|-
! $D0
| RAM(/ROM) Bank
| style="text-align: right" | <tt style="white-space: nowrap">0000 00bb bbbb bbbb</tt>
| RW16
| Selects a 64KiB bank accessed via segment 0x1000. Lower 8 bits are identical to the register at 0xC1.
|-
! $D2
| ROM0 Bank
| style="text-align: right" | <tt style="white-space: nowrap">0000 00bb bbbb bbbb</tt>
| RW16
| Selects a 64KiB bank accessed via segment 0x2000. Lower 8 bits are identical to the register at 0xC2.
|-
! $D4
| ROM1 Bank
| style="text-align: right" | <tt style="white-space: nowrap">0000 00bb bbbb bbbb</tt>
| RW16
| Selects a 64KiB bank accessed via segment 0x3000. Lower 8 bits are identical to the register at 0xC3.
|}
Not all PCBs are wired to support self-flashing. Not all ROMs have the needed /BYTE pin. Even on PCBs without support, ROM can still be enabled by writing to port $CE.
== 2003 RTC interface ==
The 2003's RTC interface is a simple half-duplex SPI-like protocol. A write to $CA will start a transaction, depending on the exact value written.
For specifics of what the S-3511A expects to be done with these bytes, see [[Real-Time Clock]].
(Put logic analyzer traces here)
Values are as follows:
=== $00-$0F, $1C-$1F ===
Immediately stop the transaction. This cannot be safely used to abort an ongoing transaction, because the 2003 still relays the 384kHz clock. In contrast, normal termination stops relaying that clock.
=== $10, $11 ===
Send command byte ($60 or $61 respectively) and stop.
=== $12 ===
Send command byte ($62), then send byte stored in $CB, then stop. The 2003 expects that the value in $CB is valid and does not pause if the CPU hasn't yet written a value.
=== $13 ===
Send command byte ($63), then receive byte, then stop. After the "data needed" is set or the "busy" bit is clear the value can be read from $CB.
=== $14 ===
Send command byte ($64), then send seven bytes of payload, then stop. The 2003 expects that the ''first'' byte is preloaded in $CB, but pauses for the CPU to write each subsequent byte by setting the "Data needed" bit.
=== $15 ===
Send command byte ($65), then receive seven bytes of payload, then stop. The 2003 pauses for the CPU to read each subsequent byte by setting the "Data needed" bit.
=== $16 ===
Send command byte ($66), then send three bytes of payload, then stop.bit.
=== $17 ===
Send command byte ($67), then receive three bytes of payload, then stop.
=== $18, $1A ===
Send command byte ($68 or $6A), then send two bytes of payload, then stop.needed" bit.
=== $19, $1B ===
Send command byte ($69 or $6B), then receive two bytes of payload, then stop.
fb1ba04fb3953f48783693db09e76e88284eff8b
74
73
2023-08-21T21:09:28Z
Lidnariq
7
/* 2003 RTC interface */ floating SIO pin is pulled high
wikitext
text/x-wiki
In addition to the normal [[Mapper]] banking interface, Bandai's 2003 adds registers for an RTC interface, GPO pins, self flashing, and accessing more than 16MiB of ROM.
{| class="wikitable"
! Category
! Port
! Description
! Bits
! Type
! Notes
|-
! rowspan="3" | RTC
! rowspan="2" | $CA
| RTC Command
| style="text-align: right" | <tt style="white-space: nowrap">...1 CCCC</tt>
| W8
| Command (C)
|-
| RTC Status
| style="text-align: right" | <tt style="white-space: nowrap">D00B CCCC</tt>
| R8
| Busy (B), Command (C), Data needed (D)
|-
! $CB
| RTC Payload
| style="text-align: right" | <tt style="white-space: nowrap">dddd dddd</tt>
| RW8
| Data (d)
|-
! rowspan="2" | GPO
! $CC
| GPO Data Direction
| style="text-align: right" | <tt style="white-space: nowrap">0000 oooo</tt>
| RW8
| 1 = output, 0 = high-impedance (weak pull-down)
|-
! $CD
| GPO Data
| style="text-align: right" | <tt style="white-space: nowrap">0000 dddd</tt>
| RW8
| 1 = 3V, if enabled by data direction
|-
! Self-Flash
! $CE
| Self-Flash Control
| style="text-align: right" | <tt style="white-space: nowrap">0000 000r</tt>
| RW8
| 1 = ROM is accessible at segment 0x1000;
0 = RAM instead.
|-
! rowspan="4" | Extended bankswitching
! $CF
| ROM Linear (EX) Bank
| style="text-align: right" | <tt style="white-space: nowrap">00bb bbbb</tt>
| RW8
| Selects a 1MiB bank accessed via segments 0x4000 through 0xF000. Identical to the register at 0xC0.
|-
! $D0
| RAM(/ROM) Bank
| style="text-align: right" | <tt style="white-space: nowrap">0000 00bb bbbb bbbb</tt>
| RW16
| Selects a 64KiB bank accessed via segment 0x1000. Lower 8 bits are identical to the register at 0xC1.
|-
! $D2
| ROM0 Bank
| style="text-align: right" | <tt style="white-space: nowrap">0000 00bb bbbb bbbb</tt>
| RW16
| Selects a 64KiB bank accessed via segment 0x2000. Lower 8 bits are identical to the register at 0xC2.
|-
! $D4
| ROM1 Bank
| style="text-align: right" | <tt style="white-space: nowrap">0000 00bb bbbb bbbb</tt>
| RW16
| Selects a 64KiB bank accessed via segment 0x3000. Lower 8 bits are identical to the register at 0xC3.
|}
Not all PCBs are wired to support self-flashing. Not all ROMs have the needed /BYTE pin. Even on PCBs without support, ROM can still be enabled by writing to port $CE.
== 2003 RTC interface ==
The 2003's RTC interface is a simple half-duplex SPI-like protocol. A write to $CA will start a transaction, depending on the exact value written.
If there is no external S-3511A, all bytes will read back as $FF due to a weak pull-up inside the 2003.
For specifics of what the S-3511A expects to be done with these bytes, see [[Real-Time Clock]].
(Put logic analyzer traces here)
Values are as follows:
=== $00-$0F, $1C-$1F ===
Immediately stop the transaction. This cannot be safely used to abort an ongoing transaction, because the 2003 still relays the 384kHz clock. In contrast, normal termination stops relaying that clock.
=== $10, $11 ===
Send command byte ($60 or $61 respectively) and stop.
=== $12 ===
Send command byte ($62), then send byte stored in $CB, then stop. The 2003 expects that the value in $CB is valid and does not pause if the CPU hasn't yet written a value.
=== $13 ===
Send command byte ($63), then receive byte, then stop. After the "data needed" is set or the "busy" bit is clear the value can be read from $CB.
=== $14 ===
Send command byte ($64), then send seven bytes of payload, then stop. The 2003 expects that the ''first'' byte is preloaded in $CB, but pauses for the CPU to write each subsequent byte by setting the "Data needed" bit.
=== $15 ===
Send command byte ($65), then receive seven bytes of payload, then stop. The 2003 pauses for the CPU to read each subsequent byte by setting the "Data needed" bit.
=== $16 ===
Send command byte ($66), then send three bytes of payload, then stop.bit.
=== $17 ===
Send command byte ($67), then receive three bytes of payload, then stop.
=== $18, $1A ===
Send command byte ($68 or $6A), then send two bytes of payload, then stop.needed" bit.
=== $19, $1B ===
Send command byte ($69 or $6B), then receive two bytes of payload, then stop.
281ed534df91aac3977ad77a4b71c3ae4f232d79
75
74
2023-08-21T21:09:58Z
Lidnariq
7
/* 2003 RTC interface */ edito
wikitext
text/x-wiki
In addition to the normal [[Mapper]] banking interface, Bandai's 2003 adds registers for an RTC interface, GPO pins, self flashing, and accessing more than 16MiB of ROM.
{| class="wikitable"
! Category
! Port
! Description
! Bits
! Type
! Notes
|-
! rowspan="3" | RTC
! rowspan="2" | $CA
| RTC Command
| style="text-align: right" | <tt style="white-space: nowrap">...1 CCCC</tt>
| W8
| Command (C)
|-
| RTC Status
| style="text-align: right" | <tt style="white-space: nowrap">D00B CCCC</tt>
| R8
| Busy (B), Command (C), Data needed (D)
|-
! $CB
| RTC Payload
| style="text-align: right" | <tt style="white-space: nowrap">dddd dddd</tt>
| RW8
| Data (d)
|-
! rowspan="2" | GPO
! $CC
| GPO Data Direction
| style="text-align: right" | <tt style="white-space: nowrap">0000 oooo</tt>
| RW8
| 1 = output, 0 = high-impedance (weak pull-down)
|-
! $CD
| GPO Data
| style="text-align: right" | <tt style="white-space: nowrap">0000 dddd</tt>
| RW8
| 1 = 3V, if enabled by data direction
|-
! Self-Flash
! $CE
| Self-Flash Control
| style="text-align: right" | <tt style="white-space: nowrap">0000 000r</tt>
| RW8
| 1 = ROM is accessible at segment 0x1000;
0 = RAM instead.
|-
! rowspan="4" | Extended bankswitching
! $CF
| ROM Linear (EX) Bank
| style="text-align: right" | <tt style="white-space: nowrap">00bb bbbb</tt>
| RW8
| Selects a 1MiB bank accessed via segments 0x4000 through 0xF000. Identical to the register at 0xC0.
|-
! $D0
| RAM(/ROM) Bank
| style="text-align: right" | <tt style="white-space: nowrap">0000 00bb bbbb bbbb</tt>
| RW16
| Selects a 64KiB bank accessed via segment 0x1000. Lower 8 bits are identical to the register at 0xC1.
|-
! $D2
| ROM0 Bank
| style="text-align: right" | <tt style="white-space: nowrap">0000 00bb bbbb bbbb</tt>
| RW16
| Selects a 64KiB bank accessed via segment 0x2000. Lower 8 bits are identical to the register at 0xC2.
|-
! $D4
| ROM1 Bank
| style="text-align: right" | <tt style="white-space: nowrap">0000 00bb bbbb bbbb</tt>
| RW16
| Selects a 64KiB bank accessed via segment 0x3000. Lower 8 bits are identical to the register at 0xC3.
|}
Not all PCBs are wired to support self-flashing. Not all ROMs have the needed /BYTE pin. Even on PCBs without support, ROM can still be enabled by writing to port $CE.
== 2003 RTC interface ==
The 2003's RTC interface is a simple half-duplex SPI-like protocol. A write to $CA will start a transaction, depending on the exact value written.
If there is no external S-3511A, all bytes will read back as $FF due to a weak pull-up inside the 2003.
For specifics of what the S-3511A expects to be done with these bytes, see [[Real-Time Clock]].
(Put logic analyzer traces here)
Values are as follows:
=== $00-$0F, $1C-$1F ===
Immediately stop the transaction. This cannot be safely used to abort an ongoing transaction, because the 2003 still relays the 384kHz clock. In contrast, normal termination stops relaying that clock.
=== $10, $11 ===
Send command byte ($60 or $61 respectively) and stop.
=== $12 ===
Send command byte ($62), then send byte stored in $CB, then stop. The 2003 expects that the value in $CB is valid and does not pause if the CPU hasn't yet written a value.
=== $13 ===
Send command byte ($63), then receive byte, then stop. After the "data needed" is set or the "busy" bit is clear the value can be read from $CB.
=== $14 ===
Send command byte ($64), then send seven bytes of payload, then stop. The 2003 expects that the ''first'' byte is preloaded in $CB, but pauses for the CPU to write each subsequent byte by setting the "Data needed" bit.
=== $15 ===
Send command byte ($65), then receive seven bytes of payload, then stop. The 2003 pauses for the CPU to read each subsequent byte by setting the "Data needed" bit.
=== $16 ===
Send command byte ($66), then send three bytes of payload, then stop.
=== $17 ===
Send command byte ($67), then receive three bytes of payload, then stop.
=== $18, $1A ===
Send command byte ($68 or $6A), then send two bytes of payload, then stop.
=== $19, $1B ===
Send command byte ($69 or $6B), then receive two bytes of payload, then stop.
0556efe6c59febe6d9a6a500ad049dde51d24379
Mapper
0
17
53
2023-08-20T18:54:40Z
Lidnariq
7
create from my notes
wikitext
text/x-wiki
There are three documented memory-mapping chips used on the WonderSwan and Pocket Challenge V2:
* [[Bandai 2001]]
* [[Bandai 2003]]
* [[KARNAK]]
All three provide this same common subset for memory banking:
{| class="wikitable"
! Category
! Port
! Description
! Bits
! Type
! Notes
|-
! rowspan="4" | Extended bankswitching
! $C0
| ROM Linear (EX) Bank
| style="text-align: right" | <tt style="white-space: nowrap">00BB bbbb</tt>
| RW8
| Selects a 1MiB bank accessed via segments 0x4000 through 0xF000.
|-
! $C1
| RAM(/ROM) Bank
| style="text-align: right" | <tt style="white-space: nowrap">bbbb bbbb</tt>
| RW8
| Selects a 64KiB bank accessed via segment 0x1000.
|-
! $C2
| ROM0 Bank
| style="text-align: right" | <tt style="white-space: nowrap">bbbb bbbb</tt>
| RW8
| Selects a 64KiB bank accessed via segment 0x2000.
|-
! $C3
| ROM1 Bank
| style="text-align: right" | <tt style="white-space: nowrap">bbbb bbbb</tt>
| RW8
| Selects a 64KiB bank accessed via segment 0x3000.
|}
Note that the number of bits in the Linear bank register depends on the mapper.
The black-and-white WonderSwan expects that the register at $C3 will power up holding $FF.
fc3aa2bbf24508dc738f7674eebf184579312756
2003 Mapper pinout
0
11
54
49
2023-08-20T19:07:42Z
Lidnariq
7
link to corresponding mapper description
wikitext
text/x-wiki
[[Bandai 2003]]: 48-pin 0.5mm pitch TQFP
Gnd -- /01 o 48\ <- CLK
GPO 3 <? /02 47\ <- /SEL
GPO 2 <? /03 46\ <- /WR
GPO 1 <? /04 45\ <- /RD
GPO 0 <? /05 44\ <- M/IO
Gnd -- /06 43\ -> /MBC
RTC SIO <> /07 42\ <- /Reset
RTC SCK <- /08 41\ <- CPU A16
RTC CS <- /09 40\ <- CPU A17
ROM A25 <- /10 39\ <- CPU A18
ROM A24 <- /11 BANDAI 38\ <- CPU A19
ROM A23 <- /12 2003 37\ <- A3
ROM A22 <- \13 36/ <- A2
ROM A17 <- \14 35/ <- A1
ROM A16 <- \15 34/ <- A0
Gnd -- \16 33/ <> D0
ROM A20 <- \17 32/ <> D1
ROM A21 <- \18 31/ <> D2
ROM A19 <- \19 30/ -- Vcc
ROM A18 <- \20 29/ <> D3
SRAM /CS <- \21 28/ <> D4
ROM /CS <- \22 27/ <> D5
ROM /BYTE <- \23 26/ <> D6
D15 (A-1) <Z \24 O 25/ <> D7
Note the orientation of the text: "Bandai 2003" when viewed upright specifies pin 1 is bottom face, leftmost.
15187cb56f2f8af756135b1e7486bee4fae550a8
64
54
2023-08-21T06:42:50Z
Fiskbit
37
Reformats pinout to match other QFPs on NESdev. Adds orientation and legend.
wikitext
text/x-wiki
_____
/ \
Gnd -- / 1 48 \ <- CLK
GPO 3 <? / 2 O 47 \ <- /SEL
GPO 2 <? / 3 46 \ <- /WR
GPO 1 <? / 4 45 \ <- /RD
GPO 0 <? / 5 44 \ <- M/IO
Gnd -- / 6 43 \ -> /MBC
RTC SIO <> / 7 42 \ <- /Reset
RTC SCK <- / 8 41 \ <- CPU A16
RTC CS <- / 9 40 \ <- CPU A17
ROM A25 <- / 10 39 \ <- CPU A18
ROM A24 <- / 11 38 \ <- CPU A19 Orientation:
ROM A23 <- / 12 37 \ <- A3 ----------------
/ BANDAI 2003 \ 36 25
\ Package TQFP-48 / | |
ROM A22 <- \ 13 0.5mm pitch 36 / <- A2 .--------.
ROM A17 <- \ 14 35 / <- A1 37-|BANDAI O|-24
ROM A16 <- \ 15 34 / <- A0 |2003 |
Gnd -- \ 16 33 / <> D0 48-|O 039XR|-13
ROM A20 <- \ 17 32 / <> D1 \--------'
ROM A21 <- \ 18 31 / <> D2 | |
ROM A19 <- \ 19 30 / -- Vcc 01 12
ROM A18 <- \ 20 29 / <> D3
SRAM /CS <- \ 21 28 / <> D4 Legend:
ROM /CS <- \ 22 27 / <> D5 -------------------------------------------
ROM /BYTE <- \ 23 O 26 / <> D6 --[2003]-- Power
D15 (A-1) <Z \ 24 25 / <> D7 ->[2003]<- 2003 input
\ / <-[2003]-> 2003 output
\ / <>[2003]<> Bidirectional
\ / <Z[2003]Z> Output or high impedance
V <?[2003]?> Output, unknown if bidirectional
(Note that the corner indicator for pin 1 is subtle
compared to the other corners as well as other QFPs.)
b76e09391767a3b116dbc915f1510c9fb1247461
2001 Mapper pinout
0
10
55
50
2023-08-20T19:08:03Z
Lidnariq
7
link to corresponding mapper description
wikitext
text/x-wiki
[[Bandai 2001]]: 48-pin 0.5mm pitch TQFP
D4 <> /01 o 48\ <> D5
D3 <> /02 47\ <> D6
D2 <> /03 46\ <> D7
D1 <> /04 45\ -> SRAM /CS
D0 <> /05 44\ -- Vcc
Gnd -- /06 43\ -> ROM /CS
A0 -> /07 42\ -> ROM A18
A1 -> /08 41\ -> ROM A19
Vcc -- /09 40\ -- Gnd
A2 -> /10 39\ -> ROM A21
A3 -> /11 38\ -> ROM A20
CPU A19 -> /12 BANDAI 37\ -> ROM A16
CPU A18 -> \13 2001 36/ -> ROM A17
CPU A17 -> \14 35/ -> ROM A22
CPU A16 -> \15 34/ -- nc
Vcc -- \16 33/ -> Microwire CS
/Reset ?> \17 32/ -> Microwire DI
/MBC <- \18 31/ <- Microwire DO
M/IO -> \19 30/ -- Vcc
/RD -> \20 29/ -> Microwire SK
/WR -> \21 28/ ?? Gnd
/SEL -> \22 27/ ?? Gnd
CLK -> \23 26/ ?? Gnd
Gnd -- \24 O 25/ ?? Gnd
Note the orientation of the text: "Bandai 2001" when viewed upright specifies pin 1 is bottom face, leftmost.
bbb1ac87b80b864d0876155826b5af767ef519f1
63
55
2023-08-21T06:42:07Z
Fiskbit
37
Reformats pinout to match other QFPs on NESdev. Adds orientation and legend.
wikitext
text/x-wiki
_____
/ \
D4 <> / 1 48 \ <> D5
D3 <> / 2 O 47 \ <> D6
D2 <> / 3 46 \ <> D7
D1 <> / 4 45 \ -> SRAM /CS
D0 <> / 5 44 \ -- Vcc
Gnd -- / 6 43 \ -> ROM /CS
A0 -> / 7 42 \ -> ROM A18
A1 -> / 8 41 \ -> ROM A19
Vcc -- / 9 40 \ -- Gnd
A2 -> / 10 39 \ -> ROM A21
A3 -> / 11 38 \ -> ROM A20 Orientation:
CPU A19 -> / 12 37 \ -> ROM A16 ----------------
/ BANDAI 2001 \ 36 25
\ Package TQFP-48 / | |
CPU A18 -> \ 13 0.5mm pitch 36 / -> ROM A17 .--------.
CPU A17 -> \ 14 35 / -> ROM A22 37-|BANDAI O|-24
CPU A16 -> \ 15 34 / -- n/c |2001 |
Vcc -- \ 16 33 / -> Microwire CS 48-|O 914XC|-13
/Reset ?> \ 17 32 / -> Microwire DI \--------'
/MBC <- \ 18 31 / <- Microwire DO | |
M/IO -> \ 19 30 / -- Vcc 01 12
/RD -> \ 20 29 / -> Microwire SK
/WR -> \ 21 28 / ?? Gnd Legend:
/SEL -> \ 22 27 / ?? Gnd ------------------------------------------
CLK -> \ 23 O 26 / ?? Gnd --[2001]-- Power, n/a
Gnd -- \ 24 25 / ?? Gnd ->[2001]<- 2001 input
\ / <-[2001]-> 2001 output
\ / <>[2001]<> Bidirectional
\ / ??[2001]?? Unknown
V ?>[2001]<? Input, unknown if bidirectional
(Note that the corner indicator for pin 1 is subtle
compared to the other corners as well as other QFPs.)
9f96bdf3f6a2e19c962186fb472fe59f1cafe012
I/O port map
0
8
56
24
2023-08-20T19:09:36Z
Asie
351
add cartridge I/o link
wikitext
text/x-wiki
* Superscripts are used to mark ports specific to a given mode or platform:
** Color mode: <sup>(color)</sup>.
** WS/WSC/SC console: <sup>(WS)</sup>, <sup>(WSC)</sup>, <sup>(SC)</sup>.
* If two Bits rows are provided, the second one refers to the "Color" mode.
* The Type can be: R - readable, W - writable, L - writable before boot ROM lockout, 8/16 - width (byte/word).
{| class="wikitable"
! Category
! Port
! Description
! Bits
! Type
! Notes
|-
! rowspan="45" | [[Display]]
! $00
| [[Display#Display Control|Display Control]]
| style="text-align: right" | <tt style="white-space: nowrap">..ow Ws21</tt>
| RW8
|
|-
! $01
| [[Display#Display Background|Display Background]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .sss</tt>
<tt style="white-space: nowrap">pppp iiii</tt>
| RW8
| Shade (s)
Palette (p), Index (i)
|-
! $02
| [[Display#Current Line|Display Current Line]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll</tt>
| R8
| Line (l)
|-
! $03
| [[Display#Interrupt Line|Display Interrupt Line]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll</tt>
| RW8
| Line (l)
|-
! $04
| [[Display#Sprite Table Address|Sprite Table Address]]
| style="text-align: right" | <tt style="white-space: nowrap">...a aaaa</tt>
<tt style="white-space: nowrap">..aa aaaa</tt>
| RW8
| Address >> 9 (a)
|-
! $05
| [[Display#Sprite Table First|Sprite Table First]]
| style="text-align: right" | <tt style="white-space: nowrap">.iii iiii</tt>
| RW8
| Index (i)
|-
! $06
| [[Display#Sprite Table Count|Sprite Table Count]]
| style="text-align: right" | <tt style="white-space: nowrap">cccc cccc</tt>
| RW8
| Count (c)
|-
! $07
| [[Display#Screen Address|Screen Address]]
| style="text-align: right" | <tt style="white-space: nowrap">.222 .111</tt>
<tt style="white-space: nowrap">2222 1111</tt>
| RW8
| Screen 1 address >> 11 (1)
Screen 2 address >> 11 (2)
|-
! $08
| [[Display#Screen 2 Window|Screen 2 Window Left]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $09
| [[Display#Screen 2 Window|Screen 2 Window Top]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $0A
| [[Display#Screen 2 Window|Screen 2 Window Right]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $0B
| [[Display#Screen 2 Window|Screen 2 Window Bottom]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $0B
| [[Display#Sprite Window|Sprite Window Left]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $0C
| [[Display#Sprite Window|Sprite Window Top]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $0E
| [[Display#Sprite Window|Sprite Window Right]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $0F
| [[Display#Sprite Window|Sprite Window Bottom]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $10
| [[Display#Screen Scroll|Screen 1 Scroll X]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $11
| [[Display#Screen Scroll|Screen 1 Scroll Y]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $12
| [[Display#Screen Scroll|Screen 2 Scroll X]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $13
| [[Display#Screen Scroll|Screen 2 Scroll Y]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $14
| [[Display#LCD Control|LCD Control]]
| style="text-align: right" | <tt style="white-space: nowrap">.... ..Ce</tt>
| RW8
| Contrast (C)<sup>(WSC)</sup>, Enable (e)
|-
! $15
| [[Display#LCD Icon Control|LCD Icon Control]]
| style="text-align: right" | <tt style="white-space: nowrap">..32 1hvs</tt>
| RW8
| Auxillary 3 (3), Auxillary 2 (2), Auxillary 1 (1),
Horizontal (h), Vertical (v), Sleep (s)
|-
! $16
| [[Display#LCD Final Line|LCD Final Line]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll</tt>
| RW8
| Line (l)
|-
! $17
| [[Display#LCD Back Porch Line|LCD Back Porch Line]]<sup>(WSC)</sup>
| style="text-align: right" | <tt style="white-space: nowrap">llll llll</tt>
| RW8
| Line (l)
|-
! $1A
| [[Display#LCD Status|LCD Status]]
| style="text-align: right" | <tt style="white-space: nowrap">...v vv.e</tt>
| RW8
| Volume segment status (v), Enable (e)
|-
! $1C
| [[Display#LCD Mono Shade LUT|LCD Mono Shade LUT 0/1]]
| style="text-align: right" | <tt style="white-space: nowrap">1111 0000</tt>
| RW8
| Shade index
|-
! $1D
| [[Display#LCD Mono Shade LUT|LCD Mono Shade LUT 2/3]]
| style="text-align: right" | <tt style="white-space: nowrap">3333 2222</tt>
| RW8
| Shade index
|-
! $1E
| [[Display#LCD Mono Shade LUT|LCD Mono Shade LUT 4/5]]
| style="text-align: right" | <tt style="white-space: nowrap">5555 4444</tt>
| RW8
| Shade index
|-
! $1F
| [[Display#LCD Mono Shade LUT|LCD Mono Shade LUT 6/7]]
| style="text-align: right" | <tt style="white-space: nowrap">7777 6666</tt>
| RW8
| Shade index
|-
! $20
| [[Display#LCD Mono Palette|LCD Mono Palette 0]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $22
| [[Display#LCD Mono Palette|LCD Mono Palette 1]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $24
| [[Display#LCD Mono Palette|LCD Mono Palette 2]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $26
| [[Display#LCD Mono Palette|LCD Mono Palette 3]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $28
| [[Display#LCD Mono Palette|LCD Mono Palette 4]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $2A
| [[Display#LCD Mono Palette|LCD Mono Palette 5]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $2C
| [[Display#LCD Mono Palette|LCD Mono Palette 6]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $2E
| [[Display#LCD Mono Palette|LCD Mono Palette 7]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $30
| [[Display#LCD Mono Palette|LCD Mono Palette 8]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $32
| [[Display#LCD Mono Palette|LCD Mono Palette 9]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $34
| [[Display#LCD Mono Palette|LCD Mono Palette 10]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $36
| [[Display#LCD Mono Palette|LCD Mono Palette 11]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $38
| [[Display#LCD Mono Palette|LCD Mono Palette 12]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $3A
| [[Display#LCD Mono Palette|LCD Mono Palette 13]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $3C
| [[Display#LCD Mono Palette|LCD Mono Palette 14]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $3E
| [[Display#LCD Mono Palette|LCD Mono Palette 15]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! rowspan="10" | [[DMA]]<sup>(color)</sup>
! $40
| [[DMA#General DMA|GDMA Source Address Low]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll llll llll</tt>
| RW16
| Linear address, low 16 bits (l)
|-
! $42
| [[DMA#General DMA|GDMA Source Address High]]
| style="text-align: right" | <tt style="white-space: nowrap">.... hhhh</tt>
| RW8
| Linear address, high 4 bits (h)
|-
! $44
| [[DMA#General DMA|GDMA Destination Address]]
| style="text-align: right" | <tt style="white-space: nowrap">aaaa aaaa aaaa aaaa</tt>
| RW16
| IRAM address (a)
|-
! $46
| [[DMA#General DMA|GDMA Length]]
| style="text-align: right" | <tt style="white-space: nowrap">bbbb bbbb bbbb bbbb</tt>
| RW16
| Bytes (b)
|-
! $48
| [[DMA#General DMA|GDMA Control]]
| style="text-align: right" | <tt style="white-space: nowrap">ed.. ....</tt>
| RW8
| Enable (e), Decrement (d)
|-
! $4A
| [[DMA#Sound DMA|SDMA Source Address Low]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll llll llll</tt>
| RW16
| Linear address, low 16 bits (l)
|-
! $4C
| [[DMA#Sound DMA|SDMA Source Address High]]
| style="text-align: right" | <tt style="white-space: nowrap">.... hhhh</tt>
| RW8
| Linear address, high 4 bits (h)
|-
! $4E
| [[DMA#Sound DMA|SDMA Length Low]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll llll llll</tt>
| RW16
| Length, low 16 bits (l)
|-
! $50
| [[DMA#Sound DMA|SDMA Length High]]
| style="text-align: right" | <tt style="white-space: nowrap">.... hhhh</tt>
| RW8
| Length, high 4 bits (h)
|-
! $52
| [[DMA#Sound DMA|SDMA Control]]
| style="text-align: right" | <tt style="white-space: nowrap">ed.t r?ff</tt>
| RW8
| Enable (e), Decrement (d), Target (t),
Repeat (r), Frequency (f)
|-
! rowspan="2" | System<sup>(color)</sup>
! $60
| System Control 2
| style="text-align: right" | <tt style="white-space: nowrap">c4C. ?.??</tt>
| RW8
| Color (c), 4BPP (4), Chunky (C)
|-
! $62
| System Control 3
| style="text-align: right" | <tt style="white-space: nowrap">S... ...p</tt>
| RW8
| SwanCrystal (S), Power off (p)
|-
! rowspan="5" | [[Hyper Voice]]<sup>(color)</sup>
! $64
| Hyper Voice Left Output
| style="text-align: right" | <tt style="white-space: nowrap">ssss ssss ssss ssss</tt>
| W16
| Raw sample (s)
|-
! $66
| Hyper Voice Right Output
| style="text-align: right" | <tt style="white-space: nowrap">ssss ssss ssss ssss</tt>
| W16
| Raw sample (s)
|-
! $68
| Hyper Voice Left Input
| style="text-align: right" | <tt style="white-space: nowrap">ssss ssss</tt>
| 8
| Sample (s)
|-
! $69
| Hyper Voice Right Input
| style="text-align: right" | <tt style="white-space: nowrap">ssss ssss</tt>
| 8
| Sample (s)
|-
! $6A
| Hyper Voice Control
| style="text-align: right" | <tt style="white-space: nowrap">.mmc .... errr ffss</tt>
| RW16
| Mask (m), Channel (c), Enable (e),
Rate (r), Format (f), Shift (s)
|-
! rowspan="8" | [[Display]]<sup>(SC)</sup>
! $70
| LCD Timing Configuration 1?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $71
| LCD Timing Configuration 2?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $72
| LCD Timing Configuration 3?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $73
| LCD Timing Configuration 4?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $74
| LCD Timing Configuration 5?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $75
| LCD Timing Configuration 6?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $76
| LCD Timing Configuration 7?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $77
| LCD Timing Configuration 8?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! rowspan="20" | [[Sound]]
! $80
| Sound Channel 1 Frequency
| style="text-align: right" | <tt style="white-space: nowrap">.... .ddd dddd dddd</tt>
| RW16
| Divider (d)
|-
! $82
| Sound Channel 2 Frequency
| style="text-align: right" | <tt style="white-space: nowrap">.... .ddd dddd dddd</tt>
| RW16
| Divider (d)
|-
! $84
| Sound Channel 3 Frequency
| style="text-align: right" | <tt style="white-space: nowrap">.... .ddd dddd dddd</tt>
| RW16
| Divider (d)
|-
! $86
| Sound Channel 4 Frequency
| style="text-align: right" | <tt style="white-space: nowrap">.... .ddd dddd dddd</tt>
| RW16
| Divider (d)
|-
! $88
| Sound Channel 1 Volume
| style="text-align: right" | <tt style="white-space: nowrap">llll rrrr</tt>
| RW8
| Left (l), Right (r)
|-
! rowspan="2" | $89
| Sound Channel 2 Volume
| style="text-align: right" | <tt style="white-space: nowrap">llll rrrr</tt>
| RW8
| Left (l), Right (r)
|-
| Sound Channel 2 Voice Sample
| style="text-align: right" | <tt style="white-space: nowrap">ssss ssss</tt>
| RW8
| Sample (s)
|-
! $8A
| Sound Channel 3 Volume
| style="text-align: right" | <tt style="white-space: nowrap">llll rrrr</tt>
| RW8
| Left (l), Right (r)
|-
! $8B
| Sound Channel 4 Volume
| style="text-align: right" | <tt style="white-space: nowrap">llll rrrr</tt>
| RW8
| Left (l), Right (r)
|-
! $8C
| Sound Channel 3 Sweep Amount
| style="text-align: right" | <tt style="white-space: nowrap">vvvv vvvv</tt>
| RW8
| Value (v)
|-
! $8D
| Sound Channel 3 Sweep Ticks
| style="text-align: right" | <tt style="white-space: nowrap">...t tttt</tt>
| RW8
| Ticks (t)
|-
! $8E
| Sound Channel 4 Noise Control
| style="text-align: right" | <tt style="white-space: nowrap">...e rttt</tt>
| RW8
| Enable (e), Reset (r), Tap (t)
|-
! $8F
| Sound Wavetable Address
| style="text-align: right" | <tt style="white-space: nowrap">wwww wwww</tt>
| RW8
| Address >> 6 (w)
|-
! $90
| Sound Channel Control
| style="text-align: right" | <tt style="white-space: nowrap">nsv. 4321</tt>
| RW8
| Channel enable (1234)
Noise (n), Sweep (s), Voice (v)
|-
! $91
| Sound Output Control
| style="text-align: right" | <tt style="white-space: nowrap">H... hrrs</tt>
| RW8
| Headphones connected (H)
Headphone output (h)
Speaker output (s), range (r)
|-
! $92
| Sound Channel 4 LFSR
| style="text-align: right" | <tt style="white-space: nowrap">.rrr rrrr rrrr rrrr</tt>
| R16
| PRNG state (r)
|-
! $94
| Sound Channel 2 Voice Volume
| style="text-align: right" | <tt style="white-space: nowrap">.... lLrR</tt>
| RW8
| Left Half (l), Full (L)
Right Half (r), Full (R)
|-
! $96
| Sound Sequencer Output Right
| style="text-align: right" | <tt style="white-space: nowrap">.... ..ss ssss ssss</tt>
| R16
| Sample (s)
|-
! $98
| Sound Sequencer Output Left
| style="text-align: right" | <tt style="white-space: nowrap">.... ..ss ssss ssss</tt>
| R16
| Sample (s)
|-
! $9A
| Sound Sequencer Output Sum
| style="text-align: right" | <tt style="white-space: nowrap">.... .sss ssss ssss</tt>
| R16
| Sample (s)
|-
! System
! $A0
| System Control
| style="text-align: right" | <tt style="white-space: nowrap">t??? swcl</tt>
| RW8
| Test OK (t), ROM speed (s), ROM width (w),
Color system (c), Boot ROM lockout (l)
|-
! rowspan="5" | Timers
! $A2
| Timer Control
| style="text-align: right" | <tt style="white-space: nowrap">.... VvHh</tt>
| RW8
| Horizontal enable (h), auto reload (H)
Vertical enable (v), auto reload (V)
|-
! $A4
| Horizontal Blank Timer Reload
| style="text-align: right" | <tt style="white-space: nowrap">tttt tttt tttt tttt</tt>
| RW16
| Ticks (t)
|-
! $A6
| Vertical Blank Timer Reload
| style="text-align: right" | <tt style="white-space: nowrap">tttt tttt tttt tttt</tt>
| RW16
| Ticks (t)
|-
! $A8
| Horizontal Blank Timer Counter
| style="text-align: right" | <tt style="white-space: nowrap">tttt tttt tttt tttt</tt>
| R16
| Ticks (t)
|-
! $AA
| Vertical Blank Timer Counter
| style="text-align: right" | <tt style="white-space: nowrap">tttt tttt tttt tttt</tt>
| R16
| Ticks (t)
|-
! Interrupts
! $B0
| Interrupt Vector
| style="text-align: right" | <tt style="white-space: nowrap">vvvv v...</tt>
| RW8
| Vector offset (v)
|-
! UART
! $B1
| Serial Data
| style="text-align: right" | <tt style="white-space: nowrap">dddd dddd</tt>
| RW8
| Data (d)
|-
! Interrupts
! $B2
| Interrupt Enable
|
| RW8
|
|-
! UART
! $B3
| Serial Control
| style="text-align: right" | <tt style="white-space: nowrap">ebO. .rot</tt>
| RW8
| Enable (e), Baud rate (b), Reset Overrun (O),
Receive ready (r), Overrun (o), Transfer ready (t)
|-
! Interrupts
! $B4
| Interrupt Status
|
| RW8
|
|-
! [[Keypad]]
! $B5
| [[Keypad|Keypad Scan]]
| style="text-align: right" | <tt style="white-space: nowrap">.iii oooo</tt>
| RW8
| Input row (i), Output column (o)
|-
! rowspan="2" | Interrupts
! $B6
| Interrupt Acknowledge
|
| RW8
|
|-
! $B7
| Interrupt NMI Control
| style="text-align: right" | <tt style="white-space: nowrap">...b ....</tt>
| RW8
| Low battery (b)
|-
! rowspan="3" | Internal EEPROM
! $BA
| Internal EEPROM Data
| style="text-align: right" | <tt style="white-space: nowrap">dddd dddd dddd dddd</tt>
| RW16
| Data (d)
|-
! $BC
| Internal EEPROM Command
|
| RW16
|
|-
! $BE
| Internal EEPROM Control
| style="text-align: right" | <tt style="white-space: nowrap">.... .... PEWR ..rd</tt>
| RW16
| Protect (P), Erase (E), Write (W), Read (R),
Ready (r), Done (d)
|-
! [[Mapper|Cartridge]]
! $C0<br />
$FF
| Cartridge I/O
|
|
| Forwarded by the SoC
|}
61956370f69113eb0fd3db95aba7f0cd511801b1
58
56
2023-08-20T19:10:37Z
Asie
351
consistency: add more URLs
wikitext
text/x-wiki
* Superscripts are used to mark ports specific to a given mode or platform:
** Color mode: <sup>(color)</sup>.
** WS/WSC/SC console: <sup>(WS)</sup>, <sup>(WSC)</sup>, <sup>(SC)</sup>.
* If two Bits rows are provided, the second one refers to the "Color" mode.
* The Type can be: R - readable, W - writable, L - writable before boot ROM lockout, 8/16 - width (byte/word).
{| class="wikitable"
! Category
! Port
! Description
! Bits
! Type
! Notes
|-
! rowspan="45" | [[Display]]
! $00
| [[Display#Display Control|Display Control]]
| style="text-align: right" | <tt style="white-space: nowrap">..ow Ws21</tt>
| RW8
|
|-
! $01
| [[Display#Display Background|Display Background]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .sss</tt>
<tt style="white-space: nowrap">pppp iiii</tt>
| RW8
| Shade (s)
Palette (p), Index (i)
|-
! $02
| [[Display#Current Line|Display Current Line]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll</tt>
| R8
| Line (l)
|-
! $03
| [[Display#Interrupt Line|Display Interrupt Line]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll</tt>
| RW8
| Line (l)
|-
! $04
| [[Display#Sprite Table Address|Sprite Table Address]]
| style="text-align: right" | <tt style="white-space: nowrap">...a aaaa</tt>
<tt style="white-space: nowrap">..aa aaaa</tt>
| RW8
| Address >> 9 (a)
|-
! $05
| [[Display#Sprite Table First|Sprite Table First]]
| style="text-align: right" | <tt style="white-space: nowrap">.iii iiii</tt>
| RW8
| Index (i)
|-
! $06
| [[Display#Sprite Table Count|Sprite Table Count]]
| style="text-align: right" | <tt style="white-space: nowrap">cccc cccc</tt>
| RW8
| Count (c)
|-
! $07
| [[Display#Screen Address|Screen Address]]
| style="text-align: right" | <tt style="white-space: nowrap">.222 .111</tt>
<tt style="white-space: nowrap">2222 1111</tt>
| RW8
| Screen 1 address >> 11 (1)
Screen 2 address >> 11 (2)
|-
! $08
| [[Display#Screen 2 Window|Screen 2 Window Left]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $09
| [[Display#Screen 2 Window|Screen 2 Window Top]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $0A
| [[Display#Screen 2 Window|Screen 2 Window Right]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $0B
| [[Display#Screen 2 Window|Screen 2 Window Bottom]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $0B
| [[Display#Sprite Window|Sprite Window Left]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $0C
| [[Display#Sprite Window|Sprite Window Top]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $0E
| [[Display#Sprite Window|Sprite Window Right]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $0F
| [[Display#Sprite Window|Sprite Window Bottom]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $10
| [[Display#Screen Scroll|Screen 1 Scroll X]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $11
| [[Display#Screen Scroll|Screen 1 Scroll Y]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $12
| [[Display#Screen Scroll|Screen 2 Scroll X]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $13
| [[Display#Screen Scroll|Screen 2 Scroll Y]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $14
| [[Display#LCD Control|LCD Control]]
| style="text-align: right" | <tt style="white-space: nowrap">.... ..Ce</tt>
| RW8
| Contrast (C)<sup>(WSC)</sup>, Enable (e)
|-
! $15
| [[Display#LCD Icon Control|LCD Icon Control]]
| style="text-align: right" | <tt style="white-space: nowrap">..32 1hvs</tt>
| RW8
| Auxillary 3 (3), Auxillary 2 (2), Auxillary 1 (1),
Horizontal (h), Vertical (v), Sleep (s)
|-
! $16
| [[Display#LCD Final Line|LCD Final Line]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll</tt>
| RW8
| Line (l)
|-
! $17
| [[Display#LCD Back Porch Line|LCD Back Porch Line]]<sup>(WSC)</sup>
| style="text-align: right" | <tt style="white-space: nowrap">llll llll</tt>
| RW8
| Line (l)
|-
! $1A
| [[Display#LCD Status|LCD Status]]
| style="text-align: right" | <tt style="white-space: nowrap">...v vv.e</tt>
| RW8
| Volume segment status (v), Enable (e)
|-
! $1C
| [[Display#LCD Mono Shade LUT|LCD Mono Shade LUT 0/1]]
| style="text-align: right" | <tt style="white-space: nowrap">1111 0000</tt>
| RW8
| Shade index
|-
! $1D
| [[Display#LCD Mono Shade LUT|LCD Mono Shade LUT 2/3]]
| style="text-align: right" | <tt style="white-space: nowrap">3333 2222</tt>
| RW8
| Shade index
|-
! $1E
| [[Display#LCD Mono Shade LUT|LCD Mono Shade LUT 4/5]]
| style="text-align: right" | <tt style="white-space: nowrap">5555 4444</tt>
| RW8
| Shade index
|-
! $1F
| [[Display#LCD Mono Shade LUT|LCD Mono Shade LUT 6/7]]
| style="text-align: right" | <tt style="white-space: nowrap">7777 6666</tt>
| RW8
| Shade index
|-
! $20
| [[Display#LCD Mono Palette|LCD Mono Palette 0]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $22
| [[Display#LCD Mono Palette|LCD Mono Palette 1]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $24
| [[Display#LCD Mono Palette|LCD Mono Palette 2]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $26
| [[Display#LCD Mono Palette|LCD Mono Palette 3]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $28
| [[Display#LCD Mono Palette|LCD Mono Palette 4]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $2A
| [[Display#LCD Mono Palette|LCD Mono Palette 5]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $2C
| [[Display#LCD Mono Palette|LCD Mono Palette 6]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $2E
| [[Display#LCD Mono Palette|LCD Mono Palette 7]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $30
| [[Display#LCD Mono Palette|LCD Mono Palette 8]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $32
| [[Display#LCD Mono Palette|LCD Mono Palette 9]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $34
| [[Display#LCD Mono Palette|LCD Mono Palette 10]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $36
| [[Display#LCD Mono Palette|LCD Mono Palette 11]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $38
| [[Display#LCD Mono Palette|LCD Mono Palette 12]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $3A
| [[Display#LCD Mono Palette|LCD Mono Palette 13]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $3C
| [[Display#LCD Mono Palette|LCD Mono Palette 14]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $3E
| [[Display#LCD Mono Palette|LCD Mono Palette 15]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! rowspan="10" | [[DMA]]<sup>(color)</sup>
! $40
| [[DMA#General DMA|GDMA Source Address Low]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll llll llll</tt>
| RW16
| Linear address, low 16 bits (l)
|-
! $42
| [[DMA#General DMA|GDMA Source Address High]]
| style="text-align: right" | <tt style="white-space: nowrap">.... hhhh</tt>
| RW8
| Linear address, high 4 bits (h)
|-
! $44
| [[DMA#General DMA|GDMA Destination Address]]
| style="text-align: right" | <tt style="white-space: nowrap">aaaa aaaa aaaa aaaa</tt>
| RW16
| IRAM address (a)
|-
! $46
| [[DMA#General DMA|GDMA Length]]
| style="text-align: right" | <tt style="white-space: nowrap">bbbb bbbb bbbb bbbb</tt>
| RW16
| Bytes (b)
|-
! $48
| [[DMA#General DMA|GDMA Control]]
| style="text-align: right" | <tt style="white-space: nowrap">ed.. ....</tt>
| RW8
| Enable (e), Decrement (d)
|-
! $4A
| [[DMA#Sound DMA|SDMA Source Address Low]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll llll llll</tt>
| RW16
| Linear address, low 16 bits (l)
|-
! $4C
| [[DMA#Sound DMA|SDMA Source Address High]]
| style="text-align: right" | <tt style="white-space: nowrap">.... hhhh</tt>
| RW8
| Linear address, high 4 bits (h)
|-
! $4E
| [[DMA#Sound DMA|SDMA Length Low]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll llll llll</tt>
| RW16
| Length, low 16 bits (l)
|-
! $50
| [[DMA#Sound DMA|SDMA Length High]]
| style="text-align: right" | <tt style="white-space: nowrap">.... hhhh</tt>
| RW8
| Length, high 4 bits (h)
|-
! $52
| [[DMA#Sound DMA|SDMA Control]]
| style="text-align: right" | <tt style="white-space: nowrap">ed.t r?ff</tt>
| RW8
| Enable (e), Decrement (d), Target (t),
Repeat (r), Frequency (f)
|-
! rowspan="2" | System<sup>(color)</sup>
! $60
| System Control 2
| style="text-align: right" | <tt style="white-space: nowrap">c4C. ?.??</tt>
| RW8
| Color (c), 4BPP (4), Chunky (C)
|-
! $62
| System Control 3
| style="text-align: right" | <tt style="white-space: nowrap">S... ...p</tt>
| RW8
| SwanCrystal (S), Power off (p)
|-
! rowspan="5" | [[Hyper Voice]]<sup>(color)</sup>
! $64
| Hyper Voice Left Output
| style="text-align: right" | <tt style="white-space: nowrap">ssss ssss ssss ssss</tt>
| W16
| Raw sample (s)
|-
! $66
| Hyper Voice Right Output
| style="text-align: right" | <tt style="white-space: nowrap">ssss ssss ssss ssss</tt>
| W16
| Raw sample (s)
|-
! $68
| Hyper Voice Left Input
| style="text-align: right" | <tt style="white-space: nowrap">ssss ssss</tt>
| 8
| Sample (s)
|-
! $69
| Hyper Voice Right Input
| style="text-align: right" | <tt style="white-space: nowrap">ssss ssss</tt>
| 8
| Sample (s)
|-
! $6A
| Hyper Voice Control
| style="text-align: right" | <tt style="white-space: nowrap">.mmc .... errr ffss</tt>
| RW16
| Mask (m), Channel (c), Enable (e),
Rate (r), Format (f), Shift (s)
|-
! rowspan="8" | [[Display]]<sup>(SC)</sup>
! $70
| LCD Timing Configuration 1?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $71
| LCD Timing Configuration 2?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $72
| LCD Timing Configuration 3?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $73
| LCD Timing Configuration 4?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $74
| LCD Timing Configuration 5?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $75
| LCD Timing Configuration 6?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $76
| LCD Timing Configuration 7?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $77
| LCD Timing Configuration 8?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! rowspan="20" | [[Sound]]
! $80
| Sound Channel 1 Frequency
| style="text-align: right" | <tt style="white-space: nowrap">.... .ddd dddd dddd</tt>
| RW16
| Divider (d)
|-
! $82
| Sound Channel 2 Frequency
| style="text-align: right" | <tt style="white-space: nowrap">.... .ddd dddd dddd</tt>
| RW16
| Divider (d)
|-
! $84
| Sound Channel 3 Frequency
| style="text-align: right" | <tt style="white-space: nowrap">.... .ddd dddd dddd</tt>
| RW16
| Divider (d)
|-
! $86
| Sound Channel 4 Frequency
| style="text-align: right" | <tt style="white-space: nowrap">.... .ddd dddd dddd</tt>
| RW16
| Divider (d)
|-
! $88
| Sound Channel 1 Volume
| style="text-align: right" | <tt style="white-space: nowrap">llll rrrr</tt>
| RW8
| Left (l), Right (r)
|-
! rowspan="2" | $89
| Sound Channel 2 Volume
| style="text-align: right" | <tt style="white-space: nowrap">llll rrrr</tt>
| RW8
| Left (l), Right (r)
|-
| Sound Channel 2 Voice Sample
| style="text-align: right" | <tt style="white-space: nowrap">ssss ssss</tt>
| RW8
| Sample (s)
|-
! $8A
| Sound Channel 3 Volume
| style="text-align: right" | <tt style="white-space: nowrap">llll rrrr</tt>
| RW8
| Left (l), Right (r)
|-
! $8B
| Sound Channel 4 Volume
| style="text-align: right" | <tt style="white-space: nowrap">llll rrrr</tt>
| RW8
| Left (l), Right (r)
|-
! $8C
| Sound Channel 3 Sweep Amount
| style="text-align: right" | <tt style="white-space: nowrap">vvvv vvvv</tt>
| RW8
| Value (v)
|-
! $8D
| Sound Channel 3 Sweep Ticks
| style="text-align: right" | <tt style="white-space: nowrap">...t tttt</tt>
| RW8
| Ticks (t)
|-
! $8E
| Sound Channel 4 Noise Control
| style="text-align: right" | <tt style="white-space: nowrap">...e rttt</tt>
| RW8
| Enable (e), Reset (r), Tap (t)
|-
! $8F
| Sound Wavetable Address
| style="text-align: right" | <tt style="white-space: nowrap">wwww wwww</tt>
| RW8
| Address >> 6 (w)
|-
! $90
| Sound Channel Control
| style="text-align: right" | <tt style="white-space: nowrap">nsv. 4321</tt>
| RW8
| Channel enable (1234)
Noise (n), Sweep (s), Voice (v)
|-
! $91
| Sound Output Control
| style="text-align: right" | <tt style="white-space: nowrap">H... hrrs</tt>
| RW8
| Headphones connected (H)
Headphone output (h)
Speaker output (s), range (r)
|-
! $92
| Sound Channel 4 LFSR
| style="text-align: right" | <tt style="white-space: nowrap">.rrr rrrr rrrr rrrr</tt>
| R16
| PRNG state (r)
|-
! $94
| Sound Channel 2 Voice Volume
| style="text-align: right" | <tt style="white-space: nowrap">.... lLrR</tt>
| RW8
| Left Half (l), Full (L)
Right Half (r), Full (R)
|-
! $96
| Sound Sequencer Output Right
| style="text-align: right" | <tt style="white-space: nowrap">.... ..ss ssss ssss</tt>
| R16
| Sample (s)
|-
! $98
| Sound Sequencer Output Left
| style="text-align: right" | <tt style="white-space: nowrap">.... ..ss ssss ssss</tt>
| R16
| Sample (s)
|-
! $9A
| Sound Sequencer Output Sum
| style="text-align: right" | <tt style="white-space: nowrap">.... .sss ssss ssss</tt>
| R16
| Sample (s)
|-
! System
! $A0
| System Control
| style="text-align: right" | <tt style="white-space: nowrap">t??? swcl</tt>
| RW8
| Test OK (t), ROM speed (s), ROM width (w),
Color system (c), Boot ROM lockout (l)
|-
! rowspan="5" | [[Timers]]
! $A2
| Timer Control
| style="text-align: right" | <tt style="white-space: nowrap">.... VvHh</tt>
| RW8
| Horizontal enable (h), auto reload (H)
Vertical enable (v), auto reload (V)
|-
! $A4
| Horizontal Blank Timer Reload
| style="text-align: right" | <tt style="white-space: nowrap">tttt tttt tttt tttt</tt>
| RW16
| Ticks (t)
|-
! $A6
| Vertical Blank Timer Reload
| style="text-align: right" | <tt style="white-space: nowrap">tttt tttt tttt tttt</tt>
| RW16
| Ticks (t)
|-
! $A8
| Horizontal Blank Timer Counter
| style="text-align: right" | <tt style="white-space: nowrap">tttt tttt tttt tttt</tt>
| R16
| Ticks (t)
|-
! $AA
| Vertical Blank Timer Counter
| style="text-align: right" | <tt style="white-space: nowrap">tttt tttt tttt tttt</tt>
| R16
| Ticks (t)
|-
! [[Interrupts]]
! $B0
| Interrupt Vector
| style="text-align: right" | <tt style="white-space: nowrap">vvvv v...</tt>
| RW8
| Vector offset (v)
|-
! [[UART]]
! $B1
| Serial Data
| style="text-align: right" | <tt style="white-space: nowrap">dddd dddd</tt>
| RW8
| Data (d)
|-
! [[Interrupts]]
! $B2
| Interrupt Enable
|
| RW8
|
|-
! [[UART]]
! $B3
| Serial Control
| style="text-align: right" | <tt style="white-space: nowrap">ebO. .rot</tt>
| RW8
| Enable (e), Baud rate (b), Reset Overrun (O),
Receive ready (r), Overrun (o), Transfer ready (t)
|-
! [[Interrupts]]
! $B4
| Interrupt Status
|
| RW8
|
|-
! [[Keypad]]
! $B5
| [[Keypad|Keypad Scan]]
| style="text-align: right" | <tt style="white-space: nowrap">.iii oooo</tt>
| RW8
| Input row (i), Output column (o)
|-
! rowspan="2" | [[Interrupts]]
! $B6
| Interrupt Acknowledge
|
| RW8
|
|-
! $B7
| Interrupt NMI Control
| style="text-align: right" | <tt style="white-space: nowrap">...b ....</tt>
| RW8
| Low battery (b)
|-
! rowspan="3" | Internal EEPROM
! $BA
| Internal EEPROM Data
| style="text-align: right" | <tt style="white-space: nowrap">dddd dddd dddd dddd</tt>
| RW16
| Data (d)
|-
! $BC
| Internal EEPROM Command
|
| RW16
|
|-
! $BE
| Internal EEPROM Control
| style="text-align: right" | <tt style="white-space: nowrap">.... .... PEWR ..rd</tt>
| RW16
| Protect (P), Erase (E), Write (W), Read (R),
Ready (r), Done (d)
|-
! [[Mapper|Cartridge]]
! $C0<br />
$FF
| Cartridge I/O
|
|
| Forwarded by the SoC
|}
6e9c0e1dfb6846f50de0aca0791c062def9c2258
77
58
2023-08-22T05:32:01Z
Asie
351
update interrupt information
wikitext
text/x-wiki
* Superscripts are used to mark ports specific to a given mode or platform:
** Color mode: <sup>(color)</sup>.
** WS/WSC/SC console: <sup>(WS)</sup>, <sup>(WSC)</sup>, <sup>(SC)</sup>.
* If two Bits rows are provided, the second one refers to the "Color" mode.
* The Type can be: R - readable, W - writable, L - writable before boot ROM lockout, 8/16 - width (byte/word).
{| class="wikitable"
! Category
! Port
! Description
! Bits
! Type
! Notes
|-
! rowspan="45" | [[Display]]
! $00
| [[Display#Display Control|Display Control]]
| style="text-align: right" | <tt style="white-space: nowrap">..ow Ws21</tt>
| RW8
|
|-
! $01
| [[Display#Display Background|Display Background]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .sss</tt>
<tt style="white-space: nowrap">pppp iiii</tt>
| RW8
| Shade (s)
Palette (p), Index (i)
|-
! $02
| [[Display#Current Line|Display Current Line]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll</tt>
| R8
| Line (l)
|-
! $03
| [[Display#Interrupt Line|Display Interrupt Line]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll</tt>
| RW8
| Line (l)
|-
! $04
| [[Display#Sprite Table Address|Sprite Table Address]]
| style="text-align: right" | <tt style="white-space: nowrap">...a aaaa</tt>
<tt style="white-space: nowrap">..aa aaaa</tt>
| RW8
| Address >> 9 (a)
|-
! $05
| [[Display#Sprite Table First|Sprite Table First]]
| style="text-align: right" | <tt style="white-space: nowrap">.iii iiii</tt>
| RW8
| Index (i)
|-
! $06
| [[Display#Sprite Table Count|Sprite Table Count]]
| style="text-align: right" | <tt style="white-space: nowrap">cccc cccc</tt>
| RW8
| Count (c)
|-
! $07
| [[Display#Screen Address|Screen Address]]
| style="text-align: right" | <tt style="white-space: nowrap">.222 .111</tt>
<tt style="white-space: nowrap">2222 1111</tt>
| RW8
| Screen 1 address >> 11 (1)
Screen 2 address >> 11 (2)
|-
! $08
| [[Display#Screen 2 Window|Screen 2 Window Left]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $09
| [[Display#Screen 2 Window|Screen 2 Window Top]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $0A
| [[Display#Screen 2 Window|Screen 2 Window Right]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $0B
| [[Display#Screen 2 Window|Screen 2 Window Bottom]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $0B
| [[Display#Sprite Window|Sprite Window Left]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $0C
| [[Display#Sprite Window|Sprite Window Top]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $0E
| [[Display#Sprite Window|Sprite Window Right]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $0F
| [[Display#Sprite Window|Sprite Window Bottom]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $10
| [[Display#Screen Scroll|Screen 1 Scroll X]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $11
| [[Display#Screen Scroll|Screen 1 Scroll Y]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $12
| [[Display#Screen Scroll|Screen 2 Scroll X]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $13
| [[Display#Screen Scroll|Screen 2 Scroll Y]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $14
| [[Display#LCD Control|LCD Control]]
| style="text-align: right" | <tt style="white-space: nowrap">.... ..Ce</tt>
| RW8
| Contrast (C)<sup>(WSC)</sup>, Enable (e)
|-
! $15
| [[Display#LCD Icon Control|LCD Icon Control]]
| style="text-align: right" | <tt style="white-space: nowrap">..32 1hvs</tt>
| RW8
| Auxillary 3 (3), Auxillary 2 (2), Auxillary 1 (1),
Horizontal (h), Vertical (v), Sleep (s)
|-
! $16
| [[Display#LCD Final Line|LCD Final Line]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll</tt>
| RW8
| Line (l)
|-
! $17
| [[Display#LCD Back Porch Line|LCD Back Porch Line]]<sup>(WSC)</sup>
| style="text-align: right" | <tt style="white-space: nowrap">llll llll</tt>
| RW8
| Line (l)
|-
! $1A
| [[Display#LCD Status|LCD Status]]
| style="text-align: right" | <tt style="white-space: nowrap">...v vv.e</tt>
| RW8
| Volume segment status (v), Enable (e)
|-
! $1C
| [[Display#LCD Mono Shade LUT|LCD Mono Shade LUT 0/1]]
| style="text-align: right" | <tt style="white-space: nowrap">1111 0000</tt>
| RW8
| Shade index
|-
! $1D
| [[Display#LCD Mono Shade LUT|LCD Mono Shade LUT 2/3]]
| style="text-align: right" | <tt style="white-space: nowrap">3333 2222</tt>
| RW8
| Shade index
|-
! $1E
| [[Display#LCD Mono Shade LUT|LCD Mono Shade LUT 4/5]]
| style="text-align: right" | <tt style="white-space: nowrap">5555 4444</tt>
| RW8
| Shade index
|-
! $1F
| [[Display#LCD Mono Shade LUT|LCD Mono Shade LUT 6/7]]
| style="text-align: right" | <tt style="white-space: nowrap">7777 6666</tt>
| RW8
| Shade index
|-
! $20
| [[Display#LCD Mono Palette|LCD Mono Palette 0]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $22
| [[Display#LCD Mono Palette|LCD Mono Palette 1]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $24
| [[Display#LCD Mono Palette|LCD Mono Palette 2]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $26
| [[Display#LCD Mono Palette|LCD Mono Palette 3]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $28
| [[Display#LCD Mono Palette|LCD Mono Palette 4]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $2A
| [[Display#LCD Mono Palette|LCD Mono Palette 5]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $2C
| [[Display#LCD Mono Palette|LCD Mono Palette 6]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $2E
| [[Display#LCD Mono Palette|LCD Mono Palette 7]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $30
| [[Display#LCD Mono Palette|LCD Mono Palette 8]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $32
| [[Display#LCD Mono Palette|LCD Mono Palette 9]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $34
| [[Display#LCD Mono Palette|LCD Mono Palette 10]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $36
| [[Display#LCD Mono Palette|LCD Mono Palette 11]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $38
| [[Display#LCD Mono Palette|LCD Mono Palette 12]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $3A
| [[Display#LCD Mono Palette|LCD Mono Palette 13]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $3C
| [[Display#LCD Mono Palette|LCD Mono Palette 14]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $3E
| [[Display#LCD Mono Palette|LCD Mono Palette 15]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! rowspan="10" | [[DMA]]<sup>(color)</sup>
! $40
| [[DMA#General DMA|GDMA Source Address Low]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll llll llll</tt>
| RW16
| Linear address, low 16 bits (l)
|-
! $42
| [[DMA#General DMA|GDMA Source Address High]]
| style="text-align: right" | <tt style="white-space: nowrap">.... hhhh</tt>
| RW8
| Linear address, high 4 bits (h)
|-
! $44
| [[DMA#General DMA|GDMA Destination Address]]
| style="text-align: right" | <tt style="white-space: nowrap">aaaa aaaa aaaa aaaa</tt>
| RW16
| IRAM address (a)
|-
! $46
| [[DMA#General DMA|GDMA Length]]
| style="text-align: right" | <tt style="white-space: nowrap">bbbb bbbb bbbb bbbb</tt>
| RW16
| Bytes (b)
|-
! $48
| [[DMA#General DMA|GDMA Control]]
| style="text-align: right" | <tt style="white-space: nowrap">ed.. ....</tt>
| RW8
| Enable (e), Decrement (d)
|-
! $4A
| [[DMA#Sound DMA|SDMA Source Address Low]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll llll llll</tt>
| RW16
| Linear address, low 16 bits (l)
|-
! $4C
| [[DMA#Sound DMA|SDMA Source Address High]]
| style="text-align: right" | <tt style="white-space: nowrap">.... hhhh</tt>
| RW8
| Linear address, high 4 bits (h)
|-
! $4E
| [[DMA#Sound DMA|SDMA Length Low]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll llll llll</tt>
| RW16
| Length, low 16 bits (l)
|-
! $50
| [[DMA#Sound DMA|SDMA Length High]]
| style="text-align: right" | <tt style="white-space: nowrap">.... hhhh</tt>
| RW8
| Length, high 4 bits (h)
|-
! $52
| [[DMA#Sound DMA|SDMA Control]]
| style="text-align: right" | <tt style="white-space: nowrap">ed.t r?ff</tt>
| RW8
| Enable (e), Decrement (d), Target (t),
Repeat (r), Frequency (f)
|-
! rowspan="2" | System<sup>(color)</sup>
! $60
| System Control 2
| style="text-align: right" | <tt style="white-space: nowrap">c4C. ?.??</tt>
| RW8
| Color (c), 4BPP (4), Chunky (C)
|-
! $62
| System Control 3
| style="text-align: right" | <tt style="white-space: nowrap">S... ...p</tt>
| RW8
| SwanCrystal (S), Power off (p)
|-
! rowspan="5" | [[Hyper Voice]]<sup>(color)</sup>
! $64
| Hyper Voice Left Output
| style="text-align: right" | <tt style="white-space: nowrap">ssss ssss ssss ssss</tt>
| W16
| Raw sample (s)
|-
! $66
| Hyper Voice Right Output
| style="text-align: right" | <tt style="white-space: nowrap">ssss ssss ssss ssss</tt>
| W16
| Raw sample (s)
|-
! $68
| Hyper Voice Left Input
| style="text-align: right" | <tt style="white-space: nowrap">ssss ssss</tt>
| 8
| Sample (s)
|-
! $69
| Hyper Voice Right Input
| style="text-align: right" | <tt style="white-space: nowrap">ssss ssss</tt>
| 8
| Sample (s)
|-
! $6A
| Hyper Voice Control
| style="text-align: right" | <tt style="white-space: nowrap">.mmc .... errr ffss</tt>
| RW16
| Mask (m), Channel (c), Enable (e),
Rate (r), Format (f), Shift (s)
|-
! rowspan="8" | [[Display]]<sup>(SC)</sup>
! $70
| LCD Timing Configuration 1?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $71
| LCD Timing Configuration 2?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $72
| LCD Timing Configuration 3?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $73
| LCD Timing Configuration 4?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $74
| LCD Timing Configuration 5?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $75
| LCD Timing Configuration 6?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $76
| LCD Timing Configuration 7?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $77
| LCD Timing Configuration 8?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! rowspan="20" | [[Sound]]
! $80
| Sound Channel 1 Frequency
| style="text-align: right" | <tt style="white-space: nowrap">.... .ddd dddd dddd</tt>
| RW16
| Divider (d)
|-
! $82
| Sound Channel 2 Frequency
| style="text-align: right" | <tt style="white-space: nowrap">.... .ddd dddd dddd</tt>
| RW16
| Divider (d)
|-
! $84
| Sound Channel 3 Frequency
| style="text-align: right" | <tt style="white-space: nowrap">.... .ddd dddd dddd</tt>
| RW16
| Divider (d)
|-
! $86
| Sound Channel 4 Frequency
| style="text-align: right" | <tt style="white-space: nowrap">.... .ddd dddd dddd</tt>
| RW16
| Divider (d)
|-
! $88
| Sound Channel 1 Volume
| style="text-align: right" | <tt style="white-space: nowrap">llll rrrr</tt>
| RW8
| Left (l), Right (r)
|-
! rowspan="2" | $89
| Sound Channel 2 Volume
| style="text-align: right" | <tt style="white-space: nowrap">llll rrrr</tt>
| RW8
| Left (l), Right (r)
|-
| Sound Channel 2 Voice Sample
| style="text-align: right" | <tt style="white-space: nowrap">ssss ssss</tt>
| RW8
| Sample (s)
|-
! $8A
| Sound Channel 3 Volume
| style="text-align: right" | <tt style="white-space: nowrap">llll rrrr</tt>
| RW8
| Left (l), Right (r)
|-
! $8B
| Sound Channel 4 Volume
| style="text-align: right" | <tt style="white-space: nowrap">llll rrrr</tt>
| RW8
| Left (l), Right (r)
|-
! $8C
| Sound Channel 3 Sweep Amount
| style="text-align: right" | <tt style="white-space: nowrap">vvvv vvvv</tt>
| RW8
| Value (v)
|-
! $8D
| Sound Channel 3 Sweep Ticks
| style="text-align: right" | <tt style="white-space: nowrap">...t tttt</tt>
| RW8
| Ticks (t)
|-
! $8E
| Sound Channel 4 Noise Control
| style="text-align: right" | <tt style="white-space: nowrap">...e rttt</tt>
| RW8
| Enable (e), Reset (r), Tap (t)
|-
! $8F
| Sound Wavetable Address
| style="text-align: right" | <tt style="white-space: nowrap">wwww wwww</tt>
| RW8
| Address >> 6 (w)
|-
! $90
| Sound Channel Control
| style="text-align: right" | <tt style="white-space: nowrap">nsv. 4321</tt>
| RW8
| Channel enable (1234)
Noise (n), Sweep (s), Voice (v)
|-
! $91
| Sound Output Control
| style="text-align: right" | <tt style="white-space: nowrap">H... hrrs</tt>
| RW8
| Headphones connected (H)
Headphone output (h)
Speaker output (s), range (r)
|-
! $92
| Sound Channel 4 LFSR
| style="text-align: right" | <tt style="white-space: nowrap">.rrr rrrr rrrr rrrr</tt>
| R16
| PRNG state (r)
|-
! $94
| Sound Channel 2 Voice Volume
| style="text-align: right" | <tt style="white-space: nowrap">.... lLrR</tt>
| RW8
| Left Half (l), Full (L)
Right Half (r), Full (R)
|-
! $96
| Sound Sequencer Output Right
| style="text-align: right" | <tt style="white-space: nowrap">.... ..ss ssss ssss</tt>
| R16
| Sample (s)
|-
! $98
| Sound Sequencer Output Left
| style="text-align: right" | <tt style="white-space: nowrap">.... ..ss ssss ssss</tt>
| R16
| Sample (s)
|-
! $9A
| Sound Sequencer Output Sum
| style="text-align: right" | <tt style="white-space: nowrap">.... .sss ssss ssss</tt>
| R16
| Sample (s)
|-
! System
! $A0
| System Control
| style="text-align: right" | <tt style="white-space: nowrap">t??? swcl</tt>
| RW8
| Test OK (t), ROM speed (s), ROM width (w),
Color system (c), Boot ROM lockout (l)
|-
! rowspan="5" | [[Timers]]
! $A2
| Timer Control
| style="text-align: right" | <tt style="white-space: nowrap">.... VvHh</tt>
| RW8
| Horizontal enable (h), auto reload (H)
Vertical enable (v), auto reload (V)
|-
! $A4
| Horizontal Blank Timer Reload
| style="text-align: right" | <tt style="white-space: nowrap">tttt tttt tttt tttt</tt>
| RW16
| Ticks (t)
|-
! $A6
| Vertical Blank Timer Reload
| style="text-align: right" | <tt style="white-space: nowrap">tttt tttt tttt tttt</tt>
| RW16
| Ticks (t)
|-
! $A8
| Horizontal Blank Timer Counter
| style="text-align: right" | <tt style="white-space: nowrap">tttt tttt tttt tttt</tt>
| R16
| Ticks (t)
|-
! $AA
| Vertical Blank Timer Counter
| style="text-align: right" | <tt style="white-space: nowrap">tttt tttt tttt tttt</tt>
| R16
| Ticks (t)
|-
! [[Interrupts]]
! $B0
| [[Interrupts#Interrupt Vector|Interrupt Vector]]
| style="text-align: right" | <tt style="white-space: nowrap">VVVV V...</tt>
| RW8
| Vector offset (v)
|-
! [[UART]]
! $B1
| Serial Data
| style="text-align: right" | <tt style="white-space: nowrap">dddd dddd</tt>
| RW8
| Data (d)
|-
! [[Interrupts]]
! $B2
| [[Interrupts#Interrupt Enable|Interrupt Enable]]
| iiii iiii
| RW8
| Interrupt index (i)
|-
! [[UART]]
! $B3
| Serial Control
| style="text-align: right" | <tt style="white-space: nowrap">ebO. .rot</tt>
| RW8
| Enable (e), Baud rate (b), Reset Overrun (O),
Receive ready (r), Overrun (o), Transfer ready (t)
|-
! [[Interrupts]]
! $B4
| [[Interrupts#Interrupt Status|Interrupt Status]]
| iiii iiii
| R8
| Interrupt index (i)
|-
! [[Keypad]]
! $B5
| [[Keypad|Keypad Scan]]
| style="text-align: right" | <tt style="white-space: nowrap">.iii oooo</tt>
| RW8
| Input row (i), Output column (o)
|-
! rowspan="2" | [[Interrupts]]
! $B6
| [[Interrupts#Interrupt Acknowledge|Interrupt Acknowledge]]
| iiii iiii
| R8?
| Interrupt index (i)
|-
! $B7
| [[Interrupts#Interrupt NMI Control|Interrupt NMI Control]]
| style="text-align: right" | <tt style="white-space: nowrap">...b ....</tt>
| RW8
| Low battery (b)
|-
! rowspan="3" | Internal EEPROM
! $BA
| Internal EEPROM Data
| style="text-align: right" | <tt style="white-space: nowrap">dddd dddd dddd dddd</tt>
| RW16
| Data (d)
|-
! $BC
| Internal EEPROM Command
|
| RW16
|
|-
! $BE
| Internal EEPROM Control
| style="text-align: right" | <tt style="white-space: nowrap">.... .... PEWR ..rd</tt>
| RW16
| Protect (P), Erase (E), Write (W), Read (R),
Ready (r), Done (d)
|-
! [[Mapper|Cartridge]]
! $C0<br />
$FF
| Cartridge I/O
|
|
| Forwarded by the SoC
|}
a6de44a164976e1f28cf9fd29f4ee0423b156d1a
79
77
2023-08-22T05:39:29Z
Asie
351
update UART information
wikitext
text/x-wiki
* Superscripts are used to mark ports specific to a given mode or platform:
** Color mode: <sup>(color)</sup>.
** WS/WSC/SC console: <sup>(WS)</sup>, <sup>(WSC)</sup>, <sup>(SC)</sup>.
* If two Bits rows are provided, the second one refers to the "Color" mode.
* The Type can be: R - readable, W - writable, L - writable before boot ROM lockout, 8/16 - width (byte/word).
{| class="wikitable"
! Category
! Port
! Description
! Bits
! Type
! Notes
|-
! rowspan="45" | [[Display]]
! $00
| [[Display#Display Control|Display Control]]
| style="text-align: right" | <tt style="white-space: nowrap">..ow Ws21</tt>
| RW8
|
|-
! $01
| [[Display#Display Background|Display Background]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .sss</tt>
<tt style="white-space: nowrap">pppp iiii</tt>
| RW8
| Shade (s)
Palette (p), Index (i)
|-
! $02
| [[Display#Current Line|Display Current Line]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll</tt>
| R8
| Line (l)
|-
! $03
| [[Display#Interrupt Line|Display Interrupt Line]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll</tt>
| RW8
| Line (l)
|-
! $04
| [[Display#Sprite Table Address|Sprite Table Address]]
| style="text-align: right" | <tt style="white-space: nowrap">...a aaaa</tt>
<tt style="white-space: nowrap">..aa aaaa</tt>
| RW8
| Address >> 9 (a)
|-
! $05
| [[Display#Sprite Table First|Sprite Table First]]
| style="text-align: right" | <tt style="white-space: nowrap">.iii iiii</tt>
| RW8
| Index (i)
|-
! $06
| [[Display#Sprite Table Count|Sprite Table Count]]
| style="text-align: right" | <tt style="white-space: nowrap">cccc cccc</tt>
| RW8
| Count (c)
|-
! $07
| [[Display#Screen Address|Screen Address]]
| style="text-align: right" | <tt style="white-space: nowrap">.222 .111</tt>
<tt style="white-space: nowrap">2222 1111</tt>
| RW8
| Screen 1 address >> 11 (1)
Screen 2 address >> 11 (2)
|-
! $08
| [[Display#Screen 2 Window|Screen 2 Window Left]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $09
| [[Display#Screen 2 Window|Screen 2 Window Top]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $0A
| [[Display#Screen 2 Window|Screen 2 Window Right]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $0B
| [[Display#Screen 2 Window|Screen 2 Window Bottom]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $0B
| [[Display#Sprite Window|Sprite Window Left]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $0C
| [[Display#Sprite Window|Sprite Window Top]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $0E
| [[Display#Sprite Window|Sprite Window Right]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $0F
| [[Display#Sprite Window|Sprite Window Bottom]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $10
| [[Display#Screen Scroll|Screen 1 Scroll X]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $11
| [[Display#Screen Scroll|Screen 1 Scroll Y]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $12
| [[Display#Screen Scroll|Screen 2 Scroll X]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $13
| [[Display#Screen Scroll|Screen 2 Scroll Y]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $14
| [[Display#LCD Control|LCD Control]]
| style="text-align: right" | <tt style="white-space: nowrap">.... ..Ce</tt>
| RW8
| Contrast (C)<sup>(WSC)</sup>, Enable (e)
|-
! $15
| [[Display#LCD Icon Control|LCD Icon Control]]
| style="text-align: right" | <tt style="white-space: nowrap">..32 1hvs</tt>
| RW8
| Auxillary 3 (3), Auxillary 2 (2), Auxillary 1 (1),
Horizontal (h), Vertical (v), Sleep (s)
|-
! $16
| [[Display#LCD Final Line|LCD Final Line]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll</tt>
| RW8
| Line (l)
|-
! $17
| [[Display#LCD Back Porch Line|LCD Back Porch Line]]<sup>(WSC)</sup>
| style="text-align: right" | <tt style="white-space: nowrap">llll llll</tt>
| RW8
| Line (l)
|-
! $1A
| [[Display#LCD Status|LCD Status]]
| style="text-align: right" | <tt style="white-space: nowrap">...v vv.e</tt>
| RW8
| Volume segment status (v), Enable (e)
|-
! $1C
| [[Display#LCD Mono Shade LUT|LCD Mono Shade LUT 0/1]]
| style="text-align: right" | <tt style="white-space: nowrap">1111 0000</tt>
| RW8
| Shade index
|-
! $1D
| [[Display#LCD Mono Shade LUT|LCD Mono Shade LUT 2/3]]
| style="text-align: right" | <tt style="white-space: nowrap">3333 2222</tt>
| RW8
| Shade index
|-
! $1E
| [[Display#LCD Mono Shade LUT|LCD Mono Shade LUT 4/5]]
| style="text-align: right" | <tt style="white-space: nowrap">5555 4444</tt>
| RW8
| Shade index
|-
! $1F
| [[Display#LCD Mono Shade LUT|LCD Mono Shade LUT 6/7]]
| style="text-align: right" | <tt style="white-space: nowrap">7777 6666</tt>
| RW8
| Shade index
|-
! $20
| [[Display#LCD Mono Palette|LCD Mono Palette 0]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $22
| [[Display#LCD Mono Palette|LCD Mono Palette 1]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $24
| [[Display#LCD Mono Palette|LCD Mono Palette 2]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $26
| [[Display#LCD Mono Palette|LCD Mono Palette 3]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $28
| [[Display#LCD Mono Palette|LCD Mono Palette 4]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $2A
| [[Display#LCD Mono Palette|LCD Mono Palette 5]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $2C
| [[Display#LCD Mono Palette|LCD Mono Palette 6]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $2E
| [[Display#LCD Mono Palette|LCD Mono Palette 7]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $30
| [[Display#LCD Mono Palette|LCD Mono Palette 8]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $32
| [[Display#LCD Mono Palette|LCD Mono Palette 9]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $34
| [[Display#LCD Mono Palette|LCD Mono Palette 10]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $36
| [[Display#LCD Mono Palette|LCD Mono Palette 11]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $38
| [[Display#LCD Mono Palette|LCD Mono Palette 12]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $3A
| [[Display#LCD Mono Palette|LCD Mono Palette 13]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $3C
| [[Display#LCD Mono Palette|LCD Mono Palette 14]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $3E
| [[Display#LCD Mono Palette|LCD Mono Palette 15]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! rowspan="10" | [[DMA]]<sup>(color)</sup>
! $40
| [[DMA#General DMA|GDMA Source Address Low]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll llll llll</tt>
| RW16
| Linear address, low 16 bits (l)
|-
! $42
| [[DMA#General DMA|GDMA Source Address High]]
| style="text-align: right" | <tt style="white-space: nowrap">.... hhhh</tt>
| RW8
| Linear address, high 4 bits (h)
|-
! $44
| [[DMA#General DMA|GDMA Destination Address]]
| style="text-align: right" | <tt style="white-space: nowrap">aaaa aaaa aaaa aaaa</tt>
| RW16
| IRAM address (a)
|-
! $46
| [[DMA#General DMA|GDMA Length]]
| style="text-align: right" | <tt style="white-space: nowrap">bbbb bbbb bbbb bbbb</tt>
| RW16
| Bytes (b)
|-
! $48
| [[DMA#General DMA|GDMA Control]]
| style="text-align: right" | <tt style="white-space: nowrap">ed.. ....</tt>
| RW8
| Enable (e), Decrement (d)
|-
! $4A
| [[DMA#Sound DMA|SDMA Source Address Low]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll llll llll</tt>
| RW16
| Linear address, low 16 bits (l)
|-
! $4C
| [[DMA#Sound DMA|SDMA Source Address High]]
| style="text-align: right" | <tt style="white-space: nowrap">.... hhhh</tt>
| RW8
| Linear address, high 4 bits (h)
|-
! $4E
| [[DMA#Sound DMA|SDMA Length Low]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll llll llll</tt>
| RW16
| Length, low 16 bits (l)
|-
! $50
| [[DMA#Sound DMA|SDMA Length High]]
| style="text-align: right" | <tt style="white-space: nowrap">.... hhhh</tt>
| RW8
| Length, high 4 bits (h)
|-
! $52
| [[DMA#Sound DMA|SDMA Control]]
| style="text-align: right" | <tt style="white-space: nowrap">ed.t r?ff</tt>
| RW8
| Enable (e), Decrement (d), Target (t),
Repeat (r), Frequency (f)
|-
! rowspan="2" | System<sup>(color)</sup>
! $60
| System Control 2
| style="text-align: right" | <tt style="white-space: nowrap">c4C. ?.??</tt>
| RW8
| Color (c), 4BPP (4), Chunky (C)
|-
! $62
| System Control 3
| style="text-align: right" | <tt style="white-space: nowrap">S... ...p</tt>
| RW8
| SwanCrystal (S), Power off (p)
|-
! rowspan="5" | [[Hyper Voice]]<sup>(color)</sup>
! $64
| Hyper Voice Left Output
| style="text-align: right" | <tt style="white-space: nowrap">ssss ssss ssss ssss</tt>
| W16
| Raw sample (s)
|-
! $66
| Hyper Voice Right Output
| style="text-align: right" | <tt style="white-space: nowrap">ssss ssss ssss ssss</tt>
| W16
| Raw sample (s)
|-
! $68
| Hyper Voice Left Input
| style="text-align: right" | <tt style="white-space: nowrap">ssss ssss</tt>
| 8
| Sample (s)
|-
! $69
| Hyper Voice Right Input
| style="text-align: right" | <tt style="white-space: nowrap">ssss ssss</tt>
| 8
| Sample (s)
|-
! $6A
| Hyper Voice Control
| style="text-align: right" | <tt style="white-space: nowrap">.mmc .... errr ffss</tt>
| RW16
| Mask (m), Channel (c), Enable (e),
Rate (r), Format (f), Shift (s)
|-
! rowspan="8" | [[Display]]<sup>(SC)</sup>
! $70
| LCD Timing Configuration 1?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $71
| LCD Timing Configuration 2?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $72
| LCD Timing Configuration 3?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $73
| LCD Timing Configuration 4?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $74
| LCD Timing Configuration 5?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $75
| LCD Timing Configuration 6?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $76
| LCD Timing Configuration 7?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $77
| LCD Timing Configuration 8?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! rowspan="20" | [[Sound]]
! $80
| Sound Channel 1 Frequency
| style="text-align: right" | <tt style="white-space: nowrap">.... .ddd dddd dddd</tt>
| RW16
| Divider (d)
|-
! $82
| Sound Channel 2 Frequency
| style="text-align: right" | <tt style="white-space: nowrap">.... .ddd dddd dddd</tt>
| RW16
| Divider (d)
|-
! $84
| Sound Channel 3 Frequency
| style="text-align: right" | <tt style="white-space: nowrap">.... .ddd dddd dddd</tt>
| RW16
| Divider (d)
|-
! $86
| Sound Channel 4 Frequency
| style="text-align: right" | <tt style="white-space: nowrap">.... .ddd dddd dddd</tt>
| RW16
| Divider (d)
|-
! $88
| Sound Channel 1 Volume
| style="text-align: right" | <tt style="white-space: nowrap">llll rrrr</tt>
| RW8
| Left (l), Right (r)
|-
! rowspan="2" | $89
| Sound Channel 2 Volume
| style="text-align: right" | <tt style="white-space: nowrap">llll rrrr</tt>
| RW8
| Left (l), Right (r)
|-
| Sound Channel 2 Voice Sample
| style="text-align: right" | <tt style="white-space: nowrap">ssss ssss</tt>
| RW8
| Sample (s)
|-
! $8A
| Sound Channel 3 Volume
| style="text-align: right" | <tt style="white-space: nowrap">llll rrrr</tt>
| RW8
| Left (l), Right (r)
|-
! $8B
| Sound Channel 4 Volume
| style="text-align: right" | <tt style="white-space: nowrap">llll rrrr</tt>
| RW8
| Left (l), Right (r)
|-
! $8C
| Sound Channel 3 Sweep Amount
| style="text-align: right" | <tt style="white-space: nowrap">vvvv vvvv</tt>
| RW8
| Value (v)
|-
! $8D
| Sound Channel 3 Sweep Ticks
| style="text-align: right" | <tt style="white-space: nowrap">...t tttt</tt>
| RW8
| Ticks (t)
|-
! $8E
| Sound Channel 4 Noise Control
| style="text-align: right" | <tt style="white-space: nowrap">...e rttt</tt>
| RW8
| Enable (e), Reset (r), Tap (t)
|-
! $8F
| Sound Wavetable Address
| style="text-align: right" | <tt style="white-space: nowrap">wwww wwww</tt>
| RW8
| Address >> 6 (w)
|-
! $90
| Sound Channel Control
| style="text-align: right" | <tt style="white-space: nowrap">nsv. 4321</tt>
| RW8
| Channel enable (1234)
Noise (n), Sweep (s), Voice (v)
|-
! $91
| Sound Output Control
| style="text-align: right" | <tt style="white-space: nowrap">H... hrrs</tt>
| RW8
| Headphones connected (H)
Headphone output (h)
Speaker output (s), range (r)
|-
! $92
| Sound Channel 4 LFSR
| style="text-align: right" | <tt style="white-space: nowrap">.rrr rrrr rrrr rrrr</tt>
| R16
| PRNG state (r)
|-
! $94
| Sound Channel 2 Voice Volume
| style="text-align: right" | <tt style="white-space: nowrap">.... lLrR</tt>
| RW8
| Left Half (l), Full (L)
Right Half (r), Full (R)
|-
! $96
| Sound Sequencer Output Right
| style="text-align: right" | <tt style="white-space: nowrap">.... ..ss ssss ssss</tt>
| R16
| Sample (s)
|-
! $98
| Sound Sequencer Output Left
| style="text-align: right" | <tt style="white-space: nowrap">.... ..ss ssss ssss</tt>
| R16
| Sample (s)
|-
! $9A
| Sound Sequencer Output Sum
| style="text-align: right" | <tt style="white-space: nowrap">.... .sss ssss ssss</tt>
| R16
| Sample (s)
|-
! System
! $A0
| System Control
| style="text-align: right" | <tt style="white-space: nowrap">t??? swcl</tt>
| RW8
| Test OK (t), ROM speed (s), ROM width (w),
Color system (c), Boot ROM lockout (l)
|-
! rowspan="5" | [[Timers]]
! $A2
| Timer Control
| style="text-align: right" | <tt style="white-space: nowrap">.... VvHh</tt>
| RW8
| Horizontal enable (h), auto reload (H)
Vertical enable (v), auto reload (V)
|-
! $A4
| Horizontal Blank Timer Reload
| style="text-align: right" | <tt style="white-space: nowrap">tttt tttt tttt tttt</tt>
| RW16
| Ticks (t)
|-
! $A6
| Vertical Blank Timer Reload
| style="text-align: right" | <tt style="white-space: nowrap">tttt tttt tttt tttt</tt>
| RW16
| Ticks (t)
|-
! $A8
| Horizontal Blank Timer Counter
| style="text-align: right" | <tt style="white-space: nowrap">tttt tttt tttt tttt</tt>
| R16
| Ticks (t)
|-
! $AA
| Vertical Blank Timer Counter
| style="text-align: right" | <tt style="white-space: nowrap">tttt tttt tttt tttt</tt>
| R16
| Ticks (t)
|-
! [[Interrupts]]
! $B0
| [[Interrupts#Interrupt Vector|Interrupt Vector]]
| style="text-align: right" | <tt style="white-space: nowrap">VVVV V...</tt>
| RW8
| Vector offset (v)
|-
! [[UART]]
! $B1
| [[UART#serial Data|Serial Data]]
| style="text-align: right" | <tt style="white-space: nowrap">dddd dddd</tt>
| RW8
| Data (d)
|-
! [[Interrupts]]
! $B2
| [[Interrupts#Interrupt Enable|Interrupt Enable]]
| iiii iiii
| RW8
| Interrupt index (i)
|-
! [[UART]]
! $B3
| [[UART#Serial Control|Serial Control]]
| style="text-align: right" | <tt style="white-space: nowrap">ebO. .tor</tt>
| RW8
| Enable (e), Baud rate (b), Reset Overrun (O),
Transfer ready (t), Overrun (o), Receive ready (r)
|-
! [[Interrupts]]
! $B4
| [[Interrupts#Interrupt Status|Interrupt Status]]
| iiii iiii
| R8
| Interrupt index (i)
|-
! [[Keypad]]
! $B5
| [[Keypad|Keypad Scan]]
| style="text-align: right" | <tt style="white-space: nowrap">.iii oooo</tt>
| RW8
| Input row (i), Output column (o)
|-
! rowspan="2" | [[Interrupts]]
! $B6
| [[Interrupts#Interrupt Acknowledge|Interrupt Acknowledge]]
| iiii iiii
| R8?
| Interrupt index (i)
|-
! $B7
| [[Interrupts#Interrupt NMI Control|Interrupt NMI Control]]
| style="text-align: right" | <tt style="white-space: nowrap">...b ....</tt>
| RW8
| Low battery (b)
|-
! rowspan="3" | Internal EEPROM
! $BA
| Internal EEPROM Data
| style="text-align: right" | <tt style="white-space: nowrap">dddd dddd dddd dddd</tt>
| RW16
| Data (d)
|-
! $BC
| Internal EEPROM Command
|
| RW16
|
|-
! $BE
| Internal EEPROM Control
| style="text-align: right" | <tt style="white-space: nowrap">.... .... PEWR ..rd</tt>
| RW16
| Protect (P), Erase (E), Write (W), Read (R),
Ready (r), Done (d)
|-
! [[Mapper|Cartridge]]
! $C0<br />
$FF
| Cartridge I/O
|
|
| Forwarded by the SoC
|}
8f5f79a511fbe5f1e76eb3071a6408d6efea71b0
83
79
2023-08-22T05:51:50Z
Asie
351
update timer information
wikitext
text/x-wiki
* Superscripts are used to mark ports specific to a given mode or platform:
** Color mode: <sup>(color)</sup>.
** WS/WSC/SC console: <sup>(WS)</sup>, <sup>(WSC)</sup>, <sup>(SC)</sup>.
* If two Bits rows are provided, the second one refers to the "Color" mode.
* The Type can be: R - readable, W - writable, L - writable before boot ROM lockout, 8/16 - width (byte/word).
{| class="wikitable"
! Category
! Port
! Description
! Bits
! Type
! Notes
|-
! rowspan="45" | [[Display]]
! $00
| [[Display#Display Control|Display Control]]
| style="text-align: right" | <tt style="white-space: nowrap">..ow Ws21</tt>
| RW8
|
|-
! $01
| [[Display#Display Background|Display Background]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .sss</tt>
<tt style="white-space: nowrap">pppp iiii</tt>
| RW8
| Shade (s)
Palette (p), Index (i)
|-
! $02
| [[Display#Current Line|Display Current Line]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll</tt>
| R8
| Line (l)
|-
! $03
| [[Display#Interrupt Line|Display Interrupt Line]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll</tt>
| RW8
| Line (l)
|-
! $04
| [[Display#Sprite Table Address|Sprite Table Address]]
| style="text-align: right" | <tt style="white-space: nowrap">...a aaaa</tt>
<tt style="white-space: nowrap">..aa aaaa</tt>
| RW8
| Address >> 9 (a)
|-
! $05
| [[Display#Sprite Table First|Sprite Table First]]
| style="text-align: right" | <tt style="white-space: nowrap">.iii iiii</tt>
| RW8
| Index (i)
|-
! $06
| [[Display#Sprite Table Count|Sprite Table Count]]
| style="text-align: right" | <tt style="white-space: nowrap">cccc cccc</tt>
| RW8
| Count (c)
|-
! $07
| [[Display#Screen Address|Screen Address]]
| style="text-align: right" | <tt style="white-space: nowrap">.222 .111</tt>
<tt style="white-space: nowrap">2222 1111</tt>
| RW8
| Screen 1 address >> 11 (1)
Screen 2 address >> 11 (2)
|-
! $08
| [[Display#Screen 2 Window|Screen 2 Window Left]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $09
| [[Display#Screen 2 Window|Screen 2 Window Top]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $0A
| [[Display#Screen 2 Window|Screen 2 Window Right]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $0B
| [[Display#Screen 2 Window|Screen 2 Window Bottom]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $0B
| [[Display#Sprite Window|Sprite Window Left]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $0C
| [[Display#Sprite Window|Sprite Window Top]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $0E
| [[Display#Sprite Window|Sprite Window Right]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $0F
| [[Display#Sprite Window|Sprite Window Bottom]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $10
| [[Display#Screen Scroll|Screen 1 Scroll X]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $11
| [[Display#Screen Scroll|Screen 1 Scroll Y]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $12
| [[Display#Screen Scroll|Screen 2 Scroll X]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $13
| [[Display#Screen Scroll|Screen 2 Scroll Y]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $14
| [[Display#LCD Control|LCD Control]]
| style="text-align: right" | <tt style="white-space: nowrap">.... ..Ce</tt>
| RW8
| Contrast (C)<sup>(WSC)</sup>, Enable (e)
|-
! $15
| [[Display#LCD Icon Control|LCD Icon Control]]
| style="text-align: right" | <tt style="white-space: nowrap">..32 1hvs</tt>
| RW8
| Auxillary 3 (3), Auxillary 2 (2), Auxillary 1 (1),
Horizontal (h), Vertical (v), Sleep (s)
|-
! $16
| [[Display#LCD Final Line|LCD Final Line]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll</tt>
| RW8
| Line (l)
|-
! $17
| [[Display#LCD Back Porch Line|LCD Back Porch Line]]<sup>(WSC)</sup>
| style="text-align: right" | <tt style="white-space: nowrap">llll llll</tt>
| RW8
| Line (l)
|-
! $1A
| [[Display#LCD Status|LCD Status]]
| style="text-align: right" | <tt style="white-space: nowrap">...v vv.e</tt>
| RW8
| Volume segment status (v), Enable (e)
|-
! $1C
| [[Display#LCD Mono Shade LUT|LCD Mono Shade LUT 0/1]]
| style="text-align: right" | <tt style="white-space: nowrap">1111 0000</tt>
| RW8
| Shade index
|-
! $1D
| [[Display#LCD Mono Shade LUT|LCD Mono Shade LUT 2/3]]
| style="text-align: right" | <tt style="white-space: nowrap">3333 2222</tt>
| RW8
| Shade index
|-
! $1E
| [[Display#LCD Mono Shade LUT|LCD Mono Shade LUT 4/5]]
| style="text-align: right" | <tt style="white-space: nowrap">5555 4444</tt>
| RW8
| Shade index
|-
! $1F
| [[Display#LCD Mono Shade LUT|LCD Mono Shade LUT 6/7]]
| style="text-align: right" | <tt style="white-space: nowrap">7777 6666</tt>
| RW8
| Shade index
|-
! $20
| [[Display#LCD Mono Palette|LCD Mono Palette 0]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $22
| [[Display#LCD Mono Palette|LCD Mono Palette 1]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $24
| [[Display#LCD Mono Palette|LCD Mono Palette 2]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $26
| [[Display#LCD Mono Palette|LCD Mono Palette 3]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $28
| [[Display#LCD Mono Palette|LCD Mono Palette 4]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $2A
| [[Display#LCD Mono Palette|LCD Mono Palette 5]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $2C
| [[Display#LCD Mono Palette|LCD Mono Palette 6]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $2E
| [[Display#LCD Mono Palette|LCD Mono Palette 7]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $30
| [[Display#LCD Mono Palette|LCD Mono Palette 8]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $32
| [[Display#LCD Mono Palette|LCD Mono Palette 9]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $34
| [[Display#LCD Mono Palette|LCD Mono Palette 10]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $36
| [[Display#LCD Mono Palette|LCD Mono Palette 11]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $38
| [[Display#LCD Mono Palette|LCD Mono Palette 12]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $3A
| [[Display#LCD Mono Palette|LCD Mono Palette 13]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $3C
| [[Display#LCD Mono Palette|LCD Mono Palette 14]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $3E
| [[Display#LCD Mono Palette|LCD Mono Palette 15]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! rowspan="10" | [[DMA]]<sup>(color)</sup>
! $40
| [[DMA#General DMA|GDMA Source Address Low]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll llll llll</tt>
| RW16
| Linear address, low 16 bits (l)
|-
! $42
| [[DMA#General DMA|GDMA Source Address High]]
| style="text-align: right" | <tt style="white-space: nowrap">.... hhhh</tt>
| RW8
| Linear address, high 4 bits (h)
|-
! $44
| [[DMA#General DMA|GDMA Destination Address]]
| style="text-align: right" | <tt style="white-space: nowrap">aaaa aaaa aaaa aaaa</tt>
| RW16
| IRAM address (a)
|-
! $46
| [[DMA#General DMA|GDMA Length]]
| style="text-align: right" | <tt style="white-space: nowrap">bbbb bbbb bbbb bbbb</tt>
| RW16
| Bytes (b)
|-
! $48
| [[DMA#General DMA|GDMA Control]]
| style="text-align: right" | <tt style="white-space: nowrap">ed.. ....</tt>
| RW8
| Enable (e), Decrement (d)
|-
! $4A
| [[DMA#Sound DMA|SDMA Source Address Low]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll llll llll</tt>
| RW16
| Linear address, low 16 bits (l)
|-
! $4C
| [[DMA#Sound DMA|SDMA Source Address High]]
| style="text-align: right" | <tt style="white-space: nowrap">.... hhhh</tt>
| RW8
| Linear address, high 4 bits (h)
|-
! $4E
| [[DMA#Sound DMA|SDMA Length Low]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll llll llll</tt>
| RW16
| Length, low 16 bits (l)
|-
! $50
| [[DMA#Sound DMA|SDMA Length High]]
| style="text-align: right" | <tt style="white-space: nowrap">.... hhhh</tt>
| RW8
| Length, high 4 bits (h)
|-
! $52
| [[DMA#Sound DMA|SDMA Control]]
| style="text-align: right" | <tt style="white-space: nowrap">ed.t r?ff</tt>
| RW8
| Enable (e), Decrement (d), Target (t),
Repeat (r), Frequency (f)
|-
! rowspan="2" | System<sup>(color)</sup>
! $60
| System Control 2
| style="text-align: right" | <tt style="white-space: nowrap">c4C. ?.??</tt>
| RW8
| Color (c), 4BPP (4), Chunky (C)
|-
! $62
| System Control 3
| style="text-align: right" | <tt style="white-space: nowrap">S... ...p</tt>
| RW8
| SwanCrystal (S), Power off (p)
|-
! rowspan="5" | [[Hyper Voice]]<sup>(color)</sup>
! $64
| Hyper Voice Left Output
| style="text-align: right" | <tt style="white-space: nowrap">ssss ssss ssss ssss</tt>
| W16
| Raw sample (s)
|-
! $66
| Hyper Voice Right Output
| style="text-align: right" | <tt style="white-space: nowrap">ssss ssss ssss ssss</tt>
| W16
| Raw sample (s)
|-
! $68
| Hyper Voice Left Input
| style="text-align: right" | <tt style="white-space: nowrap">ssss ssss</tt>
| 8
| Sample (s)
|-
! $69
| Hyper Voice Right Input
| style="text-align: right" | <tt style="white-space: nowrap">ssss ssss</tt>
| 8
| Sample (s)
|-
! $6A
| Hyper Voice Control
| style="text-align: right" | <tt style="white-space: nowrap">.mmc .... errr ffss</tt>
| RW16
| Mask (m), Channel (c), Enable (e),
Rate (r), Format (f), Shift (s)
|-
! rowspan="8" | [[Display]]<sup>(SC)</sup>
! $70
| LCD Timing Configuration 1?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $71
| LCD Timing Configuration 2?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $72
| LCD Timing Configuration 3?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $73
| LCD Timing Configuration 4?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $74
| LCD Timing Configuration 5?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $75
| LCD Timing Configuration 6?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $76
| LCD Timing Configuration 7?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $77
| LCD Timing Configuration 8?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! rowspan="20" | [[Sound]]
! $80
| Sound Channel 1 Frequency
| style="text-align: right" | <tt style="white-space: nowrap">.... .ddd dddd dddd</tt>
| RW16
| Divider (d)
|-
! $82
| Sound Channel 2 Frequency
| style="text-align: right" | <tt style="white-space: nowrap">.... .ddd dddd dddd</tt>
| RW16
| Divider (d)
|-
! $84
| Sound Channel 3 Frequency
| style="text-align: right" | <tt style="white-space: nowrap">.... .ddd dddd dddd</tt>
| RW16
| Divider (d)
|-
! $86
| Sound Channel 4 Frequency
| style="text-align: right" | <tt style="white-space: nowrap">.... .ddd dddd dddd</tt>
| RW16
| Divider (d)
|-
! $88
| Sound Channel 1 Volume
| style="text-align: right" | <tt style="white-space: nowrap">llll rrrr</tt>
| RW8
| Left (l), Right (r)
|-
! rowspan="2" | $89
| Sound Channel 2 Volume
| style="text-align: right" | <tt style="white-space: nowrap">llll rrrr</tt>
| RW8
| Left (l), Right (r)
|-
| Sound Channel 2 Voice Sample
| style="text-align: right" | <tt style="white-space: nowrap">ssss ssss</tt>
| RW8
| Sample (s)
|-
! $8A
| Sound Channel 3 Volume
| style="text-align: right" | <tt style="white-space: nowrap">llll rrrr</tt>
| RW8
| Left (l), Right (r)
|-
! $8B
| Sound Channel 4 Volume
| style="text-align: right" | <tt style="white-space: nowrap">llll rrrr</tt>
| RW8
| Left (l), Right (r)
|-
! $8C
| Sound Channel 3 Sweep Amount
| style="text-align: right" | <tt style="white-space: nowrap">vvvv vvvv</tt>
| RW8
| Value (v)
|-
! $8D
| Sound Channel 3 Sweep Ticks
| style="text-align: right" | <tt style="white-space: nowrap">...t tttt</tt>
| RW8
| Ticks (t)
|-
! $8E
| Sound Channel 4 Noise Control
| style="text-align: right" | <tt style="white-space: nowrap">...e rttt</tt>
| RW8
| Enable (e), Reset (r), Tap (t)
|-
! $8F
| Sound Wavetable Address
| style="text-align: right" | <tt style="white-space: nowrap">wwww wwww</tt>
| RW8
| Address >> 6 (w)
|-
! $90
| Sound Channel Control
| style="text-align: right" | <tt style="white-space: nowrap">nsv. 4321</tt>
| RW8
| Channel enable (1234)
Noise (n), Sweep (s), Voice (v)
|-
! $91
| Sound Output Control
| style="text-align: right" | <tt style="white-space: nowrap">H... hrrs</tt>
| RW8
| Headphones connected (H)
Headphone output (h)
Speaker output (s), range (r)
|-
! $92
| Sound Channel 4 LFSR
| style="text-align: right" | <tt style="white-space: nowrap">.rrr rrrr rrrr rrrr</tt>
| R16
| PRNG state (r)
|-
! $94
| Sound Channel 2 Voice Volume
| style="text-align: right" | <tt style="white-space: nowrap">.... lLrR</tt>
| RW8
| Left Half (l), Full (L)
Right Half (r), Full (R)
|-
! $96
| Sound Sequencer Output Right
| style="text-align: right" | <tt style="white-space: nowrap">.... ..ss ssss ssss</tt>
| R16
| Sample (s)
|-
! $98
| Sound Sequencer Output Left
| style="text-align: right" | <tt style="white-space: nowrap">.... ..ss ssss ssss</tt>
| R16
| Sample (s)
|-
! $9A
| Sound Sequencer Output Sum
| style="text-align: right" | <tt style="white-space: nowrap">.... .sss ssss ssss</tt>
| R16
| Sample (s)
|-
! System
! $A0
| System Control
| style="text-align: right" | <tt style="white-space: nowrap">t??? swcl</tt>
| RW8
| Test OK (t), ROM speed (s), ROM width (w),
Color system (c), Boot ROM lockout (l)
|-
! rowspan="5" | [[Timers]]
! $A2
| [[Timers#Timer Control|Timer Control]]
| style="text-align: right" | <tt style="white-space: nowrap">.... VvHh</tt>
| RW8
| Horizontal enable (h), auto reload (H)
Vertical enable (v), auto reload (V)
|-
! $A4
| [[Timers#Timer Reload|Horizontal Blank Timer Reload]]
| style="text-align: right" | <tt style="white-space: nowrap">tttt tttt tttt tttt</tt>
| RW16
| Ticks (t)
|-
! $A6
| [[Timers#Timer Reload|Vertical Blank Timer Reload]]
| style="text-align: right" | <tt style="white-space: nowrap">tttt tttt tttt tttt</tt>
| RW16
| Ticks (t)
|-
! $A8
| [[Timers#Timer Counter|Horizontal Blank Timer Counter]]
| style="text-align: right" | <tt style="white-space: nowrap">tttt tttt tttt tttt</tt>
| R16
| Ticks (t)
|-
! $AA
| [[Timers#Timer Counter|Vertical Blank Timer Counter]]
| style="text-align: right" | <tt style="white-space: nowrap">tttt tttt tttt tttt</tt>
| R16
| Ticks (t)
|-
! [[Interrupts]]
! $B0
| [[Interrupts#Interrupt Vector|Interrupt Vector]]
| style="text-align: right" | <tt style="white-space: nowrap">VVVV V...</tt>
| RW8
| Vector offset (v)
|-
! [[UART]]
! $B1
| [[UART#serial Data|Serial Data]]
| style="text-align: right" | <tt style="white-space: nowrap">dddd dddd</tt>
| RW8
| Data (d)
|-
! [[Interrupts]]
! $B2
| [[Interrupts#Interrupt Enable|Interrupt Enable]]
| iiii iiii
| RW8
| Interrupt index (i)
|-
! [[UART]]
! $B3
| [[UART#Serial Control|Serial Control]]
| style="text-align: right" | <tt style="white-space: nowrap">ebO. .tor</tt>
| RW8
| Enable (e), Baud rate (b), Reset Overrun (O),
Transfer ready (t), Overrun (o), Receive ready (r)
|-
! [[Interrupts]]
! $B4
| [[Interrupts#Interrupt Status|Interrupt Status]]
| iiii iiii
| R8
| Interrupt index (i)
|-
! [[Keypad]]
! $B5
| [[Keypad|Keypad Scan]]
| style="text-align: right" | <tt style="white-space: nowrap">.iii oooo</tt>
| RW8
| Input row (i), Output column (o)
|-
! rowspan="2" | [[Interrupts]]
! $B6
| [[Interrupts#Interrupt Acknowledge|Interrupt Acknowledge]]
| iiii iiii
| R8?
| Interrupt index (i)
|-
! $B7
| [[Interrupts#Interrupt NMI Control|Interrupt NMI Control]]
| style="text-align: right" | <tt style="white-space: nowrap">...b ....</tt>
| RW8
| Low battery (b)
|-
! rowspan="3" | Internal EEPROM
! $BA
| Internal EEPROM Data
| style="text-align: right" | <tt style="white-space: nowrap">dddd dddd dddd dddd</tt>
| RW16
| Data (d)
|-
! $BC
| Internal EEPROM Command
|
| RW16
|
|-
! $BE
| Internal EEPROM Control
| style="text-align: right" | <tt style="white-space: nowrap">.... .... PEWR ..rd</tt>
| RW16
| Protect (P), Erase (E), Write (W), Read (R),
Ready (r), Done (d)
|-
! [[Mapper|Cartridge]]
! $C0<br />
$FF
| Cartridge I/O
|
|
| Forwarded by the SoC
|}
c985e7981a44c5a778a3de456184708393824138
98
83
2023-08-22T09:13:02Z
Asie
351
wikitext
text/x-wiki
* Superscripts are used to mark ports specific to a given mode or platform:
** Color mode: <sup>(color)</sup>.
** WS/WSC/SC console: <sup>(WS)</sup>, <sup>(WSC)</sup>, <sup>(SC)</sup>.
* If two Bits rows are provided, the second one refers to the "Color" mode.
* The Type can be: R - readable, W - writable, L - writable before boot ROM lockout, 8/16 - width (byte/word).
{| class="wikitable"
! Category
! Port
! Description
! Bits
! Type
! Notes
|-
! rowspan="45" | [[Display]]
! $00
| [[Display#Display Control|Display Control]]
| style="text-align: right" | <tt style="white-space: nowrap">..ow Ws21</tt>
| RW8
|
|-
! $01
| [[Display#Display Background|Display Background]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .sss</tt>
<tt style="white-space: nowrap">pppp iiii</tt>
| RW8
| Shade (s)
Palette (p), Index (i)
|-
! $02
| [[Display#Current Line|Display Current Line]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll</tt>
| R8
| Line (l)
|-
! $03
| [[Display#Interrupt Line|Display Interrupt Line]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll</tt>
| RW8
| Line (l)
|-
! $04
| [[Display#Sprite Table Address|Sprite Table Address]]
| style="text-align: right" | <tt style="white-space: nowrap">...a aaaa</tt>
<tt style="white-space: nowrap">..aa aaaa</tt>
| RW8
| Address >> 9 (a)
|-
! $05
| [[Display#Sprite Table First|Sprite Table First]]
| style="text-align: right" | <tt style="white-space: nowrap">.iii iiii</tt>
| RW8
| Index (i)
|-
! $06
| [[Display#Sprite Table Count|Sprite Table Count]]
| style="text-align: right" | <tt style="white-space: nowrap">cccc cccc</tt>
| RW8
| Count (c)
|-
! $07
| [[Display#Screen Address|Screen Address]]
| style="text-align: right" | <tt style="white-space: nowrap">.222 .111</tt>
<tt style="white-space: nowrap">2222 1111</tt>
| RW8
| Screen 1 address >> 11 (1)
Screen 2 address >> 11 (2)
|-
! $08
| [[Display#Screen 2 Window|Screen 2 Window Left]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $09
| [[Display#Screen 2 Window|Screen 2 Window Top]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $0A
| [[Display#Screen 2 Window|Screen 2 Window Right]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $0B
| [[Display#Screen 2 Window|Screen 2 Window Bottom]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $0B
| [[Display#Sprite Window|Sprite Window Left]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $0C
| [[Display#Sprite Window|Sprite Window Top]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $0E
| [[Display#Sprite Window|Sprite Window Right]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $0F
| [[Display#Sprite Window|Sprite Window Bottom]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $10
| [[Display#Screen Scroll|Screen 1 Scroll X]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $11
| [[Display#Screen Scroll|Screen 1 Scroll Y]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $12
| [[Display#Screen Scroll|Screen 2 Scroll X]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $13
| [[Display#Screen Scroll|Screen 2 Scroll Y]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $14
| [[Display#LCD Control|LCD Control]]
| style="text-align: right" | <tt style="white-space: nowrap">.... ..Ce</tt>
| RW8
| Contrast (C)<sup>(WSC)</sup>, Enable (e)
|-
! $15
| [[Display#LCD Icon Control|LCD Icon Control]]
| style="text-align: right" | <tt style="white-space: nowrap">..32 1hvs</tt>
| RW8
| Auxillary 3 (3), Auxillary 2 (2), Auxillary 1 (1),
Horizontal (h), Vertical (v), Sleep (s)
|-
! $16
| [[Display#LCD Final Line|LCD Final Line]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll</tt>
| RW8
| Line (l)
|-
! $17
| [[Display#LCD Back Porch Line|LCD Back Porch Line]]<sup>(WSC)</sup>
| style="text-align: right" | <tt style="white-space: nowrap">llll llll</tt>
| RW8
| Line (l)
|-
! $1A
| [[Display#LCD Status|LCD Status]]
| style="text-align: right" | <tt style="white-space: nowrap">...v vv.s</tt>
| RW8
| Volume segment status (v), Sleep (s)
|-
! $1C
| [[Display#LCD Mono Shade LUT|LCD Mono Shade LUT 0/1]]
| style="text-align: right" | <tt style="white-space: nowrap">1111 0000</tt>
| RW8
| Shade index
|-
! $1D
| [[Display#LCD Mono Shade LUT|LCD Mono Shade LUT 2/3]]
| style="text-align: right" | <tt style="white-space: nowrap">3333 2222</tt>
| RW8
| Shade index
|-
! $1E
| [[Display#LCD Mono Shade LUT|LCD Mono Shade LUT 4/5]]
| style="text-align: right" | <tt style="white-space: nowrap">5555 4444</tt>
| RW8
| Shade index
|-
! $1F
| [[Display#LCD Mono Shade LUT|LCD Mono Shade LUT 6/7]]
| style="text-align: right" | <tt style="white-space: nowrap">7777 6666</tt>
| RW8
| Shade index
|-
! $20
| [[Display#LCD Mono Palette|LCD Mono Palette 0]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $22
| [[Display#LCD Mono Palette|LCD Mono Palette 1]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $24
| [[Display#LCD Mono Palette|LCD Mono Palette 2]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $26
| [[Display#LCD Mono Palette|LCD Mono Palette 3]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $28
| [[Display#LCD Mono Palette|LCD Mono Palette 4]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $2A
| [[Display#LCD Mono Palette|LCD Mono Palette 5]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $2C
| [[Display#LCD Mono Palette|LCD Mono Palette 6]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $2E
| [[Display#LCD Mono Palette|LCD Mono Palette 7]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $30
| [[Display#LCD Mono Palette|LCD Mono Palette 8]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $32
| [[Display#LCD Mono Palette|LCD Mono Palette 9]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $34
| [[Display#LCD Mono Palette|LCD Mono Palette 10]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $36
| [[Display#LCD Mono Palette|LCD Mono Palette 11]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $38
| [[Display#LCD Mono Palette|LCD Mono Palette 12]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $3A
| [[Display#LCD Mono Palette|LCD Mono Palette 13]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $3C
| [[Display#LCD Mono Palette|LCD Mono Palette 14]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $3E
| [[Display#LCD Mono Palette|LCD Mono Palette 15]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! rowspan="10" | [[DMA]]<sup>(color)</sup>
! $40
| [[DMA#General DMA|GDMA Source Address Low]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll llll llll</tt>
| RW16
| Linear address, low 16 bits (l)
|-
! $42
| [[DMA#General DMA|GDMA Source Address High]]
| style="text-align: right" | <tt style="white-space: nowrap">.... hhhh</tt>
| RW8
| Linear address, high 4 bits (h)
|-
! $44
| [[DMA#General DMA|GDMA Destination Address]]
| style="text-align: right" | <tt style="white-space: nowrap">aaaa aaaa aaaa aaaa</tt>
| RW16
| IRAM address (a)
|-
! $46
| [[DMA#General DMA|GDMA Length]]
| style="text-align: right" | <tt style="white-space: nowrap">bbbb bbbb bbbb bbbb</tt>
| RW16
| Bytes (b)
|-
! $48
| [[DMA#General DMA|GDMA Control]]
| style="text-align: right" | <tt style="white-space: nowrap">ed.. ....</tt>
| RW8
| Enable (e), Decrement (d)
|-
! $4A
| [[DMA#Sound DMA|SDMA Source Address Low]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll llll llll</tt>
| RW16
| Linear address, low 16 bits (l)
|-
! $4C
| [[DMA#Sound DMA|SDMA Source Address High]]
| style="text-align: right" | <tt style="white-space: nowrap">.... hhhh</tt>
| RW8
| Linear address, high 4 bits (h)
|-
! $4E
| [[DMA#Sound DMA|SDMA Length Low]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll llll llll</tt>
| RW16
| Length, low 16 bits (l)
|-
! $50
| [[DMA#Sound DMA|SDMA Length High]]
| style="text-align: right" | <tt style="white-space: nowrap">.... hhhh</tt>
| RW8
| Length, high 4 bits (h)
|-
! $52
| [[DMA#Sound DMA|SDMA Control]]
| style="text-align: right" | <tt style="white-space: nowrap">ed.t r?ff</tt>
| RW8
| Enable (e), Decrement (d), Target (t),
Repeat (r), Frequency (f)
|-
! rowspan="2" | System<sup>(color)</sup>
! $60
| System Control 2
| style="text-align: right" | <tt style="white-space: nowrap">c4C. ?.??</tt>
| RW8
| Color (c), 4BPP (4), Chunky (C)
|-
! $62
| System Control 3
| style="text-align: right" | <tt style="white-space: nowrap">S... ...p</tt>
| RW8
| SwanCrystal (S), Power off (p)
|-
! rowspan="5" | [[Hyper Voice]]<sup>(color)</sup>
! $64
| Hyper Voice Left Output
| style="text-align: right" | <tt style="white-space: nowrap">ssss ssss ssss ssss</tt>
| W16
| Raw sample (s)
|-
! $66
| Hyper Voice Right Output
| style="text-align: right" | <tt style="white-space: nowrap">ssss ssss ssss ssss</tt>
| W16
| Raw sample (s)
|-
! $68
| Hyper Voice Left Input
| style="text-align: right" | <tt style="white-space: nowrap">ssss ssss</tt>
| 8
| Sample (s)
|-
! $69
| Hyper Voice Right Input
| style="text-align: right" | <tt style="white-space: nowrap">ssss ssss</tt>
| 8
| Sample (s)
|-
! $6A
| Hyper Voice Control
| style="text-align: right" | <tt style="white-space: nowrap">.mmc .... errr ffss</tt>
| RW16
| Mask (m), Channel (c), Enable (e),
Rate (r), Format (f), Shift (s)
|-
! rowspan="8" | [[Display]]<sup>(SC)</sup>
! $70
| LCD Timing Configuration 1?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $71
| LCD Timing Configuration 2?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $72
| LCD Timing Configuration 3?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $73
| LCD Timing Configuration 4?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $74
| LCD Timing Configuration 5?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $75
| LCD Timing Configuration 6?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $76
| LCD Timing Configuration 7?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $77
| LCD Timing Configuration 8?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! rowspan="20" | [[Sound]]
! $80
| Sound Channel 1 Frequency
| style="text-align: right" | <tt style="white-space: nowrap">.... .ddd dddd dddd</tt>
| RW16
| Divider (d)
|-
! $82
| Sound Channel 2 Frequency
| style="text-align: right" | <tt style="white-space: nowrap">.... .ddd dddd dddd</tt>
| RW16
| Divider (d)
|-
! $84
| Sound Channel 3 Frequency
| style="text-align: right" | <tt style="white-space: nowrap">.... .ddd dddd dddd</tt>
| RW16
| Divider (d)
|-
! $86
| Sound Channel 4 Frequency
| style="text-align: right" | <tt style="white-space: nowrap">.... .ddd dddd dddd</tt>
| RW16
| Divider (d)
|-
! $88
| Sound Channel 1 Volume
| style="text-align: right" | <tt style="white-space: nowrap">llll rrrr</tt>
| RW8
| Left (l), Right (r)
|-
! rowspan="2" | $89
| Sound Channel 2 Volume
| style="text-align: right" | <tt style="white-space: nowrap">llll rrrr</tt>
| RW8
| Left (l), Right (r)
|-
| Sound Channel 2 Voice Sample
| style="text-align: right" | <tt style="white-space: nowrap">ssss ssss</tt>
| RW8
| Sample (s)
|-
! $8A
| Sound Channel 3 Volume
| style="text-align: right" | <tt style="white-space: nowrap">llll rrrr</tt>
| RW8
| Left (l), Right (r)
|-
! $8B
| Sound Channel 4 Volume
| style="text-align: right" | <tt style="white-space: nowrap">llll rrrr</tt>
| RW8
| Left (l), Right (r)
|-
! $8C
| Sound Channel 3 Sweep Amount
| style="text-align: right" | <tt style="white-space: nowrap">vvvv vvvv</tt>
| RW8
| Value (v)
|-
! $8D
| Sound Channel 3 Sweep Ticks
| style="text-align: right" | <tt style="white-space: nowrap">...t tttt</tt>
| RW8
| Ticks (t)
|-
! $8E
| Sound Channel 4 Noise Control
| style="text-align: right" | <tt style="white-space: nowrap">...e rttt</tt>
| RW8
| Enable (e), Reset (r), Tap (t)
|-
! $8F
| Sound Wavetable Address
| style="text-align: right" | <tt style="white-space: nowrap">wwww wwww</tt>
| RW8
| Address >> 6 (w)
|-
! $90
| Sound Channel Control
| style="text-align: right" | <tt style="white-space: nowrap">nsv. 4321</tt>
| RW8
| Channel enable (1234)
Noise (n), Sweep (s), Voice (v)
|-
! $91
| Sound Output Control
| style="text-align: right" | <tt style="white-space: nowrap">H... hrrs</tt>
| RW8
| Headphones connected (H)
Headphone output (h)
Speaker output (s), range (r)
|-
! $92
| Sound Channel 4 LFSR
| style="text-align: right" | <tt style="white-space: nowrap">.rrr rrrr rrrr rrrr</tt>
| R16
| PRNG state (r)
|-
! $94
| Sound Channel 2 Voice Volume
| style="text-align: right" | <tt style="white-space: nowrap">.... lLrR</tt>
| RW8
| Left Half (l), Full (L)
Right Half (r), Full (R)
|-
! $96
| Sound Sequencer Output Right
| style="text-align: right" | <tt style="white-space: nowrap">.... ..ss ssss ssss</tt>
| R16
| Sample (s)
|-
! $98
| Sound Sequencer Output Left
| style="text-align: right" | <tt style="white-space: nowrap">.... ..ss ssss ssss</tt>
| R16
| Sample (s)
|-
! $9A
| Sound Sequencer Output Sum
| style="text-align: right" | <tt style="white-space: nowrap">.... .sss ssss ssss</tt>
| R16
| Sample (s)
|-
! System
! $A0
| System Control
| style="text-align: right" | <tt style="white-space: nowrap">t??? swcl</tt>
| RW8
| Test OK (t), ROM speed (s), ROM width (w),
Color system (c), Boot ROM lockout (l)
|-
! rowspan="5" | [[Timers]]
! $A2
| [[Timers#Timer Control|Timer Control]]
| style="text-align: right" | <tt style="white-space: nowrap">.... VvHh</tt>
| RW8
| Horizontal enable (h), auto reload (H)
Vertical enable (v), auto reload (V)
|-
! $A4
| [[Timers#Timer Reload|Horizontal Blank Timer Reload]]
| style="text-align: right" | <tt style="white-space: nowrap">tttt tttt tttt tttt</tt>
| RW16
| Ticks (t)
|-
! $A6
| [[Timers#Timer Reload|Vertical Blank Timer Reload]]
| style="text-align: right" | <tt style="white-space: nowrap">tttt tttt tttt tttt</tt>
| RW16
| Ticks (t)
|-
! $A8
| [[Timers#Timer Counter|Horizontal Blank Timer Counter]]
| style="text-align: right" | <tt style="white-space: nowrap">tttt tttt tttt tttt</tt>
| R16
| Ticks (t)
|-
! $AA
| [[Timers#Timer Counter|Vertical Blank Timer Counter]]
| style="text-align: right" | <tt style="white-space: nowrap">tttt tttt tttt tttt</tt>
| R16
| Ticks (t)
|-
! [[Interrupts]]
! $B0
| [[Interrupts#Interrupt Vector|Interrupt Vector]]
| style="text-align: right" | <tt style="white-space: nowrap">VVVV V...</tt>
| RW8
| Vector offset (v)
|-
! [[UART]]
! $B1
| [[UART#serial Data|Serial Data]]
| style="text-align: right" | <tt style="white-space: nowrap">dddd dddd</tt>
| RW8
| Data (d)
|-
! [[Interrupts]]
! $B2
| [[Interrupts#Interrupt Enable|Interrupt Enable]]
| iiii iiii
| RW8
| Interrupt index (i)
|-
! [[UART]]
! $B3
| [[UART#Serial Control|Serial Control]]
| style="text-align: right" | <tt style="white-space: nowrap">ebO. .tor</tt>
| RW8
| Enable (e), Baud rate (b), Reset Overrun (O),
Transfer ready (t), Overrun (o), Receive ready (r)
|-
! [[Interrupts]]
! $B4
| [[Interrupts#Interrupt Status|Interrupt Status]]
| iiii iiii
| R8
| Interrupt index (i)
|-
! [[Keypad]]
! $B5
| [[Keypad|Keypad Scan]]
| style="text-align: right" | <tt style="white-space: nowrap">.iii oooo</tt>
| RW8
| Input row (i), Output column (o)
|-
! rowspan="2" | [[Interrupts]]
! $B6
| [[Interrupts#Interrupt Acknowledge|Interrupt Acknowledge]]
| iiii iiii
| R8?
| Interrupt index (i)
|-
! $B7
| [[Interrupts#Interrupt NMI Control|Interrupt NMI Control]]
| style="text-align: right" | <tt style="white-space: nowrap">...b ....</tt>
| RW8
| Low battery (b)
|-
! rowspan="3" | Internal EEPROM
! $BA
| Internal EEPROM Data
| style="text-align: right" | <tt style="white-space: nowrap">dddd dddd dddd dddd</tt>
| RW16
| Data (d)
|-
! $BC
| Internal EEPROM Command
|
| RW16
|
|-
! $BE
| Internal EEPROM Control
| style="text-align: right" | <tt style="white-space: nowrap">.... .... PEWR ..rd</tt>
| RW16
| Protect (P), Erase (E), Write (W), Read (R),
Ready (r), Done (d)
|-
! [[Mapper|Cartridge]]
! $C0<br />
$FF
| Cartridge I/O
|
|
| Forwarded by the SoC
|}
4f72cc5aab81576b03ada5fe9a6861e9cdcdef08
WSdev Wiki
0
1
57
21
2023-08-20T19:10:06Z
Asie
351
consistency: rename Serial port to UART
wikitext
text/x-wiki
'''WonderSwan Development Wiki'''
== Reference ==
=== General ===
* [[Memory map]]
* [[I/O port map]]
* [[Cartridge]]
* [[ROM header]]
* [[NEC V30MZ]] - the WonderSwan CPU (80186-compatible)
* [[Timing]]
=== Components ===
* [[Display]]
* [[Sound]]
* [[Keypad]]
* [[Timers]]
* [[Interrupts]]
* [[UART]]
* [[EEPROM]]
* [[DMA]] (WonderSwan Color only)
* [[Mapper]]
** [[Real-Time Clock]] (2003)
=== Pinouts ===
* [[Accessory port pinout]]
* [[2001 Mapper pinout]]
* [[2003 Mapper pinout]]
=== Accessories ===
* [[WonderBeat 9480]] headphone adapter
* [[WonderBorg]] robot
* [[WonderGate]] mobile adapter
* [[WonderWave]] infrared adapter
=== WonderWitch ===
* [[FreyaBIOS]]
* [[WonderWitch .fx files|.fx file format]]
== Links ==
* [https://github.com/WonderfulToolchain/awesome-wsdev awesome-wsdev] - curated documentation/tools/source code link list
== MediaWiki ==
* [https://www.mediawiki.org/wiki/Special:MyLanguage/Help:Contents User's Guide]
* [https://www.mediawiki.org/wiki/Special:MyLanguage/Manual:FAQ MediaWiki FAQ]
* [[:Category:Deletion requests|Deletion requests]]
c2b42cba83f04e05b128d9d687f172ba2145f79c
59
57
2023-08-20T22:01:15Z
Lidnariq
7
/* Pinouts */ a few other pinouts
wikitext
text/x-wiki
'''WonderSwan Development Wiki'''
== Reference ==
=== General ===
* [[Memory map]]
* [[I/O port map]]
* [[Cartridge]]
* [[ROM header]]
* [[NEC V30MZ]] - the WonderSwan CPU (80186-compatible)
* [[Timing]]
=== Components ===
* [[Display]]
* [[Sound]]
* [[Keypad]]
* [[Timers]]
* [[Interrupts]]
* [[UART]]
* [[EEPROM]]
* [[DMA]] (WonderSwan Color only)
* [[Mapper]]
** [[Real-Time Clock]] (2003)
=== Pinouts ===
* [[Accessory port pinout]]
* [[2001 Mapper pinout]]
* [[2003 Mapper pinout]]
* [[KARNAK pinout]]
* [[GIZA pinout]]
* [[S-3511A pinout]]
=== Accessories ===
* [[WonderBeat 9480]] headphone adapter
* [[WonderBorg]] robot
* [[WonderGate]] mobile adapter
* [[WonderWave]] infrared adapter
=== WonderWitch ===
* [[FreyaBIOS]]
* [[WonderWitch .fx files|.fx file format]]
== Links ==
* [https://github.com/WonderfulToolchain/awesome-wsdev awesome-wsdev] - curated documentation/tools/source code link list
== MediaWiki ==
* [https://www.mediawiki.org/wiki/Special:MyLanguage/Help:Contents User's Guide]
* [https://www.mediawiki.org/wiki/Special:MyLanguage/Manual:FAQ MediaWiki FAQ]
* [[:Category:Deletion requests|Deletion requests]]
9da09ba089aedbe1276ae0810927a05d3d5ca58b
88
59
2023-08-22T06:45:25Z
Asie
351
split console and cartridge components
wikitext
text/x-wiki
'''WonderSwan Development Wiki'''
== Reference ==
=== General ===
* [[Memory map]]
* [[I/O port map]]
* [[ROM header]]
* [[NEC V30MZ]] - the WonderSwan CPU (80186-compatible)
* [[Timing]]
=== Console components ===
* [[Display]]
* [[Sound]]
* [[Keypad]]
* [[Timers]]
* [[Interrupts]]
* [[UART]]
* [[EEPROM]]
* [[DMA]] (WonderSwan Color only)
=== Cartridge components ===
* [[Mapper]]
* [[Real-Time Clock]] (2003)
=== Pinouts ===
* [[Accessory port pinout]]
* [[2001 Mapper pinout]]
* [[2003 Mapper pinout]]
* [[KARNAK pinout]]
* [[GIZA pinout]]
* [[S-3511A pinout]]
=== Accessories ===
* [[WonderBeat 9480]] headphone adapter
* [[WonderBorg]] robot
* [[WonderGate]] mobile adapter
* [[WonderWave]] infrared adapter
=== WonderWitch ===
* [[FreyaBIOS]]
* [[WonderWitch .fx files|.fx file format]]
== Links ==
* [https://github.com/WonderfulToolchain/awesome-wsdev awesome-wsdev] - curated documentation/tools/source code link list
== MediaWiki ==
* [https://www.mediawiki.org/wiki/Special:MyLanguage/Help:Contents User's Guide]
* [https://www.mediawiki.org/wiki/Special:MyLanguage/Manual:FAQ MediaWiki FAQ]
* [[:Category:Deletion requests|Deletion requests]]
4454948a05d0f271f33862b49b67d5dadf0eb6fc
KARNAK
0
18
60
2023-08-20T22:27:05Z
Lidnariq
7
create from various sources (include ares's source, scuttlebutt via the discord)
wikitext
text/x-wiki
KARNAK was only used in Pocket Challenge V2 edutainment games.
It is not yet well-documented. It is thought to be a revision of [[Bandai 2003]] that removes the RTC interface, and adds a timer IRQ and a hardware IMA ADPCM decoder.
This page should not be taken as authoritative: it has been pieced together from multiple other pieces of research. It is unclear if the GPO and Self-Flash registers exist; from PCB photos the Self-Flash register is unused if it does exist.
{| class="wikitable"
! Category
! Port
! Description
! Bits
! Type
! Notes
|-
! rowspan="2" | GPO
! $CC
| GPO Data Direction
| style="text-align: right" | <tt style="white-space: nowrap">0000 oooo</tt>
| RW8
| 1 = output, 0 = high-impedance (weak pull-down)
|-
! $CD
| GPO Data
| style="text-align: right" | <tt style="white-space: nowrap">0000 dddd</tt>
| RW8
| 1 = 3V, if enabled by data direction
|-
! Self-Flash
! $CE
| Self-Flash Control
| style="text-align: right" | <tt style="white-space: nowrap">0000 000r</tt>
| RW8
| 1 = ROM is accessible at segment 0x1000;
0 = RAM instead.
|-
! rowspan="4" | Extended bankswitching
! $CF
| ROM Linear (EX) Bank
| style="text-align: right" | <tt style="white-space: nowrap">00bb bbbb</tt>
| RW8
| Selects a 1MiB bank accessed via segments 0x4000 through 0xF000. Identical to the register at 0xC0.
|-
! $D0
| RAM(/ROM) Bank
| style="text-align: right" | <tt style="white-space: nowrap">0000 00bb bbbb bbbb</tt>
| RW16
| Selects a 64KiB bank accessed via segment 0x1000. Lower 8 bits are identical to the register at 0xC1.
|-
! $D2
| ROM0 Bank
| style="text-align: right" | <tt style="white-space: nowrap">0000 00bb bbbb bbbb</tt>
| RW16
| Selects a 64KiB bank accessed via segment 0x2000. Lower 8 bits are identical to the register at 0xC2.
|-
! $D4
| ROM1 Bank
| style="text-align: right" | <tt style="white-space: nowrap">0000 00bb bbbb bbbb</tt>
| RW16
| Selects a 64KiB bank accessed via segment 0x3000. Lower 8 bits are identical to the register at 0xC3.
|-
! Timer
! $D6
| Programmable Interval Timer
| style="text-align: right" | <tt style="white-space: nowrap">eppp pppp</tt>
| RW8
| Enable (e); Period (p). Units are the 384kHz clock to the cartridge.
|-
! rowspan=2|ADPCM
! rowspan=2|$D8
| packed data
| ?
| W8
| Write two-sample packed ADPCM byte
|-
| unpacked data
| ?
| R16
| Read two one-byte unpacked PCM bytes
|}
Not all PCBs are wired to support self-flashing. Not all ROMs have the needed /BYTE pin. Even on PCBs without support, ROM can still be enabled by writing to port $CE.
f17d5a5680696934a02a0480e2abc23a80686500
61
60
2023-08-20T22:54:20Z
Lidnariq
7
remove copypasta
wikitext
text/x-wiki
KARNAK was only used in Pocket Challenge V2 edutainment games.
It is not yet well-documented. It is thought to be a revision of [[Bandai 2003]] that removes the RTC interface, and adds a timer IRQ and a hardware IMA ADPCM decoder.
This page should not be taken as authoritative: it has been pieced together from multiple other pieces of research. It is unclear if the GPO and Self-Flash registers exist; from PCB photos the Self-Flash register is unused if it does exist.
{| class="wikitable"
! Category
! Port
! Description
! Bits
! Type
! Notes
|-
! rowspan="2" | GPO
! $CC
| GPO Data Direction
| style="text-align: right" | <tt style="white-space: nowrap">0000 oooo</tt>
| RW8
| 1 = output, 0 = high-impedance (weak pull-down)
|-
! $CD
| GPO Data
| style="text-align: right" | <tt style="white-space: nowrap">0000 dddd</tt>
| RW8
| 1 = 3V, if enabled by data direction
|-
! Self-Flash
! $CE
| Self-Flash Control
| style="text-align: right" | <tt style="white-space: nowrap">0000 000r</tt>
| RW8
| 1 = ROM is accessible at segment 0x1000;
0 = RAM instead.
|-
! rowspan="4" | Extended bankswitching
! $CF
| ROM Linear (EX) Bank
| style="text-align: right" | <tt style="white-space: nowrap">00bb bbbb</tt>
| RW8
| Selects a 1MiB bank accessed via segments 0x4000 through 0xF000. Identical to the register at 0xC0.
|-
! $D0
| RAM(/ROM) Bank
| style="text-align: right" | <tt style="white-space: nowrap">0000 00bb bbbb bbbb</tt>
| RW16
| Selects a 64KiB bank accessed via segment 0x1000. Lower 8 bits are identical to the register at 0xC1.
|-
! $D2
| ROM0 Bank
| style="text-align: right" | <tt style="white-space: nowrap">0000 00bb bbbb bbbb</tt>
| RW16
| Selects a 64KiB bank accessed via segment 0x2000. Lower 8 bits are identical to the register at 0xC2.
|-
! $D4
| ROM1 Bank
| style="text-align: right" | <tt style="white-space: nowrap">0000 00bb bbbb bbbb</tt>
| RW16
| Selects a 64KiB bank accessed via segment 0x3000. Lower 8 bits are identical to the register at 0xC3.
|-
! Timer
! $D6
| Programmable Interval Timer
| style="text-align: right" | <tt style="white-space: nowrap">eppp pppp</tt>
| RW8
| Enable (e); Period (p). Units are the 384kHz clock to the cartridge.
|-
! rowspan=2|ADPCM
! rowspan=2|$D8
| packed data
| ?
| W8
| Write two-sample packed ADPCM byte
|-
| unpacked data
| ?
| R16
| Read two one-byte unpacked PCM bytes
|}
37a2a7ea75d2f3e5c853a9c861b5dd7149a4b4b6
KARNAK pinout
0
19
62
2023-08-20T23:03:48Z
Lidnariq
7
Half of the pinout is trivially visible by inspection of the PCBs - very close to a 180degree rotation of the 2003.
wikitext
text/x-wiki
[[KARNAK]]: 48-pin 0.5mm pitch TQFP
D7 <> /01 o 48\
D6 <> /02 47\
D5 <> /03 46\
D4 <> /04 45\
D3 <> /05 44\
Gnd -- /06 43\
D2 <> /07 42\
D1 <> /08 41\ -- Gnd
D0 <> /09 40\
A0 -> /10 39\
A1 -> /11 38\
A2 -> /12 KARNAK 37\
A3 -> \13 36/
CPU A19 <- \14 35/
CPU A18 <- \15 34/
CPU A17 -> \16 33/
CPU A16 -> \17 32/ -- Gnd
/RESET -> \18 31/ -- Gnd
/MBC <- \19 30/ -- Gnd
M/IO -> \20 29/ -- Vcc
/RD -> \21 28/
/WR -> \22 27/
/SEL -> \23 26/
/IRQ <- \24 O 25/ <- CLK
Note the orientation of the text: "Karnak" when viewed upright specifies pin 1 is bottom face, leftmost.
a2a6bfeb46e4643eccfdcdebf350f7d45747d151
WonderGate/bplXX.mopera.ne.jp
0
15
65
44
2023-08-21T18:00:46Z
Asie
351
wikitext
text/x-wiki
For the MobileWonderGate software, NTT DoCoMo operated network servers for handling URL requests:
* <code>bpl01.mopera.ne.jp</code>
* <code>bpl02.mopera.ne.jp</code>
These servers listened on TCP port 5555 for request packets in the following format, and issued a response in the same format.
Pages accessed via the mopera network server reported themselves as <code>Mozilla/3.0 (compatible; InfoBridge-mopera 1.1.1; Linux)</code>, as opposed to the browser's own <code>SWAN/1.0</code>.
== Packet format ==
Every packet sent from and to the server follows the same format: a global header, followed by an arbitrary number of blocks with their respective headers.
=== Header ===
{| class="wikitable"
! Offset
! Length
! Description
|-
| 0x00 || 1 || Unknown, always 0x01
|-
| 0x01 || 1 || Header size in bytes, always 0x18
|-
| rowspan="2" | 0x02
| rowspan="2" | 2
| Request type/Browser configuration:
<pre>
ee?i ?s?w ???? ??p?
|| | | | +- POST request
|| | | +---------- Width: 0 = 1-screen, 1 = 2-screen
|| | +------------ Image size: 0 = 50%, 1 = 100%
|| +--------------- Images: 0 = enabled, 1 = disabled
++----------------- Encoding: 0 = auto, 1 = S-JIS, 2 = EUC
</pre>
|-
| Response type:
* 0x0010 - response: allow + 0 blocks
* 0x0012 - response: deny/redirect? + 1 block
* 0x0021 - response: require ID/password + 1 block
* 0x0023 - response: unknown (too large?) + 0 blocks
|-
| 0x04 || 4? (>= 2) || Total packet size in bytes, including all headers and blocks
|-
| 0x08 || 4 || Unknown
|-
| 0x0C || 4 || Unknown
|-
| 0x10 || 4 || Unknown (216.0.192.1?)
|-
| 0x14 || 4 || Unknown (255.255.0.0?)
|}
=== Block header ===
Blocks typically consist of zero-terminated strings - a final zero appears to be omitted.
{| class="wikitable"
! Offset
! Length
! Description
|-
| 0x00 || 2 || Block size in bytes, including header
|-
| 0x02 || 1 || Block type:
* 0x01 - 0x00? byte, followed by requested URL string
* 0x03 - 0x00? byte, followed by previous URL string (referrer?)
* 0x11 - ID string, followed by PASS string
* 0x22 - 0x00? byte, followed by query field name string, followed by query field value string
|}
== TODO ==
* How does one send an HTTP response through the bridge? This has to be possible, as the bridge had its own distinct user agent.
3714bc040fc76cc90a3c50dfe427391ffb6b937f
66
65
2023-08-21T19:51:36Z
Asie
351
initial multipart block documentation
wikitext
text/x-wiki
For the MobileWonderGate software, NTT DoCoMo operated network servers for handling URL requests:
* <code>bpl01.mopera.ne.jp</code>
* <code>bpl02.mopera.ne.jp</code>
These servers listened on TCP port 5555 for request packets in the following format, and issued a response in the same format.
Pages accessed via the mopera network server reported themselves as <code>Mozilla/3.0 (compatible; InfoBridge-mopera 1.1.1; Linux)</code>, as opposed to the browser's own <code>SWAN/1.0</code>.
== Packet format ==
Every packet sent from and to the server follows the same format: a global header, followed by an arbitrary number of blocks with their respective headers.
=== Header ===
{| class="wikitable"
! Offset
! Length
! Description
|-
| 0x00 || 1 || Unknown, always 0x01
|-
| 0x01 || 1 || Header size in bytes, always 0x18
|-
| rowspan="2" | 0x02
| rowspan="2" | 2
| Request type/Browser configuration:
<pre>
ee?i ?s?w ???? ??p?
|| | | | +- POST request
|| | | +---------- Width: 0 = 1-screen, 1 = 2-screen
|| | +------------ Image size: 0 = 50%, 1 = 100%
|| +--------------- Images: 0 = enabled, 1 = disabled
++----------------- Encoding: 0 = auto, 1 = S-JIS, 2 = EUC
</pre>
|-
| Response type:
* 0x0010 - response: allow + 0 blocks
* 0x0012 - response: deny/redirect? + 1 block
* 0x0021 - response: require ID/password + 1 block
* 0x0023 - response: unknown (too large?) + 0 blocks
|-
| 0x04 || 4? (>= 2) || Total packet size in bytes, including all headers and blocks
|-
| 0x08 || 4 || Unknown
|-
| 0x0C || 4 || Unknown
|-
| 0x10 || 4 || Unknown (216.0.192.1?)
|-
| 0x14 || 4 || Unknown (255.255.0.0?)
|}
=== Block header ===
Blocks typically consist of zero-terminated strings - a final zero appears to be omitted.
{| class="wikitable"
! Offset
! Length
! Description
|-
| 0x00 || 2 || Block size in bytes, including header
|-
| 0x02 || 1 || Block type:
* 0x01 - 0x00? byte, followed by requested URL string
* 0x03 - 0x00? byte, followed by previous URL string (referrer?)
* 0x11 - ID string, followed by PASS string
* 0x22 - 0x00? byte, followed by query field name string, followed by query field value string
|}
=== Multipart blocks ===
Sending a block with a block size of `0xFFFF` and a block type of `0x00` in a response will trigger a multipart block mode, which sends data in portions between a header and footer.
{| class="wikitable"
|+ Header
! Offset
! Length
! Description
|-
| 0x00 || 1 || Number of parts?
|-
| 0x01<br/>
0x04
| ?
| Unknown
|}
{| class="wikitable"
|+ Part
! Offset
! Length
! Description
|-
| 0x00<br/>
0x01
| ?
| Unknown
|-
| 0x02
| 2
| Length of data, in bytes
|-
| 0x04<br/>
0x05
| ?
| Unknown
|-
| 0x06...
| <length>
| Data
|}
{| class="wikitable"
|+ Footer
! Offset
! Length
! Description
|-
| 0x00<br/>
0x01
| ?
| Unknown
|}
== TODO ==
* How does one send an HTTP response through the bridge? This has to be possible, as the bridge had its own distinct user agent.
d2f38296538f01a3546331346fea4ac2b5475e56
67
66
2023-08-21T19:51:55Z
Asie
351
wikitext
text/x-wiki
For the MobileWonderGate software, NTT DoCoMo operated network servers for handling URL requests:
* <code>bpl01.mopera.ne.jp</code>
* <code>bpl02.mopera.ne.jp</code>
These servers listened on TCP port 5555 for request packets in the following format, and issued a response in the same format.
Pages accessed via the mopera network server reported themselves as <code>Mozilla/3.0 (compatible; InfoBridge-mopera 1.1.1; Linux)</code>, as opposed to the browser's own <code>SWAN/1.0</code>.
== Packet format ==
Every packet sent from and to the server follows the same format: a global header, followed by an arbitrary number of blocks with their respective headers.
=== Header ===
{| class="wikitable"
! Offset
! Length
! Description
|-
| 0x00 || 1 || Unknown, always 0x01
|-
| 0x01 || 1 || Header size in bytes, always 0x18
|-
| rowspan="2" | 0x02
| rowspan="2" | 2
| Request type/Browser configuration:
<pre>
ee?i ?s?w ???? ??p?
|| | | | +- POST request
|| | | +---------- Width: 0 = 1-screen, 1 = 2-screen
|| | +------------ Image size: 0 = 50%, 1 = 100%
|| +--------------- Images: 0 = enabled, 1 = disabled
++----------------- Encoding: 0 = auto, 1 = S-JIS, 2 = EUC
</pre>
|-
| Response type:
* 0x0010 - response: allow + 0 blocks
* 0x0012 - response: deny/redirect? + 1 block
* 0x0021 - response: require ID/password + 1 block
* 0x0023 - response: unknown (too large?) + 0 blocks
|-
| 0x04 || 4? (>= 2) || Total packet size in bytes, including all headers and blocks
|-
| 0x08 || 4 || Unknown
|-
| 0x0C || 4 || Unknown
|-
| 0x10 || 4 || Unknown (216.0.192.1?)
|-
| 0x14 || 4 || Unknown (255.255.0.0?)
|}
=== Block header ===
Blocks typically consist of zero-terminated strings - a final zero appears to be omitted.
{| class="wikitable"
! Offset
! Length
! Description
|-
| 0x00 || 2 || Block size in bytes, including header
|-
| 0x02 || 1 || Block type:
* 0x01 - 0x00? byte, followed by requested URL string
* 0x03 - 0x00? byte, followed by previous URL string (referrer?)
* 0x11 - ID string, followed by PASS string
* 0x22 - 0x00? byte, followed by query field name string, followed by query field value string
|}
=== Multipart blocks ===
Sending a block with a block size of <code>0xFFFF</code> and a block type of <code>0x00</code> in a response will trigger a multipart block mode, which sends data in portions between a header and footer.
{| class="wikitable"
|+ Header
! Offset
! Length
! Description
|-
| 0x00 || 1 || Number of parts?
|-
| 0x01<br/>
0x04
| ?
| Unknown
|}
{| class="wikitable"
|+ Part
! Offset
! Length
! Description
|-
| 0x00<br/>
0x01
| ?
| Unknown
|-
| 0x02
| 2
| Length of data, in bytes
|-
| 0x04<br/>
0x05
| ?
| Unknown
|-
| 0x06...
| <length>
| Data
|}
{| class="wikitable"
|+ Footer
! Offset
! Length
! Description
|-
| 0x00<br/>
0x01
| ?
| Unknown
|}
== TODO ==
* How does one send an HTTP response through the bridge? This has to be possible, as the bridge had its own distinct user agent.
605e83f6cee5167732e81b68dfb11871ed1c8f27
68
67
2023-08-21T19:53:06Z
Asie
351
wikitext
text/x-wiki
For the MobileWonderGate software, NTT DoCoMo operated network servers for handling URL requests:
* <code>bpl01.mopera.ne.jp</code>
* <code>bpl02.mopera.ne.jp</code>
These servers listened on TCP port 5555 for request packets in the following format, and issued a response in the same format.
Pages accessed via the mopera network server reported themselves as <code>Mozilla/3.0 (compatible; InfoBridge-mopera 1.1.1; Linux)</code>, as opposed to the browser's own <code>SWAN/1.0</code>.
== Packet format ==
Every packet sent from and to the server follows the same format: a global header, followed by an arbitrary number of blocks with their respective headers.
=== Header ===
{| class="wikitable"
! Offset
! Length
! Description
|-
| 0x00 || 1 || Unknown, always 0x01
|-
| 0x01 || 1 || Header size in bytes, always 0x18
|-
| rowspan="2" | 0x02
| rowspan="2" | 2
| Request type/Browser configuration:
<pre>
ee?i ?s?w ???? ??p?
|| | | | +- POST request
|| | | +---------- Width: 0 = 1-screen, 1 = 2-screen
|| | +------------ Image size: 0 = 50%, 1 = 100%
|| +--------------- Images: 0 = enabled, 1 = disabled
++----------------- Encoding: 0 = auto, 1 = S-JIS, 2 = EUC
</pre>
|-
| Response type:
* 0x0010 - response: allow + 0 blocks
* 0x0012 - response: deny/redirect? + 1 block
* 0x0021 - response: require ID/password + 1 block
* 0x0023 - response: unknown (too large?) + 0 blocks
|-
| 0x04 || 4? (>= 2) || Total packet size in bytes, including all headers and blocks
|-
| 0x08<br/>
0x0F|| ? || Unknown
|-
| 0x0C || 4 || Unknown
|-
| 0x10 || 4? || Unknown (216.0.192.1?)
|-
| 0x14 || 4? || Unknown (255.255.0.0?)
|}
=== Block header ===
Blocks typically consist of zero-terminated strings - a final zero appears to be omitted.
{| class="wikitable"
! Offset
! Length
! Description
|-
| 0x00 || 2 || Block size in bytes, including header
|-
| 0x02 || 1 || Block type:
* 0x01 - 0x00? byte, followed by requested URL string
* 0x03 - 0x00? byte, followed by previous URL string (referrer?)
* 0x11 - ID string, followed by PASS string
* 0x22 - 0x00? byte, followed by query field name string, followed by query field value string
|}
=== Multipart blocks ===
Sending a block with a block size of <code>0xFFFF</code> and a block type of <code>0x00</code> in a response will trigger a multipart block mode, which sends data in portions between a header and footer.
{| class="wikitable"
|+ Header
! Offset
! Length
! Description
|-
| 0x00 || 1 || Number of parts?
|-
| 0x01<br/>
0x04
| ?
| Unknown
|}
{| class="wikitable"
|+ Part
! Offset
! Length
! Description
|-
| 0x00<br/>
0x01
| ?
| Unknown
|-
| 0x02
| 2
| Length of data, in bytes
|-
| 0x04<br/>
0x05
| ?
| Unknown
|-
| 0x06...
| <length>
| Data
|}
{| class="wikitable"
|+ Footer
! Offset
! Length
! Description
|-
| 0x00<br/>
0x01
| ?
| Unknown
|}
== TODO ==
* How does one send an HTTP response through the bridge? This has to be possible, as the bridge had its own distinct user agent.
8fb089c205f3707ffd44c4bdfa3b6eeeea7a1b49
69
68
2023-08-21T19:53:16Z
Asie
351
wikitext
text/x-wiki
For the MobileWonderGate software, NTT DoCoMo operated network servers for handling URL requests:
* <code>bpl01.mopera.ne.jp</code>
* <code>bpl02.mopera.ne.jp</code>
These servers listened on TCP port 5555 for request packets in the following format, and issued a response in the same format.
Pages accessed via the mopera network server reported themselves as <code>Mozilla/3.0 (compatible; InfoBridge-mopera 1.1.1; Linux)</code>, as opposed to the browser's own <code>SWAN/1.0</code>.
== Packet format ==
Every packet sent from and to the server follows the same format: a global header, followed by an arbitrary number of blocks with their respective headers.
=== Header ===
{| class="wikitable"
! Offset
! Length
! Description
|-
| 0x00 || 1 || Unknown, always 0x01
|-
| 0x01 || 1 || Header size in bytes, always 0x18
|-
| rowspan="2" | 0x02
| rowspan="2" | 2
| Request type/Browser configuration:
<pre>
ee?i ?s?w ???? ??p?
|| | | | +- POST request
|| | | +---------- Width: 0 = 1-screen, 1 = 2-screen
|| | +------------ Image size: 0 = 50%, 1 = 100%
|| +--------------- Images: 0 = enabled, 1 = disabled
++----------------- Encoding: 0 = auto, 1 = S-JIS, 2 = EUC
</pre>
|-
| Response type:
* 0x0010 - response: allow + 0 blocks
* 0x0012 - response: deny/redirect? + 1 block
* 0x0021 - response: require ID/password + 1 block
* 0x0023 - response: unknown (too large?) + 0 blocks
|-
| 0x04 || 4? (>= 2) || Total packet size in bytes, including all headers and blocks
|-
| 0x08<br/>
0x0F
| ?
| Unknown
|-
| 0x0C || 4 || Unknown
|-
| 0x10 || 4? || Unknown (216.0.192.1?)
|-
| 0x14 || 4? || Unknown (255.255.0.0?)
|}
=== Block header ===
Blocks typically consist of zero-terminated strings - a final zero appears to be omitted.
{| class="wikitable"
! Offset
! Length
! Description
|-
| 0x00 || 2 || Block size in bytes, including header
|-
| 0x02 || 1 || Block type:
* 0x01 - 0x00? byte, followed by requested URL string
* 0x03 - 0x00? byte, followed by previous URL string (referrer?)
* 0x11 - ID string, followed by PASS string
* 0x22 - 0x00? byte, followed by query field name string, followed by query field value string
|}
=== Multipart blocks ===
Sending a block with a block size of <code>0xFFFF</code> and a block type of <code>0x00</code> in a response will trigger a multipart block mode, which sends data in portions between a header and footer.
{| class="wikitable"
|+ Header
! Offset
! Length
! Description
|-
| 0x00 || 1 || Number of parts?
|-
| 0x01<br/>
0x04
| ?
| Unknown
|}
{| class="wikitable"
|+ Part
! Offset
! Length
! Description
|-
| 0x00<br/>
0x01
| ?
| Unknown
|-
| 0x02
| 2
| Length of data, in bytes
|-
| 0x04<br/>
0x05
| ?
| Unknown
|-
| 0x06...
| <length>
| Data
|}
{| class="wikitable"
|+ Footer
! Offset
! Length
! Description
|-
| 0x00<br/>
0x01
| ?
| Unknown
|}
== TODO ==
* How does one send an HTTP response through the bridge? This has to be possible, as the bridge had its own distinct user agent.
be6c3df9a1c4bd7b30d2306be8246328fda91e63
70
69
2023-08-21T19:53:46Z
Asie
351
wikitext
text/x-wiki
For the MobileWonderGate software, NTT DoCoMo operated network servers for handling URL requests:
* <code>bpl01.mopera.ne.jp</code>
* <code>bpl02.mopera.ne.jp</code>
These servers listened on TCP port 5555 for request packets in the following format, and issued a response in the same format.
Pages accessed via the mopera network server reported themselves as <code>Mozilla/3.0 (compatible; InfoBridge-mopera 1.1.1; Linux)</code>, as opposed to the browser's own <code>SWAN/1.0</code>.
== Packet format ==
Every packet sent from and to the server follows the same format: a global header, followed by an arbitrary number of blocks with their respective headers.
=== Header ===
{| class="wikitable"
! Offset
! Length
! Description
|-
| 0x00 || 1 || Unknown, always 0x01
|-
| 0x01 || 1 || Header size in bytes, always 0x18
|-
| rowspan="2" | 0x02
| rowspan="2" | 2
| Request type/Browser configuration:
<pre>
ee?i ?s?w ???? ??p?
|| | | | +- POST request
|| | | +---------- Width: 0 = 1-screen, 1 = 2-screen
|| | +------------ Image size: 0 = 50%, 1 = 100%
|| +--------------- Images: 0 = enabled, 1 = disabled
++----------------- Encoding: 0 = auto, 1 = S-JIS, 2 = EUC
</pre>
|-
| Response type:
* 0x0010 - response: allow + 0 blocks
* 0x0012 - response: deny/redirect? + 1 block
* 0x0021 - response: require ID/password + 1 block
* 0x0023 - response: unknown (too large?) + 0 blocks
|-
| 0x04 || 4? (>= 2) || Total packet size in bytes, including all headers and blocks
|-
| 0x08<br/>
0x0F
| ?
| Unknown
|-
| 0x10 || 4? || Unknown (216.0.192.1?)
|-
| 0x14 || 4? || Unknown (255.255.0.0?)
|}
=== Block header ===
Blocks typically consist of zero-terminated strings - a final zero appears to be omitted.
{| class="wikitable"
! Offset
! Length
! Description
|-
| 0x00 || 2 || Block size in bytes, including header
|-
| 0x02 || 1 || Block type:
* 0x01 - 0x00? byte, followed by requested URL string
* 0x03 - 0x00? byte, followed by previous URL string (referrer?)
* 0x11 - ID string, followed by PASS string
* 0x22 - 0x00? byte, followed by query field name string, followed by query field value string
|}
=== Multipart blocks ===
Sending a block with a block size of <code>0xFFFF</code> and a block type of <code>0x00</code> in a response will trigger a multipart block mode, which sends data in portions between a header and footer.
{| class="wikitable"
|+ Header
! Offset
! Length
! Description
|-
| 0x00 || 1 || Number of parts?
|-
| 0x01<br/>
0x04
| ?
| Unknown
|}
{| class="wikitable"
|+ Part
! Offset
! Length
! Description
|-
| 0x00<br/>
0x01
| ?
| Unknown
|-
| 0x02
| 2
| Length of data, in bytes
|-
| 0x04<br/>
0x05
| ?
| Unknown
|-
| 0x06...
| <length>
| Data
|}
{| class="wikitable"
|+ Footer
! Offset
! Length
! Description
|-
| 0x00<br/>
0x01
| ?
| Unknown
|}
== TODO ==
* How does one send an HTTP response through the bridge? This has to be possible, as the bridge had its own distinct user agent.
54b72402dad3213bdc0886dc7b7f898d92f733c3
96
70
2023-08-22T08:29:16Z
Asie
351
wikitext
text/x-wiki
For the MobileWonderGate software, NTT DoCoMo operated network servers for handling URL requests:
* <code>bpl01.mopera.ne.jp</code>
* <code>bpl02.mopera.ne.jp</code>
These servers listened on TCP port 5555 for request packets in the following format, and issued a response in the same format.
Pages accessed via the mopera network server reported themselves as <code>Mozilla/3.0 (compatible; InfoBridge-mopera 1.1.1; Linux)</code>, as opposed to the browser's own <code>SWAN/1.0</code>.
== Packet format ==
Every packet sent from and to the server follows the same format: a global header, followed by an arbitrary number of blocks with their respective headers.
=== Header ===
{| class="wikitable"
! Offset
! Length
! Description
|-
| 0x00 || 1 || Unknown, always 0x01
|-
| 0x01 || 1 || Header size in bytes, always 0x18
|-
| rowspan="2" | 0x02
| rowspan="2" | 2
| Request type/Browser configuration:
<pre>
ee?i ?s?w ???? ??p?
|| | | | +- POST request
|| | | +---------- Width: 0 = 1-screen, 1 = 2-screen
|| | +------------ Image size: 0 = 50%, 1 = 100%
|| +--------------- Images: 0 = enabled, 1 = disabled
++----------------- Encoding: 0 = auto, 1 = S-JIS, 2 = EUC
</pre>
|-
| Response type:
* 0x0010 - response: allow + 0 blocks
* 0x0012 - response: deny/redirect? + 1 block
* 0x0021 - response: require ID/password + 1 block
* 0x0023 - response: unknown (too large?) + 0 blocks
|-
| 0x04 || 4? (>= 2) || Total packet size in bytes, including all headers and blocks
|-
| 0x08<br/>
0x0F
| ?
| Unknown
|-
| 0x10 || 4? || Unknown (216.0.192.1?)
|-
| 0x14 || 4? || Unknown (255.255.0.0?)
|}
=== Block header ===
Blocks typically consist of zero-terminated strings - a final zero appears to be omitted.
{| class="wikitable"
! Offset
! Length
! Description
|-
| 0x00 || 2 || Block size in bytes, including header
|-
| 0x02 || 1 || Block type:
* 0x01 - 0x00? byte, followed by requested URL string
* 0x03 - 0x00? byte, followed by previous URL string (referrer?)
* 0x11 - ID string, followed by PASS string
* 0x22 - 0x00? byte, followed by query field name string, followed by query field value string
|}
=== Multipart blocks ===
Sending a block with a block size of <code>0xFFFF</code> and a block type of <code>0x00</code> in a response will trigger a multipart block mode, which sends data in portions between a header and footer.
While the <code>0xFFFF/0x00</code> preamble has to be included in the total length from the global header, the remainder of the multipart block section does not have to be.
{| class="wikitable"
|+ Header
! Offset
! Length
! Description
|-
| 0x00 || 1 || Number of parts?
|-
| 0x01<br/>
0x04
| ?
| Unknown
|}
{| class="wikitable"
|+ Part
! Offset
! Length
! Description
|-
| 0x00<br/>
0x01
| ?
| Unknown
|-
| 0x02
| 2
| Length of data, in bytes
|-
| 0x04<br/>
0x05
| ?
| Unknown
|-
| 0x06...
| <length>
| Data
|}
{| class="wikitable"
|+ Footer
! Offset
! Length
! Description
|-
| 0x00<br/>
0x01
| ?
| Unknown
|}
== TODO ==
* How does one send an HTTP response through the bridge? This has to be possible, as the bridge had its own distinct user agent.
938f10788d5e5b95e61e8785c71782af96a6ed15
GIZA pinout
0
20
71
2023-08-21T20:01:38Z
Lidnariq
7
Created page with "GIZA: 8-pin 0.05"-pitch SOP Vbat -> | 1 8 | <- Vconsole Vups <- | 2 7 | ?? nc Gnd -- | 3 6 | <- /RESET /CSin -> | 4 5 | -> /CSout A 10kΩ resistor is placed between the coin cell and Vbat. GIZA is a standard battery monitor and supervisor, similar to the MM1026."
wikitext
text/x-wiki
GIZA: 8-pin 0.05"-pitch SOP
Vbat -> | 1 8 | <- Vconsole
Vups <- | 2 7 | ?? nc
Gnd -- | 3 6 | <- /RESET
/CSin -> | 4 5 | -> /CSout
A 10kΩ resistor is placed between the coin cell and Vbat.
GIZA is a standard battery monitor and supervisor, similar to the MM1026.
8a143bb0fc41414647f982965df68ee55fcb9f1a
S-3511A pinout
0
21
72
2023-08-21T20:05:15Z
Lidnariq
7
from the datasheet
wikitext
text/x-wiki
Seiko Instruments Inc. S-3511A: 8-pin 0.65mm-pitch SSOP
/INT <- | 1 8 | -- Vdd
XIN -> | 2 7 | <> SIO
XOUT <- | 3 6 | <- /SCK (falling edges)
Gnd -- | 4 5 | <- +CS
40d57970f56b982b805f0d51ccacb00b2d0599c7
Interrupts
0
22
76
2023-08-22T05:31:06Z
Asie
351
Created page with "The WonderSwan features fourteen different interrupts: * CPU interrupts - six provided by the V30MZ CPU ($00-$05), * Hardware interrupts - eight provided by the SoC's hardware ($00-$07, or $08-$0F, or $10-$1F, or ... $F8-$FF - controlled by an offset <code>V</code>): ** Level - will be reissued so long as the prerequisite condition is raised or the interrupt is disabled, ** Edge - will only be issued once; acknowledging the interrupt prevents reissuing until the conditi..."
wikitext
text/x-wiki
The WonderSwan features fourteen different interrupts:
* CPU interrupts - six provided by the V30MZ CPU ($00-$05),
* Hardware interrupts - eight provided by the SoC's hardware ($00-$07, or $08-$0F, or $10-$1F, or ... $F8-$FF - controlled by an offset <code>V</code>):
** Level - will be reissued so long as the prerequisite condition is raised or the interrupt is disabled,
** Edge - will only be issued once; acknowledging the interrupt prevents reissuing until the condition is toggled again.
The user can additionally define and use any of the 256 interrupt vectors in their own code.
{| class="wikitable"
|+ List of WonderSwan interrupts
! Source
! Type
! Index
! Description
|-
! rowspan="6" | CPU
| rowspan="6" | N/A
| $00
| DIV or IDIV instruction divide error<br/>
(division by zero or result overflow)
|-
| $01
| Single-step (T flag)
|-
| $02
| NMI (non-maskable interrupt)
|-
| $03
| INT 3 opcode
|-
| $04
| INTO opcode (if V = 1)
|-
| $05
| BOUND opcode (if index out of bounds)
|-
! rowspan="8" | Hardware
| Level
| V + 0
| [[UART|UART Send Ready]]
|-
| Edge
| V + 1
| [[Keypad|Key Pressed]]
|-
| rowspan="2" | Level
| V + 2
| [[Cartridge|Cartridge IRQ]]
|-
| V + 3
| [[UART|UART Receive Ready]]
|-
| rowspan="4" | Edge
| V + 4
| [[Display|Display Interrupt Line Match]]
|-
| V + 5
| [[Timers|Vertical Blank Timer]]
|-
| V + 6
| [[Display|Display Vertical Blank]]
|-
| V + 7
| [[Timers|Horizontal Blank Timer]]
|}
== I/O Ports ==
=== Interrupt Vector ===
<pre>
7 bit 0
---- ----
VVVV V...
|||| ||||
++++-++++- Interrupt vector offset
(lowest three bits ignored)
</pre>
=== Interrupt Enable ===
<pre>
7 bit 0
---- ----
iiii iiii
|||| ||||
++++-++++- Hardware interrupt to enable
(acts as a mask)
</pre>
=== Interrupt Status ===
<pre>
7 bit 0
---- ----
iiii iiii
|||| ||||
++++-++++- 1 if interrupt requested
</pre>
=== Interrupt Acknowledge ===
<pre>
7 bit 0
---- ----
iiii iiii
|||| ||||
++++-++++- Write 1 to clear interrupt request
</pre>
=== Interrupt NMI Control ===
<pre>
7 bit 0
---- ----
...b ....
+----- Enable NMI on low battery detection
</pre>
f6f9c7e235996f2478e0edc747943677205d08d3
78
76
2023-08-22T05:33:37Z
Asie
351
wikitext
text/x-wiki
The WonderSwan features fourteen different interrupts:
* CPU interrupts - six provided by the V30MZ CPU ($00-$05),
* Hardware interrupts - eight provided by the SoC's hardware ($00-$07, or $08-$0F, or $10-$1F, or ... $F8-$FF - controlled by an offset <code>V</code>):
** Level - will be constantly requested while the prerequisite condition is true; interruption can only be prevented by resolving the condition or disabling the interrupt;
** Edge - will only be requested when the prerequisite condition ''becomes'' true; acknowledging the interrupt prevents further interruption.
The user can additionally define and use any of the 256 interrupt vectors in their own code.
{| class="wikitable"
|+ List of WonderSwan interrupts
! Source
! Type
! Index
! Description
|-
! rowspan="6" | CPU
| rowspan="6" | N/A
| $00
| DIV or IDIV instruction divide error<br/>
(division by zero or result overflow)
|-
| $01
| Single-step (T flag)
|-
| $02
| NMI (non-maskable interrupt)
|-
| $03
| INT 3 opcode
|-
| $04
| INTO opcode (if V = 1)
|-
| $05
| BOUND opcode (if index out of bounds)
|-
! rowspan="8" | Hardware
| Level
| V + 0
| [[UART|UART Send Ready]]
|-
| Edge
| V + 1
| [[Keypad|Key Pressed]]
|-
| rowspan="2" | Level
| V + 2
| [[Cartridge|Cartridge IRQ]]
|-
| V + 3
| [[UART|UART Receive Ready]]
|-
| rowspan="4" | Edge
| V + 4
| [[Display|Display Interrupt Line Match]]
|-
| V + 5
| [[Timers|Vertical Blank Timer]]
|-
| V + 6
| [[Display|Display Vertical Blank]]
|-
| V + 7
| [[Timers|Horizontal Blank Timer]]
|}
== I/O Ports ==
=== Interrupt Vector ===
<pre>
7 bit 0
---- ----
VVVV V...
|||| ||||
++++-++++- Interrupt vector offset
(lowest three bits ignored)
</pre>
=== Interrupt Enable ===
<pre>
7 bit 0
---- ----
iiii iiii
|||| ||||
++++-++++- Hardware interrupt to enable
(acts as a mask)
</pre>
=== Interrupt Status ===
<pre>
7 bit 0
---- ----
iiii iiii
|||| ||||
++++-++++- 1 if interrupt requested
</pre>
=== Interrupt Acknowledge ===
<pre>
7 bit 0
---- ----
iiii iiii
|||| ||||
++++-++++- Write 1 to clear interrupt request
</pre>
=== Interrupt NMI Control ===
<pre>
7 bit 0
---- ----
...b ....
+----- Enable NMI on low battery detection
</pre>
d06bcd77d4161ed584c09ec810e7524498c8fa72
81
78
2023-08-22T05:43:35Z
Asie
351
wikitext
text/x-wiki
The WonderSwan features fourteen different interrupts:
* CPU interrupts - six provided by the V30MZ CPU ($00-$05),
* Hardware interrupts - eight provided by the SoC's hardware ($00-$07, or $08-$0F, or $10-$1F, or ... $F8-$FF - controlled by an offset <code>V</code>):
** Level - will be constantly requested while the prerequisite condition is true; interruption can only be prevented by resolving the condition or disabling the interrupt;
** Edge - will only be requested when the prerequisite condition ''becomes'' true; acknowledging the interrupt prevents further interruption.
The user can additionally define and use any of the 256 interrupt vectors in their own code.
{| class="wikitable"
|+ List of WonderSwan interrupts
! Source
! Type
! Index
! Description
|-
! rowspan="6" | CPU
| rowspan="6" | N/A
| $00
| DIV or IDIV instruction divide error<br/>
(division by zero or result overflow)
|-
| $01
| Single-step (T flag)
|-
| $02
| NMI (non-maskable interrupt)
|-
| $03
| INT 3 opcode
|-
| $04
| INTO opcode (if V = 1)
|-
| $05
| BOUND opcode (if index out of bounds)
|-
! rowspan="8" | Hardware
| Level
| V + 0
| [[UART|UART Send Ready]]
|-
| Edge
| V + 1
| [[Keypad|Key Pressed]]
|-
| rowspan="2" | Level
| V + 2
| [[Cartridge|Cartridge IRQ]]
|-
| V + 3
| [[UART|UART Receive Ready]]
|-
| rowspan="4" | Edge
| V + 4
| [[Display|Display Interrupt Line Match]]
|-
| V + 5
| [[Timers|Vertical Blank Timer]]
|-
| V + 6
| [[Display|Display Vertical Blank]]
|-
| V + 7
| [[Timers|Horizontal Blank Timer]]
|}
== I/O ports ==
=== Interrupt Vector ===
<pre>
7 bit 0
---- ----
VVVV V...
|||| ||||
++++-++++- Interrupt vector offset
(lowest three bits ignored)
</pre>
=== Interrupt Enable ===
<pre>
7 bit 0
---- ----
iiii iiii
|||| ||||
++++-++++- Hardware interrupt to enable
(acts as a mask)
</pre>
=== Interrupt Status ===
<pre>
7 bit 0
---- ----
iiii iiii
|||| ||||
++++-++++- 1 if interrupt requested
</pre>
=== Interrupt Acknowledge ===
<pre>
7 bit 0
---- ----
iiii iiii
|||| ||||
++++-++++- Write 1 to clear interrupt request
</pre>
=== Interrupt NMI Control ===
<pre>
7 bit 0
---- ----
...b ....
+----- Enable NMI on low battery detection
</pre>
0156bd473b9117bb546a2da5dee79cf9ce3d3619
UART
0
23
80
2023-08-22T05:40:58Z
Asie
351
Created page with "The WonderSwan's EXT port features an UART operating with the following configuration: * 9,600 or 38,400 bps (bauds per second), * 8N1 (8 data bits followed by 1 stop bit, no parity). This allows for an effective maximum transfer speed of ~1066 or ~4266 bytes per second, respectively. The hardware also features a one-byte transmit and receive buffer, which allows for a slight delay in code when handling data to/from the console. == Interrupts == The UART features tw..."
wikitext
text/x-wiki
The WonderSwan's EXT port features an UART operating with the following configuration:
* 9,600 or 38,400 bps (bauds per second),
* 8N1 (8 data bits followed by 1 stop bit, no parity).
This allows for an effective maximum transfer speed of ~1066 or ~4266 bytes per second, respectively.
The hardware also features a one-byte transmit and receive buffer, which allows for a slight delay in code when handling data to/from the console.
== Interrupts ==
The UART features two interrupts:
* UART Send Ready - constantly active while the transmit buffer is empty (Serial Control bit 2),
* UART Receive Ready - constantly active while the receive buffer contains a byte (Serial Control bit 0).
== I/O ports ==
=== Serial Data ===
<pre>
7 bit 0
---- ----
dddd dddd
|||| ||||
++++-++++- Read a byte from the transmit buffer;
Write a byte into the receive buffer.
</pre>
=== Serial Control ===
<pre>
7 bit 0
---- ----
ebO. .tor
||| ||+- 1 if the receive buffer contains a byte
||| |+-- 1 on overrun (receive buffer overflow)
||| +--- 1 if the transmit buffer is empty (can transmit another byte)
||+------- Write 1 to reset overrun
|+-------- UART speed: 0 = 9600 bps, 1 = 38400 bps
+--------- UART enable: 0 = off, 1 = on
</pre>
726d30de1fe86dbec16fbdad08aaffc594f213fa
85
80
2023-08-22T06:07:09Z
Lidnariq
7
forgot start bits in byte rates
wikitext
text/x-wiki
The WonderSwan's EXT port features an UART operating with the following configuration:
* 9,600 or 38,400 bps (bauds per second),
* 8N1 (8 data bits followed by 1 stop bit, no parity).
This allows for an effective maximum transfer speed of 960 or 3840 bytes per second, respectively.
The hardware also features a one-byte transmit and receive buffer, which allows for a slight delay in code when handling data to/from the console.
== Interrupts ==
The UART features two interrupts:
* UART Send Ready - constantly active while the transmit buffer is empty (Serial Control bit 2),
* UART Receive Ready - constantly active while the receive buffer contains a byte (Serial Control bit 0).
== I/O ports ==
=== Serial Data ===
<pre>
7 bit 0
---- ----
dddd dddd
|||| ||||
++++-++++- Read a byte from the transmit buffer;
Write a byte into the receive buffer.
</pre>
=== Serial Control ===
<pre>
7 bit 0
---- ----
ebO. .tor
||| ||+- 1 if the receive buffer contains a byte
||| |+-- 1 on overrun (receive buffer overflow)
||| +--- 1 if the transmit buffer is empty (can transmit another byte)
||+------- Write 1 to reset overrun
|+-------- UART speed: 0 = 9600 bps, 1 = 38400 bps
+--------- UART enable: 0 = off, 1 = on
</pre>
c25a9f9ab210d50c062db28f448bddc3674ac770
Timers
0
24
82
2023-08-22T05:51:08Z
Asie
351
Created page with "The WonderSwan features two timers: * Horizontal Blank Timer - counts down every horizontal blank (256 CPU cycles), * Vertical Blank Timer - counts down every frame. The timers also feature an auto-reload functionality: that is, they can be configured to fire one time or repeat periodically. == Interrupts == Each timer has its own interrupt; it is triggered when the counter would be about to count down to zero, that is when the counter's value is 1 and the timer cond..."
wikitext
text/x-wiki
The WonderSwan features two timers:
* Horizontal Blank Timer - counts down every horizontal blank (256 CPU cycles),
* Vertical Blank Timer - counts down every frame.
The timers also feature an auto-reload functionality: that is, they can be configured to fire one time or repeat periodically.
== Interrupts ==
Each timer has its own interrupt; it is triggered when the counter would be about to count down to zero, that is when the counter's value is 1 and the timer condition occurs.
This leads to a quirk: the timer interrupt will be triggered if the reload value is set to one ''even if the timer countdown is disabled'', so long as the interrupt is enabled.
== I/O Ports ==
=== Timer Control ===
<pre>
7 bit 0
---- ----
.... VvHh
|||+- Horizontal blank timer: Enable countdown.
||+-- Horizontal blank timer: 0: One-shot, 1: Repeat/auto-reload.
|+--- Vertical blank timer: Enable countdown.
+---- Vertical blank timer: 0: One-shot, 1: Repeat/auto-reload.
</pre>
=== Timer Reload ===
Read/write; contains the initial counter value. The Timer Counter port is immediately initialized with this value upon writing. If auto-reload is enabled, the interrupt trigger will re-initialize the Timer Counter port with this value.
=== Timer Counter ===
Read-only; contains the current value of the counter.
Note that if auto-reload is enabled, this will never contain the value zero.
fd967c298363adbd262dc97603dd4fd3f7b857d7
86
82
2023-08-22T06:22:13Z
Asie
351
wikitext
text/x-wiki
The WonderSwan features two timers:
* Horizontal Blank Timer - counts down every horizontal blank (256 CPU cycles),
* Vertical Blank Timer - counts down every vertical blank (beginning of line 144).
The timers also feature an auto-reload functionality: that is, they can be configured to fire one time or repeat periodically.
== Interrupts ==
Each timer has its own interrupt; it is triggered when the counter would be about to count down to zero, that is when the counter's value is 1 and the timer condition occurs.
This leads to a quirk: the timer interrupt will be triggered if the reload value is set to one ''even if the timer countdown is disabled'', so long as the interrupt is enabled.
== I/O Ports ==
=== Timer Control ===
<pre>
7 bit 0
---- ----
.... VvHh
|||+- Horizontal blank timer: Enable countdown.
||+-- Horizontal blank timer: 0: One-shot, 1: Repeat/auto-reload.
|+--- Vertical blank timer: Enable countdown.
+---- Vertical blank timer: 0: One-shot, 1: Repeat/auto-reload.
</pre>
=== Timer Reload ===
Read/write; contains the initial counter value. The Timer Counter port is immediately initialized with this value upon writing. If auto-reload is enabled, the interrupt trigger will re-initialize the Timer Counter port with this value.
=== Timer Counter ===
Read-only; contains the current value of the counter.
Note that if auto-reload is enabled, this will never contain the value zero.
46e7c3f6a0fbc79aa4e6e3304aa04d8b76bd9457
Timing
0
7
84
18
2023-08-22T05:55:12Z
Asie
351
wikitext
text/x-wiki
== Clocks ==
The WonderSwan is clocked with a master clock of approximately 12288000 Hz (= 12.288 MHz).
This clock is split into four internal memory access quadrants, running at 3072000 Hz (= 3.072 MHz) each. Three of those are used by the console in "mono" mode: [[CPU|NEC V30MZ]], [[Display]] and [[Sound]]. On the WonderSwan Color, the fourth quadrant is used to handle color palette reads during display drawing.
Out of those, only the CPU quadrant can access the cartridge bus. It can be additionally configured to use one of two wait states:
* 1 cycle access - an effective bus speed of 3072000 Hz, same as the CPU,
* 3 cycle access - an effective bus speed of 1024000 Hz.
== Display ==
By default, a WonderSwan frame consists of 159 lines, 144 of which are visible. Each line consists of 256 clock cycles, of which 224 are used to draw a pixel at a time. This leads to a total duration of 40704 clock cycles per frame, for an effective default refresh rate of approximately 75.472 Hz.
Vertical blanks are always triggered on line 144; if the display is set to be shorter than 144 lines, vertical blank interrupts will never be triggered.
60be051bf7aff01c78719733d2689cf35c3b09c7
Memory map
0
25
87
2023-08-22T06:44:38Z
Asie
351
Created page with "The WonderSwan's SoC enforces the following memory map layout: {| class="wikitable" |+ WonderSwan SoC linear memory map ! Bus ! colspan="2" | Address range ! Access width ! Access speed ! Read/Write |- | Internal | colspan="2" style="text-align: center;" | 0x00000<br/>0x0FFFF | 16-bit | 1 cycle | RW |- | rowspan="2" | Cartridge | rowspan="2" style="text-align: center;" | 0x10000<br/>0xFFFFF | style="text-align: center;" | 0x10000<br/>0x1FFFF | 8-bit | ??? | RW |- | styl..."
wikitext
text/x-wiki
The WonderSwan's SoC enforces the following memory map layout:
{| class="wikitable"
|+ WonderSwan SoC linear memory map
! Bus
! colspan="2" | Address range
! Access width
! Access speed
! Read/Write
|-
| Internal
| colspan="2" style="text-align: center;" | 0x00000<br/>0x0FFFF
| 16-bit
| 1 cycle
| RW
|-
| rowspan="2" | Cartridge
| rowspan="2" style="text-align: center;" | 0x10000<br/>0xFFFFF
| style="text-align: center;" | 0x10000<br/>0x1FFFF
| 8-bit
| ???
| RW
|-
| style="text-align: center;" | 0x20000<br/>0xFFFFF
| 8/16-bit (configurable)
| 1/3 cycles (configurable)
| R
|}
== Internal ==
The WonderSwan SoC features an unified memory architecture; that is, the CPU, [[Display]] and [[Sound]] components can access the RAM in time divisions of the chip's clock. This allows for a mostly stall-free development experience.
However, a few elements of the memory live at fixed locations.
{| class="wikitable"
|+ WonderSwan SoC internal memory map
! Address
! WonderSwan
! WonderSwan Color (2BPP mode)
! WonderSwan Color (4BPP mode)
|-
| style="text-align: center;" | 0x0000
| colspan="3" style="text-align: center;" | '''Interrupt vectors''' (256 x 32-bit segment:offset address)
|-
| style="text-align: center;" | 0x0400
| colspan="3" style="text-align: center;" | Free RAM
|-
| style="text-align: center;" | 0x2000
| colspan="2" style="text-align: center;" | '''Tile data (bank 0)'''
| style="text-align: center;" | Free RAM
|-
| style="text-align: center;" | 0x4000
| rowspan="6" style="text-align: center;" |
| style="text-align: center;" | '''Tile data (bank 1)'''
| rowspan="2" style="text-align: center;" | '''Tile data (bank 0)'''
|-
| style="text-align: center;" | 0x6000
| rowspan="3" style="text-align: center;" | Free RAM
|-
| style="text-align: center;" | 0x8000
| style="text-align: center;" | '''Tile data (bank 1)'''
|-
| style="text-align: center;" | 0xC000
| style="text-align: center;" | Free RAM
|-
| style="text-align: center;" | 0xFE00
| rowspan="2" colspan="2" style="text-align: center;" | '''Color palette'''
|-
| style="text-align: center;" | 0xFFFF
|}
In addition, some elements can be placed at configurable locations in RAM, but with restrictions:
{| class="wikitable"
|+ WonderSwan SoC internal memory layout limitations
! Type
! Lowest address
! Highest address
! Alignment
|-
| Screen
| style="text-align: center;" | 0x0000
| style="text-align: center;" | 0x3800<br/>0x7800<sup>(color)</sup>
| 0x800 (2048) bytes
|-
| Sprite table
| style="text-align: center;" | 0x0000
| style="text-align: center;" | 0x3E00<br/>0x7E00<sup>(color)</sup>
| 0x200 (512) bytes
|-
| Sound wave table
| style="text-align: center;" | 0x0000
| style="text-align: center;" | 0x3FC0
| 0x40 (64) bytes
|}
== Cartridge ==
The cartridge part of the memory map is fully controlled by the cartridge bus; this is usually subdivided further by a [[Mapper]]. There exists a standard layout common to all official mappers:
{| class="wikitable"
|+ Standard mapper linear memory map
! Address range
! Bank
|-
| style="text-align: center;" | 0x10000<br/>0x1FFFF
| SRAM (or flashable ROM)
|-
| style="text-align: center;" | 0x20000<br/>0x2FFFF
| ROM bank 0
|-
| style="text-align: center;" | 0x30000<br/>0x3FFFF
| ROM bank 1
|-
| style="text-align: center;" | 0x40000<br/>0xFFFFF
| ROM linear (EX) bank
|}
3c01fc9bb6a3b27a0fcea1aa4be4a130254c1bde
89
87
2023-08-22T06:46:04Z
Asie
351
wikitext
text/x-wiki
The WonderSwan's SoC enforces the following memory map layout:
{| class="wikitable"
|+ WonderSwan SoC linear memory map
! Bus
! colspan="2" | Address range
! Access width
! Access speed
! Read/Write
|-
| Internal
| colspan="2" style="text-align: center;" | 0x00000<br/>0x0FFFF
| 16-bit
| 1 cycle
| RW
|-
| rowspan="2" | Cartridge
| rowspan="2" style="text-align: center;" | 0x10000<br/>0xFFFFF
| style="text-align: center;" | 0x10000<br/>0x1FFFF
| 8-bit
| ???
| RW
|-
| style="text-align: center;" | 0x20000<br/>0xFFFFF
| 8/16-bit (configurable)
| 1/3 cycles (configurable)
| R
|}
== Internal ==
The WonderSwan SoC features an unified memory architecture; that is, the CPU, [[Display]] and [[Sound]] components can access the RAM in time divisions of the chip's clock.
This allows for a mostly CPU-stall-free development experience, but restricts memory layouting. First of all, some elements of the memory live at fixed locations:
{| class="wikitable"
|+ WonderSwan SoC internal memory map
! Address
! WonderSwan
! WonderSwan Color (2BPP mode)
! WonderSwan Color (4BPP mode)
|-
| style="text-align: center;" | 0x0000
| colspan="3" style="text-align: center;" | '''Interrupt vectors''' (256 x 32-bit segment:offset address)
|-
| style="text-align: center;" | 0x0400
| colspan="3" style="text-align: center;" | Free RAM
|-
| style="text-align: center;" | 0x2000
| colspan="2" style="text-align: center;" | '''Tile data (bank 0)'''
| style="text-align: center;" | Free RAM
|-
| style="text-align: center;" | 0x4000
| rowspan="6" style="text-align: center;" |
| style="text-align: center;" | '''Tile data (bank 1)'''
| rowspan="2" style="text-align: center;" | '''Tile data (bank 0)'''
|-
| style="text-align: center;" | 0x6000
| rowspan="3" style="text-align: center;" | Free RAM
|-
| style="text-align: center;" | 0x8000
| style="text-align: center;" | '''Tile data (bank 1)'''
|-
| style="text-align: center;" | 0xC000
| style="text-align: center;" | Free RAM
|-
| style="text-align: center;" | 0xFE00
| rowspan="2" colspan="2" style="text-align: center;" | '''Color palette'''
|-
| style="text-align: center;" | 0xFFFF
|}
In addition, some elements can be placed at configurable locations in RAM, but with restrictions:
{| class="wikitable"
|+ WonderSwan SoC internal memory layout limitations
! Type
! Lowest address
! Highest address
! Alignment
|-
| Screen
| style="text-align: center;" | 0x0000
| style="text-align: center;" | 0x3800<br/>0x7800<sup>(color)</sup>
| 0x800 (2048) bytes
|-
| Sprite table
| style="text-align: center;" | 0x0000
| style="text-align: center;" | 0x3E00<br/>0x7E00<sup>(color)</sup>
| 0x200 (512) bytes
|-
| Sound wave table
| style="text-align: center;" | 0x0000
| style="text-align: center;" | 0x3FC0
| 0x40 (64) bytes
|}
== Cartridge ==
The cartridge part of the memory map is fully controlled by the cartridge bus; this is usually subdivided further by a [[Mapper]]. There exists a standard layout common to all official mappers:
{| class="wikitable"
|+ Standard mapper linear memory map
! Address range
! Bank
|-
| style="text-align: center;" | 0x10000<br/>0x1FFFF
| SRAM (or flashable ROM)
|-
| style="text-align: center;" | 0x20000<br/>0x2FFFF
| ROM bank 0
|-
| style="text-align: center;" | 0x30000<br/>0x3FFFF
| ROM bank 1
|-
| style="text-align: center;" | 0x40000<br/>0xFFFFF
| ROM linear (EX) bank
|}
8a0fc33423fcca5e8da906128ced94c41024823b
90
89
2023-08-22T06:46:37Z
Asie
351
wikitext
text/x-wiki
The WonderSwan's SoC enforces the following memory map layout:
{| class="wikitable"
|+ WonderSwan SoC linear memory map
! Bus
! colspan="2" | Address range
! Access width
! Access speed
! Read/Write
|-
| Internal
| colspan="2" style="text-align: center;" | 0x00000<br/>0x0FFFF
| 16-bit
| 1 cycle
| RW
|-
| rowspan="2" | Cartridge
| rowspan="2" style="text-align: center;" | 0x10000<br/>0xFFFFF
| style="text-align: center;" | 0x10000<br/>0x1FFFF
| 8-bit
| ???
| RW
|-
| style="text-align: center;" | 0x20000<br/>0xFFFFF
| 8/16-bit (configurable)
| 1/3 cycles (configurable)
| R
|}
== Internal ==
The WonderSwan SoC features an unified memory architecture; that is, the CPU, [[Display]] and [[Sound]] components can access the RAM in time divisions of the chip's clock.
This allows for a mostly CPU-stall-free development experience, but restricts memory layouting. First of all, some elements of the memory live at fixed locations:
{| class="wikitable"
|+ WonderSwan SoC internal memory map
! Address
! WonderSwan
! WonderSwan Color (2BPP mode)
! WonderSwan Color (4BPP mode)
|-
| style="text-align: center;" | 0x0000
| colspan="3" style="text-align: center;" | '''Interrupt vectors''' (256 x 32-bit segment:offset address)
|-
| style="text-align: center;" | 0x0400
| colspan="3" style="text-align: center;" | Free RAM
|-
| style="text-align: center;" | 0x2000
| colspan="2" style="text-align: center;" | '''Tile data (bank 0)'''
| style="text-align: center;" | Free RAM
|-
| style="text-align: center;" | 0x4000
| rowspan="6" style="text-align: center;" |
| style="text-align: center;" | '''Tile data (bank 1)'''
| rowspan="2" style="text-align: center;" | '''Tile data (bank 0)'''
|-
| style="text-align: center;" | 0x6000
| rowspan="2" style="text-align: center;" | Free RAM
|-
| style="text-align: center;" | 0x8000
| style="text-align: center;" | '''Tile data (bank 1)'''
|-
| style="text-align: center;" | 0xC000
| colspan="2" style="text-align: center;" | Free RAM
|-
| style="text-align: center;" | 0xFE00
| rowspan="2" colspan="2" style="text-align: center;" | '''Color palette'''
|-
| style="text-align: center;" | 0xFFFF
|}
In addition, some elements can be placed at configurable locations in RAM, but with restrictions:
{| class="wikitable"
|+ WonderSwan SoC internal memory layout limitations
! Type
! Lowest address
! Highest address
! Alignment
|-
| Screen
| style="text-align: center;" | 0x0000
| style="text-align: center;" | 0x3800<br/>0x7800<sup>(color)</sup>
| 0x800 (2048) bytes
|-
| Sprite table
| style="text-align: center;" | 0x0000
| style="text-align: center;" | 0x3E00<br/>0x7E00<sup>(color)</sup>
| 0x200 (512) bytes
|-
| Sound wave table
| style="text-align: center;" | 0x0000
| style="text-align: center;" | 0x3FC0
| 0x40 (64) bytes
|}
== Cartridge ==
The cartridge part of the memory map is fully controlled by the cartridge bus; this is usually subdivided further by a [[Mapper]]. There exists a standard layout common to all official mappers:
{| class="wikitable"
|+ Standard mapper linear memory map
! Address range
! Bank
|-
| style="text-align: center;" | 0x10000<br/>0x1FFFF
| SRAM (or flashable ROM)
|-
| style="text-align: center;" | 0x20000<br/>0x2FFFF
| ROM bank 0
|-
| style="text-align: center;" | 0x30000<br/>0x3FFFF
| ROM bank 1
|-
| style="text-align: center;" | 0x40000<br/>0xFFFFF
| ROM linear (EX) bank
|}
2566d8299bf41085570e23e59bc810bd2c85e464
91
90
2023-08-22T06:46:57Z
Asie
351
wikitext
text/x-wiki
The WonderSwan's SoC enforces the following memory map layout:
{| class="wikitable"
|+ WonderSwan SoC linear memory map
! Bus
! colspan="2" | Address range
! Access width
! Access speed
! Read/Write
|-
| Internal
| colspan="2" style="text-align: center;" | 0x00000<br/>0x0FFFF
| 16-bit
| 1 cycle
| RW
|-
| rowspan="2" | Cartridge
| rowspan="2" style="text-align: center;" | 0x10000<br/>0xFFFFF
| style="text-align: center;" | 0x10000<br/>0x1FFFF
| 8-bit
| ???
| RW
|-
| style="text-align: center;" | 0x20000<br/>0xFFFFF
| 8/16-bit (configurable)
| 1/3 cycles (configurable)
| R
|}
== Internal ==
The WonderSwan SoC features an unified memory architecture; that is, the CPU, [[Display]] and [[Sound]] components can access the RAM in time divisions of the chip's clock.
This allows for a mostly CPU-stall-free development experience, but restricts memory layouting. First of all, some elements of the memory live at fixed locations:
{| class="wikitable"
|+ WonderSwan SoC internal memory map
! Address
! WonderSwan
! WonderSwan Color (2BPP mode)
! WonderSwan Color (4BPP mode)
|-
| style="text-align: center;" | 0x0000
| colspan="3" style="text-align: center;" | '''Interrupt vectors''' (256 x 32-bit segment:offset address)
|-
| style="text-align: center;" | 0x0400
| colspan="3" style="text-align: center;" | Free RAM
|-
| style="text-align: center;" | 0x2000
| colspan="2" style="text-align: center;" | '''Tile data (bank 0)'''
| style="text-align: center;" | Free RAM
|-
| style="text-align: center;" | 0x4000
! rowspan="6" style="text-align: center;" |
| style="text-align: center;" | '''Tile data (bank 1)'''
| rowspan="2" style="text-align: center;" | '''Tile data (bank 0)'''
|-
| style="text-align: center;" | 0x6000
| rowspan="2" style="text-align: center;" | Free RAM
|-
| style="text-align: center;" | 0x8000
| style="text-align: center;" | '''Tile data (bank 1)'''
|-
| style="text-align: center;" | 0xC000
| colspan="2" style="text-align: center;" | Free RAM
|-
| style="text-align: center;" | 0xFE00
| rowspan="2" colspan="2" style="text-align: center;" | '''Color palette'''
|-
| style="text-align: center;" | 0xFFFF
|}
In addition, some elements can be placed at configurable locations in RAM, but with restrictions:
{| class="wikitable"
|+ WonderSwan SoC internal memory layout limitations
! Type
! Lowest address
! Highest address
! Alignment
|-
| Screen
| style="text-align: center;" | 0x0000
| style="text-align: center;" | 0x3800<br/>0x7800<sup>(color)</sup>
| 0x800 (2048) bytes
|-
| Sprite table
| style="text-align: center;" | 0x0000
| style="text-align: center;" | 0x3E00<br/>0x7E00<sup>(color)</sup>
| 0x200 (512) bytes
|-
| Sound wave table
| style="text-align: center;" | 0x0000
| style="text-align: center;" | 0x3FC0
| 0x40 (64) bytes
|}
== Cartridge ==
The cartridge part of the memory map is fully controlled by the cartridge bus; this is usually subdivided further by a [[Mapper]]. There exists a standard layout common to all official mappers:
{| class="wikitable"
|+ Standard mapper linear memory map
! Address range
! Bank
|-
| style="text-align: center;" | 0x10000<br/>0x1FFFF
| SRAM (or flashable ROM)
|-
| style="text-align: center;" | 0x20000<br/>0x2FFFF
| ROM bank 0
|-
| style="text-align: center;" | 0x30000<br/>0x3FFFF
| ROM bank 1
|-
| style="text-align: center;" | 0x40000<br/>0xFFFFF
| ROM linear (EX) bank
|}
c310c2adf5fa5213afd4f94023c3013547037247
92
91
2023-08-22T06:47:56Z
Asie
351
wikitext
text/x-wiki
The WonderSwan's SoC enforces the following memory map layout:
{| class="wikitable"
|+ WonderSwan SoC linear memory map
! Bus
! colspan="2" | Address range
! Access width
! Access speed
! Read/Write
|-
| Internal
| colspan="2" style="text-align: center;" | 0x00000<br/>0x0FFFF
| 16-bit
| 1 cycle
| RW
|-
| rowspan="2" | Cartridge
| rowspan="2" style="text-align: center;" | 0x10000<br/>0xFFFFF
| style="text-align: center;" | 0x10000<br/>0x1FFFF
| 8-bit
| ???
| RW
|-
| style="text-align: center;" | 0x20000<br/>0xFFFFF
| 8/16-bit (configurable)
| 1/3 cycles (configurable)
| R
|}
== Internal ==
The WonderSwan SoC features an unified memory architecture; that is, the CPU, [[Display]] and [[Sound]] components can access the RAM in time divisions of the chip's clock.
This allows for a mostly CPU-stall-free development experience, but restricts memory layouting. First of all, some elements of the memory live at fixed locations:
{| class="wikitable"
|+ WonderSwan SoC internal memory map
! Address
! WonderSwan
! WonderSwan Color (2BPP mode)
! WonderSwan Color (4BPP mode)
|-
| style="text-align: center;" | 0x0000
| colspan="3" style="text-align: center;" | '''Interrupt vectors''' (256 x 32-bit segment:offset address)
|-
| style="text-align: center;" | 0x0400
| colspan="3" style="text-align: center;" | Free RAM
|-
| style="text-align: center;" | 0x2000
| colspan="2" style="text-align: center;" | '''Tile data (bank 0)'''
| style="text-align: center;" | Free RAM
|-
| style="text-align: center;" | 0x4000
! rowspan="6" style="text-align: center;" |
| style="text-align: center;" | '''Tile data (bank 1)'''
| rowspan="2" style="text-align: center;" | '''Tile data (bank 0)'''
|-
| style="text-align: center;" | 0x6000
| rowspan="2" style="text-align: center;" | Free RAM
|-
| style="text-align: center;" | 0x8000
| style="text-align: center;" | '''Tile data (bank 1)'''
|-
| style="text-align: center;" | 0xC000
| colspan="2" style="text-align: center;" | Free RAM
|-
| style="text-align: center;" | 0xFE00
| rowspan="2" colspan="2" style="text-align: center;" | '''Color palette'''
|-
| style="text-align: center;" | 0xFFFF
|}
In addition, some elements can be placed at configurable locations in RAM, but with restrictions:
{| class="wikitable"
|+ WonderSwan SoC internal memory layout limitations
! Type
! Lowest address
! Highest address
! Alignment
|-
| Screen
| style="text-align: center;" | 0x0000
| style="text-align: center;" | 0x3800<br/>0x7800<sup>(color)</sup>
| 0x800 (2048) bytes
|-
| Sprite table
| style="text-align: center;" | 0x0000
| style="text-align: center;" | 0x3E00<br/>0x7E00<sup>(color)</sup>
| 0x200 (512) bytes
|-
| Sound wave table
| style="text-align: center;" | 0x0000
| style="text-align: center;" | 0x3FC0
| 0x40 (64) bytes
|}
Remember that just because an element exists in memory, it doesn't have to be fully utilized; for example, it is common for a WonderSwan game to only reserve sixteen out of the 256 vectors, reusing the remaining 240 as general RAM space.
== Cartridge ==
The cartridge part of the memory map is fully controlled by the cartridge bus; this is usually subdivided further by a [[Mapper]]. There exists a standard layout common to all official mappers:
{| class="wikitable"
|+ Standard mapper linear memory map
! Address range
! Bank
|-
| style="text-align: center;" | 0x10000<br/>0x1FFFF
| SRAM (or flashable ROM)
|-
| style="text-align: center;" | 0x20000<br/>0x2FFFF
| ROM bank 0
|-
| style="text-align: center;" | 0x30000<br/>0x3FFFF
| ROM bank 1
|-
| style="text-align: center;" | 0x40000<br/>0xFFFFF
| ROM linear (EX) bank
|}
cd3314691954b040e8b554f89108be8b9af5aa78
93
92
2023-08-22T06:48:11Z
Asie
351
wikitext
text/x-wiki
The WonderSwan's SoC enforces the following memory map layout:
{| class="wikitable"
|+ WonderSwan SoC linear memory map
! Bus
! colspan="2" | Address range
! Access width
! Access speed
! Read/Write
|-
| Internal
| colspan="2" style="text-align: center;" | 0x00000<br/>0x0FFFF
| 16-bit
| 1 cycle
| RW
|-
| rowspan="2" | Cartridge
| rowspan="2" style="text-align: center;" | 0x10000<br/>0xFFFFF
| style="text-align: center;" | 0x10000<br/>0x1FFFF
| 8-bit
| ???
| RW
|-
| style="text-align: center;" | 0x20000<br/>0xFFFFF
| 8/16-bit (configurable)
| 1/3 cycles (configurable)
| R
|}
== Internal ==
The WonderSwan SoC features an unified memory architecture; that is, the CPU, [[Display]] and [[Sound]] components can access the RAM in time divisions of the chip's clock.
This allows for a mostly CPU-stall-free development experience, but restricts memory layouting. First of all, some elements of the memory live at fixed locations:
{| class="wikitable"
|+ WonderSwan SoC internal memory map
! Address
! WonderSwan
! WonderSwan Color (2BPP mode)
! WonderSwan Color (4BPP mode)
|-
| style="text-align: center;" | 0x0000
| colspan="3" style="text-align: center;" | '''Interrupt vectors''' (256 x 32-bit segment:offset address)
|-
| style="text-align: center;" | 0x0400
| colspan="3" style="text-align: center;" | Free RAM
|-
| style="text-align: center;" | 0x2000
| colspan="2" style="text-align: center;" | '''Tile data (bank 0)'''
| style="text-align: center;" | Free RAM
|-
| style="text-align: center;" | 0x4000
! rowspan="6" style="text-align: center;" |
| style="text-align: center;" | '''Tile data (bank 1)'''
| rowspan="2" style="text-align: center;" | '''Tile data (bank 0)'''
|-
| style="text-align: center;" | 0x6000
| rowspan="2" style="text-align: center;" | Free RAM
|-
| style="text-align: center;" | 0x8000
| style="text-align: center;" | '''Tile data (bank 1)'''
|-
| style="text-align: center;" | 0xC000
| colspan="2" style="text-align: center;" | Free RAM
|-
| style="text-align: center;" | 0xFE00
| rowspan="2" colspan="2" style="text-align: center;" | '''Color palette'''
|-
| style="text-align: center;" | 0xFFFF
|}
In addition, some elements can be placed at configurable locations in RAM, but with restrictions:
{| class="wikitable"
|+ WonderSwan SoC internal memory layout limitations
! Type
! Lowest address
! Highest address
! Alignment
|-
| Screen
| style="text-align: center;" | 0x0000
| style="text-align: center;" | 0x3800<br/>0x7800<sup>(color)</sup>
| 0x800 (2048) bytes
|-
| Sprite table
| style="text-align: center;" | 0x0000
| style="text-align: center;" | 0x3E00<br/>0x7E00<sup>(color)</sup>
| 0x200 (512) bytes
|-
| Sound wave table
| style="text-align: center;" | 0x0000
| style="text-align: center;" | 0x3FC0
| 0x40 (64) bytes
|}
Remember that just because an element exists in memory, it doesn't have to be fully utilized; for example, it is common for a WonderSwan game to only reserve sixteen out of the 256 interrupt vectors, reusing the remaining 240 as general RAM space.
== Cartridge ==
The cartridge part of the memory map is fully controlled by the cartridge bus; this is usually subdivided further by a [[Mapper]]. There exists a standard layout common to all official mappers:
{| class="wikitable"
|+ Standard mapper linear memory map
! Address range
! Bank
|-
| style="text-align: center;" | 0x10000<br/>0x1FFFF
| SRAM (or flashable ROM)
|-
| style="text-align: center;" | 0x20000<br/>0x2FFFF
| ROM bank 0
|-
| style="text-align: center;" | 0x30000<br/>0x3FFFF
| ROM bank 1
|-
| style="text-align: center;" | 0x40000<br/>0xFFFFF
| ROM linear (EX) bank
|}
868c10ecec1911bae1a1b05132c9e31d5f2a4e10
Display
0
26
94
2023-08-22T08:16:33Z
Asie
351
initial page
wikitext
text/x-wiki
The WonderSwan's display functionality generally consists of:
* a 224x144 display clocked at ~75.47 Hz by default, capable of displaying:
** up to sixteen distinct shades of gray
** 12-bit RGB444 color<sup>(color)</sup>
* two 32x32 background layers ("screens"), capable of displaying up to 512 (1024<sup>(color)</sup>) distinct tiles,
* a sprite layer, capable of displaying up to 128 8x8 sprites (up to 32 per line),
* six LCD icons to the bottom or right of the display, usable as additional indicators.
== Components ==
=== Tiles ===
The "mono" WonderSwan can display up to 512 tiles stored in a planar format, with two bits total per pixel.
The planes are interleaved with each other; that is, two consecutive bytes form a full 8x1 row of the tile:
<pre>
plane 0 plane 1
byte N byte N+1
7 bit 0 7 bit 0 full tile
---- ---- ---- ----
.... ...1 .222 22.. .22222.1
.... ...1 2222 22.. 222222.1
.... .... 22.. .... 22......
...1 1... 22.2 2... --\ 22.33...
...1 1... 22.2 2... --/ 22.33...
.... .... 22.. .... 22......
.... .... .... .... ........
11.. .... .... .... 11......
</pre>
The WonderSwan Color extends this with an additional 512 tiles (available for screens only, not sprites) and support for three new modes.
* The first new mode is another two bit per pixel mode, but using color palettes instead of monochrome shades.
The latter two modes extend tiles to four bits per pixel.
* The first among them is the planar mode, which works similarly to the two bit per pixel mode:
<pre>
plane 0 plane 1 plane 2 plane 3
byte N byte N+1 byte N+2 byte N+3
7 bit 0 7 bit 0 7 bit 0 7 bit 0 full rows
---- ---- ---- ---- ---- ---- ---- ----
1.1. 1.1. 22.. 22.. 4444 .... .... .... --\ 7654321.
.1.1 .1.1 ..22 ..22 .... 4444 8888 8888 --/ 89ABCDEF
</pre>
* The second is the chunky mode, which instead stores each plane as consecutive bits, with each byte responsible for two of the eight pixels:
<pre>
pxl 1,0 pxl 2,3 pxl 5,4 pxl 7,6
byte N byte N+1 byte N+2 byte N+3
7 bit 0 7 bit 0 7 bit 0 7 bit 0 full rows
---- ---- ---- ---- ---- ---- ---- ----
.42. .421 .4.. .4.1 ..2. ..21 .... ...1 --\ 7654321.
8..1 8... 8.21 8.2. 84.1 84.. 8421 842. --/ 89ABCDEF
</pre>
=== Colors, Shades ===
The "mono" WonderSwan uses eight value indices, which are converted by a global look-up table to eight of the sixteen shades the LCD can display:
<pre>
Palette Global shade LUT
1 ===========> 2 ==========================> 5
^ (0, 2, 4, 6) ^ (1, 3, 5, 7, 9, 11, 13, 15) ^
| | |
Tile pixel Value Displayed shade
</pre>
In "color" mode, the WonderSwan instead loads RGB444 color values from a table in the console's internal RAM:
<pre>
15 bit 0
---- ---- ---- ----
.... rrrr gggg bbbb
|||| |||| ++++- Blue (0-15)
|||| ++++------ Green (0-15)
++++----------- Red (0-15)
</pre>
No further processing or look-up tables are applied.
=== Palettes ===
The WonderSwan provides sixteen different palettes. All sixteen can be used for screens only, while the latter eight can be used for screens and sprites. In addition, the background color (for areas where no opaque pixel is drawn) can be selected arbitrarily from the color palette or from the shade LUT.
In two bit per pixel modes, palettes 0 - 3 and 8 - 11 are ''opaque'' (color zero is opaque, four distinct colors are usable), while palettes 4 - 7 and 12 - 15 are ''translucent'' (color zero is transparent, three distinct colors are usable). This applies in both mono and color modes.
In four bit per pixel modes, every palette is ''translucent'' (color zero is transparent, fifteen distinct colors are usable). The first entry of each palette can be used only for the background color.
Palettes 8-15 are also referred to as sprite palettes 0-7.
=== Screens ===
The WonderSwan can display up to two distinct 32x32 screens. These consist of 1024 two-byte cells:
<pre>
15 bit 0
---- ---- ---- ----
vhbp pppt tttt tttt
|||| |||+-++++-++++- Tile index (0-511)
|||+-+++------------ Palette (0-15)
||+----------------- Tile bank (0-1) - color only
|+------------------ Horizontal flip
+------------------- Vertical flip
</pre>
=== Sprites ===
The WonderSwan can display up to 128 sprites, with a limit of 32 visible sprites per line.
These are stored in a sprite table in RAM, which consists of up to 128 four-byte entries:
<pre>
31 bit 0
---- ---- ---- ---- ---- ---- ---- ----
xxxx xxxx yyyy yyyy vhPi pppt tttt tttt
|||| |||| |||| |||| |||| |||+-++++-++++- Tile index (0-511) - only bank 0
|||| |||| |||| |||| |||| +++------------ Palette (0-7) - mapped to screen palettes 8-15
|||| |||| |||| |||| |||+---------------- Window location - 0 = inside, 1 = outside
|||| |||| |||| |||| ||+----------------- Priority - 0 = behind Screen 2, 1 = in front of Screen 2
|||| |||| |||| |||| |+------------------ Horizontal flip
|||| |||| |||| |||| +------------------- Vertical flip
|||| |||| ++++-++++----------------------- Y coordinate
++++-++++--------------------------------- X coordinate
</pre>
=== Windows ===
Screen 2 and the sprite layer can optionally be restricted to a specific window.
In addition, one can control if a given element is rendered inside or outside that window. For Screen 2, this is controlled globally; for sprites, this is controlled per-sprite.
=== Icons ===
Finally, the WonderSwan features six LCD segment icons which are displayed to the right<sup>(color)</sup> or below<sup>(mono)</sup> the main display. These are, as follows:
* Aux 3 - large circle,
* Aux 2 - medium circle,
* Aux 1 - small circle,
* Horizontal orientation,
* Vertical orientation,
* Sleep.
71796d349a1bb36c3ef8ca4fd0ac9f1bcd899df5
95
94
2023-08-22T08:25:23Z
Asie
351
wikitext
text/x-wiki
The WonderSwan's display functionality generally consists of:
* a 224x144 display clocked at ~75.47 Hz by default, capable of displaying:
** up to sixteen distinct shades of gray
** 12-bit RGB444 color<sup>(color)</sup>
* two 32x32 background layers ("screens"), capable of displaying up to 512 (1024<sup>(color)</sup>) distinct tiles,
* a sprite layer, capable of displaying up to 128 8x8 sprites (up to 32 per line),
* six LCD icons to the bottom or right of the display, usable as additional indicators.
== Components ==
=== Tiles ===
The "mono" WonderSwan can display up to 512 tiles stored in a planar format, with two bits total per pixel.
The planes are interleaved with each other; that is, two consecutive bytes form a full 8x1 row of the tile:
<pre>
plane 0 plane 1
byte N byte N+1
7 bit 0 7 bit 0 full tile
---- ---- ---- ----
.... ...1 .222 22.. .22222.1
.... ...1 2222 22.. 222222.1
.... .... 22.. .... 22......
...1 1... 22.2 2... --\ 22.33...
...1 1... 22.2 2... --/ 22.33...
.... .... 22.. .... 22......
.... .... .... .... ........
11.. .... .... .... 11......
</pre>
The WonderSwan Color extends this with an additional 512 tiles (available for screens only, not sprites) and support for three new modes.
* The first new mode is another two bit per pixel mode, but using color palettes instead of monochrome shades.
The latter two modes extend tiles to four bits per pixel.
* The first among them is the planar mode, which works similarly to the two bit per pixel mode:
<pre>
plane 0 plane 1 plane 2 plane 3
byte N byte N+1 byte N+2 byte N+3
7 bit 0 7 bit 0 7 bit 0 7 bit 0 full rows
---- ---- ---- ---- ---- ---- ---- ----
1.1. 1.1. 22.. 22.. 4444 .... .... .... --\ 7654321.
.1.1 .1.1 ..22 ..22 .... 4444 8888 8888 --/ 89ABCDEF
</pre>
* The second is the chunky mode, which instead stores each plane as consecutive bits, with each byte responsible for two of the eight pixels:
<pre>
pxl 1,0 pxl 2,3 pxl 5,4 pxl 7,6
byte N byte N+1 byte N+2 byte N+3
7 bit 0 7 bit 0 7 bit 0 7 bit 0 full rows
---- ---- ---- ---- ---- ---- ---- ----
.42. .421 .4.. .4.1 ..2. ..21 .... ...1 --\ 7654321.
8..1 8... 8.21 8.2. 84.1 84.. 8421 842. --/ 89ABCDEF
</pre>
=== Colors, Shades ===
The "mono" WonderSwan uses eight value indices, which are converted by a global look-up table to eight of the sixteen shades the LCD can display:
<pre>
Palette Global shade LUT
1 ===========> 2 ==========================> 5
^ (0, 2, 4, 6) ^ (1, 3, 5, 7, 9, 11, 13, 15) ^
| | |
Tile pixel Value Displayed shade
</pre>
In "color" mode, the WonderSwan instead loads RGB444 color values from a table in the console's internal RAM:
<pre>
15 bit 0
---- ---- ---- ----
.... rrrr gggg bbbb
|||| |||| ++++- Blue (0-15)
|||| ++++------ Green (0-15)
++++----------- Red (0-15)
</pre>
No further processing or look-up tables are applied.
=== Palettes ===
The WonderSwan provides sixteen different palettes. All sixteen can be used for screens only, while the latter eight can be used for screens and sprites. In addition, the background color (for areas where no opaque pixel is drawn) can be selected arbitrarily from the color palette or from the shade LUT.
In two bit per pixel modes, palettes 0 - 3 and 8 - 11 are ''opaque'' (color zero is opaque, four distinct colors are usable), while palettes 4 - 7 and 12 - 15 are ''translucent'' (color zero is transparent, three distinct colors are usable). This applies in both mono and color modes.
In four bit per pixel modes, every palette is ''translucent'' (color zero is transparent, fifteen distinct colors are usable). The first entry of each palette can be used only for the background color.
Palettes 8-15 are also referred to as sprite palettes 0-7.
=== Screens ===
The WonderSwan can display up to two distinct 32x32 screens. These consist of 1024 two-byte cells:
<pre>
15 bit 0
---- ---- ---- ----
vhbp pppt tttt tttt
|||| |||+-++++-++++- Tile index (0-511)
|||+-+++------------ Palette (0-15)
||+----------------- Tile bank (0-1) - color only
|+------------------ Horizontal flip
+------------------- Vertical flip
</pre>
=== Sprites ===
The WonderSwan can display up to 128 sprites, with a limit of 32 visible sprites per line.
These are stored in a sprite table in RAM, which consists of up to 128 four-byte entries:
<pre>
31 bit 0
---- ---- ---- ---- ---- ---- ---- ----
xxxx xxxx yyyy yyyy vhPi pppt tttt tttt
|||| |||| |||| |||| |||| |||+-++++-++++- Tile index (0-511) - only bank 0
|||| |||| |||| |||| |||| +++------------ Palette (0-7) - mapped to screen palettes 8-15
|||| |||| |||| |||| |||+---------------- Window location - 0 = inside, 1 = outside
|||| |||| |||| |||| ||+----------------- Priority - 0 = behind Screen 2, 1 = in front of Screen 2
|||| |||| |||| |||| |+------------------ Horizontal flip
|||| |||| |||| |||| +------------------- Vertical flip
|||| |||| ++++-++++----------------------- Y coordinate
++++-++++--------------------------------- X coordinate
</pre>
=== Windows ===
Screen 2 and the sprite layer can optionally be restricted to a specific window.
In addition, one can control if a given element is rendered inside or outside that window. For Screen 2, this is controlled globally; for sprites, this is controlled per-sprite.
=== Icons ===
Finally, the WonderSwan features six LCD segment icons which are displayed to the right<sup>(color)</sup> or below<sup>(mono)</sup> the main display. These are, as follows:
* Aux 3 - large circle,
* Aux 2 - medium circle,
* Aux 1 - small circle,
* Horizontal orientation,
* Vertical orientation,
* Sleep.
== Interrupts ==
The display circuit generates two interrupts of its own:
* Display Interrupt Line Match - when <code>Display Current Line</code> == <code>Display Interrupt Line</code>, at the beginning of said line.
* Display Vertical Blank - when <code>Display Current Line</code> == <code>144</code>, at the beginning of said line.
It also provides a timing source for the two Horizontal and Vertical Blank [[Timers]], which provide their own respective interrupts.
== I/O ports ==
=== Display Control ===
<pre>
7 bit 0
---- ----
..ow Ws21
|| |||+- Enable Screen 1 layer
|| ||+-- Enable Screen 2 layer
|| |+--- Enable Sprite layer
|| +---- Enable Sprite window
|+------ Enable Screen 2 window
+------- Screen 2 window location:
0 = inside, 1 = outside
</pre>
=== Display Background ===
<pre>
(mono) (color)
7 bit 0 7 bit 0
---- ---- ---- ----
.... .sss pppp iiii
+++- Value |||| ++++- Index in palette (0-15)
(0-7) ++++------ Color palette (0-15)
</pre>
=== Display Current Line ===
The current line being drawn by the display.
Note that lines are sent to the display with a one-line delay. This matters for color palette or shade LUT manipulation; changing these values when <code>current line == 1</code> will actually affect line 0.
=== Display Interrupt Line ===
The line to emit an interrupt on.
=== Sprite Table Address ===
=== Sprite Table First ===
=== Sprite Table Count ===
=== Screen Address ===
=== LCD Control ===
=== LCD Icon Control ===
=== LCD Final Line ===
=== LCD Back Porch Line (WSC only) ===
This port is available on the WonderSwan Color only - not the SwanCrystal!
=== LCD Status ===
=== LCD Timing Configuration (SwanCrystal only) ===
These eight bytes are read from internal EEPROM and configure unknown aspects of the console's TFT LCD panel.
They are only writable while the [[Boot ROM]] is unlocked - locking has the side effect of making them read-only.
2d5ec5640684340fb317402ccebfe771786c63de
97
95
2023-08-22T08:38:25Z
Fiskbit
37
Register formatting.
wikitext
text/x-wiki
The WonderSwan's display functionality generally consists of:
* a 224x144 display clocked at ~75.47 Hz by default, capable of displaying:
** up to sixteen distinct shades of gray
** 12-bit RGB444 color<sup>(color)</sup>
* two 32x32 background layers ("screens"), capable of displaying up to 512 (1024<sup>(color)</sup>) distinct tiles,
* a sprite layer, capable of displaying up to 128 8x8 sprites (up to 32 per line),
* six LCD icons to the bottom or right of the display, usable as additional indicators.
== Components ==
=== Tiles ===
The "mono" WonderSwan can display up to 512 tiles stored in a planar format, with two bits total per pixel.
The planes are interleaved with each other; that is, two consecutive bytes form a full 8x1 row of the tile:
<pre>
plane 0 plane 1
byte N byte N+1
7 bit 0 7 bit 0 full tile
---- ---- ---- ----
.... ...1 .222 22.. .22222.1
.... ...1 2222 22.. 222222.1
.... .... 22.. .... 22......
...1 1... 22.2 2... --\ 22.33...
...1 1... 22.2 2... --/ 22.33...
.... .... 22.. .... 22......
.... .... .... .... ........
11.. .... .... .... 11......
</pre>
The WonderSwan Color extends this with an additional 512 tiles (available for screens only, not sprites) and support for three new modes.
* The first new mode is another two bit per pixel mode, but using color palettes instead of monochrome shades.
The latter two modes extend tiles to four bits per pixel.
* The first among them is the planar mode, which works similarly to the two bit per pixel mode:
<pre>
plane 0 plane 1 plane 2 plane 3
byte N byte N+1 byte N+2 byte N+3
7 bit 0 7 bit 0 7 bit 0 7 bit 0 full rows
---- ---- ---- ---- ---- ---- ---- ----
1.1. 1.1. 22.. 22.. 4444 .... .... .... --\ 7654321.
.1.1 .1.1 ..22 ..22 .... 4444 8888 8888 --/ 89ABCDEF
</pre>
* The second is the chunky mode, which instead stores each plane as consecutive bits, with each byte responsible for two of the eight pixels:
<pre>
pxl 1,0 pxl 2,3 pxl 5,4 pxl 7,6
byte N byte N+1 byte N+2 byte N+3
7 bit 0 7 bit 0 7 bit 0 7 bit 0 full rows
---- ---- ---- ---- ---- ---- ---- ----
.42. .421 .4.. .4.1 ..2. ..21 .... ...1 --\ 7654321.
8..1 8... 8.21 8.2. 84.1 84.. 8421 842. --/ 89ABCDEF
</pre>
=== Colors, Shades ===
The "mono" WonderSwan uses eight value indices, which are converted by a global look-up table to eight of the sixteen shades the LCD can display:
<pre>
Palette Global shade LUT
1 ===========> 2 ==========================> 5
^ (0, 2, 4, 6) ^ (1, 3, 5, 7, 9, 11, 13, 15) ^
| | |
Tile pixel Value Displayed shade
</pre>
In "color" mode, the WonderSwan instead loads RGB444 color values from a table in the console's internal RAM:
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
.... rrrr gggg bbbb
|||| |||| ||||
|||| |||| ++++- Blue (0-15)
|||| ++++------ Green (0-15)
++++------------- Red (0-15)
</pre>
No further processing or look-up tables are applied.
=== Palettes ===
The WonderSwan provides sixteen different palettes. All sixteen can be used for screens only, while the latter eight can be used for screens and sprites. In addition, the background color (for areas where no opaque pixel is drawn) can be selected arbitrarily from the color palette or from the shade LUT.
In two bit per pixel modes, palettes 0 - 3 and 8 - 11 are ''opaque'' (color zero is opaque, four distinct colors are usable), while palettes 4 - 7 and 12 - 15 are ''translucent'' (color zero is transparent, three distinct colors are usable). This applies in both mono and color modes.
In four bit per pixel modes, every palette is ''translucent'' (color zero is transparent, fifteen distinct colors are usable). The first entry of each palette can be used only for the background color.
Palettes 8-15 are also referred to as sprite palettes 0-7.
=== Screens ===
The WonderSwan can display up to two distinct 32x32 screens. These consist of 1024 two-byte cells:
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
vhbp pppt tttt tttt
|||| |||| |||| ||||
|||| |||+---++++-++++- Tile index (0-511)
|||+-+++-------------- Palette (0-15)
||+------------------- Tile bank (0-1) - color only
|+-------------------- Horizontal flip
+--------------------- Vertical flip
</pre>
=== Sprites ===
The WonderSwan can display up to 128 sprites, with a limit of 32 visible sprites per line.
These are stored in a sprite table in RAM, which consists of up to 128 four-byte entries:
<pre>
31 bit 24 23 bit 16 15 bit 8 7 bit 0
---- ---- ---- ---- ---- ---- ---- ----
xxxx xxxx yyyy yyyy vhPi pppt tttt tttt
|||| |||| |||| |||| |||| |||| |||| ||||
|||| |||| |||| |||| |||| |||+---++++-++++- Tile index (0-511) - only bank 0
|||| |||| |||| |||| |||| +++-------------- Palette (0-7) - mapped to screen palettes 8-15
|||| |||| |||| |||| |||+------------------ Window location - 0 = inside, 1 = outside
|||| |||| |||| |||| ||+------------------- Priority - 0 = behind Screen 2, 1 = in front of Screen 2
|||| |||| |||| |||| |+-------------------- Horizontal flip
|||| |||| |||| |||| +--------------------- Vertical flip
|||| |||| ++++-++++------------------------- Y coordinate
++++-++++------------------------------------- X coordinate
</pre>
=== Windows ===
Screen 2 and the sprite layer can optionally be restricted to a specific window.
In addition, one can control if a given element is rendered inside or outside that window. For Screen 2, this is controlled globally; for sprites, this is controlled per-sprite.
=== Icons ===
Finally, the WonderSwan features six LCD segment icons which are displayed to the right<sup>(color)</sup> or below<sup>(mono)</sup> the main display. These are, as follows:
* Aux 3 - large circle,
* Aux 2 - medium circle,
* Aux 1 - small circle,
* Horizontal orientation,
* Vertical orientation,
* Sleep.
== Interrupts ==
The display circuit generates two interrupts of its own:
* Display Interrupt Line Match - when <code>Display Current Line</code> == <code>Display Interrupt Line</code>, at the beginning of said line.
* Display Vertical Blank - when <code>Display Current Line</code> == <code>144</code>, at the beginning of said line.
It also provides a timing source for the two Horizontal and Vertical Blank [[Timers]], which provide their own respective interrupts.
== I/O ports ==
=== Display Control ===
<pre>
7 bit 0
---- ----
..ow Ws21
|| ||||
|| |||+- Enable Screen 1 layer
|| ||+-- Enable Screen 2 layer
|| |+--- Enable Sprite layer
|| +---- Enable Sprite window
|+------ Enable Screen 2 window
+------- Screen 2 window location:
0 = inside, 1 = outside
</pre>
=== Display Background ===
<pre>
(mono) (color)
7 bit 0 7 bit 0
---- ---- ---- ----
.... .sss pppp iiii
||| |||| ||||
+++- Value |||| ++++- Index in palette (0-15)
(0-7) ++++------ Color palette (0-15)
</pre>
=== Display Current Line ===
The current line being drawn by the display.
Note that lines are sent to the display with a one-line delay. This matters for color palette or shade LUT manipulation; changing these values when <code>current line == 1</code> will actually affect line 0.
=== Display Interrupt Line ===
The line to emit an interrupt on.
=== Sprite Table Address ===
=== Sprite Table First ===
=== Sprite Table Count ===
=== Screen Address ===
=== LCD Control ===
=== LCD Icon Control ===
=== LCD Final Line ===
=== LCD Back Porch Line (WSC only) ===
This port is available on the WonderSwan Color only - not the SwanCrystal!
=== LCD Status ===
=== LCD Timing Configuration (SwanCrystal only) ===
These eight bytes are read from internal EEPROM and configure unknown aspects of the console's TFT LCD panel.
They are only writable while the [[Boot ROM]] is unlocked - locking has the side effect of making them read-only.
b6a6a14041dd4b352c4a4e65009ab1e479b557b8
99
97
2023-08-22T09:15:27Z
Asie
351
wikitext
text/x-wiki
The WonderSwan's display functionality generally consists of:
* a 224x144 display clocked at ~75.47 Hz by default, capable of displaying:
** up to sixteen distinct shades of gray
** 12-bit RGB444 color<sup>(color)</sup>
* two 32x32 background layers ("screens"), capable of displaying up to 512 (1024<sup>(color)</sup>) distinct tiles,
* a sprite layer, capable of displaying up to 128 8x8 sprites (up to 32 per line),
* six LCD icons to the bottom or right of the display, usable as additional indicators.
== Components ==
=== Tiles ===
The "mono" WonderSwan can display up to 512 tiles stored in a planar format, with two bits total per pixel.
The planes are interleaved with each other; that is, two consecutive bytes form a full 8x1 row of the tile:
<pre>
plane 0 plane 1
byte N byte N+1
7 bit 0 7 bit 0 full tile
---- ---- ---- ----
.... ...1 .222 22.. .22222.1
.... ...1 2222 22.. 222222.1
.... .... 22.. .... 22......
...1 1... 22.2 2... --\ 22.33...
...1 1... 22.2 2... --/ 22.33...
.... .... 22.. .... 22......
.... .... .... .... ........
11.. .... .... .... 11......
</pre>
The WonderSwan Color extends this with an additional 512 tiles (available for screens only, not sprites) and support for three new modes.
* The first new mode is another two bit per pixel mode, but using color palettes instead of monochrome shades.
The latter two modes extend tiles to four bits per pixel.
* The first among them is the planar mode, which works similarly to the two bit per pixel mode:
<pre>
plane 0 plane 1 plane 2 plane 3
byte N byte N+1 byte N+2 byte N+3
7 bit 0 7 bit 0 7 bit 0 7 bit 0 full rows
---- ---- ---- ---- ---- ---- ---- ----
1.1. 1.1. 22.. 22.. 4444 .... .... .... --\ 7654321.
.1.1 .1.1 ..22 ..22 .... 4444 8888 8888 --/ 89ABCDEF
</pre>
* The second is the chunky mode, which instead stores each plane as consecutive bits, with each byte responsible for two of the eight pixels:
<pre>
pxl 1,0 pxl 2,3 pxl 5,4 pxl 7,6
byte N byte N+1 byte N+2 byte N+3
7 bit 0 7 bit 0 7 bit 0 7 bit 0 full rows
---- ---- ---- ---- ---- ---- ---- ----
.42. .421 .4.. .4.1 ..2. ..21 .... ...1 --\ 7654321.
8..1 8... 8.21 8.2. 84.1 84.. 8421 842. --/ 89ABCDEF
</pre>
=== Colors, Shades ===
The "mono" WonderSwan uses eight value indices, which are converted by a global look-up table to eight of the sixteen shades the LCD can display:
<pre>
Palette Global shade LUT
1 ===========> 2 ==========================> 5
^ (0, 2, 4, 6) ^ (1, 3, 5, 7, 9, 11, 13, 15) ^
| | |
Tile pixel Value Displayed shade
</pre>
In "color" mode, the WonderSwan instead loads RGB444 color values from a table in the console's internal RAM:
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
.... rrrr gggg bbbb
|||| |||| ||||
|||| |||| ++++- Blue (0-15)
|||| ++++------ Green (0-15)
++++------------- Red (0-15)
</pre>
No further processing or look-up tables are applied.
=== Palettes ===
The WonderSwan provides sixteen different palettes. All sixteen can be used for screens only, while the latter eight can be used for screens and sprites. In addition, the background color (for areas where no opaque pixel is drawn) can be selected arbitrarily from the color palette or from the shade LUT.
In two bit per pixel modes, palettes 0 - 3 and 8 - 11 are ''opaque'' (color zero is opaque, four distinct colors are usable), while palettes 4 - 7 and 12 - 15 are ''translucent'' (color zero is transparent, three distinct colors are usable). This applies in both mono and color modes.
In four bit per pixel modes, every palette is ''translucent'' (color zero is transparent, fifteen distinct colors are usable). The first entry of each palette can be used only for the background color.
Palettes 8-15 are also referred to as sprite palettes 0-7.
=== Screens ===
The WonderSwan can display up to two distinct 32x32 screens. These consist of 1024 two-byte cells:
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
vhbp pppt tttt tttt
|||| |||| |||| ||||
|||| |||+---++++-++++- Tile index (0-511)
|||+-+++-------------- Palette (0-15)
||+------------------- Tile bank (0-1) - color only
|+-------------------- Horizontal flip
+--------------------- Vertical flip
</pre>
=== Sprites ===
The WonderSwan can display up to 128 sprites, with a limit of 32 visible sprites per line.
These are stored in a sprite table in RAM, which consists of up to 128 four-byte entries:
<pre>
31 bit 24 23 bit 16 15 bit 8 7 bit 0
---- ---- ---- ---- ---- ---- ---- ----
xxxx xxxx yyyy yyyy vhPi pppt tttt tttt
|||| |||| |||| |||| |||| |||| |||| ||||
|||| |||| |||| |||| |||| |||+---++++-++++- Tile index (0-511) - only bank 0
|||| |||| |||| |||| |||| +++-------------- Palette (0-7) - mapped to screen palettes 8-15
|||| |||| |||| |||| |||+------------------ Window location - 0 = inside, 1 = outside
|||| |||| |||| |||| ||+------------------- Priority - 0 = behind Screen 2, 1 = in front of Screen 2
|||| |||| |||| |||| |+-------------------- Horizontal flip
|||| |||| |||| |||| +--------------------- Vertical flip
|||| |||| ++++-++++------------------------- Y coordinate
++++-++++------------------------------------- X coordinate
</pre>
=== Windows ===
Screen 2 and the sprite layer can optionally be restricted to a specific window.
In addition, one can control if a given element is rendered inside or outside that window. For Screen 2, this is controlled globally; for sprites, this is controlled per-sprite.
=== Icons ===
Finally, the WonderSwan features six LCD segment icons which are displayed to the right<sup>(color)</sup> or below<sup>(mono)</sup> the main display. These are, as follows:
* Aux 3 - large circle,
* Aux 2 - medium circle,
* Aux 1 - small circle,
* Horizontal orientation,
* Vertical orientation,
* Sleep.
== Interrupts ==
The display circuit generates two interrupts of its own:
* Display Interrupt Line Match - when <code>Display Current Line</code> == <code>Display Interrupt Line</code>, at the beginning of said line.
* Display Vertical Blank - when <code>Display Current Line</code> == <code>144</code>, at the beginning of said line.
It also provides a timing source for the two Horizontal and Vertical Blank [[Timers]], which provide their own respective interrupts.
== I/O ports ==
=== Display Control ===
<pre>
7 bit 0
---- ----
..ow Ws21
|| ||||
|| |||+- Enable Screen 1 layer
|| ||+-- Enable Screen 2 layer
|| |+--- Enable Sprite layer
|| +---- Enable Sprite window
|+------ Enable Screen 2 window
+------- Screen 2 window location:
0 = inside, 1 = outside
</pre>
=== Display Background ===
<pre>
(mono) (color)
7 bit 0 7 bit 0
---- ---- ---- ----
.... .sss pppp iiii
||| |||| ||||
+++- Value |||| ++++- Index in palette (0-15)
(0-7) ++++------ Color palette (0-15)
</pre>
=== Display Current Line ===
The current line being drawn by the display.
Note that lines are sent to the display with a one-line delay. This matters for color palette or shade LUT manipulation; changing these values when <code>current line == 1</code> will actually affect line 0.
=== Display Interrupt Line ===
The line to emit an interrupt on.
=== Sprite Table Address ===
<pre>
7 bit 0
---- ----
..Aa aaaa
|+-++++- Address (bits 9-13)
+------- Address (bit 14) - color only
</pre>
=== Sprite Table First ===
<pre>
7 bit 0
---- ----
.iii iiii
+++-++++- Index of first sprite entry to draw (0-127)
</pre>
=== Sprite Table Count ===
<pre>
7 bit 0
---- ----
cccc cccc
++++-++++- Count of sprite entries to draw (1-128)
</pre>
=== Screen Address ===
<pre>
7 bit 0
---- ----
2222 1111
|||| |+++- Screen 1 address (bits 11-13)
|||| +---- Screen 1 address (bit 14) - color only
|+++------ Screen 2 address (bits 11-13)
+--------- Screen 2 address (bit 14) - color only
</pre>
=== LCD Control ===
<pre>
7 bit 0
---- ----
.... ..Ce
|+- LCD Enable: 0 = sleep, 1 = enabled
+-- Contrast (WSC): 0 = low, 1 = high
</pre>
=== LCD Icon Control ===
<pre>
7 bit 0
---- ----
..32 1hvs
|| |||+- Sleep
|| ||+-- Vertical orientation
|| |+--- Horizontal orientation
|| +---- Aux 1
|+------ Aux 2
+------- Aux 3
</pre>
== Internal I/O ports ==
These I/O ports are said to be internal and not intended for use by commercial games.
=== LCD Final Line ===
The final line preceding line counter restart. By default, this should be set to 158.
It is said setting this register to an odd value on SwanCrystal has an adverse effect to the LCD panel<ref>[http://daifukkat.su/docs/wsman/#REG_LCD_VSYNC REG_LCD_VSYNC - WSMan]</ref>, but the exact mechanism is unknown.
=== LCD Back Porch Line (WSC only) ===
This port is available on the WonderSwan Color only - not the SwanCrystal!
The final line preceding the vertical back porch; by default, this should be set to 155.
The vertical back porch of the LCD is assumed to be 4 lines by some hardware, including IPS mods, as well as the official "TV Swan" capture device. Given that the first visible line is sent to the LCD on the display's line 1, this should be generally set to <code>LCD Final Line - 3</code>.
Conversely, it is said moving this value closer to vertical blank improves LCD visibility<ref>[http://daifukkat.su/docs/wsman/#REG_LCD_VTOTAL REG_LCD_VTOTAL - WSMan]</ref>, but the exact mechanism is unknown.
=== LCD Status ===
<pre>
7 bit 0
---- ----
...v vv.s
| || +- LCD sleep: 0 = no, 1 = sleep
| ||
| || Volume segments:
| |+--- Volume B (medium, high)
| +---- Volume A (low, high)
+------ Speaker
</pre>
=== LCD Timing Configuration (SwanCrystal only) ===
These eight bytes are read from internal EEPROM and configure unknown aspects of the console's TFT LCD panel.
They are only writable while the [[Boot ROM]] is unlocked - locking has the side effect of making them read-only.
== Notes ==
<references />
7c7f89b52c9e5543d01bf50884cba7ce1ad3308b
100
99
2023-08-22T09:21:54Z
Fiskbit
37
Register formatting. Reworks sprite byte presentation for clarity.
wikitext
text/x-wiki
The WonderSwan's display functionality generally consists of:
* a 224x144 display clocked at ~75.47 Hz by default, capable of displaying:
** up to sixteen distinct shades of gray
** 12-bit RGB444 color<sup>(color)</sup>
* two 32x32 background layers ("screens"), capable of displaying up to 512 (1024<sup>(color)</sup>) distinct tiles,
* a sprite layer, capable of displaying up to 128 8x8 sprites (up to 32 per line),
* six LCD icons to the bottom or right of the display, usable as additional indicators.
== Components ==
=== Tiles ===
The "mono" WonderSwan can display up to 512 tiles stored in a planar format, with two bits total per pixel.
The planes are interleaved with each other; that is, two consecutive bytes form a full 8x1 row of the tile:
<pre>
plane 0 plane 1
byte N byte N+1
7 bit 0 7 bit 0 full tile
---- ---- ---- ----
.... ...1 .222 22.. .22222.1
.... ...1 2222 22.. 222222.1
.... .... 22.. .... 22......
...1 1... 22.2 2... --\ 22.33...
...1 1... 22.2 2... --/ 22.33...
.... .... 22.. .... 22......
.... .... .... .... ........
11.. .... .... .... 11......
</pre>
The WonderSwan Color extends this with an additional 512 tiles (available for screens only, not sprites) and support for three new modes.
* The first new mode is another two bit per pixel mode, but using color palettes instead of monochrome shades.
The latter two modes extend tiles to four bits per pixel.
* The first among them is the planar mode, which works similarly to the two bit per pixel mode:
<pre>
plane 0 plane 1 plane 2 plane 3
byte N byte N+1 byte N+2 byte N+3
7 bit 0 7 bit 0 7 bit 0 7 bit 0 full rows
---- ---- ---- ---- ---- ---- ---- ----
1.1. 1.1. 22.. 22.. 4444 .... .... .... --\ 7654321.
.1.1 .1.1 ..22 ..22 .... 4444 8888 8888 --/ 89ABCDEF
</pre>
* The second is the chunky mode, which instead stores each plane as consecutive bits, with each byte responsible for two of the eight pixels:
<pre>
pxl 1,0 pxl 2,3 pxl 5,4 pxl 7,6
byte N byte N+1 byte N+2 byte N+3
7 bit 0 7 bit 0 7 bit 0 7 bit 0 full rows
---- ---- ---- ---- ---- ---- ---- ----
.42. .421 .4.. .4.1 ..2. ..21 .... ...1 --\ 7654321.
8..1 8... 8.21 8.2. 84.1 84.. 8421 842. --/ 89ABCDEF
</pre>
=== Colors, Shades ===
The "mono" WonderSwan uses eight value indices, which are converted by a global look-up table to eight of the sixteen shades the LCD can display:
<pre>
Palette Global shade LUT
1 ===========> 2 ==========================> 5
^ (0, 2, 4, 6) ^ (1, 3, 5, 7, 9, 11, 13, 15) ^
| | |
Tile pixel Value Displayed shade
</pre>
In "color" mode, the WonderSwan instead loads RGB444 color values from a table in the console's internal RAM:
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
.... rrrr gggg bbbb
|||| |||| ||||
|||| |||| ++++- Blue (0-15)
|||| ++++------ Green (0-15)
++++------------ Red (0-15)
</pre>
No further processing or look-up tables are applied.
=== Palettes ===
The WonderSwan provides sixteen different palettes. All sixteen can be used for screens only, while the latter eight can be used for screens and sprites. In addition, the background color (for areas where no opaque pixel is drawn) can be selected arbitrarily from the color palette or from the shade LUT.
In two bit per pixel modes, palettes 0 - 3 and 8 - 11 are ''opaque'' (color zero is opaque, four distinct colors are usable), while palettes 4 - 7 and 12 - 15 are ''translucent'' (color zero is transparent, three distinct colors are usable). This applies in both mono and color modes.
In four bit per pixel modes, every palette is ''translucent'' (color zero is transparent, fifteen distinct colors are usable). The first entry of each palette can be used only for the background color.
Palettes 8-15 are also referred to as sprite palettes 0-7.
=== Screens ===
The WonderSwan can display up to two distinct 32x32 screens. These consist of 1024 two-byte cells:
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
vhbp pppt tttt tttt
|||| |||| |||| ||||
|||| |||+--++++-++++- Tile index (0-511)
|||+-+++------------- Palette (0-15)
||+------------------ Tile bank (0-1) - color only
|+------------------- Horizontal flip
+-------------------- Vertical flip
</pre>
=== Sprites ===
The WonderSwan can display up to 128 sprites, with a limit of 32 visible sprites per line.
These are stored in a sprite table in RAM, which consists of up to 128 four-byte entries:
<pre>
(Byte 1) (Byte 0)
15 bit 8 7 bit 0
---- ---- ---- ----
vhPi pppt tttt tttt
|||| |||| |||| ||||
|||| |||+--++++-++++- Tile index (0-511) - only bank 0
|||| +++------------- Palette (0-7) - mapped to screen palettes 8-15
|||+----------------- Window location - 0 = inside, 1 = outside
||+------------------ Priority - 0 = behind Screen 2, 1 = in front of Screen 2
|+------------------- Horizontal flip
+-------------------- Vertical flip
(Byte 2)
7 bit 0
---- ----
yyyy yyyy
|||| ||||
++++-++++- Y coordinate
(Byte 3)
7 bit 0
---- ----
xxxx xxxx
|||| ||||
++++-++++- X coordinate
</pre>
=== Windows ===
Screen 2 and the sprite layer can optionally be restricted to a specific window.
In addition, one can control if a given element is rendered inside or outside that window. For Screen 2, this is controlled globally; for sprites, this is controlled per-sprite.
=== Icons ===
Finally, the WonderSwan features six LCD segment icons which are displayed to the right<sup>(color)</sup> or below<sup>(mono)</sup> the main display. These are, as follows:
* Aux 3 - large circle,
* Aux 2 - medium circle,
* Aux 1 - small circle,
* Horizontal orientation,
* Vertical orientation,
* Sleep.
== Interrupts ==
The display circuit generates two interrupts of its own:
* Display Interrupt Line Match - when <code>Display Current Line</code> == <code>Display Interrupt Line</code>, at the beginning of said line.
* Display Vertical Blank - when <code>Display Current Line</code> == <code>144</code>, at the beginning of said line.
It also provides a timing source for the two Horizontal and Vertical Blank [[Timers]], which provide their own respective interrupts.
== I/O ports ==
=== Display Control ===
<pre>
7 bit 0
---- ----
..ow Ws21
|| ||||
|| |||+- Enable Screen 1 layer
|| ||+-- Enable Screen 2 layer
|| |+--- Enable Sprite layer
|| +---- Enable Sprite window
|+------ Enable Screen 2 window
+------- Screen 2 window location:
0 = inside, 1 = outside
</pre>
=== Display Background ===
<pre>
(mono) (color)
7 bit 0 7 bit 0
---- ---- ---- ----
.... .sss pppp iiii
||| |||| ||||
+++- Value |||| ++++- Index in palette (0-15)
(0-7) ++++------ Color palette (0-15)
</pre>
=== Display Current Line ===
The current line being drawn by the display.
Note that lines are sent to the display with a one-line delay. This matters for color palette or shade LUT manipulation; changing these values when <code>current line == 1</code> will actually affect line 0.
=== Display Interrupt Line ===
The line to emit an interrupt on.
=== Sprite Table Address ===
<pre>
7 bit 0
---- ----
..Aa aaaa
|| ||||
|+-++++- Address (bits 9-13)
+------- Address (bit 14) - color only
</pre>
=== Sprite Table First ===
<pre>
7 bit 0
---- ----
.iii iiii
||| ||||
+++-++++- Index of first sprite entry to draw (0-127)
</pre>
=== Sprite Table Count ===
<pre>
7 bit 0
---- ----
cccc cccc
|||| ||||
++++-++++- Count of sprite entries to draw (1-128)
</pre>
=== Screen Address ===
<pre>
7 bit 0
---- ----
2222 1111
|||| ||||
|||| |+++- Screen 1 address (bits 11-13)
|||| +---- Screen 1 address (bit 14) - color only
|+++------ Screen 2 address (bits 11-13)
+--------- Screen 2 address (bit 14) - color only
</pre>
=== LCD Control ===
<pre>
7 bit 0
---- ----
.... ..Ce
||
|+- LCD Enable: 0 = sleep, 1 = enabled
+-- Contrast (WSC): 0 = low, 1 = high
</pre>
=== LCD Icon Control ===
<pre>
7 bit 0
---- ----
..32 1hvs
|| ||||
|| |||+- Sleep
|| ||+-- Vertical orientation
|| |+--- Horizontal orientation
|| +---- Aux 1
|+------ Aux 2
+------- Aux 3
</pre>
== Internal I/O ports ==
These I/O ports are said to be internal and not intended for use by commercial games.
=== LCD Final Line ===
The final line preceding line counter restart. By default, this should be set to 158.
It is said setting this register to an odd value on SwanCrystal has an adverse effect to the LCD panel<ref>[http://daifukkat.su/docs/wsman/#REG_LCD_VSYNC REG_LCD_VSYNC - WSMan]</ref>, but the exact mechanism is unknown.
=== LCD Back Porch Line (WSC only) ===
This port is available on the WonderSwan Color only - not the SwanCrystal!
The final line preceding the vertical back porch; by default, this should be set to 155.
The vertical back porch of the LCD is assumed to be 4 lines by some hardware, including IPS mods, as well as the official "TV Swan" capture device. Given that the first visible line is sent to the LCD on the display's line 1, this should be generally set to <code>LCD Final Line - 3</code>.
Conversely, it is said moving this value closer to vertical blank improves LCD visibility<ref>[http://daifukkat.su/docs/wsman/#REG_LCD_VTOTAL REG_LCD_VTOTAL - WSMan]</ref>, but the exact mechanism is unknown.
=== LCD Status ===
<pre>
7 bit 0
---- ----
...v vv.s
| || |
| || +- LCD sleep: 0 = no, 1 = sleep
| ||
| || Volume segments:
| |+--- Volume B (medium, high)
| +---- Volume A (low, high)
+------ Speaker
</pre>
=== LCD Timing Configuration (SwanCrystal only) ===
These eight bytes are read from internal EEPROM and configure unknown aspects of the console's TFT LCD panel.
They are only writable while the [[Boot ROM]] is unlocked - locking has the side effect of making them read-only.
== Notes ==
<references />
51a1cad85493db4a12cf8fc494667b8f240f4a79
I/O port map
0
8
101
98
2023-08-22T09:58:16Z
Asie
351
wikitext
text/x-wiki
* Superscripts are used to mark ports specific to a given mode or platform:
** Color mode: <sup>(color)</sup>.
** WS/WSC/SC console: <sup>(WS)</sup>, <sup>(WSC)</sup>, <sup>(SC)</sup>.
* If two Bits rows are provided, the second one refers to the "Color" mode.
* The Type can be: R - readable, W - writable, L - writable before boot ROM lockout, 8/16 - width (byte/word).
{| class="wikitable"
! Category
! Port
! Description
! Bits
! Type
! Notes
|-
! rowspan="45" | [[Display]]
! $00
| [[Display#Display Control|Display Control]]
| style="text-align: right" | <tt style="white-space: nowrap">..ow Ws21</tt>
| RW8
|
|-
! $01
| [[Display#Display Background|Display Background]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .sss</tt>
<tt style="white-space: nowrap">pppp iiii</tt>
| RW8
| Shade (s)
Palette (p), Index (i)
|-
! $02
| [[Display#Current Line|Display Current Line]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll</tt>
| R8
| Line (l)
|-
! $03
| [[Display#Interrupt Line|Display Interrupt Line]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll</tt>
| RW8
| Line (l)
|-
! $04
| [[Display#Sprite Table Address|Sprite Table Address]]
| style="text-align: right" | <tt style="white-space: nowrap">...a aaaa</tt>
<tt style="white-space: nowrap">..aa aaaa</tt>
| RW8
| Address >> 9 (a)
|-
! $05
| [[Display#Sprite Table First|Sprite Table First]]
| style="text-align: right" | <tt style="white-space: nowrap">.iii iiii</tt>
| RW8
| Index (i)
|-
! $06
| [[Display#Sprite Table Count|Sprite Table Count]]
| style="text-align: right" | <tt style="white-space: nowrap">cccc cccc</tt>
| RW8
| Count (c)
|-
! $07
| [[Display#Screen Address|Screen Address]]
| style="text-align: right" | <tt style="white-space: nowrap">.222 .111</tt>
<tt style="white-space: nowrap">2222 1111</tt>
| RW8
| Screen 1 address >> 11 (1)
Screen 2 address >> 11 (2)
|-
! $08
| [[Display#Screen 2 Window|Screen 2 Window Left]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $09
| [[Display#Screen 2 Window|Screen 2 Window Top]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $0A
| [[Display#Screen 2 Window|Screen 2 Window Right]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $0B
| [[Display#Screen 2 Window|Screen 2 Window Bottom]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $0B
| [[Display#Sprite Window|Sprite Window Left]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $0C
| [[Display#Sprite Window|Sprite Window Top]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $0E
| [[Display#Sprite Window|Sprite Window Right]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $0F
| [[Display#Sprite Window|Sprite Window Bottom]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $10
| [[Display#Screen Scroll|Screen 1 Scroll X]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $11
| [[Display#Screen Scroll|Screen 1 Scroll Y]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $12
| [[Display#Screen Scroll|Screen 2 Scroll X]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $13
| [[Display#Screen Scroll|Screen 2 Scroll Y]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $14
| [[Display#LCD Control|LCD Control]]
| style="text-align: right" | <tt style="white-space: nowrap">.... ..Ce</tt>
| RW8
| Contrast (C)<sup>(WSC)</sup>, Enable (e)
|-
! $15
| [[Display#LCD Icon Control|LCD Icon Control]]
| style="text-align: right" | <tt style="white-space: nowrap">..32 1hvs</tt>
| RW8
| Auxillary 3 (3), Auxillary 2 (2), Auxillary 1 (1),
Horizontal (h), Vertical (v), Sleep (s)
|-
! $16
| [[Display#LCD Final Line|LCD Final Line]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll</tt>
| RW8
| Line (l)
|-
! $17
| [[Display#LCD Back Porch Line|LCD Back Porch Line]]<sup>(WSC)</sup>
| style="text-align: right" | <tt style="white-space: nowrap">llll llll</tt>
| RW8
| Line (l)
|-
! $1A
| [[Display#LCD Status|LCD Status]]
| style="text-align: right" | <tt style="white-space: nowrap">...v vv.s</tt>
| RW8
| Volume segment status (v), Sleep (s)
|-
! $1C
| [[Display#LCD Mono Shade LUT|LCD Mono Shade LUT 0/1]]
| style="text-align: right" | <tt style="white-space: nowrap">1111 0000</tt>
| RW8
| Shade index
|-
! $1D
| [[Display#LCD Mono Shade LUT|LCD Mono Shade LUT 2/3]]
| style="text-align: right" | <tt style="white-space: nowrap">3333 2222</tt>
| RW8
| Shade index
|-
! $1E
| [[Display#LCD Mono Shade LUT|LCD Mono Shade LUT 4/5]]
| style="text-align: right" | <tt style="white-space: nowrap">5555 4444</tt>
| RW8
| Shade index
|-
! $1F
| [[Display#LCD Mono Shade LUT|LCD Mono Shade LUT 6/7]]
| style="text-align: right" | <tt style="white-space: nowrap">7777 6666</tt>
| RW8
| Shade index
|-
! $20
| [[Display#LCD Mono Palette|LCD Mono Palette 0]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $22
| [[Display#LCD Mono Palette|LCD Mono Palette 1]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $24
| [[Display#LCD Mono Palette|LCD Mono Palette 2]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $26
| [[Display#LCD Mono Palette|LCD Mono Palette 3]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $28
| [[Display#LCD Mono Palette|LCD Mono Palette 4]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $2A
| [[Display#LCD Mono Palette|LCD Mono Palette 5]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $2C
| [[Display#LCD Mono Palette|LCD Mono Palette 6]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $2E
| [[Display#LCD Mono Palette|LCD Mono Palette 7]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $30
| [[Display#LCD Mono Palette|LCD Mono Palette 8]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $32
| [[Display#LCD Mono Palette|LCD Mono Palette 9]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $34
| [[Display#LCD Mono Palette|LCD Mono Palette 10]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $36
| [[Display#LCD Mono Palette|LCD Mono Palette 11]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $38
| [[Display#LCD Mono Palette|LCD Mono Palette 12]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $3A
| [[Display#LCD Mono Palette|LCD Mono Palette 13]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $3C
| [[Display#LCD Mono Palette|LCD Mono Palette 14]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $3E
| [[Display#LCD Mono Palette|LCD Mono Palette 15]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! rowspan="10" | [[DMA]]<sup>(color)</sup>
! $40
| [[DMA#General DMA|GDMA Source Address Low]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll llll llll</tt>
| RW16
| Linear address, low 16 bits (l)
|-
! $42
| [[DMA#General DMA|GDMA Source Address High]]
| style="text-align: right" | <tt style="white-space: nowrap">.... hhhh</tt>
| RW8
| Linear address, high 4 bits (h)
|-
! $44
| [[DMA#General DMA|GDMA Destination Address]]
| style="text-align: right" | <tt style="white-space: nowrap">aaaa aaaa aaaa aaaa</tt>
| RW16
| IRAM address (a)
|-
! $46
| [[DMA#General DMA|GDMA Length]]
| style="text-align: right" | <tt style="white-space: nowrap">bbbb bbbb bbbb bbbb</tt>
| RW16
| Bytes (b)
|-
! $48
| [[DMA#General DMA|GDMA Control]]
| style="text-align: right" | <tt style="white-space: nowrap">ed.. ....</tt>
| RW8
| Enable (e), Decrement (d)
|-
! $4A
| [[DMA#Sound DMA|SDMA Source Address Low]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll llll llll</tt>
| RW16
| Linear address, low 16 bits (l)
|-
! $4C
| [[DMA#Sound DMA|SDMA Source Address High]]
| style="text-align: right" | <tt style="white-space: nowrap">.... hhhh</tt>
| RW8
| Linear address, high 4 bits (h)
|-
! $4E
| [[DMA#Sound DMA|SDMA Length Low]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll llll llll</tt>
| RW16
| Length, low 16 bits (l)
|-
! $50
| [[DMA#Sound DMA|SDMA Length High]]
| style="text-align: right" | <tt style="white-space: nowrap">.... hhhh</tt>
| RW8
| Length, high 4 bits (h)
|-
! $52
| [[DMA#Sound DMA|SDMA Control]]
| style="text-align: right" | <tt style="white-space: nowrap">ed.t r?ff</tt>
| RW8
| Enable (e), Decrement (d), Target (t),
Repeat (r), Frequency (f)
|-
! rowspan="2" | System<sup>(color)</sup>
! $60
| System Control 2
| style="text-align: right" | <tt style="white-space: nowrap">c4C. ?.??</tt>
| RW8
| Color (c), 4BPP (4), Chunky (C)
|-
! $62
| System Control 3
| style="text-align: right" | <tt style="white-space: nowrap">S... ...p</tt>
| RW8
| SwanCrystal (S), Power off (p)
|-
! rowspan="5" | [[Hyper Voice]]<sup>(color)</sup>
! $64
| Hyper Voice Left Output
| style="text-align: right" | <tt style="white-space: nowrap">ssss ssss ssss ssss</tt>
| W16
| Raw sample (s)
|-
! $66
| Hyper Voice Right Output
| style="text-align: right" | <tt style="white-space: nowrap">ssss ssss ssss ssss</tt>
| W16
| Raw sample (s)
|-
! $68
| Hyper Voice Left Input
| style="text-align: right" | <tt style="white-space: nowrap">ssss ssss</tt>
| 8
| Sample (s)
|-
! $69
| Hyper Voice Right Input
| style="text-align: right" | <tt style="white-space: nowrap">ssss ssss</tt>
| 8
| Sample (s)
|-
! $6A
| Hyper Voice Control
| style="text-align: right" | <tt style="white-space: nowrap">.mmc .... errr ffss</tt>
| RW16
| Mask (m), Channel (c), Enable (e),
Rate (r), Format (f), Shift (s)
|-
! rowspan="8" | [[Display]]<sup>(SC)</sup>
! $70
| LCD Timing Configuration 1?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $71
| LCD Timing Configuration 2?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $72
| LCD Timing Configuration 3?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $73
| LCD Timing Configuration 4?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $74
| LCD Timing Configuration 5?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $75
| LCD Timing Configuration 6?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $76
| LCD Timing Configuration 7?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $77
| LCD Timing Configuration 8?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! rowspan="20" | [[Sound]]
! $80
| [[Sound#Sound Channel Frequency|Sound Channel 1 Frequency]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .ddd dddd dddd</tt>
| RW16
| Divider (d)
|-
! $82
| [[Sound#Sound Channel Frequency|Sound Channel 2 Frequency]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .ddd dddd dddd</tt>
| RW16
| Divider (d)
|-
! $84
| [[Sound#Sound Channel Frequency|Sound Channel 3 Frequency]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .ddd dddd dddd</tt>
| RW16
| Divider (d)
|-
! $86
| [[Sound#Sound Channel Frequency|Sound Channel 4 Frequency]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .ddd dddd dddd</tt>
| RW16
| Divider (d)
|-
! $88
| [[Sound#Sound Channel Volume|Sound Channel 1 Volume]]
| style="text-align: right" | <tt style="white-space: nowrap">llll rrrr</tt>
| RW8
| Left (l), Right (r)
|-
! rowspan="2" | $89
| [[Sound#Sound Channel Volume|Sound Channel 2 Volume]]
| style="text-align: right" | <tt style="white-space: nowrap">llll rrrr</tt>
| RW8
| Left (l), Right (r)
|-
| [[Sound#Sound Channel 2 Voice Sample|Sound Channel 2 Voice Sample]]
| style="text-align: right" | <tt style="white-space: nowrap">ssss ssss</tt>
| RW8
| Sample (s)
|-
! $8A
| [[Sound#Sound Channel Volume|Sound Channel 3 Volume]]
| style="text-align: right" | <tt style="white-space: nowrap">llll rrrr</tt>
| RW8
| Left (l), Right (r)
|-
! $8B
| [[Sound#Sound Channel Volume|Sound Channel 4 Volume]]
| style="text-align: right" | <tt style="white-space: nowrap">llll rrrr</tt>
| RW8
| Left (l), Right (r)
|-
! $8C
| [[Sound#Sound Channel 3 Sweep Amount|Sound Channel 3 Sweep Amount]
| style="text-align: right" | <tt style="white-space: nowrap">vvvv vvvv</tt>
| RW8
| Value (v)
|-
! $8D
| [[Sound#Sound Channel 3 Sweep Ticks|Sound Channel 3 Sweep Ticks]]
| style="text-align: right" | <tt style="white-space: nowrap">...t tttt</tt>
| RW8
| Ticks (t)
|-
! $8E
| [[Sound#Sound Channel 4 Noise Control|Sound Channel 4 Noise Control]]
| style="text-align: right" | <tt style="white-space: nowrap">...e rttt</tt>
| RW8
| Enable (e), Reset (r), Tap (t)
|-
! $8F
| [[Sound#Sound Wavetable Address|Sound Wavetable Address]]
| style="text-align: right" | <tt style="white-space: nowrap">wwww wwww</tt>
| RW8
| Address >> 6 (w)
|-
! $90
| [[Sound#Sound Channel Control|Sound Channel Control]]
| style="text-align: right" | <tt style="white-space: nowrap">nsv. 4321</tt>
| RW8
| Channel enable (1234)
Noise (n), Sweep (s), Voice (v)
|-
! $91
| [[Sound#Sound Output Control|Sound Output Control]]
| style="text-align: right" | <tt style="white-space: nowrap">H... hrrs</tt>
| RW8
| Headphones connected (H)
Headphone output (h)
Speaker output (s), range (r)
|-
! $92
| [[Sound#Sound Channel 4 LFSR Register|Sound Channel 4 LFSR Register]]
| style="text-align: right" | <tt style="white-space: nowrap">.rrr rrrr rrrr rrrr</tt>
| R16
| PRNG state (r)
|-
! $94
| [[Sound#Sound Channel 2 Voice Volume|Sound Channel 2 Voice Volume]]
| style="text-align: right" | <tt style="white-space: nowrap">.... lLrR</tt>
| RW8
| Left Half (l), Full (L)
Right Half (r), Full (R)
|-
! $96
| Sound Channel Output Right
| style="text-align: right" | <tt style="white-space: nowrap">.... ..ss ssss ssss</tt>
| R16
| Sample (s)
|-
! $98
| Sound Channel Output Left
| style="text-align: right" | <tt style="white-space: nowrap">.... ..ss ssss ssss</tt>
| R16
| Sample (s)
|-
! $9A
| Sound Channel Output Sum
| style="text-align: right" | <tt style="white-space: nowrap">.... .sss ssss ssss</tt>
| R16
| Sample (s)
|-
! System
! $A0
| System Control
| style="text-align: right" | <tt style="white-space: nowrap">t??? swcl</tt>
| RW8
| Test OK (t), ROM speed (s), ROM width (w),
Color system (c), Boot ROM lockout (l)
|-
! rowspan="5" | [[Timers]]
! $A2
| [[Timers#Timer Control|Timer Control]]
| style="text-align: right" | <tt style="white-space: nowrap">.... VvHh</tt>
| RW8
| Horizontal enable (h), auto reload (H)
Vertical enable (v), auto reload (V)
|-
! $A4
| [[Timers#Timer Reload|Horizontal Blank Timer Reload]]
| style="text-align: right" | <tt style="white-space: nowrap">tttt tttt tttt tttt</tt>
| RW16
| Ticks (t)
|-
! $A6
| [[Timers#Timer Reload|Vertical Blank Timer Reload]]
| style="text-align: right" | <tt style="white-space: nowrap">tttt tttt tttt tttt</tt>
| RW16
| Ticks (t)
|-
! $A8
| [[Timers#Timer Counter|Horizontal Blank Timer Counter]]
| style="text-align: right" | <tt style="white-space: nowrap">tttt tttt tttt tttt</tt>
| R16
| Ticks (t)
|-
! $AA
| [[Timers#Timer Counter|Vertical Blank Timer Counter]]
| style="text-align: right" | <tt style="white-space: nowrap">tttt tttt tttt tttt</tt>
| R16
| Ticks (t)
|-
! [[Interrupts]]
! $B0
| [[Interrupts#Interrupt Vector|Interrupt Vector]]
| style="text-align: right" | <tt style="white-space: nowrap">VVVV V...</tt>
| RW8
| Vector offset (v)
|-
! [[UART]]
! $B1
| [[UART#serial Data|Serial Data]]
| style="text-align: right" | <tt style="white-space: nowrap">dddd dddd</tt>
| RW8
| Data (d)
|-
! [[Interrupts]]
! $B2
| [[Interrupts#Interrupt Enable|Interrupt Enable]]
| iiii iiii
| RW8
| Interrupt index (i)
|-
! [[UART]]
! $B3
| [[UART#Serial Control|Serial Control]]
| style="text-align: right" | <tt style="white-space: nowrap">ebO. .tor</tt>
| RW8
| Enable (e), Baud rate (b), Reset Overrun (O),
Transfer ready (t), Overrun (o), Receive ready (r)
|-
! [[Interrupts]]
! $B4
| [[Interrupts#Interrupt Status|Interrupt Status]]
| iiii iiii
| R8
| Interrupt index (i)
|-
! [[Keypad]]
! $B5
| [[Keypad|Keypad Scan]]
| style="text-align: right" | <tt style="white-space: nowrap">.iii oooo</tt>
| RW8
| Input row (i), Output column (o)
|-
! rowspan="2" | [[Interrupts]]
! $B6
| [[Interrupts#Interrupt Acknowledge|Interrupt Acknowledge]]
| iiii iiii
| R8?
| Interrupt index (i)
|-
! $B7
| [[Interrupts#Interrupt NMI Control|Interrupt NMI Control]]
| style="text-align: right" | <tt style="white-space: nowrap">...b ....</tt>
| RW8
| Low battery (b)
|-
! rowspan="3" | Internal EEPROM
! $BA
| Internal EEPROM Data
| style="text-align: right" | <tt style="white-space: nowrap">dddd dddd dddd dddd</tt>
| RW16
| Data (d)
|-
! $BC
| Internal EEPROM Command
|
| RW16
|
|-
! $BE
| Internal EEPROM Control
| style="text-align: right" | <tt style="white-space: nowrap">.... .... PEWR ..rd</tt>
| RW16
| Protect (P), Erase (E), Write (W), Read (R),
Ready (r), Done (d)
|-
! [[Mapper|Cartridge]]
! $C0<br />
$FF
| Cartridge I/O
|
|
| Forwarded by the SoC
|}
a8a41e3fc17cc26e90de382bac208d735b5ac017
102
101
2023-08-22T09:58:25Z
Asie
351
wikitext
text/x-wiki
* Superscripts are used to mark ports specific to a given mode or platform:
** Color mode: <sup>(color)</sup>.
** WS/WSC/SC console: <sup>(WS)</sup>, <sup>(WSC)</sup>, <sup>(SC)</sup>.
* If two Bits rows are provided, the second one refers to the "Color" mode.
* The Type can be: R - readable, W - writable, L - writable before boot ROM lockout, 8/16 - width (byte/word).
{| class="wikitable"
! Category
! Port
! Description
! Bits
! Type
! Notes
|-
! rowspan="45" | [[Display]]
! $00
| [[Display#Display Control|Display Control]]
| style="text-align: right" | <tt style="white-space: nowrap">..ow Ws21</tt>
| RW8
|
|-
! $01
| [[Display#Display Background|Display Background]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .sss</tt>
<tt style="white-space: nowrap">pppp iiii</tt>
| RW8
| Shade (s)
Palette (p), Index (i)
|-
! $02
| [[Display#Current Line|Display Current Line]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll</tt>
| R8
| Line (l)
|-
! $03
| [[Display#Interrupt Line|Display Interrupt Line]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll</tt>
| RW8
| Line (l)
|-
! $04
| [[Display#Sprite Table Address|Sprite Table Address]]
| style="text-align: right" | <tt style="white-space: nowrap">...a aaaa</tt>
<tt style="white-space: nowrap">..aa aaaa</tt>
| RW8
| Address >> 9 (a)
|-
! $05
| [[Display#Sprite Table First|Sprite Table First]]
| style="text-align: right" | <tt style="white-space: nowrap">.iii iiii</tt>
| RW8
| Index (i)
|-
! $06
| [[Display#Sprite Table Count|Sprite Table Count]]
| style="text-align: right" | <tt style="white-space: nowrap">cccc cccc</tt>
| RW8
| Count (c)
|-
! $07
| [[Display#Screen Address|Screen Address]]
| style="text-align: right" | <tt style="white-space: nowrap">.222 .111</tt>
<tt style="white-space: nowrap">2222 1111</tt>
| RW8
| Screen 1 address >> 11 (1)
Screen 2 address >> 11 (2)
|-
! $08
| [[Display#Screen 2 Window|Screen 2 Window Left]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $09
| [[Display#Screen 2 Window|Screen 2 Window Top]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $0A
| [[Display#Screen 2 Window|Screen 2 Window Right]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $0B
| [[Display#Screen 2 Window|Screen 2 Window Bottom]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $0B
| [[Display#Sprite Window|Sprite Window Left]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $0C
| [[Display#Sprite Window|Sprite Window Top]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $0E
| [[Display#Sprite Window|Sprite Window Right]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $0F
| [[Display#Sprite Window|Sprite Window Bottom]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $10
| [[Display#Screen Scroll|Screen 1 Scroll X]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $11
| [[Display#Screen Scroll|Screen 1 Scroll Y]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $12
| [[Display#Screen Scroll|Screen 2 Scroll X]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $13
| [[Display#Screen Scroll|Screen 2 Scroll Y]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $14
| [[Display#LCD Control|LCD Control]]
| style="text-align: right" | <tt style="white-space: nowrap">.... ..Ce</tt>
| RW8
| Contrast (C)<sup>(WSC)</sup>, Enable (e)
|-
! $15
| [[Display#LCD Icon Control|LCD Icon Control]]
| style="text-align: right" | <tt style="white-space: nowrap">..32 1hvs</tt>
| RW8
| Auxillary 3 (3), Auxillary 2 (2), Auxillary 1 (1),
Horizontal (h), Vertical (v), Sleep (s)
|-
! $16
| [[Display#LCD Final Line|LCD Final Line]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll</tt>
| RW8
| Line (l)
|-
! $17
| [[Display#LCD Back Porch Line|LCD Back Porch Line]]<sup>(WSC)</sup>
| style="text-align: right" | <tt style="white-space: nowrap">llll llll</tt>
| RW8
| Line (l)
|-
! $1A
| [[Display#LCD Status|LCD Status]]
| style="text-align: right" | <tt style="white-space: nowrap">...v vv.s</tt>
| RW8
| Volume segment status (v), Sleep (s)
|-
! $1C
| [[Display#LCD Mono Shade LUT|LCD Mono Shade LUT 0/1]]
| style="text-align: right" | <tt style="white-space: nowrap">1111 0000</tt>
| RW8
| Shade index
|-
! $1D
| [[Display#LCD Mono Shade LUT|LCD Mono Shade LUT 2/3]]
| style="text-align: right" | <tt style="white-space: nowrap">3333 2222</tt>
| RW8
| Shade index
|-
! $1E
| [[Display#LCD Mono Shade LUT|LCD Mono Shade LUT 4/5]]
| style="text-align: right" | <tt style="white-space: nowrap">5555 4444</tt>
| RW8
| Shade index
|-
! $1F
| [[Display#LCD Mono Shade LUT|LCD Mono Shade LUT 6/7]]
| style="text-align: right" | <tt style="white-space: nowrap">7777 6666</tt>
| RW8
| Shade index
|-
! $20
| [[Display#LCD Mono Palette|LCD Mono Palette 0]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $22
| [[Display#LCD Mono Palette|LCD Mono Palette 1]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $24
| [[Display#LCD Mono Palette|LCD Mono Palette 2]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $26
| [[Display#LCD Mono Palette|LCD Mono Palette 3]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $28
| [[Display#LCD Mono Palette|LCD Mono Palette 4]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $2A
| [[Display#LCD Mono Palette|LCD Mono Palette 5]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $2C
| [[Display#LCD Mono Palette|LCD Mono Palette 6]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $2E
| [[Display#LCD Mono Palette|LCD Mono Palette 7]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $30
| [[Display#LCD Mono Palette|LCD Mono Palette 8]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $32
| [[Display#LCD Mono Palette|LCD Mono Palette 9]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $34
| [[Display#LCD Mono Palette|LCD Mono Palette 10]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $36
| [[Display#LCD Mono Palette|LCD Mono Palette 11]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $38
| [[Display#LCD Mono Palette|LCD Mono Palette 12]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $3A
| [[Display#LCD Mono Palette|LCD Mono Palette 13]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $3C
| [[Display#LCD Mono Palette|LCD Mono Palette 14]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $3E
| [[Display#LCD Mono Palette|LCD Mono Palette 15]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! rowspan="10" | [[DMA]]<sup>(color)</sup>
! $40
| [[DMA#General DMA|GDMA Source Address Low]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll llll llll</tt>
| RW16
| Linear address, low 16 bits (l)
|-
! $42
| [[DMA#General DMA|GDMA Source Address High]]
| style="text-align: right" | <tt style="white-space: nowrap">.... hhhh</tt>
| RW8
| Linear address, high 4 bits (h)
|-
! $44
| [[DMA#General DMA|GDMA Destination Address]]
| style="text-align: right" | <tt style="white-space: nowrap">aaaa aaaa aaaa aaaa</tt>
| RW16
| IRAM address (a)
|-
! $46
| [[DMA#General DMA|GDMA Length]]
| style="text-align: right" | <tt style="white-space: nowrap">bbbb bbbb bbbb bbbb</tt>
| RW16
| Bytes (b)
|-
! $48
| [[DMA#General DMA|GDMA Control]]
| style="text-align: right" | <tt style="white-space: nowrap">ed.. ....</tt>
| RW8
| Enable (e), Decrement (d)
|-
! $4A
| [[DMA#Sound DMA|SDMA Source Address Low]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll llll llll</tt>
| RW16
| Linear address, low 16 bits (l)
|-
! $4C
| [[DMA#Sound DMA|SDMA Source Address High]]
| style="text-align: right" | <tt style="white-space: nowrap">.... hhhh</tt>
| RW8
| Linear address, high 4 bits (h)
|-
! $4E
| [[DMA#Sound DMA|SDMA Length Low]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll llll llll</tt>
| RW16
| Length, low 16 bits (l)
|-
! $50
| [[DMA#Sound DMA|SDMA Length High]]
| style="text-align: right" | <tt style="white-space: nowrap">.... hhhh</tt>
| RW8
| Length, high 4 bits (h)
|-
! $52
| [[DMA#Sound DMA|SDMA Control]]
| style="text-align: right" | <tt style="white-space: nowrap">ed.t r?ff</tt>
| RW8
| Enable (e), Decrement (d), Target (t),
Repeat (r), Frequency (f)
|-
! rowspan="2" | System<sup>(color)</sup>
! $60
| System Control 2
| style="text-align: right" | <tt style="white-space: nowrap">c4C. ?.??</tt>
| RW8
| Color (c), 4BPP (4), Chunky (C)
|-
! $62
| System Control 3
| style="text-align: right" | <tt style="white-space: nowrap">S... ...p</tt>
| RW8
| SwanCrystal (S), Power off (p)
|-
! rowspan="5" | [[Hyper Voice]]<sup>(color)</sup>
! $64
| Hyper Voice Left Output
| style="text-align: right" | <tt style="white-space: nowrap">ssss ssss ssss ssss</tt>
| W16
| Raw sample (s)
|-
! $66
| Hyper Voice Right Output
| style="text-align: right" | <tt style="white-space: nowrap">ssss ssss ssss ssss</tt>
| W16
| Raw sample (s)
|-
! $68
| Hyper Voice Left Input
| style="text-align: right" | <tt style="white-space: nowrap">ssss ssss</tt>
| 8
| Sample (s)
|-
! $69
| Hyper Voice Right Input
| style="text-align: right" | <tt style="white-space: nowrap">ssss ssss</tt>
| 8
| Sample (s)
|-
! $6A
| Hyper Voice Control
| style="text-align: right" | <tt style="white-space: nowrap">.mmc .... errr ffss</tt>
| RW16
| Mask (m), Channel (c), Enable (e),
Rate (r), Format (f), Shift (s)
|-
! rowspan="8" | [[Display]]<sup>(SC)</sup>
! $70
| LCD Timing Configuration 1?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $71
| LCD Timing Configuration 2?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $72
| LCD Timing Configuration 3?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $73
| LCD Timing Configuration 4?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $74
| LCD Timing Configuration 5?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $75
| LCD Timing Configuration 6?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $76
| LCD Timing Configuration 7?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $77
| LCD Timing Configuration 8?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! rowspan="20" | [[Sound]]
! $80
| [[Sound#Sound Channel Frequency|Sound Channel 1 Frequency]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .ddd dddd dddd</tt>
| RW16
| Divider (d)
|-
! $82
| [[Sound#Sound Channel Frequency|Sound Channel 2 Frequency]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .ddd dddd dddd</tt>
| RW16
| Divider (d)
|-
! $84
| [[Sound#Sound Channel Frequency|Sound Channel 3 Frequency]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .ddd dddd dddd</tt>
| RW16
| Divider (d)
|-
! $86
| [[Sound#Sound Channel Frequency|Sound Channel 4 Frequency]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .ddd dddd dddd</tt>
| RW16
| Divider (d)
|-
! $88
| [[Sound#Sound Channel Volume|Sound Channel 1 Volume]]
| style="text-align: right" | <tt style="white-space: nowrap">llll rrrr</tt>
| RW8
| Left (l), Right (r)
|-
! rowspan="2" | $89
| [[Sound#Sound Channel Volume|Sound Channel 2 Volume]]
| style="text-align: right" | <tt style="white-space: nowrap">llll rrrr</tt>
| RW8
| Left (l), Right (r)
|-
| [[Sound#Sound Channel 2 Voice Sample|Sound Channel 2 Voice Sample]]
| style="text-align: right" | <tt style="white-space: nowrap">ssss ssss</tt>
| RW8
| Sample (s)
|-
! $8A
| [[Sound#Sound Channel Volume|Sound Channel 3 Volume]]
| style="text-align: right" | <tt style="white-space: nowrap">llll rrrr</tt>
| RW8
| Left (l), Right (r)
|-
! $8B
| [[Sound#Sound Channel Volume|Sound Channel 4 Volume]]
| style="text-align: right" | <tt style="white-space: nowrap">llll rrrr</tt>
| RW8
| Left (l), Right (r)
|-
! $8C
| [[Sound#Sound Channel 3 Sweep Amount|Sound Channel 3 Sweep Amount]]
| style="text-align: right" | <tt style="white-space: nowrap">vvvv vvvv</tt>
| RW8
| Value (v)
|-
! $8D
| [[Sound#Sound Channel 3 Sweep Ticks|Sound Channel 3 Sweep Ticks]]
| style="text-align: right" | <tt style="white-space: nowrap">...t tttt</tt>
| RW8
| Ticks (t)
|-
! $8E
| [[Sound#Sound Channel 4 Noise Control|Sound Channel 4 Noise Control]]
| style="text-align: right" | <tt style="white-space: nowrap">...e rttt</tt>
| RW8
| Enable (e), Reset (r), Tap (t)
|-
! $8F
| [[Sound#Sound Wavetable Address|Sound Wavetable Address]]
| style="text-align: right" | <tt style="white-space: nowrap">wwww wwww</tt>
| RW8
| Address >> 6 (w)
|-
! $90
| [[Sound#Sound Channel Control|Sound Channel Control]]
| style="text-align: right" | <tt style="white-space: nowrap">nsv. 4321</tt>
| RW8
| Channel enable (1234)
Noise (n), Sweep (s), Voice (v)
|-
! $91
| [[Sound#Sound Output Control|Sound Output Control]]
| style="text-align: right" | <tt style="white-space: nowrap">H... hrrs</tt>
| RW8
| Headphones connected (H)
Headphone output (h)
Speaker output (s), range (r)
|-
! $92
| [[Sound#Sound Channel 4 LFSR Register|Sound Channel 4 LFSR Register]]
| style="text-align: right" | <tt style="white-space: nowrap">.rrr rrrr rrrr rrrr</tt>
| R16
| PRNG state (r)
|-
! $94
| [[Sound#Sound Channel 2 Voice Volume|Sound Channel 2 Voice Volume]]
| style="text-align: right" | <tt style="white-space: nowrap">.... lLrR</tt>
| RW8
| Left Half (l), Full (L)
Right Half (r), Full (R)
|-
! $96
| Sound Channel Output Right
| style="text-align: right" | <tt style="white-space: nowrap">.... ..ss ssss ssss</tt>
| R16
| Sample (s)
|-
! $98
| Sound Channel Output Left
| style="text-align: right" | <tt style="white-space: nowrap">.... ..ss ssss ssss</tt>
| R16
| Sample (s)
|-
! $9A
| Sound Channel Output Sum
| style="text-align: right" | <tt style="white-space: nowrap">.... .sss ssss ssss</tt>
| R16
| Sample (s)
|-
! System
! $A0
| System Control
| style="text-align: right" | <tt style="white-space: nowrap">t??? swcl</tt>
| RW8
| Test OK (t), ROM speed (s), ROM width (w),
Color system (c), Boot ROM lockout (l)
|-
! rowspan="5" | [[Timers]]
! $A2
| [[Timers#Timer Control|Timer Control]]
| style="text-align: right" | <tt style="white-space: nowrap">.... VvHh</tt>
| RW8
| Horizontal enable (h), auto reload (H)
Vertical enable (v), auto reload (V)
|-
! $A4
| [[Timers#Timer Reload|Horizontal Blank Timer Reload]]
| style="text-align: right" | <tt style="white-space: nowrap">tttt tttt tttt tttt</tt>
| RW16
| Ticks (t)
|-
! $A6
| [[Timers#Timer Reload|Vertical Blank Timer Reload]]
| style="text-align: right" | <tt style="white-space: nowrap">tttt tttt tttt tttt</tt>
| RW16
| Ticks (t)
|-
! $A8
| [[Timers#Timer Counter|Horizontal Blank Timer Counter]]
| style="text-align: right" | <tt style="white-space: nowrap">tttt tttt tttt tttt</tt>
| R16
| Ticks (t)
|-
! $AA
| [[Timers#Timer Counter|Vertical Blank Timer Counter]]
| style="text-align: right" | <tt style="white-space: nowrap">tttt tttt tttt tttt</tt>
| R16
| Ticks (t)
|-
! [[Interrupts]]
! $B0
| [[Interrupts#Interrupt Vector|Interrupt Vector]]
| style="text-align: right" | <tt style="white-space: nowrap">VVVV V...</tt>
| RW8
| Vector offset (v)
|-
! [[UART]]
! $B1
| [[UART#serial Data|Serial Data]]
| style="text-align: right" | <tt style="white-space: nowrap">dddd dddd</tt>
| RW8
| Data (d)
|-
! [[Interrupts]]
! $B2
| [[Interrupts#Interrupt Enable|Interrupt Enable]]
| iiii iiii
| RW8
| Interrupt index (i)
|-
! [[UART]]
! $B3
| [[UART#Serial Control|Serial Control]]
| style="text-align: right" | <tt style="white-space: nowrap">ebO. .tor</tt>
| RW8
| Enable (e), Baud rate (b), Reset Overrun (O),
Transfer ready (t), Overrun (o), Receive ready (r)
|-
! [[Interrupts]]
! $B4
| [[Interrupts#Interrupt Status|Interrupt Status]]
| iiii iiii
| R8
| Interrupt index (i)
|-
! [[Keypad]]
! $B5
| [[Keypad|Keypad Scan]]
| style="text-align: right" | <tt style="white-space: nowrap">.iii oooo</tt>
| RW8
| Input row (i), Output column (o)
|-
! rowspan="2" | [[Interrupts]]
! $B6
| [[Interrupts#Interrupt Acknowledge|Interrupt Acknowledge]]
| iiii iiii
| R8?
| Interrupt index (i)
|-
! $B7
| [[Interrupts#Interrupt NMI Control|Interrupt NMI Control]]
| style="text-align: right" | <tt style="white-space: nowrap">...b ....</tt>
| RW8
| Low battery (b)
|-
! rowspan="3" | Internal EEPROM
! $BA
| Internal EEPROM Data
| style="text-align: right" | <tt style="white-space: nowrap">dddd dddd dddd dddd</tt>
| RW16
| Data (d)
|-
! $BC
| Internal EEPROM Command
|
| RW16
|
|-
! $BE
| Internal EEPROM Control
| style="text-align: right" | <tt style="white-space: nowrap">.... .... PEWR ..rd</tt>
| RW16
| Protect (P), Erase (E), Write (W), Read (R),
Ready (r), Done (d)
|-
! [[Mapper|Cartridge]]
! $C0<br />
$FF
| Cartridge I/O
|
|
| Forwarded by the SoC
|}
37acd8dc350f521577baf03fc2f4dbc3c3d06cc3
115
102
2023-08-22T11:34:13Z
Fiskbit
37
Splits Serial Control into Status and Control.
wikitext
text/x-wiki
* Superscripts are used to mark ports specific to a given mode or platform:
** Color mode: <sup>(color)</sup>.
** WS/WSC/SC console: <sup>(WS)</sup>, <sup>(WSC)</sup>, <sup>(SC)</sup>.
* If two Bits rows are provided, the second one refers to the "Color" mode.
* The Type can be: R - readable, W - writable, L - writable before boot ROM lockout, 8/16 - width (byte/word).
{| class="wikitable"
! Category
! Port
! Description
! Bits
! Type
! Notes
|-
! rowspan="45" | [[Display]]
! $00
| [[Display#Display Control|Display Control]]
| style="text-align: right" | <tt style="white-space: nowrap">..ow Ws21</tt>
| RW8
|
|-
! $01
| [[Display#Display Background|Display Background]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .sss</tt>
<tt style="white-space: nowrap">pppp iiii</tt>
| RW8
| Shade (s)
Palette (p), Index (i)
|-
! $02
| [[Display#Current Line|Display Current Line]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll</tt>
| R8
| Line (l)
|-
! $03
| [[Display#Interrupt Line|Display Interrupt Line]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll</tt>
| RW8
| Line (l)
|-
! $04
| [[Display#Sprite Table Address|Sprite Table Address]]
| style="text-align: right" | <tt style="white-space: nowrap">...a aaaa</tt>
<tt style="white-space: nowrap">..aa aaaa</tt>
| RW8
| Address >> 9 (a)
|-
! $05
| [[Display#Sprite Table First|Sprite Table First]]
| style="text-align: right" | <tt style="white-space: nowrap">.iii iiii</tt>
| RW8
| Index (i)
|-
! $06
| [[Display#Sprite Table Count|Sprite Table Count]]
| style="text-align: right" | <tt style="white-space: nowrap">cccc cccc</tt>
| RW8
| Count (c)
|-
! $07
| [[Display#Screen Address|Screen Address]]
| style="text-align: right" | <tt style="white-space: nowrap">.222 .111</tt>
<tt style="white-space: nowrap">2222 1111</tt>
| RW8
| Screen 1 address >> 11 (1)
Screen 2 address >> 11 (2)
|-
! $08
| [[Display#Screen 2 Window|Screen 2 Window Left]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $09
| [[Display#Screen 2 Window|Screen 2 Window Top]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $0A
| [[Display#Screen 2 Window|Screen 2 Window Right]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $0B
| [[Display#Screen 2 Window|Screen 2 Window Bottom]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $0B
| [[Display#Sprite Window|Sprite Window Left]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $0C
| [[Display#Sprite Window|Sprite Window Top]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $0E
| [[Display#Sprite Window|Sprite Window Right]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $0F
| [[Display#Sprite Window|Sprite Window Bottom]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $10
| [[Display#Screen Scroll|Screen 1 Scroll X]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $11
| [[Display#Screen Scroll|Screen 1 Scroll Y]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $12
| [[Display#Screen Scroll|Screen 2 Scroll X]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $13
| [[Display#Screen Scroll|Screen 2 Scroll Y]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $14
| [[Display#LCD Control|LCD Control]]
| style="text-align: right" | <tt style="white-space: nowrap">.... ..Ce</tt>
| RW8
| Contrast (C)<sup>(WSC)</sup>, Enable (e)
|-
! $15
| [[Display#LCD Icon Control|LCD Icon Control]]
| style="text-align: right" | <tt style="white-space: nowrap">..32 1hvs</tt>
| RW8
| Auxillary 3 (3), Auxillary 2 (2), Auxillary 1 (1),
Horizontal (h), Vertical (v), Sleep (s)
|-
! $16
| [[Display#LCD Final Line|LCD Final Line]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll</tt>
| RW8
| Line (l)
|-
! $17
| [[Display#LCD Back Porch Line|LCD Back Porch Line]]<sup>(WSC)</sup>
| style="text-align: right" | <tt style="white-space: nowrap">llll llll</tt>
| RW8
| Line (l)
|-
! $1A
| [[Display#LCD Status|LCD Status]]
| style="text-align: right" | <tt style="white-space: nowrap">...v vv.s</tt>
| RW8
| Volume segment status (v), Sleep (s)
|-
! $1C
| [[Display#LCD Mono Shade LUT|LCD Mono Shade LUT 0/1]]
| style="text-align: right" | <tt style="white-space: nowrap">1111 0000</tt>
| RW8
| Shade index
|-
! $1D
| [[Display#LCD Mono Shade LUT|LCD Mono Shade LUT 2/3]]
| style="text-align: right" | <tt style="white-space: nowrap">3333 2222</tt>
| RW8
| Shade index
|-
! $1E
| [[Display#LCD Mono Shade LUT|LCD Mono Shade LUT 4/5]]
| style="text-align: right" | <tt style="white-space: nowrap">5555 4444</tt>
| RW8
| Shade index
|-
! $1F
| [[Display#LCD Mono Shade LUT|LCD Mono Shade LUT 6/7]]
| style="text-align: right" | <tt style="white-space: nowrap">7777 6666</tt>
| RW8
| Shade index
|-
! $20
| [[Display#LCD Mono Palette|LCD Mono Palette 0]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $22
| [[Display#LCD Mono Palette|LCD Mono Palette 1]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $24
| [[Display#LCD Mono Palette|LCD Mono Palette 2]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $26
| [[Display#LCD Mono Palette|LCD Mono Palette 3]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $28
| [[Display#LCD Mono Palette|LCD Mono Palette 4]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $2A
| [[Display#LCD Mono Palette|LCD Mono Palette 5]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $2C
| [[Display#LCD Mono Palette|LCD Mono Palette 6]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $2E
| [[Display#LCD Mono Palette|LCD Mono Palette 7]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $30
| [[Display#LCD Mono Palette|LCD Mono Palette 8]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $32
| [[Display#LCD Mono Palette|LCD Mono Palette 9]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $34
| [[Display#LCD Mono Palette|LCD Mono Palette 10]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $36
| [[Display#LCD Mono Palette|LCD Mono Palette 11]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $38
| [[Display#LCD Mono Palette|LCD Mono Palette 12]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $3A
| [[Display#LCD Mono Palette|LCD Mono Palette 13]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $3C
| [[Display#LCD Mono Palette|LCD Mono Palette 14]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $3E
| [[Display#LCD Mono Palette|LCD Mono Palette 15]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! rowspan="10" | [[DMA]]<sup>(color)</sup>
! $40
| [[DMA#General DMA|GDMA Source Address Low]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll llll llll</tt>
| RW16
| Linear address, low 16 bits (l)
|-
! $42
| [[DMA#General DMA|GDMA Source Address High]]
| style="text-align: right" | <tt style="white-space: nowrap">.... hhhh</tt>
| RW8
| Linear address, high 4 bits (h)
|-
! $44
| [[DMA#General DMA|GDMA Destination Address]]
| style="text-align: right" | <tt style="white-space: nowrap">aaaa aaaa aaaa aaaa</tt>
| RW16
| IRAM address (a)
|-
! $46
| [[DMA#General DMA|GDMA Length]]
| style="text-align: right" | <tt style="white-space: nowrap">bbbb bbbb bbbb bbbb</tt>
| RW16
| Bytes (b)
|-
! $48
| [[DMA#General DMA|GDMA Control]]
| style="text-align: right" | <tt style="white-space: nowrap">ed.. ....</tt>
| RW8
| Enable (e), Decrement (d)
|-
! $4A
| [[DMA#Sound DMA|SDMA Source Address Low]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll llll llll</tt>
| RW16
| Linear address, low 16 bits (l)
|-
! $4C
| [[DMA#Sound DMA|SDMA Source Address High]]
| style="text-align: right" | <tt style="white-space: nowrap">.... hhhh</tt>
| RW8
| Linear address, high 4 bits (h)
|-
! $4E
| [[DMA#Sound DMA|SDMA Length Low]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll llll llll</tt>
| RW16
| Length, low 16 bits (l)
|-
! $50
| [[DMA#Sound DMA|SDMA Length High]]
| style="text-align: right" | <tt style="white-space: nowrap">.... hhhh</tt>
| RW8
| Length, high 4 bits (h)
|-
! $52
| [[DMA#Sound DMA|SDMA Control]]
| style="text-align: right" | <tt style="white-space: nowrap">ed.t r?ff</tt>
| RW8
| Enable (e), Decrement (d), Target (t),
Repeat (r), Frequency (f)
|-
! rowspan="2" | System<sup>(color)</sup>
! $60
| System Control 2
| style="text-align: right" | <tt style="white-space: nowrap">c4C. ?.??</tt>
| RW8
| Color (c), 4BPP (4), Chunky (C)
|-
! $62
| System Control 3
| style="text-align: right" | <tt style="white-space: nowrap">S... ...p</tt>
| RW8
| SwanCrystal (S), Power off (p)
|-
! rowspan="5" | [[Hyper Voice]]<sup>(color)</sup>
! $64
| Hyper Voice Left Output
| style="text-align: right" | <tt style="white-space: nowrap">ssss ssss ssss ssss</tt>
| W16
| Raw sample (s)
|-
! $66
| Hyper Voice Right Output
| style="text-align: right" | <tt style="white-space: nowrap">ssss ssss ssss ssss</tt>
| W16
| Raw sample (s)
|-
! $68
| Hyper Voice Left Input
| style="text-align: right" | <tt style="white-space: nowrap">ssss ssss</tt>
| 8
| Sample (s)
|-
! $69
| Hyper Voice Right Input
| style="text-align: right" | <tt style="white-space: nowrap">ssss ssss</tt>
| 8
| Sample (s)
|-
! $6A
| Hyper Voice Control
| style="text-align: right" | <tt style="white-space: nowrap">.mmc .... errr ffss</tt>
| RW16
| Mask (m), Channel (c), Enable (e),
Rate (r), Format (f), Shift (s)
|-
! rowspan="8" | [[Display]]<sup>(SC)</sup>
! $70
| LCD Timing Configuration 1?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $71
| LCD Timing Configuration 2?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $72
| LCD Timing Configuration 3?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $73
| LCD Timing Configuration 4?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $74
| LCD Timing Configuration 5?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $75
| LCD Timing Configuration 6?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $76
| LCD Timing Configuration 7?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $77
| LCD Timing Configuration 8?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! rowspan="20" | [[Sound]]
! $80
| [[Sound#Sound Channel Frequency|Sound Channel 1 Frequency]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .ddd dddd dddd</tt>
| RW16
| Divider (d)
|-
! $82
| [[Sound#Sound Channel Frequency|Sound Channel 2 Frequency]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .ddd dddd dddd</tt>
| RW16
| Divider (d)
|-
! $84
| [[Sound#Sound Channel Frequency|Sound Channel 3 Frequency]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .ddd dddd dddd</tt>
| RW16
| Divider (d)
|-
! $86
| [[Sound#Sound Channel Frequency|Sound Channel 4 Frequency]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .ddd dddd dddd</tt>
| RW16
| Divider (d)
|-
! $88
| [[Sound#Sound Channel Volume|Sound Channel 1 Volume]]
| style="text-align: right" | <tt style="white-space: nowrap">llll rrrr</tt>
| RW8
| Left (l), Right (r)
|-
! rowspan="2" | $89
| [[Sound#Sound Channel Volume|Sound Channel 2 Volume]]
| style="text-align: right" | <tt style="white-space: nowrap">llll rrrr</tt>
| RW8
| Left (l), Right (r)
|-
| [[Sound#Sound Channel 2 Voice Sample|Sound Channel 2 Voice Sample]]
| style="text-align: right" | <tt style="white-space: nowrap">ssss ssss</tt>
| RW8
| Sample (s)
|-
! $8A
| [[Sound#Sound Channel Volume|Sound Channel 3 Volume]]
| style="text-align: right" | <tt style="white-space: nowrap">llll rrrr</tt>
| RW8
| Left (l), Right (r)
|-
! $8B
| [[Sound#Sound Channel Volume|Sound Channel 4 Volume]]
| style="text-align: right" | <tt style="white-space: nowrap">llll rrrr</tt>
| RW8
| Left (l), Right (r)
|-
! $8C
| [[Sound#Sound Channel 3 Sweep Amount|Sound Channel 3 Sweep Amount]]
| style="text-align: right" | <tt style="white-space: nowrap">vvvv vvvv</tt>
| RW8
| Value (v)
|-
! $8D
| [[Sound#Sound Channel 3 Sweep Ticks|Sound Channel 3 Sweep Ticks]]
| style="text-align: right" | <tt style="white-space: nowrap">...t tttt</tt>
| RW8
| Ticks (t)
|-
! $8E
| [[Sound#Sound Channel 4 Noise Control|Sound Channel 4 Noise Control]]
| style="text-align: right" | <tt style="white-space: nowrap">...e rttt</tt>
| RW8
| Enable (e), Reset (r), Tap (t)
|-
! $8F
| [[Sound#Sound Wavetable Address|Sound Wavetable Address]]
| style="text-align: right" | <tt style="white-space: nowrap">wwww wwww</tt>
| RW8
| Address >> 6 (w)
|-
! $90
| [[Sound#Sound Channel Control|Sound Channel Control]]
| style="text-align: right" | <tt style="white-space: nowrap">nsv. 4321</tt>
| RW8
| Channel enable (1234)
Noise (n), Sweep (s), Voice (v)
|-
! $91
| [[Sound#Sound Output Control|Sound Output Control]]
| style="text-align: right" | <tt style="white-space: nowrap">H... hrrs</tt>
| RW8
| Headphones connected (H)
Headphone output (h)
Speaker output (s), range (r)
|-
! $92
| [[Sound#Sound Channel 4 LFSR Register|Sound Channel 4 LFSR Register]]
| style="text-align: right" | <tt style="white-space: nowrap">.rrr rrrr rrrr rrrr</tt>
| R16
| PRNG state (r)
|-
! $94
| [[Sound#Sound Channel 2 Voice Volume|Sound Channel 2 Voice Volume]]
| style="text-align: right" | <tt style="white-space: nowrap">.... lLrR</tt>
| RW8
| Left Half (l), Full (L)
Right Half (r), Full (R)
|-
! $96
| Sound Channel Output Right
| style="text-align: right" | <tt style="white-space: nowrap">.... ..ss ssss ssss</tt>
| R16
| Sample (s)
|-
! $98
| Sound Channel Output Left
| style="text-align: right" | <tt style="white-space: nowrap">.... ..ss ssss ssss</tt>
| R16
| Sample (s)
|-
! $9A
| Sound Channel Output Sum
| style="text-align: right" | <tt style="white-space: nowrap">.... .sss ssss ssss</tt>
| R16
| Sample (s)
|-
! System
! $A0
| System Control
| style="text-align: right" | <tt style="white-space: nowrap">t??? swcl</tt>
| RW8
| Test OK (t), ROM speed (s), ROM width (w),
Color system (c), Boot ROM lockout (l)
|-
! rowspan="5" | [[Timers]]
! $A2
| [[Timers#Timer Control|Timer Control]]
| style="text-align: right" | <tt style="white-space: nowrap">.... VvHh</tt>
| RW8
| Horizontal enable (h), auto reload (H)
Vertical enable (v), auto reload (V)
|-
! $A4
| [[Timers#Timer Reload|Horizontal Blank Timer Reload]]
| style="text-align: right" | <tt style="white-space: nowrap">tttt tttt tttt tttt</tt>
| RW16
| Ticks (t)
|-
! $A6
| [[Timers#Timer Reload|Vertical Blank Timer Reload]]
| style="text-align: right" | <tt style="white-space: nowrap">tttt tttt tttt tttt</tt>
| RW16
| Ticks (t)
|-
! $A8
| [[Timers#Timer Counter|Horizontal Blank Timer Counter]]
| style="text-align: right" | <tt style="white-space: nowrap">tttt tttt tttt tttt</tt>
| R16
| Ticks (t)
|-
! $AA
| [[Timers#Timer Counter|Vertical Blank Timer Counter]]
| style="text-align: right" | <tt style="white-space: nowrap">tttt tttt tttt tttt</tt>
| R16
| Ticks (t)
|-
! [[Interrupts]]
! $B0
| [[Interrupts#Interrupt Vector|Interrupt Vector]]
| style="text-align: right" | <tt style="white-space: nowrap">VVVV V...</tt>
| RW8
| Vector offset (v)
|-
! [[UART]]
! $B1
| [[UART#serial Data|Serial Data]]
| style="text-align: right" | <tt style="white-space: nowrap">dddd dddd</tt>
| RW8
| Data (d)
|-
! [[Interrupts]]
! $B2
| [[Interrupts#Interrupt Enable|Interrupt Enable]]
| iiii iiii
| RW8
| Interrupt index (i)
|-
! rowspan="2" | [[UART]]
! $B3
| [[UART#Serial Status|Serial Status]]
| style="text-align: right" | <tt style="white-space: nowrap">eb.. .tor</tt>
| R8
| Enable (e), Baud rate (b),
Transfer ready (t), Overrun (o), Receive ready (r)
|-
! $B3
| [[UART#Serial Control|Serial Control]]
| style="text-align: right" | <tt style="white-space: nowrap">ebO. ....</tt>
| W8
| Enable (e), Baud rate (b), Reset Overrun (O)
|-
! [[Interrupts]]
! $B4
| [[Interrupts#Interrupt Status|Interrupt Status]]
| iiii iiii
| R8
| Interrupt index (i)
|-
! [[Keypad]]
! $B5
| [[Keypad|Keypad Scan]]
| style="text-align: right" | <tt style="white-space: nowrap">.iii oooo</tt>
| RW8
| Input row (i), Output column (o)
|-
! rowspan="2" | [[Interrupts]]
! $B6
| [[Interrupts#Interrupt Acknowledge|Interrupt Acknowledge]]
| iiii iiii
| R8?
| Interrupt index (i)
|-
! $B7
| [[Interrupts#Interrupt NMI Control|Interrupt NMI Control]]
| style="text-align: right" | <tt style="white-space: nowrap">...b ....</tt>
| RW8
| Low battery (b)
|-
! rowspan="3" | Internal EEPROM
! $BA
| Internal EEPROM Data
| style="text-align: right" | <tt style="white-space: nowrap">dddd dddd dddd dddd</tt>
| RW16
| Data (d)
|-
! $BC
| Internal EEPROM Command
|
| RW16
|
|-
! $BE
| Internal EEPROM Control
| style="text-align: right" | <tt style="white-space: nowrap">.... .... PEWR ..rd</tt>
| RW16
| Protect (P), Erase (E), Write (W), Read (R),
Ready (r), Done (d)
|-
! [[Mapper|Cartridge]]
! $C0<br />
$FF
| Cartridge I/O
|
|
| Forwarded by the SoC
|}
60e9d8f0e55f5d3883559756bbbd229ebb7f3c9c
124
115
2023-08-22T12:07:24Z
Fiskbit
37
Splits Serial Data into Serial Receive Data and Serial Transmit Data.
wikitext
text/x-wiki
* Superscripts are used to mark ports specific to a given mode or platform:
** Color mode: <sup>(color)</sup>.
** WS/WSC/SC console: <sup>(WS)</sup>, <sup>(WSC)</sup>, <sup>(SC)</sup>.
* If two Bits rows are provided, the second one refers to the "Color" mode.
* The Type can be: R - readable, W - writable, L - writable before boot ROM lockout, 8/16 - width (byte/word).
{| class="wikitable"
! Category
! Port
! Description
! Bits
! Type
! Notes
|-
! rowspan="45" | [[Display]]
! $00
| [[Display#Display Control|Display Control]]
| style="text-align: right" | <tt style="white-space: nowrap">..ow Ws21</tt>
| RW8
|
|-
! $01
| [[Display#Display Background|Display Background]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .sss</tt>
<tt style="white-space: nowrap">pppp iiii</tt>
| RW8
| Shade (s)
Palette (p), Index (i)
|-
! $02
| [[Display#Current Line|Display Current Line]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll</tt>
| R8
| Line (l)
|-
! $03
| [[Display#Interrupt Line|Display Interrupt Line]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll</tt>
| RW8
| Line (l)
|-
! $04
| [[Display#Sprite Table Address|Sprite Table Address]]
| style="text-align: right" | <tt style="white-space: nowrap">...a aaaa</tt>
<tt style="white-space: nowrap">..aa aaaa</tt>
| RW8
| Address >> 9 (a)
|-
! $05
| [[Display#Sprite Table First|Sprite Table First]]
| style="text-align: right" | <tt style="white-space: nowrap">.iii iiii</tt>
| RW8
| Index (i)
|-
! $06
| [[Display#Sprite Table Count|Sprite Table Count]]
| style="text-align: right" | <tt style="white-space: nowrap">cccc cccc</tt>
| RW8
| Count (c)
|-
! $07
| [[Display#Screen Address|Screen Address]]
| style="text-align: right" | <tt style="white-space: nowrap">.222 .111</tt>
<tt style="white-space: nowrap">2222 1111</tt>
| RW8
| Screen 1 address >> 11 (1)
Screen 2 address >> 11 (2)
|-
! $08
| [[Display#Screen 2 Window|Screen 2 Window Left]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $09
| [[Display#Screen 2 Window|Screen 2 Window Top]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $0A
| [[Display#Screen 2 Window|Screen 2 Window Right]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $0B
| [[Display#Screen 2 Window|Screen 2 Window Bottom]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $0B
| [[Display#Sprite Window|Sprite Window Left]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $0C
| [[Display#Sprite Window|Sprite Window Top]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $0E
| [[Display#Sprite Window|Sprite Window Right]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $0F
| [[Display#Sprite Window|Sprite Window Bottom]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $10
| [[Display#Screen Scroll|Screen 1 Scroll X]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $11
| [[Display#Screen Scroll|Screen 1 Scroll Y]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $12
| [[Display#Screen Scroll|Screen 2 Scroll X]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $13
| [[Display#Screen Scroll|Screen 2 Scroll Y]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $14
| [[Display#LCD Control|LCD Control]]
| style="text-align: right" | <tt style="white-space: nowrap">.... ..Ce</tt>
| RW8
| Contrast (C)<sup>(WSC)</sup>, Enable (e)
|-
! $15
| [[Display#LCD Icon Control|LCD Icon Control]]
| style="text-align: right" | <tt style="white-space: nowrap">..32 1hvs</tt>
| RW8
| Auxillary 3 (3), Auxillary 2 (2), Auxillary 1 (1),
Horizontal (h), Vertical (v), Sleep (s)
|-
! $16
| [[Display#LCD Final Line|LCD Final Line]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll</tt>
| RW8
| Line (l)
|-
! $17
| [[Display#LCD Back Porch Line|LCD Back Porch Line]]<sup>(WSC)</sup>
| style="text-align: right" | <tt style="white-space: nowrap">llll llll</tt>
| RW8
| Line (l)
|-
! $1A
| [[Display#LCD Status|LCD Status]]
| style="text-align: right" | <tt style="white-space: nowrap">...v vv.s</tt>
| RW8
| Volume segment status (v), Sleep (s)
|-
! $1C
| [[Display#LCD Mono Shade LUT|LCD Mono Shade LUT 0/1]]
| style="text-align: right" | <tt style="white-space: nowrap">1111 0000</tt>
| RW8
| Shade index
|-
! $1D
| [[Display#LCD Mono Shade LUT|LCD Mono Shade LUT 2/3]]
| style="text-align: right" | <tt style="white-space: nowrap">3333 2222</tt>
| RW8
| Shade index
|-
! $1E
| [[Display#LCD Mono Shade LUT|LCD Mono Shade LUT 4/5]]
| style="text-align: right" | <tt style="white-space: nowrap">5555 4444</tt>
| RW8
| Shade index
|-
! $1F
| [[Display#LCD Mono Shade LUT|LCD Mono Shade LUT 6/7]]
| style="text-align: right" | <tt style="white-space: nowrap">7777 6666</tt>
| RW8
| Shade index
|-
! $20
| [[Display#LCD Mono Palette|LCD Mono Palette 0]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $22
| [[Display#LCD Mono Palette|LCD Mono Palette 1]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $24
| [[Display#LCD Mono Palette|LCD Mono Palette 2]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $26
| [[Display#LCD Mono Palette|LCD Mono Palette 3]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $28
| [[Display#LCD Mono Palette|LCD Mono Palette 4]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $2A
| [[Display#LCD Mono Palette|LCD Mono Palette 5]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $2C
| [[Display#LCD Mono Palette|LCD Mono Palette 6]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $2E
| [[Display#LCD Mono Palette|LCD Mono Palette 7]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $30
| [[Display#LCD Mono Palette|LCD Mono Palette 8]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $32
| [[Display#LCD Mono Palette|LCD Mono Palette 9]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $34
| [[Display#LCD Mono Palette|LCD Mono Palette 10]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $36
| [[Display#LCD Mono Palette|LCD Mono Palette 11]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $38
| [[Display#LCD Mono Palette|LCD Mono Palette 12]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $3A
| [[Display#LCD Mono Palette|LCD Mono Palette 13]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $3C
| [[Display#LCD Mono Palette|LCD Mono Palette 14]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $3E
| [[Display#LCD Mono Palette|LCD Mono Palette 15]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! rowspan="10" | [[DMA]]<sup>(color)</sup>
! $40
| [[DMA#General DMA|GDMA Source Address Low]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll llll llll</tt>
| RW16
| Linear address, low 16 bits (l)
|-
! $42
| [[DMA#General DMA|GDMA Source Address High]]
| style="text-align: right" | <tt style="white-space: nowrap">.... hhhh</tt>
| RW8
| Linear address, high 4 bits (h)
|-
! $44
| [[DMA#General DMA|GDMA Destination Address]]
| style="text-align: right" | <tt style="white-space: nowrap">aaaa aaaa aaaa aaaa</tt>
| RW16
| IRAM address (a)
|-
! $46
| [[DMA#General DMA|GDMA Length]]
| style="text-align: right" | <tt style="white-space: nowrap">bbbb bbbb bbbb bbbb</tt>
| RW16
| Bytes (b)
|-
! $48
| [[DMA#General DMA|GDMA Control]]
| style="text-align: right" | <tt style="white-space: nowrap">ed.. ....</tt>
| RW8
| Enable (e), Decrement (d)
|-
! $4A
| [[DMA#Sound DMA|SDMA Source Address Low]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll llll llll</tt>
| RW16
| Linear address, low 16 bits (l)
|-
! $4C
| [[DMA#Sound DMA|SDMA Source Address High]]
| style="text-align: right" | <tt style="white-space: nowrap">.... hhhh</tt>
| RW8
| Linear address, high 4 bits (h)
|-
! $4E
| [[DMA#Sound DMA|SDMA Length Low]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll llll llll</tt>
| RW16
| Length, low 16 bits (l)
|-
! $50
| [[DMA#Sound DMA|SDMA Length High]]
| style="text-align: right" | <tt style="white-space: nowrap">.... hhhh</tt>
| RW8
| Length, high 4 bits (h)
|-
! $52
| [[DMA#Sound DMA|SDMA Control]]
| style="text-align: right" | <tt style="white-space: nowrap">ed.t r?ff</tt>
| RW8
| Enable (e), Decrement (d), Target (t),
Repeat (r), Frequency (f)
|-
! rowspan="2" | System<sup>(color)</sup>
! $60
| System Control 2
| style="text-align: right" | <tt style="white-space: nowrap">c4C. ?.??</tt>
| RW8
| Color (c), 4BPP (4), Chunky (C)
|-
! $62
| System Control 3
| style="text-align: right" | <tt style="white-space: nowrap">S... ...p</tt>
| RW8
| SwanCrystal (S), Power off (p)
|-
! rowspan="5" | [[Hyper Voice]]<sup>(color)</sup>
! $64
| Hyper Voice Left Output
| style="text-align: right" | <tt style="white-space: nowrap">ssss ssss ssss ssss</tt>
| W16
| Raw sample (s)
|-
! $66
| Hyper Voice Right Output
| style="text-align: right" | <tt style="white-space: nowrap">ssss ssss ssss ssss</tt>
| W16
| Raw sample (s)
|-
! $68
| Hyper Voice Left Input
| style="text-align: right" | <tt style="white-space: nowrap">ssss ssss</tt>
| 8
| Sample (s)
|-
! $69
| Hyper Voice Right Input
| style="text-align: right" | <tt style="white-space: nowrap">ssss ssss</tt>
| 8
| Sample (s)
|-
! $6A
| Hyper Voice Control
| style="text-align: right" | <tt style="white-space: nowrap">.mmc .... errr ffss</tt>
| RW16
| Mask (m), Channel (c), Enable (e),
Rate (r), Format (f), Shift (s)
|-
! rowspan="8" | [[Display]]<sup>(SC)</sup>
! $70
| LCD Timing Configuration 1?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $71
| LCD Timing Configuration 2?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $72
| LCD Timing Configuration 3?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $73
| LCD Timing Configuration 4?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $74
| LCD Timing Configuration 5?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $75
| LCD Timing Configuration 6?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $76
| LCD Timing Configuration 7?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $77
| LCD Timing Configuration 8?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! rowspan="20" | [[Sound]]
! $80
| [[Sound#Sound Channel Frequency|Sound Channel 1 Frequency]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .ddd dddd dddd</tt>
| RW16
| Divider (d)
|-
! $82
| [[Sound#Sound Channel Frequency|Sound Channel 2 Frequency]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .ddd dddd dddd</tt>
| RW16
| Divider (d)
|-
! $84
| [[Sound#Sound Channel Frequency|Sound Channel 3 Frequency]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .ddd dddd dddd</tt>
| RW16
| Divider (d)
|-
! $86
| [[Sound#Sound Channel Frequency|Sound Channel 4 Frequency]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .ddd dddd dddd</tt>
| RW16
| Divider (d)
|-
! $88
| [[Sound#Sound Channel Volume|Sound Channel 1 Volume]]
| style="text-align: right" | <tt style="white-space: nowrap">llll rrrr</tt>
| RW8
| Left (l), Right (r)
|-
! rowspan="2" | $89
| [[Sound#Sound Channel Volume|Sound Channel 2 Volume]]
| style="text-align: right" | <tt style="white-space: nowrap">llll rrrr</tt>
| RW8
| Left (l), Right (r)
|-
| [[Sound#Sound Channel 2 Voice Sample|Sound Channel 2 Voice Sample]]
| style="text-align: right" | <tt style="white-space: nowrap">ssss ssss</tt>
| RW8
| Sample (s)
|-
! $8A
| [[Sound#Sound Channel Volume|Sound Channel 3 Volume]]
| style="text-align: right" | <tt style="white-space: nowrap">llll rrrr</tt>
| RW8
| Left (l), Right (r)
|-
! $8B
| [[Sound#Sound Channel Volume|Sound Channel 4 Volume]]
| style="text-align: right" | <tt style="white-space: nowrap">llll rrrr</tt>
| RW8
| Left (l), Right (r)
|-
! $8C
| [[Sound#Sound Channel 3 Sweep Amount|Sound Channel 3 Sweep Amount]]
| style="text-align: right" | <tt style="white-space: nowrap">vvvv vvvv</tt>
| RW8
| Value (v)
|-
! $8D
| [[Sound#Sound Channel 3 Sweep Ticks|Sound Channel 3 Sweep Ticks]]
| style="text-align: right" | <tt style="white-space: nowrap">...t tttt</tt>
| RW8
| Ticks (t)
|-
! $8E
| [[Sound#Sound Channel 4 Noise Control|Sound Channel 4 Noise Control]]
| style="text-align: right" | <tt style="white-space: nowrap">...e rttt</tt>
| RW8
| Enable (e), Reset (r), Tap (t)
|-
! $8F
| [[Sound#Sound Wavetable Address|Sound Wavetable Address]]
| style="text-align: right" | <tt style="white-space: nowrap">wwww wwww</tt>
| RW8
| Address >> 6 (w)
|-
! $90
| [[Sound#Sound Channel Control|Sound Channel Control]]
| style="text-align: right" | <tt style="white-space: nowrap">nsv. 4321</tt>
| RW8
| Channel enable (1234)
Noise (n), Sweep (s), Voice (v)
|-
! $91
| [[Sound#Sound Output Control|Sound Output Control]]
| style="text-align: right" | <tt style="white-space: nowrap">H... hrrs</tt>
| RW8
| Headphones connected (H)
Headphone output (h)
Speaker output (s), range (r)
|-
! $92
| [[Sound#Sound Channel 4 LFSR Register|Sound Channel 4 LFSR Register]]
| style="text-align: right" | <tt style="white-space: nowrap">.rrr rrrr rrrr rrrr</tt>
| R16
| PRNG state (r)
|-
! $94
| [[Sound#Sound Channel 2 Voice Volume|Sound Channel 2 Voice Volume]]
| style="text-align: right" | <tt style="white-space: nowrap">.... lLrR</tt>
| RW8
| Left Half (l), Full (L)
Right Half (r), Full (R)
|-
! $96
| Sound Channel Output Right
| style="text-align: right" | <tt style="white-space: nowrap">.... ..ss ssss ssss</tt>
| R16
| Sample (s)
|-
! $98
| Sound Channel Output Left
| style="text-align: right" | <tt style="white-space: nowrap">.... ..ss ssss ssss</tt>
| R16
| Sample (s)
|-
! $9A
| Sound Channel Output Sum
| style="text-align: right" | <tt style="white-space: nowrap">.... .sss ssss ssss</tt>
| R16
| Sample (s)
|-
! System
! $A0
| System Control
| style="text-align: right" | <tt style="white-space: nowrap">t??? swcl</tt>
| RW8
| Test OK (t), ROM speed (s), ROM width (w),
Color system (c), Boot ROM lockout (l)
|-
! rowspan="5" | [[Timers]]
! $A2
| [[Timers#Timer Control|Timer Control]]
| style="text-align: right" | <tt style="white-space: nowrap">.... VvHh</tt>
| RW8
| Horizontal enable (h), auto reload (H)
Vertical enable (v), auto reload (V)
|-
! $A4
| [[Timers#Timer Reload|Horizontal Blank Timer Reload]]
| style="text-align: right" | <tt style="white-space: nowrap">tttt tttt tttt tttt</tt>
| RW16
| Ticks (t)
|-
! $A6
| [[Timers#Timer Reload|Vertical Blank Timer Reload]]
| style="text-align: right" | <tt style="white-space: nowrap">tttt tttt tttt tttt</tt>
| RW16
| Ticks (t)
|-
! $A8
| [[Timers#Timer Counter|Horizontal Blank Timer Counter]]
| style="text-align: right" | <tt style="white-space: nowrap">tttt tttt tttt tttt</tt>
| R16
| Ticks (t)
|-
! $AA
| [[Timers#Timer Counter|Vertical Blank Timer Counter]]
| style="text-align: right" | <tt style="white-space: nowrap">tttt tttt tttt tttt</tt>
| R16
| Ticks (t)
|-
! [[Interrupts]]
! $B0
| [[Interrupts#Interrupt Vector|Interrupt Vector]]
| style="text-align: right" | <tt style="white-space: nowrap">VVVV V...</tt>
| RW8
| Vector offset (v)
|-
! rowspan="2" | [[UART]]
! $B1
| [[UART#Serial Receive Data|Serial Receive Data]]
| style="text-align: right" | <tt style="white-space: nowrap">dddd dddd</tt>
| R8
| Data (d)
|-
! $B1
| [[UART#Serial Transmit Data|Serial Transmit Data]]
| style="text-align: right" | <tt style="white-space: nowrap">dddd dddd</tt>
| W8
| Data (d)
|-
! [[Interrupts]]
! $B2
| [[Interrupts#Interrupt Enable|Interrupt Enable]]
| iiii iiii
| RW8
| Interrupt index (i)
|-
! rowspan="2" | [[UART]]
! $B3
| [[UART#Serial Status|Serial Status]]
| style="text-align: right" | <tt style="white-space: nowrap">eb.. .tor</tt>
| R8
| Enable (e), Baud rate (b),
Transfer ready (t), Overrun (o), Receive ready (r)
|-
! $B3
| [[UART#Serial Control|Serial Control]]
| style="text-align: right" | <tt style="white-space: nowrap">ebO. ....</tt>
| W8
| Enable (e), Baud rate (b), Reset Overrun (O)
|-
! [[Interrupts]]
! $B4
| [[Interrupts#Interrupt Status|Interrupt Status]]
| iiii iiii
| R8
| Interrupt index (i)
|-
! [[Keypad]]
! $B5
| [[Keypad|Keypad Scan]]
| style="text-align: right" | <tt style="white-space: nowrap">.iii oooo</tt>
| RW8
| Input row (i), Output column (o)
|-
! rowspan="2" | [[Interrupts]]
! $B6
| [[Interrupts#Interrupt Acknowledge|Interrupt Acknowledge]]
| iiii iiii
| R8?
| Interrupt index (i)
|-
! $B7
| [[Interrupts#Interrupt NMI Control|Interrupt NMI Control]]
| style="text-align: right" | <tt style="white-space: nowrap">...b ....</tt>
| RW8
| Low battery (b)
|-
! rowspan="3" | Internal EEPROM
! $BA
| Internal EEPROM Data
| style="text-align: right" | <tt style="white-space: nowrap">dddd dddd dddd dddd</tt>
| RW16
| Data (d)
|-
! $BC
| Internal EEPROM Command
|
| RW16
|
|-
! $BE
| Internal EEPROM Control
| style="text-align: right" | <tt style="white-space: nowrap">.... .... PEWR ..rd</tt>
| RW16
| Protect (P), Erase (E), Write (W), Read (R),
Ready (r), Done (d)
|-
! [[Mapper|Cartridge]]
! $C0<br />
$FF
| Cartridge I/O
|
|
| Forwarded by the SoC
|}
8a8559dc8c973cd36b56b73817186d1c7173585d
126
124
2023-08-22T12:08:26Z
Fiskbit
37
More explicit Serial Data descriptions.
wikitext
text/x-wiki
* Superscripts are used to mark ports specific to a given mode or platform:
** Color mode: <sup>(color)</sup>.
** WS/WSC/SC console: <sup>(WS)</sup>, <sup>(WSC)</sup>, <sup>(SC)</sup>.
* If two Bits rows are provided, the second one refers to the "Color" mode.
* The Type can be: R - readable, W - writable, L - writable before boot ROM lockout, 8/16 - width (byte/word).
{| class="wikitable"
! Category
! Port
! Description
! Bits
! Type
! Notes
|-
! rowspan="45" | [[Display]]
! $00
| [[Display#Display Control|Display Control]]
| style="text-align: right" | <tt style="white-space: nowrap">..ow Ws21</tt>
| RW8
|
|-
! $01
| [[Display#Display Background|Display Background]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .sss</tt>
<tt style="white-space: nowrap">pppp iiii</tt>
| RW8
| Shade (s)
Palette (p), Index (i)
|-
! $02
| [[Display#Current Line|Display Current Line]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll</tt>
| R8
| Line (l)
|-
! $03
| [[Display#Interrupt Line|Display Interrupt Line]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll</tt>
| RW8
| Line (l)
|-
! $04
| [[Display#Sprite Table Address|Sprite Table Address]]
| style="text-align: right" | <tt style="white-space: nowrap">...a aaaa</tt>
<tt style="white-space: nowrap">..aa aaaa</tt>
| RW8
| Address >> 9 (a)
|-
! $05
| [[Display#Sprite Table First|Sprite Table First]]
| style="text-align: right" | <tt style="white-space: nowrap">.iii iiii</tt>
| RW8
| Index (i)
|-
! $06
| [[Display#Sprite Table Count|Sprite Table Count]]
| style="text-align: right" | <tt style="white-space: nowrap">cccc cccc</tt>
| RW8
| Count (c)
|-
! $07
| [[Display#Screen Address|Screen Address]]
| style="text-align: right" | <tt style="white-space: nowrap">.222 .111</tt>
<tt style="white-space: nowrap">2222 1111</tt>
| RW8
| Screen 1 address >> 11 (1)
Screen 2 address >> 11 (2)
|-
! $08
| [[Display#Screen 2 Window|Screen 2 Window Left]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $09
| [[Display#Screen 2 Window|Screen 2 Window Top]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $0A
| [[Display#Screen 2 Window|Screen 2 Window Right]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $0B
| [[Display#Screen 2 Window|Screen 2 Window Bottom]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $0B
| [[Display#Sprite Window|Sprite Window Left]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $0C
| [[Display#Sprite Window|Sprite Window Top]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $0E
| [[Display#Sprite Window|Sprite Window Right]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $0F
| [[Display#Sprite Window|Sprite Window Bottom]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $10
| [[Display#Screen Scroll|Screen 1 Scroll X]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $11
| [[Display#Screen Scroll|Screen 1 Scroll Y]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $12
| [[Display#Screen Scroll|Screen 2 Scroll X]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $13
| [[Display#Screen Scroll|Screen 2 Scroll Y]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $14
| [[Display#LCD Control|LCD Control]]
| style="text-align: right" | <tt style="white-space: nowrap">.... ..Ce</tt>
| RW8
| Contrast (C)<sup>(WSC)</sup>, Enable (e)
|-
! $15
| [[Display#LCD Icon Control|LCD Icon Control]]
| style="text-align: right" | <tt style="white-space: nowrap">..32 1hvs</tt>
| RW8
| Auxillary 3 (3), Auxillary 2 (2), Auxillary 1 (1),
Horizontal (h), Vertical (v), Sleep (s)
|-
! $16
| [[Display#LCD Final Line|LCD Final Line]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll</tt>
| RW8
| Line (l)
|-
! $17
| [[Display#LCD Back Porch Line|LCD Back Porch Line]]<sup>(WSC)</sup>
| style="text-align: right" | <tt style="white-space: nowrap">llll llll</tt>
| RW8
| Line (l)
|-
! $1A
| [[Display#LCD Status|LCD Status]]
| style="text-align: right" | <tt style="white-space: nowrap">...v vv.s</tt>
| RW8
| Volume segment status (v), Sleep (s)
|-
! $1C
| [[Display#LCD Mono Shade LUT|LCD Mono Shade LUT 0/1]]
| style="text-align: right" | <tt style="white-space: nowrap">1111 0000</tt>
| RW8
| Shade index
|-
! $1D
| [[Display#LCD Mono Shade LUT|LCD Mono Shade LUT 2/3]]
| style="text-align: right" | <tt style="white-space: nowrap">3333 2222</tt>
| RW8
| Shade index
|-
! $1E
| [[Display#LCD Mono Shade LUT|LCD Mono Shade LUT 4/5]]
| style="text-align: right" | <tt style="white-space: nowrap">5555 4444</tt>
| RW8
| Shade index
|-
! $1F
| [[Display#LCD Mono Shade LUT|LCD Mono Shade LUT 6/7]]
| style="text-align: right" | <tt style="white-space: nowrap">7777 6666</tt>
| RW8
| Shade index
|-
! $20
| [[Display#LCD Mono Palette|LCD Mono Palette 0]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $22
| [[Display#LCD Mono Palette|LCD Mono Palette 1]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $24
| [[Display#LCD Mono Palette|LCD Mono Palette 2]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $26
| [[Display#LCD Mono Palette|LCD Mono Palette 3]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $28
| [[Display#LCD Mono Palette|LCD Mono Palette 4]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $2A
| [[Display#LCD Mono Palette|LCD Mono Palette 5]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $2C
| [[Display#LCD Mono Palette|LCD Mono Palette 6]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $2E
| [[Display#LCD Mono Palette|LCD Mono Palette 7]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $30
| [[Display#LCD Mono Palette|LCD Mono Palette 8]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $32
| [[Display#LCD Mono Palette|LCD Mono Palette 9]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $34
| [[Display#LCD Mono Palette|LCD Mono Palette 10]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $36
| [[Display#LCD Mono Palette|LCD Mono Palette 11]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $38
| [[Display#LCD Mono Palette|LCD Mono Palette 12]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $3A
| [[Display#LCD Mono Palette|LCD Mono Palette 13]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $3C
| [[Display#LCD Mono Palette|LCD Mono Palette 14]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $3E
| [[Display#LCD Mono Palette|LCD Mono Palette 15]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! rowspan="10" | [[DMA]]<sup>(color)</sup>
! $40
| [[DMA#General DMA|GDMA Source Address Low]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll llll llll</tt>
| RW16
| Linear address, low 16 bits (l)
|-
! $42
| [[DMA#General DMA|GDMA Source Address High]]
| style="text-align: right" | <tt style="white-space: nowrap">.... hhhh</tt>
| RW8
| Linear address, high 4 bits (h)
|-
! $44
| [[DMA#General DMA|GDMA Destination Address]]
| style="text-align: right" | <tt style="white-space: nowrap">aaaa aaaa aaaa aaaa</tt>
| RW16
| IRAM address (a)
|-
! $46
| [[DMA#General DMA|GDMA Length]]
| style="text-align: right" | <tt style="white-space: nowrap">bbbb bbbb bbbb bbbb</tt>
| RW16
| Bytes (b)
|-
! $48
| [[DMA#General DMA|GDMA Control]]
| style="text-align: right" | <tt style="white-space: nowrap">ed.. ....</tt>
| RW8
| Enable (e), Decrement (d)
|-
! $4A
| [[DMA#Sound DMA|SDMA Source Address Low]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll llll llll</tt>
| RW16
| Linear address, low 16 bits (l)
|-
! $4C
| [[DMA#Sound DMA|SDMA Source Address High]]
| style="text-align: right" | <tt style="white-space: nowrap">.... hhhh</tt>
| RW8
| Linear address, high 4 bits (h)
|-
! $4E
| [[DMA#Sound DMA|SDMA Length Low]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll llll llll</tt>
| RW16
| Length, low 16 bits (l)
|-
! $50
| [[DMA#Sound DMA|SDMA Length High]]
| style="text-align: right" | <tt style="white-space: nowrap">.... hhhh</tt>
| RW8
| Length, high 4 bits (h)
|-
! $52
| [[DMA#Sound DMA|SDMA Control]]
| style="text-align: right" | <tt style="white-space: nowrap">ed.t r?ff</tt>
| RW8
| Enable (e), Decrement (d), Target (t),
Repeat (r), Frequency (f)
|-
! rowspan="2" | System<sup>(color)</sup>
! $60
| System Control 2
| style="text-align: right" | <tt style="white-space: nowrap">c4C. ?.??</tt>
| RW8
| Color (c), 4BPP (4), Chunky (C)
|-
! $62
| System Control 3
| style="text-align: right" | <tt style="white-space: nowrap">S... ...p</tt>
| RW8
| SwanCrystal (S), Power off (p)
|-
! rowspan="5" | [[Hyper Voice]]<sup>(color)</sup>
! $64
| Hyper Voice Left Output
| style="text-align: right" | <tt style="white-space: nowrap">ssss ssss ssss ssss</tt>
| W16
| Raw sample (s)
|-
! $66
| Hyper Voice Right Output
| style="text-align: right" | <tt style="white-space: nowrap">ssss ssss ssss ssss</tt>
| W16
| Raw sample (s)
|-
! $68
| Hyper Voice Left Input
| style="text-align: right" | <tt style="white-space: nowrap">ssss ssss</tt>
| 8
| Sample (s)
|-
! $69
| Hyper Voice Right Input
| style="text-align: right" | <tt style="white-space: nowrap">ssss ssss</tt>
| 8
| Sample (s)
|-
! $6A
| Hyper Voice Control
| style="text-align: right" | <tt style="white-space: nowrap">.mmc .... errr ffss</tt>
| RW16
| Mask (m), Channel (c), Enable (e),
Rate (r), Format (f), Shift (s)
|-
! rowspan="8" | [[Display]]<sup>(SC)</sup>
! $70
| LCD Timing Configuration 1?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $71
| LCD Timing Configuration 2?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $72
| LCD Timing Configuration 3?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $73
| LCD Timing Configuration 4?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $74
| LCD Timing Configuration 5?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $75
| LCD Timing Configuration 6?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $76
| LCD Timing Configuration 7?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $77
| LCD Timing Configuration 8?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! rowspan="20" | [[Sound]]
! $80
| [[Sound#Sound Channel Frequency|Sound Channel 1 Frequency]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .ddd dddd dddd</tt>
| RW16
| Divider (d)
|-
! $82
| [[Sound#Sound Channel Frequency|Sound Channel 2 Frequency]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .ddd dddd dddd</tt>
| RW16
| Divider (d)
|-
! $84
| [[Sound#Sound Channel Frequency|Sound Channel 3 Frequency]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .ddd dddd dddd</tt>
| RW16
| Divider (d)
|-
! $86
| [[Sound#Sound Channel Frequency|Sound Channel 4 Frequency]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .ddd dddd dddd</tt>
| RW16
| Divider (d)
|-
! $88
| [[Sound#Sound Channel Volume|Sound Channel 1 Volume]]
| style="text-align: right" | <tt style="white-space: nowrap">llll rrrr</tt>
| RW8
| Left (l), Right (r)
|-
! rowspan="2" | $89
| [[Sound#Sound Channel Volume|Sound Channel 2 Volume]]
| style="text-align: right" | <tt style="white-space: nowrap">llll rrrr</tt>
| RW8
| Left (l), Right (r)
|-
| [[Sound#Sound Channel 2 Voice Sample|Sound Channel 2 Voice Sample]]
| style="text-align: right" | <tt style="white-space: nowrap">ssss ssss</tt>
| RW8
| Sample (s)
|-
! $8A
| [[Sound#Sound Channel Volume|Sound Channel 3 Volume]]
| style="text-align: right" | <tt style="white-space: nowrap">llll rrrr</tt>
| RW8
| Left (l), Right (r)
|-
! $8B
| [[Sound#Sound Channel Volume|Sound Channel 4 Volume]]
| style="text-align: right" | <tt style="white-space: nowrap">llll rrrr</tt>
| RW8
| Left (l), Right (r)
|-
! $8C
| [[Sound#Sound Channel 3 Sweep Amount|Sound Channel 3 Sweep Amount]]
| style="text-align: right" | <tt style="white-space: nowrap">vvvv vvvv</tt>
| RW8
| Value (v)
|-
! $8D
| [[Sound#Sound Channel 3 Sweep Ticks|Sound Channel 3 Sweep Ticks]]
| style="text-align: right" | <tt style="white-space: nowrap">...t tttt</tt>
| RW8
| Ticks (t)
|-
! $8E
| [[Sound#Sound Channel 4 Noise Control|Sound Channel 4 Noise Control]]
| style="text-align: right" | <tt style="white-space: nowrap">...e rttt</tt>
| RW8
| Enable (e), Reset (r), Tap (t)
|-
! $8F
| [[Sound#Sound Wavetable Address|Sound Wavetable Address]]
| style="text-align: right" | <tt style="white-space: nowrap">wwww wwww</tt>
| RW8
| Address >> 6 (w)
|-
! $90
| [[Sound#Sound Channel Control|Sound Channel Control]]
| style="text-align: right" | <tt style="white-space: nowrap">nsv. 4321</tt>
| RW8
| Channel enable (1234)
Noise (n), Sweep (s), Voice (v)
|-
! $91
| [[Sound#Sound Output Control|Sound Output Control]]
| style="text-align: right" | <tt style="white-space: nowrap">H... hrrs</tt>
| RW8
| Headphones connected (H)
Headphone output (h)
Speaker output (s), range (r)
|-
! $92
| [[Sound#Sound Channel 4 LFSR Register|Sound Channel 4 LFSR Register]]
| style="text-align: right" | <tt style="white-space: nowrap">.rrr rrrr rrrr rrrr</tt>
| R16
| PRNG state (r)
|-
! $94
| [[Sound#Sound Channel 2 Voice Volume|Sound Channel 2 Voice Volume]]
| style="text-align: right" | <tt style="white-space: nowrap">.... lLrR</tt>
| RW8
| Left Half (l), Full (L)
Right Half (r), Full (R)
|-
! $96
| Sound Channel Output Right
| style="text-align: right" | <tt style="white-space: nowrap">.... ..ss ssss ssss</tt>
| R16
| Sample (s)
|-
! $98
| Sound Channel Output Left
| style="text-align: right" | <tt style="white-space: nowrap">.... ..ss ssss ssss</tt>
| R16
| Sample (s)
|-
! $9A
| Sound Channel Output Sum
| style="text-align: right" | <tt style="white-space: nowrap">.... .sss ssss ssss</tt>
| R16
| Sample (s)
|-
! System
! $A0
| System Control
| style="text-align: right" | <tt style="white-space: nowrap">t??? swcl</tt>
| RW8
| Test OK (t), ROM speed (s), ROM width (w),
Color system (c), Boot ROM lockout (l)
|-
! rowspan="5" | [[Timers]]
! $A2
| [[Timers#Timer Control|Timer Control]]
| style="text-align: right" | <tt style="white-space: nowrap">.... VvHh</tt>
| RW8
| Horizontal enable (h), auto reload (H)
Vertical enable (v), auto reload (V)
|-
! $A4
| [[Timers#Timer Reload|Horizontal Blank Timer Reload]]
| style="text-align: right" | <tt style="white-space: nowrap">tttt tttt tttt tttt</tt>
| RW16
| Ticks (t)
|-
! $A6
| [[Timers#Timer Reload|Vertical Blank Timer Reload]]
| style="text-align: right" | <tt style="white-space: nowrap">tttt tttt tttt tttt</tt>
| RW16
| Ticks (t)
|-
! $A8
| [[Timers#Timer Counter|Horizontal Blank Timer Counter]]
| style="text-align: right" | <tt style="white-space: nowrap">tttt tttt tttt tttt</tt>
| R16
| Ticks (t)
|-
! $AA
| [[Timers#Timer Counter|Vertical Blank Timer Counter]]
| style="text-align: right" | <tt style="white-space: nowrap">tttt tttt tttt tttt</tt>
| R16
| Ticks (t)
|-
! [[Interrupts]]
! $B0
| [[Interrupts#Interrupt Vector|Interrupt Vector]]
| style="text-align: right" | <tt style="white-space: nowrap">VVVV V...</tt>
| RW8
| Vector offset (v)
|-
! rowspan="2" | [[UART]]
! $B1
| [[UART#Serial Receive Data|Serial Receive Data]]
| style="text-align: right" | <tt style="white-space: nowrap">dddd dddd</tt>
| R8
| Receive buffer data (d)
|-
! $B1
| [[UART#Serial Transmit Data|Serial Transmit Data]]
| style="text-align: right" | <tt style="white-space: nowrap">dddd dddd</tt>
| W8
| Transmit buffer data (d)
|-
! [[Interrupts]]
! $B2
| [[Interrupts#Interrupt Enable|Interrupt Enable]]
| iiii iiii
| RW8
| Interrupt index (i)
|-
! rowspan="2" | [[UART]]
! $B3
| [[UART#Serial Status|Serial Status]]
| style="text-align: right" | <tt style="white-space: nowrap">eb.. .tor</tt>
| R8
| Enable (e), Baud rate (b),
Transfer ready (t), Overrun (o), Receive ready (r)
|-
! $B3
| [[UART#Serial Control|Serial Control]]
| style="text-align: right" | <tt style="white-space: nowrap">ebO. ....</tt>
| W8
| Enable (e), Baud rate (b), Reset Overrun (O)
|-
! [[Interrupts]]
! $B4
| [[Interrupts#Interrupt Status|Interrupt Status]]
| iiii iiii
| R8
| Interrupt index (i)
|-
! [[Keypad]]
! $B5
| [[Keypad|Keypad Scan]]
| style="text-align: right" | <tt style="white-space: nowrap">.iii oooo</tt>
| RW8
| Input row (i), Output column (o)
|-
! rowspan="2" | [[Interrupts]]
! $B6
| [[Interrupts#Interrupt Acknowledge|Interrupt Acknowledge]]
| iiii iiii
| R8?
| Interrupt index (i)
|-
! $B7
| [[Interrupts#Interrupt NMI Control|Interrupt NMI Control]]
| style="text-align: right" | <tt style="white-space: nowrap">...b ....</tt>
| RW8
| Low battery (b)
|-
! rowspan="3" | Internal EEPROM
! $BA
| Internal EEPROM Data
| style="text-align: right" | <tt style="white-space: nowrap">dddd dddd dddd dddd</tt>
| RW16
| Data (d)
|-
! $BC
| Internal EEPROM Command
|
| RW16
|
|-
! $BE
| Internal EEPROM Control
| style="text-align: right" | <tt style="white-space: nowrap">.... .... PEWR ..rd</tt>
| RW16
| Protect (P), Erase (E), Write (W), Read (R),
Ready (r), Done (d)
|-
! [[Mapper|Cartridge]]
! $C0<br />
$FF
| Cartridge I/O
|
|
| Forwarded by the SoC
|}
afc5e49e69423646bad0b59d4bd07f4e8ded65df
141
126
2023-08-22T12:46:58Z
Asie
351
wikitext
text/x-wiki
* Superscripts are used to mark ports specific to a given mode or platform:
** Color mode: <sup>(color)</sup>.
** WS/WSC/SC console: <sup>(WS)</sup>, <sup>(WSC)</sup>, <sup>(SC)</sup>.
* If two Bits rows are provided, the second one refers to the "Color" mode.
* The Type can be: R - readable, W - writable, L - writable before boot ROM lockout, 8/16 - width (byte/word).
{| class="wikitable"
! Category
! Port
! Description
! Bits
! Type
! Notes
|-
! rowspan="45" | [[Display]]
! $00
| [[Display#Display Control|Display Control]]
| style="text-align: right" | <tt style="white-space: nowrap">..ow Ws21</tt>
| RW8
|
|-
! $01
| [[Display#Display Background|Display Background]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .sss</tt>
<tt style="white-space: nowrap">pppp iiii</tt>
| RW8
| Shade (s)
Palette (p), Index (i)
|-
! $02
| [[Display#Current Line|Display Current Line]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll</tt>
| R8
| Line (l)
|-
! $03
| [[Display#Interrupt Line|Display Interrupt Line]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll</tt>
| RW8
| Line (l)
|-
! $04
| [[Display#Sprite Table Address|Sprite Table Address]]
| style="text-align: right" | <tt style="white-space: nowrap">...a aaaa</tt>
<tt style="white-space: nowrap">..aa aaaa</tt>
| RW8
| Address >> 9 (a)
|-
! $05
| [[Display#Sprite Table First|Sprite Table First]]
| style="text-align: right" | <tt style="white-space: nowrap">.iii iiii</tt>
| RW8
| Index (i)
|-
! $06
| [[Display#Sprite Table Count|Sprite Table Count]]
| style="text-align: right" | <tt style="white-space: nowrap">cccc cccc</tt>
| RW8
| Count (c)
|-
! $07
| [[Display#Screen Address|Screen Address]]
| style="text-align: right" | <tt style="white-space: nowrap">.222 .111</tt>
<tt style="white-space: nowrap">2222 1111</tt>
| RW8
| Screen 1 address >> 11 (1)
Screen 2 address >> 11 (2)
|-
! $08
| [[Display#Screen 2 Window|Screen 2 Window Left]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $09
| [[Display#Screen 2 Window|Screen 2 Window Top]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $0A
| [[Display#Screen 2 Window|Screen 2 Window Right]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $0B
| [[Display#Screen 2 Window|Screen 2 Window Bottom]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $0B
| [[Display#Sprite Window|Sprite Window Left]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $0C
| [[Display#Sprite Window|Sprite Window Top]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $0E
| [[Display#Sprite Window|Sprite Window Right]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $0F
| [[Display#Sprite Window|Sprite Window Bottom]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $10
| [[Display#Screen Scroll|Screen 1 Scroll X]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $11
| [[Display#Screen Scroll|Screen 1 Scroll Y]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $12
| [[Display#Screen Scroll|Screen 2 Scroll X]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $13
| [[Display#Screen Scroll|Screen 2 Scroll Y]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $14
| [[Display#LCD Control|LCD Control]]
| style="text-align: right" | <tt style="white-space: nowrap">.... ..Ce</tt>
| RW8
| Contrast (C)<sup>(WSC)</sup>, Enable (e)
|-
! $15
| [[Display#LCD Icon Control|LCD Icon Control]]
| style="text-align: right" | <tt style="white-space: nowrap">..32 1hvs</tt>
| RW8
| Auxillary 3 (3), Auxillary 2 (2), Auxillary 1 (1),
Horizontal (h), Vertical (v), Sleep (s)
|-
! $16
| [[Display#LCD Final Line|LCD Final Line]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll</tt>
| RW8
| Line (l)
|-
! $17
| [[Display#LCD Back Porch Line|LCD Back Porch Line]]<sup>(WSC)</sup>
| style="text-align: right" | <tt style="white-space: nowrap">llll llll</tt>
| RW8
| Line (l)
|-
! $1A
| [[Display#LCD Status|LCD Status]]
| style="text-align: right" | <tt style="white-space: nowrap">...v vv.s</tt>
| RW8
| Volume segment status (v), Sleep (s)
|-
! $1C
| [[Display#LCD Mono Shade LUT|LCD Mono Shade LUT 0/1]]
| style="text-align: right" | <tt style="white-space: nowrap">1111 0000</tt>
| RW8
| Shade index
|-
! $1D
| [[Display#LCD Mono Shade LUT|LCD Mono Shade LUT 2/3]]
| style="text-align: right" | <tt style="white-space: nowrap">3333 2222</tt>
| RW8
| Shade index
|-
! $1E
| [[Display#LCD Mono Shade LUT|LCD Mono Shade LUT 4/5]]
| style="text-align: right" | <tt style="white-space: nowrap">5555 4444</tt>
| RW8
| Shade index
|-
! $1F
| [[Display#LCD Mono Shade LUT|LCD Mono Shade LUT 6/7]]
| style="text-align: right" | <tt style="white-space: nowrap">7777 6666</tt>
| RW8
| Shade index
|-
! $20
| [[Display#LCD Mono Palette|LCD Mono Palette 0]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $22
| [[Display#LCD Mono Palette|LCD Mono Palette 1]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $24
| [[Display#LCD Mono Palette|LCD Mono Palette 2]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $26
| [[Display#LCD Mono Palette|LCD Mono Palette 3]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $28
| [[Display#LCD Mono Palette|LCD Mono Palette 4]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $2A
| [[Display#LCD Mono Palette|LCD Mono Palette 5]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $2C
| [[Display#LCD Mono Palette|LCD Mono Palette 6]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $2E
| [[Display#LCD Mono Palette|LCD Mono Palette 7]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $30
| [[Display#LCD Mono Palette|LCD Mono Palette 8]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $32
| [[Display#LCD Mono Palette|LCD Mono Palette 9]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $34
| [[Display#LCD Mono Palette|LCD Mono Palette 10]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $36
| [[Display#LCD Mono Palette|LCD Mono Palette 11]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $38
| [[Display#LCD Mono Palette|LCD Mono Palette 12]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $3A
| [[Display#LCD Mono Palette|LCD Mono Palette 13]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $3C
| [[Display#LCD Mono Palette|LCD Mono Palette 14]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $3E
| [[Display#LCD Mono Palette|LCD Mono Palette 15]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! rowspan="10" | [[DMA]]<sup>(color)</sup>
! $40
| [[DMA#General DMA|GDMA Source Address Low]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll llll llll</tt>
| RW16
| Linear address, low 16 bits (l)
|-
! $42
| [[DMA#General DMA|GDMA Source Address High]]
| style="text-align: right" | <tt style="white-space: nowrap">.... hhhh</tt>
| RW8
| Linear address, high 4 bits (h)
|-
! $44
| [[DMA#General DMA|GDMA Destination Address]]
| style="text-align: right" | <tt style="white-space: nowrap">aaaa aaaa aaaa aaaa</tt>
| RW16
| IRAM address (a)
|-
! $46
| [[DMA#General DMA|GDMA Length]]
| style="text-align: right" | <tt style="white-space: nowrap">bbbb bbbb bbbb bbbb</tt>
| RW16
| Bytes (b)
|-
! $48
| [[DMA#General DMA|GDMA Control]]
| style="text-align: right" | <tt style="white-space: nowrap">ed.. ....</tt>
| RW8
| Enable (e), Decrement (d)
|-
! $4A
| [[DMA#Sound DMA|SDMA Source Address Low]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll llll llll</tt>
| RW16
| Linear address, low 16 bits (l)
|-
! $4C
| [[DMA#Sound DMA|SDMA Source Address High]]
| style="text-align: right" | <tt style="white-space: nowrap">.... hhhh</tt>
| RW8
| Linear address, high 4 bits (h)
|-
! $4E
| [[DMA#Sound DMA|SDMA Length Low]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll llll llll</tt>
| RW16
| Length, low 16 bits (l)
|-
! $50
| [[DMA#Sound DMA|SDMA Length High]]
| style="text-align: right" | <tt style="white-space: nowrap">.... hhhh</tt>
| RW8
| Length, high 4 bits (h)
|-
! $52
| [[DMA#Sound DMA|SDMA Control]]
| style="text-align: right" | <tt style="white-space: nowrap">ed.t r?ff</tt>
| RW8
| Enable (e), Decrement (d), Target (t),
Repeat (r), Frequency (f)
|-
! rowspan="2" | System<sup>(color)</sup>
! $60
| System Control 2
| style="text-align: right" | <tt style="white-space: nowrap">c4C. ?.??</tt>
| RW8
| Color (c), 4BPP (4), Chunky (C)
|-
! $62
| System Control 3
| style="text-align: right" | <tt style="white-space: nowrap">S... ...p</tt>
| RW8
| SwanCrystal (S), Power off (p)
|-
! rowspan="5" | [[Hyper Voice]]<sup>(color)</sup>
! $64
| Hyper Voice Left Output
| style="text-align: right" | <tt style="white-space: nowrap">ssss ssss ssss ssss</tt>
| W16
| Raw sample (s)
|-
! $66
| Hyper Voice Right Output
| style="text-align: right" | <tt style="white-space: nowrap">ssss ssss ssss ssss</tt>
| W16
| Raw sample (s)
|-
! $68
| Hyper Voice Left Input
| style="text-align: right" | <tt style="white-space: nowrap">ssss ssss</tt>
| 8
| Sample (s)
|-
! $69
| Hyper Voice Right Input
| style="text-align: right" | <tt style="white-space: nowrap">ssss ssss</tt>
| 8
| Sample (s)
|-
! $6A
| Hyper Voice Control
| style="text-align: right" | <tt style="white-space: nowrap">.mmc .... errr ffss</tt>
| RW16
| Mask (m), Channel (c), Enable (e),
Rate (r), Format (f), Shift (s)
|-
! rowspan="8" | [[Display]]<sup>(SC)</sup>
! $70
| LCD Timing Configuration 1?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $71
| LCD Timing Configuration 2?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $72
| LCD Timing Configuration 3?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $73
| LCD Timing Configuration 4?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $74
| LCD Timing Configuration 5?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $75
| LCD Timing Configuration 6?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $76
| LCD Timing Configuration 7?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $77
| LCD Timing Configuration 8?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! rowspan="20" | [[Sound]]
! $80
| [[Sound#Sound Channel Frequency|Sound Channel 1 Frequency]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .ddd dddd dddd</tt>
| RW16
| Divider (d)
|-
! $82
| [[Sound#Sound Channel Frequency|Sound Channel 2 Frequency]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .ddd dddd dddd</tt>
| RW16
| Divider (d)
|-
! $84
| [[Sound#Sound Channel Frequency|Sound Channel 3 Frequency]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .ddd dddd dddd</tt>
| RW16
| Divider (d)
|-
! $86
| [[Sound#Sound Channel Frequency|Sound Channel 4 Frequency]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .ddd dddd dddd</tt>
| RW16
| Divider (d)
|-
! $88
| [[Sound#Sound Channel Volume|Sound Channel 1 Volume]]
| style="text-align: right" | <tt style="white-space: nowrap">llll rrrr</tt>
| RW8
| Left (l), Right (r)
|-
! rowspan="2" | $89
| [[Sound#Sound Channel Volume|Sound Channel 2 Volume]]
| style="text-align: right" | <tt style="white-space: nowrap">llll rrrr</tt>
| RW8
| Left (l), Right (r)
|-
| [[Sound#Sound Channel 2 Voice Sample|Sound Channel 2 Voice Sample]]
| style="text-align: right" | <tt style="white-space: nowrap">ssss ssss</tt>
| RW8
| Sample (s)
|-
! $8A
| [[Sound#Sound Channel Volume|Sound Channel 3 Volume]]
| style="text-align: right" | <tt style="white-space: nowrap">llll rrrr</tt>
| RW8
| Left (l), Right (r)
|-
! $8B
| [[Sound#Sound Channel Volume|Sound Channel 4 Volume]]
| style="text-align: right" | <tt style="white-space: nowrap">llll rrrr</tt>
| RW8
| Left (l), Right (r)
|-
! $8C
| [[Sound#Sound Channel 3 Sweep Amount|Sound Channel 3 Sweep Amount]]
| style="text-align: right" | <tt style="white-space: nowrap">vvvv vvvv</tt>
| RW8
| Value (v)
|-
! $8D
| [[Sound#Sound Channel 3 Sweep Ticks|Sound Channel 3 Sweep Ticks]]
| style="text-align: right" | <tt style="white-space: nowrap">...t tttt</tt>
| RW8
| Ticks (t)
|-
! $8E
| [[Sound#Sound Channel 4 Noise Control|Sound Channel 4 Noise Control]]
| style="text-align: right" | <tt style="white-space: nowrap">...e rttt</tt>
| RW8
| Enable (e), Reset (r), Tap (t)
|-
! $8F
| [[Sound#Sound Wavetable Address|Sound Wavetable Address]]
| style="text-align: right" | <tt style="white-space: nowrap">wwww wwww</tt>
| RW8
| Address >> 6 (w)
|-
! $90
| [[Sound#Sound Channel Control|Sound Channel Control]]
| style="text-align: right" | <tt style="white-space: nowrap">nsv. 4321</tt>
| RW8
| Channel enable (1234)
Noise (n), Sweep (s), Voice (v)
|-
! $91
| [[Sound#Sound Output Control|Sound Output Control]]
| style="text-align: right" | <tt style="white-space: nowrap">H... hrrs</tt>
| RW8
| Headphones connected (H)
Headphone output (h)
Speaker output (s), range (r)
|-
! $92
| [[Sound#Sound Channel 4 LFSR Register|Sound Channel 4 LFSR Register]]
| style="text-align: right" | <tt style="white-space: nowrap">.rrr rrrr rrrr rrrr</tt>
| R16
| PRNG state (r)
|-
! $94
| [[Sound#Sound Channel 2 Voice Volume|Sound Channel 2 Voice Volume]]
| style="text-align: right" | <tt style="white-space: nowrap">.... lLrR</tt>
| RW8
| Left Half (l), Full (L)
Right Half (r), Full (R)
|-
! $96
| Sound Channel Output Right
| style="text-align: right" | <tt style="white-space: nowrap">.... ..ss ssss ssss</tt>
| R16
| Sample (s)
|-
! $98
| Sound Channel Output Left
| style="text-align: right" | <tt style="white-space: nowrap">.... ..ss ssss ssss</tt>
| R16
| Sample (s)
|-
! $9A
| Sound Channel Output Sum
| style="text-align: right" | <tt style="white-space: nowrap">.... .sss ssss ssss</tt>
| R16
| Sample (s)
|-
| $9E
| Sound Speaker Master Volume<sup>(color)</sup>
| style="text-align: right" | <tt style="white-space: nowrap">.... ..vv</tt>
| R8
| ?
|-
! System
! $A0
| System Control
| style="text-align: right" | <tt style="white-space: nowrap">t??? swcl</tt>
| RW8
| Test OK (t), ROM speed (s), ROM width (w),
Color system (c), Boot ROM lockout (l)
|-
! rowspan="5" | [[Timers]]
! $A2
| [[Timers#Timer Control|Timer Control]]
| style="text-align: right" | <tt style="white-space: nowrap">.... VvHh</tt>
| RW8
| Horizontal enable (h), auto reload (H)
Vertical enable (v), auto reload (V)
|-
! $A4
| [[Timers#Timer Reload|Horizontal Blank Timer Reload]]
| style="text-align: right" | <tt style="white-space: nowrap">tttt tttt tttt tttt</tt>
| RW16
| Ticks (t)
|-
! $A6
| [[Timers#Timer Reload|Vertical Blank Timer Reload]]
| style="text-align: right" | <tt style="white-space: nowrap">tttt tttt tttt tttt</tt>
| RW16
| Ticks (t)
|-
! $A8
| [[Timers#Timer Counter|Horizontal Blank Timer Counter]]
| style="text-align: right" | <tt style="white-space: nowrap">tttt tttt tttt tttt</tt>
| R16
| Ticks (t)
|-
! $AA
| [[Timers#Timer Counter|Vertical Blank Timer Counter]]
| style="text-align: right" | <tt style="white-space: nowrap">tttt tttt tttt tttt</tt>
| R16
| Ticks (t)
|-
! [[Interrupts]]
! $B0
| [[Interrupts#Interrupt Vector|Interrupt Vector]]
| style="text-align: right" | <tt style="white-space: nowrap">VVVV V...</tt>
| RW8
| Vector offset (v)
|-
! rowspan="2" | [[UART]]
! $B1
| [[UART#Serial Receive Data|Serial Receive Data]]
| style="text-align: right" | <tt style="white-space: nowrap">dddd dddd</tt>
| R8
| Receive buffer data (d)
|-
! $B1
| [[UART#Serial Transmit Data|Serial Transmit Data]]
| style="text-align: right" | <tt style="white-space: nowrap">dddd dddd</tt>
| W8
| Transmit buffer data (d)
|-
! [[Interrupts]]
! $B2
| [[Interrupts#Interrupt Enable|Interrupt Enable]]
| iiii iiii
| RW8
| Interrupt index (i)
|-
! rowspan="2" | [[UART]]
! $B3
| [[UART#Serial Status|Serial Status]]
| style="text-align: right" | <tt style="white-space: nowrap">eb.. .tor</tt>
| R8
| Enable (e), Baud rate (b),
Transfer ready (t), Overrun (o), Receive ready (r)
|-
! $B3
| [[UART#Serial Control|Serial Control]]
| style="text-align: right" | <tt style="white-space: nowrap">ebO. ....</tt>
| W8
| Enable (e), Baud rate (b), Reset Overrun (O)
|-
! [[Interrupts]]
! $B4
| [[Interrupts#Interrupt Status|Interrupt Status]]
| iiii iiii
| R8
| Interrupt index (i)
|-
! [[Keypad]]
! $B5
| [[Keypad|Keypad Scan]]
| style="text-align: right" | <tt style="white-space: nowrap">.iii oooo</tt>
| RW8
| Input row (i), Output column (o)
|-
! rowspan="2" | [[Interrupts]]
! $B6
| [[Interrupts#Interrupt Acknowledge|Interrupt Acknowledge]]
| iiii iiii
| R8?
| Interrupt index (i)
|-
! $B7
| [[Interrupts#Interrupt NMI Control|Interrupt NMI Control]]
| style="text-align: right" | <tt style="white-space: nowrap">...b ....</tt>
| RW8
| Low battery (b)
|-
! rowspan="3" | Internal EEPROM
! $BA
| Internal EEPROM Data
| style="text-align: right" | <tt style="white-space: nowrap">dddd dddd dddd dddd</tt>
| RW16
| Data (d)
|-
! $BC
| Internal EEPROM Command
|
| RW16
|
|-
! $BE
| Internal EEPROM Control
| style="text-align: right" | <tt style="white-space: nowrap">.... .... PEWR ..rd</tt>
| RW16
| Protect (P), Erase (E), Write (W), Read (R),
Ready (r), Done (d)
|-
! [[Mapper|Cartridge]]
! $C0<br />
$FF
| Cartridge I/O
|
|
| Forwarded by the SoC
|}
8379a2abae9a8450ba981076ea738c8562dc72ff
142
141
2023-08-22T12:47:38Z
Asie
351
wikitext
text/x-wiki
* Superscripts are used to mark ports specific to a given mode or platform:
** Color mode: <sup>(color)</sup>.
** WS/WSC/SC console: <sup>(WS)</sup>, <sup>(WSC)</sup>, <sup>(SC)</sup>.
* If two Bits rows are provided, the second one refers to the "Color" mode.
* The Type can be: R - readable, W - writable, L - writable before boot ROM lockout, 8/16 - width (byte/word).
{| class="wikitable"
! Category
! Port
! Description
! Bits
! Type
! Notes
|-
! rowspan="45" | [[Display]]
! $00
| [[Display#Display Control|Display Control]]
| style="text-align: right" | <tt style="white-space: nowrap">..ow Ws21</tt>
| RW8
|
|-
! $01
| [[Display#Display Background|Display Background]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .sss</tt>
<tt style="white-space: nowrap">pppp iiii</tt>
| RW8
| Shade (s)
Palette (p), Index (i)
|-
! $02
| [[Display#Current Line|Display Current Line]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll</tt>
| R8
| Line (l)
|-
! $03
| [[Display#Interrupt Line|Display Interrupt Line]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll</tt>
| RW8
| Line (l)
|-
! $04
| [[Display#Sprite Table Address|Sprite Table Address]]
| style="text-align: right" | <tt style="white-space: nowrap">...a aaaa</tt>
<tt style="white-space: nowrap">..aa aaaa</tt>
| RW8
| Address >> 9 (a)
|-
! $05
| [[Display#Sprite Table First|Sprite Table First]]
| style="text-align: right" | <tt style="white-space: nowrap">.iii iiii</tt>
| RW8
| Index (i)
|-
! $06
| [[Display#Sprite Table Count|Sprite Table Count]]
| style="text-align: right" | <tt style="white-space: nowrap">cccc cccc</tt>
| RW8
| Count (c)
|-
! $07
| [[Display#Screen Address|Screen Address]]
| style="text-align: right" | <tt style="white-space: nowrap">.222 .111</tt>
<tt style="white-space: nowrap">2222 1111</tt>
| RW8
| Screen 1 address >> 11 (1)
Screen 2 address >> 11 (2)
|-
! $08
| [[Display#Screen 2 Window|Screen 2 Window Left]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $09
| [[Display#Screen 2 Window|Screen 2 Window Top]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $0A
| [[Display#Screen 2 Window|Screen 2 Window Right]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $0B
| [[Display#Screen 2 Window|Screen 2 Window Bottom]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $0B
| [[Display#Sprite Window|Sprite Window Left]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $0C
| [[Display#Sprite Window|Sprite Window Top]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $0E
| [[Display#Sprite Window|Sprite Window Right]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $0F
| [[Display#Sprite Window|Sprite Window Bottom]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $10
| [[Display#Screen Scroll|Screen 1 Scroll X]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $11
| [[Display#Screen Scroll|Screen 1 Scroll Y]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $12
| [[Display#Screen Scroll|Screen 2 Scroll X]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $13
| [[Display#Screen Scroll|Screen 2 Scroll Y]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $14
| [[Display#LCD Control|LCD Control]]
| style="text-align: right" | <tt style="white-space: nowrap">.... ..Ce</tt>
| RW8
| Contrast (C)<sup>(WSC)</sup>, Enable (e)
|-
! $15
| [[Display#LCD Icon Control|LCD Icon Control]]
| style="text-align: right" | <tt style="white-space: nowrap">..32 1hvs</tt>
| RW8
| Auxillary 3 (3), Auxillary 2 (2), Auxillary 1 (1),
Horizontal (h), Vertical (v), Sleep (s)
|-
! $16
| [[Display#LCD Final Line|LCD Final Line]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll</tt>
| RW8
| Line (l)
|-
! $17
| [[Display#LCD Back Porch Line|LCD Back Porch Line]]<sup>(WSC)</sup>
| style="text-align: right" | <tt style="white-space: nowrap">llll llll</tt>
| RW8
| Line (l)
|-
! $1A
| [[Display#LCD Status|LCD Status]]
| style="text-align: right" | <tt style="white-space: nowrap">...v vv.s</tt>
| RW8
| Volume segment status (v), Sleep (s)
|-
! $1C
| [[Display#LCD Mono Shade LUT|LCD Mono Shade LUT 0/1]]
| style="text-align: right" | <tt style="white-space: nowrap">1111 0000</tt>
| RW8
| Shade index
|-
! $1D
| [[Display#LCD Mono Shade LUT|LCD Mono Shade LUT 2/3]]
| style="text-align: right" | <tt style="white-space: nowrap">3333 2222</tt>
| RW8
| Shade index
|-
! $1E
| [[Display#LCD Mono Shade LUT|LCD Mono Shade LUT 4/5]]
| style="text-align: right" | <tt style="white-space: nowrap">5555 4444</tt>
| RW8
| Shade index
|-
! $1F
| [[Display#LCD Mono Shade LUT|LCD Mono Shade LUT 6/7]]
| style="text-align: right" | <tt style="white-space: nowrap">7777 6666</tt>
| RW8
| Shade index
|-
! $20
| [[Display#LCD Mono Palette|LCD Mono Palette 0]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $22
| [[Display#LCD Mono Palette|LCD Mono Palette 1]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $24
| [[Display#LCD Mono Palette|LCD Mono Palette 2]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $26
| [[Display#LCD Mono Palette|LCD Mono Palette 3]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $28
| [[Display#LCD Mono Palette|LCD Mono Palette 4]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $2A
| [[Display#LCD Mono Palette|LCD Mono Palette 5]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $2C
| [[Display#LCD Mono Palette|LCD Mono Palette 6]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $2E
| [[Display#LCD Mono Palette|LCD Mono Palette 7]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $30
| [[Display#LCD Mono Palette|LCD Mono Palette 8]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $32
| [[Display#LCD Mono Palette|LCD Mono Palette 9]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $34
| [[Display#LCD Mono Palette|LCD Mono Palette 10]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $36
| [[Display#LCD Mono Palette|LCD Mono Palette 11]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $38
| [[Display#LCD Mono Palette|LCD Mono Palette 12]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $3A
| [[Display#LCD Mono Palette|LCD Mono Palette 13]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $3C
| [[Display#LCD Mono Palette|LCD Mono Palette 14]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $3E
| [[Display#LCD Mono Palette|LCD Mono Palette 15]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! rowspan="10" | [[DMA]]<sup>(color)</sup>
! $40
| [[DMA#General DMA|GDMA Source Address Low]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll llll llll</tt>
| RW16
| Linear address, low 16 bits (l)
|-
! $42
| [[DMA#General DMA|GDMA Source Address High]]
| style="text-align: right" | <tt style="white-space: nowrap">.... hhhh</tt>
| RW8
| Linear address, high 4 bits (h)
|-
! $44
| [[DMA#General DMA|GDMA Destination Address]]
| style="text-align: right" | <tt style="white-space: nowrap">aaaa aaaa aaaa aaaa</tt>
| RW16
| IRAM address (a)
|-
! $46
| [[DMA#General DMA|GDMA Length]]
| style="text-align: right" | <tt style="white-space: nowrap">bbbb bbbb bbbb bbbb</tt>
| RW16
| Bytes (b)
|-
! $48
| [[DMA#General DMA|GDMA Control]]
| style="text-align: right" | <tt style="white-space: nowrap">ed.. ....</tt>
| RW8
| Enable (e), Decrement (d)
|-
! $4A
| [[DMA#Sound DMA|SDMA Source Address Low]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll llll llll</tt>
| RW16
| Linear address, low 16 bits (l)
|-
! $4C
| [[DMA#Sound DMA|SDMA Source Address High]]
| style="text-align: right" | <tt style="white-space: nowrap">.... hhhh</tt>
| RW8
| Linear address, high 4 bits (h)
|-
! $4E
| [[DMA#Sound DMA|SDMA Length Low]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll llll llll</tt>
| RW16
| Length, low 16 bits (l)
|-
! $50
| [[DMA#Sound DMA|SDMA Length High]]
| style="text-align: right" | <tt style="white-space: nowrap">.... hhhh</tt>
| RW8
| Length, high 4 bits (h)
|-
! $52
| [[DMA#Sound DMA|SDMA Control]]
| style="text-align: right" | <tt style="white-space: nowrap">ed.t r?ff</tt>
| RW8
| Enable (e), Decrement (d), Target (t),
Repeat (r), Frequency (f)
|-
! rowspan="2" | System<sup>(color)</sup>
! $60
| System Control 2
| style="text-align: right" | <tt style="white-space: nowrap">c4C. ?.??</tt>
| RW8
| Color (c), 4BPP (4), Chunky (C)
|-
! $62
| System Control 3
| style="text-align: right" | <tt style="white-space: nowrap">S... ...p</tt>
| RW8
| SwanCrystal (S), Power off (p)
|-
! rowspan="5" | [[Hyper Voice]]<sup>(color)</sup>
! $64
| Hyper Voice Left Output
| style="text-align: right" | <tt style="white-space: nowrap">ssss ssss ssss ssss</tt>
| W16
| Raw sample (s)
|-
! $66
| Hyper Voice Right Output
| style="text-align: right" | <tt style="white-space: nowrap">ssss ssss ssss ssss</tt>
| W16
| Raw sample (s)
|-
! $68
| Hyper Voice Left Input
| style="text-align: right" | <tt style="white-space: nowrap">ssss ssss</tt>
| 8
| Sample (s)
|-
! $69
| Hyper Voice Right Input
| style="text-align: right" | <tt style="white-space: nowrap">ssss ssss</tt>
| 8
| Sample (s)
|-
! $6A
| Hyper Voice Control
| style="text-align: right" | <tt style="white-space: nowrap">.mmc .... errr ffss</tt>
| RW16
| Mask (m), Channel (c), Enable (e),
Rate (r), Format (f), Shift (s)
|-
! rowspan="8" | [[Display]]<sup>(SC)</sup>
! $70
| LCD Timing Configuration 1?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $71
| LCD Timing Configuration 2?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $72
| LCD Timing Configuration 3?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $73
| LCD Timing Configuration 4?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $74
| LCD Timing Configuration 5?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $75
| LCD Timing Configuration 6?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $76
| LCD Timing Configuration 7?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $77
| LCD Timing Configuration 8?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! rowspan="21" | [[Sound]]
! $80
| [[Sound#Sound Channel Frequency|Sound Channel 1 Frequency]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .ddd dddd dddd</tt>
| RW16
| Divider (d)
|-
! $82
| [[Sound#Sound Channel Frequency|Sound Channel 2 Frequency]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .ddd dddd dddd</tt>
| RW16
| Divider (d)
|-
! $84
| [[Sound#Sound Channel Frequency|Sound Channel 3 Frequency]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .ddd dddd dddd</tt>
| RW16
| Divider (d)
|-
! $86
| [[Sound#Sound Channel Frequency|Sound Channel 4 Frequency]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .ddd dddd dddd</tt>
| RW16
| Divider (d)
|-
! $88
| [[Sound#Sound Channel Volume|Sound Channel 1 Volume]]
| style="text-align: right" | <tt style="white-space: nowrap">llll rrrr</tt>
| RW8
| Left (l), Right (r)
|-
! rowspan="2" | $89
| [[Sound#Sound Channel Volume|Sound Channel 2 Volume]]
| style="text-align: right" | <tt style="white-space: nowrap">llll rrrr</tt>
| RW8
| Left (l), Right (r)
|-
| [[Sound#Sound Channel 2 Voice Sample|Sound Channel 2 Voice Sample]]
| style="text-align: right" | <tt style="white-space: nowrap">ssss ssss</tt>
| RW8
| Sample (s)
|-
! $8A
| [[Sound#Sound Channel Volume|Sound Channel 3 Volume]]
| style="text-align: right" | <tt style="white-space: nowrap">llll rrrr</tt>
| RW8
| Left (l), Right (r)
|-
! $8B
| [[Sound#Sound Channel Volume|Sound Channel 4 Volume]]
| style="text-align: right" | <tt style="white-space: nowrap">llll rrrr</tt>
| RW8
| Left (l), Right (r)
|-
! $8C
| [[Sound#Sound Channel 3 Sweep Amount|Sound Channel 3 Sweep Amount]]
| style="text-align: right" | <tt style="white-space: nowrap">vvvv vvvv</tt>
| RW8
| Value (v)
|-
! $8D
| [[Sound#Sound Channel 3 Sweep Ticks|Sound Channel 3 Sweep Ticks]]
| style="text-align: right" | <tt style="white-space: nowrap">...t tttt</tt>
| RW8
| Ticks (t)
|-
! $8E
| [[Sound#Sound Channel 4 Noise Control|Sound Channel 4 Noise Control]]
| style="text-align: right" | <tt style="white-space: nowrap">...e rttt</tt>
| RW8
| Enable (e), Reset (r), Tap (t)
|-
! $8F
| [[Sound#Sound Wavetable Address|Sound Wavetable Address]]
| style="text-align: right" | <tt style="white-space: nowrap">wwww wwww</tt>
| RW8
| Address >> 6 (w)
|-
! $90
| [[Sound#Sound Channel Control|Sound Channel Control]]
| style="text-align: right" | <tt style="white-space: nowrap">nsv. 4321</tt>
| RW8
| Channel enable (1234)
Noise (n), Sweep (s), Voice (v)
|-
! $91
| [[Sound#Sound Output Control|Sound Output Control]]
| style="text-align: right" | <tt style="white-space: nowrap">H... hrrs</tt>
| RW8
| Headphones connected (H)
Headphone output (h)
Speaker output (s), range (r)
|-
! $92
| [[Sound#Sound Channel 4 LFSR Register|Sound Channel 4 LFSR Register]]
| style="text-align: right" | <tt style="white-space: nowrap">.rrr rrrr rrrr rrrr</tt>
| R16
| PRNG state (r)
|-
! $94
| [[Sound#Sound Channel 2 Voice Volume|Sound Channel 2 Voice Volume]]
| style="text-align: right" | <tt style="white-space: nowrap">.... lLrR</tt>
| RW8
| Left Half (l), Full (L)
Right Half (r), Full (R)
|-
! $96
| Sound Channel Output Right
| style="text-align: right" | <tt style="white-space: nowrap">.... ..ss ssss ssss</tt>
| R16
| Sample (s)
|-
! $98
| Sound Channel Output Left
| style="text-align: right" | <tt style="white-space: nowrap">.... ..ss ssss ssss</tt>
| R16
| Sample (s)
|-
! $9A
| Sound Channel Output Sum
| style="text-align: right" | <tt style="white-space: nowrap">.... .sss ssss ssss</tt>
| R16
| Sample (s)
|-
! $9E
| Sound Speaker Master Volume<sup>(color)</sup>
| style="text-align: right" | <tt style="white-space: nowrap">.... ..vv</tt>
| R8
| ?
|-
! System
! $A0
| System Control
| style="text-align: right" | <tt style="white-space: nowrap">t??? swcl</tt>
| RW8
| Test OK (t), ROM speed (s), ROM width (w),
Color system (c), Boot ROM lockout (l)
|-
! rowspan="5" | [[Timers]]
! $A2
| [[Timers#Timer Control|Timer Control]]
| style="text-align: right" | <tt style="white-space: nowrap">.... VvHh</tt>
| RW8
| Horizontal enable (h), auto reload (H)
Vertical enable (v), auto reload (V)
|-
! $A4
| [[Timers#Timer Reload|Horizontal Blank Timer Reload]]
| style="text-align: right" | <tt style="white-space: nowrap">tttt tttt tttt tttt</tt>
| RW16
| Ticks (t)
|-
! $A6
| [[Timers#Timer Reload|Vertical Blank Timer Reload]]
| style="text-align: right" | <tt style="white-space: nowrap">tttt tttt tttt tttt</tt>
| RW16
| Ticks (t)
|-
! $A8
| [[Timers#Timer Counter|Horizontal Blank Timer Counter]]
| style="text-align: right" | <tt style="white-space: nowrap">tttt tttt tttt tttt</tt>
| R16
| Ticks (t)
|-
! $AA
| [[Timers#Timer Counter|Vertical Blank Timer Counter]]
| style="text-align: right" | <tt style="white-space: nowrap">tttt tttt tttt tttt</tt>
| R16
| Ticks (t)
|-
! [[Interrupts]]
! $B0
| [[Interrupts#Interrupt Vector|Interrupt Vector]]
| style="text-align: right" | <tt style="white-space: nowrap">VVVV V...</tt>
| RW8
| Vector offset (v)
|-
! rowspan="2" | [[UART]]
! $B1
| [[UART#Serial Receive Data|Serial Receive Data]]
| style="text-align: right" | <tt style="white-space: nowrap">dddd dddd</tt>
| R8
| Receive buffer data (d)
|-
! $B1
| [[UART#Serial Transmit Data|Serial Transmit Data]]
| style="text-align: right" | <tt style="white-space: nowrap">dddd dddd</tt>
| W8
| Transmit buffer data (d)
|-
! [[Interrupts]]
! $B2
| [[Interrupts#Interrupt Enable|Interrupt Enable]]
| iiii iiii
| RW8
| Interrupt index (i)
|-
! rowspan="2" | [[UART]]
! $B3
| [[UART#Serial Status|Serial Status]]
| style="text-align: right" | <tt style="white-space: nowrap">eb.. .tor</tt>
| R8
| Enable (e), Baud rate (b),
Transfer ready (t), Overrun (o), Receive ready (r)
|-
! $B3
| [[UART#Serial Control|Serial Control]]
| style="text-align: right" | <tt style="white-space: nowrap">ebO. ....</tt>
| W8
| Enable (e), Baud rate (b), Reset Overrun (O)
|-
! [[Interrupts]]
! $B4
| [[Interrupts#Interrupt Status|Interrupt Status]]
| iiii iiii
| R8
| Interrupt index (i)
|-
! [[Keypad]]
! $B5
| [[Keypad|Keypad Scan]]
| style="text-align: right" | <tt style="white-space: nowrap">.iii oooo</tt>
| RW8
| Input row (i), Output column (o)
|-
! rowspan="2" | [[Interrupts]]
! $B6
| [[Interrupts#Interrupt Acknowledge|Interrupt Acknowledge]]
| iiii iiii
| R8?
| Interrupt index (i)
|-
! $B7
| [[Interrupts#Interrupt NMI Control|Interrupt NMI Control]]
| style="text-align: right" | <tt style="white-space: nowrap">...b ....</tt>
| RW8
| Low battery (b)
|-
! rowspan="3" | Internal EEPROM
! $BA
| Internal EEPROM Data
| style="text-align: right" | <tt style="white-space: nowrap">dddd dddd dddd dddd</tt>
| RW16
| Data (d)
|-
! $BC
| Internal EEPROM Command
|
| RW16
|
|-
! $BE
| Internal EEPROM Control
| style="text-align: right" | <tt style="white-space: nowrap">.... .... PEWR ..rd</tt>
| RW16
| Protect (P), Erase (E), Write (W), Read (R),
Ready (r), Done (d)
|-
! [[Mapper|Cartridge]]
! $C0<br />
$FF
| Cartridge I/O
|
|
| Forwarded by the SoC
|}
74ada3cb20536887a3e61a506a5c4facb30e2f17
Sound
0
27
103
2023-08-22T10:00:48Z
Asie
351
Created page with "The WonderSwan features the following sound hardware: * Four audio channels: ** channel 1 - wavetable (32 x 4-bit samples), ** channel 2 - wavetable or 8-bit unsigned PCM sample, ** channel 3 - wavetable with optional hardware sweep, ** channel 4 - wavetable or LFSR noise, * [[Hyper Voice]]<sup>(color)</sup> - headphone output exclusive 16-bit stereo PCM output, * 24000 Hz output: ** internal speaker - 8-bit, mono, ** headphone output - 16-bit, stereo. The sound is mix..."
wikitext
text/x-wiki
The WonderSwan features the following sound hardware:
* Four audio channels:
** channel 1 - wavetable (32 x 4-bit samples),
** channel 2 - wavetable or 8-bit unsigned PCM sample,
** channel 3 - wavetable with optional hardware sweep,
** channel 4 - wavetable or LFSR noise,
* [[Hyper Voice]]<sup>(color)</sup> - headphone output exclusive 16-bit stereo PCM output,
* 24000 Hz output:
** internal speaker - 8-bit, mono,
** headphone output - 16-bit, stereo.
The sound is mixed as follows:
<pre>
Ch1 Ch2 Ch3 Ch4 Glossary: L = left, R = right, M = mono
| | | | Mnn = nn-bit mono
8 8 8 8 port $98 port $nn = value port
| | | | /
_V___V___V___V_ / _____ _____
| |--L10------+------| | | |
| + | | | + |--M11-->| >>r |--M8--> Speaker output
|_______________|--R10------|-+----|_____| / |_____|
/ _|_|_ / (r=0...3)
/ | | /
port $96 | <<5 | port $9A
|_____|
| |
| |
port $68 port $64 | |
/ _______________ \ __V_V__ _____
L8-->| (Color only) |--L16-->| |----------L16---| |
| Hyper Voice | | + + | | I2S |------> Headphone output
R8-->|_______________|--R16-->|_______|----------R16---|_____|
\ /
port $69 port $66
</pre>
[[Hyper Voice]] functionality is documented on its own sub-page.
== I/O Ports ==
=== Sound Channel Frequency ===
<pre>
15 bit 8 7 bit 0
--------- ---------
.... .ddd dddd dddd
+++--++++-++++- Frequency divisor
</pre>
This frequency is used for wavetable output. It is calculated as follows: <code>sample rate = 3072000 Hz / (2048 - divisor)</code>.
Note that this refers to the sample rate of the ''wavetable'', and needs to be scaled accordingly for a given waveform when performing music playback.
=== Sound Channel Volume ===
<pre>
7 bit 0
---------
llll rrrr
|||| ++++- Right channel volume (0-15)
++++------ Left channel volume (0-15)
</pre>
This volume is used for wavetable output.
The calculation to get an unsigned 8-bit sample out of a 4-bit wavetable sample / 4-bit volume pair is simple: <code>out_sample = sample * volume</code>. This means that the maximum sample in wavetable output mode is <code>15 * 15 = 225</code>.
=== Sound Channel 2 Voice Sample ===
<pre>
7 bit 0
---------
ssss ssss
++++-++++- Unsigned 8-bit PCM sample (0-255)
</pre>
This sample is used for voice output.
=== Sound Channel 3 Sweep Amount ===
<pre>
7 bit 0
---------
vvvv vvvv
++++-++++- Value; 8-bit, signed.
</pre>
This port is used for wavetable output with sweep enabled.
The signed value in this port will be added to the frequency divider for channel 3 every sweep step (as determined by the Sweep Ticks port). Wraparound is present - adding 1 to a frequency divider value of 2047 will cause it to roll over back to 0.
=== Sound Channel 3 Sweep Ticks ===
<pre>
7 bit 0
---------
...t tttt
+-++++- Ticks per step - 1
</pre>
This port is used for wavetable output with sweep enabled.
Every <code>ttttt + 1</code> ticks, clocked at 375 Hz, the value in the Sweep Amount port will be added to the frequency divider for channel 3.
=== Sound Channel 4 Noise Control ===
<pre>
7 bit 0
---- ----
...e rttt
| |+++- LFSR tap mode
| +---- LFSR reset: 1 = reset shift register
+------ LFSR enabled: 0 = off, 1 = on
</pre>
This port is used for noise output.
{| class="wikitable"
|+ List of LFSR tap modes
! Tap mode
! Tap bit
! Sequence length
|-
| 0
| 14
| 32767
|-
| 1
| 10
| 1953
|-
| 2
| 13
| 254
|-
| 3
| 4
| 217
|-
| 4
| 8
| 73
|-
| 5
| 6
| 63
|-
| 6
| 9
| 42
|-
| 7
| 11
| 28
|}
Noise output works using the following algorithm, performed once per sample generated:
1. Create a new bit by XORing bit 7 with the tap bit.
2. Shift the LFSR register one bit to the left.
3. Write the new bit as bit 0.
4. Use the new bit as if it were a wavetable sample: 0 = 0, 1 = 15.
=== Sound Wavetable Address ===
<pre>
7 bit 0
---- ----
wwww wwww
++++-++++- Wavetable address (bits 6-13)
</pre>
=== Sound Channel Control ===
<pre>
7 bit 0
---- ----
nsv. 4321
||| |||+- Channel 1 enable
||| ||+-- Channel 2 enable
||| |+--- Channel 3 enable
||| +---- Channel 4 enable
||+------- Channel 2 mode: 0 = wavetable, 1 = voice
|+-------- Channel 3 sweep: 0 = disable, 1 = enable
+--------- Channel 4 mode: 0 = wavetable, 1 = noise
</pre>
=== Sound Output Control ===
<pre>
7 bit 0
---- ----
H... hrrs
| |||+- Internal speaker output enable
| |++-- Internal speaker shift right value
| +---- Headphone output enable
+--------- Headphones connected: 1 if true
</pre>
It is a good idea to set the internal speaker shift right value correctly. If the value is too low, multi-channel music will clip; if the value is too high, single-channel PCM sample playback will be very quiet.
=== Sound Channel 4 LFSR Register ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
.rrr rrrr rrrr rrrr
+++-++++--++++-++++- Shift register value
</pre>
=== Sound Channel 2 Voice Volume ===
<pre>
7 bit 0
---- ----
.... lLrR
|||+- Right channel 100% volume
||+-- Right channel 50% volume
|+--- Left channel 100% volume
+---- Left channel 50% volume
</pre>
This port is used for voice output.
The <code>50% volume</code> have no effect if their respective <code>100% volume</code> bits are set.
281bb4a2d3ed5342e07ac0f3c97b9665d8c16374
104
103
2023-08-22T10:01:31Z
Asie
351
wikitext
text/x-wiki
The WonderSwan features the following sound hardware:
* Four audio channels:
** channel 1 - wavetable (32 x 4-bit samples),
** channel 2 - wavetable or 8-bit unsigned PCM sample,
** channel 3 - wavetable with optional hardware sweep,
** channel 4 - wavetable or LFSR noise,
* [[Hyper Voice]]<sup>(color)</sup> - headphone output exclusive 16-bit stereo PCM output,
* 24000 Hz output:
** internal speaker - 8-bit, mono,
** headphone output - 16-bit, stereo.
The sound is mixed as follows:
<pre>
Ch1 Ch2 Ch3 Ch4 Glossary: L = left, R = right, M = mono
| | | | Mnn = nn-bit mono
8 8 8 8 port $98 port $nn = value port
| | | | /
_V___V___V___V_ / _____ _____
| |--L10------+------| | | |
| + | | | + |--M11-->| >>r |--M8--> Speaker output
|_______________|--R10------|-+----|_____| / |_____|
/ _|_|_ / (r=0...3)
/ | | /
port $96 | <<5 | port $9A
|_____|
| |
| |
port $68 port $64 | |
/ _______________ \ __V_V__ _____
L8-->| (Color only) |--L16-->| |----------L16---| |
| Hyper Voice | | + + | | I2S |------> Headphone output
R8-->|_______________|--R16-->|_______|----------R16---|_____|
\ /
port $69 port $66
</pre>
[[Hyper Voice]] functionality is documented on its own sub-page.
== I/O Ports ==
=== Sound Channel Frequency ===
<pre>
15 bit 8 7 bit 0
--------- ---------
.... .ddd dddd dddd
+++--++++-++++- Frequency divisor
</pre>
This frequency is used for wavetable output. It is calculated as follows: <code>sample rate = 3072000 Hz / (2048 - divisor)</code>.
Note that this refers to the sample rate of the ''wavetable'', and needs to be scaled accordingly for a given waveform when performing music playback.
=== Sound Channel Volume ===
<pre>
7 bit 0
---------
llll rrrr
|||| ++++- Right channel volume (0-15)
++++------ Left channel volume (0-15)
</pre>
This volume is used for wavetable output.
The calculation to get an unsigned 8-bit sample out of a 4-bit wavetable sample / 4-bit volume pair is simple: <code>out_sample = sample * volume</code>. This means that the maximum sample in wavetable output mode is <code>15 * 15 = 225</code>.
=== Sound Channel 2 Voice Sample ===
<pre>
7 bit 0
---------
ssss ssss
++++-++++- Unsigned 8-bit PCM sample (0-255)
</pre>
This sample is used for voice output.
=== Sound Channel 3 Sweep Amount ===
<pre>
7 bit 0
---------
vvvv vvvv
++++-++++- Value; 8-bit, signed.
</pre>
This port is used for wavetable output with sweep enabled.
The signed value in this port will be added to the frequency divider for channel 3 every sweep step (as determined by the Sweep Ticks port). Wraparound is present - adding 1 to a frequency divider value of 2047 will cause it to roll over back to 0.
=== Sound Channel 3 Sweep Ticks ===
<pre>
7 bit 0
---------
...t tttt
+-++++- Ticks per step - 1
</pre>
This port is used for wavetable output with sweep enabled.
Every <code>ttttt + 1</code> ticks, clocked at 375 Hz, the value in the Sweep Amount port will be added to the frequency divider for channel 3.
=== Sound Channel 4 Noise Control ===
<pre>
7 bit 0
---- ----
...e rttt
| |+++- LFSR tap mode
| +---- LFSR reset: 1 = reset shift register
+------ LFSR enabled: 0 = off, 1 = on
</pre>
This port is used for noise output.
{| class="wikitable"
|+ List of LFSR tap modes
! Tap mode
! Tap bit
! Sequence length
|-
| 0
| 14
| 32767
|-
| 1
| 10
| 1953
|-
| 2
| 13
| 254
|-
| 3
| 4
| 217
|-
| 4
| 8
| 73
|-
| 5
| 6
| 63
|-
| 6
| 9
| 42
|-
| 7
| 11
| 28
|}
Noise output works using the following algorithm, performed once per sample generated:
# Create a new bit by XORing bit 7 with the tap bit.
# Shift the LFSR register one bit to the left.
# Write the new bit as bit 0.
# Use the new bit as if it were a wavetable sample: 0 = 0, 1 = 15.
=== Sound Wavetable Address ===
<pre>
7 bit 0
---- ----
wwww wwww
++++-++++- Wavetable address (bits 6-13)
</pre>
=== Sound Channel Control ===
<pre>
7 bit 0
---- ----
nsv. 4321
||| |||+- Channel 1 enable
||| ||+-- Channel 2 enable
||| |+--- Channel 3 enable
||| +---- Channel 4 enable
||+------- Channel 2 mode: 0 = wavetable, 1 = voice
|+-------- Channel 3 sweep: 0 = disable, 1 = enable
+--------- Channel 4 mode: 0 = wavetable, 1 = noise
</pre>
=== Sound Output Control ===
<pre>
7 bit 0
---- ----
H... hrrs
| |||+- Internal speaker output enable
| |++-- Internal speaker shift right value
| +---- Headphone output enable
+--------- Headphones connected: 1 if true
</pre>
It is a good idea to set the internal speaker shift right value correctly. If the value is too low, multi-channel music will clip; if the value is too high, single-channel PCM sample playback will be very quiet.
=== Sound Channel 4 LFSR Register ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
.rrr rrrr rrrr rrrr
+++-++++--++++-++++- Shift register value
</pre>
=== Sound Channel 2 Voice Volume ===
<pre>
7 bit 0
---- ----
.... lLrR
|||+- Right channel 100% volume
||+-- Right channel 50% volume
|+--- Left channel 100% volume
+---- Left channel 50% volume
</pre>
This port is used for voice output.
The <code>50% volume</code> have no effect if their respective <code>100% volume</code> bits are set.
c958317b70f4dfaf25b9e807be7c3c9b9a659a13
105
104
2023-08-22T10:09:06Z
Asie
351
wikitext
text/x-wiki
The WonderSwan features the following sound hardware:
* Four audio channels:
** channel 1 - wavetable (32 x 4-bit samples),
** channel 2 - wavetable or 8-bit unsigned PCM sample,
** channel 3 - wavetable with optional hardware sweep,
** channel 4 - wavetable or LFSR noise,
* [[Hyper Voice]]<sup>(color)</sup> - headphone output exclusive 16-bit stereo PCM output,
* 24000 Hz output:
** internal speaker - 8-bit, mono,
** headphone output - 16-bit, stereo.
The sound is mixed as follows:
<pre>
Ch1 Ch2 Ch3 Ch4 Glossary: L = left, R = right, M = mono
| | | | Mnn = nn-bit mono
8 8 8 8 port $98 port $nn = value port
| | | | /
_V___V___V___V_ / _____ _____
| |--L10------+------| | | |
| + | | | + |--M11-->| >>r |--M8--> Speaker output
|_______________|--R10------|-+----|_____| / |_____|
/ _|_|_ / (r=0...3)
/ | | /
port $96 | <<5 | port $9A
|_____|
| |
| |
port $68 port $64 | |
/ _______________ \ __V_V__ _____
L8-->| (Color only) |--L16-->| |----------L16---| |
| Hyper Voice | | + + | | I2S |------> Headphone output
R8-->|_______________|--R16-->|_______|----------R16---|_____|
\ /
port $69 port $66
</pre>
[[Hyper Voice]] functionality is documented on its own sub-page.
== I/O Ports ==
=== Sound Channel Frequency ===
<pre>
15 bit 8 7 bit 0
--------- ---------
.... .ddd dddd dddd
+++--++++-++++- Frequency divisor
</pre>
This frequency is used for wavetable output. It is calculated as follows: <code>sample rate = 3072000 Hz / (2048 - divisor)</code>.
Note that this refers to the sample rate of the ''wavetable'', and needs to be scaled accordingly for a given waveform when performing music playback.
=== Sound Channel Volume ===
<pre>
7 bit 0
---------
llll rrrr
|||| ++++- Right channel volume (0-15)
++++------ Left channel volume (0-15)
</pre>
This volume is used for wavetable output.
The calculation to get an unsigned 8-bit sample out of a 4-bit wavetable sample / 4-bit volume pair is simple: <code>out_sample = sample * volume</code>. This means that the maximum sample in wavetable output mode is <code>15 * 15 = 225</code>.
=== Sound Channel 2 Voice Sample ===
<pre>
7 bit 0
---------
ssss ssss
++++-++++- Unsigned 8-bit PCM sample (0-255)
</pre>
This sample is used for voice output.
=== Sound Channel 3 Sweep Amount ===
<pre>
7 bit 0
---------
vvvv vvvv
++++-++++- Value; 8-bit, signed.
</pre>
This port is used for wavetable output with sweep enabled.
The signed value in this port will be added to the frequency divider for channel 3 every sweep step (as determined by the Sweep Ticks port). Wraparound is present - adding 1 to a frequency divider value of 2047 will cause it to roll over back to 0.
=== Sound Channel 3 Sweep Ticks ===
<pre>
7 bit 0
---------
...t tttt
+-++++- Ticks per step - 1
</pre>
This port is used for wavetable output with sweep enabled.
Every <code>ttttt + 1</code> ticks, clocked at 375 Hz, the value in the Sweep Amount port will be added to the frequency divider for channel 3.
=== Sound Channel 4 Noise Control ===
<pre>
7 bit 0
---- ----
...e rttt
| |+++- LFSR tap mode
| +---- LFSR reset: 1 = reset shift register
+------ LFSR enabled: 0 = off, 1 = on
</pre>
This port is used for noise output.
{| class="wikitable"
|+ List of LFSR tap modes
! Tap mode
! Tap bit
! Sequence length
|-
| 0
| 14
| 32767
|-
| 1
| 10
| 1953
|-
| 2
| 13
| 254
|-
| 3
| 4
| 217
|-
| 4
| 8
| 73
|-
| 5
| 6
| 63
|-
| 6
| 9
| 42
|-
| 7
| 11
| 28
|}
Noise output works using the following algorithm, performed once per sample generated:
# Create a new bit by XORing bit 7 with the tap bit.
# Shift the LFSR register one bit to the left.
# Write the new bit as bit 0.
# Use the new bit as if it were a wavetable sample: 0 = 0, 1 = 15.
=== Sound Wavetable Address ===
<pre>
7 bit 0
---- ----
wwww wwww
++++-++++- Wavetable address (bits 6-13)
</pre>
The wavetable is 4 x 16 bytes long; each 16-byte block contains 32 4-bit samples for the relevant channel:
<pre>
Address $00 $01 $02 $03 $04 $05 $06 $07 $08 $09 $0A $0B $0C $0D $0E $0F
98 CB ED FF FF EF BD 8A 57 24 01 00 00 21 43 76
Sample
15 .. .. .. ## ## #. .. .. .. .. .. .. .. .. .. ..
14 .. .. .# || || |# .. .. .. .. .. .. .. .. .. ..
13 .. .. #| || || || #. .. .. .. .. .. .. .. .. ..
12 .. .# || || || || |. .. .. .. .. .. .. .. .. ..
11 .. #| || || || || |# .. .. .. .. .. .. .. .. ..
10 .. || || || || || || #. .. .. .. .. .. .. .. ..
9 .# || || || || || || |. .. .. .. .. .. .. .. ..
8 #| || || || || || || |# .. .. .. .. .. .. .. ..
7 || || || || || || || || #. .. .. .. .. .. .. .#
6 || || || || || || || || |. .. .. .. .. .. .. #|
5 || || || || || || || || |# .. .. .. .. .. .. ||
4 || || || || || || || || || #. .. .. .. .. .# ||
3 || || || || || || || || || |. .. .. .. .. #| ||
2 || || || || || || || || || |# .. .. .. .# || ||
1 || || || || || || || || || || #. .. .. #| || ||
0 || || || || || || || || || || |# ## ## || || ||
</pre>
=== Sound Channel Control ===
<pre>
7 bit 0
---- ----
nsv. 4321
||| |||+- Channel 1 enable
||| ||+-- Channel 2 enable
||| |+--- Channel 3 enable
||| +---- Channel 4 enable
||+------- Channel 2 mode: 0 = wavetable, 1 = voice
|+-------- Channel 3 sweep: 0 = disable, 1 = enable
+--------- Channel 4 mode: 0 = wavetable, 1 = noise
</pre>
=== Sound Output Control ===
<pre>
7 bit 0
---- ----
H... hrrs
| |||+- Internal speaker output enable
| |++-- Internal speaker shift right value
| +---- Headphone output enable
+--------- Headphones connected: 1 if true
</pre>
It is a good idea to set the internal speaker shift right value correctly. If the value is too low, multi-channel music will clip; if the value is too high, single-channel PCM sample playback will be very quiet.
=== Sound Channel 4 LFSR Register ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
.rrr rrrr rrrr rrrr
+++-++++--++++-++++- Shift register value
</pre>
=== Sound Channel 2 Voice Volume ===
<pre>
7 bit 0
---- ----
.... lLrR
|||+- Right channel 100% volume
||+-- Right channel 50% volume
|+--- Left channel 100% volume
+---- Left channel 50% volume
</pre>
This port is used for voice output.
The <code>50% volume</code> have no effect if their respective <code>100% volume</code> bits are set.
ab4290edf1a78bb26fd886a725a7414cda6975ba
106
105
2023-08-22T10:10:29Z
Asie
351
wikitext
text/x-wiki
The WonderSwan features the following sound hardware:
* Four audio channels:
** channel 1 - wavetable (32 x 4-bit samples),
** channel 2 - wavetable or 8-bit unsigned PCM sample,
** channel 3 - wavetable with optional hardware sweep,
** channel 4 - wavetable or LFSR noise,
* [[Hyper Voice]]<sup>(color)</sup> - headphone output exclusive 16-bit stereo PCM output,
* 24000 Hz output:
** internal speaker - 8-bit, mono,
** headphone output - 16-bit, stereo.
The sound is mixed as follows:
<pre>
Ch1 Ch2 Ch3 Ch4 Glossary: L = left, R = right, M = mono
| | | | Mnn = nn-bit mono
8 8 8 8 port $98 port $nn = value port
| | | | /
_V___V___V___V_ / _____ _____
| |--L10------+------| | | |
| + | | | + |--M11-->| >>r |--M8--> Speaker output
|_______________|--R10------|-+----|_____| / |_____|
/ _|_|_ / (r=0...3)
/ | | /
port $96 | <<5 | port $9A
|_____|
| |
| |
port $68 port $64 | |
/ _______________ \ __V_V__ _____
L8-->| (Color only) |--L16-->| |----------L16---| |
| Hyper Voice | | + + | | I2S |------> Headphone output
R8-->|_______________|--R16-->|_______|----------R16---|_____|
\ /
port $69 port $66
</pre>
[[Hyper Voice]] functionality is documented on its own sub-page.
== I/O Ports ==
=== Sound Channel Frequency ===
<pre>
15 bit 8 7 bit 0
--------- ---------
.... .ddd dddd dddd
+++--++++-++++- Frequency divisor
</pre>
This frequency is used for wavetable output. It is calculated as follows: <code>sample rate = 3072000 Hz / (2048 - divisor)</code>.
Note that this refers to the sample rate of the ''wavetable'', and needs to be scaled accordingly for a given waveform when performing music playback.
=== Sound Channel Volume ===
<pre>
7 bit 0
---------
llll rrrr
|||| ++++- Right channel volume (0-15)
++++------ Left channel volume (0-15)
</pre>
This volume is used for wavetable output.
The calculation to get an unsigned 8-bit sample out of a 4-bit wavetable sample / 4-bit volume pair is simple: <code>out_sample = sample * volume</code>. This means that the maximum sample in wavetable output mode is <code>15 * 15 = 225</code>.
=== Sound Channel 2 Voice Sample ===
<pre>
7 bit 0
---------
ssss ssss
++++-++++- Unsigned 8-bit PCM sample (0-255)
</pre>
This sample is used for voice output.
=== Sound Channel 3 Sweep Amount ===
<pre>
7 bit 0
---------
vvvv vvvv
++++-++++- Value; 8-bit, signed.
</pre>
This port is used for wavetable output with sweep enabled.
The signed value in this port will be added to the frequency divider for channel 3 every sweep step (as determined by the Sweep Ticks port). Wraparound is present - adding 1 to a frequency divider value of 2047 will cause it to roll over back to 0.
=== Sound Channel 3 Sweep Ticks ===
<pre>
7 bit 0
---------
...t tttt
+-++++- Ticks per step - 1
</pre>
This port is used for wavetable output with sweep enabled.
Every <code>ttttt + 1</code> ticks, clocked at 375 Hz, the value in the Sweep Amount port will be added to the frequency divider for channel 3.
=== Sound Channel 4 Noise Control ===
<pre>
7 bit 0
---- ----
...e rttt
| |+++- LFSR tap mode
| +---- LFSR reset: 1 = reset shift register
+------ LFSR enabled: 0 = off, 1 = on
</pre>
This port is used for noise output.
{| class="wikitable"
|+ List of LFSR tap modes
! Tap mode
! Tap bit
! Sequence length
|-
| 0
| 14
| 32767
|-
| 1
| 10
| 1953
|-
| 2
| 13
| 254
|-
| 3
| 4
| 217
|-
| 4
| 8
| 73
|-
| 5
| 6
| 63
|-
| 6
| 9
| 42
|-
| 7
| 11
| 28
|}
Noise output works using the following algorithm, performed once per sample generated:
# Create a new bit by XORing bit 7 with the tap bit.
# Shift the LFSR register one bit to the left.
# Write the new bit as bit 0.
# Use the new bit as if it were a wavetable sample: 0 = 0, 1 = 15.
=== Sound Wavetable Address ===
<pre>
7 bit 0
---- ----
wwww wwww
++++-++++- Wavetable address (bits 6-13)
</pre>
The wavetable is 4 x 16 bytes long; each 16-byte block contains 32 4-bit samples for the relevant channel:
<pre>
Address $00 $01 $02 $03 $04 $05 $06 $07 $08 $09 $0A $0B $0C $0D $0E $0F
98 CB ED FF FF EF BD 8A 57 24 01 00 00 21 43 76
Sample
15 .. .. .. ## ## #. .. .. .. .. .. .. .. .. .. ..
14 .. .. .# || || |# .. .. .. .. .. .. .. .. .. ..
13 .. .. #| || || || #. .. .. .. .. .. .. .. .. ..
12 .. .# || || || || |. .. .. .. .. .. .. .. .. ..
11 .. #| || || || || |# .. .. .. .. .. .. .. .. ..
10 .. || || || || || || #. .. .. .. .. .. .. .. ..
9 .# || || || || || || |. .. .. .. .. .. .. .. ..
8 #| || || || || || || |# .. .. .. .. .. .. .. ..
7 || || || || || || || || #. .. .. .. .. .. .. .#
6 || || || || || || || || |. .. .. .. .. .. .. #|
5 || || || || || || || || |# .. .. .. .. .. .. ||
4 || || || || || || || || || #. .. .. .. .. .# ||
3 || || || || || || || || || |. .. .. .. .. #| ||
2 || || || || || || || || || |# .. .. .. .# || ||
1 || || || || || || || || || || #. .. .. #| || ||
0 || || || || || || || || || || |# ## ## || || ||
</pre>
Note that the ''higher'' bits - the first hexadecimal number - specify the ''later'' samples; that is to say, the nybbles of each sample are swapped relative to the wave drawing.
=== Sound Channel Control ===
<pre>
7 bit 0
---- ----
nsv. 4321
||| |||+- Channel 1 enable
||| ||+-- Channel 2 enable
||| |+--- Channel 3 enable
||| +---- Channel 4 enable
||+------- Channel 2 mode: 0 = wavetable, 1 = voice
|+-------- Channel 3 sweep: 0 = disable, 1 = enable
+--------- Channel 4 mode: 0 = wavetable, 1 = noise
</pre>
=== Sound Output Control ===
<pre>
7 bit 0
---- ----
H... hrrs
| |||+- Internal speaker output enable
| |++-- Internal speaker shift right value
| +---- Headphone output enable
+--------- Headphones connected: 1 if true
</pre>
It is a good idea to set the internal speaker shift right value correctly. If the value is too low, multi-channel music will clip; if the value is too high, single-channel PCM sample playback will be very quiet.
=== Sound Channel 4 LFSR Register ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
.rrr rrrr rrrr rrrr
+++-++++--++++-++++- Shift register value
</pre>
=== Sound Channel 2 Voice Volume ===
<pre>
7 bit 0
---- ----
.... lLrR
|||+- Right channel 100% volume
||+-- Right channel 50% volume
|+--- Left channel 100% volume
+---- Left channel 50% volume
</pre>
This port is used for voice output.
The <code>50% volume</code> have no effect if their respective <code>100% volume</code> bits are set.
e34c49ad924c8300bc2d806f91f86c91ee38bc9c
107
106
2023-08-22T10:36:39Z
Fiskbit
37
Register formatting.
wikitext
text/x-wiki
The WonderSwan features the following sound hardware:
* Four audio channels:
** channel 1 - wavetable (32 x 4-bit samples),
** channel 2 - wavetable or 8-bit unsigned PCM sample,
** channel 3 - wavetable with optional hardware sweep,
** channel 4 - wavetable or LFSR noise,
* [[Hyper Voice]]<sup>(color)</sup> - headphone output exclusive 16-bit stereo PCM output,
* 24000 Hz output:
** internal speaker - 8-bit, mono,
** headphone output - 16-bit, stereo.
The sound is mixed as follows:
<pre>
Ch1 Ch2 Ch3 Ch4 Glossary: L = left, R = right, M = mono
| | | | Mnn = nn-bit mono
8 8 8 8 port $98 port $nn = value port
| | | | /
_V___V___V___V_ / _____ _____
| |--L10------+------| | | |
| + | | | + |--M11-->| >>r |--M8--> Speaker output
|_______________|--R10------|-+----|_____| / |_____|
/ _|_|_ / (r=0...3)
/ | | /
port $96 | <<5 | port $9A
|_____|
| |
| |
port $68 port $64 | |
/ _______________ \ __V_V__ _____
L8-->| (Color only) |--L16-->| |----------L16---| |
| Hyper Voice | | + + | | I2S |------> Headphone output
R8-->|_______________|--R16-->|_______|----------R16---|_____|
\ /
port $69 port $66
</pre>
[[Hyper Voice]] functionality is documented on its own sub-page.
== I/O Ports ==
=== Sound Channel Frequency ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
.... .ddd dddd dddd
||| |||| ||||
+++--++++-++++- Frequency divisor
</pre>
This frequency is used for wavetable output. It is calculated as follows: <code>sample rate = 3072000 Hz / (2048 - divisor)</code>.
Note that this refers to the sample rate of the ''wavetable'', and needs to be scaled accordingly for a given waveform when performing music playback.
=== Sound Channel Volume ===
<pre>
7 bit 0
---------
llll rrrr
|||| ||||
|||| ++++- Right channel volume (0-15)
++++------ Left channel volume (0-15)
</pre>
This volume is used for wavetable output.
The calculation to get an unsigned 8-bit sample out of a 4-bit wavetable sample / 4-bit volume pair is simple: <code>out_sample = sample * volume</code>. This means that the maximum sample in wavetable output mode is <code>15 * 15 = 225</code>.
=== Sound Channel 2 Voice Sample ===
<pre>
7 bit 0
---- ----
ssss ssss
|||| ||||
++++-++++- Unsigned 8-bit PCM sample (0-255)
</pre>
This sample is used for voice output.
=== Sound Channel 3 Sweep Amount ===
<pre>
7 bit 0
---- ----
vvvv vvvv
|||| ||||
++++-++++- Value; 8-bit, signed.
</pre>
This port is used for wavetable output with sweep enabled.
The signed value in this port will be added to the frequency divider for channel 3 every sweep step (as determined by the Sweep Ticks port). Wraparound is present - adding 1 to a frequency divider value of 2047 will cause it to roll over back to 0.
=== Sound Channel 3 Sweep Ticks ===
<pre>
7 bit 0
---- ----
...t tttt
| ||||
+-++++- Ticks per step - 1
</pre>
This port is used for wavetable output with sweep enabled.
Every <code>ttttt + 1</code> ticks, clocked at 375 Hz, the value in the Sweep Amount port will be added to the frequency divider for channel 3.
=== Sound Channel 4 Noise Control ===
<pre>
7 bit 0
---- ----
...e rttt
| ||||
| |+++- LFSR tap mode
| +---- LFSR reset: 1 = reset shift register
+------ LFSR enabled: 0 = off, 1 = on
</pre>
This port is used for noise output.
{| class="wikitable"
|+ List of LFSR tap modes
! Tap mode
! Tap bit
! Sequence length
|-
| 0
| 14
| 32767
|-
| 1
| 10
| 1953
|-
| 2
| 13
| 254
|-
| 3
| 4
| 217
|-
| 4
| 8
| 73
|-
| 5
| 6
| 63
|-
| 6
| 9
| 42
|-
| 7
| 11
| 28
|}
Noise output works using the following algorithm, performed once per sample generated:
# Create a new bit by XORing bit 7 with the tap bit.
# Shift the LFSR register one bit to the left.
# Write the new bit as bit 0.
# Use the new bit as if it were a wavetable sample: 0 = 0, 1 = 15.
=== Sound Wavetable Address ===
<pre>
7 bit 0
---- ----
wwww wwww
|||| ||||
++++-++++- Wavetable address (bits 6-13)
</pre>
The wavetable is 4 x 16 bytes long; each 16-byte block contains 32 4-bit samples for the relevant channel:
<pre>
Address $00 $01 $02 $03 $04 $05 $06 $07 $08 $09 $0A $0B $0C $0D $0E $0F
98 CB ED FF FF EF BD 8A 57 24 01 00 00 21 43 76
Sample
15 .. .. .. ## ## #. .. .. .. .. .. .. .. .. .. ..
14 .. .. .# || || |# .. .. .. .. .. .. .. .. .. ..
13 .. .. #| || || || #. .. .. .. .. .. .. .. .. ..
12 .. .# || || || || |. .. .. .. .. .. .. .. .. ..
11 .. #| || || || || |# .. .. .. .. .. .. .. .. ..
10 .. || || || || || || #. .. .. .. .. .. .. .. ..
9 .# || || || || || || |. .. .. .. .. .. .. .. ..
8 #| || || || || || || |# .. .. .. .. .. .. .. ..
7 || || || || || || || || #. .. .. .. .. .. .. .#
6 || || || || || || || || |. .. .. .. .. .. .. #|
5 || || || || || || || || |# .. .. .. .. .. .. ||
4 || || || || || || || || || #. .. .. .. .. .# ||
3 || || || || || || || || || |. .. .. .. .. #| ||
2 || || || || || || || || || |# .. .. .. .# || ||
1 || || || || || || || || || || #. .. .. #| || ||
0 || || || || || || || || || || |# ## ## || || ||
</pre>
Note that the ''higher'' bits - the first hexadecimal number - specify the ''later'' samples; that is to say, the nybbles of each sample are swapped relative to the wave drawing.
=== Sound Channel Control ===
<pre>
7 bit 0
---- ----
nsv. 4321
||| ||||
||| |||+- Channel 1 enable
||| ||+-- Channel 2 enable
||| |+--- Channel 3 enable
||| +---- Channel 4 enable
||+------- Channel 2 mode: 0 = wavetable, 1 = voice
|+-------- Channel 3 sweep: 0 = disable, 1 = enable
+--------- Channel 4 mode: 0 = wavetable, 1 = noise
</pre>
=== Sound Output Control ===
<pre>
7 bit 0
---- ----
H... hrrs
| ||||
| |||+- Internal speaker output enable
| |++-- Internal speaker shift right value
| +---- Headphone output enable
+--------- Headphones connected: 1 if true
</pre>
It is a good idea to set the internal speaker shift right value correctly. If the value is too low, multi-channel music will clip; if the value is too high, single-channel PCM sample playback will be very quiet.
=== Sound Channel 4 LFSR Register ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
.rrr rrrr rrrr rrrr
||| |||| |||| ||||
+++-++++--++++-++++- Shift register value
</pre>
=== Sound Channel 2 Voice Volume ===
<pre>
7 bit 0
---- ----
.... lLrR
||||
|||+- Right channel 100% volume
||+-- Right channel 50% volume
|+--- Left channel 100% volume
+---- Left channel 50% volume
</pre>
This port is used for voice output.
The <code>50% volume</code> have no effect if their respective <code>100% volume</code> bits are set.
da0c63c9675ff538908c8f73233c74e655f7b49c
119
107
2023-08-22T11:55:14Z
Asie
351
adjust port category name formatting
wikitext
text/x-wiki
The WonderSwan features the following sound hardware:
* Four audio channels:
** channel 1 - wavetable (32 x 4-bit samples),
** channel 2 - wavetable or 8-bit unsigned PCM sample,
** channel 3 - wavetable with optional hardware sweep,
** channel 4 - wavetable or LFSR noise,
* [[Hyper Voice]]<sup>(color)</sup> - headphone output exclusive 16-bit stereo PCM output,
* 24000 Hz output:
** internal speaker - 8-bit, mono,
** headphone output - 16-bit, stereo.
The sound is mixed as follows:
<pre>
Ch1 Ch2 Ch3 Ch4 Glossary: L = left, R = right, M = mono
| | | | Mnn = nn-bit mono
8 8 8 8 port $98 port $nn = value port
| | | | /
_V___V___V___V_ / _____ _____
| |--L10------+------| | | |
| + | | | + |--M11-->| >>r |--M8--> Speaker output
|_______________|--R10------|-+----|_____| / |_____|
/ _|_|_ / (r=0...3)
/ | | /
port $96 | <<5 | port $9A
|_____|
| |
| |
port $68 port $64 | |
/ _______________ \ __V_V__ _____
L8-->| (Color only) |--L16-->| |----------L16---| |
| Hyper Voice | | + + | | I2S |------> Headphone output
R8-->|_______________|--R16-->|_______|----------R16---|_____|
\ /
port $69 port $66
</pre>
[[Hyper Voice]] functionality is documented on its own sub-page.
== I/O Ports ==
{{Anchor|Sound Channel Frequency}}
=== Sound Channel Frequency ($80, $81; $82, $83; $84, $85; $86, $87) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
.... .ddd dddd dddd
||| |||| ||||
+++--++++-++++- Frequency divisor
</pre>
This frequency is used for wavetable output. It is calculated as follows: <code>sample rate = 3072000 Hz / (2048 - divisor)</code>.
Note that this refers to the sample rate of the ''wavetable'', and needs to be scaled accordingly for a given waveform when performing music playback.
{{Anchor|Sound Channel Volume}}
=== Sound Channel Volume ($88; $89; $8A; $8B) ===
<pre>
7 bit 0
---------
llll rrrr
|||| ||||
|||| ++++- Right channel volume (0-15)
++++------ Left channel volume (0-15)
</pre>
This volume is used for wavetable output.
The calculation to get an unsigned 8-bit sample out of a 4-bit wavetable sample / 4-bit volume pair is simple: <code>out_sample = sample * volume</code>. This means that the maximum sample in wavetable output mode is <code>15 * 15 = 225</code>.
{{Anchor|Sound Channel 2 Voice Sample}}
=== Sound Channel 2 Voice Sample ($89) ===
<pre>
7 bit 0
---- ----
ssss ssss
|||| ||||
++++-++++- Unsigned 8-bit PCM sample (0-255)
</pre>
This sample is used for voice output.
{{Anchor|Sound Channel 3 Sweep Amount}}
=== Sound Channel 3 Sweep Amount ($8C) ===
<pre>
7 bit 0
---- ----
vvvv vvvv
|||| ||||
++++-++++- Value; 8-bit, signed.
</pre>
This port is used for wavetable output with sweep enabled.
The signed value in this port will be added to the frequency divider for channel 3 every sweep step (as determined by the Sweep Ticks port). Wraparound is present - adding 1 to a frequency divider value of 2047 will cause it to roll over back to 0.
{{Anchor|Sound Channel 3 Sweep Ticks}}
=== Sound Channel 3 Sweep Ticks ($8D) ===
<pre>
7 bit 0
---- ----
...t tttt
| ||||
+-++++- Ticks per step - 1
</pre>
This port is used for wavetable output with sweep enabled.
Every <code>ttttt + 1</code> ticks, clocked at 375 Hz, the value in the Sweep Amount port will be added to the frequency divider for channel 3.
{{Anchor|Sound Channel 4 Noise Control}}
=== Sound Channel 4 Noise Control ($8F) ===
<pre>
7 bit 0
---- ----
...e rttt
| ||||
| |+++- LFSR tap mode
| +---- LFSR reset: 1 = reset shift register
+------ LFSR enabled: 0 = off, 1 = on
</pre>
This port is used for noise output.
{| class="wikitable"
|+ List of LFSR tap modes
! Tap mode
! Tap bit
! Sequence length
|-
| 0
| 14
| 32767
|-
| 1
| 10
| 1953
|-
| 2
| 13
| 254
|-
| 3
| 4
| 217
|-
| 4
| 8
| 73
|-
| 5
| 6
| 63
|-
| 6
| 9
| 42
|-
| 7
| 11
| 28
|}
Noise output works using the following algorithm, performed once per sample generated:
# Create a new bit by XORing bit 7 with the tap bit.
# Shift the LFSR register one bit to the left.
# Write the new bit as bit 0.
# Use the new bit as if it were a wavetable sample: 0 = 0, 1 = 15.
{{Anchor|Sound Wavetable Address}}
=== Sound Wavetable Address ($8F) ===
<pre>
7 bit 0
---- ----
wwww wwww
|||| ||||
++++-++++- Wavetable address (bits 6-13)
</pre>
The wavetable is 4 x 16 bytes long; each 16-byte block contains 32 4-bit samples for the relevant channel:
<pre>
Address $00 $01 $02 $03 $04 $05 $06 $07 $08 $09 $0A $0B $0C $0D $0E $0F
98 CB ED FF FF EF BD 8A 57 24 01 00 00 21 43 76
Sample
15 .. .. .. ## ## #. .. .. .. .. .. .. .. .. .. ..
14 .. .. .# || || |# .. .. .. .. .. .. .. .. .. ..
13 .. .. #| || || || #. .. .. .. .. .. .. .. .. ..
12 .. .# || || || || |. .. .. .. .. .. .. .. .. ..
11 .. #| || || || || |# .. .. .. .. .. .. .. .. ..
10 .. || || || || || || #. .. .. .. .. .. .. .. ..
9 .# || || || || || || |. .. .. .. .. .. .. .. ..
8 #| || || || || || || |# .. .. .. .. .. .. .. ..
7 || || || || || || || || #. .. .. .. .. .. .. .#
6 || || || || || || || || |. .. .. .. .. .. .. #|
5 || || || || || || || || |# .. .. .. .. .. .. ||
4 || || || || || || || || || #. .. .. .. .. .# ||
3 || || || || || || || || || |. .. .. .. .. #| ||
2 || || || || || || || || || |# .. .. .. .# || ||
1 || || || || || || || || || || #. .. .. #| || ||
0 || || || || || || || || || || |# ## ## || || ||
</pre>
Note that the ''higher'' bits - the first hexadecimal number - specify the ''later'' samples; that is to say, the nybbles of each sample are swapped relative to the wave drawing.
{{Anchor|Sound Channel Control}}
=== Sound Channel Control ($90) ===
<pre>
7 bit 0
---- ----
nsv. 4321
||| ||||
||| |||+- Channel 1 enable
||| ||+-- Channel 2 enable
||| |+--- Channel 3 enable
||| +---- Channel 4 enable
||+------- Channel 2 mode: 0 = wavetable, 1 = voice
|+-------- Channel 3 sweep: 0 = disable, 1 = enable
+--------- Channel 4 mode: 0 = wavetable, 1 = noise
</pre>
{{Anchor|Sound Output Control}}
=== Sound Output Control ($91) ===
<pre>
7 bit 0
---- ----
H... hrrs
| ||||
| |||+- Internal speaker output enable
| |++-- Internal speaker shift right value
| +---- Headphone output enable
+--------- Headphones connected: 1 if true
</pre>
It is a good idea to set the internal speaker shift right value correctly. If the value is too low, multi-channel music will clip; if the value is too high, single-channel PCM sample playback will be very quiet.
{{Anchor|Sound Channel 4 LFSR Register}}
=== Sound Channel 4 LFSR Register ($92, $93 read) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
.rrr rrrr rrrr rrrr
||| |||| |||| ||||
+++-++++--++++-++++- Shift register value
</pre>
{{Anchor|Sound Channel 2 Voice Volume}}
=== Sound Channel 2 Voice Volume ($94) ===
<pre>
7 bit 0
---- ----
.... lLrR
||||
|||+- Right channel 100% volume
||+-- Right channel 50% volume
|+--- Left channel 100% volume
+---- Left channel 50% volume
</pre>
This port is used for voice output.
The <code>50% volume</code> have no effect if their respective <code>100% volume</code> bits are set.
ba9f2fd5b05f6f5e6a024d314fb7ba5774ada07b
120
119
2023-08-22T11:56:09Z
Asie
351
wikitext
text/x-wiki
The WonderSwan features the following sound hardware:
* Four audio channels:
** channel 1 - wavetable (32 x 4-bit samples),
** channel 2 - wavetable or 8-bit unsigned PCM sample,
** channel 3 - wavetable with optional hardware sweep,
** channel 4 - wavetable or LFSR noise,
* [[Hyper Voice]]<sup>(color)</sup> - headphone output exclusive 16-bit stereo PCM output,
* 24000 Hz output:
** internal speaker - 8-bit, mono,
** headphone output - 16-bit, stereo.
The sound is mixed as follows:
<pre>
Ch1 Ch2 Ch3 Ch4 Glossary: L = left, R = right, M = mono
| | | | Mnn = nn-bit mono
8 8 8 8 port $98 port $nn = value port
| | | | /
_V___V___V___V_ / _____ _____
| |--L10------+------| | | |
| + | | | + |--M11-->| >>r |--M8--> Speaker output
|_______________|--R10------|-+----|_____| / |_____|
/ _|_|_ / (r=0...3)
/ | | /
port $96 | <<5 | port $9A
|_____|
| |
| |
port $68 port $64 | |
/ _______________ \ __V_V__ _____
L8-->| (Color only) |--L16-->| |----------L16---| |
| Hyper Voice | | + + | | I2S |------> Headphone output
R8-->|_______________|--R16-->|_______|----------R16---|_____|
\ /
port $69 port $66
</pre>
[[Hyper Voice]] functionality is documented on its own sub-page.
== I/O Ports ==
{{Anchor|Sound Channel Frequency}}
=== Sound Channel Frequency ($80, $81; $82, $83; $84, $85; $86, $87) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
.... .ddd dddd dddd
||| |||| ||||
+++--++++-++++- Frequency divisor
</pre>
This frequency is used for wavetable output. It is calculated as follows: <code>sample rate = 3072000 Hz / (2048 - divisor)</code>.
Note that this refers to the sample rate of the ''wavetable'', and needs to be scaled accordingly for a given waveform when performing music playback.
{{Anchor|Sound Channel Volume}}
=== Sound Channel Volume ($88; $89; $8A; $8B) ===
<pre>
7 bit 0
---------
llll rrrr
|||| ||||
|||| ++++- Right channel volume (0-15)
++++------ Left channel volume (0-15)
</pre>
This volume is used for wavetable output.
The calculation to get an unsigned 8-bit sample out of a 4-bit wavetable sample / 4-bit volume pair is simple: <code>out_sample = sample * volume</code>. This means that the maximum sample in wavetable output mode is <code>15 * 15 = 225</code>.
{{Anchor|Sound Channel 2 Voice Sample}}
=== Sound Channel 2 Voice Sample ($89) ===
<pre>
7 bit 0
---- ----
ssss ssss
|||| ||||
++++-++++- Unsigned 8-bit PCM sample (0-255)
</pre>
This sample is used for voice output.
{{Anchor|Sound Channel 3 Sweep Amount}}
=== Sound Channel 3 Sweep Amount ($8C) ===
<pre>
7 bit 0
---- ----
vvvv vvvv
|||| ||||
++++-++++- Value; 8-bit, signed.
</pre>
This port is used for wavetable output with sweep enabled.
The signed value in this port will be added to the frequency divider for channel 3 every sweep step (as determined by the Sweep Ticks port). Wraparound is present - adding 1 to a frequency divider value of 2047 will cause it to roll over back to 0.
{{Anchor|Sound Channel 3 Sweep Ticks}}
=== Sound Channel 3 Sweep Ticks ($8D) ===
<pre>
7 bit 0
---- ----
...t tttt
| ||||
+-++++- Ticks per step - 1
</pre>
This port is used for wavetable output with sweep enabled.
Every <code>ttttt + 1</code> ticks, clocked at 375 Hz, the value in the Sweep Amount port will be added to the frequency divider for channel 3.
{{Anchor|Sound Channel 4 Noise Control}}
=== Sound Channel 4 Noise Control ($8E) ===
<pre>
7 bit 0
---- ----
...e rttt
| ||||
| |+++- LFSR tap mode
| +---- LFSR reset: 1 = reset shift register
+------ LFSR enabled: 0 = off, 1 = on
</pre>
This port is used for noise output.
{| class="wikitable"
|+ List of LFSR tap modes
! Tap mode
! Tap bit
! Sequence length
|-
| 0
| 14
| 32767
|-
| 1
| 10
| 1953
|-
| 2
| 13
| 254
|-
| 3
| 4
| 217
|-
| 4
| 8
| 73
|-
| 5
| 6
| 63
|-
| 6
| 9
| 42
|-
| 7
| 11
| 28
|}
Noise output works using the following algorithm, performed once per sample generated:
# Create a new bit by XORing bit 7 with the tap bit.
# Shift the LFSR register one bit to the left.
# Write the new bit as bit 0.
# Use the new bit as if it were a wavetable sample: 0 = 0, 1 = 15.
{{Anchor|Sound Wavetable Address}}
=== Sound Wavetable Address ($8F) ===
<pre>
7 bit 0
---- ----
wwww wwww
|||| ||||
++++-++++- Wavetable address (bits 6-13)
</pre>
The wavetable is 4 x 16 bytes long; each 16-byte block contains 32 4-bit samples for the relevant channel:
<pre>
Address $00 $01 $02 $03 $04 $05 $06 $07 $08 $09 $0A $0B $0C $0D $0E $0F
98 CB ED FF FF EF BD 8A 57 24 01 00 00 21 43 76
Sample
15 .. .. .. ## ## #. .. .. .. .. .. .. .. .. .. ..
14 .. .. .# || || |# .. .. .. .. .. .. .. .. .. ..
13 .. .. #| || || || #. .. .. .. .. .. .. .. .. ..
12 .. .# || || || || |. .. .. .. .. .. .. .. .. ..
11 .. #| || || || || |# .. .. .. .. .. .. .. .. ..
10 .. || || || || || || #. .. .. .. .. .. .. .. ..
9 .# || || || || || || |. .. .. .. .. .. .. .. ..
8 #| || || || || || || |# .. .. .. .. .. .. .. ..
7 || || || || || || || || #. .. .. .. .. .. .. .#
6 || || || || || || || || |. .. .. .. .. .. .. #|
5 || || || || || || || || |# .. .. .. .. .. .. ||
4 || || || || || || || || || #. .. .. .. .. .# ||
3 || || || || || || || || || |. .. .. .. .. #| ||
2 || || || || || || || || || |# .. .. .. .# || ||
1 || || || || || || || || || || #. .. .. #| || ||
0 || || || || || || || || || || |# ## ## || || ||
</pre>
Note that the ''higher'' bits - the first hexadecimal number - specify the ''later'' samples; that is to say, the nybbles of each sample are swapped relative to the wave drawing.
{{Anchor|Sound Channel Control}}
=== Sound Channel Control ($90) ===
<pre>
7 bit 0
---- ----
nsv. 4321
||| ||||
||| |||+- Channel 1 enable
||| ||+-- Channel 2 enable
||| |+--- Channel 3 enable
||| +---- Channel 4 enable
||+------- Channel 2 mode: 0 = wavetable, 1 = voice
|+-------- Channel 3 sweep: 0 = disable, 1 = enable
+--------- Channel 4 mode: 0 = wavetable, 1 = noise
</pre>
{{Anchor|Sound Output Control}}
=== Sound Output Control ($91) ===
<pre>
7 bit 0
---- ----
H... hrrs
| ||||
| |||+- Internal speaker output enable
| |++-- Internal speaker shift right value
| +---- Headphone output enable
+--------- Headphones connected: 1 if true
</pre>
It is a good idea to set the internal speaker shift right value correctly. If the value is too low, multi-channel music will clip; if the value is too high, single-channel PCM sample playback will be very quiet.
{{Anchor|Sound Channel 4 LFSR Register}}
=== Sound Channel 4 LFSR Register ($92, $93 read) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
.rrr rrrr rrrr rrrr
||| |||| |||| ||||
+++-++++--++++-++++- Shift register value
</pre>
{{Anchor|Sound Channel 2 Voice Volume}}
=== Sound Channel 2 Voice Volume ($94) ===
<pre>
7 bit 0
---- ----
.... lLrR
||||
|||+- Right channel 100% volume
||+-- Right channel 50% volume
|+--- Left channel 100% volume
+---- Left channel 50% volume
</pre>
This port is used for voice output.
The <code>50% volume</code> have no effect if their respective <code>100% volume</code> bits are set.
93b4bd92460a9225a15821ef72100ec43db6b8c7
125
120
2023-08-22T12:08:12Z
Asie
351
wikitext
text/x-wiki
The WonderSwan features the following sound hardware:
* Four audio channels:
** channel 1 - wavetable (32 x 4-bit samples),
** channel 2 - wavetable or 8-bit unsigned PCM sample,
** channel 3 - wavetable with optional hardware sweep,
** channel 4 - wavetable or LFSR noise,
* [[Hyper Voice]]<sup>(color)</sup> - headphone output exclusive 16-bit stereo PCM output,
* 24000 Hz output:
** internal speaker - 8-bit, mono,
** headphone output - 16-bit, stereo.
[[Hyper Voice]] functionality is documented on its own sub-page.
== Mixing diagram ==
The sound is mixed as follows:
<pre>
Ch1 Ch2 Ch3 Ch4 Glossary: L = left, R = right, M = mono
| | | | Mnn = nn-bit mono
8 8 8 8 port $98 port $nn = value port
| | | | /
_V___V___V___V_ / _____ _____
| |--L10------+------| | | |
| + | | | + |--M11-->| >>r |--M8--> Speaker output
|_______________|--R10------|-+----|_____| / |_____|
/ _|_|_ / (r=0...3)
/ | | /
port $96 | <<5 | port $9A
|_____|
| |
| |
port $68 port $64 | |
/ _______________ \ __V_V__ _____
L8-->| (Color only) |--L16-->| |----------L16---| |
| Hyper Voice | | + + | | I2S |------> Headphone output
R8-->|_______________|--R16-->|_______|----------R16---|_____|
\ /
port $69 port $66
</pre>
== I/O Ports ==
{{Anchor|Sound Channel Frequency}}
=== Sound Channel Frequency ($80, $81; $82, $83; $84, $85; $86, $87) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
.... .ddd dddd dddd
||| |||| ||||
+++--++++-++++- Frequency divisor
</pre>
This frequency is used for wavetable output. It is calculated as follows: <code>sample rate = 3072000 Hz / (2048 - divisor)</code>.
Note that this refers to the sample rate of the ''wavetable'', and needs to be scaled accordingly for a given waveform when performing music playback.
{{Anchor|Sound Channel Volume}}
=== Sound Channel Volume ($88; $89; $8A; $8B) ===
<pre>
7 bit 0
---------
llll rrrr
|||| ||||
|||| ++++- Right channel volume (0-15)
++++------ Left channel volume (0-15)
</pre>
This volume is used for wavetable output.
The calculation to get an unsigned 8-bit sample out of a 4-bit wavetable sample / 4-bit volume pair is simple: <code>out_sample = sample * volume</code>. This means that the maximum sample in wavetable output mode is <code>15 * 15 = 225</code>.
{{Anchor|Sound Channel 2 Voice Sample}}
=== Sound Channel 2 Voice Sample ($89) ===
<pre>
7 bit 0
---- ----
ssss ssss
|||| ||||
++++-++++- Unsigned 8-bit PCM sample (0-255)
</pre>
This sample is used for voice output.
{{Anchor|Sound Channel 3 Sweep Amount}}
=== Sound Channel 3 Sweep Amount ($8C) ===
<pre>
7 bit 0
---- ----
vvvv vvvv
|||| ||||
++++-++++- Value; 8-bit, signed.
</pre>
This port is used for wavetable output with sweep enabled.
The signed value in this port will be added to the frequency divider for channel 3 every sweep step (as determined by the Sweep Ticks port). Wraparound is present - adding 1 to a frequency divider value of 2047 will cause it to roll over back to 0.
{{Anchor|Sound Channel 3 Sweep Ticks}}
=== Sound Channel 3 Sweep Ticks ($8D) ===
<pre>
7 bit 0
---- ----
...t tttt
| ||||
+-++++- Ticks per step - 1
</pre>
This port is used for wavetable output with sweep enabled.
Every <code>ttttt + 1</code> ticks, clocked at 375 Hz, the value in the Sweep Amount port will be added to the frequency divider for channel 3.
{{Anchor|Sound Channel 4 Noise Control}}
=== Sound Channel 4 Noise Control ($8E) ===
<pre>
7 bit 0
---- ----
...e rttt
| ||||
| |+++- LFSR tap mode
| +---- LFSR reset: 1 = reset shift register
+------ LFSR enabled: 0 = off, 1 = on
</pre>
This port is used for noise output.
{| class="wikitable"
|+ List of LFSR tap modes
! Tap mode
! Tap bit
! Sequence length
|-
| 0
| 14
| 32767
|-
| 1
| 10
| 1953
|-
| 2
| 13
| 254
|-
| 3
| 4
| 217
|-
| 4
| 8
| 73
|-
| 5
| 6
| 63
|-
| 6
| 9
| 42
|-
| 7
| 11
| 28
|}
Noise output works using the following algorithm, performed once per sample generated:
# Create a new bit by XORing bit 7 with the tap bit.
# Shift the LFSR register one bit to the left.
# Write the new bit as bit 0.
# Use the new bit as if it were a wavetable sample: 0 = 0, 1 = 15.
{{Anchor|Sound Wavetable Address}}
=== Sound Wavetable Address ($8F) ===
<pre>
7 bit 0
---- ----
wwww wwww
|||| ||||
++++-++++- Wavetable address (bits 6-13)
</pre>
The wavetable is 4 x 16 bytes long; each 16-byte block contains 32 4-bit samples for the relevant channel:
<pre>
Address $00 $01 $02 $03 $04 $05 $06 $07 $08 $09 $0A $0B $0C $0D $0E $0F
98 CB ED FF FF EF BD 8A 57 24 01 00 00 21 43 76
Sample
15 .. .. .. ## ## #. .. .. .. .. .. .. .. .. .. ..
14 .. .. .# || || |# .. .. .. .. .. .. .. .. .. ..
13 .. .. #| || || || #. .. .. .. .. .. .. .. .. ..
12 .. .# || || || || |. .. .. .. .. .. .. .. .. ..
11 .. #| || || || || |# .. .. .. .. .. .. .. .. ..
10 .. || || || || || || #. .. .. .. .. .. .. .. ..
9 .# || || || || || || |. .. .. .. .. .. .. .. ..
8 #| || || || || || || |# .. .. .. .. .. .. .. ..
7 || || || || || || || || #. .. .. .. .. .. .. .#
6 || || || || || || || || |. .. .. .. .. .. .. #|
5 || || || || || || || || |# .. .. .. .. .. .. ||
4 || || || || || || || || || #. .. .. .. .. .# ||
3 || || || || || || || || || |. .. .. .. .. #| ||
2 || || || || || || || || || |# .. .. .. .# || ||
1 || || || || || || || || || || #. .. .. #| || ||
0 || || || || || || || || || || |# ## ## || || ||
</pre>
Note that the ''higher'' bits - the first hexadecimal number - specify the ''later'' samples; that is to say, the nybbles of each sample are swapped relative to the wave drawing.
{{Anchor|Sound Channel Control}}
=== Sound Channel Control ($90) ===
<pre>
7 bit 0
---- ----
nsv. 4321
||| ||||
||| |||+- Channel 1 enable
||| ||+-- Channel 2 enable
||| |+--- Channel 3 enable
||| +---- Channel 4 enable
||+------- Channel 2 mode: 0 = wavetable, 1 = voice
|+-------- Channel 3 sweep: 0 = disable, 1 = enable
+--------- Channel 4 mode: 0 = wavetable, 1 = noise
</pre>
{{Anchor|Sound Output Control}}
=== Sound Output Control ($91) ===
<pre>
7 bit 0
---- ----
H... hrrs
| ||||
| |||+- Internal speaker output enable
| |++-- Internal speaker shift right value
| +---- Headphone output enable
+--------- Headphones connected: 1 if true
</pre>
It is a good idea to set the internal speaker shift right value correctly. If the value is too low, multi-channel music will clip; if the value is too high, single-channel PCM sample playback will be very quiet.
{{Anchor|Sound Channel 4 LFSR Register}}
=== Sound Channel 4 LFSR Register ($92, $93 read) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
.rrr rrrr rrrr rrrr
||| |||| |||| ||||
+++-++++--++++-++++- Shift register value
</pre>
{{Anchor|Sound Channel 2 Voice Volume}}
=== Sound Channel 2 Voice Volume ($94) ===
<pre>
7 bit 0
---- ----
.... lLrR
||||
|||+- Right channel 100% volume
||+-- Right channel 50% volume
|+--- Left channel 100% volume
+---- Left channel 50% volume
</pre>
This port is used for voice output.
The <code>50% volume</code> have no effect if their respective <code>100% volume</code> bits are set.
3af9bda4a3bdbf03e3809535585fc943928bad3e
127
125
2023-08-22T12:11:07Z
Asie
351
wikitext
text/x-wiki
The WonderSwan features the following sound hardware:
* Four audio channels:
** channel 1 - wavetable (32 x 4-bit samples),
** channel 2 - wavetable or 8-bit unsigned PCM sample,
** channel 3 - wavetable with optional hardware sweep,
** channel 4 - wavetable or LFSR noise,
* [[Hyper Voice]]<sup>(color)</sup> - headphone output exclusive 16-bit stereo PCM output,
* 24000 Hz output:
** internal speaker - 8-bit, mono,
** headphone output - 16-bit, stereo.
[[Hyper Voice]] functionality is documented on its own sub-page.
== Mixing diagram ==
The sound is mixed as follows:
<pre>
Ch1 Ch2 Ch3 Ch4 Glossary: L = left, R = right, M = mono
| | | | Mnn = nn-bit mono
8 8 8 8 port $98 port $nn = value port
| | | | /
_V___V___V___V_ / _____ _____
| |--L10------+------| | | |
| + | | | + |--M11-->| >>r |--M8--> Speaker output
|_______________|--R10------|-+----|_____| / |_____|
/ _|_|_ / (r=0...3)
/ | | /
port $96 | <<5 | port $9A
|_____|
| |
| |
port $68 port $64 | |
/ _______________ \ __V_V__ _____
L8-->| (Color only) |--L16-->| |----------L16---| |
| Hyper Voice | | + + | | I2S |------> Headphone output
R8-->|_______________|--R16-->|_______|----------R16---|_____|
\ /
port $69 port $66
</pre>
== I/O Ports ==
{{Anchor|Sound Channel Frequency}}
=== Sound Channel Frequency ($80, $81; $82, $83; $84, $85; $86, $87) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
.... .ddd dddd dddd
||| |||| ||||
+++--++++-++++- Frequency divisor
</pre>
This frequency is used for wavetable output. It is calculated as follows: <code>sample rate = 3072000 Hz / (2048 - divisor)</code>.
Note that this refers to the sample rate of the ''wavetable'', and needs to be scaled accordingly for a given waveform when performing music playback.
{{Anchor|Sound Channel Volume}}
=== Sound Channel Volume ($88; $89; $8A; $8B) ===
<pre>
7 bit 0
---------
llll rrrr
|||| ||||
|||| ++++- Right channel volume (0-15)
++++------ Left channel volume (0-15)
</pre>
This volume is used for wavetable output.
The calculation to get an unsigned 8-bit sample out of a 4-bit wavetable sample / 4-bit volume pair is simple: <code>out_sample = sample * volume</code>. This means that the maximum sample in wavetable output mode is <code>15 * 15 = 225</code>.
{{Anchor|Sound Channel 2 Voice Sample}}
=== Sound Channel 2 Voice Sample ($89) ===
<pre>
7 bit 0
---- ----
ssss ssss
|||| ||||
++++-++++- Unsigned 8-bit PCM sample (0-255)
</pre>
This sample is used for voice output.
{{Anchor|Sound Channel 3 Sweep Amount}}
=== Sound Channel 3 Sweep Amount ($8C) ===
<pre>
7 bit 0
---- ----
vvvv vvvv
|||| ||||
++++-++++- Value; 8-bit, signed.
</pre>
This port is used for wavetable output with sweep enabled.
The signed value in this port will be added to the frequency divider for channel 3 every sweep step (as determined by the Sweep Ticks port). Wraparound is present - adding 1 to a frequency divider value of 2047 will cause it to roll over back to 0.
{{Anchor|Sound Channel 3 Sweep Ticks}}
=== Sound Channel 3 Sweep Ticks ($8D) ===
<pre>
7 bit 0
---- ----
...t tttt
| ||||
+-++++- Ticks per step - 1
</pre>
This port is used for wavetable output with sweep enabled.
Every <code>ttttt + 1</code> ticks, clocked at 375 Hz, the value in the Sweep Amount port will be added to the frequency divider for channel 3.
{{Anchor|Sound Channel 4 Noise Control}}
=== Sound Channel 4 Noise Control ($8E) ===
<pre>
7 bit 0
---- ----
...e rttt
| ||||
| |+++- LFSR tap mode
| +---- LFSR reset: 1 = reset shift register
+------ LFSR enabled: 0 = off, 1 = on
</pre>
This port is used for noise output.
{| class="wikitable"
|+ List of LFSR tap modes
! Tap mode
! Tap bit
! Sequence length
|-
| 0
| 14
| 32767
|-
| 1
| 10
| 1953
|-
| 2
| 13
| 254
|-
| 3
| 4
| 217
|-
| 4
| 8
| 73
|-
| 5
| 6
| 63
|-
| 6
| 9
| 42
|-
| 7
| 11
| 28
|}
Noise output works using the following algorithm, performed once per sample generated:
# Create a new bit by XORing bit 7 with the tap bit.
# Shift the LFSR register one bit to the left.
# Write the new bit as bit 0.
# Use the new bit as if it were a wavetable sample: 0 = 0, 1 = 15.
{{Anchor|Sound Wavetable Address}}
=== Sound Wavetable Address ($8F) ===
<pre>
7 bit 0
---- ----
wwww wwww
|||| ||||
++++-++++- Wavetable address (bits 6-13)
</pre>
The wavetable is 4 x 16 bytes long; each 16-byte block contains 32 4-bit samples for the relevant channel:
<pre>
Address $00 $01 $02 $03 $04 $05 $06 $07 $08 $09 $0A $0B $0C $0D $0E $0F
98 CB ED FF FF EF BD 8A 57 24 01 00 00 21 43 76
Sample
15 .. .. .. ## ## #. .. .. .. .. .. .. .. .. .. ..
14 .. .. .# || || |# .. .. .. .. .. .. .. .. .. ..
13 .. .. #| || || || #. .. .. .. .. .. .. .. .. ..
12 .. .# || || || || |. .. .. .. .. .. .. .. .. ..
11 .. #| || || || || |# .. .. .. .. .. .. .. .. ..
10 .. || || || || || || #. .. .. .. .. .. .. .. ..
9 .# || || || || || || |. .. .. .. .. .. .. .. ..
8 #| || || || || || || |# .. .. .. .. .. .. .. ..
7 || || || || || || || || #. .. .. .. .. .. .. .#
6 || || || || || || || || |. .. .. .. .. .. .. #|
5 || || || || || || || || |# .. .. .. .. .. .. ||
4 || || || || || || || || || #. .. .. .. .. .# ||
3 || || || || || || || || || |. .. .. .. .. #| ||
2 || || || || || || || || || |# .. .. .. .# || ||
1 || || || || || || || || || || #. .. .. #| || ||
0 || || || || || || || || || || |# ## ## || || ||
</pre>
Note that the ''higher'' bits - the first hexadecimal number - specify the ''later'' samples; that is to say, the nybbles of each sample are swapped relative to the wave drawing.
{{Anchor|Sound Channel Control}}
=== Sound Channel Control ($90) ===
<pre>
7 bit 0
---- ----
nsv. 4321
||| ||||
||| |||+- Channel 1 enable
||| ||+-- Channel 2 enable
||| |+--- Channel 3 enable
||| +---- Channel 4 enable
||+------- Channel 2 mode: 0 = wavetable, 1 = voice
|+-------- Channel 3 sweep: 0 = disable, 1 = enable
+--------- Channel 4 mode: 0 = wavetable, 1 = noise
</pre>
{{Anchor|Sound Output Control}}
=== Sound Output Control ($91) ===
<pre>
7 bit 0
---- ----
H... hrrs
| ||||
| |||+- Internal speaker output enable
| |++-- Internal speaker shift right value
| +---- Headphone output enable
+--------- Headphones connected: 1 if true
</pre>
It is a good idea to set the internal speaker shift right value correctly. If the value is too low, multi-channel music will clip; if the value is too high, single-channel PCM sample playback will be very quiet.
{{Anchor|Sound Channel 4 LFSR Register}}
=== Sound Channel 4 LFSR Register ($92, $93 read) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
.rrr rrrr rrrr rrrr
||| |||| |||| ||||
+++-++++--++++-++++- Shift register value
</pre>
{{Anchor|Sound Channel 2 Voice Volume}}
=== Sound Channel 2 Voice Volume ($94) ===
<pre>
7 bit 0
---- ----
.... lLrR
||||
|||+- Right channel 100% volume
||+-- Right channel 50% volume
|+--- Left channel 100% volume
+---- Left channel 50% volume
</pre>
This port is used for voice output.
The <code>50% volume</code> have no effect if their respective <code>100% volume</code> bits are set.
{{Anchor|Sound Channel Output Right}}
=== Sound Channel Output Right ($96, $97 read) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
.... ..ss ssss ssss
++--++++-++++- Unsigned 10-bit sample
</pre>
{{Anchor|Sound Channel Output Left}}
=== Sound Channel Output Left ($98, $99 read) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
.... ..ss ssss ssss
++--++++-++++- Unsigned 10-bit sample
</pre>
{{Anchor|Sound Channel Output Sum}}
=== Sound Channel Output Sum ($9A, $9B read) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
.... .sss ssss ssss
+++--++++-++++- Unsigned 11-bit sample
</pre>
bdf9dfdae7d8ce5560cf92ed8be8196440f71563
147
127
2023-08-22T14:08:42Z
Fiskbit
37
Register formatting.
wikitext
text/x-wiki
The WonderSwan features the following sound hardware:
* Four audio channels:
** channel 1 - wavetable (32 x 4-bit samples),
** channel 2 - wavetable or 8-bit unsigned PCM sample,
** channel 3 - wavetable with optional hardware sweep,
** channel 4 - wavetable or LFSR noise,
* [[Hyper Voice]]<sup>(color)</sup> - headphone output exclusive 16-bit stereo PCM output,
* 24000 Hz output:
** internal speaker - 8-bit, mono,
** headphone output - 16-bit, stereo.
[[Hyper Voice]] functionality is documented on its own sub-page.
== Mixing diagram ==
The sound is mixed as follows:
<pre>
Ch1 Ch2 Ch3 Ch4 Glossary: L = left, R = right, M = mono
| | | | Mnn = nn-bit mono
8 8 8 8 port $98 port $nn = value port
| | | | /
_V___V___V___V_ / _____ _____
| |--L10------+------| | | |
| + | | | + |--M11-->| >>r |--M8--> Speaker output
|_______________|--R10------|-+----|_____| / |_____|
/ _|_|_ / (r=0...3)
/ | | /
port $96 | <<5 | port $9A
|_____|
| |
| |
port $68 port $64 | |
/ _______________ \ __V_V__ _____
L8-->| (Color only) |--L16-->| |----------L16---| |
| Hyper Voice | | + + | | I2S |------> Headphone output
R8-->|_______________|--R16-->|_______|----------R16---|_____|
\ /
port $69 port $66
</pre>
== I/O Ports ==
{{Anchor|Sound Channel Frequency}}
=== Sound Channel Frequency ($80, $81; $82, $83; $84, $85; $86, $87) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
.... .ddd dddd dddd
||| |||| ||||
+++--++++-++++- Frequency divisor
</pre>
This frequency is used for wavetable output. It is calculated as follows: <code>sample rate = 3072000 Hz / (2048 - divisor)</code>.
Note that this refers to the sample rate of the ''wavetable'', and needs to be scaled accordingly for a given waveform when performing music playback.
{{Anchor|Sound Channel Volume}}
=== Sound Channel Volume ($88; $89; $8A; $8B) ===
<pre>
7 bit 0
---------
llll rrrr
|||| ||||
|||| ++++- Right channel volume (0-15)
++++------ Left channel volume (0-15)
</pre>
This volume is used for wavetable output.
The calculation to get an unsigned 8-bit sample out of a 4-bit wavetable sample / 4-bit volume pair is simple: <code>out_sample = sample * volume</code>. This means that the maximum sample in wavetable output mode is <code>15 * 15 = 225</code>.
{{Anchor|Sound Channel 2 Voice Sample}}
=== Sound Channel 2 Voice Sample ($89) ===
<pre>
7 bit 0
---- ----
ssss ssss
|||| ||||
++++-++++- Unsigned 8-bit PCM sample (0-255)
</pre>
This sample is used for voice output.
{{Anchor|Sound Channel 3 Sweep Amount}}
=== Sound Channel 3 Sweep Amount ($8C) ===
<pre>
7 bit 0
---- ----
vvvv vvvv
|||| ||||
++++-++++- Value; 8-bit, signed.
</pre>
This port is used for wavetable output with sweep enabled.
The signed value in this port will be added to the frequency divider for channel 3 every sweep step (as determined by the Sweep Ticks port). Wraparound is present - adding 1 to a frequency divider value of 2047 will cause it to roll over back to 0.
{{Anchor|Sound Channel 3 Sweep Ticks}}
=== Sound Channel 3 Sweep Ticks ($8D) ===
<pre>
7 bit 0
---- ----
...t tttt
| ||||
+-++++- Ticks per step - 1
</pre>
This port is used for wavetable output with sweep enabled.
Every <code>ttttt + 1</code> ticks, clocked at 375 Hz, the value in the Sweep Amount port will be added to the frequency divider for channel 3.
{{Anchor|Sound Channel 4 Noise Control}}
=== Sound Channel 4 Noise Control ($8E) ===
<pre>
7 bit 0
---- ----
...e rttt
| ||||
| |+++- LFSR tap mode
| +---- LFSR reset: 1 = reset shift register
+------ LFSR enabled: 0 = off, 1 = on
</pre>
This port is used for noise output.
{| class="wikitable"
|+ List of LFSR tap modes
! Tap mode
! Tap bit
! Sequence length
|-
| 0
| 14
| 32767
|-
| 1
| 10
| 1953
|-
| 2
| 13
| 254
|-
| 3
| 4
| 217
|-
| 4
| 8
| 73
|-
| 5
| 6
| 63
|-
| 6
| 9
| 42
|-
| 7
| 11
| 28
|}
Noise output works using the following algorithm, performed once per sample generated:
# Create a new bit by XORing bit 7 with the tap bit.
# Shift the LFSR register one bit to the left.
# Write the new bit as bit 0.
# Use the new bit as if it were a wavetable sample: 0 = 0, 1 = 15.
{{Anchor|Sound Wavetable Address}}
=== Sound Wavetable Address ($8F) ===
<pre>
7 bit 0
---- ----
wwww wwww
|||| ||||
++++-++++- Wavetable address (bits 6-13)
</pre>
The wavetable is 4 x 16 bytes long; each 16-byte block contains 32 4-bit samples for the relevant channel:
<pre>
Address $00 $01 $02 $03 $04 $05 $06 $07 $08 $09 $0A $0B $0C $0D $0E $0F
98 CB ED FF FF EF BD 8A 57 24 01 00 00 21 43 76
Sample
15 .. .. .. ## ## #. .. .. .. .. .. .. .. .. .. ..
14 .. .. .# || || |# .. .. .. .. .. .. .. .. .. ..
13 .. .. #| || || || #. .. .. .. .. .. .. .. .. ..
12 .. .# || || || || |. .. .. .. .. .. .. .. .. ..
11 .. #| || || || || |# .. .. .. .. .. .. .. .. ..
10 .. || || || || || || #. .. .. .. .. .. .. .. ..
9 .# || || || || || || |. .. .. .. .. .. .. .. ..
8 #| || || || || || || |# .. .. .. .. .. .. .. ..
7 || || || || || || || || #. .. .. .. .. .. .. .#
6 || || || || || || || || |. .. .. .. .. .. .. #|
5 || || || || || || || || |# .. .. .. .. .. .. ||
4 || || || || || || || || || #. .. .. .. .. .# ||
3 || || || || || || || || || |. .. .. .. .. #| ||
2 || || || || || || || || || |# .. .. .. .# || ||
1 || || || || || || || || || || #. .. .. #| || ||
0 || || || || || || || || || || |# ## ## || || ||
</pre>
Note that the ''higher'' bits - the first hexadecimal number - specify the ''later'' samples; that is to say, the nybbles of each sample are swapped relative to the wave drawing.
{{Anchor|Sound Channel Control}}
=== Sound Channel Control ($90) ===
<pre>
7 bit 0
---- ----
nsv. 4321
||| ||||
||| |||+- Channel 1 enable
||| ||+-- Channel 2 enable
||| |+--- Channel 3 enable
||| +---- Channel 4 enable
||+------- Channel 2 mode: 0 = wavetable, 1 = voice
|+-------- Channel 3 sweep: 0 = disable, 1 = enable
+--------- Channel 4 mode: 0 = wavetable, 1 = noise
</pre>
{{Anchor|Sound Output Control}}
=== Sound Output Control ($91) ===
<pre>
7 bit 0
---- ----
H... hrrs
| ||||
| |||+- Internal speaker output enable
| |++-- Internal speaker shift right value
| +---- Headphone output enable
+--------- Headphones connected: 1 if true
</pre>
It is a good idea to set the internal speaker shift right value correctly. If the value is too low, multi-channel music will clip; if the value is too high, single-channel PCM sample playback will be very quiet.
{{Anchor|Sound Channel 4 LFSR Register}}
=== Sound Channel 4 LFSR Register ($92, $93 read) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
.rrr rrrr rrrr rrrr
||| |||| |||| ||||
+++-++++--++++-++++- Shift register value
</pre>
{{Anchor|Sound Channel 2 Voice Volume}}
=== Sound Channel 2 Voice Volume ($94) ===
<pre>
7 bit 0
---- ----
.... lLrR
||||
|||+- Right channel 100% volume
||+-- Right channel 50% volume
|+--- Left channel 100% volume
+---- Left channel 50% volume
</pre>
This port is used for voice output.
The <code>50% volume</code> have no effect if their respective <code>100% volume</code> bits are set.
{{Anchor|Sound Channel Output Right}}
=== Sound Channel Output Right ($96, $97 read) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
.... ..ss ssss ssss
|| |||| ||||
++--++++-++++- Unsigned 10-bit sample
</pre>
{{Anchor|Sound Channel Output Left}}
=== Sound Channel Output Left ($98, $99 read) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
.... ..ss ssss ssss
|| |||| ||||
++--++++-++++- Unsigned 10-bit sample
</pre>
{{Anchor|Sound Channel Output Sum}}
=== Sound Channel Output Sum ($9A, $9B read) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
.... .sss ssss ssss
||| |||| ||||
+++--++++-++++- Unsigned 11-bit sample
</pre>
e39a122aa082e9bd17f06d6296043cbac289e10b
Timers
0
24
108
86
2023-08-22T10:50:33Z
Fiskbit
37
Register formatting.
wikitext
text/x-wiki
The WonderSwan features two timers:
* Horizontal Blank Timer - counts down every horizontal blank (256 CPU cycles),
* Vertical Blank Timer - counts down every vertical blank (beginning of line 144).
The timers also feature an auto-reload functionality: that is, they can be configured to fire one time or repeat periodically.
== Interrupts ==
Each timer has its own interrupt; it is triggered when the counter would be about to count down to zero, that is when the counter's value is 1 and the timer condition occurs.
This leads to a quirk: the timer interrupt will be triggered if the reload value is set to one ''even if the timer countdown is disabled'', so long as the interrupt is enabled.
== I/O Ports ==
=== Timer Control ===
<pre>
7 bit 0
---- ----
.... VvHh
||||
|||+- Horizontal blank timer: Enable countdown.
||+-- Horizontal blank timer: 0: One-shot, 1: Repeat/auto-reload.
|+--- Vertical blank timer: Enable countdown.
+---- Vertical blank timer: 0: One-shot, 1: Repeat/auto-reload.
</pre>
=== Timer Reload ===
Read/write; contains the initial counter value. The Timer Counter port is immediately initialized with this value upon writing. If auto-reload is enabled, the interrupt trigger will re-initialize the Timer Counter port with this value.
=== Timer Counter ===
Read-only; contains the current value of the counter.
Note that if auto-reload is enabled, this will never contain the value zero.
ee1589b1d5e228967f28f19788a66ec00e318d77
117
108
2023-08-22T11:51:35Z
Asie
351
adjust port category name formatting
wikitext
text/x-wiki
The WonderSwan features two timers:
* Horizontal Blank Timer - counts down every horizontal blank (256 CPU cycles),
* Vertical Blank Timer - counts down every vertical blank (beginning of line 144).
The timers also feature an auto-reload functionality: that is, they can be configured to fire one time or repeat periodically.
== Interrupts ==
Each timer has its own interrupt; it is triggered when the counter would be about to count down to zero, that is when the counter's value is 1 and the timer condition occurs.
This leads to a quirk: the timer interrupt will be triggered if the reload value is set to one ''even if the timer countdown is disabled'', so long as the interrupt is enabled.
== I/O Ports ==
=== Timer Control ($A2, $A3) ===
<pre>
7 bit 0
---- ----
.... VvHh
||||
|||+- Horizontal blank timer: Enable countdown.
||+-- Horizontal blank timer: 0: One-shot, 1: Repeat/auto-reload.
|+--- Vertical blank timer: Enable countdown.
+---- Vertical blank timer: 0: One-shot, 1: Repeat/auto-reload.
</pre>
{{Anchor|Timer Reload}}
=== Horizontal Blank Timer Reload ($A4, $A5) ===
=== Vertical Blank Timer Reload ($A6, $A7) ===
Contains the initial counter value. The Timer Counter port is immediately initialized with this value upon writing. If auto-reload is enabled, the interrupt trigger will re-initialize the Timer Counter port with this value.
{{Anchor|Timer Counter}}
=== Horizontal Blank Timer Counter ($A8, $A9 read) ===
=== Vertical Blank Timer Counter ($AA, $AB read) ===
Contains the current value of the counter.
Note that if auto-reload is enabled, this will never contain the value zero.
2da5adcb175b3fb05cb340c185cab789b3c34b60
UART
0
23
109
85
2023-08-22T10:51:18Z
Fiskbit
37
Register formatting.
wikitext
text/x-wiki
The WonderSwan's EXT port features an UART operating with the following configuration:
* 9,600 or 38,400 bps (bauds per second),
* 8N1 (8 data bits followed by 1 stop bit, no parity).
This allows for an effective maximum transfer speed of 960 or 3840 bytes per second, respectively.
The hardware also features a one-byte transmit and receive buffer, which allows for a slight delay in code when handling data to/from the console.
== Interrupts ==
The UART features two interrupts:
* UART Send Ready - constantly active while the transmit buffer is empty (Serial Control bit 2),
* UART Receive Ready - constantly active while the receive buffer contains a byte (Serial Control bit 0).
== I/O ports ==
=== Serial Data ===
<pre>
7 bit 0
---- ----
dddd dddd
|||| ||||
++++-++++- Read a byte from the transmit buffer;
Write a byte into the receive buffer.
</pre>
=== Serial Control ===
<pre>
7 bit 0
---- ----
ebO. .tor
||| |||
||| ||+- 1 if the receive buffer contains a byte
||| |+-- 1 on overrun (receive buffer overflow)
||| +--- 1 if the transmit buffer is empty (can transmit another byte)
||+------- Write 1 to reset overrun
|+-------- UART speed: 0 = 9600 bps, 1 = 38400 bps
+--------- UART enable: 0 = off, 1 = on
</pre>
7576a61b5a2c1f3268a4b357edbb271eb6d1222d
114
109
2023-08-22T11:30:47Z
Fiskbit
37
Fixes data register. Adds register addresses and access types. Splits Serial Control into Status and Control.
wikitext
text/x-wiki
The WonderSwan's EXT port features an UART operating with the following configuration:
* 9,600 or 38,400 bps (bauds per second),
* 8N1 (8 data bits followed by 1 stop bit, no parity).
This allows for an effective maximum transfer speed of 960 or 3840 bytes per second, respectively.
The hardware also features one-byte transmit and receive buffers, which allow for a slight delay in code when handling data to/from the console.
== Interrupts ==
The UART features two interrupts:
* UART Send Ready - constantly active while the transmit buffer is empty (Serial Status bit 2),
* UART Receive Ready - constantly active while the receive buffer contains a byte (Serial Status bit 0).
== I/O ports ==
{{Anchor|Serial Data}}
=== Serial Data ($B1) ===
<pre>
7 bit 0
---- ----
dddd dddd
|||| ||||
++++-++++- Read a byte from the receive buffer, or
Write a byte into the transmit buffer.
</pre>
{{Anchor|Serial Status}}
=== Serial Status ($B3 read) ===
<pre>
7 bit 0
---- ----
eb.. .tor
|| |||
|| ||+- 1 if the receive buffer contains a byte
|| |+-- 1 on overrun (receive buffer overflow)
|| +--- 1 if the transmit buffer is empty (can transmit another byte)
|+-------- UART speed: 0 = 9600 bps, 1 = 38400 bps
+--------- UART enable: 0 = off, 1 = on
</pre>
{{Anchor|Serial Control}}
=== Serial Control ($B3 write) ===
<pre>
7 bit 0
---- ----
ebO. ....
|||
||+------- Write 1 to reset overrun
|+-------- UART speed: 0 = 9600 bps, 1 = 38400 bps
+--------- UART enable: 0 = off, 1 = on
</pre>
03f36154be516590cd1f795c76fcb9cd907ba267
123
114
2023-08-22T12:05:15Z
Fiskbit
37
Splits Serial Data into Serial Receive Data and Serial Transmit Data
wikitext
text/x-wiki
The WonderSwan's EXT port features an UART operating with the following configuration:
* 9,600 or 38,400 bps (bauds per second),
* 8N1 (8 data bits followed by 1 stop bit, no parity).
This allows for an effective maximum transfer speed of 960 or 3840 bytes per second, respectively.
The hardware also features one-byte transmit and receive buffers, which allow for a slight delay in code when handling data to/from the console.
== Interrupts ==
The UART features two interrupts:
* UART Send Ready - constantly active while the transmit buffer is empty (Serial Status bit 2),
* UART Receive Ready - constantly active while the receive buffer contains a byte (Serial Status bit 0).
== I/O ports ==
{{Anchor|Serial Receive Data}}
=== Serial Receive Data ($B1 read) ===
<pre>
7 bit 0
---- ----
dddd dddd
|||| ||||
++++-++++- Receive buffer value
</pre>
{{Anchor|Serial Transmit Data}}
=== Serial Transmit Data ($B1 write) ===
<pre>
7 bit 0
---- ----
dddd dddd
|||| ||||
++++-++++- Transmit buffer value
</pre>
{{Anchor|Serial Status}}
=== Serial Status ($B3 read) ===
<pre>
7 bit 0
---- ----
eb.. .tor
|| |||
|| ||+- 1 if the receive buffer contains a byte
|| |+-- 1 on overrun (receive buffer overflow)
|| +--- 1 if the transmit buffer is empty (can transmit another byte)
|+-------- UART speed: 0 = 9600 bps, 1 = 38400 bps
+--------- UART enable: 0 = off, 1 = on
</pre>
{{Anchor|Serial Control}}
=== Serial Control ($B3 write) ===
<pre>
7 bit 0
---- ----
ebO. ....
|||
||+------- Write 1 to reset overrun
|+-------- UART speed: 0 = 9600 bps, 1 = 38400 bps
+--------- UART enable: 0 = off, 1 = on
</pre>
f8c48f74235142dc49c79d44086399927796ae9a
Interrupts
0
22
110
81
2023-08-22T10:53:02Z
Fiskbit
37
Register formatting.
wikitext
text/x-wiki
The WonderSwan features fourteen different interrupts:
* CPU interrupts - six provided by the V30MZ CPU ($00-$05),
* Hardware interrupts - eight provided by the SoC's hardware ($00-$07, or $08-$0F, or $10-$1F, or ... $F8-$FF - controlled by an offset <code>V</code>):
** Level - will be constantly requested while the prerequisite condition is true; interruption can only be prevented by resolving the condition or disabling the interrupt;
** Edge - will only be requested when the prerequisite condition ''becomes'' true; acknowledging the interrupt prevents further interruption.
The user can additionally define and use any of the 256 interrupt vectors in their own code.
{| class="wikitable"
|+ List of WonderSwan interrupts
! Source
! Type
! Index
! Description
|-
! rowspan="6" | CPU
| rowspan="6" | N/A
| $00
| DIV or IDIV instruction divide error<br/>
(division by zero or result overflow)
|-
| $01
| Single-step (T flag)
|-
| $02
| NMI (non-maskable interrupt)
|-
| $03
| INT 3 opcode
|-
| $04
| INTO opcode (if V = 1)
|-
| $05
| BOUND opcode (if index out of bounds)
|-
! rowspan="8" | Hardware
| Level
| V + 0
| [[UART|UART Send Ready]]
|-
| Edge
| V + 1
| [[Keypad|Key Pressed]]
|-
| rowspan="2" | Level
| V + 2
| [[Cartridge|Cartridge IRQ]]
|-
| V + 3
| [[UART|UART Receive Ready]]
|-
| rowspan="4" | Edge
| V + 4
| [[Display|Display Interrupt Line Match]]
|-
| V + 5
| [[Timers|Vertical Blank Timer]]
|-
| V + 6
| [[Display|Display Vertical Blank]]
|-
| V + 7
| [[Timers|Horizontal Blank Timer]]
|}
== I/O ports ==
=== Interrupt Vector ===
<pre>
7 bit 0
---- ----
VVVV V...
|||| ||||
++++-++++- Interrupt vector offset
(lowest three bits ignored)
</pre>
=== Interrupt Enable ===
<pre>
7 bit 0
---- ----
iiii iiii
|||| ||||
++++-++++- Hardware interrupt to enable
(acts as a mask)
</pre>
=== Interrupt Status ===
<pre>
7 bit 0
---- ----
iiii iiii
|||| ||||
++++-++++- 1 if interrupt requested
</pre>
=== Interrupt Acknowledge ===
<pre>
7 bit 0
---- ----
iiii iiii
|||| ||||
++++-++++- Write 1 to clear interrupt request
</pre>
=== Interrupt NMI Control ===
<pre>
7 bit 0
---- ----
...b ....
|
+----- Enable NMI on low battery detection
</pre>
1dde55d95e5d78904c7751698637520bdac3c324
111
110
2023-08-22T11:04:22Z
Fiskbit
37
Moves Interrupts below table of contents.
wikitext
text/x-wiki
== Interrupts ==
The WonderSwan features fourteen different interrupts:
* CPU interrupts - six provided by the V30MZ CPU ($00-$05),
* Hardware interrupts - eight provided by the SoC's hardware ($00-$07, or $08-$0F, or $10-$1F, or ... $F8-$FF - controlled by an offset <code>V</code>):
** Level - will be constantly requested while the prerequisite condition is true; interruption can only be prevented by resolving the condition or disabling the interrupt;
** Edge - will only be requested when the prerequisite condition ''becomes'' true; acknowledging the interrupt prevents further interruption.
The user can additionally define and use any of the 256 interrupt vectors in their own code.
{| class="wikitable"
|+ List of WonderSwan interrupts
! Source
! Type
! Index
! Description
|-
! rowspan="6" | CPU
| rowspan="6" | N/A
| $00
| DIV or IDIV instruction divide error<br/>
(division by zero or result overflow)
|-
| $01
| Single-step (T flag)
|-
| $02
| NMI (non-maskable interrupt)
|-
| $03
| INT 3 opcode
|-
| $04
| INTO opcode (if V = 1)
|-
| $05
| BOUND opcode (if index out of bounds)
|-
! rowspan="8" | Hardware
| Level
| V + 0
| [[UART|UART Send Ready]]
|-
| Edge
| V + 1
| [[Keypad|Key Pressed]]
|-
| rowspan="2" | Level
| V + 2
| [[Cartridge|Cartridge IRQ]]
|-
| V + 3
| [[UART|UART Receive Ready]]
|-
| rowspan="4" | Edge
| V + 4
| [[Display|Display Interrupt Line Match]]
|-
| V + 5
| [[Timers|Vertical Blank Timer]]
|-
| V + 6
| [[Display|Display Vertical Blank]]
|-
| V + 7
| [[Timers|Horizontal Blank Timer]]
|}
== I/O ports ==
=== Interrupt Vector ===
<pre>
7 bit 0
---- ----
VVVV V...
|||| ||||
++++-++++- Interrupt vector offset
(lowest three bits ignored)
</pre>
=== Interrupt Enable ===
<pre>
7 bit 0
---- ----
iiii iiii
|||| ||||
++++-++++- Hardware interrupt to enable
(acts as a mask)
</pre>
=== Interrupt Status ===
<pre>
7 bit 0
---- ----
iiii iiii
|||| ||||
++++-++++- 1 if interrupt requested
</pre>
=== Interrupt Acknowledge ===
<pre>
7 bit 0
---- ----
iiii iiii
|||| ||||
++++-++++- Write 1 to clear interrupt request
</pre>
=== Interrupt NMI Control ===
<pre>
7 bit 0
---- ----
...b ....
|
+----- Enable NMI on low battery detection
</pre>
ad649ec7d38abb9856b70cbaca9b3c6b901671b6
116
111
2023-08-22T11:48:08Z
Asie
351
adjust port category name formatting
wikitext
text/x-wiki
== Interrupts ==
The WonderSwan features fourteen different interrupts:
* CPU interrupts - six provided by the V30MZ CPU ($00-$05),
* Hardware interrupts - eight provided by the SoC's hardware ($00-$07, or $08-$0F, or $10-$1F, or ... $F8-$FF - controlled by an offset <code>V</code>):
** Level - will be constantly requested while the prerequisite condition is true; interruption can only be prevented by resolving the condition or disabling the interrupt;
** Edge - will only be requested when the prerequisite condition ''becomes'' true; acknowledging the interrupt prevents further interruption.
The user can additionally define and use any of the 256 interrupt vectors in their own code.
{| class="wikitable"
|+ List of WonderSwan interrupts
! Source
! Type
! Index
! Description
|-
! rowspan="6" | CPU
| rowspan="6" | N/A
| $00
| DIV or IDIV instruction divide error<br/>
(division by zero or result overflow)
|-
| $01
| Single-step (T flag)
|-
| $02
| NMI (non-maskable interrupt)
|-
| $03
| INT 3 opcode
|-
| $04
| INTO opcode (if V = 1)
|-
| $05
| BOUND opcode (if index out of bounds)
|-
! rowspan="8" | Hardware
| Level
| V + 0
| [[UART|UART Send Ready]]
|-
| Edge
| V + 1
| [[Keypad|Key Pressed]]
|-
| rowspan="2" | Level
| V + 2
| [[Cartridge|Cartridge IRQ]]
|-
| V + 3
| [[UART|UART Receive Ready]]
|-
| rowspan="4" | Edge
| V + 4
| [[Display|Display Interrupt Line Match]]
|-
| V + 5
| [[Timers|Vertical Blank Timer]]
|-
| V + 6
| [[Display|Display Vertical Blank]]
|-
| V + 7
| [[Timers|Horizontal Blank Timer]]
|}
== I/O ports ==
{{Anchor|Interrupt Vector}}
=== Interrupt Vector ($B0) ===
<pre>
7 bit 0
---- ----
VVVV V...
|||| ||||
++++-++++- Interrupt vector offset
</pre>
{{Anchor|Interrupt Enable}}
=== Interrupt Enable ($B2) ===
<pre>
7 bit 0
---- ----
iiii iiii
|||| ||||
++++-++++- Hardware interrupt to enable
(acts as a mask)
</pre>
{{Anchor|Interrupt Status}}
=== Interrupt Status ($B4 read)===
<pre>
7 bit 0
---- ----
iiii iiii
|||| ||||
++++-++++- 1 if interrupt requested
</pre>
{{Anchor|Interrupt Acknowledge}}
=== Interrupt Acknowledge ($B6 write)===
<pre>
7 bit 0
---- ----
iiii iiii
|||| ||||
++++-++++- Write 1 to clear interrupt request
</pre>
{{Anchor|Interrupt NMI Control}}
=== Interrupt NMI Control ($B7)===
<pre>
7 bit 0
---- ----
...b ....
|
+----- Enable NMI on low battery detection
</pre>
6179617c25fdb541d3699dc5264ef55955658282
Template:Anchor
10
28
112
2023-08-22T11:24:56Z
Fiskbit
37
Adds anchor template.
wikitext
text/x-wiki
{{#if:{{{1|<noinclude>1</noinclude>}}}|<ins id="{{{1|<noinclude>test-anchor</noinclude>}}}"></ins>}}<!--
-->{{#if:{{{2|}}}|<ins id="{{{2|}}}"></ins>}}<!--
-->{{#if:{{{3|}}}|<ins id="{{{3|}}}"></ins>}}<!--
-->{{#if:{{{4|}}}|<ins id="{{{4|}}}"></ins>}}<!--
-->{{#if:{{{5|}}}|<ins id="{{{5|}}}"></ins>}}<!--
-->{{#if:{{{6|}}}|<ins id="{{{6|}}}"></ins>}}<!--
-->{{#if:{{{7|}}}|<ins id="{{{7|}}}"></ins>}}<!--
-->{{#if:{{{8|}}}|<ins id="{{{8|}}}"></ins>}}<!--
-->{{#if:{{{9|}}}|<ins id="{{{9|}}}"></ins>}}<!--
-->{{#if:{{{10|}}}|<ins id="{{{10|}}}"></ins>}}<!--
-->{{#if:{{{11|}}}|<span class="error">[[Template:Anchor]]: Too many anchors; maximum is 10.</span>}}<noinclude>{{Template:Anchor/doc}}</noinclude>
d19deedb0ebb921c0b7614951d0382695f54fea1
Template:Anchor/doc
10
29
113
2023-08-22T11:25:25Z
Fiskbit
37
Adds anchor template doc.
wikitext
text/x-wiki
{| class="wikitable"
| This documentation is at: [[Template:Anchor/doc]]
|}
This template manually adds one or more HTML anchors, allowing links to locations other than section headings.
Usage can create a single named anchor, or many at the same location:
<code><nowiki>
{{Anchor|name1}}
</nowiki></code>
<code><nowiki>
{{Anchor|name1|name2|name3...}}
</nowiki></code>
Linking can be used within the same page, or in cross-page links:
<code><nowiki>
[[#name1|name1]]
</nowiki></code>
<code><nowiki>
[[Pagename#name1|name1]]
</nowiki></code>
8b491fdabd76e3517387ebf5622d363ea3ac766b
Keypad
0
9
118
26
2023-08-22T11:52:01Z
Asie
351
wikitext
text/x-wiki
The WonderSwan SoC features a 4 by 3 keypad matrix.
== I/O Ports ==
=== Keypad Scan ($B5) ===
Scanning is done via writing to and reading from port $B5.
<pre>
7 bit 0
---- ----
.iii oooo
||| ++++- Output rows (0-3)
+++------ Input rows (4-6)
</pre>
The standard procedure is to read rows 4, 5 and 6 in order, shifting their values into one twelve-bit mask like so:
<pre>
15 bit 0
---- ---- ---- ----
.... 4444 5555 6666
</pre>
Typical keypad scanning implementations introduce a delay between writing to and reading from the matrix, allowing the scanned values to stabilize. For example, one can use the DAA opcode for doing so.
== Startup override ==
On startup, the [[boot ROM]] checks whether or not certain output rows are forced high when all input rows are disabled. This triggers a startup override prior to the boot logo:
* Input row 0 - jump to 4000:0000,
* Input row 1 - jump to 4000:0010.
As this override is done before boot ROM lockout, it can be used to dump the boot ROM.
== Keypad arrangement ==
=== WonderSwan ===
==== Layout ====
<pre>
Y1
Y4 Y2
Y3
X1
X4 X2 A
X3 Sound Start Power B
(St)
</pre>
Sound and Power buttons are not exposed directly to software.
==== Matrix ====
<pre>
Bit O 3 2 1 0
I | | | |
| | | |
4--- Y4 - Y3 - Y2 - Y1 -
| | | |
5--- X4 - X3 - X2 - X1 -
| | | |
6--- B - A - St ---+--
| | | |
</pre>
==== Bit mask ====
<pre>
15 bit 0
---- ---- ---- ----
.... yyyy xxxx bas.
|||| |||| ||+- Start
|||| |||| |+-- A
|||| |||| +--- B
|||| ++++----- X4, X3, X2, X1
++++---------- Y4, Y3, Y2, Y1
</pre>
=== Pocket Challenge V2 ===
==== Layout ====
<pre>
Power
Esc
View
Up Clear
(Clr)
Lft Rgh Circle
(Crc)
Dwn Pass
(Pas)
</pre>
The Power switch is not exposed directly to software.
==== Matrix ====
<pre>
Bit O 3 2 1 0
I | | | |
| | | |
4--- Pas Crc --+-- Clr -
| | | |
5--- Rgh Esc --+- View -
| | | |
6--- Up - Dwn --+-- Lft -
| | | |
[1]
</pre>
==== Bit mask ====
<pre>
15 bit 0
---- ---- ---- ----
.... pc1C re1v ud1l
|| | || | || +- Left
|| | || | |+--- Down
|| | || | +---- Up
|| | || +------ View
|| | |+-------- Esc
|| | +--------- Right
|| +----------- Clear
|+------------- Circle
+-------------- Pass
</pre>
939180a2693938fc81ddc2715fdda49155f70248
Display
0
26
121
100
2023-08-22T12:00:59Z
Asie
351
adjust port category name formatting
wikitext
text/x-wiki
The WonderSwan's display functionality generally consists of:
* a 224x144 display clocked at ~75.47 Hz by default, capable of displaying:
** up to sixteen distinct shades of gray
** 12-bit RGB444 color<sup>(color)</sup>
* two 32x32 background layers ("screens"), capable of displaying up to 512 (1024<sup>(color)</sup>) distinct tiles,
* a sprite layer, capable of displaying up to 128 8x8 sprites (up to 32 per line),
* six LCD icons to the bottom or right of the display, usable as additional indicators.
== Components ==
=== Tiles ===
The "mono" WonderSwan can display up to 512 tiles stored in a planar format, with two bits total per pixel.
The planes are interleaved with each other; that is, two consecutive bytes form a full 8x1 row of the tile:
<pre>
plane 0 plane 1
byte N byte N+1
7 bit 0 7 bit 0 full tile
---- ---- ---- ----
.... ...1 .222 22.. .22222.1
.... ...1 2222 22.. 222222.1
.... .... 22.. .... 22......
...1 1... 22.2 2... --\ 22.33...
...1 1... 22.2 2... --/ 22.33...
.... .... 22.. .... 22......
.... .... .... .... ........
11.. .... .... .... 11......
</pre>
The WonderSwan Color extends this with an additional 512 tiles (available for screens only, not sprites) and support for three new modes.
* The first new mode is another two bit per pixel mode, but using color palettes instead of monochrome shades.
The latter two modes extend tiles to four bits per pixel.
* The first among them is the planar mode, which works similarly to the two bit per pixel mode:
<pre>
plane 0 plane 1 plane 2 plane 3
byte N byte N+1 byte N+2 byte N+3
7 bit 0 7 bit 0 7 bit 0 7 bit 0 full rows
---- ---- ---- ---- ---- ---- ---- ----
1.1. 1.1. 22.. 22.. 4444 .... .... .... --\ 7654321.
.1.1 .1.1 ..22 ..22 .... 4444 8888 8888 --/ 89ABCDEF
</pre>
* The second is the chunky mode, which instead stores each plane as consecutive bits, with each byte responsible for two of the eight pixels:
<pre>
pxl 1,0 pxl 2,3 pxl 5,4 pxl 7,6
byte N byte N+1 byte N+2 byte N+3
7 bit 0 7 bit 0 7 bit 0 7 bit 0 full rows
---- ---- ---- ---- ---- ---- ---- ----
.42. .421 .4.. .4.1 ..2. ..21 .... ...1 --\ 7654321.
8..1 8... 8.21 8.2. 84.1 84.. 8421 842. --/ 89ABCDEF
</pre>
=== Colors, Shades ===
The "mono" WonderSwan uses eight value indices, which are converted by a global look-up table to eight of the sixteen shades the LCD can display:
<pre>
Palette Global shade LUT
1 ===========> 2 ==========================> 5
^ (0, 2, 4, 6) ^ (1, 3, 5, 7, 9, 11, 13, 15) ^
| | |
Tile pixel Value Displayed shade
</pre>
In "color" mode, the WonderSwan instead loads RGB444 color values from a table in the console's internal RAM:
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
.... rrrr gggg bbbb
|||| |||| ||||
|||| |||| ++++- Blue (0-15)
|||| ++++------ Green (0-15)
++++------------ Red (0-15)
</pre>
No further processing or look-up tables are applied.
=== Palettes ===
The WonderSwan provides sixteen different palettes. All sixteen can be used for screens only, while the latter eight can be used for screens and sprites. In addition, the background color (for areas where no opaque pixel is drawn) can be selected arbitrarily from the color palette or from the shade LUT.
In two bit per pixel modes, palettes 0 - 3 and 8 - 11 are ''opaque'' (color zero is opaque, four distinct colors are usable), while palettes 4 - 7 and 12 - 15 are ''translucent'' (color zero is transparent, three distinct colors are usable). This applies in both mono and color modes.
In four bit per pixel modes, every palette is ''translucent'' (color zero is transparent, fifteen distinct colors are usable). The first entry of each palette can be used only for the background color.
Palettes 8-15 are also referred to as sprite palettes 0-7.
=== Screens ===
The WonderSwan can display up to two distinct 32x32 screens. These consist of 1024 two-byte cells:
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
vhbp pppt tttt tttt
|||| |||| |||| ||||
|||| |||+--++++-++++- Tile index (0-511)
|||+-+++------------- Palette (0-15)
||+------------------ Tile bank (0-1) - color only
|+------------------- Horizontal flip
+-------------------- Vertical flip
</pre>
=== Sprites ===
The WonderSwan can display up to 128 sprites, with a limit of 32 visible sprites per line.
These are stored in a sprite table in RAM, which consists of up to 128 four-byte entries:
<pre>
(Byte 1) (Byte 0)
15 bit 8 7 bit 0
---- ---- ---- ----
vhPi pppt tttt tttt
|||| |||| |||| ||||
|||| |||+--++++-++++- Tile index (0-511) - only bank 0
|||| +++------------- Palette (0-7) - mapped to screen palettes 8-15
|||+----------------- Window location - 0 = inside, 1 = outside
||+------------------ Priority - 0 = behind Screen 2, 1 = in front of Screen 2
|+------------------- Horizontal flip
+-------------------- Vertical flip
(Byte 2)
7 bit 0
---- ----
yyyy yyyy
|||| ||||
++++-++++- Y coordinate
(Byte 3)
7 bit 0
---- ----
xxxx xxxx
|||| ||||
++++-++++- X coordinate
</pre>
=== Windows ===
Screen 2 and the sprite layer can optionally be restricted to a specific window.
In addition, one can control if a given element is rendered inside or outside that window. For Screen 2, this is controlled globally; for sprites, this is controlled per-sprite.
=== Icons ===
Finally, the WonderSwan features six LCD segment icons which are displayed to the right<sup>(color)</sup> or below<sup>(mono)</sup> the main display. These are, as follows:
* Aux 3 - large circle,
* Aux 2 - medium circle,
* Aux 1 - small circle,
* Horizontal orientation,
* Vertical orientation,
* Sleep.
== Interrupts ==
The display circuit generates two interrupts of its own:
* Display Interrupt Line Match - when <code>Display Current Line</code> == <code>Display Interrupt Line</code>, at the beginning of said line.
* Display Vertical Blank - when <code>Display Current Line</code> == <code>144</code>, at the beginning of said line.
It also provides a timing source for the two Horizontal and Vertical Blank [[Timers]], which provide their own respective interrupts.
== I/O ports ==
{{Anchor|Display Control}}
=== Display Control ($00) ===
<pre>
7 bit 0
---- ----
..ow Ws21
|| ||||
|| |||+- Enable Screen 1 layer
|| ||+-- Enable Screen 2 layer
|| |+--- Enable Sprite layer
|| +---- Enable Sprite window
|+------ Enable Screen 2 window
+------- Screen 2 window location:
0 = inside, 1 = outside
</pre>
{{Anchor|Display Background}}
=== Display Background Color ($01) ===
<pre>
(mono) (color)
7 bit 0 7 bit 0
---- ---- ---- ----
.... .sss pppp iiii
||| |||| ||||
+++- Value |||| ++++- Index in palette (0-15)
(0-7) ++++------ Color palette (0-15)
</pre>
{{Anchor|Display Current Line}}
=== Display Current Line ($02 read) ===
The current line being drawn by the display.
Note that lines are sent to the display with a one-line delay. This matters for color palette or shade LUT manipulation; changing these values when <code>current line == 1</code> will actually affect line 0.
{{Anchor|Display Interrupt Line}}
=== Display Interrupt Line ($03) ===
The line to emit an interrupt on.
{{Anchor|Sprite Table Address}}
=== Sprite Table Address ($04) ===
<pre>
7 bit 0
---- ----
..Aa aaaa
|| ||||
|+-++++- Address (bits 9-13)
+------- Address (bit 14) - color only
</pre>
{{Anchor|Sprite Table First}}
=== Sprite Table First ($05) ===
<pre>
7 bit 0
---- ----
.iii iiii
||| ||||
+++-++++- Index of first sprite entry to draw (0-127)
</pre>
{{Anchor|Sprite Table Count}}
=== Sprite Table Count ($06) ===
<pre>
7 bit 0
---- ----
cccc cccc
|||| ||||
++++-++++- Count of sprite entries to draw (1-128)
</pre>
{{Anchor|Screen Address}}
=== Screen Address ($07) ===
<pre>
7 bit 0
---- ----
2222 1111
|||| ||||
|||| |+++- Screen 1 address (bits 11-13)
|||| +---- Screen 1 address (bit 14) - color only
|+++------ Screen 2 address (bits 11-13)
+--------- Screen 2 address (bit 14) - color only
</pre>
{{Anchor|LCD Control}}
=== LCD Control ($14) ===
<pre>
7 bit 0
---- ----
.... ..Ce
||
|+- LCD Enable: 0 = sleep, 1 = enabled
+-- Contrast (WSC): 0 = low, 1 = high
</pre>
{{Anchor|LCD Icon Control}}
=== LCD Icon Control ($15) ===
<pre>
7 bit 0
---- ----
..32 1hvs
|| ||||
|| |||+- Sleep
|| ||+-- Vertical orientation
|| |+--- Horizontal orientation
|| +---- Aux 1
|+------ Aux 2
+------- Aux 3
</pre>
== Internal I/O ports ==
These I/O ports are said to be internal and not intended for use by commercial games.
{{Anchor|LCD Final Line}}
=== LCD Final Line ($16) ===
The final line preceding line counter restart. By default, this should be set to 158.
It is said setting this register to an odd value on SwanCrystal has an adverse effect to the LCD panel<ref>[http://daifukkat.su/docs/wsman/#REG_LCD_VSYNC REG_LCD_VSYNC - WSMan]</ref>, but the exact mechanism is unknown.
{{Anchor|LCD Back Porch Line}}
=== LCD Back Porch Line ($17, WSC only) ===
This port is available on the WonderSwan Color only - not the SwanCrystal!
The final line preceding the vertical back porch; by default, this should be set to 155.
The vertical back porch of the LCD is assumed to be 4 lines by some hardware, including IPS mods, as well as the official "TV Swan" capture device. Given that the first visible line is sent to the LCD on the display's line 1, this should be generally set to <code>LCD Final Line - 3</code>.
Conversely, it is said moving this value closer to vertical blank improves LCD visibility<ref>[http://daifukkat.su/docs/wsman/#REG_LCD_VTOTAL REG_LCD_VTOTAL - WSMan]</ref>, but the exact mechanism is unknown.
{{Anchor|LCD Status}}
=== LCD Status ($1A) ===
<pre>
7 bit 0
---- ----
...v vv.s
| || |
| || +- LCD sleep: 0 = no, 1 = sleep
| ||
| || Volume segments:
| |+--- Volume B (medium, high)
| +---- Volume A (low, high)
+------ Speaker
</pre>
=== LCD Timing Configuration ($70, $71, $72, $73, $74, $75, $76, $77 SwanCrystal only) ===
These eight bytes are read from internal EEPROM and configure unknown aspects of the console's TFT LCD panel.
They are only writable while the [[Boot ROM]] is unlocked - locking has the side effect of making them read-only.
== Notes ==
<references />
7655e18ba632a081d55fa75f2261d9f46fe59337
ROM header
0
5
122
27
2023-08-22T12:03:57Z
Asie
351
adjust port category name formatting
wikitext
text/x-wiki
Every WonderSwan ROM contains a header. It is stored at the end - final sixteen bytes - of the ROM image.
== ROM header ==
Parts of this header are validated or otherwise used by the console's [[boot ROM]] - they are marked in '''bold'''.
{| class="wikitable"
|+ Header contents
|-
! Offset !! Length !! Contents
|-
| '''$0''' || '''5''' || Far jump instruction: '''0xEA''', offset, segment.
|-
| '''$5''' || '''1''' || '''Maintenance'''
|-
| $6 || 1 || Developer/Publisher ID
|-
| $7 || 1 || Color
|-
| $8 || 1 || Game ID (binary-coded decimal)
|-
| '''$9''' || '''1''' || '''Game version? / Safe mode'''
|-
| $A || 1 || ROM size
|-
| $B || 1 || Save type/size
|-
| '''$C''' || '''1''' || '''Flags'''
|-
| $D || 1 || Mapper
|-
| $E || 2 || Checksum (sum of all ROM bytes excluding the checksum)
|}
=== Maintenance ($5) ===
----
<pre>
7 bit 0
---- ----
s... 0000
| ||||
| ++++- Must be zero; otherwise the console will prohibit execution.
| Purpose unknown.
+--------- (Color) Splash bypass: 0 = Disable, 1 = Enable.
Bypasses the custom boot splash stored in the console's
internal EEPROM; presumably used for bricked console recovery.
</pre>
=== Developer/Publisher ID ($6) ===
----
{| class="wikitable"
|+ Known official developer/publisher IDs
|-
! ID !! Publisher code !! Publisher
|-
| $01 || BAN || Bandai
|-
| $02 || TAT || Taito
|-
| $03 || TMY || Tomy
|-
| $04 || KEX || Koei
|-
| $05 || DTE || Data East
|-
| $06 || AAE || Asmik Ace
|-
| $07 || MDE || Media Entertainment
|-
| $08 || NHB || Nichibutsu
|-
| $0A || CCJ || Coconuts Japan
|-
| $0B || SUM || Sammy
|-
| $0C || SUN || Sunsoft
|-
| $0D || PAW || Mebius
|-
| $0E || BPR || Banpresto
|-
| $10 || JLC || Jaleco
|-
| $11 || MGA || Imagineer
|-
| $12 || KNM || Konami
|-
| $16 || KBS || Kobunsha
|-
| $17 || BTM || Bottom Up
|-
| $18 || KGT || Kaga Tech
|-
| $19 || SRV || Sunrise
|-
| $1A || CFT || Cyber Front
|-
| $1B || MGH || Megahouse
|-
| $1D || BEC || Interbec
|-
| $1E || NAP || Nihon Application
|-
| $1F || BVL || Bandai Visual
|-
| $20 || ATN || Athena
|-
| $21 || KDX || KID
|-
| $22 || HAL || HAL Corporation
|-
| $23 || YKE || Yuki Enterprise
|-
| $24 || OMN || Omega Micott
|-
| $25 || LAY || Layup
|-
| $26 || KDK || Kadokawa Shoten
|-
| $27 || SHL || Shall Luck
|-
| $28 || SQR || Squaresoft
|-
| $2A || SCC || ?
|-
| $2B || TMC || Tom Create
|-
| $2D || NMC || Namco
|-
| $2E || SES || ?
|-
| $2F || HTR || ?
|-
| $31 || VGD || Vanguard
|-
| $32 || MGT || Megatron
|-
| $33 || WIZ || Wiz
|-
| $35 || TAN || Tanita
|-
| $36 || CPC || Capcom
|}
Note that IDs $00 and $01 are used across a variety of commercial games. Homebrew is known to use arbitrary values in this field.
=== Color ($7) ===
----
<pre>
7 bit 0
---- ----
???? ???c
|
+- 0 = Monochrome only, 1 = Supports Color mode.
</pre>
=== Game version? / Safe mode ($9) ===
----
<pre>
7 bit 0
---- ----
pvvv vvvv
|||| ||||
|+++ ++++- Game version?
+--------- Internal EEPROM write protect: 0 = Enable, 1 = Disable.
This prohibits writing to the internal EEPROM for addresses
0x60 and above (user settings, custom splash screen).
Games are expected to enable write protection; however, the
WonderWitch is factory configured with it disabled.
</pre>
=== ROM size ($A) ===
----
Unofficial/inferred ROM size values are marked in ''italic''.
{| class="wikitable"
|+ ROM size values
|-
! ID !! Size
|-
| ''$00'' || ''1 Mbit (128 KiB)''
|-
| ''$01'' || ''2 Mbit (256 KiB)''
|-
| $02 || 4 Mbit (512 KiB)
|-
| $03 || 8 Mbit (1 MiB)
|-
| $04 || 16 Mbit (2 MiB)
|-
| ''$05'' || ''24 Mbit (3 MiB)''
|-
| $06 || 32 Mbit (4 MiB)
|-
| ''$07'' || ''48 Mbit (6 MiB)''
|-
| $08 || 64 Mbit (8 MiB)
|-
| $09 || 128 Mbit (16 MiB)
|-
| ''$0A'' || ''256 Mbit (32 MiB)''
|-
| ''$0B'' || ''512 Mbit (64 MiB)''
|}
Note that ROM sizes over 16 MiB are not supported by the [[Bandai 2001]] mapper. The [[Bandai 2003]] mapper is limited to 64 MiB.
=== Save type/size ($B) ===
----
{| class="wikitable"
|+ Save type values
|-
! ID !! Type !! Size
|-
| $00 || colspan="2" style="text-align:center;" | None
|-
| $01 || rowspan="5" | SRAM || 64 Kbit (8 KiB)
|-
| $02 || 256 Kbit (32 KiB)
|-
| $03 || 1 Mbit (128 KiB)
|-
| $04 || 2 Mbit (256 KiB)
|-
| $05 || 4 Mbit (512 KiB)
|-
| $10 || rowspan="3" | EEPROM || 1 Kbit (128 B)
|-
| $20 || 16 Kbit (2 KiB)
|-
| $50 || 8 Kbit (1 KiB)
|}
=== Flags ($C) ===
----
<pre>
7 bit 0
---- ----
???? ?SBv
|||
||+- Starting screen orientation: 0 = Horizontal, 1 = Vertical.
|| Controls the splash screen's orientation.
|+-- ROM bus width: 0 = 16-bit, 1 = 8-bit.
+--- ROM access time: 0 = 3 CPU cycles, 1 = 1 CPU cycle.
</pre>
=== Mapper ($D) ===
----
{| class="wikitable"
|+ Known mapper types
|-
! ID !! Mapper
|-
| $00 || [[Bandai 2001]]
|-
| $01 || [[Bandai 2003]]
|-
| $02 || [[KARNAK]] (Pocket Challenge V2)
|}
2f32eef755f8983aaf5fbe43bf1ec315d4ecaef8
Hyper Voice
0
30
128
2023-08-22T12:20:41Z
Asie
351
Created page with "Hyper Voice is a headphone-only sample output channel introduced with the WonderSwan Color. It allows converting 8-bit signed and unsigned, mono and stereo samples into 16-bit signed PCM sent directly to the headphone output, after mixing with the traditional four channels. == I/O Ports == === Hyper Voice Left Output ($64, $65) === === Hyper Voice Right Output ($66, $67) === <pre> 15 bit 8 7 bit 0 ---- ---- ---- ---- ssss ssss ssss ssss ++++-++++--++++-++++..."
wikitext
text/x-wiki
Hyper Voice is a headphone-only sample output channel introduced with the WonderSwan Color. It allows converting 8-bit signed and unsigned, mono and stereo samples into 16-bit signed PCM sent directly to the headphone output, after mixing with the traditional four channels.
== I/O Ports ==
=== Hyper Voice Left Output ($64, $65) ===
=== Hyper Voice Right Output ($66, $67) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
ssss ssss ssss ssss
++++-++++--++++-++++- Signed 16-bit sample.
</pre>
Unlike the [[Sound]] output registers, these can be written to - allowing for direct 16-bit sample output.
=== Hyper Voice Left Input ($68) ===
=== Hyper Voice Right Input ($69) ===
<pre>
7 bit 0
---- ----
ssss ssss
++++-++++- 8-bit sample.
</pre>
These are typically written to by [[DMA|Sound DMA]], but can also be written to manually by the user.
=== Hyper Voice Control ($6A, $6B) ===
<pre>
15 bit 0 7 bit 0
---- ---- ---- ----
.mmc .... errr ffss
||| |||| ||++- Shift/Volume:
||| |||| || 0 = 100% 1 = 50%
||| |||| || 2 = 25% 3 = 12.5%
||| |||| ++--- Input sample mode:
||| |||| 0 = Unsigned
||| |||| 1 = Unsigned, negate
||| |||| 2 = Signed
||| |||| 3 = Signed, ignore Shift/Volume
||| |+++------ Update sample rate/Divisor:
||| | 0 = 24000/1 = 24000 Hz
||| | 1 = 24000/2 = 12000 Hz
||| | 2 = 24000/3 = 8000 Hz
||| | 3 = 24000/4 = 6000 Hz
||| | 4 = 24000/5 = 4800 Hz
||| | 5 = 24000/6 = 4000 Hz
||| | 6 = 24000/8 = 3000 Hz
||| | 7 = 24000/12 = 2000 Hz
||| +--------- Enable: 0 = off, 1 = on
||+----------------- Input channel: 0 = left, 1 = right
++------------------ Channel mode:
0 = Stereo
1 = Mono, left channel only
2 = Mono, right channel only
3 = Mono, both channels
</pre>
1e8ef6830e0e57e1cdc5a12c98702ee09a8f767a
129
128
2023-08-22T12:21:45Z
Asie
351
wikitext
text/x-wiki
Hyper Voice is a headphone-only sample output channel introduced with the WonderSwan Color. It allows converting 8-bit signed and unsigned, mono and stereo samples into 16-bit signed PCM sent directly to the headphone output, after mixing with the traditional four channels.
== I/O Ports ==
{{Anchor|Hyper Voice Output}}
=== Hyper Voice Left Output ($64, $65) ===
=== Hyper Voice Right Output ($66, $67) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
ssss ssss ssss ssss
++++-++++--++++-++++- Signed 16-bit sample.
</pre>
Unlike the [[Sound]] sample output registers, these can be written to - allowing for direct 16-bit sample output.
{{Anchor|Hyper Voice Input}}
=== Hyper Voice Left Input ($68) ===
=== Hyper Voice Right Input ($69) ===
<pre>
7 bit 0
---- ----
ssss ssss
++++-++++- 8-bit sample.
</pre>
These are typically written to by [[DMA|Sound DMA]], but can also be written to manually by the user.
{{Anchor|Hyper Voice Control}}
=== Hyper Voice Control ($6A, $6B) ===
<pre>
15 bit 0 7 bit 0
---- ---- ---- ----
.mmc .... errr ffss
||| |||| ||++- Shift/Volume:
||| |||| || 0 = 100% 1 = 50%
||| |||| || 2 = 25% 3 = 12.5%
||| |||| ++--- Input sample mode:
||| |||| 0 = Unsigned
||| |||| 1 = Unsigned, negate
||| |||| 2 = Signed
||| |||| 3 = Signed, ignore Shift/Volume
||| |+++------ Update sample rate/Divisor:
||| | 0 = 24000/1 = 24000 Hz
||| | 1 = 24000/2 = 12000 Hz
||| | 2 = 24000/3 = 8000 Hz
||| | 3 = 24000/4 = 6000 Hz
||| | 4 = 24000/5 = 4800 Hz
||| | 5 = 24000/6 = 4000 Hz
||| | 6 = 24000/8 = 3000 Hz
||| | 7 = 24000/12 = 2000 Hz
||| +--------- Enable: 0 = off, 1 = on
||+----------------- Input channel: 0 = left, 1 = right
++------------------ Channel mode:
0 = Stereo
1 = Mono, left channel only
2 = Mono, right channel only
3 = Mono, both channels
</pre>
264d841844b9f7dab15743e5ce92d9adee458e8d
131
129
2023-08-22T12:23:23Z
Asie
351
wikitext
text/x-wiki
Hyper Voice is a headphone-only sample output channel introduced with the WonderSwan Color. It allows converting 8-bit signed and unsigned, mono and stereo samples into 16-bit signed PCM sent directly to the headphone output, after mixing with the traditional four channels.
== I/O Ports ==
{{Anchor|Hyper Voice Output}}
=== Hyper Voice Left Output ($64, $65) ===
=== Hyper Voice Right Output ($66, $67) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
ssss ssss ssss ssss
++++-++++--++++-++++- Signed 16-bit sample.
</pre>
Unlike the [[Sound]] sample output registers, these can be written to - allowing for direct 16-bit sample output.
{{Anchor|Hyper Voice Input}}
=== Hyper Voice Left Input ($68) ===
=== Hyper Voice Right Input ($69) ===
<pre>
7 bit 0
---- ----
ssss ssss
++++-++++- 8-bit sample.
</pre>
These are typically written to by [[DMA|Sound DMA]], but can also be written to manually by the user.
{{Anchor|Hyper Voice Control}}
=== Hyper Voice Control ($6A, $6B) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
.mmc .... errr ffss
||| |||| ||++- Shift/Volume:
||| |||| || 0 = 100% 1 = 50%
||| |||| || 2 = 25% 3 = 12.5%
||| |||| ++--- Input sample mode:
||| |||| 0 = Unsigned
||| |||| 1 = Unsigned, negate
||| |||| 2 = Signed
||| |||| 3 = Signed, ignore Shift/Volume
||| |+++------ Update sample rate/Divisor:
||| | 0 = 24000/1 = 24000 Hz
||| | 1 = 24000/2 = 12000 Hz
||| | 2 = 24000/3 = 8000 Hz
||| | 3 = 24000/4 = 6000 Hz
||| | 4 = 24000/5 = 4800 Hz
||| | 5 = 24000/6 = 4000 Hz
||| | 6 = 24000/8 = 3000 Hz
||| | 7 = 24000/12 = 2000 Hz
||| +--------- Enable: 0 = off, 1 = on
||+----------------- Input channel: 0 = left, 1 = right
++------------------ Channel mode:
0 = Stereo
1 = Mono, left channel only
2 = Mono, right channel only
3 = Mono, both channels
</pre>
51d0f63401642a3c00d3e9660e48f6ad8abc6fa5
WSdev Wiki
0
1
130
88
2023-08-22T12:23:04Z
Asie
351
wikitext
text/x-wiki
'''WonderSwan Development Wiki'''
== Reference ==
=== General ===
* [[Memory map]]
* [[I/O port map]]
* [[ROM header]]
* [[NEC V30MZ]] - the WonderSwan CPU (80186-compatible)
* [[Timing]]
=== Console components ===
* [[Display]]
* [[Sound]]
** [[Hyper Voice]]<sup>(color)</sup>
* [[Keypad]]
* [[Timers]]
* [[Interrupts]]
* [[UART]]
* [[EEPROM]]
* [[DMA]]<sup>(color)</sup>
=== Cartridge components ===
* [[Mapper]]
* [[Real-Time Clock]] (2003)
=== Pinouts ===
* [[Accessory port pinout]]
* [[2001 Mapper pinout]]
* [[2003 Mapper pinout]]
* [[KARNAK pinout]]
* [[GIZA pinout]]
* [[S-3511A pinout]]
=== Accessories ===
* [[WonderBeat 9480]] headphone adapter
* [[WonderBorg]] robot
* [[WonderGate]] mobile adapter
* [[WonderWave]] infrared adapter
=== WonderWitch ===
* [[FreyaBIOS]]
* [[WonderWitch .fx files|.fx file format]]
== Links ==
* [https://github.com/WonderfulToolchain/awesome-wsdev awesome-wsdev] - curated documentation/tools/source code link list
== MediaWiki ==
* [https://www.mediawiki.org/wiki/Special:MyLanguage/Help:Contents User's Guide]
* [https://www.mediawiki.org/wiki/Special:MyLanguage/Manual:FAQ MediaWiki FAQ]
* [[:Category:Deletion requests|Deletion requests]]
e7ad637cb3abfe2283f6842c5b5c5806ea23e799
136
130
2023-08-22T12:40:20Z
Asie
351
wikitext
text/x-wiki
'''WonderSwan Development Wiki'''
== Reference ==
=== General ===
* [[Memory map]]
* [[I/O port map]]
* [[ROM header]]
* [[NEC V30MZ]] - the WonderSwan CPU (80186-compatible)
* [[Timing]]
=== Console components ===
* [[Display]]
* [[Sound]]
** [[Hyper Voice]]<sup>(color)</sup>
* [[Keypad]]
* [[Timers]]
* [[Interrupts]]
* [[UART]]
* [[EEPROM]]
* [[DMA]]<sup>(color)</sup>
=== Cartridge components ===
* [[Mapper]]
** [[Bandai 2001]]
** [[Bandai 2003]]
** [[KARNAK]]
* [[Real-Time Clock]] (2003)
=== Pinouts ===
* [[Accessory port pinout]]
* [[2001 Mapper pinout]]
* [[2003 Mapper pinout]]
* [[KARNAK pinout]]
* [[GIZA pinout]]
* [[S-3511A pinout]]
=== Accessories ===
* [[WonderBeat 9480]] headphone adapter
* [[WonderBorg]] robot
* [[WonderGate]] mobile adapter
* [[WonderWave]] infrared adapter
=== WonderWitch ===
* [[FreyaBIOS]]
* [[WonderWitch .fx files|.fx file format]]
== Links ==
* [https://github.com/WonderfulToolchain/awesome-wsdev awesome-wsdev] - curated documentation/tools/source code link list
== MediaWiki ==
* [https://www.mediawiki.org/wiki/Special:MyLanguage/Help:Contents User's Guide]
* [https://www.mediawiki.org/wiki/Special:MyLanguage/Manual:FAQ MediaWiki FAQ]
* [[:Category:Deletion requests|Deletion requests]]
1247e7a32bb26d31de899b303f39ac8b6036522a
146
136
2023-08-22T13:52:46Z
Asie
351
wikitext
text/x-wiki
'''WonderSwan Development Wiki'''
== Reference ==
=== General ===
* [[Memory map]]
* [[I/O port map]]
* [[ROM header]]
* [[NEC V30MZ]] - the WonderSwan CPU (80186-compatible)
* [[Timing]]
=== Console components ===
* [[Display]]
* [[Sound]]
** [[Hyper Voice]]<sup>(color)</sup>
* [[Keypad]]
* [[Timers]]
* [[Interrupts]]
* [[UART]]
* [[EEPROM|Internal EEPROM]]
** [[Splash animation]]<sup>(color)</sup>
* [[DMA]]<sup>(color)</sup>
=== Cartridge components ===
* [[Mapper]]
** [[Bandai 2001]]
** [[Bandai 2003]]
** [[KARNAK]]
* [[EEPROM]] (2001)
* [[Real-Time Clock]] (2003)
=== Pinouts ===
* [[Accessory port pinout]]
* [[2001 Mapper pinout]]
* [[2003 Mapper pinout]]
* [[KARNAK pinout]]
* [[GIZA pinout]]
* [[S-3511A pinout]]
=== Accessories ===
* [[WonderBeat 9480]] headphone adapter
* [[WonderBorg]] robot
* [[WonderGate]] mobile adapter
* [[WonderWave]] infrared adapter
=== WonderWitch ===
* [[FreyaBIOS]]
* [[WonderWitch .fx files|.fx file format]]
== Links ==
* [https://github.com/WonderfulToolchain/awesome-wsdev awesome-wsdev] - curated documentation/tools/source code link list
== MediaWiki ==
* [https://www.mediawiki.org/wiki/Special:MyLanguage/Help:Contents User's Guide]
* [https://www.mediawiki.org/wiki/Special:MyLanguage/Manual:FAQ MediaWiki FAQ]
* [[:Category:Deletion requests|Deletion requests]]
75d6c30c02e8346d5ed309791b5de20b66993cdf
DMA
0
31
132
2023-08-22T12:35:24Z
Asie
351
Created page with "The WonderSwan Color introduced two DMA blocks: * General DMA (GDMA) - allowing for fast IRAM/ROM -> IRAM transfers, * Sound DMA (SDMA) - allowing for IRAM/ROM -> sound transfers in a much less CPU-intensive way than an interrupt. == General DMA == {{Anchor|GDMA Source Address Low}} {{Anchor|GDMA Source Address High}} === GDMA Source Address ($40, $41, $42) === <pre> 23 bit 16 15 bit 8 7 bit 0 ---- ---- ---- ---- ---- ---- .... hhhh llll llll llll llll..."
wikitext
text/x-wiki
The WonderSwan Color introduced two DMA blocks:
* General DMA (GDMA) - allowing for fast IRAM/ROM -> IRAM transfers,
* Sound DMA (SDMA) - allowing for IRAM/ROM -> sound transfers in a much less CPU-intensive way than an interrupt.
== General DMA ==
{{Anchor|GDMA Source Address Low}}
{{Anchor|GDMA Source Address High}}
=== GDMA Source Address ($40, $41, $42) ===
<pre>
23 bit 16 15 bit 8 7 bit 0
---- ---- ---- ---- ---- ----
.... hhhh llll llll llll llll
++++--++++-++++--++++-++++- Linear source address
($00000 - $FFFFF)
</pre>
DMA allows source addresses in IRAM and ROM; any attempt to access SRAM causes DMA to immediately return, even if in the middle of a transfer.
TODO: What about source addresses in ROM configured as 8-bit?
{{Anchor|GDMA Destination Address}}
=== GDMA Destination Address ($44, $45) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
aaaa aaaa aaaa aaaa
++++-++++--++++-++++- Destination address in IRAM
</pre>
GDMA allows destination addresses in IRAM.
{{Anchor|GDMA Length}}
=== GDMA Length ($46, $47) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
bbbb bbbb bbbb bbbb
++++-++++--++++-++++- Transfer length, in bytes
</pre>
{{Anchor|GDMA Control}}
=== GDMA Control ($48) ===
<pre>
7 bit 0
---- ----
ed.. ....
|+-------- Direction: 0 = increment, 1 = decrement
+--------- Enable DMA: 0 = off, 1 = on
</pre>
The CPU is stalled immediately after General DMA is enabled. General DMA takes <code>(5 + 2 * length)</code> cycles to complete.
== Sound DMA ==
Sound DMA is a specialized form of General DMA with a hard-coded destination and built-in timer logic. As such, all of the rules for GDMA apply to SDMA as well.
Due to its need to access the external cartridge bus, Sound DMA steals 7 cycles - the same amount of time GDMA would take for transferring one byte - every 128 cycles. These are always cycles <code>{117, 118, 119, 120, 121, 122, 123} mod 128</code>.
TODO: How does Sound DMA interact with the cartridge waitstate configuration?
{{Anchor|SDMA Source Address Low}}
{{Anchor|SDMA Source Address High}}
=== SDMA Source Address ($4A, $4B, $4C) ===
<pre>
23 bit 16 15 bit 8 7 bit 0
---- ---- ---- ---- ---- ----
.... hhhh llll llll llll llll
++++--++++-++++--++++-++++- Linear source address
($00000 - $FFFFF)
</pre>
{{Anchor|SDMA Length}}
=== SDMA Length ($4E, $4F) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
bbbb bbbb bbbb bbbb
++++-++++--++++-++++- Transfer length, in bytes
</pre>
{{Anchor|SDMA Control}}
=== SDMA Control ($50) ===
<pre>
7 bit 0
---- ----
ed.t r?ff
|| | | ++- Frequency/Rate:
|| | | 0 = 24000/1 = 24000 Hz
|| | | 1 = 24000/2 = 12000 Hz
|| | | 2 = 24000/4 = 6000 Hz
|| | | 3 = 24000/6 = 4000 Hz
|| | +---- Repeat: 0 = one-shot, 1 = auto-repeat
|| +------ Target:
|| 0 = Channel 2 (port $89)
|| 1 = Hyper Voice
|+-------- Direction: 0 = increment, 1 = decrement
+--------- Enable DMA: 0 = off, 1 = on
</pre>
The CPU is stalled immediately after General DMA is enabled. General DMA takes <code>(5 + 2 * length)</code> cycles to complete.
6d4aac1e8190fe8bcb5d7156cc1d75e913ffa279
133
132
2023-08-22T12:36:25Z
Asie
351
wikitext
text/x-wiki
The WonderSwan Color introduced two DMA blocks:
* General DMA (GDMA) - allowing for fast IRAM/ROM -> IRAM transfers,
* Sound DMA (SDMA) - allowing for IRAM/ROM -> sound transfers in a much less CPU-intensive way than an interrupt.
== General DMA ==
{{Anchor|GDMA Source Address Low}}
{{Anchor|GDMA Source Address High}}
=== GDMA Source Address ($40, $41, $42) ===
<pre>
23 bit 16 15 bit 8 7 bit 0
---- ---- ---- ---- ---- ----
.... hhhh llll llll llll llll
++++--++++-++++--++++-++++- Linear source address
($00000 - $FFFFF)
</pre>
DMA allows source addresses in IRAM and ROM; any attempt to access SRAM causes DMA to immediately return, even if in the middle of a transfer.
TODO: What about source addresses in ROM configured as 8-bit?
{{Anchor|GDMA Destination Address}}
=== GDMA Destination Address ($44, $45) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
aaaa aaaa aaaa aaaa
++++-++++--++++-++++- Destination address in IRAM
</pre>
GDMA allows destination addresses in IRAM.
{{Anchor|GDMA Length}}
=== GDMA Length ($46, $47) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
bbbb bbbb bbbb bbbb
++++-++++--++++-++++- Transfer length, in bytes
</pre>
{{Anchor|GDMA Control}}
=== GDMA Control ($48) ===
<pre>
7 bit 0
---- ----
ed.. ....
|+-------- Direction: 0 = increment, 1 = decrement
+--------- Enable DMA: 0 = off, 1 = on
</pre>
The CPU is stalled immediately after General DMA is enabled. General DMA takes <code>(5 + 2 * length)</code> cycles to complete.
== Sound DMA ==
Sound DMA is a specialized form of General DMA with a hard-coded destination and built-in timer logic. As such, all of the rules for GDMA apply to SDMA as well.
Due to its need to access the external cartridge bus, Sound DMA steals 7 cycles - the same amount of time GDMA would take for transferring one byte - every 128 cycles. These are always cycles <code>{117, 118, 119, 120, 121, 122, 123} mod 128</code>.
TODO: How does Sound DMA interact with the cartridge waitstate configuration?
{{Anchor|SDMA Source Address Low}}
{{Anchor|SDMA Source Address High}}
=== SDMA Source Address ($4A, $4B, $4C) ===
<pre>
23 bit 16 15 bit 8 7 bit 0
---- ---- ---- ---- ---- ----
.... hhhh llll llll llll llll
++++--++++-++++--++++-++++- Linear source address
($00000 - $FFFFF)
</pre>
{{Anchor|SDMA Length}}
=== SDMA Length ($4E, $4F, $50) ===
<pre>
23 bit 16 15 bit 8 7 bit 0
---- ---- ---- ---- ---- ----
.... hhhh llll llll llll llll
++++--++++-++++--++++-++++- Transfer length, in bytes
</pre>
{{Anchor|SDMA Control}}
=== SDMA Control ($52) ===
<pre>
7 bit 0
---- ----
ed.t r?ff
|| | | ++- Frequency/Rate:
|| | | 0 = 24000/1 = 24000 Hz
|| | | 1 = 24000/2 = 12000 Hz
|| | | 2 = 24000/4 = 6000 Hz
|| | | 3 = 24000/6 = 4000 Hz
|| | +---- Repeat: 0 = one-shot, 1 = auto-repeat
|| +------ Target:
|| 0 = Channel 2 (port $89)
|| 1 = Hyper Voice
|+-------- Direction: 0 = increment, 1 = decrement
+--------- Enable DMA: 0 = off, 1 = on
</pre>
The CPU is stalled immediately after General DMA is enabled. General DMA takes <code>(5 + 2 * length)</code> cycles to complete.
e950d4ec16d0d2133faf08e3a0db2c09c8e89744
134
133
2023-08-22T12:38:15Z
Asie
351
wikitext
text/x-wiki
The WonderSwan Color introduced two DMA blocks:
* General DMA (GDMA) - allowing for fast IRAM/ROM -> IRAM transfers,
* Sound DMA (SDMA) - allowing for IRAM/ROM -> sound transfers in a much less CPU-intensive way than an interrupt.
== General DMA ==
{{Anchor|GDMA Source Address Low}}
{{Anchor|GDMA Source Address High}}
=== GDMA Source Address ($40, $41, $42) ===
<pre>
23 bit 16 15 bit 8 7 bit 0
---- ---- ---- ---- ---- ----
.... hhhh llll llll llll llll
++++---++++-++++---++++-++++- Linear source address
($00000 - $FFFFF)
</pre>
DMA allows source addresses in IRAM and ROM; any attempt to access SRAM causes DMA to immediately return, even if in the middle of a transfer.
TODO: What about source addresses in ROM configured as 8-bit?
{{Anchor|GDMA Destination Address}}
=== GDMA Destination Address ($44, $45) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
aaaa aaaa aaaa aaaa
++++-++++--++++-++++- Destination address in IRAM
</pre>
GDMA allows destination addresses in IRAM.
{{Anchor|GDMA Length}}
=== GDMA Length ($46, $47) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
bbbb bbbb bbbb bbbb
++++-++++--++++-++++- Transfer length, in bytes
</pre>
{{Anchor|GDMA Control}}
=== GDMA Control ($48) ===
<pre>
7 bit 0
---- ----
ed.. ....
|+-------- Direction: 0 = increment, 1 = decrement
+--------- Enable DMA: 0 = off, 1 = on
</pre>
The CPU is stalled immediately after General DMA is enabled. General DMA takes <code>(5 + 2 * length)</code> cycles to complete.
== Sound DMA ==
Sound DMA is a specialized form of General DMA with a hard-coded destination and built-in timer logic. As such, all of the rules for GDMA apply to SDMA as well.
Due to its need to access the external cartridge bus, Sound DMA steals 7 cycles - the same amount of time GDMA would take for transferring one byte - every 128 cycles. These are always cycles <code>{117, 118, 119, 120, 121, 122, 123} mod 128</code>.
TODO: How does Sound DMA interact with the cartridge waitstate configuration?
{{Anchor|SDMA Source Address Low}}
{{Anchor|SDMA Source Address High}}
=== SDMA Source Address ($4A, $4B, $4C) ===
<pre>
23 bit 16 15 bit 8 7 bit 0
---- ---- ---- ---- ---- ----
.... hhhh llll llll llll llll
++++--++++-++++--++++-++++- Linear source address
($00000 - $FFFFF)
</pre>
{{Anchor|SDMA Length}}
=== SDMA Length ($4E, $4F, $50) ===
<pre>
23 bit 16 15 bit 8 7 bit 0
---- ---- ---- ---- ---- ----
.... hhhh llll llll llll llll
++++---++++-++++---++++-++++- Transfer length, in bytes
</pre>
{{Anchor|SDMA Control}}
=== SDMA Control ($52) ===
<pre>
7 bit 0
---- ----
ed.t r?ff
|| | | ++- Frequency/Rate:
|| | | 0 = 24000/1 = 24000 Hz
|| | | 1 = 24000/2 = 12000 Hz
|| | | 2 = 24000/4 = 6000 Hz
|| | | 3 = 24000/6 = 4000 Hz
|| | +---- Repeat: 0 = one-shot, 1 = auto-repeat
|| +------ Target:
|| 0 = Channel 2 (port $89)
|| 1 = Hyper Voice
|+-------- Direction: 0 = increment, 1 = decrement
+--------- Enable DMA: 0 = off, 1 = on
</pre>
The CPU is stalled immediately after General DMA is enabled. General DMA takes <code>(5 + 2 * length)</code> cycles to complete.
81a0562286fe1850e951e4a95947e9e41ebe90ad
135
134
2023-08-22T12:38:45Z
Asie
351
wikitext
text/x-wiki
The WonderSwan Color introduced two DMA blocks:
* General DMA (GDMA) - allowing for fast IRAM/ROM -> IRAM transfers,
* Sound DMA (SDMA) - allowing for IRAM/ROM -> sound transfers in a much less CPU-intensive way than an interrupt.
== General DMA ==
{{Anchor|GDMA Source Address Low}}
{{Anchor|GDMA Source Address High}}
=== GDMA Source Address ($40, $41, $42) ===
<pre>
23 bit 16 15 bit 8 7 bit 0
---- ---- ---- ---- ---- ----
.... hhhh llll llll llll llll
++++---++++-++++---++++-++++- Linear source address
($00000 - $FFFFF)
</pre>
DMA allows source addresses in IRAM and ROM; any attempt to access SRAM causes DMA to immediately return, even if in the middle of a transfer.
TODO: What about source addresses in ROM configured as 8-bit?
{{Anchor|GDMA Destination Address}}
=== GDMA Destination Address ($44, $45) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
aaaa aaaa aaaa aaaa
++++-++++--++++-++++- Destination address in IRAM
</pre>
GDMA allows destination addresses in IRAM.
{{Anchor|GDMA Length}}
=== GDMA Length ($46, $47) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
bbbb bbbb bbbb bbbb
++++-++++--++++-++++- Transfer length, in bytes
</pre>
{{Anchor|GDMA Control}}
=== GDMA Control ($48) ===
<pre>
7 bit 0
---- ----
ed.. ....
|+-------- Direction: 0 = increment, 1 = decrement
+--------- Enable DMA: 0 = off, 1 = on
</pre>
The CPU is stalled immediately after General DMA is enabled. General DMA takes <code>(5 + 2 * length)</code> cycles to complete.
== Sound DMA ==
Sound DMA is a specialized form of General DMA with a hard-coded destination and built-in timer logic. As such, all of the rules for GDMA apply to SDMA as well.
Due to its need to access the external cartridge bus, Sound DMA steals 7 cycles - the same amount of time GDMA would take for transferring one byte - every 128 cycles. These are always cycles <code>{117, 118, 119, 120, 121, 122, 123} mod 128</code>.
TODO: How does Sound DMA interact with the cartridge waitstate configuration?
{{Anchor|SDMA Source Address Low}}
{{Anchor|SDMA Source Address High}}
=== SDMA Source Address ($4A, $4B, $4C) ===
<pre>
23 bit 16 15 bit 8 7 bit 0
---- ---- ---- ---- ---- ----
.... hhhh llll llll llll llll
++++---++++-++++---++++-++++- Linear source address
($00000 - $FFFFF)
</pre>
{{Anchor|SDMA Length}}
=== SDMA Length ($4E, $4F, $50) ===
<pre>
23 bit 16 15 bit 8 7 bit 0
---- ---- ---- ---- ---- ----
.... hhhh llll llll llll llll
++++---++++-++++---++++-++++- Transfer length, in bytes
</pre>
{{Anchor|SDMA Control}}
=== SDMA Control ($52) ===
<pre>
7 bit 0
---- ----
ed.t r?ff
|| | | ++- Frequency/Rate:
|| | | 0 = 24000/1 = 24000 Hz
|| | | 1 = 24000/2 = 12000 Hz
|| | | 2 = 24000/4 = 6000 Hz
|| | | 3 = 24000/6 = 4000 Hz
|| | +---- Repeat: 0 = one-shot, 1 = auto-repeat
|| +------ Target:
|| 0 = Channel 2 (port $89)
|| 1 = Hyper Voice
|+-------- Direction: 0 = increment, 1 = decrement
+--------- Enable DMA: 0 = off, 1 = on
</pre>
The CPU is stalled immediately after General DMA is enabled. General DMA takes <code>(5 + 2 * length)</code> cycles to complete.
9d9660d38614efd86ecdbc55e4d698510e7ac56a
145
135
2023-08-22T13:13:49Z
Fiskbit
37
Register formatting.
wikitext
text/x-wiki
The WonderSwan Color introduced two DMA blocks:
* General DMA (GDMA) - allowing for fast IRAM/ROM -> IRAM transfers,
* Sound DMA (SDMA) - allowing for IRAM/ROM -> sound transfers in a much less CPU-intensive way than an interrupt.
== General DMA ==
{{Anchor|GDMA Source Address Low}}
{{Anchor|GDMA Source Address High}}
=== GDMA Source Address ($40, $41, $42) ===
<pre>
23 bit 16 15 bit 8 7 bit 0
---- ---- ---- ---- ---- ----
.... hhhh llll llll llll llll
|||| |||| |||| |||| ||||
++++---++++-++++---++++-++++- Linear source address
($00000 - $FFFFF)
</pre>
DMA allows source addresses in IRAM and ROM; any attempt to access SRAM causes DMA to immediately return, even if in the middle of a transfer.
TODO: What about source addresses in ROM configured as 8-bit?
{{Anchor|GDMA Destination Address}}
=== GDMA Destination Address ($44, $45) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
aaaa aaaa aaaa aaaa
|||| |||| |||| ||||
++++-++++--++++-++++- Destination address in IRAM
</pre>
GDMA allows destination addresses in IRAM.
{{Anchor|GDMA Length}}
=== GDMA Length ($46, $47) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
bbbb bbbb bbbb bbbb
|||| |||| |||| ||||
++++-++++--++++-++++- Transfer length, in bytes
</pre>
{{Anchor|GDMA Control}}
=== GDMA Control ($48) ===
<pre>
7 bit 0
---- ----
ed.. ....
||
|+-------- Direction: 0 = increment, 1 = decrement
+--------- Enable DMA: 0 = off, 1 = on
</pre>
The CPU is stalled immediately after General DMA is enabled. General DMA takes <code>(5 + 2 * length)</code> cycles to complete.
== Sound DMA ==
Sound DMA is a specialized form of General DMA with a hard-coded destination and built-in timer logic. As such, all of the rules for GDMA apply to SDMA as well.
Due to its need to access the external cartridge bus, Sound DMA steals 7 cycles - the same amount of time GDMA would take for transferring one byte - every 128 cycles. These are always cycles <code>{117, 118, 119, 120, 121, 122, 123} mod 128</code>.
TODO: How does Sound DMA interact with the cartridge waitstate configuration?
{{Anchor|SDMA Source Address Low}}
{{Anchor|SDMA Source Address High}}
=== SDMA Source Address ($4A, $4B, $4C) ===
<pre>
23 bit 16 15 bit 8 7 bit 0
---- ---- ---- ---- ---- ----
.... hhhh llll llll llll llll
|||| |||| |||| |||| ||||
++++---++++-++++---++++-++++- Linear source address
($00000 - $FFFFF)
</pre>
{{Anchor|SDMA Length}}
=== SDMA Length ($4E, $4F, $50) ===
<pre>
23 bit 16 15 bit 8 7 bit 0
---- ---- ---- ---- ---- ----
.... hhhh llll llll llll llll
|||| |||| |||| |||| ||||
++++---++++-++++---++++-++++- Transfer length, in bytes
</pre>
{{Anchor|SDMA Control}}
=== SDMA Control ($52) ===
<pre>
7 bit 0
---- ----
ed.t r?ff
|| | | ||
|| | | ++- Frequency/Rate:
|| | | 0 = 24000/1 = 24000 Hz
|| | | 1 = 24000/2 = 12000 Hz
|| | | 2 = 24000/4 = 6000 Hz
|| | | 3 = 24000/6 = 4000 Hz
|| | +---- Repeat: 0 = one-shot, 1 = auto-repeat
|| +------ Target:
|| 0 = Channel 2 (port $89)
|| 1 = Hyper Voice
|+-------- Direction: 0 = increment, 1 = decrement
+--------- Enable DMA: 0 = off, 1 = on
</pre>
The CPU is stalled immediately after General DMA is enabled. General DMA takes <code>(5 + 2 * length)</code> cycles to complete.
e651e8c40646f83c3fe88264bc2663c5b7c136e2
KARNAK
0
18
137
61
2023-08-22T12:41:22Z
Asie
351
wikitext
text/x-wiki
KARNAK was only used in Pocket Challenge V2 edutainment games.
It is not yet well-documented. It is thought to be a revision of [[Bandai 2003]] that removes the RTC interface, and adds a timer IRQ and a hardware IMA ADPCM decoder.
This page should not be taken as authoritative: it has been pieced together from multiple other pieces of research. It is unclear if the GPO and Self-Flash registers exist; from PCB photos the Self-Flash register is unused if it does exist.
{| class="wikitable"
! Category
! Port
! Description
! Bits
! Type
! Notes
|-
! rowspan="2" | GPO
! $CC
| GPO Data Direction
| style="text-align: right" | <tt style="white-space: nowrap">0000 oooo</tt>
| RW8
| 1 = output, 0 = high-impedance (weak pull-down)
|-
! $CD
| GPO Data
| style="text-align: right" | <tt style="white-space: nowrap">0000 dddd</tt>
| RW8
| 1 = 3V, if enabled by data direction
|-
! Self-Flash
! $CE
| Self-Flash Control
| style="text-align: right" | <tt style="white-space: nowrap">0000 000r</tt>
| RW8
| 1 = ROM is accessible at segment 0x1000;
0 = RAM instead.
|-
! rowspan="4" | Extended bankswitching
! $CF
| ROM Linear (EX) Bank
| style="text-align: right" | <tt style="white-space: nowrap">00bb bbbb</tt>
| RW8
| Selects a 1MiB bank accessed via segments 0x4000 through 0xF000. Identical to the register at 0xC0.
|-
! $D0
| RAM(/ROM) Bank
| style="text-align: right" | <tt style="white-space: nowrap">0000 00bb bbbb bbbb</tt>
| RW16
| Selects a 64KiB bank accessed via segment 0x1000. Lower 8 bits are identical to the register at 0xC1.
|-
! $D2
| ROM0 Bank
| style="text-align: right" | <tt style="white-space: nowrap">0000 00bb bbbb bbbb</tt>
| RW16
| Selects a 64KiB bank accessed via segment 0x2000. Lower 8 bits are identical to the register at 0xC2.
|-
! $D4
| ROM1 Bank
| style="text-align: right" | <tt style="white-space: nowrap">0000 00bb bbbb bbbb</tt>
| RW16
| Selects a 64KiB bank accessed via segment 0x3000. Lower 8 bits are identical to the register at 0xC3.
|-
! Timer
! $D6
| Programmable Interval Timer
| style="text-align: right" | <tt style="white-space: nowrap">eppp pppp</tt>
| RW8
| Enable (e); Period (p). Units are the 384kHz clock to the cartridge.
|-
! rowspan=2|ADPCM
! $D8
| Packed data
| ?
| W8?
| Write two-sample packed ADPCM byte
|-
| $D9
| Unpacked data
| ?
| R8?
| Read two one-byte unpacked PCM bytes, in sequence
|}
d62a73fb69e545595272d7d9f98e9ea07022111f
138
137
2023-08-22T12:41:27Z
Asie
351
wikitext
text/x-wiki
KARNAK was only used in Pocket Challenge V2 edutainment games.
It is not yet well-documented. It is thought to be a revision of [[Bandai 2003]] that removes the RTC interface, and adds a timer IRQ and a hardware IMA ADPCM decoder.
This page should not be taken as authoritative: it has been pieced together from multiple other pieces of research. It is unclear if the GPO and Self-Flash registers exist; from PCB photos the Self-Flash register is unused if it does exist.
{| class="wikitable"
! Category
! Port
! Description
! Bits
! Type
! Notes
|-
! rowspan="2" | GPO
! $CC
| GPO Data Direction
| style="text-align: right" | <tt style="white-space: nowrap">0000 oooo</tt>
| RW8
| 1 = output, 0 = high-impedance (weak pull-down)
|-
! $CD
| GPO Data
| style="text-align: right" | <tt style="white-space: nowrap">0000 dddd</tt>
| RW8
| 1 = 3V, if enabled by data direction
|-
! Self-Flash
! $CE
| Self-Flash Control
| style="text-align: right" | <tt style="white-space: nowrap">0000 000r</tt>
| RW8
| 1 = ROM is accessible at segment 0x1000;
0 = RAM instead.
|-
! rowspan="4" | Extended bankswitching
! $CF
| ROM Linear (EX) Bank
| style="text-align: right" | <tt style="white-space: nowrap">00bb bbbb</tt>
| RW8
| Selects a 1MiB bank accessed via segments 0x4000 through 0xF000. Identical to the register at 0xC0.
|-
! $D0
| RAM(/ROM) Bank
| style="text-align: right" | <tt style="white-space: nowrap">0000 00bb bbbb bbbb</tt>
| RW16
| Selects a 64KiB bank accessed via segment 0x1000. Lower 8 bits are identical to the register at 0xC1.
|-
! $D2
| ROM0 Bank
| style="text-align: right" | <tt style="white-space: nowrap">0000 00bb bbbb bbbb</tt>
| RW16
| Selects a 64KiB bank accessed via segment 0x2000. Lower 8 bits are identical to the register at 0xC2.
|-
! $D4
| ROM1 Bank
| style="text-align: right" | <tt style="white-space: nowrap">0000 00bb bbbb bbbb</tt>
| RW16
| Selects a 64KiB bank accessed via segment 0x3000. Lower 8 bits are identical to the register at 0xC3.
|-
! Timer
! $D6
| Programmable Interval Timer
| style="text-align: right" | <tt style="white-space: nowrap">eppp pppp</tt>
| RW8
| Enable (e); Period (p). Units are the 384kHz clock to the cartridge.
|-
! rowspan=2|ADPCM
! $D8
| Packed data
| ?
| W8?
| Write two-sample packed ADPCM byte
|-
! $D9
| Unpacked data
| ?
| R8?
| Read two one-byte unpacked PCM bytes, in sequence
|}
8c2e993b07630345cce063edaa06f4b127d9bfe8
139
138
2023-08-22T12:42:18Z
Asie
351
wikitext
text/x-wiki
KARNAK was only used in Pocket Challenge V2 edutainment games.
It is not yet well-documented. It is thought to be a revision of [[Bandai 2003]] that removes the RTC interface, and adds a timer IRQ and a hardware IMA ADPCM decoder.
This page should not be taken as authoritative: it has been pieced together from multiple other pieces of research. It is unclear if the GPO and Self-Flash registers exist; from PCB photos the Self-Flash register is unused if it does exist.
{| class="wikitable"
! Category
! Port
! Description
! Bits
! Type
! Notes
|-
! rowspan="2" | GPO
! $CC
| GPO Data Direction
| style="text-align: right" | <tt style="white-space: nowrap">0000 oooo</tt>
| RW8
| 1 = output, 0 = high-impedance (weak pull-down)
|-
! $CD
| GPO Data
| style="text-align: right" | <tt style="white-space: nowrap">0000 dddd</tt>
| RW8
| 1 = 3V, if enabled by data direction
|-
! Self-Flash
! $CE
| Self-Flash Control
| style="text-align: right" | <tt style="white-space: nowrap">0000 000r</tt>
| RW8
| 1 = ROM is accessible at segment 0x1000;
0 = RAM instead.
|-
! rowspan="4" | Extended bankswitching
! $CF
| ROM Linear (EX) Bank
| style="text-align: right" | <tt style="white-space: nowrap">00bb bbbb</tt>
| RW8
| Selects a 1MiB bank accessed via segments 0x4000 through 0xF000. Identical to the register at 0xC0.
|-
! $D0
| RAM(/ROM) Bank
| style="text-align: right" | <tt style="white-space: nowrap">0000 00bb bbbb bbbb</tt>
| RW16
| Selects a 64KiB bank accessed via segment 0x1000. Lower 8 bits are identical to the register at 0xC1.
|-
! $D2
| ROM0 Bank
| style="text-align: right" | <tt style="white-space: nowrap">0000 00bb bbbb bbbb</tt>
| RW16
| Selects a 64KiB bank accessed via segment 0x2000. Lower 8 bits are identical to the register at 0xC2.
|-
! $D4
| ROM1 Bank
| style="text-align: right" | <tt style="white-space: nowrap">0000 00bb bbbb bbbb</tt>
| RW16
| Selects a 64KiB bank accessed via segment 0x3000. Lower 8 bits are identical to the register at 0xC3.
|-
! Timer
! $D6
| Programmable Interval Timer
| style="text-align: right" | <tt style="white-space: nowrap">eppp pppp</tt>
| RW8
| Enable (e); Period (p). Units are the 384kHz clock to the cartridge.
|-
! rowspan=2|ADPCM
! $D8
| Packed data
| ?
| W8?
| Write two-sample packed ADPCM byte
|-
! $D9
| Unpacked data
| ?
| R8?
| Read two one-byte unpacked PCM bytes, in sequence
|}
== Timer ==
If enabled, the timer will emit a [[Interrupts|cartridge interrupt]] every <code>((period + 1) * 2)</code> cartridge clocks, where "one cartridge clock" = 384KHz = 1/8th CPU clock.
73e45ad837d4aab16198f6550e1f8c22c8a7e28f
Timing
0
7
140
84
2023-08-22T12:42:47Z
Asie
351
wikitext
text/x-wiki
== Clocks ==
The WonderSwan is clocked with a master clock of approximately 12288000 Hz (= 12.288 MHz).
This clock is split into four internal memory access quadrants, running at 3072000 Hz (= 3.072 MHz) each. Three of those are used by the console in "mono" mode: [[CPU|NEC V30MZ]], [[Display]] and [[Sound]]. On the WonderSwan Color, the fourth quadrant is used to handle color palette reads during display drawing.
Out of those, only the CPU quadrant can access the cartridge bus. It can be additionally configured to use one of two wait states:
* 1 cycle access - an effective bus speed of 3072000 Hz, same as the CPU,
* 3 cycle access - an effective bus speed of 1024000 Hz.
In addition, a separate 384000 Hz (3072000 / 8) clock is provided on one of the cartridge pins.
== Display ==
By default, a WonderSwan frame consists of 159 lines, 144 of which are visible. Each line consists of 256 clock cycles, of which 224 are used to draw a pixel at a time. This leads to a total duration of 40704 clock cycles per frame, for an effective default refresh rate of approximately 75.472 Hz.
Vertical blanks are always triggered on line 144; if the display is set to be shorter than 144 lines, vertical blank interrupts will never be triggered.
0cd23cad2bf08244b0d8838df22cec6d7660e15a
Category:Deletion requests
14
32
143
2023-08-22T12:52:42Z
Fiskbit
37
Adds deletion-request category.
wikitext
text/x-wiki
This is a list of pages including the <nowiki>{{delete}}</nowiki> template, requesting a moderator to review them for deletion.
See: [[Template:Delete]]
f5fc73d29d81cdb615aefd3b4fd885759b595dfb
Template:Delete
10
33
144
2023-08-22T12:53:13Z
Fiskbit
37
Adds deletion-request template.
wikitext
text/x-wiki
<noinclude>Place this template on a page that you think should be deleted.
For a list of pending deletion requests see: [[:Category:Deletion requests]]
</noinclude>'''''This page is requested for deletion review by a moderator.'''''
<includeonly>[[Category:Deletion requests]]</includeonly>
97de1a9d59533764786c50377a5383f61fabc645
Splash animation
0
34
148
2023-08-22T14:09:11Z
Asie
351
Created page with "The WonderSwan Color upgraded the [[EEPROM|internal EEPROM]] from 128 bytes to 2 kilobytes; most of the additional space is utilized to allow for branding consoles in the form of unique, custom splash animations on console startup. == Format == {| class="wikitable" |- ! Offset !! Length !! Contents |- | $83 || 1 || WSC-specific configuration. Bit 7 enables custom splash animation. |- | $84 || 1 || Name color |- | $85 || 1 || Must be $00 |- | $86 || 1 || Size; 0 = ends..."
wikitext
text/x-wiki
The WonderSwan Color upgraded the [[EEPROM|internal EEPROM]] from 128 bytes to 2 kilobytes; most of the additional space is utilized to allow for branding consoles in the form of unique, custom splash animations on console startup.
== Format ==
{| class="wikitable"
|-
! Offset !! Length !! Contents
|-
| $83 || 1 || WSC-specific configuration. Bit 7 enables custom splash animation.
|-
| $84 || 1 || Name color
|-
| $85 || 1 || Must be $00
|-
| $86 || 1 || Size; 0 = ends at <= $3FF, 1 = ends at <= $7FF
|-
| $87 || 1 || First frame
|-
| $88 || 1 || Last frame
|-
| $89 || 1 || Sprite count
|-
| $8A || 1 || Palette flags
|-
| $8B || 1 || Tile count
|-
| $8C || 2 || Palette location - $80
|-
| $8E || 2 || Tile data location - $80
|-
| $90 || 2 || Tilemap location - $80
|-
| $92 || 2 || Screen offset (Horizontal)
|-
| $94 || 2 || Screen offset (Vertical)
|-
| $96 || 1 || Tilemap width
|-
| $97 || 1 || Tilemap height
|-
| $98 || 2 || VBlank IRQ handler offset
|-
| $9A || 2 || VBlank IRQ handler segment
|-
| $9C || 1 || Owner name X (horizontal)
|-
| $9D || 1 || Owner name Y (horizontal)
|-
| $9E || 1 || Owner name X (vertical)
|-
| $9F || 1 || Owner name Y (vertical)
|-
| $A0 || 2 || Padding, unused
|-
| $A2 || 2 || Sound wavetable location - $80
|-
| $A4 || 2 || Sound channel 1 data offset - $80
|-
| $A6 || 2 || Sound channel 2 data offset - $80
|-
| $A8 || 2 || Sound channel 3 data offset - $80
|-
| $AA || 2 || Sound channel 4 data offset - $80
|-
| $AC || 10 || SwanCrystal TFT LCD configuration
|-
| $B6 || 10 || Padding, unused
|-
| $C0 || ... || Arbitrary data - palettes, tilemaps, etc.
|}
=== Palette flags ===
<pre>
7 bit 0
---- ----
b..p pppp
| +-++++- Palette count (0-16)
+--------- Tile/palette bits per pixel:
0 = 1 bit per pixel
1 = 2 bits per pixel
</pre>
=== Name colors ===
{| class="wikitable"
|-
! Value !! RGB code
|-
| 0 || #000
|-
| 1 || #f00
|-
| 2 || #f70
|-
| 3 || #ff0
|-
| 4 || #7f0
|-
| 5 || #0f0
|-
| 6 || #0f7
|-
| 7 || #0ff
|-
| 8 || #07f
|-
| 9 || #00f
|-
| 10 || #70f
|-
| 11 || #f0f
|-
| 12 || #f07
|}
30b8c12184dda3369d503840be15e06a7967323e
149
148
2023-08-22T14:12:33Z
Asie
351
wikitext
text/x-wiki
The WonderSwan Color upgraded the [[EEPROM|internal EEPROM]] from 128 bytes to 2 kilobytes; most of the additional space is utilized to allow for branding consoles in the form of unique, custom splash animations on console startup.
== Format ==
{| class="wikitable"
|-
! Offset !! Length !! Contents
|-
| $83 || 1 || WSC-specific configuration. Bit 7 enables custom splash animation.
|-
| $84 || 1 || Name color
|-
| $85 || 1 || Must be $00
|-
| $86 || 1 || Size; 0 = ends at <= $3FF, 1 = ends at <= $7FF
|-
| $87 || 1 || First frame
|-
| $88 || 1 || Last frame
|-
| $89 || 1 || Sprite count
|-
| $8A || 1 || Palette flags
|-
| $8B || 1 || Tile count
|-
| $8C || 2 || Palette location - $80
|-
| $8E || 2 || Tile data location - $80
|-
| $90 || 2 || Tilemap location - $80
|-
| $92 || 2 || Screen offset (Horizontal)
|-
| $94 || 2 || Screen offset (Vertical)
|-
| $96 || 1 || Tilemap width
|-
| $97 || 1 || Tilemap height
|-
| $98 || 2 || VBlank IRQ handler offset
|-
| $9A || 2 || VBlank IRQ handler segment, must be $0600
|-
| $9C || 1 || Owner name X (horizontal)
|-
| $9D || 1 || Owner name Y (horizontal)
|-
| $9E || 1 || Owner name X (vertical)
|-
| $9F || 1 || Owner name Y (vertical)
|-
| $A0 || 2 || Padding, unused
|-
| $A2 || 2 || Sound wavetable location - $80
|-
| $A4 || 2 || Sound channel 1 data offset - $80
|-
| $A6 || 2 || Sound channel 2 data offset - $80
|-
| $A8 || 2 || Sound channel 3 data offset - $80
|-
| $AA || 2 || Sound channel 4 data offset - $80
|-
| $AC || 10 || SwanCrystal TFT LCD configuration
|-
| $B6 || 10 || Padding, unused
|-
| $C0 || ... || Arbitrary data - palettes, tilemaps, etc.
|}
=== Palette flags ===
<pre>
7 bit 0
---- ----
b..p pppp
| +-++++- Palette count (0-16)
+--------- Tile/palette bits per pixel:
0 = 1 bit per pixel
1 = 2 bits per pixel
</pre>
=== Name colors ===
{| class="wikitable"
|-
! Value !! RGB code
|-
| 0 || #000
|-
| 1 || #f00
|-
| 2 || #f70
|-
| 3 || #ff0
|-
| 4 || #7f0
|-
| 5 || #0f0
|-
| 6 || #0f7
|-
| 7 || #0ff
|-
| 8 || #07f
|-
| 9 || #00f
|-
| 10 || #70f
|-
| 11 || #f0f
|-
| 12 || #f07
|}
=== VBlank IRQ handler ===
A custom splash animation ''must'' provide a valid VBlank IRQ handler, with the following rules:
* The segment must be ''0x0600''; the offset is provided relative to ''$80'', as with other data offsets.
* The code must end with a ''retf'' opcode, or equivalent.
=== Horizontal/Vertical orientation handling ===
The splash animation loader will automatically rotate the tile data and tilemap when booting a cartridge whose [[ROM header||header]] declares vertical orientation as its startup orientation.
=== Sound channel data format ===
TODO
1f03303a60af2978ee2f3eed1970d407b2e71cd3
EEPROM
0
35
150
2023-08-22T16:41:42Z
Asie
351
Created page with "The WonderSwan utilizes M93LCx6-compatible EEPROMs: * in the SoC: ** 1 Kbit internal EEPROM (M93LC46-compatible) on the WonderSwan, ** 16 Kbit internal EEPROM (M93LC86-compatible) on the WonderSwan Color, * on cartridges: ** 1 Kbit cartridge EEPROM (M93LC46-compatible) ** 8 Kbit cartridge EEPROM (M93LC76-compatible) ** 16 Kbit cartridge EEPROM (M93LC86-compatible) Additional variants exists which were not seen on any production cartridge: * 2 Kbit EEPROM (M93LC56-comp..."
wikitext
text/x-wiki
The WonderSwan utilizes M93LCx6-compatible EEPROMs:
* in the SoC:
** 1 Kbit internal EEPROM (M93LC46-compatible) on the WonderSwan,
** 16 Kbit internal EEPROM (M93LC86-compatible) on the WonderSwan Color,
* on cartridges:
** 1 Kbit cartridge EEPROM (M93LC46-compatible)
** 8 Kbit cartridge EEPROM (M93LC76-compatible)
** 16 Kbit cartridge EEPROM (M93LC86-compatible)
Additional variants exists which were not seen on any production cartridge:
* 2 Kbit EEPROM (M93LC56-compatible)
* 4 Kbit EEPROM (M93LC66-compatible)
== Commands ==
TODO
== I/O ports ==
The I/O ports listed refer to the internal EEPROM; for the cartridge EEPROM port numbers, refer to the [[Bandai 2001|mapper documentation]].
{{Anchor|Internal EEPROM Data}}
=== Internal EEPROM Data ($BA, $BB) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
dddd dddd dddd dddd
|||| |||| |||| ||||
++++-++++--++++-++++- Data read from/written to the EEPROM.
</pre>
This port functions as a shared buffer for both "read" and "write" modes. (TODO: Verify)
{{Anchor|Internal EEPROM Command}}
=== Internal EEPROM Command ($BC, $BD) ===
<pre>
Command Pattern 1
15 bit 8 7 bit 0
---- ---- ---- ----
0000 0001 ooaa aaaa (1 Kbit - M93LC46)
0000 01oo aaaa aaaa (2, 4 Kbit - M93LC56/66)
0001 ooaa aaaa aaaa (8, 16 Kbit - M93LC76/86)
|||| |||| ||||
||++--++++-++++- Address (MSb .. LSb)
++-------------- Opcode:
01 - WRITE
10 - READ
11 - ERASE
</pre>
<pre>
Command Pattern 2
15 bit 8 7 bit 0
---- ---- ---- ----
0000 0001 00ss .... (1 Kbit - M93LC46)
0000 0100 ss.. .... (2, 4 Kbit - M93LC56/66)
0001 00ss .... .... (8, 16 Kbit - M93LC76/86)
||
++------------ Sub-Opcode:
00 - WDS
01 - WRAL
01 - ERAL
11 - WEN
</pre>
{{Anchor|Internal EEPROM Control}}
=== Internal EEPROM Control ($BE, $BF write) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
.... .... pewr ....
||||
|||+------ 1 for READ command, 0 otherwise
||+------- 1 for WRITE and WRAL command, 0 otherwise
|+-------- 1 for ERASE, WDS, ERAL and WEN command, 0 otherwise
+--------- 1 to enable internal EEPROM write protection.
Cannot be cleared once set.
</pre>
{{Anchor|Internal EEPROM Status}}
=== Internal EEPROM Status ($BE, $BF read) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
.... .... p... ..RD
| ||
| |+- 1 if a READ command has completed.
| +-- 0 if the EEPROM is busy,
| 1 if a command can be accepted (idle).
+--------- Internal EEPROM write protection:
0 = disabled, 1 = enabled
</pre>
== Hardware notes ==
EEPROM command bits are shifted out starting from the ''most'' significant bit of the port.
<pre>
+----> EEPROM Serial Data
|
[0] <= [0000 0001 ooaa aaaa]
EEPROM Command Port
</pre>
While the M93LCx6 family supports byte organization, the WonderSwan always uses word organization. As such, this implementation detail is omitted in this documentation.
== Links ==
* [https://www.st.com/resource/en/datasheet/m93c46-w.pdf STMicroelectronics M93LCx6 datasheet]
5f304b0451bf528ca115012752867f7de948eb27
I/O port map
0
8
151
142
2023-08-22T16:43:22Z
Asie
351
wikitext
text/x-wiki
* Superscripts are used to mark ports specific to a given mode or platform:
** Color mode: <sup>(color)</sup>.
** WS/WSC/SC console: <sup>(WS)</sup>, <sup>(WSC)</sup>, <sup>(SC)</sup>.
* If two Bits rows are provided, the second one refers to the "Color" mode.
* The Type can be: R - readable, W - writable, L - writable before boot ROM lockout, 8/16 - width (byte/word).
{| class="wikitable"
! Category
! Port
! Description
! Bits
! Type
! Notes
|-
! rowspan="45" | [[Display]]
! $00
| [[Display#Display Control|Display Control]]
| style="text-align: right" | <tt style="white-space: nowrap">..ow Ws21</tt>
| RW8
|
|-
! $01
| [[Display#Display Background|Display Background]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .sss</tt>
<tt style="white-space: nowrap">pppp iiii</tt>
| RW8
| Shade (s)
Palette (p), Index (i)
|-
! $02
| [[Display#Current Line|Display Current Line]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll</tt>
| R8
| Line (l)
|-
! $03
| [[Display#Interrupt Line|Display Interrupt Line]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll</tt>
| RW8
| Line (l)
|-
! $04
| [[Display#Sprite Table Address|Sprite Table Address]]
| style="text-align: right" | <tt style="white-space: nowrap">...a aaaa</tt>
<tt style="white-space: nowrap">..aa aaaa</tt>
| RW8
| Address >> 9 (a)
|-
! $05
| [[Display#Sprite Table First|Sprite Table First]]
| style="text-align: right" | <tt style="white-space: nowrap">.iii iiii</tt>
| RW8
| Index (i)
|-
! $06
| [[Display#Sprite Table Count|Sprite Table Count]]
| style="text-align: right" | <tt style="white-space: nowrap">cccc cccc</tt>
| RW8
| Count (c)
|-
! $07
| [[Display#Screen Address|Screen Address]]
| style="text-align: right" | <tt style="white-space: nowrap">.222 .111</tt>
<tt style="white-space: nowrap">2222 1111</tt>
| RW8
| Screen 1 address >> 11 (1)
Screen 2 address >> 11 (2)
|-
! $08
| [[Display#Screen 2 Window|Screen 2 Window Left]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $09
| [[Display#Screen 2 Window|Screen 2 Window Top]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $0A
| [[Display#Screen 2 Window|Screen 2 Window Right]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $0B
| [[Display#Screen 2 Window|Screen 2 Window Bottom]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $0B
| [[Display#Sprite Window|Sprite Window Left]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $0C
| [[Display#Sprite Window|Sprite Window Top]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $0E
| [[Display#Sprite Window|Sprite Window Right]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $0F
| [[Display#Sprite Window|Sprite Window Bottom]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $10
| [[Display#Screen Scroll|Screen 1 Scroll X]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $11
| [[Display#Screen Scroll|Screen 1 Scroll Y]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $12
| [[Display#Screen Scroll|Screen 2 Scroll X]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $13
| [[Display#Screen Scroll|Screen 2 Scroll Y]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $14
| [[Display#LCD Control|LCD Control]]
| style="text-align: right" | <tt style="white-space: nowrap">.... ..Ce</tt>
| RW8
| Contrast (C)<sup>(WSC)</sup>, Enable (e)
|-
! $15
| [[Display#LCD Icon Control|LCD Icon Control]]
| style="text-align: right" | <tt style="white-space: nowrap">..32 1hvs</tt>
| RW8
| Auxillary 3 (3), Auxillary 2 (2), Auxillary 1 (1),
Horizontal (h), Vertical (v), Sleep (s)
|-
! $16
| [[Display#LCD Final Line|LCD Final Line]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll</tt>
| RW8
| Line (l)
|-
! $17
| [[Display#LCD Back Porch Line|LCD Back Porch Line]]<sup>(WSC)</sup>
| style="text-align: right" | <tt style="white-space: nowrap">llll llll</tt>
| RW8
| Line (l)
|-
! $1A
| [[Display#LCD Status|LCD Status]]
| style="text-align: right" | <tt style="white-space: nowrap">...v vv.s</tt>
| RW8
| Volume segment status (v), Sleep (s)
|-
! $1C
| [[Display#LCD Mono Shade LUT|LCD Mono Shade LUT 0/1]]
| style="text-align: right" | <tt style="white-space: nowrap">1111 0000</tt>
| RW8
| Shade index
|-
! $1D
| [[Display#LCD Mono Shade LUT|LCD Mono Shade LUT 2/3]]
| style="text-align: right" | <tt style="white-space: nowrap">3333 2222</tt>
| RW8
| Shade index
|-
! $1E
| [[Display#LCD Mono Shade LUT|LCD Mono Shade LUT 4/5]]
| style="text-align: right" | <tt style="white-space: nowrap">5555 4444</tt>
| RW8
| Shade index
|-
! $1F
| [[Display#LCD Mono Shade LUT|LCD Mono Shade LUT 6/7]]
| style="text-align: right" | <tt style="white-space: nowrap">7777 6666</tt>
| RW8
| Shade index
|-
! $20
| [[Display#LCD Mono Palette|LCD Mono Palette 0]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $22
| [[Display#LCD Mono Palette|LCD Mono Palette 1]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $24
| [[Display#LCD Mono Palette|LCD Mono Palette 2]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $26
| [[Display#LCD Mono Palette|LCD Mono Palette 3]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $28
| [[Display#LCD Mono Palette|LCD Mono Palette 4]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $2A
| [[Display#LCD Mono Palette|LCD Mono Palette 5]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $2C
| [[Display#LCD Mono Palette|LCD Mono Palette 6]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $2E
| [[Display#LCD Mono Palette|LCD Mono Palette 7]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $30
| [[Display#LCD Mono Palette|LCD Mono Palette 8]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $32
| [[Display#LCD Mono Palette|LCD Mono Palette 9]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $34
| [[Display#LCD Mono Palette|LCD Mono Palette 10]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $36
| [[Display#LCD Mono Palette|LCD Mono Palette 11]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $38
| [[Display#LCD Mono Palette|LCD Mono Palette 12]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $3A
| [[Display#LCD Mono Palette|LCD Mono Palette 13]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $3C
| [[Display#LCD Mono Palette|LCD Mono Palette 14]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $3E
| [[Display#LCD Mono Palette|LCD Mono Palette 15]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! rowspan="10" | [[DMA]]<sup>(color)</sup>
! $40
| [[DMA#General DMA|GDMA Source Address Low]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll llll llll</tt>
| RW16
| Linear address, low 16 bits (l)
|-
! $42
| [[DMA#General DMA|GDMA Source Address High]]
| style="text-align: right" | <tt style="white-space: nowrap">.... hhhh</tt>
| RW8
| Linear address, high 4 bits (h)
|-
! $44
| [[DMA#General DMA|GDMA Destination Address]]
| style="text-align: right" | <tt style="white-space: nowrap">aaaa aaaa aaaa aaaa</tt>
| RW16
| IRAM address (a)
|-
! $46
| [[DMA#General DMA|GDMA Length]]
| style="text-align: right" | <tt style="white-space: nowrap">bbbb bbbb bbbb bbbb</tt>
| RW16
| Bytes (b)
|-
! $48
| [[DMA#General DMA|GDMA Control]]
| style="text-align: right" | <tt style="white-space: nowrap">ed.. ....</tt>
| RW8
| Enable (e), Decrement (d)
|-
! $4A
| [[DMA#Sound DMA|SDMA Source Address Low]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll llll llll</tt>
| RW16
| Linear address, low 16 bits (l)
|-
! $4C
| [[DMA#Sound DMA|SDMA Source Address High]]
| style="text-align: right" | <tt style="white-space: nowrap">.... hhhh</tt>
| RW8
| Linear address, high 4 bits (h)
|-
! $4E
| [[DMA#Sound DMA|SDMA Length Low]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll llll llll</tt>
| RW16
| Length, low 16 bits (l)
|-
! $50
| [[DMA#Sound DMA|SDMA Length High]]
| style="text-align: right" | <tt style="white-space: nowrap">.... hhhh</tt>
| RW8
| Length, high 4 bits (h)
|-
! $52
| [[DMA#Sound DMA|SDMA Control]]
| style="text-align: right" | <tt style="white-space: nowrap">ed.t r?ff</tt>
| RW8
| Enable (e), Decrement (d), Target (t),
Repeat (r), Frequency (f)
|-
! rowspan="2" | System<sup>(color)</sup>
! $60
| System Control 2
| style="text-align: right" | <tt style="white-space: nowrap">c4C. ?.??</tt>
| RW8
| Color (c), 4BPP (4), Chunky (C)
|-
! $62
| System Control 3
| style="text-align: right" | <tt style="white-space: nowrap">S... ...p</tt>
| RW8
| SwanCrystal (S), Power off (p)
|-
! rowspan="5" | [[Hyper Voice]]<sup>(color)</sup>
! $64
| Hyper Voice Left Output
| style="text-align: right" | <tt style="white-space: nowrap">ssss ssss ssss ssss</tt>
| W16
| Raw sample (s)
|-
! $66
| Hyper Voice Right Output
| style="text-align: right" | <tt style="white-space: nowrap">ssss ssss ssss ssss</tt>
| W16
| Raw sample (s)
|-
! $68
| Hyper Voice Left Input
| style="text-align: right" | <tt style="white-space: nowrap">ssss ssss</tt>
| 8
| Sample (s)
|-
! $69
| Hyper Voice Right Input
| style="text-align: right" | <tt style="white-space: nowrap">ssss ssss</tt>
| 8
| Sample (s)
|-
! $6A
| Hyper Voice Control
| style="text-align: right" | <tt style="white-space: nowrap">.mmc .... errr ffss</tt>
| RW16
| Mask (m), Channel (c), Enable (e),
Rate (r), Format (f), Shift (s)
|-
! rowspan="8" | [[Display]]<sup>(SC)</sup>
! $70
| LCD Timing Configuration 1?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $71
| LCD Timing Configuration 2?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $72
| LCD Timing Configuration 3?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $73
| LCD Timing Configuration 4?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $74
| LCD Timing Configuration 5?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $75
| LCD Timing Configuration 6?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $76
| LCD Timing Configuration 7?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $77
| LCD Timing Configuration 8?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! rowspan="21" | [[Sound]]
! $80
| [[Sound#Sound Channel Frequency|Sound Channel 1 Frequency]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .ddd dddd dddd</tt>
| RW16
| Divider (d)
|-
! $82
| [[Sound#Sound Channel Frequency|Sound Channel 2 Frequency]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .ddd dddd dddd</tt>
| RW16
| Divider (d)
|-
! $84
| [[Sound#Sound Channel Frequency|Sound Channel 3 Frequency]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .ddd dddd dddd</tt>
| RW16
| Divider (d)
|-
! $86
| [[Sound#Sound Channel Frequency|Sound Channel 4 Frequency]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .ddd dddd dddd</tt>
| RW16
| Divider (d)
|-
! $88
| [[Sound#Sound Channel Volume|Sound Channel 1 Volume]]
| style="text-align: right" | <tt style="white-space: nowrap">llll rrrr</tt>
| RW8
| Left (l), Right (r)
|-
! rowspan="2" | $89
| [[Sound#Sound Channel Volume|Sound Channel 2 Volume]]
| style="text-align: right" | <tt style="white-space: nowrap">llll rrrr</tt>
| RW8
| Left (l), Right (r)
|-
| [[Sound#Sound Channel 2 Voice Sample|Sound Channel 2 Voice Sample]]
| style="text-align: right" | <tt style="white-space: nowrap">ssss ssss</tt>
| RW8
| Sample (s)
|-
! $8A
| [[Sound#Sound Channel Volume|Sound Channel 3 Volume]]
| style="text-align: right" | <tt style="white-space: nowrap">llll rrrr</tt>
| RW8
| Left (l), Right (r)
|-
! $8B
| [[Sound#Sound Channel Volume|Sound Channel 4 Volume]]
| style="text-align: right" | <tt style="white-space: nowrap">llll rrrr</tt>
| RW8
| Left (l), Right (r)
|-
! $8C
| [[Sound#Sound Channel 3 Sweep Amount|Sound Channel 3 Sweep Amount]]
| style="text-align: right" | <tt style="white-space: nowrap">vvvv vvvv</tt>
| RW8
| Value (v)
|-
! $8D
| [[Sound#Sound Channel 3 Sweep Ticks|Sound Channel 3 Sweep Ticks]]
| style="text-align: right" | <tt style="white-space: nowrap">...t tttt</tt>
| RW8
| Ticks (t)
|-
! $8E
| [[Sound#Sound Channel 4 Noise Control|Sound Channel 4 Noise Control]]
| style="text-align: right" | <tt style="white-space: nowrap">...e rttt</tt>
| RW8
| Enable (e), Reset (r), Tap (t)
|-
! $8F
| [[Sound#Sound Wavetable Address|Sound Wavetable Address]]
| style="text-align: right" | <tt style="white-space: nowrap">wwww wwww</tt>
| RW8
| Address >> 6 (w)
|-
! $90
| [[Sound#Sound Channel Control|Sound Channel Control]]
| style="text-align: right" | <tt style="white-space: nowrap">nsv. 4321</tt>
| RW8
| Channel enable (1234)
Noise (n), Sweep (s), Voice (v)
|-
! $91
| [[Sound#Sound Output Control|Sound Output Control]]
| style="text-align: right" | <tt style="white-space: nowrap">H... hrrs</tt>
| RW8
| Headphones connected (H)
Headphone output (h)
Speaker output (s), range (r)
|-
! $92
| [[Sound#Sound Channel 4 LFSR Register|Sound Channel 4 LFSR Register]]
| style="text-align: right" | <tt style="white-space: nowrap">.rrr rrrr rrrr rrrr</tt>
| R16
| PRNG state (r)
|-
! $94
| [[Sound#Sound Channel 2 Voice Volume|Sound Channel 2 Voice Volume]]
| style="text-align: right" | <tt style="white-space: nowrap">.... lLrR</tt>
| RW8
| Left Half (l), Full (L)
Right Half (r), Full (R)
|-
! $96
| Sound Channel Output Right
| style="text-align: right" | <tt style="white-space: nowrap">.... ..ss ssss ssss</tt>
| R16
| Sample (s)
|-
! $98
| Sound Channel Output Left
| style="text-align: right" | <tt style="white-space: nowrap">.... ..ss ssss ssss</tt>
| R16
| Sample (s)
|-
! $9A
| Sound Channel Output Sum
| style="text-align: right" | <tt style="white-space: nowrap">.... .sss ssss ssss</tt>
| R16
| Sample (s)
|-
! $9E
| Sound Speaker Master Volume<sup>(color)</sup>
| style="text-align: right" | <tt style="white-space: nowrap">.... ..vv</tt>
| R8
| ?
|-
! System
! $A0
| System Control
| style="text-align: right" | <tt style="white-space: nowrap">t??? swcl</tt>
| RW8
| Test OK (t), ROM speed (s), ROM width (w),
Color system (c), Boot ROM lockout (l)
|-
! rowspan="5" | [[Timers]]
! $A2
| [[Timers#Timer Control|Timer Control]]
| style="text-align: right" | <tt style="white-space: nowrap">.... VvHh</tt>
| RW8
| Horizontal enable (h), auto reload (H)
Vertical enable (v), auto reload (V)
|-
! $A4
| [[Timers#Timer Reload|Horizontal Blank Timer Reload]]
| style="text-align: right" | <tt style="white-space: nowrap">tttt tttt tttt tttt</tt>
| RW16
| Ticks (t)
|-
! $A6
| [[Timers#Timer Reload|Vertical Blank Timer Reload]]
| style="text-align: right" | <tt style="white-space: nowrap">tttt tttt tttt tttt</tt>
| RW16
| Ticks (t)
|-
! $A8
| [[Timers#Timer Counter|Horizontal Blank Timer Counter]]
| style="text-align: right" | <tt style="white-space: nowrap">tttt tttt tttt tttt</tt>
| R16
| Ticks (t)
|-
! $AA
| [[Timers#Timer Counter|Vertical Blank Timer Counter]]
| style="text-align: right" | <tt style="white-space: nowrap">tttt tttt tttt tttt</tt>
| R16
| Ticks (t)
|-
! [[Interrupts]]
! $B0
| [[Interrupts#Interrupt Vector|Interrupt Vector]]
| style="text-align: right" | <tt style="white-space: nowrap">VVVV V...</tt>
| RW8
| Vector offset (v)
|-
! rowspan="2" | [[UART]]
! $B1
| [[UART#Serial Receive Data|Serial Receive Data]]
| style="text-align: right" | <tt style="white-space: nowrap">dddd dddd</tt>
| R8
| Receive buffer data (d)
|-
! $B1
| [[UART#Serial Transmit Data|Serial Transmit Data]]
| style="text-align: right" | <tt style="white-space: nowrap">dddd dddd</tt>
| W8
| Transmit buffer data (d)
|-
! [[Interrupts]]
! $B2
| [[Interrupts#Interrupt Enable|Interrupt Enable]]
| iiii iiii
| RW8
| Interrupt index (i)
|-
! rowspan="2" | [[UART]]
! $B3
| [[UART#Serial Status|Serial Status]]
| style="text-align: right" | <tt style="white-space: nowrap">eb.. .tor</tt>
| R8
| Enable (e), Baud rate (b),
Transfer ready (t), Overrun (o), Receive ready (r)
|-
! $B3
| [[UART#Serial Control|Serial Control]]
| style="text-align: right" | <tt style="white-space: nowrap">ebO. ....</tt>
| W8
| Enable (e), Baud rate (b), Reset Overrun (O)
|-
! [[Interrupts]]
! $B4
| [[Interrupts#Interrupt Status|Interrupt Status]]
| iiii iiii
| R8
| Interrupt index (i)
|-
! [[Keypad]]
! $B5
| [[Keypad|Keypad Scan]]
| style="text-align: right" | <tt style="white-space: nowrap">.iii oooo</tt>
| RW8
| Input row (i), Output column (o)
|-
! rowspan="2" | [[Interrupts]]
! $B6
| [[Interrupts#Interrupt Acknowledge|Interrupt Acknowledge]]
| iiii iiii
| R8?
| Interrupt index (i)
|-
! $B7
| [[Interrupts#Interrupt NMI Control|Interrupt NMI Control]]
| style="text-align: right" | <tt style="white-space: nowrap">...b ....</tt>
| RW8
| Low battery (b)
|-
! rowspan="4" | [[EEPROM|Internal EEPROM]]
! $BA
| [[EEPROM#Internal EEPROM Data|Internal EEPROM Data]]
| style="text-align: right" | <tt style="white-space: nowrap">dddd dddd dddd dddd</tt>
| RW16
| Data (d)
|-
! $BC
| [[EEPROM#Internal EEPROM Command|Internal EEPROM Command]]
|
| RW16
|
|-
! rowspan="2" | $BE
| [[EEPROM#Internal EEPROM Control|Internal EEPROM Control]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .... pewr ....</tt>
| W16
| Protect (p), Erase (e), Write (w), Read (r)
|-
| [[EEPROM#Internal EEPROM Status|Internal EEPROM Status]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .... p... ..RD</tt>
| R16
| Protected (p), Ready (R), Done (D)
|-
! [[Mapper|Cartridge]]
! $C0<br />
$FF
| Cartridge I/O
|
|
| Forwarded by the SoC
|}
7026be789c8610f73a79c4bac349bc445ec4acc6
152
151
2023-08-22T16:44:12Z
Asie
351
wikitext
text/x-wiki
* Superscripts are used to mark ports specific to a given mode or platform:
** Color mode: <sup>(color)</sup>.
** WS/WSC/SC console: <sup>(WS)</sup>, <sup>(WSC)</sup>, <sup>(SC)</sup>.
* If two Bits rows are provided, the second one refers to the "Color" mode.
* The Type can be: R - readable, W - writable, L - writable before boot ROM lockout, 8/16 - width (byte/word).
{| class="wikitable"
! Category
! Port
! Description
! Bits
! Type
! Notes
|-
! rowspan="45" | [[Display]]
! $00
| [[Display#Display Control|Display Control]]
| style="text-align: right" | <tt style="white-space: nowrap">..ow Ws21</tt>
| RW8
|
|-
! $01
| [[Display#Display Background|Display Background]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .sss</tt>
<tt style="white-space: nowrap">pppp iiii</tt>
| RW8
| Shade (s)
Palette (p), Index (i)
|-
! $02
| [[Display#Current Line|Display Current Line]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll</tt>
| R8
| Line (l)
|-
! $03
| [[Display#Interrupt Line|Display Interrupt Line]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll</tt>
| RW8
| Line (l)
|-
! $04
| [[Display#Sprite Table Address|Sprite Table Address]]
| style="text-align: right" | <tt style="white-space: nowrap">...a aaaa</tt>
<tt style="white-space: nowrap">..aa aaaa</tt>
| RW8
| Address >> 9 (a)
|-
! $05
| [[Display#Sprite Table First|Sprite Table First]]
| style="text-align: right" | <tt style="white-space: nowrap">.iii iiii</tt>
| RW8
| Index (i)
|-
! $06
| [[Display#Sprite Table Count|Sprite Table Count]]
| style="text-align: right" | <tt style="white-space: nowrap">cccc cccc</tt>
| RW8
| Count (c)
|-
! $07
| [[Display#Screen Address|Screen Address]]
| style="text-align: right" | <tt style="white-space: nowrap">.222 .111</tt>
<tt style="white-space: nowrap">2222 1111</tt>
| RW8
| Screen 1 address >> 11 (1)
Screen 2 address >> 11 (2)
|-
! $08
| [[Display#Screen 2 Window|Screen 2 Window Left]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $09
| [[Display#Screen 2 Window|Screen 2 Window Top]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $0A
| [[Display#Screen 2 Window|Screen 2 Window Right]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $0B
| [[Display#Screen 2 Window|Screen 2 Window Bottom]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $0B
| [[Display#Sprite Window|Sprite Window Left]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $0C
| [[Display#Sprite Window|Sprite Window Top]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $0E
| [[Display#Sprite Window|Sprite Window Right]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $0F
| [[Display#Sprite Window|Sprite Window Bottom]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $10
| [[Display#Screen Scroll|Screen 1 Scroll X]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $11
| [[Display#Screen Scroll|Screen 1 Scroll Y]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $12
| [[Display#Screen Scroll|Screen 2 Scroll X]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $13
| [[Display#Screen Scroll|Screen 2 Scroll Y]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $14
| [[Display#LCD Control|LCD Control]]
| style="text-align: right" | <tt style="white-space: nowrap">.... ..Ce</tt>
| RW8
| Contrast (C)<sup>(WSC)</sup>, Enable (e)
|-
! $15
| [[Display#LCD Icon Control|LCD Icon Control]]
| style="text-align: right" | <tt style="white-space: nowrap">..32 1hvs</tt>
| RW8
| Auxillary 3 (3), Auxillary 2 (2), Auxillary 1 (1),
Horizontal (h), Vertical (v), Sleep (s)
|-
! $16
| [[Display#LCD Final Line|LCD Final Line]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll</tt>
| RW8
| Line (l)
|-
! $17
| [[Display#LCD Back Porch Line|LCD Back Porch Line]]<sup>(WSC)</sup>
| style="text-align: right" | <tt style="white-space: nowrap">llll llll</tt>
| RW8
| Line (l)
|-
! $1A
| [[Display#LCD Status|LCD Status]]
| style="text-align: right" | <tt style="white-space: nowrap">...v vv.s</tt>
| RW8
| Volume segment status (v), Sleep (s)
|-
! $1C
| [[Display#LCD Mono Shade LUT|LCD Mono Shade LUT 0/1]]
| style="text-align: right" | <tt style="white-space: nowrap">1111 0000</tt>
| RW8
| Shade index
|-
! $1D
| [[Display#LCD Mono Shade LUT|LCD Mono Shade LUT 2/3]]
| style="text-align: right" | <tt style="white-space: nowrap">3333 2222</tt>
| RW8
| Shade index
|-
! $1E
| [[Display#LCD Mono Shade LUT|LCD Mono Shade LUT 4/5]]
| style="text-align: right" | <tt style="white-space: nowrap">5555 4444</tt>
| RW8
| Shade index
|-
! $1F
| [[Display#LCD Mono Shade LUT|LCD Mono Shade LUT 6/7]]
| style="text-align: right" | <tt style="white-space: nowrap">7777 6666</tt>
| RW8
| Shade index
|-
! $20
| [[Display#LCD Mono Palette|LCD Mono Palette 0]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $22
| [[Display#LCD Mono Palette|LCD Mono Palette 1]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $24
| [[Display#LCD Mono Palette|LCD Mono Palette 2]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $26
| [[Display#LCD Mono Palette|LCD Mono Palette 3]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $28
| [[Display#LCD Mono Palette|LCD Mono Palette 4]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $2A
| [[Display#LCD Mono Palette|LCD Mono Palette 5]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $2C
| [[Display#LCD Mono Palette|LCD Mono Palette 6]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $2E
| [[Display#LCD Mono Palette|LCD Mono Palette 7]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $30
| [[Display#LCD Mono Palette|LCD Mono Palette 8]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $32
| [[Display#LCD Mono Palette|LCD Mono Palette 9]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $34
| [[Display#LCD Mono Palette|LCD Mono Palette 10]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $36
| [[Display#LCD Mono Palette|LCD Mono Palette 11]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $38
| [[Display#LCD Mono Palette|LCD Mono Palette 12]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $3A
| [[Display#LCD Mono Palette|LCD Mono Palette 13]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $3C
| [[Display#LCD Mono Palette|LCD Mono Palette 14]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $3E
| [[Display#LCD Mono Palette|LCD Mono Palette 15]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! rowspan="10" | [[DMA]]<sup>(color)</sup>
! $40
| [[DMA#General DMA|GDMA Source Address Low]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll llll llll</tt>
| RW16
| Linear address, low 16 bits (l)
|-
! $42
| [[DMA#General DMA|GDMA Source Address High]]
| style="text-align: right" | <tt style="white-space: nowrap">.... hhhh</tt>
| RW8
| Linear address, high 4 bits (h)
|-
! $44
| [[DMA#General DMA|GDMA Destination Address]]
| style="text-align: right" | <tt style="white-space: nowrap">aaaa aaaa aaaa aaaa</tt>
| RW16
| IRAM address (a)
|-
! $46
| [[DMA#General DMA|GDMA Length]]
| style="text-align: right" | <tt style="white-space: nowrap">bbbb bbbb bbbb bbbb</tt>
| RW16
| Bytes (b)
|-
! $48
| [[DMA#General DMA|GDMA Control]]
| style="text-align: right" | <tt style="white-space: nowrap">ed.. ....</tt>
| RW8
| Enable (e), Decrement (d)
|-
! $4A
| [[DMA#Sound DMA|SDMA Source Address Low]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll llll llll</tt>
| RW16
| Linear address, low 16 bits (l)
|-
! $4C
| [[DMA#Sound DMA|SDMA Source Address High]]
| style="text-align: right" | <tt style="white-space: nowrap">.... hhhh</tt>
| RW8
| Linear address, high 4 bits (h)
|-
! $4E
| [[DMA#Sound DMA|SDMA Length Low]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll llll llll</tt>
| RW16
| Length, low 16 bits (l)
|-
! $50
| [[DMA#Sound DMA|SDMA Length High]]
| style="text-align: right" | <tt style="white-space: nowrap">.... hhhh</tt>
| RW8
| Length, high 4 bits (h)
|-
! $52
| [[DMA#Sound DMA|SDMA Control]]
| style="text-align: right" | <tt style="white-space: nowrap">ed.t r?ff</tt>
| RW8
| Enable (e), Decrement (d), Target (t),
Repeat (r), Frequency (f)
|-
! rowspan="2" | System<sup>(color)</sup>
! $60
| System Control 2
| style="text-align: right" | <tt style="white-space: nowrap">c4C. ?.??</tt>
| RW8
| Color (c), 4BPP (4), Chunky (C)
|-
! $62
| System Control 3
| style="text-align: right" | <tt style="white-space: nowrap">S... ...p</tt>
| RW8
| SwanCrystal (S), Power off (p)
|-
! rowspan="5" | [[Hyper Voice]]<sup>(color)</sup>
! $64
| Hyper Voice Left Output
| style="text-align: right" | <tt style="white-space: nowrap">ssss ssss ssss ssss</tt>
| W16
| Raw sample (s)
|-
! $66
| Hyper Voice Right Output
| style="text-align: right" | <tt style="white-space: nowrap">ssss ssss ssss ssss</tt>
| W16
| Raw sample (s)
|-
! $68
| Hyper Voice Left Input
| style="text-align: right" | <tt style="white-space: nowrap">ssss ssss</tt>
| 8
| Sample (s)
|-
! $69
| Hyper Voice Right Input
| style="text-align: right" | <tt style="white-space: nowrap">ssss ssss</tt>
| 8
| Sample (s)
|-
! $6A
| Hyper Voice Control
| style="text-align: right" | <tt style="white-space: nowrap">.mmc .... errr ffss</tt>
| RW16
| Mask (m), Channel (c), Enable (e),
Rate (r), Format (f), Shift (s)
|-
! rowspan="8" | [[Display]]<sup>(SC)</sup>
! $70
| LCD Timing Configuration 1?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $71
| LCD Timing Configuration 2?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $72
| LCD Timing Configuration 3?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $73
| LCD Timing Configuration 4?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $74
| LCD Timing Configuration 5?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $75
| LCD Timing Configuration 6?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $76
| LCD Timing Configuration 7?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $77
| LCD Timing Configuration 8?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! rowspan="21" | [[Sound]]
! $80
| [[Sound#Sound Channel Frequency|Sound Channel 1 Frequency]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .ddd dddd dddd</tt>
| RW16
| Divider (d)
|-
! $82
| [[Sound#Sound Channel Frequency|Sound Channel 2 Frequency]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .ddd dddd dddd</tt>
| RW16
| Divider (d)
|-
! $84
| [[Sound#Sound Channel Frequency|Sound Channel 3 Frequency]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .ddd dddd dddd</tt>
| RW16
| Divider (d)
|-
! $86
| [[Sound#Sound Channel Frequency|Sound Channel 4 Frequency]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .ddd dddd dddd</tt>
| RW16
| Divider (d)
|-
! $88
| [[Sound#Sound Channel Volume|Sound Channel 1 Volume]]
| style="text-align: right" | <tt style="white-space: nowrap">llll rrrr</tt>
| RW8
| Left (l), Right (r)
|-
! rowspan="2" | $89
| [[Sound#Sound Channel Volume|Sound Channel 2 Volume]]
| style="text-align: right" | <tt style="white-space: nowrap">llll rrrr</tt>
| RW8
| Left (l), Right (r)
|-
| [[Sound#Sound Channel 2 Voice Sample|Sound Channel 2 Voice Sample]]
| style="text-align: right" | <tt style="white-space: nowrap">ssss ssss</tt>
| RW8
| Sample (s)
|-
! $8A
| [[Sound#Sound Channel Volume|Sound Channel 3 Volume]]
| style="text-align: right" | <tt style="white-space: nowrap">llll rrrr</tt>
| RW8
| Left (l), Right (r)
|-
! $8B
| [[Sound#Sound Channel Volume|Sound Channel 4 Volume]]
| style="text-align: right" | <tt style="white-space: nowrap">llll rrrr</tt>
| RW8
| Left (l), Right (r)
|-
! $8C
| [[Sound#Sound Channel 3 Sweep Amount|Sound Channel 3 Sweep Amount]]
| style="text-align: right" | <tt style="white-space: nowrap">vvvv vvvv</tt>
| RW8
| Value (v)
|-
! $8D
| [[Sound#Sound Channel 3 Sweep Ticks|Sound Channel 3 Sweep Ticks]]
| style="text-align: right" | <tt style="white-space: nowrap">...t tttt</tt>
| RW8
| Ticks (t)
|-
! $8E
| [[Sound#Sound Channel 4 Noise Control|Sound Channel 4 Noise Control]]
| style="text-align: right" | <tt style="white-space: nowrap">...e rttt</tt>
| RW8
| Enable (e), Reset (r), Tap (t)
|-
! $8F
| [[Sound#Sound Wavetable Address|Sound Wavetable Address]]
| style="text-align: right" | <tt style="white-space: nowrap">wwww wwww</tt>
| RW8
| Address >> 6 (w)
|-
! $90
| [[Sound#Sound Channel Control|Sound Channel Control]]
| style="text-align: right" | <tt style="white-space: nowrap">nsv. 4321</tt>
| RW8
| Channel enable (1234)
Noise (n), Sweep (s), Voice (v)
|-
! $91
| [[Sound#Sound Output Control|Sound Output Control]]
| style="text-align: right" | <tt style="white-space: nowrap">H... hrrs</tt>
| RW8
| Headphones connected (H)
Headphone output (h)
Speaker output (s), range (r)
|-
! $92
| [[Sound#Sound Channel 4 LFSR Register|Sound Channel 4 LFSR Register]]
| style="text-align: right" | <tt style="white-space: nowrap">.rrr rrrr rrrr rrrr</tt>
| R16
| PRNG state (r)
|-
! $94
| [[Sound#Sound Channel 2 Voice Volume|Sound Channel 2 Voice Volume]]
| style="text-align: right" | <tt style="white-space: nowrap">.... lLrR</tt>
| RW8
| Left Half (l), Full (L)
Right Half (r), Full (R)
|-
! $96
| Sound Channel Output Right
| style="text-align: right" | <tt style="white-space: nowrap">.... ..ss ssss ssss</tt>
| R16
| Sample (s)
|-
! $98
| Sound Channel Output Left
| style="text-align: right" | <tt style="white-space: nowrap">.... ..ss ssss ssss</tt>
| R16
| Sample (s)
|-
! $9A
| Sound Channel Output Sum
| style="text-align: right" | <tt style="white-space: nowrap">.... .sss ssss ssss</tt>
| R16
| Sample (s)
|-
! $9E
| Sound Speaker Master Volume<sup>(color)</sup>
| style="text-align: right" | <tt style="white-space: nowrap">.... ..vv</tt>
| R8
| ?
|-
! System
! $A0
| System Control
| style="text-align: right" | <tt style="white-space: nowrap">t??? swcl</tt>
| RW8
| Test OK (t), ROM speed (s), ROM width (w),
Color system (c), Boot ROM lockout (l)
|-
! rowspan="5" | [[Timers]]
! $A2
| [[Timers#Timer Control|Timer Control]]
| style="text-align: right" | <tt style="white-space: nowrap">.... VvHh</tt>
| RW8
| Horizontal enable (h), auto reload (H)
Vertical enable (v), auto reload (V)
|-
! $A4
| [[Timers#Timer Reload|Horizontal Blank Timer Reload]]
| style="text-align: right" | <tt style="white-space: nowrap">tttt tttt tttt tttt</tt>
| RW16
| Ticks (t)
|-
! $A6
| [[Timers#Timer Reload|Vertical Blank Timer Reload]]
| style="text-align: right" | <tt style="white-space: nowrap">tttt tttt tttt tttt</tt>
| RW16
| Ticks (t)
|-
! $A8
| [[Timers#Timer Counter|Horizontal Blank Timer Counter]]
| style="text-align: right" | <tt style="white-space: nowrap">tttt tttt tttt tttt</tt>
| R16
| Ticks (t)
|-
! $AA
| [[Timers#Timer Counter|Vertical Blank Timer Counter]]
| style="text-align: right" | <tt style="white-space: nowrap">tttt tttt tttt tttt</tt>
| R16
| Ticks (t)
|-
! [[Interrupts]]
! $B0
| [[Interrupts#Interrupt Vector|Interrupt Vector]]
| style="text-align: right" | <tt style="white-space: nowrap">VVVV V...</tt>
| RW8
| Vector offset (v)
|-
! rowspan="2" | [[UART]]
! $B1
| [[UART#Serial Receive Data|Serial Receive Data]]
| style="text-align: right" | <tt style="white-space: nowrap">dddd dddd</tt>
| R8
| Receive buffer data (d)
|-
! $B1
| [[UART#Serial Transmit Data|Serial Transmit Data]]
| style="text-align: right" | <tt style="white-space: nowrap">dddd dddd</tt>
| W8
| Transmit buffer data (d)
|-
! [[Interrupts]]
! $B2
| [[Interrupts#Interrupt Enable|Interrupt Enable]]
| iiii iiii
| RW8
| Interrupt index (i)
|-
! rowspan="2" | [[UART]]
! $B3
| [[UART#Serial Status|Serial Status]]
| style="text-align: right" | <tt style="white-space: nowrap">eb.. .tor</tt>
| R8
| Enable (e), Baud rate (b),
Transfer ready (t), Overrun (o), Receive ready (r)
|-
! $B3
| [[UART#Serial Control|Serial Control]]
| style="text-align: right" | <tt style="white-space: nowrap">ebO. ....</tt>
| W8
| Enable (e), Baud rate (b), Reset Overrun (O)
|-
! [[Interrupts]]
! $B4
| [[Interrupts#Interrupt Status|Interrupt Status]]
| iiii iiii
| R8
| Interrupt index (i)
|-
! [[Keypad]]
! $B5
| [[Keypad|Keypad Scan]]
| style="text-align: right" | <tt style="white-space: nowrap">.iii oooo</tt>
| RW8
| Input row (i), Output column (o)
|-
! rowspan="2" | [[Interrupts]]
! $B6
| [[Interrupts#Interrupt Acknowledge|Interrupt Acknowledge]]
| iiii iiii
| R8?
| Interrupt index (i)
|-
! $B7
| [[Interrupts#Interrupt NMI Control|Interrupt NMI Control]]
| style="text-align: right" | <tt style="white-space: nowrap">...b ....</tt>
| RW8
| Low battery (b)
|-
! rowspan="4" | [[EEPROM|Internal EEPROM]]
! $BA
| [[EEPROM#Internal EEPROM Data|Internal EEPROM Data]]
| style="text-align: right" | <tt style="white-space: nowrap">dddd dddd dddd dddd</tt>
| RW16
| Data (d)
|-
! $BC
| [[EEPROM#Internal EEPROM Command|Internal EEPROM Command]]
|
| RW16
|
|-
! rowspan="2" | $BE
| [[EEPROM#Internal EEPROM Status|Internal EEPROM Status]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .... p... ..RD</tt>
| R16
| Protected (p), Ready (R), Done (D)
|-
| [[EEPROM#Internal EEPROM Control|Internal EEPROM Control]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .... pewr ....</tt>
| W16
| Protect (p), Erase (e), Write (w), Read (r)
|-
! [[Mapper|Cartridge]]
! $C0<br />
$FF
| Cartridge I/O
|
|
| Forwarded by the SoC
|}
c25e07d0cb8cf63bc3ca3678ea8bffdeaf1ca2fb
194
152
2023-08-25T16:50:08Z
Asie
351
add System/SoC links
wikitext
text/x-wiki
* Superscripts are used to mark ports specific to a given mode or platform:
** Color mode: <sup>(color)</sup>.
** WS/WSC/SC console: <sup>(WS)</sup>, <sup>(WSC)</sup>, <sup>(SC)</sup>.
* If two Bits rows are provided, the second one refers to the "Color" mode.
* The Type can be: R - readable, W - writable, L - writable before boot ROM lockout, 8/16 - width (byte/word).
{| class="wikitable"
! Category
! Port
! Description
! Bits
! Type
! Notes
|-
! rowspan="45" | [[Display]]
! $00
| [[Display#Display Control|Display Control]]
| style="text-align: right" | <tt style="white-space: nowrap">..ow Ws21</tt>
| RW8
|
|-
! $01
| [[Display#Display Background|Display Background]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .sss</tt>
<tt style="white-space: nowrap">pppp iiii</tt>
| RW8
| Shade (s)
Palette (p), Index (i)
|-
! $02
| [[Display#Current Line|Display Current Line]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll</tt>
| R8
| Line (l)
|-
! $03
| [[Display#Interrupt Line|Display Interrupt Line]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll</tt>
| RW8
| Line (l)
|-
! $04
| [[Display#Sprite Table Address|Sprite Table Address]]
| style="text-align: right" | <tt style="white-space: nowrap">...a aaaa</tt>
<tt style="white-space: nowrap">..aa aaaa</tt>
| RW8
| Address >> 9 (a)
|-
! $05
| [[Display#Sprite Table First|Sprite Table First]]
| style="text-align: right" | <tt style="white-space: nowrap">.iii iiii</tt>
| RW8
| Index (i)
|-
! $06
| [[Display#Sprite Table Count|Sprite Table Count]]
| style="text-align: right" | <tt style="white-space: nowrap">cccc cccc</tt>
| RW8
| Count (c)
|-
! $07
| [[Display#Screen Address|Screen Address]]
| style="text-align: right" | <tt style="white-space: nowrap">.222 .111</tt>
<tt style="white-space: nowrap">2222 1111</tt>
| RW8
| Screen 1 address >> 11 (1)
Screen 2 address >> 11 (2)
|-
! $08
| [[Display#Screen 2 Window|Screen 2 Window Left]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $09
| [[Display#Screen 2 Window|Screen 2 Window Top]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $0A
| [[Display#Screen 2 Window|Screen 2 Window Right]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $0B
| [[Display#Screen 2 Window|Screen 2 Window Bottom]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $0B
| [[Display#Sprite Window|Sprite Window Left]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $0C
| [[Display#Sprite Window|Sprite Window Top]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $0E
| [[Display#Sprite Window|Sprite Window Right]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $0F
| [[Display#Sprite Window|Sprite Window Bottom]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $10
| [[Display#Screen Scroll|Screen 1 Scroll X]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $11
| [[Display#Screen Scroll|Screen 1 Scroll Y]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $12
| [[Display#Screen Scroll|Screen 2 Scroll X]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $13
| [[Display#Screen Scroll|Screen 2 Scroll Y]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $14
| [[Display#LCD Control|LCD Control]]
| style="text-align: right" | <tt style="white-space: nowrap">.... ..Ce</tt>
| RW8
| Contrast (C)<sup>(WSC)</sup>, Enable (e)
|-
! $15
| [[Display#LCD Icon Control|LCD Icon Control]]
| style="text-align: right" | <tt style="white-space: nowrap">..32 1hvs</tt>
| RW8
| Auxillary 3 (3), Auxillary 2 (2), Auxillary 1 (1),
Horizontal (h), Vertical (v), Sleep (s)
|-
! $16
| [[Display#LCD Final Line|LCD Final Line]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll</tt>
| RW8
| Line (l)
|-
! $17
| [[Display#LCD Back Porch Line|LCD Back Porch Line]]<sup>(WSC)</sup>
| style="text-align: right" | <tt style="white-space: nowrap">llll llll</tt>
| RW8
| Line (l)
|-
! $1A
| [[Display#LCD Status|LCD Status]]
| style="text-align: right" | <tt style="white-space: nowrap">...v vv.s</tt>
| RW8
| Volume segment status (v), Sleep (s)
|-
! $1C
| [[Display#LCD Mono Shade LUT|LCD Mono Shade LUT 0/1]]
| style="text-align: right" | <tt style="white-space: nowrap">1111 0000</tt>
| RW8
| Shade index
|-
! $1D
| [[Display#LCD Mono Shade LUT|LCD Mono Shade LUT 2/3]]
| style="text-align: right" | <tt style="white-space: nowrap">3333 2222</tt>
| RW8
| Shade index
|-
! $1E
| [[Display#LCD Mono Shade LUT|LCD Mono Shade LUT 4/5]]
| style="text-align: right" | <tt style="white-space: nowrap">5555 4444</tt>
| RW8
| Shade index
|-
! $1F
| [[Display#LCD Mono Shade LUT|LCD Mono Shade LUT 6/7]]
| style="text-align: right" | <tt style="white-space: nowrap">7777 6666</tt>
| RW8
| Shade index
|-
! $20
| [[Display#LCD Mono Palette|LCD Mono Palette 0]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $22
| [[Display#LCD Mono Palette|LCD Mono Palette 1]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $24
| [[Display#LCD Mono Palette|LCD Mono Palette 2]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $26
| [[Display#LCD Mono Palette|LCD Mono Palette 3]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $28
| [[Display#LCD Mono Palette|LCD Mono Palette 4]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $2A
| [[Display#LCD Mono Palette|LCD Mono Palette 5]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $2C
| [[Display#LCD Mono Palette|LCD Mono Palette 6]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $2E
| [[Display#LCD Mono Palette|LCD Mono Palette 7]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $30
| [[Display#LCD Mono Palette|LCD Mono Palette 8]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $32
| [[Display#LCD Mono Palette|LCD Mono Palette 9]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $34
| [[Display#LCD Mono Palette|LCD Mono Palette 10]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $36
| [[Display#LCD Mono Palette|LCD Mono Palette 11]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $38
| [[Display#LCD Mono Palette|LCD Mono Palette 12]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $3A
| [[Display#LCD Mono Palette|LCD Mono Palette 13]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $3C
| [[Display#LCD Mono Palette|LCD Mono Palette 14]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $3E
| [[Display#LCD Mono Palette|LCD Mono Palette 15]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! rowspan="10" | [[DMA]]<sup>(color)</sup>
! $40
| [[DMA#General DMA|GDMA Source Address Low]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll llll llll</tt>
| RW16
| Linear address, low 16 bits (l)
|-
! $42
| [[DMA#General DMA|GDMA Source Address High]]
| style="text-align: right" | <tt style="white-space: nowrap">.... hhhh</tt>
| RW8
| Linear address, high 4 bits (h)
|-
! $44
| [[DMA#General DMA|GDMA Destination Address]]
| style="text-align: right" | <tt style="white-space: nowrap">aaaa aaaa aaaa aaaa</tt>
| RW16
| IRAM address (a)
|-
! $46
| [[DMA#General DMA|GDMA Length]]
| style="text-align: right" | <tt style="white-space: nowrap">bbbb bbbb bbbb bbbb</tt>
| RW16
| Bytes (b)
|-
! $48
| [[DMA#General DMA|GDMA Control]]
| style="text-align: right" | <tt style="white-space: nowrap">ed.. ....</tt>
| RW8
| Enable (e), Decrement (d)
|-
! $4A
| [[DMA#Sound DMA|SDMA Source Address Low]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll llll llll</tt>
| RW16
| Linear address, low 16 bits (l)
|-
! $4C
| [[DMA#Sound DMA|SDMA Source Address High]]
| style="text-align: right" | <tt style="white-space: nowrap">.... hhhh</tt>
| RW8
| Linear address, high 4 bits (h)
|-
! $4E
| [[DMA#Sound DMA|SDMA Length Low]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll llll llll</tt>
| RW16
| Length, low 16 bits (l)
|-
! $50
| [[DMA#Sound DMA|SDMA Length High]]
| style="text-align: right" | <tt style="white-space: nowrap">.... hhhh</tt>
| RW8
| Length, high 4 bits (h)
|-
! $52
| [[DMA#Sound DMA|SDMA Control]]
| style="text-align: right" | <tt style="white-space: nowrap">ed.t r?ff</tt>
| RW8
| Enable (e), Decrement (d), Target (t),
Repeat (r), Frequency (f)
|-
! rowspan="2" | [[SoC]]<sup>(color)</sup>
! $60
| [[SoC#System Control 2|System Control 2]]
| style="text-align: right" | <tt style="white-space: nowrap">c4C. ?.??</tt>
| RW8
| Color (c), 4BPP (4), Chunky (C)
|-
! $62
| [[SoC#System Control 3|System Control 3]]
| style="text-align: right" | <tt style="white-space: nowrap">S... ...p</tt>
| RW8
| SwanCrystal (S), Power off (p)
|-
! rowspan="5" | [[Hyper Voice]]<sup>(color)</sup>
! $64
| Hyper Voice Left Output
| style="text-align: right" | <tt style="white-space: nowrap">ssss ssss ssss ssss</tt>
| W16
| Raw sample (s)
|-
! $66
| Hyper Voice Right Output
| style="text-align: right" | <tt style="white-space: nowrap">ssss ssss ssss ssss</tt>
| W16
| Raw sample (s)
|-
! $68
| Hyper Voice Left Input
| style="text-align: right" | <tt style="white-space: nowrap">ssss ssss</tt>
| 8
| Sample (s)
|-
! $69
| Hyper Voice Right Input
| style="text-align: right" | <tt style="white-space: nowrap">ssss ssss</tt>
| 8
| Sample (s)
|-
! $6A
| Hyper Voice Control
| style="text-align: right" | <tt style="white-space: nowrap">.mmc .... errr ffss</tt>
| RW16
| Mask (m), Channel (c), Enable (e),
Rate (r), Format (f), Shift (s)
|-
! rowspan="8" | [[Display]]<sup>(SC)</sup>
! $70
| LCD Timing Configuration 1?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $71
| LCD Timing Configuration 2?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $72
| LCD Timing Configuration 3?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $73
| LCD Timing Configuration 4?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $74
| LCD Timing Configuration 5?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $75
| LCD Timing Configuration 6?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $76
| LCD Timing Configuration 7?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $77
| LCD Timing Configuration 8?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! rowspan="21" | [[Sound]]
! $80
| [[Sound#Sound Channel Frequency|Sound Channel 1 Frequency]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .ddd dddd dddd</tt>
| RW16
| Divider (d)
|-
! $82
| [[Sound#Sound Channel Frequency|Sound Channel 2 Frequency]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .ddd dddd dddd</tt>
| RW16
| Divider (d)
|-
! $84
| [[Sound#Sound Channel Frequency|Sound Channel 3 Frequency]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .ddd dddd dddd</tt>
| RW16
| Divider (d)
|-
! $86
| [[Sound#Sound Channel Frequency|Sound Channel 4 Frequency]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .ddd dddd dddd</tt>
| RW16
| Divider (d)
|-
! $88
| [[Sound#Sound Channel Volume|Sound Channel 1 Volume]]
| style="text-align: right" | <tt style="white-space: nowrap">llll rrrr</tt>
| RW8
| Left (l), Right (r)
|-
! rowspan="2" | $89
| [[Sound#Sound Channel Volume|Sound Channel 2 Volume]]
| style="text-align: right" | <tt style="white-space: nowrap">llll rrrr</tt>
| RW8
| Left (l), Right (r)
|-
| [[Sound#Sound Channel 2 Voice Sample|Sound Channel 2 Voice Sample]]
| style="text-align: right" | <tt style="white-space: nowrap">ssss ssss</tt>
| RW8
| Sample (s)
|-
! $8A
| [[Sound#Sound Channel Volume|Sound Channel 3 Volume]]
| style="text-align: right" | <tt style="white-space: nowrap">llll rrrr</tt>
| RW8
| Left (l), Right (r)
|-
! $8B
| [[Sound#Sound Channel Volume|Sound Channel 4 Volume]]
| style="text-align: right" | <tt style="white-space: nowrap">llll rrrr</tt>
| RW8
| Left (l), Right (r)
|-
! $8C
| [[Sound#Sound Channel 3 Sweep Amount|Sound Channel 3 Sweep Amount]]
| style="text-align: right" | <tt style="white-space: nowrap">vvvv vvvv</tt>
| RW8
| Value (v)
|-
! $8D
| [[Sound#Sound Channel 3 Sweep Ticks|Sound Channel 3 Sweep Ticks]]
| style="text-align: right" | <tt style="white-space: nowrap">...t tttt</tt>
| RW8
| Ticks (t)
|-
! $8E
| [[Sound#Sound Channel 4 Noise Control|Sound Channel 4 Noise Control]]
| style="text-align: right" | <tt style="white-space: nowrap">...e rttt</tt>
| RW8
| Enable (e), Reset (r), Tap (t)
|-
! $8F
| [[Sound#Sound Wavetable Address|Sound Wavetable Address]]
| style="text-align: right" | <tt style="white-space: nowrap">wwww wwww</tt>
| RW8
| Address >> 6 (w)
|-
! $90
| [[Sound#Sound Channel Control|Sound Channel Control]]
| style="text-align: right" | <tt style="white-space: nowrap">nsv. 4321</tt>
| RW8
| Channel enable (1234)
Noise (n), Sweep (s), Voice (v)
|-
! $91
| [[Sound#Sound Output Control|Sound Output Control]]
| style="text-align: right" | <tt style="white-space: nowrap">H... hrrs</tt>
| RW8
| Headphones connected (H)
Headphone output (h)
Speaker output (s), range (r)
|-
! $92
| [[Sound#Sound Channel 4 LFSR Register|Sound Channel 4 LFSR Register]]
| style="text-align: right" | <tt style="white-space: nowrap">.rrr rrrr rrrr rrrr</tt>
| R16
| PRNG state (r)
|-
! $94
| [[Sound#Sound Channel 2 Voice Volume|Sound Channel 2 Voice Volume]]
| style="text-align: right" | <tt style="white-space: nowrap">.... lLrR</tt>
| RW8
| Left Half (l), Full (L)
Right Half (r), Full (R)
|-
! $96
| Sound Channel Output Right
| style="text-align: right" | <tt style="white-space: nowrap">.... ..ss ssss ssss</tt>
| R16
| Sample (s)
|-
! $98
| Sound Channel Output Left
| style="text-align: right" | <tt style="white-space: nowrap">.... ..ss ssss ssss</tt>
| R16
| Sample (s)
|-
! $9A
| Sound Channel Output Sum
| style="text-align: right" | <tt style="white-space: nowrap">.... .sss ssss ssss</tt>
| R16
| Sample (s)
|-
! $9E
| Sound Speaker Master Volume<sup>(color)</sup>
| style="text-align: right" | <tt style="white-space: nowrap">.... ..vv</tt>
| R8
| ?
|-
! [[SoC]]
! $A0
| [[SoC#System Control|System Control]]
| style="text-align: right" | <tt style="white-space: nowrap">t??? swcl</tt>
| RW8
| Test OK (t), ROM speed (s), ROM width (w),
Color system (c), Boot ROM lockout (l)
|-
! rowspan="5" | [[Timers]]
! $A2
| [[Timers#Timer Control|Timer Control]]
| style="text-align: right" | <tt style="white-space: nowrap">.... VvHh</tt>
| RW8
| Horizontal enable (h), auto reload (H)
Vertical enable (v), auto reload (V)
|-
! $A4
| [[Timers#Timer Reload|Horizontal Blank Timer Reload]]
| style="text-align: right" | <tt style="white-space: nowrap">tttt tttt tttt tttt</tt>
| RW16
| Ticks (t)
|-
! $A6
| [[Timers#Timer Reload|Vertical Blank Timer Reload]]
| style="text-align: right" | <tt style="white-space: nowrap">tttt tttt tttt tttt</tt>
| RW16
| Ticks (t)
|-
! $A8
| [[Timers#Timer Counter|Horizontal Blank Timer Counter]]
| style="text-align: right" | <tt style="white-space: nowrap">tttt tttt tttt tttt</tt>
| R16
| Ticks (t)
|-
! $AA
| [[Timers#Timer Counter|Vertical Blank Timer Counter]]
| style="text-align: right" | <tt style="white-space: nowrap">tttt tttt tttt tttt</tt>
| R16
| Ticks (t)
|-
! [[Interrupts]]
! $B0
| [[Interrupts#Interrupt Vector|Interrupt Vector]]
| style="text-align: right" | <tt style="white-space: nowrap">VVVV V...</tt>
| RW8
| Vector offset (v)
|-
! rowspan="2" | [[UART]]
! $B1
| [[UART#Serial Receive Data|Serial Receive Data]]
| style="text-align: right" | <tt style="white-space: nowrap">dddd dddd</tt>
| R8
| Receive buffer data (d)
|-
! $B1
| [[UART#Serial Transmit Data|Serial Transmit Data]]
| style="text-align: right" | <tt style="white-space: nowrap">dddd dddd</tt>
| W8
| Transmit buffer data (d)
|-
! [[Interrupts]]
! $B2
| [[Interrupts#Interrupt Enable|Interrupt Enable]]
| iiii iiii
| RW8
| Interrupt index (i)
|-
! rowspan="2" | [[UART]]
! $B3
| [[UART#Serial Status|Serial Status]]
| style="text-align: right" | <tt style="white-space: nowrap">eb.. .tor</tt>
| R8
| Enable (e), Baud rate (b),
Transfer ready (t), Overrun (o), Receive ready (r)
|-
! $B3
| [[UART#Serial Control|Serial Control]]
| style="text-align: right" | <tt style="white-space: nowrap">ebO. ....</tt>
| W8
| Enable (e), Baud rate (b), Reset Overrun (O)
|-
! [[Interrupts]]
! $B4
| [[Interrupts#Interrupt Status|Interrupt Status]]
| iiii iiii
| R8
| Interrupt index (i)
|-
! [[Keypad]]
! $B5
| [[Keypad|Keypad Scan]]
| style="text-align: right" | <tt style="white-space: nowrap">.iii oooo</tt>
| RW8
| Input row (i), Output column (o)
|-
! rowspan="2" | [[Interrupts]]
! $B6
| [[Interrupts#Interrupt Acknowledge|Interrupt Acknowledge]]
| iiii iiii
| R8?
| Interrupt index (i)
|-
! $B7
| [[Interrupts#Interrupt NMI Control|Interrupt NMI Control]]
| style="text-align: right" | <tt style="white-space: nowrap">...b ....</tt>
| RW8
| Low battery (b)
|-
! rowspan="4" | [[EEPROM|Internal EEPROM]]
! $BA
| [[EEPROM#Internal EEPROM Data|Internal EEPROM Data]]
| style="text-align: right" | <tt style="white-space: nowrap">dddd dddd dddd dddd</tt>
| RW16
| Data (d)
|-
! $BC
| [[EEPROM#Internal EEPROM Command|Internal EEPROM Command]]
|
| RW16
|
|-
! rowspan="2" | $BE
| [[EEPROM#Internal EEPROM Status|Internal EEPROM Status]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .... p... ..RD</tt>
| R16
| Protected (p), Ready (R), Done (D)
|-
| [[EEPROM#Internal EEPROM Control|Internal EEPROM Control]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .... pewr ....</tt>
| W16
| Protect (p), Erase (e), Write (w), Read (r)
|-
! [[Mapper|Cartridge]]
! $C0<br />
$FF
| Cartridge I/O
|
|
| Forwarded by the SoC
|}
fbc2c02d11c3c4a621f4e1d7a00e76e5b50cc997
198
194
2023-08-27T10:47:20Z
Asie
351
document routing etc
wikitext
text/x-wiki
The WonderSwan SoC has three general blocks of I/O port accesses:
{| class="wikitable"
! From !! To !! Holder !! Width
|-
| $00 || $B7 || WonderSwan SoC || 8/16-bit
|-
| $B8 || $BF || Internal EEPROM control || 16-bit
|-
| $C0 || $FF || Cartridge bus || 8-bit
|}
With the exception of internal EEPROM on the ASWAN, all unaligned 16-bit accesses can be converted to two 8-bit accesses with a 1-cycle penalty.
== I/O port map ==
* Superscripts are used to mark ports specific to a given mode or platform:
** Color mode: <sup>(color)</sup>.
** WS/WSC/SC console: <sup>(WS)</sup>, <sup>(WSC)</sup>, <sup>(SC)</sup>.
* If two Bits rows are provided, the second one refers to the "Color" mode.
* The Type can be: R - readable, W - writable, L - writable before boot ROM lockout, 8/16 - width (byte/word).
{| class="wikitable"
! Category
! Port
! Description
! Bits
! Type
! Notes
|-
! rowspan="45" | [[Display]]
! $00
| [[Display#Display Control|Display Control]]
| style="text-align: right" | <tt style="white-space: nowrap">..ow Ws21</tt>
| RW8
|
|-
! $01
| [[Display#Display Background|Display Background]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .sss</tt>
<tt style="white-space: nowrap">pppp iiii</tt>
| RW8
| Shade (s)
Palette (p), Index (i)
|-
! $02
| [[Display#Current Line|Display Current Line]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll</tt>
| R8
| Line (l)
|-
! $03
| [[Display#Interrupt Line|Display Interrupt Line]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll</tt>
| RW8
| Line (l)
|-
! $04
| [[Display#Sprite Table Address|Sprite Table Address]]
| style="text-align: right" | <tt style="white-space: nowrap">...a aaaa</tt>
<tt style="white-space: nowrap">..aa aaaa</tt>
| RW8
| Address >> 9 (a)
|-
! $05
| [[Display#Sprite Table First|Sprite Table First]]
| style="text-align: right" | <tt style="white-space: nowrap">.iii iiii</tt>
| RW8
| Index (i)
|-
! $06
| [[Display#Sprite Table Count|Sprite Table Count]]
| style="text-align: right" | <tt style="white-space: nowrap">cccc cccc</tt>
| RW8
| Count (c)
|-
! $07
| [[Display#Screen Address|Screen Address]]
| style="text-align: right" | <tt style="white-space: nowrap">.222 .111</tt>
<tt style="white-space: nowrap">2222 1111</tt>
| RW8
| Screen 1 address >> 11 (1)
Screen 2 address >> 11 (2)
|-
! $08
| [[Display#Screen 2 Window|Screen 2 Window Left]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $09
| [[Display#Screen 2 Window|Screen 2 Window Top]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $0A
| [[Display#Screen 2 Window|Screen 2 Window Right]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $0B
| [[Display#Screen 2 Window|Screen 2 Window Bottom]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $0B
| [[Display#Sprite Window|Sprite Window Left]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $0C
| [[Display#Sprite Window|Sprite Window Top]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $0E
| [[Display#Sprite Window|Sprite Window Right]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $0F
| [[Display#Sprite Window|Sprite Window Bottom]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $10
| [[Display#Screen Scroll|Screen 1 Scroll X]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $11
| [[Display#Screen Scroll|Screen 1 Scroll Y]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $12
| [[Display#Screen Scroll|Screen 2 Scroll X]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $13
| [[Display#Screen Scroll|Screen 2 Scroll Y]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $14
| [[Display#LCD Control|LCD Control]]
| style="text-align: right" | <tt style="white-space: nowrap">.... ..Ce</tt>
| RW8
| Contrast (C)<sup>(WSC)</sup>, Enable (e)
|-
! $15
| [[Display#LCD Icon Control|LCD Icon Control]]
| style="text-align: right" | <tt style="white-space: nowrap">..32 1hvs</tt>
| RW8
| Auxillary 3 (3), Auxillary 2 (2), Auxillary 1 (1),
Horizontal (h), Vertical (v), Sleep (s)
|-
! $16
| [[Display#LCD Final Line|LCD Final Line]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll</tt>
| RW8
| Line (l)
|-
! $17
| [[Display#LCD Back Porch Line|LCD Back Porch Line]]<sup>(WSC)</sup>
| style="text-align: right" | <tt style="white-space: nowrap">llll llll</tt>
| RW8
| Line (l)
|-
! $1A
| [[Display#LCD Status|LCD Status]]
| style="text-align: right" | <tt style="white-space: nowrap">...v vv.s</tt>
| RW8
| Volume segment status (v), Sleep (s)
|-
! $1C
| [[Display#LCD Mono Shade LUT|LCD Mono Shade LUT 0/1]]
| style="text-align: right" | <tt style="white-space: nowrap">1111 0000</tt>
| RW8
| Shade index
|-
! $1D
| [[Display#LCD Mono Shade LUT|LCD Mono Shade LUT 2/3]]
| style="text-align: right" | <tt style="white-space: nowrap">3333 2222</tt>
| RW8
| Shade index
|-
! $1E
| [[Display#LCD Mono Shade LUT|LCD Mono Shade LUT 4/5]]
| style="text-align: right" | <tt style="white-space: nowrap">5555 4444</tt>
| RW8
| Shade index
|-
! $1F
| [[Display#LCD Mono Shade LUT|LCD Mono Shade LUT 6/7]]
| style="text-align: right" | <tt style="white-space: nowrap">7777 6666</tt>
| RW8
| Shade index
|-
! $20
| [[Display#LCD Mono Palette|LCD Mono Palette 0]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $22
| [[Display#LCD Mono Palette|LCD Mono Palette 1]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $24
| [[Display#LCD Mono Palette|LCD Mono Palette 2]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $26
| [[Display#LCD Mono Palette|LCD Mono Palette 3]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $28
| [[Display#LCD Mono Palette|LCD Mono Palette 4]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $2A
| [[Display#LCD Mono Palette|LCD Mono Palette 5]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $2C
| [[Display#LCD Mono Palette|LCD Mono Palette 6]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $2E
| [[Display#LCD Mono Palette|LCD Mono Palette 7]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $30
| [[Display#LCD Mono Palette|LCD Mono Palette 8]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $32
| [[Display#LCD Mono Palette|LCD Mono Palette 9]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $34
| [[Display#LCD Mono Palette|LCD Mono Palette 10]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $36
| [[Display#LCD Mono Palette|LCD Mono Palette 11]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $38
| [[Display#LCD Mono Palette|LCD Mono Palette 12]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $3A
| [[Display#LCD Mono Palette|LCD Mono Palette 13]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $3C
| [[Display#LCD Mono Palette|LCD Mono Palette 14]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $3E
| [[Display#LCD Mono Palette|LCD Mono Palette 15]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! rowspan="10" | [[DMA]]<sup>(color)</sup>
! $40
| [[DMA#General DMA|GDMA Source Address Low]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll llll llll</tt>
| RW16
| Linear address, low 16 bits (l)
|-
! $42
| [[DMA#General DMA|GDMA Source Address High]]
| style="text-align: right" | <tt style="white-space: nowrap">.... hhhh</tt>
| RW8
| Linear address, high 4 bits (h)
|-
! $44
| [[DMA#General DMA|GDMA Destination Address]]
| style="text-align: right" | <tt style="white-space: nowrap">aaaa aaaa aaaa aaaa</tt>
| RW16
| IRAM address (a)
|-
! $46
| [[DMA#General DMA|GDMA Length]]
| style="text-align: right" | <tt style="white-space: nowrap">bbbb bbbb bbbb bbbb</tt>
| RW16
| Bytes (b)
|-
! $48
| [[DMA#General DMA|GDMA Control]]
| style="text-align: right" | <tt style="white-space: nowrap">ed.. ....</tt>
| RW8
| Enable (e), Decrement (d)
|-
! $4A
| [[DMA#Sound DMA|SDMA Source Address Low]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll llll llll</tt>
| RW16
| Linear address, low 16 bits (l)
|-
! $4C
| [[DMA#Sound DMA|SDMA Source Address High]]
| style="text-align: right" | <tt style="white-space: nowrap">.... hhhh</tt>
| RW8
| Linear address, high 4 bits (h)
|-
! $4E
| [[DMA#Sound DMA|SDMA Length Low]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll llll llll</tt>
| RW16
| Length, low 16 bits (l)
|-
! $50
| [[DMA#Sound DMA|SDMA Length High]]
| style="text-align: right" | <tt style="white-space: nowrap">.... hhhh</tt>
| RW8
| Length, high 4 bits (h)
|-
! $52
| [[DMA#Sound DMA|SDMA Control]]
| style="text-align: right" | <tt style="white-space: nowrap">ed.t r?ff</tt>
| RW8
| Enable (e), Decrement (d), Target (t),
Repeat (r), Frequency (f)
|-
! rowspan="2" | [[SoC]]<sup>(color)</sup>
! $60
| [[SoC#System Control 2|System Control 2]]
| style="text-align: right" | <tt style="white-space: nowrap">c4C. ?.??</tt>
| RW8
| Color (c), 4BPP (4), Chunky (C)
|-
! $62
| [[SoC#System Control 3|System Control 3]]
| style="text-align: right" | <tt style="white-space: nowrap">S... ...p</tt>
| RW8
| SwanCrystal (S), Power off (p)
|-
! rowspan="5" | [[Hyper Voice]]<sup>(color)</sup>
! $64
| Hyper Voice Left Output
| style="text-align: right" | <tt style="white-space: nowrap">ssss ssss ssss ssss</tt>
| W16
| Raw sample (s)
|-
! $66
| Hyper Voice Right Output
| style="text-align: right" | <tt style="white-space: nowrap">ssss ssss ssss ssss</tt>
| W16
| Raw sample (s)
|-
! $68
| Hyper Voice Left Input
| style="text-align: right" | <tt style="white-space: nowrap">ssss ssss</tt>
| 8
| Sample (s)
|-
! $69
| Hyper Voice Right Input
| style="text-align: right" | <tt style="white-space: nowrap">ssss ssss</tt>
| 8
| Sample (s)
|-
! $6A
| Hyper Voice Control
| style="text-align: right" | <tt style="white-space: nowrap">.mmc .... errr ffss</tt>
| RW16
| Mask (m), Channel (c), Enable (e),
Rate (r), Format (f), Shift (s)
|-
! rowspan="8" | [[Display]]<sup>(SC)</sup>
! $70
| LCD Timing Configuration 1?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $71
| LCD Timing Configuration 2?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $72
| LCD Timing Configuration 3?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $73
| LCD Timing Configuration 4?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $74
| LCD Timing Configuration 5?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $75
| LCD Timing Configuration 6?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $76
| LCD Timing Configuration 7?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $77
| LCD Timing Configuration 8?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! rowspan="21" | [[Sound]]
! $80
| [[Sound#Sound Channel Frequency|Sound Channel 1 Frequency]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .ddd dddd dddd</tt>
| RW16
| Divider (d)
|-
! $82
| [[Sound#Sound Channel Frequency|Sound Channel 2 Frequency]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .ddd dddd dddd</tt>
| RW16
| Divider (d)
|-
! $84
| [[Sound#Sound Channel Frequency|Sound Channel 3 Frequency]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .ddd dddd dddd</tt>
| RW16
| Divider (d)
|-
! $86
| [[Sound#Sound Channel Frequency|Sound Channel 4 Frequency]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .ddd dddd dddd</tt>
| RW16
| Divider (d)
|-
! $88
| [[Sound#Sound Channel Volume|Sound Channel 1 Volume]]
| style="text-align: right" | <tt style="white-space: nowrap">llll rrrr</tt>
| RW8
| Left (l), Right (r)
|-
! rowspan="2" | $89
| [[Sound#Sound Channel Volume|Sound Channel 2 Volume]]
| style="text-align: right" | <tt style="white-space: nowrap">llll rrrr</tt>
| RW8
| Left (l), Right (r)
|-
| [[Sound#Sound Channel 2 Voice Sample|Sound Channel 2 Voice Sample]]
| style="text-align: right" | <tt style="white-space: nowrap">ssss ssss</tt>
| RW8
| Sample (s)
|-
! $8A
| [[Sound#Sound Channel Volume|Sound Channel 3 Volume]]
| style="text-align: right" | <tt style="white-space: nowrap">llll rrrr</tt>
| RW8
| Left (l), Right (r)
|-
! $8B
| [[Sound#Sound Channel Volume|Sound Channel 4 Volume]]
| style="text-align: right" | <tt style="white-space: nowrap">llll rrrr</tt>
| RW8
| Left (l), Right (r)
|-
! $8C
| [[Sound#Sound Channel 3 Sweep Amount|Sound Channel 3 Sweep Amount]]
| style="text-align: right" | <tt style="white-space: nowrap">vvvv vvvv</tt>
| RW8
| Value (v)
|-
! $8D
| [[Sound#Sound Channel 3 Sweep Ticks|Sound Channel 3 Sweep Ticks]]
| style="text-align: right" | <tt style="white-space: nowrap">...t tttt</tt>
| RW8
| Ticks (t)
|-
! $8E
| [[Sound#Sound Channel 4 Noise Control|Sound Channel 4 Noise Control]]
| style="text-align: right" | <tt style="white-space: nowrap">...e rttt</tt>
| RW8
| Enable (e), Reset (r), Tap (t)
|-
! $8F
| [[Sound#Sound Wavetable Address|Sound Wavetable Address]]
| style="text-align: right" | <tt style="white-space: nowrap">wwww wwww</tt>
| RW8
| Address >> 6 (w)
|-
! $90
| [[Sound#Sound Channel Control|Sound Channel Control]]
| style="text-align: right" | <tt style="white-space: nowrap">nsv. 4321</tt>
| RW8
| Channel enable (1234)
Noise (n), Sweep (s), Voice (v)
|-
! $91
| [[Sound#Sound Output Control|Sound Output Control]]
| style="text-align: right" | <tt style="white-space: nowrap">H... hrrs</tt>
| RW8
| Headphones connected (H)
Headphone output (h)
Speaker output (s), range (r)
|-
! $92
| [[Sound#Sound Channel 4 LFSR Register|Sound Channel 4 LFSR Register]]
| style="text-align: right" | <tt style="white-space: nowrap">.rrr rrrr rrrr rrrr</tt>
| R16
| PRNG state (r)
|-
! $94
| [[Sound#Sound Channel 2 Voice Volume|Sound Channel 2 Voice Volume]]
| style="text-align: right" | <tt style="white-space: nowrap">.... lLrR</tt>
| RW8
| Left Half (l), Full (L)
Right Half (r), Full (R)
|-
! $96
| Sound Channel Output Right
| style="text-align: right" | <tt style="white-space: nowrap">.... ..ss ssss ssss</tt>
| R16
| Sample (s)
|-
! $98
| Sound Channel Output Left
| style="text-align: right" | <tt style="white-space: nowrap">.... ..ss ssss ssss</tt>
| R16
| Sample (s)
|-
! $9A
| Sound Channel Output Sum
| style="text-align: right" | <tt style="white-space: nowrap">.... .sss ssss ssss</tt>
| R16
| Sample (s)
|-
! $9E
| Sound Speaker Master Volume<sup>(color)</sup>
| style="text-align: right" | <tt style="white-space: nowrap">.... ..vv</tt>
| R8
| ?
|-
! [[SoC]]
! $A0
| [[SoC#System Control|System Control]]
| style="text-align: right" | <tt style="white-space: nowrap">t??? swcl</tt>
| RW8
| Test OK (t), ROM speed (s), ROM width (w),
Color system (c), Boot ROM lockout (l)
|-
! rowspan="5" | [[Timers]]
! $A2
| [[Timers#Timer Control|Timer Control]]
| style="text-align: right" | <tt style="white-space: nowrap">.... VvHh</tt>
| RW8
| Horizontal enable (h), auto reload (H)
Vertical enable (v), auto reload (V)
|-
! $A4
| [[Timers#Timer Reload|Horizontal Blank Timer Reload]]
| style="text-align: right" | <tt style="white-space: nowrap">tttt tttt tttt tttt</tt>
| RW16
| Ticks (t)
|-
! $A6
| [[Timers#Timer Reload|Vertical Blank Timer Reload]]
| style="text-align: right" | <tt style="white-space: nowrap">tttt tttt tttt tttt</tt>
| RW16
| Ticks (t)
|-
! $A8
| [[Timers#Timer Counter|Horizontal Blank Timer Counter]]
| style="text-align: right" | <tt style="white-space: nowrap">tttt tttt tttt tttt</tt>
| R16
| Ticks (t)
|-
! $AA
| [[Timers#Timer Counter|Vertical Blank Timer Counter]]
| style="text-align: right" | <tt style="white-space: nowrap">tttt tttt tttt tttt</tt>
| R16
| Ticks (t)
|-
! [[Interrupts]]
! $B0
| [[Interrupts#Interrupt Vector|Interrupt Vector]]
| style="text-align: right" | <tt style="white-space: nowrap">VVVV V...</tt>
| RW8
| Vector offset (v)
|-
! rowspan="2" | [[UART]]
! $B1
| [[UART#Serial Receive Data|Serial Receive Data]]
| style="text-align: right" | <tt style="white-space: nowrap">dddd dddd</tt>
| R8
| Receive buffer data (d)
|-
! $B1
| [[UART#Serial Transmit Data|Serial Transmit Data]]
| style="text-align: right" | <tt style="white-space: nowrap">dddd dddd</tt>
| W8
| Transmit buffer data (d)
|-
! [[Interrupts]]
! $B2
| [[Interrupts#Interrupt Enable|Interrupt Enable]]
| iiii iiii
| RW8
| Interrupt index (i)
|-
! rowspan="2" | [[UART]]
! $B3
| [[UART#Serial Status|Serial Status]]
| style="text-align: right" | <tt style="white-space: nowrap">eb.. .tor</tt>
| R8
| Enable (e), Baud rate (b),
Transfer ready (t), Overrun (o), Receive ready (r)
|-
! $B3
| [[UART#Serial Control|Serial Control]]
| style="text-align: right" | <tt style="white-space: nowrap">ebO. ....</tt>
| W8
| Enable (e), Baud rate (b), Reset Overrun (O)
|-
! [[Interrupts]]
! $B4
| [[Interrupts#Interrupt Status|Interrupt Status]]
| iiii iiii
| R8
| Interrupt index (i)
|-
! [[Keypad]]
! $B5
| [[Keypad|Keypad Scan]]
| style="text-align: right" | <tt style="white-space: nowrap">.iii oooo</tt>
| RW8
| Input row (i), Output column (o)
|-
! rowspan="2" | [[Interrupts]]
! $B6
| [[Interrupts#Interrupt Acknowledge|Interrupt Acknowledge]]
| iiii iiii
| R8?
| Interrupt index (i)
|-
! $B7
| [[Interrupts#Interrupt NMI Control|Interrupt NMI Control]]
| style="text-align: right" | <tt style="white-space: nowrap">...b ....</tt>
| RW8
| Low battery (b)
|-
! rowspan="4" | [[EEPROM|Internal EEPROM]]
! $BA
| [[EEPROM#Internal EEPROM Data|Internal EEPROM Data]]
| style="text-align: right" | <tt style="white-space: nowrap">dddd dddd dddd dddd</tt>
| RW16
| Data (d)
|-
! $BC
| [[EEPROM#Internal EEPROM Command|Internal EEPROM Command]]
|
| RW16
|
|-
! rowspan="2" | $BE
| [[EEPROM#Internal EEPROM Status|Internal EEPROM Status]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .... p... ..RD</tt>
| R16
| Protected (p), Ready (R), Done (D)
|-
| [[EEPROM#Internal EEPROM Control|Internal EEPROM Control]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .... pewr ....</tt>
| W16
| Protect (p), Erase (e), Write (w), Read (r)
|-
! [[Mapper|Cartridge]]
! $C0<br />
$FF
| Cartridge I/O
|
| RW8
| Forwarded by the SoC
|}
== I/O port routing ==
The [[NEC V30MZ]] supports 16-bit I/O port addresses. The WonderSwan SoC routes them using the following algorithm:
* If an address is between <code>$00B8</code> and <code>$00BF</code> inclusive, it is routed to the internal EEPROM control block.
* If an address is between <code>$00C0</code> and <code>$00FF</code> inclusive, it is routed to the cartride bus.
* If an address's bits <code>0</code> through <code>8</code> inclusive are between <code>$000</code> and <code>$0B7</code> inclusive, they are routed to the SoC block.
* If none of these conditions are reached, open bus is read.
22ef1e7debbf80bc06c69b5559700a5a37bd03d9
200
198
2023-08-27T10:50:53Z
Asie
351
wikitext
text/x-wiki
The WonderSwan SoC has three general blocks of I/O port accesses:
{| class="wikitable"
! From !! To !! Holder !! Width
|-
| $00 || $B7 || WonderSwan SoC || 8/16-bit
|-
| $B8 || $BF || Internal EEPROM control || 16-bit
|-
| $C0 || $FF || Cartridge bus || 8-bit
|}
With the exception of internal EEPROM on the ASWAN, all unaligned 16-bit accesses can be converted to two 8-bit accesses with a 1-cycle penalty.
== I/O port map ==
* Superscripts are used to mark ports specific to a given mode or platform:
** Color mode: <sup>(color)</sup>. Such ports are only accessible when color mode is enabled through port <code>$60</code>.
** WS/WSC/SC console: <sup>(WS)</sup>, <sup>(WSC)</sup>, <sup>(SC)</sup>.
* If two Bits rows are provided, the second one refers to the "Color" mode.
* The Type can be: R - readable, W - writable, L - writable before boot ROM lockout, 8/16 - width (byte/word).
{| class="wikitable"
! Category
! Port
! Description
! Bits
! Type
! Notes
|-
! rowspan="45" | [[Display]]
! $00
| [[Display#Display Control|Display Control]]
| style="text-align: right" | <tt style="white-space: nowrap">..ow Ws21</tt>
| RW8
|
|-
! $01
| [[Display#Display Background|Display Background]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .sss</tt>
<tt style="white-space: nowrap">pppp iiii</tt>
| RW8
| Shade (s)
Palette (p), Index (i)
|-
! $02
| [[Display#Current Line|Display Current Line]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll</tt>
| R8
| Line (l)
|-
! $03
| [[Display#Interrupt Line|Display Interrupt Line]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll</tt>
| RW8
| Line (l)
|-
! $04
| [[Display#Sprite Table Address|Sprite Table Address]]
| style="text-align: right" | <tt style="white-space: nowrap">...a aaaa</tt>
<tt style="white-space: nowrap">..aa aaaa</tt>
| RW8
| Address >> 9 (a)
|-
! $05
| [[Display#Sprite Table First|Sprite Table First]]
| style="text-align: right" | <tt style="white-space: nowrap">.iii iiii</tt>
| RW8
| Index (i)
|-
! $06
| [[Display#Sprite Table Count|Sprite Table Count]]
| style="text-align: right" | <tt style="white-space: nowrap">cccc cccc</tt>
| RW8
| Count (c)
|-
! $07
| [[Display#Screen Address|Screen Address]]
| style="text-align: right" | <tt style="white-space: nowrap">.222 .111</tt>
<tt style="white-space: nowrap">2222 1111</tt>
| RW8
| Screen 1 address >> 11 (1)
Screen 2 address >> 11 (2)
|-
! $08
| [[Display#Screen 2 Window|Screen 2 Window Left]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $09
| [[Display#Screen 2 Window|Screen 2 Window Top]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $0A
| [[Display#Screen 2 Window|Screen 2 Window Right]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $0B
| [[Display#Screen 2 Window|Screen 2 Window Bottom]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $0B
| [[Display#Sprite Window|Sprite Window Left]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $0C
| [[Display#Sprite Window|Sprite Window Top]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $0E
| [[Display#Sprite Window|Sprite Window Right]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $0F
| [[Display#Sprite Window|Sprite Window Bottom]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $10
| [[Display#Screen Scroll|Screen 1 Scroll X]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $11
| [[Display#Screen Scroll|Screen 1 Scroll Y]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $12
| [[Display#Screen Scroll|Screen 2 Scroll X]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $13
| [[Display#Screen Scroll|Screen 2 Scroll Y]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $14
| [[Display#LCD Control|LCD Control]]
| style="text-align: right" | <tt style="white-space: nowrap">.... ..Ce</tt>
| RW8
| Contrast (C)<sup>(WSC)</sup>, Enable (e)
|-
! $15
| [[Display#LCD Icon Control|LCD Icon Control]]
| style="text-align: right" | <tt style="white-space: nowrap">..32 1hvs</tt>
| RW8
| Auxillary 3 (3), Auxillary 2 (2), Auxillary 1 (1),
Horizontal (h), Vertical (v), Sleep (s)
|-
! $16
| [[Display#LCD Final Line|LCD Final Line]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll</tt>
| RW8
| Line (l)
|-
! $17
| [[Display#LCD Back Porch Line|LCD Back Porch Line]]<sup>(WSC)</sup>
| style="text-align: right" | <tt style="white-space: nowrap">llll llll</tt>
| RW8
| Line (l)
|-
! $1A
| [[Display#LCD Status|LCD Status]]
| style="text-align: right" | <tt style="white-space: nowrap">...v vv.s</tt>
| RW8
| Volume segment status (v), Sleep (s)
|-
! $1C
| [[Display#LCD Mono Shade LUT|LCD Mono Shade LUT 0/1]]
| style="text-align: right" | <tt style="white-space: nowrap">1111 0000</tt>
| RW8
| Shade index
|-
! $1D
| [[Display#LCD Mono Shade LUT|LCD Mono Shade LUT 2/3]]
| style="text-align: right" | <tt style="white-space: nowrap">3333 2222</tt>
| RW8
| Shade index
|-
! $1E
| [[Display#LCD Mono Shade LUT|LCD Mono Shade LUT 4/5]]
| style="text-align: right" | <tt style="white-space: nowrap">5555 4444</tt>
| RW8
| Shade index
|-
! $1F
| [[Display#LCD Mono Shade LUT|LCD Mono Shade LUT 6/7]]
| style="text-align: right" | <tt style="white-space: nowrap">7777 6666</tt>
| RW8
| Shade index
|-
! $20
| [[Display#LCD Mono Palette|LCD Mono Palette 0]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $22
| [[Display#LCD Mono Palette|LCD Mono Palette 1]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $24
| [[Display#LCD Mono Palette|LCD Mono Palette 2]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $26
| [[Display#LCD Mono Palette|LCD Mono Palette 3]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $28
| [[Display#LCD Mono Palette|LCD Mono Palette 4]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $2A
| [[Display#LCD Mono Palette|LCD Mono Palette 5]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $2C
| [[Display#LCD Mono Palette|LCD Mono Palette 6]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $2E
| [[Display#LCD Mono Palette|LCD Mono Palette 7]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $30
| [[Display#LCD Mono Palette|LCD Mono Palette 8]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $32
| [[Display#LCD Mono Palette|LCD Mono Palette 9]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $34
| [[Display#LCD Mono Palette|LCD Mono Palette 10]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $36
| [[Display#LCD Mono Palette|LCD Mono Palette 11]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $38
| [[Display#LCD Mono Palette|LCD Mono Palette 12]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $3A
| [[Display#LCD Mono Palette|LCD Mono Palette 13]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $3C
| [[Display#LCD Mono Palette|LCD Mono Palette 14]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $3E
| [[Display#LCD Mono Palette|LCD Mono Palette 15]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! rowspan="10" | [[DMA]]<sup>(color)</sup>
! $40
| [[DMA#General DMA|GDMA Source Address Low]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll llll llll</tt>
| RW16
| Linear address, low 16 bits (l)
|-
! $42
| [[DMA#General DMA|GDMA Source Address High]]
| style="text-align: right" | <tt style="white-space: nowrap">.... hhhh</tt>
| RW8
| Linear address, high 4 bits (h)
|-
! $44
| [[DMA#General DMA|GDMA Destination Address]]
| style="text-align: right" | <tt style="white-space: nowrap">aaaa aaaa aaaa aaaa</tt>
| RW16
| IRAM address (a)
|-
! $46
| [[DMA#General DMA|GDMA Length]]
| style="text-align: right" | <tt style="white-space: nowrap">bbbb bbbb bbbb bbbb</tt>
| RW16
| Bytes (b)
|-
! $48
| [[DMA#General DMA|GDMA Control]]
| style="text-align: right" | <tt style="white-space: nowrap">ed.. ....</tt>
| RW8
| Enable (e), Decrement (d)
|-
! $4A
| [[DMA#Sound DMA|SDMA Source Address Low]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll llll llll</tt>
| RW16
| Linear address, low 16 bits (l)
|-
! $4C
| [[DMA#Sound DMA|SDMA Source Address High]]
| style="text-align: right" | <tt style="white-space: nowrap">.... hhhh</tt>
| RW8
| Linear address, high 4 bits (h)
|-
! $4E
| [[DMA#Sound DMA|SDMA Length Low]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll llll llll</tt>
| RW16
| Length, low 16 bits (l)
|-
! $50
| [[DMA#Sound DMA|SDMA Length High]]
| style="text-align: right" | <tt style="white-space: nowrap">.... hhhh</tt>
| RW8
| Length, high 4 bits (h)
|-
! $52
| [[DMA#Sound DMA|SDMA Control]]
| style="text-align: right" | <tt style="white-space: nowrap">ed.t r?ff</tt>
| RW8
| Enable (e), Decrement (d), Target (t),
Repeat (r), Frequency (f)
|-
! rowspan="2" | [[SoC]]<sup>(color)</sup>
! $60
| [[SoC#System Control 2|System Control 2]]
| style="text-align: right" | <tt style="white-space: nowrap">c4C. ?.??</tt>
| RW8
| Color (c), 4BPP (4), Chunky (C)
|-
! $62
| [[SoC#System Control 3|System Control 3]]
| style="text-align: right" | <tt style="white-space: nowrap">S... ...p</tt>
| RW8
| SwanCrystal (S), Power off (p)
|-
! rowspan="5" | [[Hyper Voice]]<sup>(color)</sup>
! $64
| Hyper Voice Left Output
| style="text-align: right" | <tt style="white-space: nowrap">ssss ssss ssss ssss</tt>
| W16
| Raw sample (s)
|-
! $66
| Hyper Voice Right Output
| style="text-align: right" | <tt style="white-space: nowrap">ssss ssss ssss ssss</tt>
| W16
| Raw sample (s)
|-
! $68
| Hyper Voice Left Input
| style="text-align: right" | <tt style="white-space: nowrap">ssss ssss</tt>
| 8
| Sample (s)
|-
! $69
| Hyper Voice Right Input
| style="text-align: right" | <tt style="white-space: nowrap">ssss ssss</tt>
| 8
| Sample (s)
|-
! $6A
| Hyper Voice Control
| style="text-align: right" | <tt style="white-space: nowrap">.mmc .... errr ffss</tt>
| RW16
| Mask (m), Channel (c), Enable (e),
Rate (r), Format (f), Shift (s)
|-
! rowspan="8" | [[Display]]<sup>(SC)</sup>
! $70
| LCD Timing Configuration 1?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $71
| LCD Timing Configuration 2?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $72
| LCD Timing Configuration 3?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $73
| LCD Timing Configuration 4?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $74
| LCD Timing Configuration 5?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $75
| LCD Timing Configuration 6?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $76
| LCD Timing Configuration 7?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $77
| LCD Timing Configuration 8?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! rowspan="21" | [[Sound]]
! $80
| [[Sound#Sound Channel Frequency|Sound Channel 1 Frequency]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .ddd dddd dddd</tt>
| RW16
| Divider (d)
|-
! $82
| [[Sound#Sound Channel Frequency|Sound Channel 2 Frequency]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .ddd dddd dddd</tt>
| RW16
| Divider (d)
|-
! $84
| [[Sound#Sound Channel Frequency|Sound Channel 3 Frequency]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .ddd dddd dddd</tt>
| RW16
| Divider (d)
|-
! $86
| [[Sound#Sound Channel Frequency|Sound Channel 4 Frequency]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .ddd dddd dddd</tt>
| RW16
| Divider (d)
|-
! $88
| [[Sound#Sound Channel Volume|Sound Channel 1 Volume]]
| style="text-align: right" | <tt style="white-space: nowrap">llll rrrr</tt>
| RW8
| Left (l), Right (r)
|-
! rowspan="2" | $89
| [[Sound#Sound Channel Volume|Sound Channel 2 Volume]]
| style="text-align: right" | <tt style="white-space: nowrap">llll rrrr</tt>
| RW8
| Left (l), Right (r)
|-
| [[Sound#Sound Channel 2 Voice Sample|Sound Channel 2 Voice Sample]]
| style="text-align: right" | <tt style="white-space: nowrap">ssss ssss</tt>
| RW8
| Sample (s)
|-
! $8A
| [[Sound#Sound Channel Volume|Sound Channel 3 Volume]]
| style="text-align: right" | <tt style="white-space: nowrap">llll rrrr</tt>
| RW8
| Left (l), Right (r)
|-
! $8B
| [[Sound#Sound Channel Volume|Sound Channel 4 Volume]]
| style="text-align: right" | <tt style="white-space: nowrap">llll rrrr</tt>
| RW8
| Left (l), Right (r)
|-
! $8C
| [[Sound#Sound Channel 3 Sweep Amount|Sound Channel 3 Sweep Amount]]
| style="text-align: right" | <tt style="white-space: nowrap">vvvv vvvv</tt>
| RW8
| Value (v)
|-
! $8D
| [[Sound#Sound Channel 3 Sweep Ticks|Sound Channel 3 Sweep Ticks]]
| style="text-align: right" | <tt style="white-space: nowrap">...t tttt</tt>
| RW8
| Ticks (t)
|-
! $8E
| [[Sound#Sound Channel 4 Noise Control|Sound Channel 4 Noise Control]]
| style="text-align: right" | <tt style="white-space: nowrap">...e rttt</tt>
| RW8
| Enable (e), Reset (r), Tap (t)
|-
! $8F
| [[Sound#Sound Wavetable Address|Sound Wavetable Address]]
| style="text-align: right" | <tt style="white-space: nowrap">wwww wwww</tt>
| RW8
| Address >> 6 (w)
|-
! $90
| [[Sound#Sound Channel Control|Sound Channel Control]]
| style="text-align: right" | <tt style="white-space: nowrap">nsv. 4321</tt>
| RW8
| Channel enable (1234)
Noise (n), Sweep (s), Voice (v)
|-
! $91
| [[Sound#Sound Output Control|Sound Output Control]]
| style="text-align: right" | <tt style="white-space: nowrap">H... hrrs</tt>
| RW8
| Headphones connected (H)
Headphone output (h)
Speaker output (s), range (r)
|-
! $92
| [[Sound#Sound Channel 4 LFSR Register|Sound Channel 4 LFSR Register]]
| style="text-align: right" | <tt style="white-space: nowrap">.rrr rrrr rrrr rrrr</tt>
| R16
| PRNG state (r)
|-
! $94
| [[Sound#Sound Channel 2 Voice Volume|Sound Channel 2 Voice Volume]]
| style="text-align: right" | <tt style="white-space: nowrap">.... lLrR</tt>
| RW8
| Left Half (l), Full (L)
Right Half (r), Full (R)
|-
! $96
| Sound Channel Output Right
| style="text-align: right" | <tt style="white-space: nowrap">.... ..ss ssss ssss</tt>
| R16
| Sample (s)
|-
! $98
| Sound Channel Output Left
| style="text-align: right" | <tt style="white-space: nowrap">.... ..ss ssss ssss</tt>
| R16
| Sample (s)
|-
! $9A
| Sound Channel Output Sum
| style="text-align: right" | <tt style="white-space: nowrap">.... .sss ssss ssss</tt>
| R16
| Sample (s)
|-
! $9E
| Sound Speaker Master Volume<sup>(color)</sup>
| style="text-align: right" | <tt style="white-space: nowrap">.... ..vv</tt>
| R8
| ?
|-
! [[SoC]]
! $A0
| [[SoC#System Control|System Control]]
| style="text-align: right" | <tt style="white-space: nowrap">t??? swcl</tt>
| RW8
| Test OK (t), ROM speed (s), ROM width (w),
Color system (c), Boot ROM lockout (l)
|-
! rowspan="5" | [[Timers]]
! $A2
| [[Timers#Timer Control|Timer Control]]
| style="text-align: right" | <tt style="white-space: nowrap">.... VvHh</tt>
| RW8
| Horizontal enable (h), auto reload (H)
Vertical enable (v), auto reload (V)
|-
! $A4
| [[Timers#Timer Reload|Horizontal Blank Timer Reload]]
| style="text-align: right" | <tt style="white-space: nowrap">tttt tttt tttt tttt</tt>
| RW16
| Ticks (t)
|-
! $A6
| [[Timers#Timer Reload|Vertical Blank Timer Reload]]
| style="text-align: right" | <tt style="white-space: nowrap">tttt tttt tttt tttt</tt>
| RW16
| Ticks (t)
|-
! $A8
| [[Timers#Timer Counter|Horizontal Blank Timer Counter]]
| style="text-align: right" | <tt style="white-space: nowrap">tttt tttt tttt tttt</tt>
| R16
| Ticks (t)
|-
! $AA
| [[Timers#Timer Counter|Vertical Blank Timer Counter]]
| style="text-align: right" | <tt style="white-space: nowrap">tttt tttt tttt tttt</tt>
| R16
| Ticks (t)
|-
! [[Interrupts]]
! $B0
| [[Interrupts#Interrupt Vector|Interrupt Vector]]
| style="text-align: right" | <tt style="white-space: nowrap">VVVV V...</tt>
| RW8
| Vector offset (v)
|-
! rowspan="2" | [[UART]]
! $B1
| [[UART#Serial Receive Data|Serial Receive Data]]
| style="text-align: right" | <tt style="white-space: nowrap">dddd dddd</tt>
| R8
| Receive buffer data (d)
|-
! $B1
| [[UART#Serial Transmit Data|Serial Transmit Data]]
| style="text-align: right" | <tt style="white-space: nowrap">dddd dddd</tt>
| W8
| Transmit buffer data (d)
|-
! [[Interrupts]]
! $B2
| [[Interrupts#Interrupt Enable|Interrupt Enable]]
| iiii iiii
| RW8
| Interrupt index (i)
|-
! rowspan="2" | [[UART]]
! $B3
| [[UART#Serial Status|Serial Status]]
| style="text-align: right" | <tt style="white-space: nowrap">eb.. .tor</tt>
| R8
| Enable (e), Baud rate (b),
Transfer ready (t), Overrun (o), Receive ready (r)
|-
! $B3
| [[UART#Serial Control|Serial Control]]
| style="text-align: right" | <tt style="white-space: nowrap">ebO. ....</tt>
| W8
| Enable (e), Baud rate (b), Reset Overrun (O)
|-
! [[Interrupts]]
! $B4
| [[Interrupts#Interrupt Status|Interrupt Status]]
| iiii iiii
| R8
| Interrupt index (i)
|-
! [[Keypad]]
! $B5
| [[Keypad|Keypad Scan]]
| style="text-align: right" | <tt style="white-space: nowrap">.iii oooo</tt>
| RW8
| Input row (i), Output column (o)
|-
! rowspan="2" | [[Interrupts]]
! $B6
| [[Interrupts#Interrupt Acknowledge|Interrupt Acknowledge]]
| iiii iiii
| R8?
| Interrupt index (i)
|-
! $B7
| [[Interrupts#Interrupt NMI Control|Interrupt NMI Control]]
| style="text-align: right" | <tt style="white-space: nowrap">...b ....</tt>
| RW8
| Low battery (b)
|-
! rowspan="4" | [[EEPROM|Internal EEPROM]]
! $BA
| [[EEPROM#Internal EEPROM Data|Internal EEPROM Data]]
| style="text-align: right" | <tt style="white-space: nowrap">dddd dddd dddd dddd</tt>
| RW16
| Data (d)
|-
! $BC
| [[EEPROM#Internal EEPROM Command|Internal EEPROM Command]]
|
| RW16
|
|-
! rowspan="2" | $BE
| [[EEPROM#Internal EEPROM Status|Internal EEPROM Status]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .... p... ..RD</tt>
| R16
| Protected (p), Ready (R), Done (D)
|-
| [[EEPROM#Internal EEPROM Control|Internal EEPROM Control]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .... pewr ....</tt>
| W16
| Protect (p), Erase (e), Write (w), Read (r)
|-
! [[Mapper|Cartridge]]
! $C0<br />
$FF
| Cartridge I/O
|
| RW8
| Forwarded by the SoC
|}
== I/O port routing ==
The [[NEC V30MZ]] supports 16-bit I/O port addresses. The WonderSwan SoC routes them using the following algorithm:
* If an address is between <code>$00B8</code> and <code>$00BF</code> inclusive, it is routed to the internal EEPROM control block.
* If an address is between <code>$00C0</code> and <code>$00FF</code> inclusive, it is routed to the cartride bus.
* If an address's bits <code>0</code> through <code>8</code> inclusive are between <code>$000</code> and <code>$0B7</code> inclusive, they are routed to the SoC block.
* If none of these conditions are reached, open bus is read.
On the monochrome models, as well as color models in mono emulation, open bus is always <code>0x90</code>.
16d411851b1935e4546c8d5184de2b6450a59c53
Frame timing
0
36
153
2023-08-22T18:15:05Z
Asie
351
Created page with "Notes: * Sprite indices are given negatively. Sprites are filtered for every line, and are drawn from last found to first found. * Fetches may be off by one cycle. This stuff is complicated. {| class="wikitable" ! rowspan="2" | Cycle ! rowspan="2" | CPU ! colspan="4" | PPU ! rowspan="2" | APU ! rowspan="2" | Palette |- ! Mono/2BPP ! Color/2BPP ! Color/4BPP ! Line 144 |- | 0 | rowspan="117" style="vertical-align:top;" | V30MZ ! rowspan="256" style="text-align: center;"..."
wikitext
text/x-wiki
Notes:
* Sprite indices are given negatively. Sprites are filtered for every line, and are drawn from last found to first found.
* Fetches may be off by one cycle. This stuff is complicated.
{| class="wikitable"
! rowspan="2" | Cycle
! rowspan="2" | CPU
! colspan="4" | PPU
! rowspan="2" | APU
! rowspan="2" | Palette
|-
! Mono/2BPP
! Color/2BPP
! Color/4BPP
! Line 144
|-
| 0
| rowspan="117" style="vertical-align:top;" | V30MZ
! rowspan="256" style="text-align: center;" | TODO
| Fetch screen 1 cell (0, Y)
! rowspan="256" style="text-align: center;" | TODO
| rowspan="256" style="vertical-align:top;" | Sprite table DMA<br/>
Copy one word every cycle
| rowspan="122" style="vertical-align:top;" |
| rowspan="224" style="vertical-align:top;" | Fetch palette for pixel (N, Y)
|-
| 1
| Fetch tile data for above
|-
| 2
| Fetch screen 1 cell (1, Y)
|-
| 3
| Fetch tile data for above
|-
| 4
| Fetch screen 1 cell (2, Y)
|-
| 5
| Fetch tile data for above
|-
| 6
| Fetch screen 1 cell (3, Y)
|-
| 7
| Fetch tile data for above
|-
| 8
| Fetch screen 1 cell (4, Y)
|-
| 9
| Fetch tile data for above
|-
| 10
| Fetch screen 1 cell (5, Y)
|-
| 11
| Fetch tile data for above
|-
| 12
| Fetch screen 1 cell (6, Y)
|-
| 13
| Fetch tile data for above
|-
| 14
| Fetch screen 1 cell (7, Y)
|-
| 15
| Fetch tile data for above
|-
| 16
| Fetch screen 1 cell (8, Y)
|-
| 17
| Fetch tile data for above
|-
| 18
| Fetch screen 1 cell (9, Y)
|-
| 19
| Fetch tile data for above
|-
| 20
| Fetch screen 1 cell (10, Y)
|-
| 21
| Fetch tile data for above
|-
| 22
| Fetch screen 1 cell (11, Y)
|-
| 23
| Fetch tile data for above
|-
| 24
| Fetch screen 1 cell (12, Y)
|-
| 25
| Fetch tile data for above
|-
| 26
| Fetch screen 1 cell (13, Y)
|-
| 27
| Fetch tile data for above
|-
| 28
| Fetch screen 1 cell (14, Y)
|-
| 29
| Fetch tile data for above
|-
| 30
| Fetch screen 1 cell (15, Y)
|-
| 31
| Fetch tile data for above
|-
| 32
| Fetch screen 1 cell (16, Y)
|-
| 33
| Fetch tile data for above
|-
| 34
| Fetch screen 1 cell (17, Y)
|-
| 35
| Fetch tile data for above
|-
| 36
| Fetch screen 1 cell (18, Y)
|-
| 37
| Fetch tile data for above
|-
| 38
| Fetch screen 1 cell (19, Y)
|-
| 39
| Fetch tile data for above
|-
| 40
| Fetch screen 1 cell (20, Y)
|-
| 41
| Fetch tile data for above
|-
| 42
| Fetch screen 1 cell (21, Y)
|-
| 43
| Fetch tile data for above
|-
| 44
| Fetch screen 1 cell (22, Y)
|-
| 45
| Fetch tile data for above
|-
| 46
| Fetch screen 1 cell (23, Y)
|-
| 47
| Fetch tile data for above
|-
| 48
| Fetch screen 1 cell (24, Y)
|-
| 49
| Fetch tile data for above
|-
| 50
| Fetch screen 1 cell (25, Y)
|-
| 51
| Fetch tile data for above
|-
| 52
| Fetch screen 1 cell (26, Y)
|-
| 53
| Fetch tile data for above
|-
| 54
| Fetch screen 1 cell (27, Y)
|-
| 55
| Fetch tile data for above
|-
| 56
| Fetch screen 1 cell (28, Y)
|-
| 57
| Fetch tile data for above
|-
| 58
| Fetch screen 1 cell (29, Y)
|-
| 59
| Fetch tile data for above
|-
| 60
| Fetch screen 1 cell (30, Y)
|-
| 61
| Fetch tile data for above
|-
| 62
| Fetch screen 1 cell (31, Y)
|-
| 63
| Fetch tile data for above
|-
| 64
| Fetch screen 1 cell (0, Y)
|-
| 65
| Fetch tile data for above
|-
| 66
| Fetch screen 2 cell (0, Y)
|-
| 67
| Fetch tile data for above
|-
| 68
| Fetch screen 2 cell (1, Y)
|-
| 69
| Fetch tile data for above
|-
| 70
| Fetch screen 2 cell (2, Y)
|-
| 71
| Fetch tile data for above
|-
| 72
| Fetch screen 2 cell (3, Y)
|-
| 73
| Fetch tile data for above
|-
| 74
| Fetch screen 2 cell (4, Y)
|-
| 75
| Fetch tile data for above
|-
| 76
| Fetch screen 2 cell (5, Y)
|-
| 77
| Fetch tile data for above
|-
| 78
| Fetch screen 2 cell (6, Y)
|-
| 79
| Fetch tile data for above
|-
| 80
| Fetch screen 2 cell (7, Y)
|-
| 81
| Fetch tile data for above
|-
| 82
| Fetch screen 2 cell (8, Y)
|-
| 83
| Fetch tile data for above
|-
| 84
| Fetch screen 2 cell (9, Y)
|-
| 85
| Fetch tile data for above
|-
| 86
| Fetch screen 2 cell (10, Y)
|-
| 87
| Fetch tile data for above
|-
| 88
| Fetch screen 2 cell (11, Y)
|-
| 89
| Fetch tile data for above
|-
| 90
| Fetch screen 2 cell (12, Y)
|-
| 91
| Fetch tile data for above
|-
| 92
| Fetch screen 2 cell (13, Y)
|-
| 93
| Fetch tile data for above
|-
| 94
| Fetch screen 2 cell (14, Y)
|-
| 95
| Fetch tile data for above
|-
| 96
| Fetch screen 2 cell (15, Y)
|-
| 97
| Fetch tile data for above
|-
| 98
| Fetch screen 2 cell (16, Y)
|-
| 99
| Fetch tile data for above
|-
| 100
| Fetch screen 2 cell (17, Y)
|-
| 101
| Fetch tile data for above
|-
| 102
| Fetch screen 2 cell (18, Y)
|-
| 103
| Fetch tile data for above
|-
| 104
| Fetch screen 2 cell (19, Y)
|-
| 105
| Fetch tile data for above
|-
| 106
| Fetch screen 2 cell (20, Y)
|-
| 107
| Fetch tile data for above
|-
| 108
| Fetch screen 2 cell (21, Y)
|-
| 109
| Fetch tile data for above
|-
| 110
| Fetch screen 2 cell (22, Y)
|-
| 111
| Fetch tile data for above
|-
| 112
| Fetch screen 2 cell (23, Y)
|-
| 113
| Fetch tile data for above
|-
| 114
| Fetch screen 2 cell (24, Y)
|-
| 115
| Fetch tile data for above
|-
| 116
| Fetch screen 2 cell (25, Y)
|-
| 117
| rowspan="5" style="vertical-align:top;" | (SDMA) Initialize
| Fetch tile data for above
|-
| 118
| Fetch screen 2 cell (26, Y)
|-
| 119
| Fetch tile data for above
|-
| 120
| Fetch screen 2 cell (27, Y)
|-
| 121
| Fetch tile data for above
|-
| 122
| (SDMA) Fetch RAM byte
| Fetch screen 2 cell (28, Y)
| Reset sound output
|-
| 123
| (SDMA) Write sound port
| Fetch tile data for above
| Fetch channel 1 wavetable sample
|-
| 124
| rowspan="121" style="vertical-align:top;" | V30MZ
| Fetch screen 2 cell (29, Y)
| Fetch channel 2 wavetable sample<br/>
Add channel 1 output
|-
| 125
| Fetch tile data for above
| Fetch channel 3 wavetable sample<br/>
Add channel 2 output
|-
| 126
| Fetch screen 2 cell (30, Y)
| Fetch channel 4 wavetable sample<br/>
Add channel 3 output
|-
| 127
| Fetch tile data for above
| Add channel 4 output
|-
| 128
| Fetch screen 2 cell (31, Y)
| rowspan="122" |
|-
| 129
| Fetch tile data for above
|-
| 130
| Fetch screen 2 cell (0, Y)
|-
| 131
| Fetch tile data for above
|-
| 132
! rowspan="26" | TODO
|-
| 133
|-
| 134
|-
| 135
|-
| 136
|-
| 137
|-
| 138
|-
| 139
|-
| 140
|-
| 141
|-
| 142
|-
| 143
|-
| 144
|-
| 145
|-
| 146
|-
| 147
|-
| 148
|-
| 149
|-
| 150
|-
| 151
|-
| 152
|-
| 153
|-
| 154
|-
| 155
|-
| 156
|-
| 157
|-
| 158
| Fetch tile data for sprite -1
|-
| 159
! TODO
|-
| 160
| Fetch tile data for sprite -2
|-
| 161
! TODO
|-
| 162
| Fetch tile data for sprite -3
|-
| 163
! rowspan="3" | TODO
|-
| 164
|-
| 165
|-
| 166
| Fetch tile data for sprite -4
|-
| 167
! TODO
|-
| 168
| Fetch tile data for sprite -5
|-
| 169
! TODO
|-
| 170
| Fetch tile data for sprite -6
|-
| 171
! rowspan="3" | TODO
|-
| 172
|-
| 173
|-
| 174
| Fetch tile data for sprite -7
|-
| 175
! TODO
|-
| 176
| Fetch tile data for sprite -8
|-
| 177
! TODO
|-
| 178
| Fetch tile data for sprite -9
|-
| 179
! rowspan="3" | TODO
|-
| 180
|-
| 181
|-
| 182
| Fetch tile data for sprite -10
|-
| 183
! TODO
|-
| 184
| Fetch tile data for sprite -11
|-
| 185
! TODO
|-
| 186
| Fetch tile data for sprite -12
|-
| 187
! rowspan="3" | TODO
|-
| 188
|-
| 189
|-
| 190
| Fetch tile data for sprite -13
|-
| 191
! TODO
|-
| 192
| Fetch tile data for sprite -14
|-
| 193
! TODO
|-
| 194
| Fetch tile data for sprite -15
|-
| 195
! rowspan="3" | TODO
|-
| 196
|-
| 197
|-
| 198
| Fetch tile data for sprite -16
|-
| 199
! TODO
|-
| 200
| Fetch tile data for sprite -17
|-
| 201
! TODO
|-
| 202
| Fetch tile data for sprite -18
|-
| 203
! rowspan="3" | TODO
|-
| 204
|-
| 205
|-
| 206
| Fetch tile data for sprite -19
|-
| 207
! TODO
|-
| 208
| Fetch tile data for sprite -20
|-
| 209
! TODO
|-
| 210
| Fetch tile data for sprite -21
|-
| 211
! rowspan="3" | TODO
|-
| 212
|-
| 213
|-
| 214
| Fetch tile data for sprite -22
|-
| 215
! TODO
|-
| 216
| Fetch tile data for sprite -23
|-
| 217
! TODO
|-
| 218
| Fetch tile data for sprite -24
|-
| 219
! rowspan="3" | TODO
|-
| 220
|-
| 221
|-
| 222
| Fetch tile data for sprite -25
|-
| 223
! TODO
|-
| 224
| Fetch tile data for sprite -26
! rowspan="32" | TODO
|-
| 225
! TODO
|-
| 226
| Fetch tile data for sprite -27
|-
| 227
! rowspan="3" | TODO
|-
| 228
|-
| 229
|-
| 230
| Fetch tile data for sprite -28
|-
| 231
! TODO
|-
| 232
| Fetch tile data for sprite -29
|-
| 233
! TODO
|-
| 234
| Fetch tile data for sprite -30
|-
| 235
! rowspan="3" | TODO
|-
| 236
|-
| 237
|-
| 238
| Fetch tile data for sprite -31
|-
| 239
! TODO
|-
| 240
| Fetch tile data for sprite -32
|-
| 241
! rowspan="15" | TODO
|-
| 242
|-
| 243
|-
| 244
|-
| 245
| rowspan="5" style="vertical-align:top;" | (SDMA) Initialize
|-
| 246
|-
| 247
|-
| 248
|-
| 249
|-
| 250
| (SDMA) Fetch RAM byte
| Reset sound output
|-
| 251
| (SDMA) Write sound port
| Fetch channel 1 wavetable sample
|-
| 252
| rowspan="4" style="vertical-align:top;" | V30MZ
| Fetch channel 2 wavetable sample<br/>
Add channel 1 output
|-
| 253
| Fetch channel 3 wavetable sample<br/>
Add channel 2 output
|-
| 254
| Fetch channel 4 wavetable sample<br/>
Add channel 3 output
|-
| 255
| Add channel 4 output
|}
60f10a865098288e3751e3981ced65278be08257
154
153
2023-08-22T18:17:04Z
Asie
351
wikitext
text/x-wiki
Notes:
* Sprite indices are given negatively. Sprites are filtered for every line, and are drawn from last found to first found.
* Fetches may be off by one cycle. This stuff is complicated.
{| class="wikitable"
! rowspan="3" | Cycle
! colspan="7" | Quadrant
|-
! rowspan="2" | CPU
! colspan="4" | PPU
! rowspan="2" | APU
! rowspan="2" | Palette
|-
! Mono/2BPP
! Color/2BPP
! Color/4BPP
! Line 144
|-
| 0
| rowspan="117" style="vertical-align:top;" | V30MZ
! rowspan="256" style="text-align: center;" | TODO
| Fetch screen 1 cell (0, Y)
! rowspan="256" style="text-align: center;" | TODO
| rowspan="256" style="vertical-align:top;" | Sprite table DMA<br/>
Copy one word every cycle
| rowspan="122" style="vertical-align:top;" |
| rowspan="224" style="vertical-align:top;" | Fetch palette for pixel (N, Y)
|-
| 1
| Fetch tile data for above
|-
| 2
| Fetch screen 1 cell (1, Y)
|-
| 3
| Fetch tile data for above
|-
| 4
| Fetch screen 1 cell (2, Y)
|-
| 5
| Fetch tile data for above
|-
| 6
| Fetch screen 1 cell (3, Y)
|-
| 7
| Fetch tile data for above
|-
| 8
| Fetch screen 1 cell (4, Y)
|-
| 9
| Fetch tile data for above
|-
| 10
| Fetch screen 1 cell (5, Y)
|-
| 11
| Fetch tile data for above
|-
| 12
| Fetch screen 1 cell (6, Y)
|-
| 13
| Fetch tile data for above
|-
| 14
| Fetch screen 1 cell (7, Y)
|-
| 15
| Fetch tile data for above
|-
| 16
| Fetch screen 1 cell (8, Y)
|-
| 17
| Fetch tile data for above
|-
| 18
| Fetch screen 1 cell (9, Y)
|-
| 19
| Fetch tile data for above
|-
| 20
| Fetch screen 1 cell (10, Y)
|-
| 21
| Fetch tile data for above
|-
| 22
| Fetch screen 1 cell (11, Y)
|-
| 23
| Fetch tile data for above
|-
| 24
| Fetch screen 1 cell (12, Y)
|-
| 25
| Fetch tile data for above
|-
| 26
| Fetch screen 1 cell (13, Y)
|-
| 27
| Fetch tile data for above
|-
| 28
| Fetch screen 1 cell (14, Y)
|-
| 29
| Fetch tile data for above
|-
| 30
| Fetch screen 1 cell (15, Y)
|-
| 31
| Fetch tile data for above
|-
| 32
| Fetch screen 1 cell (16, Y)
|-
| 33
| Fetch tile data for above
|-
| 34
| Fetch screen 1 cell (17, Y)
|-
| 35
| Fetch tile data for above
|-
| 36
| Fetch screen 1 cell (18, Y)
|-
| 37
| Fetch tile data for above
|-
| 38
| Fetch screen 1 cell (19, Y)
|-
| 39
| Fetch tile data for above
|-
| 40
| Fetch screen 1 cell (20, Y)
|-
| 41
| Fetch tile data for above
|-
| 42
| Fetch screen 1 cell (21, Y)
|-
| 43
| Fetch tile data for above
|-
| 44
| Fetch screen 1 cell (22, Y)
|-
| 45
| Fetch tile data for above
|-
| 46
| Fetch screen 1 cell (23, Y)
|-
| 47
| Fetch tile data for above
|-
| 48
| Fetch screen 1 cell (24, Y)
|-
| 49
| Fetch tile data for above
|-
| 50
| Fetch screen 1 cell (25, Y)
|-
| 51
| Fetch tile data for above
|-
| 52
| Fetch screen 1 cell (26, Y)
|-
| 53
| Fetch tile data for above
|-
| 54
| Fetch screen 1 cell (27, Y)
|-
| 55
| Fetch tile data for above
|-
| 56
| Fetch screen 1 cell (28, Y)
|-
| 57
| Fetch tile data for above
|-
| 58
| Fetch screen 1 cell (29, Y)
|-
| 59
| Fetch tile data for above
|-
| 60
| Fetch screen 1 cell (30, Y)
|-
| 61
| Fetch tile data for above
|-
| 62
| Fetch screen 1 cell (31, Y)
|-
| 63
| Fetch tile data for above
|-
| 64
| Fetch screen 1 cell (0, Y)
|-
| 65
| Fetch tile data for above
|-
| 66
| Fetch screen 2 cell (0, Y)
|-
| 67
| Fetch tile data for above
|-
| 68
| Fetch screen 2 cell (1, Y)
|-
| 69
| Fetch tile data for above
|-
| 70
| Fetch screen 2 cell (2, Y)
|-
| 71
| Fetch tile data for above
|-
| 72
| Fetch screen 2 cell (3, Y)
|-
| 73
| Fetch tile data for above
|-
| 74
| Fetch screen 2 cell (4, Y)
|-
| 75
| Fetch tile data for above
|-
| 76
| Fetch screen 2 cell (5, Y)
|-
| 77
| Fetch tile data for above
|-
| 78
| Fetch screen 2 cell (6, Y)
|-
| 79
| Fetch tile data for above
|-
| 80
| Fetch screen 2 cell (7, Y)
|-
| 81
| Fetch tile data for above
|-
| 82
| Fetch screen 2 cell (8, Y)
|-
| 83
| Fetch tile data for above
|-
| 84
| Fetch screen 2 cell (9, Y)
|-
| 85
| Fetch tile data for above
|-
| 86
| Fetch screen 2 cell (10, Y)
|-
| 87
| Fetch tile data for above
|-
| 88
| Fetch screen 2 cell (11, Y)
|-
| 89
| Fetch tile data for above
|-
| 90
| Fetch screen 2 cell (12, Y)
|-
| 91
| Fetch tile data for above
|-
| 92
| Fetch screen 2 cell (13, Y)
|-
| 93
| Fetch tile data for above
|-
| 94
| Fetch screen 2 cell (14, Y)
|-
| 95
| Fetch tile data for above
|-
| 96
| Fetch screen 2 cell (15, Y)
|-
| 97
| Fetch tile data for above
|-
| 98
| Fetch screen 2 cell (16, Y)
|-
| 99
| Fetch tile data for above
|-
| 100
| Fetch screen 2 cell (17, Y)
|-
| 101
| Fetch tile data for above
|-
| 102
| Fetch screen 2 cell (18, Y)
|-
| 103
| Fetch tile data for above
|-
| 104
| Fetch screen 2 cell (19, Y)
|-
| 105
| Fetch tile data for above
|-
| 106
| Fetch screen 2 cell (20, Y)
|-
| 107
| Fetch tile data for above
|-
| 108
| Fetch screen 2 cell (21, Y)
|-
| 109
| Fetch tile data for above
|-
| 110
| Fetch screen 2 cell (22, Y)
|-
| 111
| Fetch tile data for above
|-
| 112
| Fetch screen 2 cell (23, Y)
|-
| 113
| Fetch tile data for above
|-
| 114
| Fetch screen 2 cell (24, Y)
|-
| 115
| Fetch tile data for above
|-
| 116
| Fetch screen 2 cell (25, Y)
|-
| 117
| rowspan="5" style="vertical-align:top;" | (SDMA) Initialize
| Fetch tile data for above
|-
| 118
| Fetch screen 2 cell (26, Y)
|-
| 119
| Fetch tile data for above
|-
| 120
| Fetch screen 2 cell (27, Y)
|-
| 121
| Fetch tile data for above
|-
| 122
| (SDMA) Fetch RAM byte
| Fetch screen 2 cell (28, Y)
| Reset sound output
|-
| 123
| (SDMA) Write sound port
| Fetch tile data for above
| Fetch channel 1 wavetable sample
|-
| 124
| rowspan="121" style="vertical-align:top;" | V30MZ
| Fetch screen 2 cell (29, Y)
| Fetch channel 2 wavetable sample<br/>
Add channel 1 output
|-
| 125
| Fetch tile data for above
| Fetch channel 3 wavetable sample<br/>
Add channel 2 output
|-
| 126
| Fetch screen 2 cell (30, Y)
| Fetch channel 4 wavetable sample<br/>
Add channel 3 output
|-
| 127
| Fetch tile data for above
| Add channel 4 output
|-
| 128
| Fetch screen 2 cell (31, Y)
| rowspan="122" |
|-
| 129
| Fetch tile data for above
|-
| 130
| Fetch screen 2 cell (0, Y)
|-
| 131
| Fetch tile data for above
|-
| 132
! rowspan="26" | TODO
|-
| 133
|-
| 134
|-
| 135
|-
| 136
|-
| 137
|-
| 138
|-
| 139
|-
| 140
|-
| 141
|-
| 142
|-
| 143
|-
| 144
|-
| 145
|-
| 146
|-
| 147
|-
| 148
|-
| 149
|-
| 150
|-
| 151
|-
| 152
|-
| 153
|-
| 154
|-
| 155
|-
| 156
|-
| 157
|-
| 158
| Fetch tile data for sprite -1
|-
| 159
! TODO
|-
| 160
| Fetch tile data for sprite -2
|-
| 161
! TODO
|-
| 162
| Fetch tile data for sprite -3
|-
| 163
! rowspan="3" | TODO
|-
| 164
|-
| 165
|-
| 166
| Fetch tile data for sprite -4
|-
| 167
! TODO
|-
| 168
| Fetch tile data for sprite -5
|-
| 169
! TODO
|-
| 170
| Fetch tile data for sprite -6
|-
| 171
! rowspan="3" | TODO
|-
| 172
|-
| 173
|-
| 174
| Fetch tile data for sprite -7
|-
| 175
! TODO
|-
| 176
| Fetch tile data for sprite -8
|-
| 177
! TODO
|-
| 178
| Fetch tile data for sprite -9
|-
| 179
! rowspan="3" | TODO
|-
| 180
|-
| 181
|-
| 182
| Fetch tile data for sprite -10
|-
| 183
! TODO
|-
| 184
| Fetch tile data for sprite -11
|-
| 185
! TODO
|-
| 186
| Fetch tile data for sprite -12
|-
| 187
! rowspan="3" | TODO
|-
| 188
|-
| 189
|-
| 190
| Fetch tile data for sprite -13
|-
| 191
! TODO
|-
| 192
| Fetch tile data for sprite -14
|-
| 193
! TODO
|-
| 194
| Fetch tile data for sprite -15
|-
| 195
! rowspan="3" | TODO
|-
| 196
|-
| 197
|-
| 198
| Fetch tile data for sprite -16
|-
| 199
! TODO
|-
| 200
| Fetch tile data for sprite -17
|-
| 201
! TODO
|-
| 202
| Fetch tile data for sprite -18
|-
| 203
! rowspan="3" | TODO
|-
| 204
|-
| 205
|-
| 206
| Fetch tile data for sprite -19
|-
| 207
! TODO
|-
| 208
| Fetch tile data for sprite -20
|-
| 209
! TODO
|-
| 210
| Fetch tile data for sprite -21
|-
| 211
! rowspan="3" | TODO
|-
| 212
|-
| 213
|-
| 214
| Fetch tile data for sprite -22
|-
| 215
! TODO
|-
| 216
| Fetch tile data for sprite -23
|-
| 217
! TODO
|-
| 218
| Fetch tile data for sprite -24
|-
| 219
! rowspan="3" | TODO
|-
| 220
|-
| 221
|-
| 222
| Fetch tile data for sprite -25
|-
| 223
! TODO
|-
| 224
| Fetch tile data for sprite -26
! rowspan="32" | TODO
|-
| 225
! TODO
|-
| 226
| Fetch tile data for sprite -27
|-
| 227
! rowspan="3" | TODO
|-
| 228
|-
| 229
|-
| 230
| Fetch tile data for sprite -28
|-
| 231
! TODO
|-
| 232
| Fetch tile data for sprite -29
|-
| 233
! TODO
|-
| 234
| Fetch tile data for sprite -30
|-
| 235
! rowspan="3" | TODO
|-
| 236
|-
| 237
|-
| 238
| Fetch tile data for sprite -31
|-
| 239
! TODO
|-
| 240
| Fetch tile data for sprite -32
|-
| 241
! rowspan="15" | TODO
|-
| 242
|-
| 243
|-
| 244
|-
| 245
| rowspan="5" style="vertical-align:top;" | (SDMA) Initialize
|-
| 246
|-
| 247
|-
| 248
|-
| 249
|-
| 250
| (SDMA) Fetch RAM byte
| Reset sound output
|-
| 251
| (SDMA) Write sound port
| Fetch channel 1 wavetable sample
|-
| 252
| rowspan="4" style="vertical-align:top;" | V30MZ
| Fetch channel 2 wavetable sample<br/>
Add channel 1 output
|-
| 253
| Fetch channel 3 wavetable sample<br/>
Add channel 2 output
|-
| 254
| Fetch channel 4 wavetable sample<br/>
Add channel 3 output
|-
| 255
| Add channel 4 output
|}
dde35f5530e1f0b38efc8cd979669c26db8de836
155
154
2023-08-22T18:17:24Z
Asie
351
wikitext
text/x-wiki
Notes:
* Sprite indices are given negatively. Sprites are filtered for every line, and are drawn from last found to first found.
* Fetches may be off by one cycle. This stuff is complicated.
{| class="wikitable"
! rowspan="3" | Cycle
! colspan="7" | Quadrant
|-
! rowspan="2" | CPU
! colspan="4" | PPU
! rowspan="2" | APU
! rowspan="2" | Palette
|-
! Mono/2BPP
! Color/2BPP
! Color/4BPP
! Line 144
|-
| 0
| rowspan="117" style="vertical-align:top;" | V30MZ
! rowspan="256" style="text-align: center;" | TODO
| Fetch screen 1 cell (0, Y)
! rowspan="256" style="text-align: center;" | TODO
| rowspan="256" style="vertical-align:top;" | Sprite table DMA<br/>
Copy one word every cycle
| rowspan="122" style="vertical-align:top;" |
| rowspan="224" style="vertical-align:top;" | Fetch palette for pixel (N, Y - 1)
|-
| 1
| Fetch tile data for above
|-
| 2
| Fetch screen 1 cell (1, Y)
|-
| 3
| Fetch tile data for above
|-
| 4
| Fetch screen 1 cell (2, Y)
|-
| 5
| Fetch tile data for above
|-
| 6
| Fetch screen 1 cell (3, Y)
|-
| 7
| Fetch tile data for above
|-
| 8
| Fetch screen 1 cell (4, Y)
|-
| 9
| Fetch tile data for above
|-
| 10
| Fetch screen 1 cell (5, Y)
|-
| 11
| Fetch tile data for above
|-
| 12
| Fetch screen 1 cell (6, Y)
|-
| 13
| Fetch tile data for above
|-
| 14
| Fetch screen 1 cell (7, Y)
|-
| 15
| Fetch tile data for above
|-
| 16
| Fetch screen 1 cell (8, Y)
|-
| 17
| Fetch tile data for above
|-
| 18
| Fetch screen 1 cell (9, Y)
|-
| 19
| Fetch tile data for above
|-
| 20
| Fetch screen 1 cell (10, Y)
|-
| 21
| Fetch tile data for above
|-
| 22
| Fetch screen 1 cell (11, Y)
|-
| 23
| Fetch tile data for above
|-
| 24
| Fetch screen 1 cell (12, Y)
|-
| 25
| Fetch tile data for above
|-
| 26
| Fetch screen 1 cell (13, Y)
|-
| 27
| Fetch tile data for above
|-
| 28
| Fetch screen 1 cell (14, Y)
|-
| 29
| Fetch tile data for above
|-
| 30
| Fetch screen 1 cell (15, Y)
|-
| 31
| Fetch tile data for above
|-
| 32
| Fetch screen 1 cell (16, Y)
|-
| 33
| Fetch tile data for above
|-
| 34
| Fetch screen 1 cell (17, Y)
|-
| 35
| Fetch tile data for above
|-
| 36
| Fetch screen 1 cell (18, Y)
|-
| 37
| Fetch tile data for above
|-
| 38
| Fetch screen 1 cell (19, Y)
|-
| 39
| Fetch tile data for above
|-
| 40
| Fetch screen 1 cell (20, Y)
|-
| 41
| Fetch tile data for above
|-
| 42
| Fetch screen 1 cell (21, Y)
|-
| 43
| Fetch tile data for above
|-
| 44
| Fetch screen 1 cell (22, Y)
|-
| 45
| Fetch tile data for above
|-
| 46
| Fetch screen 1 cell (23, Y)
|-
| 47
| Fetch tile data for above
|-
| 48
| Fetch screen 1 cell (24, Y)
|-
| 49
| Fetch tile data for above
|-
| 50
| Fetch screen 1 cell (25, Y)
|-
| 51
| Fetch tile data for above
|-
| 52
| Fetch screen 1 cell (26, Y)
|-
| 53
| Fetch tile data for above
|-
| 54
| Fetch screen 1 cell (27, Y)
|-
| 55
| Fetch tile data for above
|-
| 56
| Fetch screen 1 cell (28, Y)
|-
| 57
| Fetch tile data for above
|-
| 58
| Fetch screen 1 cell (29, Y)
|-
| 59
| Fetch tile data for above
|-
| 60
| Fetch screen 1 cell (30, Y)
|-
| 61
| Fetch tile data for above
|-
| 62
| Fetch screen 1 cell (31, Y)
|-
| 63
| Fetch tile data for above
|-
| 64
| Fetch screen 1 cell (0, Y)
|-
| 65
| Fetch tile data for above
|-
| 66
| Fetch screen 2 cell (0, Y)
|-
| 67
| Fetch tile data for above
|-
| 68
| Fetch screen 2 cell (1, Y)
|-
| 69
| Fetch tile data for above
|-
| 70
| Fetch screen 2 cell (2, Y)
|-
| 71
| Fetch tile data for above
|-
| 72
| Fetch screen 2 cell (3, Y)
|-
| 73
| Fetch tile data for above
|-
| 74
| Fetch screen 2 cell (4, Y)
|-
| 75
| Fetch tile data for above
|-
| 76
| Fetch screen 2 cell (5, Y)
|-
| 77
| Fetch tile data for above
|-
| 78
| Fetch screen 2 cell (6, Y)
|-
| 79
| Fetch tile data for above
|-
| 80
| Fetch screen 2 cell (7, Y)
|-
| 81
| Fetch tile data for above
|-
| 82
| Fetch screen 2 cell (8, Y)
|-
| 83
| Fetch tile data for above
|-
| 84
| Fetch screen 2 cell (9, Y)
|-
| 85
| Fetch tile data for above
|-
| 86
| Fetch screen 2 cell (10, Y)
|-
| 87
| Fetch tile data for above
|-
| 88
| Fetch screen 2 cell (11, Y)
|-
| 89
| Fetch tile data for above
|-
| 90
| Fetch screen 2 cell (12, Y)
|-
| 91
| Fetch tile data for above
|-
| 92
| Fetch screen 2 cell (13, Y)
|-
| 93
| Fetch tile data for above
|-
| 94
| Fetch screen 2 cell (14, Y)
|-
| 95
| Fetch tile data for above
|-
| 96
| Fetch screen 2 cell (15, Y)
|-
| 97
| Fetch tile data for above
|-
| 98
| Fetch screen 2 cell (16, Y)
|-
| 99
| Fetch tile data for above
|-
| 100
| Fetch screen 2 cell (17, Y)
|-
| 101
| Fetch tile data for above
|-
| 102
| Fetch screen 2 cell (18, Y)
|-
| 103
| Fetch tile data for above
|-
| 104
| Fetch screen 2 cell (19, Y)
|-
| 105
| Fetch tile data for above
|-
| 106
| Fetch screen 2 cell (20, Y)
|-
| 107
| Fetch tile data for above
|-
| 108
| Fetch screen 2 cell (21, Y)
|-
| 109
| Fetch tile data for above
|-
| 110
| Fetch screen 2 cell (22, Y)
|-
| 111
| Fetch tile data for above
|-
| 112
| Fetch screen 2 cell (23, Y)
|-
| 113
| Fetch tile data for above
|-
| 114
| Fetch screen 2 cell (24, Y)
|-
| 115
| Fetch tile data for above
|-
| 116
| Fetch screen 2 cell (25, Y)
|-
| 117
| rowspan="5" style="vertical-align:top;" | (SDMA) Initialize
| Fetch tile data for above
|-
| 118
| Fetch screen 2 cell (26, Y)
|-
| 119
| Fetch tile data for above
|-
| 120
| Fetch screen 2 cell (27, Y)
|-
| 121
| Fetch tile data for above
|-
| 122
| (SDMA) Fetch RAM byte
| Fetch screen 2 cell (28, Y)
| Reset sound output
|-
| 123
| (SDMA) Write sound port
| Fetch tile data for above
| Fetch channel 1 wavetable sample
|-
| 124
| rowspan="121" style="vertical-align:top;" | V30MZ
| Fetch screen 2 cell (29, Y)
| Fetch channel 2 wavetable sample<br/>
Add channel 1 output
|-
| 125
| Fetch tile data for above
| Fetch channel 3 wavetable sample<br/>
Add channel 2 output
|-
| 126
| Fetch screen 2 cell (30, Y)
| Fetch channel 4 wavetable sample<br/>
Add channel 3 output
|-
| 127
| Fetch tile data for above
| Add channel 4 output
|-
| 128
| Fetch screen 2 cell (31, Y)
| rowspan="122" |
|-
| 129
| Fetch tile data for above
|-
| 130
| Fetch screen 2 cell (0, Y)
|-
| 131
| Fetch tile data for above
|-
| 132
! rowspan="26" | TODO
|-
| 133
|-
| 134
|-
| 135
|-
| 136
|-
| 137
|-
| 138
|-
| 139
|-
| 140
|-
| 141
|-
| 142
|-
| 143
|-
| 144
|-
| 145
|-
| 146
|-
| 147
|-
| 148
|-
| 149
|-
| 150
|-
| 151
|-
| 152
|-
| 153
|-
| 154
|-
| 155
|-
| 156
|-
| 157
|-
| 158
| Fetch tile data for sprite -1
|-
| 159
! TODO
|-
| 160
| Fetch tile data for sprite -2
|-
| 161
! TODO
|-
| 162
| Fetch tile data for sprite -3
|-
| 163
! rowspan="3" | TODO
|-
| 164
|-
| 165
|-
| 166
| Fetch tile data for sprite -4
|-
| 167
! TODO
|-
| 168
| Fetch tile data for sprite -5
|-
| 169
! TODO
|-
| 170
| Fetch tile data for sprite -6
|-
| 171
! rowspan="3" | TODO
|-
| 172
|-
| 173
|-
| 174
| Fetch tile data for sprite -7
|-
| 175
! TODO
|-
| 176
| Fetch tile data for sprite -8
|-
| 177
! TODO
|-
| 178
| Fetch tile data for sprite -9
|-
| 179
! rowspan="3" | TODO
|-
| 180
|-
| 181
|-
| 182
| Fetch tile data for sprite -10
|-
| 183
! TODO
|-
| 184
| Fetch tile data for sprite -11
|-
| 185
! TODO
|-
| 186
| Fetch tile data for sprite -12
|-
| 187
! rowspan="3" | TODO
|-
| 188
|-
| 189
|-
| 190
| Fetch tile data for sprite -13
|-
| 191
! TODO
|-
| 192
| Fetch tile data for sprite -14
|-
| 193
! TODO
|-
| 194
| Fetch tile data for sprite -15
|-
| 195
! rowspan="3" | TODO
|-
| 196
|-
| 197
|-
| 198
| Fetch tile data for sprite -16
|-
| 199
! TODO
|-
| 200
| Fetch tile data for sprite -17
|-
| 201
! TODO
|-
| 202
| Fetch tile data for sprite -18
|-
| 203
! rowspan="3" | TODO
|-
| 204
|-
| 205
|-
| 206
| Fetch tile data for sprite -19
|-
| 207
! TODO
|-
| 208
| Fetch tile data for sprite -20
|-
| 209
! TODO
|-
| 210
| Fetch tile data for sprite -21
|-
| 211
! rowspan="3" | TODO
|-
| 212
|-
| 213
|-
| 214
| Fetch tile data for sprite -22
|-
| 215
! TODO
|-
| 216
| Fetch tile data for sprite -23
|-
| 217
! TODO
|-
| 218
| Fetch tile data for sprite -24
|-
| 219
! rowspan="3" | TODO
|-
| 220
|-
| 221
|-
| 222
| Fetch tile data for sprite -25
|-
| 223
! TODO
|-
| 224
| Fetch tile data for sprite -26
! rowspan="32" | TODO
|-
| 225
! TODO
|-
| 226
| Fetch tile data for sprite -27
|-
| 227
! rowspan="3" | TODO
|-
| 228
|-
| 229
|-
| 230
| Fetch tile data for sprite -28
|-
| 231
! TODO
|-
| 232
| Fetch tile data for sprite -29
|-
| 233
! TODO
|-
| 234
| Fetch tile data for sprite -30
|-
| 235
! rowspan="3" | TODO
|-
| 236
|-
| 237
|-
| 238
| Fetch tile data for sprite -31
|-
| 239
! TODO
|-
| 240
| Fetch tile data for sprite -32
|-
| 241
! rowspan="15" | TODO
|-
| 242
|-
| 243
|-
| 244
|-
| 245
| rowspan="5" style="vertical-align:top;" | (SDMA) Initialize
|-
| 246
|-
| 247
|-
| 248
|-
| 249
|-
| 250
| (SDMA) Fetch RAM byte
| Reset sound output
|-
| 251
| (SDMA) Write sound port
| Fetch channel 1 wavetable sample
|-
| 252
| rowspan="4" style="vertical-align:top;" | V30MZ
| Fetch channel 2 wavetable sample<br/>
Add channel 1 output
|-
| 253
| Fetch channel 3 wavetable sample<br/>
Add channel 2 output
|-
| 254
| Fetch channel 4 wavetable sample<br/>
Add channel 3 output
|-
| 255
| Add channel 4 output
|}
0a13eb77ee228532c22ac14fa7fedbc6ebb00c37
157
155
2023-08-22T18:21:43Z
Asie
351
wikitext
text/x-wiki
Notes:
* Sprite indices are given negatively. Sprites are filtered for every line, and are drawn from last found to first found.
* Fetches may be off by one cycle. This stuff is complicated.
{| class="wikitable"
! rowspan="3" | Cycle
! colspan="7" | Quadrant
|-
! rowspan="2" | CPU
! colspan="4" | Display
! rowspan="2" | Sound
! rowspan="2" | Palette
|-
! Mono/2BPP
! Color/2BPP
! Color/4BPP
! Line 144
|-
| 0
| rowspan="117" style="vertical-align:top;" | V30MZ
! rowspan="256" style="text-align: center;" | TODO
| Fetch screen 1 cell (0, Y)
! rowspan="256" style="text-align: center;" | TODO
| rowspan="256" style="vertical-align:top;" | Sprite table DMA<br/>
Copy one word every cycle
| rowspan="122" style="vertical-align:top;" |
| rowspan="224" style="vertical-align:top;" | Fetch palette for pixel (N, Y - 1)
|-
| 1
| Fetch tile data for above
|-
| 2
| Fetch screen 1 cell (1, Y)
|-
| 3
| Fetch tile data for above
|-
| 4
| Fetch screen 1 cell (2, Y)
|-
| 5
| Fetch tile data for above
|-
| 6
| Fetch screen 1 cell (3, Y)
|-
| 7
| Fetch tile data for above
|-
| 8
| Fetch screen 1 cell (4, Y)
|-
| 9
| Fetch tile data for above
|-
| 10
| Fetch screen 1 cell (5, Y)
|-
| 11
| Fetch tile data for above
|-
| 12
| Fetch screen 1 cell (6, Y)
|-
| 13
| Fetch tile data for above
|-
| 14
| Fetch screen 1 cell (7, Y)
|-
| 15
| Fetch tile data for above
|-
| 16
| Fetch screen 1 cell (8, Y)
|-
| 17
| Fetch tile data for above
|-
| 18
| Fetch screen 1 cell (9, Y)
|-
| 19
| Fetch tile data for above
|-
| 20
| Fetch screen 1 cell (10, Y)
|-
| 21
| Fetch tile data for above
|-
| 22
| Fetch screen 1 cell (11, Y)
|-
| 23
| Fetch tile data for above
|-
| 24
| Fetch screen 1 cell (12, Y)
|-
| 25
| Fetch tile data for above
|-
| 26
| Fetch screen 1 cell (13, Y)
|-
| 27
| Fetch tile data for above
|-
| 28
| Fetch screen 1 cell (14, Y)
|-
| 29
| Fetch tile data for above
|-
| 30
| Fetch screen 1 cell (15, Y)
|-
| 31
| Fetch tile data for above
|-
| 32
| Fetch screen 1 cell (16, Y)
|-
| 33
| Fetch tile data for above
|-
| 34
| Fetch screen 1 cell (17, Y)
|-
| 35
| Fetch tile data for above
|-
| 36
| Fetch screen 1 cell (18, Y)
|-
| 37
| Fetch tile data for above
|-
| 38
| Fetch screen 1 cell (19, Y)
|-
| 39
| Fetch tile data for above
|-
| 40
| Fetch screen 1 cell (20, Y)
|-
| 41
| Fetch tile data for above
|-
| 42
| Fetch screen 1 cell (21, Y)
|-
| 43
| Fetch tile data for above
|-
| 44
| Fetch screen 1 cell (22, Y)
|-
| 45
| Fetch tile data for above
|-
| 46
| Fetch screen 1 cell (23, Y)
|-
| 47
| Fetch tile data for above
|-
| 48
| Fetch screen 1 cell (24, Y)
|-
| 49
| Fetch tile data for above
|-
| 50
| Fetch screen 1 cell (25, Y)
|-
| 51
| Fetch tile data for above
|-
| 52
| Fetch screen 1 cell (26, Y)
|-
| 53
| Fetch tile data for above
|-
| 54
| Fetch screen 1 cell (27, Y)
|-
| 55
| Fetch tile data for above
|-
| 56
| Fetch screen 1 cell (28, Y)
|-
| 57
| Fetch tile data for above
|-
| 58
| Fetch screen 1 cell (29, Y)
|-
| 59
| Fetch tile data for above
|-
| 60
| Fetch screen 1 cell (30, Y)
|-
| 61
| Fetch tile data for above
|-
| 62
| Fetch screen 1 cell (31, Y)
|-
| 63
| Fetch tile data for above
|-
| 64
| Fetch screen 1 cell (0, Y)
|-
| 65
| Fetch tile data for above
|-
| 66
| Fetch screen 2 cell (0, Y)
|-
| 67
| Fetch tile data for above
|-
| 68
| Fetch screen 2 cell (1, Y)
|-
| 69
| Fetch tile data for above
|-
| 70
| Fetch screen 2 cell (2, Y)
|-
| 71
| Fetch tile data for above
|-
| 72
| Fetch screen 2 cell (3, Y)
|-
| 73
| Fetch tile data for above
|-
| 74
| Fetch screen 2 cell (4, Y)
|-
| 75
| Fetch tile data for above
|-
| 76
| Fetch screen 2 cell (5, Y)
|-
| 77
| Fetch tile data for above
|-
| 78
| Fetch screen 2 cell (6, Y)
|-
| 79
| Fetch tile data for above
|-
| 80
| Fetch screen 2 cell (7, Y)
|-
| 81
| Fetch tile data for above
|-
| 82
| Fetch screen 2 cell (8, Y)
|-
| 83
| Fetch tile data for above
|-
| 84
| Fetch screen 2 cell (9, Y)
|-
| 85
| Fetch tile data for above
|-
| 86
| Fetch screen 2 cell (10, Y)
|-
| 87
| Fetch tile data for above
|-
| 88
| Fetch screen 2 cell (11, Y)
|-
| 89
| Fetch tile data for above
|-
| 90
| Fetch screen 2 cell (12, Y)
|-
| 91
| Fetch tile data for above
|-
| 92
| Fetch screen 2 cell (13, Y)
|-
| 93
| Fetch tile data for above
|-
| 94
| Fetch screen 2 cell (14, Y)
|-
| 95
| Fetch tile data for above
|-
| 96
| Fetch screen 2 cell (15, Y)
|-
| 97
| Fetch tile data for above
|-
| 98
| Fetch screen 2 cell (16, Y)
|-
| 99
| Fetch tile data for above
|-
| 100
| Fetch screen 2 cell (17, Y)
|-
| 101
| Fetch tile data for above
|-
| 102
| Fetch screen 2 cell (18, Y)
|-
| 103
| Fetch tile data for above
|-
| 104
| Fetch screen 2 cell (19, Y)
|-
| 105
| Fetch tile data for above
|-
| 106
| Fetch screen 2 cell (20, Y)
|-
| 107
| Fetch tile data for above
|-
| 108
| Fetch screen 2 cell (21, Y)
|-
| 109
| Fetch tile data for above
|-
| 110
| Fetch screen 2 cell (22, Y)
|-
| 111
| Fetch tile data for above
|-
| 112
| Fetch screen 2 cell (23, Y)
|-
| 113
| Fetch tile data for above
|-
| 114
| Fetch screen 2 cell (24, Y)
|-
| 115
| Fetch tile data for above
|-
| 116
| Fetch screen 2 cell (25, Y)
|-
| 117
| rowspan="5" style="vertical-align:top;" | (SDMA) Initialize
| Fetch tile data for above
|-
| 118
| Fetch screen 2 cell (26, Y)
|-
| 119
| Fetch tile data for above
|-
| 120
| Fetch screen 2 cell (27, Y)
|-
| 121
| Fetch tile data for above
|-
| 122
| (SDMA) Fetch RAM byte
| Fetch screen 2 cell (28, Y)
| Reset sound output
|-
| 123
| (SDMA) Write sound port
| Fetch tile data for above
| Fetch channel 1 wavetable sample
|-
| 124
| rowspan="121" style="vertical-align:top;" | V30MZ
| Fetch screen 2 cell (29, Y)
| Fetch channel 2 wavetable sample<br/>
Add channel 1 output
|-
| 125
| Fetch tile data for above
| Fetch channel 3 wavetable sample<br/>
Add channel 2 output
|-
| 126
| Fetch screen 2 cell (30, Y)
| Fetch channel 4 wavetable sample<br/>
Add channel 3 output
|-
| 127
| Fetch tile data for above
| Add channel 4 output
|-
| 128
| Fetch screen 2 cell (31, Y)
| rowspan="122" |
|-
| 129
| Fetch tile data for above
|-
| 130
| Fetch screen 2 cell (0, Y)
|-
| 131
| Fetch tile data for above
|-
| 132
! rowspan="26" | TODO
|-
| 133
|-
| 134
|-
| 135
|-
| 136
|-
| 137
|-
| 138
|-
| 139
|-
| 140
|-
| 141
|-
| 142
|-
| 143
|-
| 144
|-
| 145
|-
| 146
|-
| 147
|-
| 148
|-
| 149
|-
| 150
|-
| 151
|-
| 152
|-
| 153
|-
| 154
|-
| 155
|-
| 156
|-
| 157
|-
| 158
| Fetch tile data for sprite -1
|-
| 159
! TODO
|-
| 160
| Fetch tile data for sprite -2
|-
| 161
! TODO
|-
| 162
| Fetch tile data for sprite -3
|-
| 163
! rowspan="3" | TODO
|-
| 164
|-
| 165
|-
| 166
| Fetch tile data for sprite -4
|-
| 167
! TODO
|-
| 168
| Fetch tile data for sprite -5
|-
| 169
! TODO
|-
| 170
| Fetch tile data for sprite -6
|-
| 171
! rowspan="3" | TODO
|-
| 172
|-
| 173
|-
| 174
| Fetch tile data for sprite -7
|-
| 175
! TODO
|-
| 176
| Fetch tile data for sprite -8
|-
| 177
! TODO
|-
| 178
| Fetch tile data for sprite -9
|-
| 179
! rowspan="3" | TODO
|-
| 180
|-
| 181
|-
| 182
| Fetch tile data for sprite -10
|-
| 183
! TODO
|-
| 184
| Fetch tile data for sprite -11
|-
| 185
! TODO
|-
| 186
| Fetch tile data for sprite -12
|-
| 187
! rowspan="3" | TODO
|-
| 188
|-
| 189
|-
| 190
| Fetch tile data for sprite -13
|-
| 191
! TODO
|-
| 192
| Fetch tile data for sprite -14
|-
| 193
! TODO
|-
| 194
| Fetch tile data for sprite -15
|-
| 195
! rowspan="3" | TODO
|-
| 196
|-
| 197
|-
| 198
| Fetch tile data for sprite -16
|-
| 199
! TODO
|-
| 200
| Fetch tile data for sprite -17
|-
| 201
! TODO
|-
| 202
| Fetch tile data for sprite -18
|-
| 203
! rowspan="3" | TODO
|-
| 204
|-
| 205
|-
| 206
| Fetch tile data for sprite -19
|-
| 207
! TODO
|-
| 208
| Fetch tile data for sprite -20
|-
| 209
! TODO
|-
| 210
| Fetch tile data for sprite -21
|-
| 211
! rowspan="3" | TODO
|-
| 212
|-
| 213
|-
| 214
| Fetch tile data for sprite -22
|-
| 215
! TODO
|-
| 216
| Fetch tile data for sprite -23
|-
| 217
! TODO
|-
| 218
| Fetch tile data for sprite -24
|-
| 219
! rowspan="3" | TODO
|-
| 220
|-
| 221
|-
| 222
| Fetch tile data for sprite -25
|-
| 223
! TODO
|-
| 224
| Fetch tile data for sprite -26
! rowspan="32" | TODO
|-
| 225
! TODO
|-
| 226
| Fetch tile data for sprite -27
|-
| 227
! rowspan="3" | TODO
|-
| 228
|-
| 229
|-
| 230
| Fetch tile data for sprite -28
|-
| 231
! TODO
|-
| 232
| Fetch tile data for sprite -29
|-
| 233
! TODO
|-
| 234
| Fetch tile data for sprite -30
|-
| 235
! rowspan="3" | TODO
|-
| 236
|-
| 237
|-
| 238
| Fetch tile data for sprite -31
|-
| 239
! TODO
|-
| 240
| Fetch tile data for sprite -32
|-
| 241
! rowspan="15" | TODO
|-
| 242
|-
| 243
|-
| 244
|-
| 245
| rowspan="5" style="vertical-align:top;" | (SDMA) Initialize
|-
| 246
|-
| 247
|-
| 248
|-
| 249
|-
| 250
| (SDMA) Fetch RAM byte
| Reset sound output
|-
| 251
| (SDMA) Write sound port
| Fetch channel 1 wavetable sample
|-
| 252
| rowspan="4" style="vertical-align:top;" | V30MZ
| Fetch channel 2 wavetable sample<br/>
Add channel 1 output
|-
| 253
| Fetch channel 3 wavetable sample<br/>
Add channel 2 output
|-
| 254
| Fetch channel 4 wavetable sample<br/>
Add channel 3 output
|-
| 255
| Add channel 4 output
|}
70508b43a2892aaafad4b97ea9a81617598518fc
158
157
2023-08-22T18:25:51Z
Asie
351
wikitext
text/x-wiki
== Line timing ==
Notes:
* Sprite indices are given negatively. Sprites are filtered for every line, and are drawn from last found to first found.
* Fetches may be off by one cycle. This stuff is complicated.
{| class="wikitable"
! rowspan="3" | Cycle
! colspan="7" | Quadrant
|-
! rowspan="2" | CPU
! colspan="4" | Display
! rowspan="2" | Sound
! rowspan="2" | Palette
|-
! Mono/2BPP
! Color/2BPP
! Color/4BPP
! Line 144
|-
| 0
| rowspan="117" style="vertical-align:top;" | V30MZ
! rowspan="256" style="text-align: center;" | TODO
| Fetch screen 1 cell (0, Y)
! rowspan="256" style="text-align: center;" | TODO
| rowspan="256" style="vertical-align:top;" | Sprite table DMA<br/>
Copy one word every cycle
| rowspan="122" style="vertical-align:top;" |
| rowspan="224" style="vertical-align:top;" | Fetch palette for pixel (N, Y - 1)
|-
| 1
| Fetch tile data for above
|-
| 2
| Fetch screen 1 cell (1, Y)
|-
| 3
| Fetch tile data for above
|-
| 4
| Fetch screen 1 cell (2, Y)
|-
| 5
| Fetch tile data for above
|-
| 6
| Fetch screen 1 cell (3, Y)
|-
| 7
| Fetch tile data for above
|-
| 8
| Fetch screen 1 cell (4, Y)
|-
| 9
| Fetch tile data for above
|-
| 10
| Fetch screen 1 cell (5, Y)
|-
| 11
| Fetch tile data for above
|-
| 12
| Fetch screen 1 cell (6, Y)
|-
| 13
| Fetch tile data for above
|-
| 14
| Fetch screen 1 cell (7, Y)
|-
| 15
| Fetch tile data for above
|-
| 16
| Fetch screen 1 cell (8, Y)
|-
| 17
| Fetch tile data for above
|-
| 18
| Fetch screen 1 cell (9, Y)
|-
| 19
| Fetch tile data for above
|-
| 20
| Fetch screen 1 cell (10, Y)
|-
| 21
| Fetch tile data for above
|-
| 22
| Fetch screen 1 cell (11, Y)
|-
| 23
| Fetch tile data for above
|-
| 24
| Fetch screen 1 cell (12, Y)
|-
| 25
| Fetch tile data for above
|-
| 26
| Fetch screen 1 cell (13, Y)
|-
| 27
| Fetch tile data for above
|-
| 28
| Fetch screen 1 cell (14, Y)
|-
| 29
| Fetch tile data for above
|-
| 30
| Fetch screen 1 cell (15, Y)
|-
| 31
| Fetch tile data for above
|-
| 32
| Fetch screen 1 cell (16, Y)
|-
| 33
| Fetch tile data for above
|-
| 34
| Fetch screen 1 cell (17, Y)
|-
| 35
| Fetch tile data for above
|-
| 36
| Fetch screen 1 cell (18, Y)
|-
| 37
| Fetch tile data for above
|-
| 38
| Fetch screen 1 cell (19, Y)
|-
| 39
| Fetch tile data for above
|-
| 40
| Fetch screen 1 cell (20, Y)
|-
| 41
| Fetch tile data for above
|-
| 42
| Fetch screen 1 cell (21, Y)
|-
| 43
| Fetch tile data for above
|-
| 44
| Fetch screen 1 cell (22, Y)
|-
| 45
| Fetch tile data for above
|-
| 46
| Fetch screen 1 cell (23, Y)
|-
| 47
| Fetch tile data for above
|-
| 48
| Fetch screen 1 cell (24, Y)
|-
| 49
| Fetch tile data for above
|-
| 50
| Fetch screen 1 cell (25, Y)
|-
| 51
| Fetch tile data for above
|-
| 52
| Fetch screen 1 cell (26, Y)
|-
| 53
| Fetch tile data for above
|-
| 54
| Fetch screen 1 cell (27, Y)
|-
| 55
| Fetch tile data for above
|-
| 56
| Fetch screen 1 cell (28, Y)
|-
| 57
| Fetch tile data for above
|-
| 58
| Fetch screen 1 cell (29, Y)
|-
| 59
| Fetch tile data for above
|-
| 60
| Fetch screen 1 cell (30, Y)
|-
| 61
| Fetch tile data for above
|-
| 62
| Fetch screen 1 cell (31, Y)
|-
| 63
| Fetch tile data for above
|-
| 64
| Fetch screen 1 cell (0, Y)
|-
| 65
| Fetch tile data for above
|-
| 66
| Fetch screen 2 cell (0, Y)
|-
| 67
| Fetch tile data for above
|-
| 68
| Fetch screen 2 cell (1, Y)
|-
| 69
| Fetch tile data for above
|-
| 70
| Fetch screen 2 cell (2, Y)
|-
| 71
| Fetch tile data for above
|-
| 72
| Fetch screen 2 cell (3, Y)
|-
| 73
| Fetch tile data for above
|-
| 74
| Fetch screen 2 cell (4, Y)
|-
| 75
| Fetch tile data for above
|-
| 76
| Fetch screen 2 cell (5, Y)
|-
| 77
| Fetch tile data for above
|-
| 78
| Fetch screen 2 cell (6, Y)
|-
| 79
| Fetch tile data for above
|-
| 80
| Fetch screen 2 cell (7, Y)
|-
| 81
| Fetch tile data for above
|-
| 82
| Fetch screen 2 cell (8, Y)
|-
| 83
| Fetch tile data for above
|-
| 84
| Fetch screen 2 cell (9, Y)
|-
| 85
| Fetch tile data for above
|-
| 86
| Fetch screen 2 cell (10, Y)
|-
| 87
| Fetch tile data for above
|-
| 88
| Fetch screen 2 cell (11, Y)
|-
| 89
| Fetch tile data for above
|-
| 90
| Fetch screen 2 cell (12, Y)
|-
| 91
| Fetch tile data for above
|-
| 92
| Fetch screen 2 cell (13, Y)
|-
| 93
| Fetch tile data for above
|-
| 94
| Fetch screen 2 cell (14, Y)
|-
| 95
| Fetch tile data for above
|-
| 96
| Fetch screen 2 cell (15, Y)
|-
| 97
| Fetch tile data for above
|-
| 98
| Fetch screen 2 cell (16, Y)
|-
| 99
| Fetch tile data for above
|-
| 100
| Fetch screen 2 cell (17, Y)
|-
| 101
| Fetch tile data for above
|-
| 102
| Fetch screen 2 cell (18, Y)
|-
| 103
| Fetch tile data for above
|-
| 104
| Fetch screen 2 cell (19, Y)
|-
| 105
| Fetch tile data for above
|-
| 106
| Fetch screen 2 cell (20, Y)
|-
| 107
| Fetch tile data for above
|-
| 108
| Fetch screen 2 cell (21, Y)
|-
| 109
| Fetch tile data for above
|-
| 110
| Fetch screen 2 cell (22, Y)
|-
| 111
| Fetch tile data for above
|-
| 112
| Fetch screen 2 cell (23, Y)
|-
| 113
| Fetch tile data for above
|-
| 114
| Fetch screen 2 cell (24, Y)
|-
| 115
| Fetch tile data for above
|-
| 116
| Fetch screen 2 cell (25, Y)
|-
| 117
| rowspan="5" style="vertical-align:top;" | (SDMA) Initialize
| Fetch tile data for above
|-
| 118
| Fetch screen 2 cell (26, Y)
|-
| 119
| Fetch tile data for above
|-
| 120
| Fetch screen 2 cell (27, Y)
|-
| 121
| Fetch tile data for above
|-
| 122
| (SDMA) Fetch RAM byte
| Fetch screen 2 cell (28, Y)
| Reset sound output
|-
| 123
| (SDMA) Write sound port
| Fetch tile data for above
| Fetch channel 1 wavetable sample
|-
| 124
| rowspan="121" style="vertical-align:top;" | V30MZ
| Fetch screen 2 cell (29, Y)
| Fetch channel 2 wavetable sample<br/>
Add channel 1 output
|-
| 125
| Fetch tile data for above
| Fetch channel 3 wavetable sample<br/>
Add channel 2 output
|-
| 126
| Fetch screen 2 cell (30, Y)
| Fetch channel 4 wavetable sample<br/>
Add channel 3 output
|-
| 127
| Fetch tile data for above
| Add channel 4 output
|-
| 128
| Fetch screen 2 cell (31, Y)
| rowspan="122" |
|-
| 129
| Fetch tile data for above
|-
| 130
| Fetch screen 2 cell (0, Y)
|-
| 131
| Fetch tile data for above
|-
| 132
! rowspan="26" | TODO
|-
| 133
|-
| 134
|-
| 135
|-
| 136
|-
| 137
|-
| 138
|-
| 139
|-
| 140
|-
| 141
|-
| 142
|-
| 143
|-
| 144
|-
| 145
|-
| 146
|-
| 147
|-
| 148
|-
| 149
|-
| 150
|-
| 151
|-
| 152
|-
| 153
|-
| 154
|-
| 155
|-
| 156
|-
| 157
|-
| 158
| Fetch tile data for sprite -1
|-
| 159
! TODO
|-
| 160
| Fetch tile data for sprite -2
|-
| 161
! TODO
|-
| 162
| Fetch tile data for sprite -3
|-
| 163
! rowspan="3" | TODO
|-
| 164
|-
| 165
|-
| 166
| Fetch tile data for sprite -4
|-
| 167
! TODO
|-
| 168
| Fetch tile data for sprite -5
|-
| 169
! TODO
|-
| 170
| Fetch tile data for sprite -6
|-
| 171
! rowspan="3" | TODO
|-
| 172
|-
| 173
|-
| 174
| Fetch tile data for sprite -7
|-
| 175
! TODO
|-
| 176
| Fetch tile data for sprite -8
|-
| 177
! TODO
|-
| 178
| Fetch tile data for sprite -9
|-
| 179
! rowspan="3" | TODO
|-
| 180
|-
| 181
|-
| 182
| Fetch tile data for sprite -10
|-
| 183
! TODO
|-
| 184
| Fetch tile data for sprite -11
|-
| 185
! TODO
|-
| 186
| Fetch tile data for sprite -12
|-
| 187
! rowspan="3" | TODO
|-
| 188
|-
| 189
|-
| 190
| Fetch tile data for sprite -13
|-
| 191
! TODO
|-
| 192
| Fetch tile data for sprite -14
|-
| 193
! TODO
|-
| 194
| Fetch tile data for sprite -15
|-
| 195
! rowspan="3" | TODO
|-
| 196
|-
| 197
|-
| 198
| Fetch tile data for sprite -16
|-
| 199
! TODO
|-
| 200
| Fetch tile data for sprite -17
|-
| 201
! TODO
|-
| 202
| Fetch tile data for sprite -18
|-
| 203
! rowspan="3" | TODO
|-
| 204
|-
| 205
|-
| 206
| Fetch tile data for sprite -19
|-
| 207
! TODO
|-
| 208
| Fetch tile data for sprite -20
|-
| 209
! TODO
|-
| 210
| Fetch tile data for sprite -21
|-
| 211
! rowspan="3" | TODO
|-
| 212
|-
| 213
|-
| 214
| Fetch tile data for sprite -22
|-
| 215
! TODO
|-
| 216
| Fetch tile data for sprite -23
|-
| 217
! TODO
|-
| 218
| Fetch tile data for sprite -24
|-
| 219
! rowspan="3" | TODO
|-
| 220
|-
| 221
|-
| 222
| Fetch tile data for sprite -25
|-
| 223
! TODO
|-
| 224
| Fetch tile data for sprite -26
! rowspan="32" | TODO
|-
| 225
! TODO
|-
| 226
| Fetch tile data for sprite -27
|-
| 227
! rowspan="3" | TODO
|-
| 228
|-
| 229
|-
| 230
| Fetch tile data for sprite -28
|-
| 231
! TODO
|-
| 232
| Fetch tile data for sprite -29
|-
| 233
! TODO
|-
| 234
| Fetch tile data for sprite -30
|-
| 235
! rowspan="3" | TODO
|-
| 236
|-
| 237
|-
| 238
| Fetch tile data for sprite -31
|-
| 239
! TODO
|-
| 240
| Fetch tile data for sprite -32
|-
| 241
! rowspan="15" | TODO
|-
| 242
|-
| 243
|-
| 244
|-
| 245
| rowspan="5" style="vertical-align:top;" | (SDMA) Initialize
|-
| 246
|-
| 247
|-
| 248
|-
| 249
|-
| 250
| (SDMA) Fetch RAM byte
| Reset sound output
|-
| 251
| (SDMA) Write sound port
| Fetch channel 1 wavetable sample
|-
| 252
| rowspan="4" style="vertical-align:top;" | V30MZ
| Fetch channel 2 wavetable sample<br/>
Add channel 1 output
|-
| 253
| Fetch channel 3 wavetable sample<br/>
Add channel 2 output
|-
| 254
| Fetch channel 4 wavetable sample<br/>
Add channel 3 output
|-
| 255
| Add channel 4 output
|}
c1951496d14387bde92fcf7868cf8fe0502ca2fd
Timing
0
7
156
140
2023-08-22T18:20:16Z
Asie
351
wikitext
text/x-wiki
== Clocks ==
The WonderSwan is clocked with a ''master clock'' of approximately 12288000 Hz (= 12.288 MHz).
This clock is split into four internal memory access quadrants, running at 3072000 Hz (= 3.072 MHz) each. Three of those are used by the console in "mono" mode:
* [[CPU|NEC V30MZ]] - referred to as the ''CPU clock'',
* [[Display]],
* [[Sound]].
On the WonderSwan Color, the fourth quadrant is used to handle color palette reads during display drawing.
Only the CPU quadrant can access the cartridge bus; this means that [[DMA]] necessarily stalls the CPU.
In addition, a separate 384000 Hz (3072000 / 8) ''cartridge clock'' is provided on one of the cartridge pins.
== Display timing ==
By default, a WonderSwan frame consists of 159 lines, 144 of which are visible. Each line consists of 256 clock cycles, of which 224 are used to draw a pixel at a time. This leads to a total duration of 40704 clock cycles per frame, for an effective default refresh rate of approximately 75.472 Hz.
Vertical blanks are always triggered on line 144; if the display is set to be shorter than 144 lines, vertical blank interrupts will never be triggered.
TODO: back/front porches, etc.
== Frame timing ==
The details of per-line and per-frame timing are available in a table on the [[Frame timing]] page.
b31a880c4ad1ef04654c9cbde1411ebc890fadad
EEPROM
0
35
159
150
2023-08-22T19:09:24Z
Asie
351
wikitext
text/x-wiki
The WonderSwan utilizes M93LCx6-compatible EEPROMs:
* in the SoC:
** 1 Kbit internal EEPROM (M93LC46-compatible) on the WonderSwan,
** 16 Kbit internal EEPROM (M93LC86-compatible) on the WonderSwan Color,
* on cartridges:
** 1 Kbit cartridge EEPROM (M93LC46-compatible)
** 8 Kbit cartridge EEPROM (M93LC76-compatible)
** 16 Kbit cartridge EEPROM (M93LC86-compatible)
Additional variants exists which were not seen on any production cartridge:
* 2 Kbit EEPROM (M93LC56-compatible)
* 4 Kbit EEPROM (M93LC66-compatible)
== Commands ==
=== READ - Read Word ===
The READ command takes an address of a word (address 0 => bytes 0, 1; address 1 => bytes 2, 3; ...) and returns the word at that address.
=== WRITE - Write Word ===
The WRITE command takes an address of a word (address 0 => bytes 0, 1; address 1 => bytes 2, 3; ...) and the word to write to it, then writes the word.
=== ERASE - Erase Word ===
The ERASE command takes an address of a word (address 0 => bytes 0, 1; address 1 => bytes 2, 3; ...) and erases the word at that address, setting it to 0xFFFF.
=== WDS - Write Disable ===
TODO
=== WRAL - Write All ===
TODO
=== ERAL - Erase All ===
TODO
=== WEN - Write Enable ===
TODO
== I/O ports ==
The I/O ports listed refer to the internal EEPROM; for the cartridge EEPROM port numbers, refer to the [[Bandai 2001|mapper documentation]].
{{Anchor|Internal EEPROM Data}}
=== Internal EEPROM Data ($BA, $BB) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
dddd dddd dddd dddd
|||| |||| |||| ||||
++++-++++--++++-++++- Data read from/written to the EEPROM.
</pre>
This port functions as a shared buffer for both "read" and "write" modes. (TODO: Verify)
{{Anchor|Internal EEPROM Command}}
=== Internal EEPROM Command ($BC, $BD) ===
<pre>
Command Pattern 1
15 bit 8 7 bit 0
---- ---- ---- ----
0000 0001 ooaa aaaa (1 Kbit - M93LC46)
0000 01oo aaaa aaaa (2, 4 Kbit - M93LC56/66)
0001 ooaa aaaa aaaa (8, 16 Kbit - M93LC76/86)
|||| |||| ||||
||++--++++-++++- Address (MSb .. LSb)
++-------------- Opcode:
01 - WRITE
10 - READ
11 - ERASE
</pre>
<pre>
Command Pattern 2
15 bit 8 7 bit 0
---- ---- ---- ----
0000 0001 00ss .... (1 Kbit - M93LC46)
0000 0100 ss.. .... (2, 4 Kbit - M93LC56/66)
0001 00ss .... .... (8, 16 Kbit - M93LC76/86)
||
++------------ Sub-Opcode:
00 - WDS
01 - WRAL
01 - ERAL
11 - WEN
</pre>
{{Anchor|Internal EEPROM Control}}
=== Internal EEPROM Control ($BE, $BF write) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
.... .... pewr ....
||||
|||+------ 1 for READ command, 0 otherwise
||+------- 1 for WRITE and WRAL command, 0 otherwise
|+-------- 1 for ERASE, WDS, ERAL and WEN command, 0 otherwise
+--------- 1 to enable internal EEPROM write protection.
Cannot be cleared once set.
</pre>
{{Anchor|Internal EEPROM Status}}
=== Internal EEPROM Status ($BE, $BF read) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
.... .... p... ..RD
| ||
| |+- 1 if a READ command has completed.
| +-- 0 if the EEPROM is busy,
| 1 if a command can be accepted (idle).
+--------- Internal EEPROM write protection:
0 = disabled, 1 = enabled
</pre>
== Hardware notes ==
EEPROM command bits are shifted out starting from the ''most'' significant bit of the port.
<pre>
+----> EEPROM Serial Data
|
[0] <= [0000 0001 ooaa aaaa]
EEPROM Command Port
</pre>
While the M93LCx6 family supports byte organization, the WonderSwan always uses word organization. As such, this implementation detail is omitted in this documentation.
== Links ==
* [https://www.st.com/resource/en/datasheet/m93c46-w.pdf STMicroelectronics M93LCx6 datasheet]
92a61e487fe5574da58651ecd0302bcc1911428a
160
159
2023-08-22T19:17:34Z
Asie
351
wikitext
text/x-wiki
The WonderSwan utilizes M93LCx6-compatible EEPROMs:
* in the SoC:
** 1 Kbit internal EEPROM (M93LC46-compatible) on the WonderSwan,
** 16 Kbit internal EEPROM (M93LC86-compatible) on the WonderSwan Color,
* on cartridges:
** 1 Kbit cartridge EEPROM (M93LC46-compatible)
** 8 Kbit cartridge EEPROM (M93LC76-compatible)
** 16 Kbit cartridge EEPROM (M93LC86-compatible)
Additional variants exists which were not seen on any production cartridge:
* 2 Kbit EEPROM (M93LC56-compatible)
* 4 Kbit EEPROM (M93LC66-compatible)
== Commands ==
=== READ - Read Word ===
The READ command takes an address of a word (address 0 => bytes 0, 1; address 1 => bytes 2, 3; ...) and returns the word at that address.
=== WRITE - Write Word ===
The WRITE command takes an address of a word (address 0 => bytes 0, 1; address 1 => bytes 2, 3; ...) and the word to write to it, then writes the word.
=== ERASE - Erase Word ===
The ERASE command takes an address of a word (address 0 => bytes 0, 1; address 1 => bytes 2, 3; ...) and erases the word at that address, setting it to 0xFFFF.
=== WDS - Write Disable ===
TODO
=== WRAL - Write All ===
TODO
=== ERAL - Erase All ===
TODO
=== WEN - Write Enable ===
TODO
== I/O ports ==
The I/O ports listed refer to the internal EEPROM; for the cartridge EEPROM port numbers, refer to the [[Bandai 2001|mapper documentation]].
{{Anchor|Internal EEPROM Data}}
=== Internal EEPROM Data ($BA, $BB) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
dddd dddd dddd dddd
|||| |||| |||| ||||
++++-++++--++++-++++- Data read from/written to the EEPROM.
</pre>
This port functions as a shared buffer for both "read" and "write" modes. (TODO: Verify)
{{Anchor|Internal EEPROM Command}}
=== Internal EEPROM Command ($BC, $BD) ===
<pre>
Command Pattern 1
15 bit 8 7 bit 0
---- ---- ---- ----
0000 0001 ooaa aaaa (1 Kbit - M93LC46)
0000 01oo aaaa aaaa (2, 4 Kbit - M93LC56/66)
0001 ooaa aaaa aaaa (8, 16 Kbit - M93LC76/86)
|||| |||| ||||
||++--++++-++++- Address (MSb .. LSb)
++-------------- Opcode:
01 - WRITE
10 - READ
11 - ERASE
</pre>
<pre>
Command Pattern 2
15 bit 8 7 bit 0
---- ---- ---- ----
0000 0001 00ss .... (1 Kbit - M93LC46)
0000 0100 ss.. .... (2, 4 Kbit - M93LC56/66)
0001 00ss .... .... (8, 16 Kbit - M93LC76/86)
||
++------------ Sub-Opcode:
00 - WDS
01 - WRAL
01 - ERAL
11 - WEN
</pre>
{{Anchor|Internal EEPROM Control}}
=== Internal EEPROM Control ($BE, $BF write) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
.... .... pewr ....
||||
|||+------ 1 for READ command, 0 otherwise
||+------- 1 for WRITE and WRAL command, 0 otherwise
|+-------- 1 for ERASE, WDS, ERAL and WEN command, 0 otherwise
+--------- 1 to enable internal EEPROM write protection.
Cannot be cleared once set.
</pre>
{{Anchor|Internal EEPROM Status}}
=== Internal EEPROM Status ($BE, $BF read) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
.... .... p... ..RD
| ||
| |+- 1 if a READ command has completed.
| +-- 0 if the EEPROM is busy,
| 1 if a command can be accepted (idle).
+--------- Internal EEPROM write protection:
0 = disabled, 1 = enabled
</pre>
== Internal EEPROM Layout ==
{| class="wikitable"
|-
! Offset !! Length !! Contents
|-
| $00 || 96 || Program data. Can be written by programs even if write protection has been enabled.
|-
| $60 || 16 || Owner name, custom character set.
|-
| $70 || 1 || Owner birthday year, BCD, first/higher two digits
|-
| $71 || 1 || Owner birthday year, BCD, last/lower two digits
|-
| $72 || 1 || Owner birthday month, BCD
|-
| $73 || 1 || Owner birthday day, BCD
|-
| $74 || 1 || Owner gender:<br/>
0 - ?<br/>
1 - Male<br/>
2 - Female
|-
| $75 || 1 || Owner blood type:<br/>
0 - ?<br/>
1 - A<br/>
2 - B<br/>
3 - AB<br/>
4 - 0
|-
| $76 || 1 | Last booted cartridge developer/publisher ID
|-
| $77 || 1 | Last booted cartridge game ID
|-
| $78 || 1 | Last booted cartridge game version
|-
| $7C || 1 | Stored cartridge ID/version change counter
|-
| $7D || 1 | Owner name change counter
|-
| $7E || 2 | System startup counter
|-
| $83 || 1 | Color console configuration
|-
| $84 || ? | [[Splash animation|Custom splash animation]], if present
|}
=== Owner name character set ===
{| class="wikitable"
|-
!
! <code>.0</code>
! <code>.1</code>
! <code>.2</code>
! <code>.3</code>
! <code>.4</code>
! <code>.5</code>
! <code>.6</code>
! <code>.7</code>
! <code>.8</code>
! <code>.9</code>
! <code>.A</code>
! <code>.B</code>
! <code>.C</code>
! <code>.D</code>
! <code>.E</code>
! <code>.F</code>
|-
! <code>0.</code>
| || 0 || 1 || 2 || 3 || 4 || 5 || 6 || 7 || 8 || 9 || A || B || C || D || E
|-
! <code>1.</code>
| F || G || H || I || J || K || L || M || N || O || P || Q || R || S || T || U
|-
! <code>2.</code>
| V || W || X || Y || Z || ♥ || ♪ || + || - || ? || .
!
!
!
!
!
|}
=== Color console configuration ===
<pre>
7 bit 0
---- ----
sc.. ..vv
|| ||
|| ++- Volume level
|+-------- Contrast (WSC): 0 = Low, 1 = High
+--------- Custom splash animation enabled
</pre>
== Hardware notes ==
EEPROM command bits are shifted out starting from the ''most'' significant bit of the port.
<pre>
+----> EEPROM Serial Data
|
[0] <= [0000 0001 ooaa aaaa]
EEPROM Command Port
</pre>
While the M93LCx6 family supports byte organization, the WonderSwan always uses word organization. As such, this implementation detail is omitted in this documentation.
== Links ==
* [https://www.st.com/resource/en/datasheet/m93c46-w.pdf STMicroelectronics M93LCx6 datasheet]
4ddf82adaf0bc56b6a0250630bdd217913ecc73e
161
160
2023-08-22T19:29:30Z
Lidnariq
7
/* I/O ports */ timing caveat
wikitext
text/x-wiki
The WonderSwan utilizes M93LCx6-compatible EEPROMs:
* in the SoC:
** 1 Kbit internal EEPROM (M93LC46-compatible) on the WonderSwan,
** 16 Kbit internal EEPROM (M93LC86-compatible) on the WonderSwan Color,
* on cartridges:
** 1 Kbit cartridge EEPROM (M93LC46-compatible)
** 8 Kbit cartridge EEPROM (M93LC76-compatible)
** 16 Kbit cartridge EEPROM (M93LC86-compatible)
Additional variants exists which were not seen on any production cartridge:
* 2 Kbit EEPROM (M93LC56-compatible)
* 4 Kbit EEPROM (M93LC66-compatible)
== Commands ==
=== READ - Read Word ===
The READ command takes an address of a word (address 0 => bytes 0, 1; address 1 => bytes 2, 3; ...) and returns the word at that address.
=== WRITE - Write Word ===
The WRITE command takes an address of a word (address 0 => bytes 0, 1; address 1 => bytes 2, 3; ...) and the word to write to it, then writes the word.
=== ERASE - Erase Word ===
The ERASE command takes an address of a word (address 0 => bytes 0, 1; address 1 => bytes 2, 3; ...) and erases the word at that address, setting it to 0xFFFF.
=== WDS - Write Disable ===
TODO
=== WRAL - Write All ===
TODO
=== ERAL - Erase All ===
TODO
=== WEN - Write Enable ===
TODO
== I/O ports ==
The I/O ports listed refer to the internal EEPROM; for the cartridge EEPROM port numbers, refer to the [[Bandai 2001|mapper documentation]].
Note that on the original WonderSwan, the data and command registers can ''only'' be accessed word-wide via even addresses: access to odd addresses whether byte or word-wide don't provide valid data.
{{Anchor|Internal EEPROM Data}}
=== Internal EEPROM Data ($BA, $BB) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
dddd dddd dddd dddd
|||| |||| |||| ||||
++++-++++--++++-++++- Data read from/written to the EEPROM.
</pre>
This port functions as a shared buffer for both "read" and "write" modes. (TODO: Verify)
{{Anchor|Internal EEPROM Command}}
=== Internal EEPROM Command ($BC, $BD) ===
<pre>
Command Pattern 1
15 bit 8 7 bit 0
---- ---- ---- ----
0000 0001 ooaa aaaa (1 Kbit - M93LC46)
0000 01oo aaaa aaaa (2, 4 Kbit - M93LC56/66)
0001 ooaa aaaa aaaa (8, 16 Kbit - M93LC76/86)
|||| |||| ||||
||++--++++-++++- Address (MSb .. LSb)
++-------------- Opcode:
01 - WRITE
10 - READ
11 - ERASE
</pre>
<pre>
Command Pattern 2
15 bit 8 7 bit 0
---- ---- ---- ----
0000 0001 00ss .... (1 Kbit - M93LC46)
0000 0100 ss.. .... (2, 4 Kbit - M93LC56/66)
0001 00ss .... .... (8, 16 Kbit - M93LC76/86)
||
++------------ Sub-Opcode:
00 - WDS
01 - WRAL
01 - ERAL
11 - WEN
</pre>
{{Anchor|Internal EEPROM Control}}
=== Internal EEPROM Control ($BE, $BF write) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
.... .... pewr ....
||||
|||+------ 1 for READ command, 0 otherwise
||+------- 1 for WRITE and WRAL command, 0 otherwise
|+-------- 1 for ERASE, WDS, ERAL and WEN command, 0 otherwise
+--------- 1 to enable internal EEPROM write protection.
Cannot be cleared once set.
</pre>
{{Anchor|Internal EEPROM Status}}
=== Internal EEPROM Status ($BE, $BF read) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
.... .... p... ..RD
| ||
| |+- 1 if a READ command has completed.
| +-- 0 if the EEPROM is busy,
| 1 if a command can be accepted (idle).
+--------- Internal EEPROM write protection:
0 = disabled, 1 = enabled
</pre>
== Internal EEPROM Layout ==
{| class="wikitable"
|-
! Offset !! Length !! Contents
|-
| $00 || 96 || Program data. Can be written by programs even if write protection has been enabled.
|-
| $60 || 16 || Owner name, custom character set.
|-
| $70 || 1 || Owner birthday year, BCD, first/higher two digits
|-
| $71 || 1 || Owner birthday year, BCD, last/lower two digits
|-
| $72 || 1 || Owner birthday month, BCD
|-
| $73 || 1 || Owner birthday day, BCD
|-
| $74 || 1 || Owner gender:<br/>
0 - ?<br/>
1 - Male<br/>
2 - Female
|-
| $75 || 1 || Owner blood type:<br/>
0 - ?<br/>
1 - A<br/>
2 - B<br/>
3 - AB<br/>
4 - 0
|-
| $76 || 1 | Last booted cartridge developer/publisher ID
|-
| $77 || 1 | Last booted cartridge game ID
|-
| $78 || 1 | Last booted cartridge game version
|-
| $7C || 1 | Stored cartridge ID/version change counter
|-
| $7D || 1 | Owner name change counter
|-
| $7E || 2 | System startup counter
|-
| $83 || 1 | Color console configuration
|-
| $84 || ? | [[Splash animation|Custom splash animation]], if present
|}
=== Owner name character set ===
{| class="wikitable"
|-
!
! <code>.0</code>
! <code>.1</code>
! <code>.2</code>
! <code>.3</code>
! <code>.4</code>
! <code>.5</code>
! <code>.6</code>
! <code>.7</code>
! <code>.8</code>
! <code>.9</code>
! <code>.A</code>
! <code>.B</code>
! <code>.C</code>
! <code>.D</code>
! <code>.E</code>
! <code>.F</code>
|-
! <code>0.</code>
| || 0 || 1 || 2 || 3 || 4 || 5 || 6 || 7 || 8 || 9 || A || B || C || D || E
|-
! <code>1.</code>
| F || G || H || I || J || K || L || M || N || O || P || Q || R || S || T || U
|-
! <code>2.</code>
| V || W || X || Y || Z || ♥ || ♪ || + || - || ? || .
!
!
!
!
!
|}
=== Color console configuration ===
<pre>
7 bit 0
---- ----
sc.. ..vv
|| ||
|| ++- Volume level
|+-------- Contrast (WSC): 0 = Low, 1 = High
+--------- Custom splash animation enabled
</pre>
== Hardware notes ==
EEPROM command bits are shifted out starting from the ''most'' significant bit of the port.
<pre>
+----> EEPROM Serial Data
|
[0] <= [0000 0001 ooaa aaaa]
EEPROM Command Port
</pre>
While the M93LCx6 family supports byte organization, the WonderSwan always uses word organization. As such, this implementation detail is omitted in this documentation.
== Links ==
* [https://www.st.com/resource/en/datasheet/m93c46-w.pdf STMicroelectronics M93LCx6 datasheet]
33522c9b8dc8c1e4c856be4e15526ddf1d8872f1
162
161
2023-08-22T20:11:53Z
Asie
351
wikitext
text/x-wiki
The WonderSwan utilizes M93LCx6-compatible EEPROMs:
* in the SoC:
** 1 Kbit internal EEPROM (M93LC46-compatible) on the WonderSwan,
** 16 Kbit internal EEPROM (M93LC86-compatible) on the WonderSwan Color,
* on cartridges:
** 1 Kbit cartridge EEPROM (M93LC46-compatible)
** 8 Kbit cartridge EEPROM (M93LC76-compatible)
** 16 Kbit cartridge EEPROM (M93LC86-compatible)
Additional variants exists which were not seen on any production cartridge:
* 2 Kbit EEPROM (M93LC56-compatible)
* 4 Kbit EEPROM (M93LC66-compatible)
== Commands ==
=== READ - Read Word ===
The READ command takes an address of a word (address 0 => bytes 0, 1; address 1 => bytes 2, 3; ...) and returns the word at that address.
=== WRITE - Write Word ===
The WRITE command takes an address of a word (address 0 => bytes 0, 1; address 1 => bytes 2, 3; ...) and the word to write to it, then writes the word.
=== ERASE - Erase Word ===
The ERASE command takes an address of a word (address 0 => bytes 0, 1; address 1 => bytes 2, 3; ...) and erases the word at that address, setting it to 0xFFFF.
=== WDS - Write Disable ===
TODO
=== WRAL - Write All ===
This command is not guaranteed to be present on all EEPROMs.
TODO
=== ERAL - Erase All ===
This command is not guaranteed to be present on all EEPROMs.
TODO
=== WEN - Write Enable ===
TODO
== I/O ports ==
The I/O ports listed refer to the internal EEPROM; for the cartridge EEPROM port numbers, refer to the [[Bandai 2001|mapper documentation]].
Note that on the original/"mono" WonderSwan, the data and command registers can ''only'' be accessed word-wide via even addresses: access to odd addresses whether byte or word-wide don't provide valid data. This has been fixed on the WonderSwan Color, even for "mono" compatibility mode.
{{Anchor|Internal EEPROM Data}}
=== Internal EEPROM Data ($BA, $BB) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
dddd dddd dddd dddd
|||| |||| |||| ||||
++++-++++--++++-++++- Data read from/written to the EEPROM.
</pre>
This port functions as a shared buffer for both "read" and "write" modes. (TODO: Verify)
{{Anchor|Internal EEPROM Command}}
=== Internal EEPROM Command ($BC, $BD) ===
<pre>
Command Pattern 1
15 bit 8 7 bit 0
---- ---- ---- ----
0000 0001 ooaa aaaa (1 Kbit - M93LC46)
0000 01oo aaaa aaaa (2, 4 Kbit - M93LC56/66)
0001 ooaa aaaa aaaa (8, 16 Kbit - M93LC76/86)
|||| |||| ||||
||++--++++-++++- Address (MSb .. LSb)
++-------------- Opcode:
01 - WRITE
10 - READ
11 - ERASE
</pre>
<pre>
Command Pattern 2
15 bit 8 7 bit 0
---- ---- ---- ----
0000 0001 00ss .... (1 Kbit - M93LC46)
0000 0100 ss.. .... (2, 4 Kbit - M93LC56/66)
0001 00ss .... .... (8, 16 Kbit - M93LC76/86)
||
++------------ Sub-Opcode:
00 - WDS
01 - WRAL
01 - ERAL
11 - WEN
</pre>
{{Anchor|Internal EEPROM Control}}
=== Internal EEPROM Control ($BE, $BF write) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
.... .... pewr ....
||||
|||+------ Read mode: 1 for READ command, 0 otherwise
||+------- Write mode: 1 for WRITE and WRAL command, 0 otherwise
|+-------- Erase mode: 1 for ERASE, WDS, ERAL and WEN command, 0 otherwise
+--------- 1 to enable internal EEPROM write protection.
Cannot be cleared once set.
</pre>
The ''mode'' flags control the behaviour of the EEPROM interface:
* Read mode: Sends 16 bits from Command, then reads 16 bits to Data.
* Write mode: Sends 16 bits from Command, then 16 bits from Data. De-asserts Microwire chip select, then re-asserts it and waits for the EEPROM to confirm command completion.
* Erase mode: Sends 16 bits from Command, de-asserts Microwire chip select, then re-asserts it and waits for the EEPROM to confirm command completion.
{{Anchor|Internal EEPROM Status}}
=== Internal EEPROM Status ($BE, $BF read) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
.... .... p... ..RD
| ||
| |+- 1 if a READ command has completed.
| +-- 0 if the EEPROM is busy,
| 1 if a command can be accepted (idle).
+--------- Internal EEPROM write protection:
0 = disabled, 1 = enabled
</pre>
== Internal EEPROM Layout ==
{| class="wikitable"
|-
! Offset !! Length !! Contents
|-
| $00 || 96 || Program data. Can be written by programs even if write protection has been enabled.
|-
| $60 || 16 || Owner name, custom character set.
|-
| $70 || 1 || Owner birthday year, BCD, first/higher two digits
|-
| $71 || 1 || Owner birthday year, BCD, last/lower two digits
|-
| $72 || 1 || Owner birthday month, BCD
|-
| $73 || 1 || Owner birthday day, BCD
|-
| $74 || 1 || Owner gender:<br/>
0 - ?<br/>
1 - Male<br/>
2 - Female
|-
| $75 || 1 || Owner blood type:<br/>
0 - ?<br/>
1 - A<br/>
2 - B<br/>
3 - AB<br/>
4 - 0
|-
| $76 || 1 | Last booted cartridge developer/publisher ID
|-
| $77 || 1 | Last booted cartridge game ID
|-
| $78 || 1 | Last booted cartridge game version
|-
| $7C || 1 | Stored cartridge ID/version change counter
|-
| $7D || 1 | Owner name change counter
|-
| $7E || 2 | System startup counter
|-
| $83 || 1 | Color console configuration
|-
| $84 || ? | [[Splash animation|Custom splash animation]], if present
|}
=== Owner name character set ===
{| class="wikitable"
|-
!
! <code>.0</code>
! <code>.1</code>
! <code>.2</code>
! <code>.3</code>
! <code>.4</code>
! <code>.5</code>
! <code>.6</code>
! <code>.7</code>
! <code>.8</code>
! <code>.9</code>
! <code>.A</code>
! <code>.B</code>
! <code>.C</code>
! <code>.D</code>
! <code>.E</code>
! <code>.F</code>
|-
! <code>0.</code>
| || 0 || 1 || 2 || 3 || 4 || 5 || 6 || 7 || 8 || 9 || A || B || C || D || E
|-
! <code>1.</code>
| F || G || H || I || J || K || L || M || N || O || P || Q || R || S || T || U
|-
! <code>2.</code>
| V || W || X || Y || Z || ♥ || ♪ || + || - || ? || .
!
!
!
!
!
|}
=== Color console configuration ===
<pre>
7 bit 0
---- ----
sc.. ..vv
|| ||
|| ++- Volume level
|+-------- Contrast (WSC): 0 = Low, 1 = High
+--------- Custom splash animation enabled
</pre>
== Hardware notes ==
EEPROM command bits are shifted out starting from the ''most'' significant bit of the port.
<pre>
+----> EEPROM Serial Data
|
[0] <= [0000 0001 ooaa aaaa]
EEPROM Command Port
</pre>
While the M93LCx6 family supports byte organization, the WonderSwan always uses word organization. As such, this implementation detail is omitted in this documentation.
== Links ==
* [https://www.st.com/resource/en/datasheet/m93c46-w.pdf STMicroelectronics M93LCx6 datasheet]
97f5e503a8501bd068e8d55b76bf690c234657cc
163
162
2023-08-22T20:12:15Z
Asie
351
fix spacing
wikitext
text/x-wiki
The WonderSwan utilizes M93LCx6-compatible EEPROMs:
* in the SoC:
** 1 Kbit internal EEPROM (M93LC46-compatible) on the WonderSwan,
** 16 Kbit internal EEPROM (M93LC86-compatible) on the WonderSwan Color,
* on cartridges:
** 1 Kbit cartridge EEPROM (M93LC46-compatible)
** 8 Kbit cartridge EEPROM (M93LC76-compatible)
** 16 Kbit cartridge EEPROM (M93LC86-compatible)
Additional variants exists which were not seen on any production cartridge:
* 2 Kbit EEPROM (M93LC56-compatible)
* 4 Kbit EEPROM (M93LC66-compatible)
== Commands ==
=== READ - Read Word ===
The READ command takes an address of a word (address 0 => bytes 0, 1; address 1 => bytes 2, 3; ...) and returns the word at that address.
=== WRITE - Write Word ===
The WRITE command takes an address of a word (address 0 => bytes 0, 1; address 1 => bytes 2, 3; ...) and the word to write to it, then writes the word.
=== ERASE - Erase Word ===
The ERASE command takes an address of a word (address 0 => bytes 0, 1; address 1 => bytes 2, 3; ...) and erases the word at that address, setting it to 0xFFFF.
=== WDS - Write Disable ===
TODO
=== WRAL - Write All ===
This command is not guaranteed to be present on all EEPROMs.
TODO
=== ERAL - Erase All ===
This command is not guaranteed to be present on all EEPROMs.
TODO
=== WEN - Write Enable ===
TODO
== I/O ports ==
The I/O ports listed refer to the internal EEPROM; for the cartridge EEPROM port numbers, refer to the [[Bandai 2001|mapper documentation]].
Note that on the original/"mono" WonderSwan, the data and command registers can ''only'' be accessed word-wide via even addresses: access to odd addresses whether byte or word-wide don't provide valid data. This has been fixed on the WonderSwan Color, even for "mono" compatibility mode.
{{Anchor|Internal EEPROM Data}}
=== Internal EEPROM Data ($BA, $BB) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
dddd dddd dddd dddd
|||| |||| |||| ||||
++++-++++--++++-++++- Data read from/written to the EEPROM.
</pre>
This port functions as a shared buffer for both "read" and "write" modes. (TODO: Verify)
{{Anchor|Internal EEPROM Command}}
=== Internal EEPROM Command ($BC, $BD) ===
<pre>
Command Pattern 1
15 bit 8 7 bit 0
---- ---- ---- ----
0000 0001 ooaa aaaa (1 Kbit - M93LC46)
0000 01oo aaaa aaaa (2, 4 Kbit - M93LC56/66)
0001 ooaa aaaa aaaa (8, 16 Kbit - M93LC76/86)
|||| |||| ||||
||++--++++-++++- Address (MSb .. LSb)
++-------------- Opcode:
01 - WRITE
10 - READ
11 - ERASE
</pre>
<pre>
Command Pattern 2
15 bit 8 7 bit 0
---- ---- ---- ----
0000 0001 00ss .... (1 Kbit - M93LC46)
0000 0100 ss.. .... (2, 4 Kbit - M93LC56/66)
0001 00ss .... .... (8, 16 Kbit - M93LC76/86)
||
++------------ Sub-Opcode:
00 - WDS
01 - WRAL
01 - ERAL
11 - WEN
</pre>
{{Anchor|Internal EEPROM Control}}
=== Internal EEPROM Control ($BE, $BF write) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
.... .... pewr ....
||||
|||+------ Read mode: 1 for READ command, 0 otherwise
||+------- Write mode: 1 for WRITE and WRAL command, 0 otherwise
|+-------- Erase mode: 1 for ERASE, WDS, ERAL and WEN command, 0 otherwise
+--------- 1 to enable internal EEPROM write protection.
Cannot be cleared once set.
</pre>
The ''mode'' flags control the behaviour of the EEPROM interface:
* Read mode: Sends 16 bits from Command, then reads 16 bits to Data.
* Write mode: Sends 16 bits from Command, then 16 bits from Data. De-asserts Microwire chip select, then re-asserts it and waits for the EEPROM to confirm command completion.
* Erase mode: Sends 16 bits from Command, de-asserts Microwire chip select, then re-asserts it and waits for the EEPROM to confirm command completion.
{{Anchor|Internal EEPROM Status}}
=== Internal EEPROM Status ($BE, $BF read) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
.... .... p... ..RD
| ||
| |+- 1 if a READ command has completed.
| +-- 0 if the EEPROM is busy,
| 1 if a command can be accepted (idle).
+--------- Internal EEPROM write protection:
0 = disabled, 1 = enabled
</pre>
== Internal EEPROM Layout ==
{| class="wikitable"
|-
! Offset !! Length !! Contents
|-
| $00 || 96 || Program data. Can be written by programs even if write protection has been enabled.
|-
| $60 || 16 || Owner name, custom character set.
|-
| $70 || 1 || Owner birthday year, BCD, first/higher two digits
|-
| $71 || 1 || Owner birthday year, BCD, last/lower two digits
|-
| $72 || 1 || Owner birthday month, BCD
|-
| $73 || 1 || Owner birthday day, BCD
|-
| $74 || 1 || Owner gender:<br/>
0 - ?<br/>
1 - Male<br/>
2 - Female
|-
| $75 || 1 || Owner blood type:<br/>
0 - ?<br/>
1 - A<br/>
2 - B<br/>
3 - AB<br/>
4 - 0
|-
| $76 || 1 | Last booted cartridge developer/publisher ID
|-
| $77 || 1 | Last booted cartridge game ID
|-
| $78 || 1 | Last booted cartridge game version
|-
| $7C || 1 | Stored cartridge ID/version change counter
|-
| $7D || 1 | Owner name change counter
|-
| $7E || 2 | System startup counter
|-
| $83 || 1 | Color console configuration
|-
| $84 || ? | [[Splash animation|Custom splash animation]], if present
|}
=== Owner name character set ===
{| class="wikitable"
|-
!
! <code>.0</code>
! <code>.1</code>
! <code>.2</code>
! <code>.3</code>
! <code>.4</code>
! <code>.5</code>
! <code>.6</code>
! <code>.7</code>
! <code>.8</code>
! <code>.9</code>
! <code>.A</code>
! <code>.B</code>
! <code>.C</code>
! <code>.D</code>
! <code>.E</code>
! <code>.F</code>
|-
! <code>0.</code>
| || 0 || 1 || 2 || 3 || 4 || 5 || 6 || 7 || 8 || 9 || A || B || C || D || E
|-
! <code>1.</code>
| F || G || H || I || J || K || L || M || N || O || P || Q || R || S || T || U
|-
! <code>2.</code>
| V || W || X || Y || Z || ♥ || ♪ || + || - || ? || .
!
!
!
!
!
|}
=== Color console configuration ===
<pre>
7 bit 0
---- ----
sc.. ..vv
|| ||
|| ++- Volume level
|+-------- Contrast (WSC): 0 = Low, 1 = High
+--------- Custom splash animation enabled
</pre>
== Hardware notes ==
EEPROM command bits are shifted out starting from the ''most'' significant bit of the port.
<pre>
+----> EEPROM Serial Data
|
[0] <= [0000 0001 ooaa aaaa]
EEPROM Command Port
</pre>
While the M93LCx6 family supports byte organization, the WonderSwan always uses word organization. As such, this implementation detail is omitted in this documentation.
== Links ==
* [https://www.st.com/resource/en/datasheet/m93c46-w.pdf STMicroelectronics M93LCx6 datasheet]
e986b04c6b3fbf3623ed7ad94951ef1f70023d5a
164
163
2023-08-22T23:37:16Z
Lidnariq
7
despite the name, setting the 0x20s bit in the control register doesn't cause the WSC/2001 to poll for completion when sending WEN. So unless it snoops the command bits...
wikitext
text/x-wiki
The WonderSwan utilizes M93LCx6-compatible EEPROMs:
* in the SoC:
** 1 Kbit internal EEPROM (M93LC46-compatible) on the WonderSwan,
** 16 Kbit internal EEPROM (M93LC86-compatible) on the WonderSwan Color,
* on cartridges:
** 1 Kbit cartridge EEPROM (M93LC46-compatible)
** 8 Kbit cartridge EEPROM (M93LC76-compatible)
** 16 Kbit cartridge EEPROM (M93LC86-compatible)
Additional variants exists which were not seen on any production cartridge:
* 256 bit EEPROM (M93LC06-compatible)
* 2 Kbit EEPROM (M93LC56-compatible)
* 4 Kbit EEPROM (M93LC66-compatible)
== Commands ==
=== READ - Read Word ===
The READ command takes an address of a word (address 0 => bytes 0, 1; address 1 => bytes 2, 3; ...) and returns the word at that address.
=== WRITE - Write Word ===
The WRITE command takes an address of a word (address 0 => bytes 0, 1; address 1 => bytes 2, 3; ...) and the word to write to it, then writes the word.
=== ERASE - Erase Word ===
The ERASE command takes an address of a word (address 0 => bytes 0, 1; address 1 => bytes 2, 3; ...) and erases the word at that address, setting it to 0xFFFF.
=== WDS - Write Disable ===
TODO
=== WRAL - Write All ===
This command is not guaranteed to be present on all EEPROMs.
TODO
=== ERAL - Erase All ===
This command is not guaranteed to be present on all EEPROMs.
TODO
=== WEN - Write Enable ===
TODO
== I/O ports ==
The I/O ports listed refer to the internal EEPROM; for the cartridge EEPROM port numbers, refer to the [[Bandai 2001|mapper documentation]].
Note that on the original/"mono" WonderSwan, the data and command registers can ''only'' be accessed word-wide via even addresses: access to odd addresses whether byte or word-wide don't provide valid data. This has been fixed on the WonderSwan Color, even for "mono" compatibility mode.
{{Anchor|Internal EEPROM Data}}
=== Internal EEPROM Data ($BA, $BB) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
dddd dddd dddd dddd
|||| |||| |||| ||||
++++-++++--++++-++++- Data read from/written to the EEPROM.
</pre>
This port functions as a shared buffer for both "read" and "write" modes. (TODO: Verify)
{{Anchor|Internal EEPROM Command}}
=== Internal EEPROM Command ($BC, $BD) ===
<pre>
Command Pattern 1
15 bit 8 7 bit 0
---- ---- ---- ----
0000 0001 ooaa aaaa (¼, 1 Kbit - M93LC06/46)
0000 01oo aaaa aaaa (2, 4 Kbit - M93LC56/66)
0001 ooaa aaaa aaaa (8, 16 Kbit - M93LC76/86)
|||| |||| ||||
||++--++++-++++- Address (MSb .. LSb)
++-------------- Opcode:
01 - WRITE
10 - READ
11 - ERASE
</pre>
<pre>
Command Pattern 2
15 bit 8 7 bit 0
---- ---- ---- ----
0000 0001 00ss .... (1 Kbit - M93LC46)
0000 0100 ss.. .... (2, 4 Kbit - M93LC56/66)
0001 00ss .... .... (8, 16 Kbit - M93LC76/86)
||
++------------ Sub-Opcode:
00 - WDS
01 - WRAL
01 - ERAL
11 - WEN
</pre>
{{Anchor|Internal EEPROM Control}}
=== Internal EEPROM Control ($BE, $BF write) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
.... .... pswr ....
||||
|||+------ Read mode: 1 for READ command, 0 otherwise
||+------- Write mode: 1 for WRITE and WRAL command, 0 otherwise
|+-------- Short mode: 1 for ERASE, WDS, ERAL and WEN command, 0 otherwise
+--------- 1 to enable internal EEPROM write protection.
Cannot be cleared once set.
</pre>
The ''mode'' flags control the behaviour of the EEPROM interface:
* Read mode: Sends 16 bits from Command, then reads 16 bits to Data.
* Write mode: Sends 16 bits from Command, then 16 bits from Data. De-asserts Microwire chip select, then re-asserts it and waits for the EEPROM to confirm command completion.
* Short mode: Sends 16 bits from Command, de-asserts Microwire chip select.
Also note that nothing inside the SoC or 2001 checks that the contents of the command register matches the bit set in this register.
{{Anchor|Internal EEPROM Status}}
=== Internal EEPROM Status ($BE, $BF read) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
.... .... p... ..RD
| ||
| |+- 1 if a READ command has completed.
| +-- 0 if the EEPROM is busy,
| 1 if a command can be accepted (idle).
+--------- Internal EEPROM write protection:
0 = disabled, 1 = enabled
</pre>
== Internal EEPROM Layout ==
{| class="wikitable"
|-
! Offset !! Length !! Contents
|-
| $00 || 96 || Program data. Can be written by programs even if write protection has been enabled.
|-
| $60 || 16 || Owner name, custom character set.
|-
| $70 || 1 || Owner birthday year, BCD, first/higher two digits
|-
| $71 || 1 || Owner birthday year, BCD, last/lower two digits
|-
| $72 || 1 || Owner birthday month, BCD
|-
| $73 || 1 || Owner birthday day, BCD
|-
| $74 || 1 || Owner gender:<br/>
0 - ?<br/>
1 - Male<br/>
2 - Female
|-
| $75 || 1 || Owner blood type:<br/>
0 - ?<br/>
1 - A<br/>
2 - B<br/>
3 - AB<br/>
4 - 0
|-
| $76 || 1 | Last booted cartridge developer/publisher ID
|-
| $77 || 1 | Last booted cartridge game ID
|-
| $78 || 1 | Last booted cartridge game version
|-
| $7C || 1 | Stored cartridge ID/version change counter
|-
| $7D || 1 | Owner name change counter
|-
| $7E || 2 | System startup counter
|-
| $83 || 1 | Color console configuration
|-
| $84 || ? | [[Splash animation|Custom splash animation]], if present
|}
=== Owner name character set ===
{| class="wikitable"
|-
!
! <code>.0</code>
! <code>.1</code>
! <code>.2</code>
! <code>.3</code>
! <code>.4</code>
! <code>.5</code>
! <code>.6</code>
! <code>.7</code>
! <code>.8</code>
! <code>.9</code>
! <code>.A</code>
! <code>.B</code>
! <code>.C</code>
! <code>.D</code>
! <code>.E</code>
! <code>.F</code>
|-
! <code>0.</code>
| || 0 || 1 || 2 || 3 || 4 || 5 || 6 || 7 || 8 || 9 || A || B || C || D || E
|-
! <code>1.</code>
| F || G || H || I || J || K || L || M || N || O || P || Q || R || S || T || U
|-
! <code>2.</code>
| V || W || X || Y || Z || ♥ || ♪ || + || - || ? || .
!
!
!
!
!
|}
=== Color console configuration ===
<pre>
7 bit 0
---- ----
sc.. ..vv
|| ||
|| ++- Volume level
|+-------- Contrast (WSC): 0 = Low, 1 = High
+--------- Custom splash animation enabled
</pre>
== Hardware notes ==
EEPROM command bits are shifted out starting from the ''most'' significant bit of the port.
<pre>
+----> EEPROM Serial Data
|
[0] <= [0000 0001 ooaa aaaa]
EEPROM Command Port
</pre>
While the M93LCx6 family supports byte organization, the WonderSwan always uses word organization. As such, this implementation detail is omitted in this documentation.
== Links ==
* [https://www.st.com/resource/en/datasheet/m93c46-w.pdf STMicroelectronics M93LCx6 datasheet]
9fffba4035c4c7c521befd948664b95b9d5f5dd2
199
164
2023-08-27T10:49:23Z
Asie
351
add errata
wikitext
text/x-wiki
The WonderSwan utilizes M93LCx6-compatible EEPROMs:
* in the SoC:
** 1 Kbit internal EEPROM (M93LC46-compatible) on the WonderSwan,
** 16 Kbit internal EEPROM (M93LC86-compatible) on the WonderSwan Color,
* on cartridges:
** 1 Kbit cartridge EEPROM (M93LC46-compatible)
** 8 Kbit cartridge EEPROM (M93LC76-compatible)
** 16 Kbit cartridge EEPROM (M93LC86-compatible)
Additional variants exists which were not seen on any production cartridge:
* 256 bit EEPROM (M93LC06-compatible)
* 2 Kbit EEPROM (M93LC56-compatible)
* 4 Kbit EEPROM (M93LC66-compatible)
== Commands ==
=== READ - Read Word ===
The READ command takes an address of a word (address 0 => bytes 0, 1; address 1 => bytes 2, 3; ...) and returns the word at that address.
=== WRITE - Write Word ===
The WRITE command takes an address of a word (address 0 => bytes 0, 1; address 1 => bytes 2, 3; ...) and the word to write to it, then writes the word.
=== ERASE - Erase Word ===
The ERASE command takes an address of a word (address 0 => bytes 0, 1; address 1 => bytes 2, 3; ...) and erases the word at that address, setting it to 0xFFFF.
=== WDS - Write Disable ===
TODO
=== WRAL - Write All ===
This command is not guaranteed to be present on all EEPROMs.
TODO
=== ERAL - Erase All ===
This command is not guaranteed to be present on all EEPROMs.
TODO
=== WEN - Write Enable ===
TODO
== I/O ports ==
The I/O ports listed refer to the internal EEPROM; for the cartridge EEPROM port numbers, refer to the [[Bandai 2001|mapper documentation]].
Note that on the original/"mono" WonderSwan, the data and command registers can ''only'' be accessed word-wide via even addresses: access to odd addresses whether byte or word-wide don't provide valid data. This has been fixed on the WonderSwan Color, even for "mono" compatibility mode.
{{Anchor|Internal EEPROM Data}}
=== Internal EEPROM Data ($BA, $BB) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
dddd dddd dddd dddd
|||| |||| |||| ||||
++++-++++--++++-++++- Data read from/written to the EEPROM.
</pre>
This port functions as a shared buffer for both "read" and "write" modes. (TODO: Verify)
{{Anchor|Internal EEPROM Command}}
=== Internal EEPROM Command ($BC, $BD) ===
<pre>
Command Pattern 1
15 bit 8 7 bit 0
---- ---- ---- ----
0000 0001 ooaa aaaa (¼, 1 Kbit - M93LC06/46)
0000 01oo aaaa aaaa (2, 4 Kbit - M93LC56/66)
0001 ooaa aaaa aaaa (8, 16 Kbit - M93LC76/86)
|||| |||| ||||
||++--++++-++++- Address (MSb .. LSb)
++-------------- Opcode:
01 - WRITE
10 - READ
11 - ERASE
</pre>
<pre>
Command Pattern 2
15 bit 8 7 bit 0
---- ---- ---- ----
0000 0001 00ss .... (1 Kbit - M93LC46)
0000 0100 ss.. .... (2, 4 Kbit - M93LC56/66)
0001 00ss .... .... (8, 16 Kbit - M93LC76/86)
||
++------------ Sub-Opcode:
00 - WDS
01 - WRAL
01 - ERAL
11 - WEN
</pre>
{{Anchor|Internal EEPROM Control}}
=== Internal EEPROM Control ($BE, $BF write) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
.... .... pswr ....
||||
|||+------ Read mode: 1 for READ command, 0 otherwise
||+------- Write mode: 1 for WRITE and WRAL command, 0 otherwise
|+-------- Short mode: 1 for ERASE, WDS, ERAL and WEN command, 0 otherwise
+--------- 1 to enable internal EEPROM write protection.
Cannot be cleared once set.
</pre>
The ''mode'' flags control the behaviour of the EEPROM interface:
* Read mode: Sends 16 bits from Command, then reads 16 bits to Data.
* Write mode: Sends 16 bits from Command, then 16 bits from Data. De-asserts Microwire chip select, then re-asserts it and waits for the EEPROM to confirm command completion.
* Short mode: Sends 16 bits from Command, de-asserts Microwire chip select.
Also note that nothing inside the SoC or 2001 checks that the contents of the command register matches the bit set in this register.
{{Anchor|Internal EEPROM Status}}
=== Internal EEPROM Status ($BE, $BF read) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
.... .... p... ..RD
| ||
| |+- 1 if a READ command has completed.
| +-- 0 if the EEPROM is busy,
| 1 if a command can be accepted (idle).
+--------- Internal EEPROM write protection:
0 = disabled, 1 = enabled
</pre>
== Internal EEPROM Layout ==
{| class="wikitable"
|-
! Offset !! Length !! Contents
|-
| $00 || 96 || Program data. Can be written by programs even if write protection has been enabled.
|-
| $60 || 16 || Owner name, custom character set.
|-
| $70 || 1 || Owner birthday year, BCD, first/higher two digits
|-
| $71 || 1 || Owner birthday year, BCD, last/lower two digits
|-
| $72 || 1 || Owner birthday month, BCD
|-
| $73 || 1 || Owner birthday day, BCD
|-
| $74 || 1 || Owner gender:<br/>
0 - ?<br/>
1 - Male<br/>
2 - Female
|-
| $75 || 1 || Owner blood type:<br/>
0 - ?<br/>
1 - A<br/>
2 - B<br/>
3 - AB<br/>
4 - 0
|-
| $76 || 1 | Last booted cartridge developer/publisher ID
|-
| $77 || 1 | Last booted cartridge game ID
|-
| $78 || 1 | Last booted cartridge game version
|-
| $7C || 1 | Stored cartridge ID/version change counter
|-
| $7D || 1 | Owner name change counter
|-
| $7E || 2 | System startup counter
|-
| $83 || 1 | Color console configuration
|-
| $84 || ? | [[Splash animation|Custom splash animation]], if present
|}
=== Owner name character set ===
{| class="wikitable"
|-
!
! <code>.0</code>
! <code>.1</code>
! <code>.2</code>
! <code>.3</code>
! <code>.4</code>
! <code>.5</code>
! <code>.6</code>
! <code>.7</code>
! <code>.8</code>
! <code>.9</code>
! <code>.A</code>
! <code>.B</code>
! <code>.C</code>
! <code>.D</code>
! <code>.E</code>
! <code>.F</code>
|-
! <code>0.</code>
| || 0 || 1 || 2 || 3 || 4 || 5 || 6 || 7 || 8 || 9 || A || B || C || D || E
|-
! <code>1.</code>
| F || G || H || I || J || K || L || M || N || O || P || Q || R || S || T || U
|-
! <code>2.</code>
| V || W || X || Y || Z || ♥ || ♪ || + || - || ? || .
!
!
!
!
!
|}
=== Color console configuration ===
<pre>
7 bit 0
---- ----
sc.. ..vv
|| ||
|| ++- Volume level
|+-------- Contrast (WSC): 0 = Low, 1 = High
+--------- Custom splash animation enabled
</pre>
== Hardware notes ==
EEPROM command bits are shifted out starting from the ''most'' significant bit of the port.
<pre>
+----> EEPROM Serial Data
|
[0] <= [0000 0001 ooaa aaaa]
EEPROM Command Port
</pre>
While the M93LCx6 family supports byte organization, the WonderSwan always uses word organization. As such, this implementation detail is omitted in this documentation.
== Errata ==
=== Non-word access on ASWAN ===
On the ASWAN SoC, accessing the internal EEPROM command ports as bytes only works correctly for even addresses. For odd addresses, these accesses return open bus; this means that unaligned word accesses also don't work, as they are converted to one odd and one even byte access internally.
As such, it is recommended to only use word port accesses to talk to the internal EEPROM.
This issue is not present on the SPHINX and newer SoCs, including in "mono" emulation mode, as well as the cartridge bus (which is always forced to be accessed per byte).
== Links ==
* [https://www.st.com/resource/en/datasheet/m93c46-w.pdf STMicroelectronics M93LCx6 datasheet]
eb9ebef12de2a3a77138472edc312fafcb05335f
Splash animation
0
34
165
149
2023-08-23T06:11:07Z
Asie
351
fix URL
wikitext
text/x-wiki
The WonderSwan Color upgraded the [[EEPROM|internal EEPROM]] from 128 bytes to 2 kilobytes; most of the additional space is utilized to allow for branding consoles in the form of unique, custom splash animations on console startup.
== Format ==
{| class="wikitable"
|-
! Offset !! Length !! Contents
|-
| $83 || 1 || WSC-specific configuration. Bit 7 enables custom splash animation.
|-
| $84 || 1 || Name color
|-
| $85 || 1 || Must be $00
|-
| $86 || 1 || Size; 0 = ends at <= $3FF, 1 = ends at <= $7FF
|-
| $87 || 1 || First frame
|-
| $88 || 1 || Last frame
|-
| $89 || 1 || Sprite count
|-
| $8A || 1 || Palette flags
|-
| $8B || 1 || Tile count
|-
| $8C || 2 || Palette location - $80
|-
| $8E || 2 || Tile data location - $80
|-
| $90 || 2 || Tilemap location - $80
|-
| $92 || 2 || Screen offset (Horizontal)
|-
| $94 || 2 || Screen offset (Vertical)
|-
| $96 || 1 || Tilemap width
|-
| $97 || 1 || Tilemap height
|-
| $98 || 2 || VBlank IRQ handler offset
|-
| $9A || 2 || VBlank IRQ handler segment, must be $0600
|-
| $9C || 1 || Owner name X (horizontal)
|-
| $9D || 1 || Owner name Y (horizontal)
|-
| $9E || 1 || Owner name X (vertical)
|-
| $9F || 1 || Owner name Y (vertical)
|-
| $A0 || 2 || Padding, unused
|-
| $A2 || 2 || Sound wavetable location - $80
|-
| $A4 || 2 || Sound channel 1 data offset - $80
|-
| $A6 || 2 || Sound channel 2 data offset - $80
|-
| $A8 || 2 || Sound channel 3 data offset - $80
|-
| $AA || 2 || Sound channel 4 data offset - $80
|-
| $AC || 10 || SwanCrystal TFT LCD configuration
|-
| $B6 || 10 || Padding, unused
|-
| $C0 || ... || Arbitrary data - palettes, tilemaps, etc.
|}
=== Palette flags ===
<pre>
7 bit 0
---- ----
b..p pppp
| +-++++- Palette count (0-16)
+--------- Tile/palette bits per pixel:
0 = 1 bit per pixel
1 = 2 bits per pixel
</pre>
=== Name colors ===
{| class="wikitable"
|-
! Value !! RGB code
|-
| 0 || #000
|-
| 1 || #f00
|-
| 2 || #f70
|-
| 3 || #ff0
|-
| 4 || #7f0
|-
| 5 || #0f0
|-
| 6 || #0f7
|-
| 7 || #0ff
|-
| 8 || #07f
|-
| 9 || #00f
|-
| 10 || #70f
|-
| 11 || #f0f
|-
| 12 || #f07
|}
=== VBlank IRQ handler ===
A custom splash animation ''must'' provide a valid VBlank IRQ handler, with the following rules:
* The segment must be ''0x0600''; the offset is provided relative to ''$80'', as with other data offsets.
* The code must end with a ''retf'' opcode, or equivalent.
=== Horizontal/Vertical orientation handling ===
The splash animation loader will automatically rotate the tile data and tilemap when booting a cartridge whose [[ROM header|header]] declares vertical orientation as its startup orientation.
=== Sound channel data format ===
TODO
b329fcd773f12e2e38e4995970dd769d3d2dd8dc
WSdev Wiki
0
1
166
146
2023-08-23T06:24:23Z
Fiskbit
37
Fiskbit moved page [[Main Page]] to [[WSdev Wiki]]: Rename main page to match wiki name.
wikitext
text/x-wiki
'''WonderSwan Development Wiki'''
== Reference ==
=== General ===
* [[Memory map]]
* [[I/O port map]]
* [[ROM header]]
* [[NEC V30MZ]] - the WonderSwan CPU (80186-compatible)
* [[Timing]]
=== Console components ===
* [[Display]]
* [[Sound]]
** [[Hyper Voice]]<sup>(color)</sup>
* [[Keypad]]
* [[Timers]]
* [[Interrupts]]
* [[UART]]
* [[EEPROM|Internal EEPROM]]
** [[Splash animation]]<sup>(color)</sup>
* [[DMA]]<sup>(color)</sup>
=== Cartridge components ===
* [[Mapper]]
** [[Bandai 2001]]
** [[Bandai 2003]]
** [[KARNAK]]
* [[EEPROM]] (2001)
* [[Real-Time Clock]] (2003)
=== Pinouts ===
* [[Accessory port pinout]]
* [[2001 Mapper pinout]]
* [[2003 Mapper pinout]]
* [[KARNAK pinout]]
* [[GIZA pinout]]
* [[S-3511A pinout]]
=== Accessories ===
* [[WonderBeat 9480]] headphone adapter
* [[WonderBorg]] robot
* [[WonderGate]] mobile adapter
* [[WonderWave]] infrared adapter
=== WonderWitch ===
* [[FreyaBIOS]]
* [[WonderWitch .fx files|.fx file format]]
== Links ==
* [https://github.com/WonderfulToolchain/awesome-wsdev awesome-wsdev] - curated documentation/tools/source code link list
== MediaWiki ==
* [https://www.mediawiki.org/wiki/Special:MyLanguage/Help:Contents User's Guide]
* [https://www.mediawiki.org/wiki/Special:MyLanguage/Manual:FAQ MediaWiki FAQ]
* [[:Category:Deletion requests|Deletion requests]]
75d6c30c02e8346d5ed309791b5de20b66993cdf
178
166
2023-08-25T06:02:11Z
Asie
351
/* WonderWitch */
wikitext
text/x-wiki
'''WonderSwan Development Wiki'''
== Reference ==
=== General ===
* [[Memory map]]
* [[I/O port map]]
* [[ROM header]]
* [[NEC V30MZ]] - the WonderSwan CPU (80186-compatible)
* [[Timing]]
=== Console components ===
* [[Display]]
* [[Sound]]
** [[Hyper Voice]]<sup>(color)</sup>
* [[Keypad]]
* [[Timers]]
* [[Interrupts]]
* [[UART]]
* [[EEPROM|Internal EEPROM]]
** [[Splash animation]]<sup>(color)</sup>
* [[DMA]]<sup>(color)</sup>
=== Cartridge components ===
* [[Mapper]]
** [[Bandai 2001]]
** [[Bandai 2003]]
** [[KARNAK]]
* [[EEPROM]] (2001)
* [[Real-Time Clock]] (2003)
=== Pinouts ===
* [[Accessory port pinout]]
* [[2001 Mapper pinout]]
* [[2003 Mapper pinout]]
* [[KARNAK pinout]]
* [[GIZA pinout]]
* [[S-3511A pinout]]
=== Accessories ===
* [[WonderBeat 9480]] headphone adapter
* [[WonderBorg]] robot
* [[WonderGate]] mobile adapter
* [[WonderWave]] infrared adapter
=== WonderWitch ===
* [[WonderWitch]]
** [[FreyaBIOS]]
** [[FreyaOS]]
** [[WonderWitch .fx files|.fx file format]]
== Links ==
* [https://github.com/WonderfulToolchain/awesome-wsdev awesome-wsdev] - curated documentation/tools/source code link list
== MediaWiki ==
* [https://www.mediawiki.org/wiki/Special:MyLanguage/Help:Contents User's Guide]
* [https://www.mediawiki.org/wiki/Special:MyLanguage/Manual:FAQ MediaWiki FAQ]
* [[:Category:Deletion requests|Deletion requests]]
0f6d5f98637e80076bd5e95c74f017375023d452
179
178
2023-08-25T06:06:26Z
Asie
351
/* WonderWitch */
wikitext
text/x-wiki
'''WonderSwan Development Wiki'''
== Reference ==
=== General ===
* [[Memory map]]
* [[I/O port map]]
* [[ROM header]]
* [[NEC V30MZ]] - the WonderSwan CPU (80186-compatible)
* [[Timing]]
=== Console components ===
* [[Display]]
* [[Sound]]
** [[Hyper Voice]]<sup>(color)</sup>
* [[Keypad]]
* [[Timers]]
* [[Interrupts]]
* [[UART]]
* [[EEPROM|Internal EEPROM]]
** [[Splash animation]]<sup>(color)</sup>
* [[DMA]]<sup>(color)</sup>
=== Cartridge components ===
* [[Mapper]]
** [[Bandai 2001]]
** [[Bandai 2003]]
** [[KARNAK]]
* [[EEPROM]] (2001)
* [[Real-Time Clock]] (2003)
=== Pinouts ===
* [[Accessory port pinout]]
* [[2001 Mapper pinout]]
* [[2003 Mapper pinout]]
* [[KARNAK pinout]]
* [[GIZA pinout]]
* [[S-3511A pinout]]
=== Accessories ===
* [[WonderBeat 9480]] headphone adapter
* [[WonderBorg]] robot
* [[WonderGate]] mobile adapter
* [[WonderWave]] infrared adapter
=== WonderWitch ===
* [[WonderWitch]]
** [[WonderWitch/FreyaBIOS|FreyaBIOS]]
** [[WonderWitch/FreyaOS|FreyaOS]]
** [[WonderWitch .fx files|.fx file format]]
== Links ==
* [https://github.com/WonderfulToolchain/awesome-wsdev awesome-wsdev] - curated documentation/tools/source code link list
== MediaWiki ==
* [https://www.mediawiki.org/wiki/Special:MyLanguage/Help:Contents User's Guide]
* [https://www.mediawiki.org/wiki/Special:MyLanguage/Manual:FAQ MediaWiki FAQ]
* [[:Category:Deletion requests|Deletion requests]]
5b1dd5d24a5c32bbb635543760d88aab4c570e74
189
179
2023-08-25T16:36:38Z
Asie
351
wikitext
text/x-wiki
'''WonderSwan Development Wiki'''
== Reference ==
=== General ===
* [[Memory map]]
* [[I/O port map]]
* [[ROM header]]
* [[NEC V30MZ]] - the WonderSwan CPU (80186-compatible)
* [[Timing]]
=== Console components ===
* [[Display]]
* [[Sound]]
** [[Hyper Voice]]<sup>(color)</sup>
* [[Keypad]]
* [[Timers]]
* [[Interrupts]]
* [[UART]]
* [[EEPROM|Internal EEPROM]]
** [[Splash animation]]<sup>(color)</sup>
* [[DMA]]<sup>(color)</sup>
=== Cartridge components ===
* [[Cartridge]]
* [[Mapper]]
** [[Bandai 2001]]
** [[Bandai 2003]]
** [[KARNAK]]
* [[EEPROM]] (2001)
* [[Real-Time Clock]] (2003)
=== Pinouts ===
* [[Cartridge pinout]]
* [[Accessory port pinout]]
* [[2001 Mapper pinout]]
* [[2003 Mapper pinout]]
* [[KARNAK pinout]]
* [[GIZA pinout]]
* [[S-3511A pinout]]
=== Accessories ===
* [[WonderBeat 9480]] headphone adapter
* [[WonderBorg]] robot
* [[WonderGate]] mobile adapter
* [[WonderWave]] infrared adapter
=== WonderWitch ===
* [[WonderWitch]]
** [[WonderWitch/FreyaBIOS|FreyaBIOS]]
** [[WonderWitch/FreyaOS|FreyaOS]]
** [[WonderWitch .fx files|.fx file format]]
== Links ==
* [https://github.com/WonderfulToolchain/awesome-wsdev awesome-wsdev] - curated documentation/tools/source code link list
== MediaWiki ==
* [https://www.mediawiki.org/wiki/Special:MyLanguage/Help:Contents User's Guide]
* [https://www.mediawiki.org/wiki/Special:MyLanguage/Manual:FAQ MediaWiki FAQ]
* [[:Category:Deletion requests|Deletion requests]]
95c33705be94f518f4d3e573b6c2e4056fc66247
193
189
2023-08-25T16:49:29Z
Asie
351
/* Console components */
wikitext
text/x-wiki
'''WonderSwan Development Wiki'''
== Reference ==
=== General ===
* [[Memory map]]
* [[I/O port map]]
* [[ROM header]]
* [[NEC V30MZ]] - the WonderSwan CPU (80186-compatible)
* [[Timing]]
=== Console components ===
* [[SoC]]
** [[Display]]
** [[Sound]]
*** [[Hyper Voice]]<sup>(color)</sup>
** [[Keypad]]
** [[Timers]]
** [[Interrupts]]
** [[UART]]
** [[DMA]]<sup>(color)</sup>
* [[EEPROM|Internal EEPROM]]
** [[Splash animation]]<sup>(color)</sup>
=== Cartridge components ===
* [[Cartridge]]
* [[Mapper]]
** [[Bandai 2001]]
** [[Bandai 2003]]
** [[KARNAK]]
* [[EEPROM]] (2001)
* [[Real-Time Clock]] (2003)
=== Pinouts ===
* [[Cartridge pinout]]
* [[Accessory port pinout]]
* [[2001 Mapper pinout]]
* [[2003 Mapper pinout]]
* [[KARNAK pinout]]
* [[GIZA pinout]]
* [[S-3511A pinout]]
=== Accessories ===
* [[WonderBeat 9480]] headphone adapter
* [[WonderBorg]] robot
* [[WonderGate]] mobile adapter
* [[WonderWave]] infrared adapter
=== WonderWitch ===
* [[WonderWitch]]
** [[WonderWitch/FreyaBIOS|FreyaBIOS]]
** [[WonderWitch/FreyaOS|FreyaOS]]
** [[WonderWitch .fx files|.fx file format]]
== Links ==
* [https://github.com/WonderfulToolchain/awesome-wsdev awesome-wsdev] - curated documentation/tools/source code link list
== MediaWiki ==
* [https://www.mediawiki.org/wiki/Special:MyLanguage/Help:Contents User's Guide]
* [https://www.mediawiki.org/wiki/Special:MyLanguage/Manual:FAQ MediaWiki FAQ]
* [[:Category:Deletion requests|Deletion requests]]
dc765d975223ec7acd0a2006e153928891a0140a
Main Page
0
37
167
2023-08-23T06:24:23Z
Fiskbit
37
Fiskbit moved page [[Main Page]] to [[WSdev Wiki]]: Rename main page to match wiki name.
wikitext
text/x-wiki
#REDIRECT [[WSdev Wiki]]
d4a3115c654c6d60b2ff1677bf90ce8b9817d25c
MediaWiki:Mainpage
8
38
168
2023-08-23T06:24:55Z
Fiskbit
37
Point to the new main page name.
wikitext
text/x-wiki
WSdev Wiki
a830bc53ff68da5503384ab6a4ea98619b59ae8f
Bandai 2001
0
12
169
51
2023-08-23T11:17:08Z
Asie
351
add SoC name
wikitext
text/x-wiki
The Bandai 2001 (LUXSOR) is one of the two mappers used in WonderSwan cartridges.
In addition to the normal [[Mapper]] banking interface, Bandai's 2001 adds three registers for interacting with a Microwire EEPROM:
{| class="wikitable"
! Category
! Port
! Description
! Bits
! Type
! Notes
|-
! rowspan="4" | External EEPROM
! $C4
| External EEPROM Data
| style="text-align: right" | <tt style="white-space: nowrap">dddd dddd dddd dddd</tt>
| RW16
| Data (d)
|-
! $C6
| External EEPROM Command
| style="text-align: right" | <tt style="white-space: nowrap">0001 CCaa aaaa aaaa</tt>
or <tt style="white-space: nowrap">0000 0001 CCaa aaaa</tt>
| RW16
| Command and address
|-
! rowspan=2|$C8
| External EEPROM Command
| style="text-align: right" | <tt style="white-space: nowrap">ACWR ....</tt>
| W8
| Abort (A), Command (C), Write (W), Read (R)
|-
| External EEPROM Status
| style="text-align: right" | <tt style="white-space: nowrap">.... ..rd</tt>
| R8
| Ready (r), Done (d)
|-
|}
The specific meaning of the "Command" register depends on the model of EEPROM on the PCB. Only three Microwire EEPROMs have been seen used (equivalent to 93C46, 93C76, and 93C86)
On the 2001, the EEPROM "done" bit is buggy and doesn't have useful information. It's set when a Read completes, but is only cleared when a Command or Write is started. (To be useful it would need to also be cleared when a Read is started).
If more than ACWR bit is set at the same time, the 2001 ignores it.
The CWR bits specify how many data bits are sent/received. C: No data bits. W: Send Data register after command register. R: Receive data register after sending command register.
If the A bit is set, the transaction immediately stops.
(Upload logic analyzer traces here)
e0987b1db12efc55cba425e4b9c48d6f737fff07
Bandai 2003
0
13
170
75
2023-08-23T11:17:18Z
Asie
351
add SoC name
wikitext
text/x-wiki
The Bandai 2003 (LUXSOR2) is one of the two mappers used in WonderSwan cartridges.
In addition to the normal [[Mapper]] banking interface, Bandai's 2003 adds registers for an RTC interface, GPO pins, self flashing, and accessing more than 16MiB of ROM.
{| class="wikitable"
! Category
! Port
! Description
! Bits
! Type
! Notes
|-
! rowspan="3" | RTC
! rowspan="2" | $CA
| RTC Command
| style="text-align: right" | <tt style="white-space: nowrap">...1 CCCC</tt>
| W8
| Command (C)
|-
| RTC Status
| style="text-align: right" | <tt style="white-space: nowrap">D00B CCCC</tt>
| R8
| Busy (B), Command (C), Data needed (D)
|-
! $CB
| RTC Payload
| style="text-align: right" | <tt style="white-space: nowrap">dddd dddd</tt>
| RW8
| Data (d)
|-
! rowspan="2" | GPO
! $CC
| GPO Data Direction
| style="text-align: right" | <tt style="white-space: nowrap">0000 oooo</tt>
| RW8
| 1 = output, 0 = high-impedance (weak pull-down)
|-
! $CD
| GPO Data
| style="text-align: right" | <tt style="white-space: nowrap">0000 dddd</tt>
| RW8
| 1 = 3V, if enabled by data direction
|-
! Self-Flash
! $CE
| Self-Flash Control
| style="text-align: right" | <tt style="white-space: nowrap">0000 000r</tt>
| RW8
| 1 = ROM is accessible at segment 0x1000;
0 = RAM instead.
|-
! rowspan="4" | Extended bankswitching
! $CF
| ROM Linear (EX) Bank
| style="text-align: right" | <tt style="white-space: nowrap">00bb bbbb</tt>
| RW8
| Selects a 1MiB bank accessed via segments 0x4000 through 0xF000. Identical to the register at 0xC0.
|-
! $D0
| RAM(/ROM) Bank
| style="text-align: right" | <tt style="white-space: nowrap">0000 00bb bbbb bbbb</tt>
| RW16
| Selects a 64KiB bank accessed via segment 0x1000. Lower 8 bits are identical to the register at 0xC1.
|-
! $D2
| ROM0 Bank
| style="text-align: right" | <tt style="white-space: nowrap">0000 00bb bbbb bbbb</tt>
| RW16
| Selects a 64KiB bank accessed via segment 0x2000. Lower 8 bits are identical to the register at 0xC2.
|-
! $D4
| ROM1 Bank
| style="text-align: right" | <tt style="white-space: nowrap">0000 00bb bbbb bbbb</tt>
| RW16
| Selects a 64KiB bank accessed via segment 0x3000. Lower 8 bits are identical to the register at 0xC3.
|}
Not all PCBs are wired to support self-flashing. Not all ROMs have the needed /BYTE pin. Even on PCBs without support, ROM can still be enabled by writing to port $CE.
== 2003 RTC interface ==
The 2003's RTC interface is a simple half-duplex SPI-like protocol. A write to $CA will start a transaction, depending on the exact value written.
If there is no external S-3511A, all bytes will read back as $FF due to a weak pull-up inside the 2003.
For specifics of what the S-3511A expects to be done with these bytes, see [[Real-Time Clock]].
(Put logic analyzer traces here)
Values are as follows:
=== $00-$0F, $1C-$1F ===
Immediately stop the transaction. This cannot be safely used to abort an ongoing transaction, because the 2003 still relays the 384kHz clock. In contrast, normal termination stops relaying that clock.
=== $10, $11 ===
Send command byte ($60 or $61 respectively) and stop.
=== $12 ===
Send command byte ($62), then send byte stored in $CB, then stop. The 2003 expects that the value in $CB is valid and does not pause if the CPU hasn't yet written a value.
=== $13 ===
Send command byte ($63), then receive byte, then stop. After the "data needed" is set or the "busy" bit is clear the value can be read from $CB.
=== $14 ===
Send command byte ($64), then send seven bytes of payload, then stop. The 2003 expects that the ''first'' byte is preloaded in $CB, but pauses for the CPU to write each subsequent byte by setting the "Data needed" bit.
=== $15 ===
Send command byte ($65), then receive seven bytes of payload, then stop. The 2003 pauses for the CPU to read each subsequent byte by setting the "Data needed" bit.
=== $16 ===
Send command byte ($66), then send three bytes of payload, then stop.
=== $17 ===
Send command byte ($67), then receive three bytes of payload, then stop.
=== $18, $1A ===
Send command byte ($68 or $6A), then send two bytes of payload, then stop.
=== $19, $1B ===
Send command byte ($69 or $6B), then receive two bytes of payload, then stop.
260f7f0e96b5cc553681bb7168e1a9e022c4d2b5
KARNAK
0
18
171
139
2023-08-23T11:17:51Z
Asie
351
wikitext
text/x-wiki
The KARNAK mapper is only used in some Pocket Challenge V2 edutainment cartridges.
It is not yet well-documented. It is thought to be a revision of [[Bandai 2003]] that removes the RTC interface, and adds a timer IRQ and a hardware IMA ADPCM decoder.
This page should not be taken as authoritative: it has been pieced together from multiple other pieces of research. It is unclear if the GPO and Self-Flash registers exist; from PCB photos the Self-Flash register is unused if it does exist.
{| class="wikitable"
! Category
! Port
! Description
! Bits
! Type
! Notes
|-
! rowspan="2" | GPO
! $CC
| GPO Data Direction
| style="text-align: right" | <tt style="white-space: nowrap">0000 oooo</tt>
| RW8
| 1 = output, 0 = high-impedance (weak pull-down)
|-
! $CD
| GPO Data
| style="text-align: right" | <tt style="white-space: nowrap">0000 dddd</tt>
| RW8
| 1 = 3V, if enabled by data direction
|-
! Self-Flash
! $CE
| Self-Flash Control
| style="text-align: right" | <tt style="white-space: nowrap">0000 000r</tt>
| RW8
| 1 = ROM is accessible at segment 0x1000;
0 = RAM instead.
|-
! rowspan="4" | Extended bankswitching
! $CF
| ROM Linear (EX) Bank
| style="text-align: right" | <tt style="white-space: nowrap">00bb bbbb</tt>
| RW8
| Selects a 1MiB bank accessed via segments 0x4000 through 0xF000. Identical to the register at 0xC0.
|-
! $D0
| RAM(/ROM) Bank
| style="text-align: right" | <tt style="white-space: nowrap">0000 00bb bbbb bbbb</tt>
| RW16
| Selects a 64KiB bank accessed via segment 0x1000. Lower 8 bits are identical to the register at 0xC1.
|-
! $D2
| ROM0 Bank
| style="text-align: right" | <tt style="white-space: nowrap">0000 00bb bbbb bbbb</tt>
| RW16
| Selects a 64KiB bank accessed via segment 0x2000. Lower 8 bits are identical to the register at 0xC2.
|-
! $D4
| ROM1 Bank
| style="text-align: right" | <tt style="white-space: nowrap">0000 00bb bbbb bbbb</tt>
| RW16
| Selects a 64KiB bank accessed via segment 0x3000. Lower 8 bits are identical to the register at 0xC3.
|-
! Timer
! $D6
| Programmable Interval Timer
| style="text-align: right" | <tt style="white-space: nowrap">eppp pppp</tt>
| RW8
| Enable (e); Period (p). Units are the 384kHz clock to the cartridge.
|-
! rowspan=2|ADPCM
! $D8
| Packed data
| ?
| W8?
| Write two-sample packed ADPCM byte
|-
! $D9
| Unpacked data
| ?
| R8?
| Read two one-byte unpacked PCM bytes, in sequence
|}
== Timer ==
If enabled, the timer will emit a [[Interrupts|cartridge interrupt]] every <code>((period + 1) * 2)</code> cartridge clocks, where "one cartridge clock" = 384KHz = 1/8th CPU clock.
8b487e952deb84c1e2ea1efb2162140fe1c7234c
NEC V30MZ
0
39
172
2023-08-23T16:27:14Z
Asie
351
Created page with "The NEC V30MZ is the CPU component of the WonderSwan SoC. == Sections == * [[NEC V30MZ/Undocumented|CPU undocumented behavior]] == Links == * [https://www.ardent-tool.com/CPU/docs/NEC/V20-V30/v30mz.pdf NEC V30MZ datasheet]"
wikitext
text/x-wiki
The NEC V30MZ is the CPU component of the WonderSwan SoC.
== Sections ==
* [[NEC V30MZ/Undocumented|CPU undocumented behavior]]
== Links ==
* [https://www.ardent-tool.com/CPU/docs/NEC/V20-V30/v30mz.pdf NEC V30MZ datasheet]
cdf08baff9b18a1658ca8b9b1d20c8e07df5ff80
173
172
2023-08-23T16:29:37Z
Asie
351
wikitext
text/x-wiki
The NEC V30MZ is the CPU component of the WonderSwan SoC.
Unlike the NEC V20/V30 CPU family, the V30MZ is fully compatible with the Intel 80186's documented behaviour, as well as some of its undocumented behaviour (such as the SALC opcode); it also omits the V20/V30's opcode extensions.
The NEC V30MZ datasheet uses distinct names for opcodes and registers (''NEC names''); as all homebrew compilers and assemblers for the platform utilize Intel's official naming (''Intel names''), the latter is what the wiki has standardized on.
== Sections ==
* [[NEC V30MZ/Undocumented|CPU undocumented behavior]]
== Links ==
* [https://www.ardent-tool.com/CPU/docs/NEC/V20-V30/v30mz.pdf NEC V30MZ datasheet]
d867a96624eef10d13a212d35634fb1c2cbc76bc
Real-Time Clock
0
40
174
2023-08-23T23:15:43Z
Lidnariq
7
get something here
wikitext
text/x-wiki
The [[Bandai 2003|2003]] mapper provides a special-purpose interface to interact with Seiko's S-3511A RTC chip.
This page will cover how games expect to interact with it; not the low-level protocol specifics. (For that see the datasheet and the Timing section of this wiki)
== Internal operation ==
The RTC consists of 10 total bytes of user-visible state.
The following are always interpreted as 2 digit packed BCD.
* Year (always assumes 00 is a leap year)
* Month (1=January)
* Day-of-month (1-indexed)
* Day-of-week (0-indexed and free-running, no predefined mapping of number to legal day)
* Hour
* Minute
* Second
* Configuration
* Alarm configuration
=== Configuration ===
7 bit 0
P2A0 M0F0
|||| ||||
|||+--+-+--- always 0
||+--+-+---- IRQ mode
|+---------- 1: 24 hour mode 0: 12 hour mode
+----------- power failure occurred
Sending the Reset or Read Configuration commands clear the "power failure" bit.
Interrupts:
AMF
000 -- "No interrupts" - continuously deasserts /IRQ pin
100 -- "Alarm" - Treat "alarm configuration" as packed BCD HHMM. Assert /IRQ during that hour and minute. Hour encoding must match 12/24 bit setting.
x10 -- "Per-minute edge" - Asserts /IRQ during the first 10 ms of each minute. During following 990ms, /IRQ can be deasserted by reading the configuration register.
x11 -- "Per-minute steady" - Asserts /IRQ during the first 10ms of each minute. De-asserts /IRQ at the 30th second.
x01 -- "Frequency" - subsecond prescaler is bitwise inverted, bitwise ANDed with the lower 15 bits of the "alarm configuration" register, then all fifteen bits are NORed together. This signal directly drives the /IRQ pin.
=== Reset RTC ($10, $11) ===
Writing $10 or $11 to port $CA will send the "reset" command to the RTC. The S-3511A will then reset the year, month, day-of-month, day-of-week, hour, minute, second, config, and alarm registers. It is unknown if it resets the sub-second prescaler.
=== Write Configuration ($12) ===
Writing $12 to port $CA will send the "set configuration" command to the RTC. The 2003 expects that $CB contains valid contents by the time the 2003 sends that register's contents.
=== Read Configuration ($13) ===
Writing $13 to port $CA will send the "get configuration" command to the RTC.
=== Write current YMDdHMS ($14) ===
Writing $14 will set the current Year, Month, Day-of-Month, Day-of-Week, Hour, Minute, and Second.
=== Read current YMDdHMS ($15) ===
Writing $15 will get the current Year, Month, Day-of-Month, Day-of-Week, Hour, Minute, and Second.
=== Write current HMS ($16) ===
Writing $16 will set the current Hour, Minute, and Second.
These are the same as command $14.
=== Read current HMS ($17) ===
Writing $17 will get the current Hour, Minute, and Second.
=== Write alarm configuration ($18) ===
Writing $18 will set the current alarm configuration. The interpretation of these two bytes depend on the Configuration register
=== Nonsense alarm configuration ($19) ===
Writing $19 will set the current alarm configuration to $FFFF. The 2003 thinks it's reading from the S-3511A, but the S-3511A disagrees.
$FFFF will be read back by the 2003.
=== Write nonsense ($1A) ===
Writing $1A expects to send 2 bytes to the RTC. The S-3511A ignores them.
=== Read nonsense ($1B) ===
Writing $1B expects to read 2 bytes from the RTC. The S-3511A leaves its output high, returning $FFFF.
== Interrupts ==
The 2003 and S-3511A do not provide a thread-safe way to acknowledge the IRQ. Since the 2003 only holds one byte at a time, an interrupt can be fired in the middle of a multi-byte read or write without knowing what needs to be done for the rest of the command, nor how to safely restart that command when exiting the interrupt.
As such, the only choices are:
* all communication to the 2003 happens while Cassette interrupts are disabled, or
* the only thing the interrupt handler can do is [[Interrupts#Interrupt_Enable|mask]] the interrupt and then [[Interrupts#Interrupt_Acknowledge|acknowledge]] it, and only afterwards handle any subsequent communication.
a63417d1cb1746d69e0e3151e8ecbca6ea98b07b
175
174
2023-08-23T23:51:49Z
Lidnariq
7
/* Internal operation */ reflow
wikitext
text/x-wiki
The [[Bandai 2003|2003]] mapper provides a special-purpose interface to interact with Seiko's S-3511A RTC chip.
This page will cover how games expect to interact with it; not the low-level protocol specifics. (For that see the datasheet and the Timing section of this wiki)
== Internal operation ==
The RTC consists of 10 total bytes of user-visible state.
* Configuration
* Alarm configuration
The following are always interpreted as 2 digit packed BCD.
* Year (always assumes 00 is a leap year)
* Month (1=January)
* Day-of-month (1-indexed)
* Day-of-week (0-indexed and free-running, no predefined mapping of number to legal day)
* Hour (0x80s bit is 12/24 state)
* Minute
* Second
=== Configuration ===
7 bit 0
P2A0 M0F0
|||| ||||
|||+--+-+--- always 0
||+--+-+---- IRQ mode
|+---------- 1: 24 hour mode 0: 12 hour mode
+----------- power failure occurred
Sending the Reset or Read Configuration commands clear the "power failure" bit.
Interrupts:
AMF
000 -- "No interrupts" - continuously deasserts /IRQ pin
100 -- "Alarm" - Treat "alarm configuration" as packed BCD HHMM. Assert /IRQ during that hour and minute. Hour encoding must match 12/24 bit setting.
x10 -- "Per-minute edge" - Asserts /IRQ during the first 10 ms of each minute. During following 990ms, /IRQ can be deasserted by reading the configuration register.
x11 -- "Per-minute steady" - Asserts /IRQ during the first 10ms of each minute. De-asserts /IRQ at the 30th second.
x01 -- "Frequency" - subsecond prescaler is bitwise inverted, bitwise ANDed with the lower 15 bits of the "alarm configuration" register, then all fifteen bits are NORed together. This signal directly drives the /IRQ pin.
=== Reset RTC ($10, $11) ===
Writing $10 or $11 to port $CA will send the "reset" command to the RTC. The S-3511A will then reset the year, month, day-of-month, day-of-week, hour, minute, second, config, and alarm registers. It is unknown if it resets the sub-second prescaler.
=== Write Configuration ($12) ===
Writing $12 to port $CA will send the "set configuration" command to the RTC. The 2003 expects that $CB contains valid contents by the time the 2003 sends that register's contents.
=== Read Configuration ($13) ===
Writing $13 to port $CA will send the "get configuration" command to the RTC.
=== Write current YMDdHMS ($14) ===
Writing $14 will set the current Year, Month, Day-of-Month, Day-of-Week, Hour, Minute, and Second.
=== Read current YMDdHMS ($15) ===
Writing $15 will get the current Year, Month, Day-of-Month, Day-of-Week, Hour, Minute, and Second.
=== Write current HMS ($16) ===
Writing $16 will set the current Hour, Minute, and Second.
These are the same as command $14.
=== Read current HMS ($17) ===
Writing $17 will get the current Hour, Minute, and Second.
=== Write alarm configuration ($18) ===
Writing $18 will set the current alarm configuration. The interpretation of these two bytes depend on the Configuration register
=== Nonsense alarm configuration ($19) ===
Writing $19 will set the current alarm configuration to $FFFF. The 2003 thinks it's reading from the S-3511A, but the S-3511A disagrees.
$FFFF will be read back by the 2003.
=== Write nonsense ($1A) ===
Writing $1A expects to send 2 bytes to the RTC. The S-3511A ignores them.
=== Read nonsense ($1B) ===
Writing $1B expects to read 2 bytes from the RTC. The S-3511A leaves its output high, returning $FFFF.
== Interrupts ==
The 2003 and S-3511A do not provide a thread-safe way to acknowledge the IRQ. Since the 2003 only holds one byte at a time, an interrupt can be fired in the middle of a multi-byte read or write without knowing what needs to be done for the rest of the command, nor how to safely restart that command when exiting the interrupt.
As such, the only choices are:
* all communication to the 2003 happens while Cassette interrupts are disabled, or
* the only thing the interrupt handler can do is [[Interrupts#Interrupt_Enable|mask]] the interrupt and then [[Interrupts#Interrupt_Acknowledge|acknowledge]] it, and only afterwards handle any subsequent communication.
a5d1ea33868139574015d329f2b463cecf02fb19
176
175
2023-08-24T07:28:43Z
Asie
351
adjust terminology to match wiki
wikitext
text/x-wiki
The [[Bandai 2003|2003]] mapper provides a special-purpose interface to interact with Seiko's S-3511A RTC chip.
This page will cover how games expect to interact with it; not the low-level protocol specifics. (For that see the datasheet and the Timing section of this wiki)
== Internal operation ==
The RTC consists of 10 total bytes of user-visible state.
* Configuration
* Alarm configuration
The following are always interpreted as 2 digit packed BCD.
* Year (always assumes 00 is a leap year)
* Month (1=January)
* Day-of-month (1-indexed)
* Day-of-week (0-indexed and free-running, no predefined mapping of number to legal day)
* Hour (0x80s bit is 12/24 state)
* Minute
* Second
=== Configuration ===
7 bit 0
P2A0 M0F0
|||| ||||
|||+--+-+--- always 0
||+--+-+---- IRQ mode
|+---------- 1: 24 hour mode 0: 12 hour mode
+----------- power failure occurred
Sending the Reset or Read Configuration commands clear the "power failure" bit.
Interrupts:
AMF
000 -- "No interrupts" - continuously deasserts /IRQ pin
100 -- "Alarm" - Treat "alarm configuration" as packed BCD HHMM. Assert /IRQ during that hour and minute. Hour encoding must match 12/24 bit setting.
x10 -- "Per-minute edge" - Asserts /IRQ during the first 10 ms of each minute. During following 990ms, /IRQ can be deasserted by reading the configuration register.
x11 -- "Per-minute steady" - Asserts /IRQ during the first 10ms of each minute. De-asserts /IRQ at the 30th second.
x01 -- "Frequency" - subsecond prescaler is bitwise inverted, bitwise ANDed with the lower 15 bits of the "alarm configuration" register, then all fifteen bits are NORed together. This signal directly drives the /IRQ pin.
=== Reset RTC ($10, $11) ===
Writing $10 or $11 to port $CA will send the "reset" command to the RTC. The S-3511A will then reset the year, month, day-of-month, day-of-week, hour, minute, second, config, and alarm registers. It is unknown if it resets the sub-second prescaler.
=== Write Configuration ($12) ===
Writing $12 to port $CA will send the "set configuration" command to the RTC. The 2003 expects that $CB contains valid contents by the time the 2003 sends that register's contents.
=== Read Configuration ($13) ===
Writing $13 to port $CA will send the "get configuration" command to the RTC.
=== Write current YMDdHMS ($14) ===
Writing $14 will set the current Year, Month, Day-of-Month, Day-of-Week, Hour, Minute, and Second.
=== Read current YMDdHMS ($15) ===
Writing $15 will get the current Year, Month, Day-of-Month, Day-of-Week, Hour, Minute, and Second.
=== Write current HMS ($16) ===
Writing $16 will set the current Hour, Minute, and Second.
These are the same as command $14.
=== Read current HMS ($17) ===
Writing $17 will get the current Hour, Minute, and Second.
=== Write alarm configuration ($18) ===
Writing $18 will set the current alarm configuration. The interpretation of these two bytes depend on the Configuration register
=== Nonsense alarm configuration ($19) ===
Writing $19 will set the current alarm configuration to $FFFF. The 2003 thinks it's reading from the S-3511A, but the S-3511A disagrees.
$FFFF will be read back by the 2003.
=== Write nonsense ($1A) ===
Writing $1A expects to send 2 bytes to the RTC. The S-3511A ignores them.
=== Read nonsense ($1B) ===
Writing $1B expects to read 2 bytes from the RTC. The S-3511A leaves its output high, returning $FFFF.
== Interrupts ==
The 2003 and S-3511A do not provide a thread-safe way to acknowledge the IRQ. Since the 2003 only holds one byte at a time, an interrupt can be fired in the middle of a multi-byte read or write without knowing what needs to be done for the rest of the command, nor how to safely restart that command when exiting the interrupt.
As such, the only choices are:
* all communication to the 2003 happens while cartridge IRQs are disabled, or
* the only thing the interrupt handler can do is [[Interrupts#Interrupt_Enable|mask]] the interrupt and then [[Interrupts#Interrupt_Acknowledge|acknowledge]] it, and only afterwards handle any subsequent communication.
510ff6fb004672590762e9735a6a7063929a5ed1
177
176
2023-08-24T17:41:27Z
Lidnariq
7
/* Internal operation */
wikitext
text/x-wiki
The [[Bandai 2003|2003]] mapper provides a special-purpose interface to interact with Seiko's S-3511A RTC chip.
This page will cover how games expect to interact with it; not the low-level protocol specifics. (For that see the datasheet and the Timing section of this wiki)
== Internal operation ==
The RTC consists of 10 total bytes of user-visible state.
* Configuration
* Alarm configuration (2 bytes)
The following are always interpreted as 2 digit packed BCD.
* Year (always assumes 00 is a leap year)
* Month (1=January)
* Day-of-month (1-indexed)
* Day-of-week (0-indexed and free-running, no predefined mapping of number to legal day)
* Hour (0x80s bit is 12/24 state)
* Minute
* Second
=== Configuration ===
7 bit 0
P2A0 M0F0
|||| ||||
|||+--+-+--- always 0
||+--+-+---- IRQ mode
|+---------- 1: 24 hour mode 0: 12 hour mode
+----------- power failure occurred
Sending the Reset or Read Configuration commands clear the "power failure" bit.
Interrupts:
AMF
000 -- "No interrupts" - continuously deasserts /IRQ pin
100 -- "Alarm" - Treat "alarm configuration" as packed BCD HHMM. Assert /IRQ during that hour and minute. Hour encoding must match 12/24 bit setting.
x10 -- "Per-minute edge" - Asserts /IRQ during the first 10 ms of each minute. During following 990ms, /IRQ can be deasserted by reading the configuration register.
x11 -- "Per-minute steady" - Asserts /IRQ during the first 10ms of each minute. De-asserts /IRQ at the 30th second.
x01 -- "Frequency" - subsecond prescaler is bitwise inverted, bitwise ANDed with the lower 15 bits of the "alarm configuration" register, then all fifteen bits are NORed together. This signal directly drives the /IRQ pin.
=== Reset RTC ($10, $11) ===
Writing $10 or $11 to port $CA will send the "reset" command to the RTC. The S-3511A will then reset the year, month, day-of-month, day-of-week, hour, minute, second, config, and alarm registers. It is unknown if it resets the sub-second prescaler.
=== Write Configuration ($12) ===
Writing $12 to port $CA will send the "set configuration" command to the RTC. The 2003 expects that $CB contains valid contents by the time the 2003 sends that register's contents.
=== Read Configuration ($13) ===
Writing $13 to port $CA will send the "get configuration" command to the RTC.
=== Write current YMDdHMS ($14) ===
Writing $14 will set the current Year, Month, Day-of-Month, Day-of-Week, Hour, Minute, and Second.
=== Read current YMDdHMS ($15) ===
Writing $15 will get the current Year, Month, Day-of-Month, Day-of-Week, Hour, Minute, and Second.
=== Write current HMS ($16) ===
Writing $16 will set the current Hour, Minute, and Second.
These are the same as command $14.
=== Read current HMS ($17) ===
Writing $17 will get the current Hour, Minute, and Second.
=== Write alarm configuration ($18) ===
Writing $18 will set the current alarm configuration. The interpretation of these two bytes depend on the Configuration register
=== Nonsense alarm configuration ($19) ===
Writing $19 will set the current alarm configuration to $FFFF. The 2003 thinks it's reading from the S-3511A, but the S-3511A disagrees.
$FFFF will be read back by the 2003.
=== Write nonsense ($1A) ===
Writing $1A expects to send 2 bytes to the RTC. The S-3511A ignores them.
=== Read nonsense ($1B) ===
Writing $1B expects to read 2 bytes from the RTC. The S-3511A leaves its output high, returning $FFFF.
== Interrupts ==
The 2003 and S-3511A do not provide a thread-safe way to acknowledge the IRQ. Since the 2003 only holds one byte at a time, an interrupt can be fired in the middle of a multi-byte read or write without knowing what needs to be done for the rest of the command, nor how to safely restart that command when exiting the interrupt.
As such, the only choices are:
* all communication to the 2003 happens while cartridge IRQs are disabled, or
* the only thing the interrupt handler can do is [[Interrupts#Interrupt_Enable|mask]] the interrupt and then [[Interrupts#Interrupt_Acknowledge|acknowledge]] it, and only afterwards handle any subsequent communication.
aad9bb9c4a478d115abf42b6e5149e2657527904
WonderWitch
0
41
180
2023-08-25T06:10:28Z
Asie
351
Created page with "The WonderWitch is an official homebrew development kit released by Qute Corporation on July 18th, 2000. == Hardware == The WonderWitch cartridge is based on the [[Bandai 2003]] mapper. It provides an RTC, as well as NOR self-flashing functionality using the Fujitsu MBM29DL400TC chip. There were three ways available to acquire WonderWitch cartridges: * '''WonderWitch''', a software development kit containing a reflashable cartridge, a WonderSwan<->RS-232 adapter, a d..."
wikitext
text/x-wiki
The WonderWitch is an official homebrew development kit released by Qute Corporation on July 18th, 2000.
== Hardware ==
The WonderWitch cartridge is based on the [[Bandai 2003]] mapper. It provides an RTC, as well as NOR self-flashing functionality using the Fujitsu MBM29DL400TC chip.
There were three ways available to acquire WonderWitch cartridges:
* '''WonderWitch''', a software development kit containing a reflashable cartridge, a WonderSwan<->RS-232 adapter, a development manual and a development tool CD;
* '''WonderWitch Player''', a priced-down user-only version omitting the development manual and tooling;
* The VAR program, allowing independent creators to buy reflashable cartridges in bulk, in units of 20 or 100.
== Software ==
The 512KB of NOR flash memory is mapped and partitioned as follows:
{| class="wikitable"
! Linear address
! Size
! Description
|-
| 0x8nnnn
| rowspan="6" | 384 KB
| rowspan="6" | [[WonderWitch/File system|File system]]
|-
| 0x9nnnn
|-
| 0xAnnnn
|-
| 0xBnnnn
|-
| 0xCnnnn
|-
| 0xDnnnn
|-
| 0xEnnnn
| 64 KB
| [[WonderWitch/FreyaOS|FreyaOS]]
|-
| 0xFnnnn
| 64 KB
| [[WonderWitch/FreyaBIOS|FreyaBIOS]]
|}
== Development Tools ==
TODO
== Links ==
* [https://github.com/up-n-atom/WonderWitch/blob/main/Datasheets/MBM29DL400BC-12PFTN_to_MBM29DL400TC-90PFTN.pdf Fujitsu MBM29DL400TC datasheet]
566f634e6aae48b73f50f4bb68d44303d03a5fae
WonderWitch/FreyaBIOS
0
42
181
2023-08-25T06:16:03Z
Asie
351
Created page with "FreyaBIOS is a boot program and hardware abstraction layer for [[WonderWitch]], present in the top-most (last) 64 KB of any WonderWitch cartridge. It provides the following functionality: * bring-up code, * interrupt-based hardware abstraction layer, providing a more user-friendly (and less direct) interface to the WonderSwan hardware, * a monitor program, allowing FreyaOS recovery and updates via XMODEM. Other functionality (like file system access) is instead includ..."
wikitext
text/x-wiki
FreyaBIOS is a boot program and hardware abstraction layer for [[WonderWitch]], present in the top-most (last) 64 KB of any WonderWitch cartridge.
It provides the following functionality:
* bring-up code,
* interrupt-based hardware abstraction layer, providing a more user-friendly (and less direct) interface to the WonderSwan hardware,
* a monitor program, allowing FreyaOS recovery and updates via XMODEM.
Other functionality (like file system access) is instead included as part of [[WonderWitch/FreyaOS|FreyaOS]]' system libraries; some other functionality (like WonderSwan Color support is implemented as part of the development tooling.
== Revisions ==
TODO
== Interrupts ==
* [[WonderWitch/FreyaBIOS/Exit|Exit]] (INT $10)
* [[WonderWitch/FreyaBIOS/Key|Key]] (INT $11)
* [[WonderWitch/FreyaBIOS/Display|Display]] (INT $12)
* [[WonderWitch/FreyaBIOS/Text|Text]] (INT $13)
* [[WonderWitch/FreyaBIOS/Communication|Communication]] (INT $14)
* [[WonderWitch/FreyaBIOS/Sound|Sound]] (INT $15)
* [[WonderWitch/FreyaBIOS/Timer|Timer]] (INT $16)
* [[WonderWitch/FreyaBIOS/System|System]] (INT $17)
* [[WonderWitch/FreyaBIOS/Bank|Bank]] (INT $18)
== Freya Monitor ==
TODO
6bd7cf8d2d0effa3cb049dfbfc970055d9dee56d
182
181
2023-08-25T06:20:22Z
Asie
351
wikitext
text/x-wiki
FreyaBIOS is a boot program and hardware abstraction layer for [[WonderWitch]], present in the top-most (last) 64 KB of any WonderWitch cartridge.
It provides the following functionality:
* bring-up code,
* interrupt-based hardware abstraction layer, providing a more user-friendly (and less direct) interface to the WonderSwan hardware,
* 8x8 ASCII and kanji fonts,
* a monitor program, allowing FreyaOS recovery and updates via XMODEM.
Other functionality (like file system access) is instead included as part of [[WonderWitch/FreyaOS|FreyaOS]]' system libraries; some other functionality (like WonderSwan Color support is implemented as part of the development tooling.
== Revisions ==
TODO
== Interrupts ==
* [[WonderWitch/FreyaBIOS/Exit|Exit]] (INT $10)
* [[WonderWitch/FreyaBIOS/Key|Key]] (INT $11)
* [[WonderWitch/FreyaBIOS/Display|Display]] (INT $12)
* [[WonderWitch/FreyaBIOS/Text|Text]] (INT $13)
* [[WonderWitch/FreyaBIOS/Communication|Communication]] (INT $14)
* [[WonderWitch/FreyaBIOS/Sound|Sound]] (INT $15)
* [[WonderWitch/FreyaBIOS/Timer|Timer]] (INT $16)
* [[WonderWitch/FreyaBIOS/System|System]] (INT $17)
* [[WonderWitch/FreyaBIOS/Bank|Bank]] (INT $18)
== Freya Monitor ==
TODO
7e33c04d2b0a361866b0b73a4721cc7d6eaaa98b
Keypad
0
9
183
118
2023-08-25T06:24:34Z
Asie
351
formatting
wikitext
text/x-wiki
The WonderSwan SoC features a 4 by 3 keypad matrix.
== I/O Ports ==
=== Keypad Scan ($B5) ===
Scanning is done via writing to and reading from port $B5.
<pre>
7 bit 0
---- ----
.iii oooo
||| ||||
||| ++++- Output rows (0-3)
+++------ Input rows (4-6)
</pre>
The standard procedure is to read rows controlled by bit 4, bit 5, then bit 6 in order, shifting their values into one twelve-bit mask like so:
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
.... 4444 5555 6666
</pre>
Typical keypad scanning implementations introduce a delay between writing to and reading from the matrix, allowing the scanned values to stabilize. For example, one can use the DAA opcode for doing so.
== Startup override ==
On startup, the [[boot ROM]] checks whether or not certain output rows are forced high when all input rows are disabled. This triggers a startup override prior to the boot logo:
* Input row 0 - jump to 4000:0000,
* Input row 1 - jump to 4000:0010.
As this override is done before boot ROM lockout, it can be used to dump the boot ROM.
== Keypad arrangement ==
=== WonderSwan ===
==== Layout ====
<pre>
Y1
Y4 Y2
Y3
X1
X4 X2 A
X3 Sound Start Power B
(St)
</pre>
Sound and Power buttons are not exposed directly to software.
==== Matrix ====
<pre>
Bit O 3 2 1 0
I | | | |
| | | |
4--- Y4 - Y3 - Y2 - Y1 -
| | | |
5--- X4 - X3 - X2 - X1 -
| | | |
6--- B - A - St ---+--
| | | |
</pre>
==== Bit mask ====
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
.... yyyy xxxx bas.
|||| |||| |||
|||| |||| ||+- Start
|||| |||| |+-- A
|||| |||| +--- B
|||| ++++----- X4, X3, X2, X1
++++----------- Y4, Y3, Y2, Y1
</pre>
=== Pocket Challenge V2 ===
==== Layout ====
<pre>
Power
Esc
View
Up Clear
(Clr)
Lft Rgh Circle
(Crc)
Dwn Pass
(Pas)
</pre>
The Power switch is not exposed directly to software.
==== Matrix ====
<pre>
Bit O 3 2 1 0
I | | | |
| | | |
4--- Pas Crc --+-- Clr -
| | | |
5--- Rgh Esc --+- View -
| | | |
6--- Up - Dwn --+-- Lft -
| | | |
[1]
</pre>
==== Bit mask ====
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
.... pc1C re1v ud1l
|| | || | || |
|| | || | || +- Left
|| | || | |+--- Down
|| | || | +---- Up
|| | || +------ View
|| | |+-------- Esc
|| | +--------- Right
|| +----------- Clear
|+------------- Circle
+-------------- Pass
</pre>
5a5167d16ae0e6b42ad821dfc6c256673ed97b3a
Accessory port pinout
0
43
184
2023-08-25T09:29:07Z
Asie
351
Created page with "The WonderSwan accessory (EXT) port provides an [[UART]] serial port and I<sup>2</sup>S digital audio output. == Pinout == (Female 8-pin port on peripheral) <pre> MISO_ _MOSI \ / +3V_ \ / _GND ______\ __\ __ /__ /______ | 04__03__02__01 | | __|"" "" "" ""|__ | | |__ __| | '. |..__..__..__..| .' \____05__06__07__08____/ _/ / \ \_ BCLK /..."
wikitext
text/x-wiki
The WonderSwan accessory (EXT) port provides an [[UART]] serial port and I<sup>2</sup>S digital audio output.
== Pinout ==
(Female 8-pin port on peripheral)
<pre>
MISO_ _MOSI
\ /
+3V_ \ / _GND
______\ __\ __ /__ /______
| 04__03__02__01 |
| __|"" "" "" ""|__ |
| |__ __| |
'. |..__..__..__..| .'
\____05__06__07__08____/
_/ / \ \_
BCLK / \ /HDPN
_/ \_
LRCK SDAT
</pre>
{| class="wikitable"
|-
! Pin !! Group !! Description
|-
| 01 (GND)
| Power
| Ground
|-
| 02 (MOSI)
| rowspan="2" | [[UART]]
| WonderSwan -> accessory
|-
| 03 (MISO)
| Accessory -> WonderSwan
|-
| 04 (+3V)
| Power
| 3.3 volt?
|-
| 05 (BCLK)
| rowspan="4" | I<sup>2</sup>S
| Bit clock
|-
| 06 (LRCK)
| Channel clock
|-
| 07 (SDAT)
| Bit data
|-
| 08 (/HDPN)
| Headphone detect
|}
== HDMI connector mapping ==
Thanks to luck, it turns out that female HDMI connectors are - to some extent - electrically compatible with male EXT port connectors:
* Using an HDMI plug may cause increased wear on the connector.
* A typical HDMI cable port lacks the plastic sleeve around the connector, leading to a loose connection.
** One solution is to 3D-print a sleeve to improve connection.
** Another solution is to include some type of LED/indicator in order to validate proper connection.
Nonetheless, due to the lack of availability of new EXT port connectors, this is a popular solution for DIY users and lower-end aftermarket accessories. The HDMI pinout maps as follows:
{| class="wikitable"
|-
! EXT !! HDMI
| 01 (GND)
| 15 (SCL)
|-
| 02 (MOSI)
| 11 (TMDS Clock Shield)
|-
| 03 (MISO)
| 7 (TMDS Data 0 +)
|-
| 04 (+3V)
| 3 (TMDS Data 2 -)
|-
| 05 (BCLK)
| 4 (TMDS Data 1 +)
|-
| 06 (LRCK)
| 8 (TMDS Data 0 Shield)
|-
| 07 (SDAT)
| 12 (TMDS Clock -)
|-
| 08 (/HDPN)
| 16 (SDA)
|}
2ee56876eb167b3254a5a77eea85d9a5c3abd0b7
185
184
2023-08-25T09:29:25Z
Asie
351
wikitext
text/x-wiki
The WonderSwan accessory (EXT) port provides an [[UART]] serial port and I<sup>2</sup>S digital audio output.
== Pinout ==
(Female 8-pin port on peripheral)
<pre>
MISO_ _MOSI
\ /
+3V_ \ / _GND
______\ __\ __ /__ /______
| 04__03__02__01 |
| __|"" "" "" ""|__ |
| |__ __| |
'. |..__..__..__..| .'
\____05__06__07__08____/
_/ / \ \_
BCLK / \ /HDPN
_/ \_
LRCK SDAT
</pre>
{| class="wikitable"
|-
! Pin !! Group !! Description
|-
| 01 (GND)
| Power
| Ground
|-
| 02 (MOSI)
| rowspan="2" | [[UART]]
| WonderSwan -> accessory
|-
| 03 (MISO)
| Accessory -> WonderSwan
|-
| 04 (+3V)
| Power
| 3.3 volt?
|-
| 05 (BCLK)
| rowspan="4" | I<sup>2</sup>S
| Bit clock
|-
| 06 (LRCK)
| Channel clock
|-
| 07 (SDAT)
| Bit data
|-
| 08 (/HDPN)
| Headphone detect
|}
== HDMI connector mapping ==
Thanks to luck, it turns out that female HDMI connectors are - to some extent - electrically compatible with male EXT port connectors:
* Using an HDMI plug may cause increased wear on the connector.
* A typical HDMI cable port lacks the plastic sleeve around the connector, leading to a loose connection.
** One solution is to 3D-print a sleeve to improve connection.
** Another solution is to include some type of LED/indicator in order to validate proper connection.
Nonetheless, due to the lack of availability of new EXT port connectors, this is a popular solution for DIY users and lower-end aftermarket accessories. The HDMI pinout maps as follows:
{| class="wikitable"
|-
! EXT !! HDMI
|-
| 01 (GND)
| 15 (SCL)
|-
| 02 (MOSI)
| 11 (TMDS Clock Shield)
|-
| 03 (MISO)
| 7 (TMDS Data 0 +)
|-
| 04 (+3V)
| 3 (TMDS Data 2 -)
|-
| 05 (BCLK)
| 4 (TMDS Data 1 +)
|-
| 06 (LRCK)
| 8 (TMDS Data 0 Shield)
|-
| 07 (SDAT)
| 12 (TMDS Clock -)
|-
| 08 (/HDPN)
| 16 (SDA)
|}
aad8020be70496cdd6062f70b51f4cbe3760fb8a
186
185
2023-08-25T09:29:39Z
Asie
351
wikitext
text/x-wiki
The WonderSwan accessory (EXT) port provides an [[UART]] serial port and I<sup>2</sup>S digital audio output.
== Pinout ==
(Female 8-pin port on peripheral)
<pre>
MISO_ _MOSI
\ /
+3V_ \ / _GND
______\ __\ __ /__ /______
| 04__03__02__01 |
| __|"" "" "" ""|__ |
| |__ __| |
'. |..__..__..__..| .'
\____05__06__07__08____/
_/ / \ \_
BCLK / \ /HDPN
_/ \_
LRCK SDAT
</pre>
{| class="wikitable"
|-
! Pin !! Group !! Description
|-
| 01 (GND)
| Power
| Ground
|-
| 02 (MOSI)
| rowspan="2" | [[UART]]
| WonderSwan -> Accessory
|-
| 03 (MISO)
| Accessory -> WonderSwan
|-
| 04 (+3V)
| Power
| 3.3 volt?
|-
| 05 (BCLK)
| rowspan="4" | I<sup>2</sup>S
| Bit clock
|-
| 06 (LRCK)
| Channel clock
|-
| 07 (SDAT)
| Bit data
|-
| 08 (/HDPN)
| Headphone detect
|}
== HDMI connector mapping ==
Thanks to luck, it turns out that female HDMI connectors are - to some extent - electrically compatible with male EXT port connectors:
* Using an HDMI plug may cause increased wear on the connector.
* A typical HDMI cable port lacks the plastic sleeve around the connector, leading to a loose connection.
** One solution is to 3D-print a sleeve to improve connection.
** Another solution is to include some type of LED/indicator in order to validate proper connection.
Nonetheless, due to the lack of availability of new EXT port connectors, this is a popular solution for DIY users and lower-end aftermarket accessories. The HDMI pinout maps as follows:
{| class="wikitable"
|-
! EXT !! HDMI
|-
| 01 (GND)
| 15 (SCL)
|-
| 02 (MOSI)
| 11 (TMDS Clock Shield)
|-
| 03 (MISO)
| 7 (TMDS Data 0 +)
|-
| 04 (+3V)
| 3 (TMDS Data 2 -)
|-
| 05 (BCLK)
| 4 (TMDS Data 1 +)
|-
| 06 (LRCK)
| 8 (TMDS Data 0 Shield)
|-
| 07 (SDAT)
| 12 (TMDS Clock -)
|-
| 08 (/HDPN)
| 16 (SDA)
|}
a124e4b736c4fbafb198de8a02f7183a1eda27dc
187
186
2023-08-25T09:30:02Z
Asie
351
wikitext
text/x-wiki
The WonderSwan accessory (EXT) port provides an [[UART]] serial port and I<sup>2</sup>S digital audio output.
== Pinout ==
(Female 8-pin port on peripheral)
<pre>
MISO_ _MOSI
\ /
+3V_ \ / _GND
______\ __\ __ /__ /______
| 04__03__02__01 |
| __|"" "" "" ""|__ |
| |__ __| |
'. |..__..__..__..| .'
\____05__06__07__08____/
_/ / \ \_
BCLK / \ /HDPN
_/ \_
LRCK SDAT
</pre>
{| class="wikitable"
|-
! Pin !! Group !! Description
|-
| 01 (GND)
| Power
| Ground
|-
| 02 (MOSI)
| rowspan="2" | [[UART]]
| WonderSwan -> Accessory
|-
| 03 (MISO)
| Accessory -> WonderSwan
|-
| 04 (+3V)
| Power
| 3.3 volt?
|-
| 05 (BCLK)
| rowspan="4" | I<sup>2</sup>S
| Bit clock
|-
| 06 (LRCK)
| Channel clock
|-
| 07 (SDAT)
| Bit data
|-
| 08 (/HDPN)
| Headphone detect
|}
== HDMI connector mapping ==
Thanks to luck, it turns out that male HDMI connectors are - to some extent - electrically compatible with male EXT port connectors:
* Using an HDMI plug may cause increased wear on the connector.
* A typical HDMI cable port lacks the plastic sleeve around the connector, leading to a loose connection.
** One solution is to 3D-print a sleeve to improve connection.
** Another solution is to include some type of LED/indicator in order to validate proper connection.
Nonetheless, due to the lack of availability of new EXT port connectors, this is a popular solution for DIY users and lower-end aftermarket accessories. The HDMI pinout maps as follows:
{| class="wikitable"
|-
! EXT !! HDMI
|-
| 01 (GND)
| 15 (SCL)
|-
| 02 (MOSI)
| 11 (TMDS Clock Shield)
|-
| 03 (MISO)
| 7 (TMDS Data 0 +)
|-
| 04 (+3V)
| 3 (TMDS Data 2 -)
|-
| 05 (BCLK)
| 4 (TMDS Data 1 +)
|-
| 06 (LRCK)
| 8 (TMDS Data 0 Shield)
|-
| 07 (SDAT)
| 12 (TMDS Clock -)
|-
| 08 (/HDPN)
| 16 (SDA)
|}
bc4a9cc028166091263245c1f6738c2046e600e0
188
187
2023-08-25T09:30:21Z
Asie
351
wikitext
text/x-wiki
The WonderSwan accessory (EXT) port provides an [[UART]] serial port and I<sup>2</sup>S digital audio output.
== Pinout ==
(Female 8-pin port on peripheral)
<pre>
MISO_ _MOSI
\ /
+3V_ \ / _GND
______\ __\ __ /__ /______
| 04__03__02__01 |
| __|"" "" "" ""|__ |
| |__ __| |
'. |..__..__..__..| .'
\____05__06__07__08____/
_/ / \ \_
BCLK / \ /HDPN
_/ \_
LRCK SDAT
</pre>
{| class="wikitable"
|-
! Pin !! Group !! Description
|-
| 01 (GND)
| Power
| Ground
|-
| 02 (MOSI)
| rowspan="2" | [[UART]]
| WonderSwan -> Accessory
|-
| 03 (MISO)
| Accessory -> WonderSwan
|-
| 04 (+3V)
| Power
| 3.3 volt?
|-
| 05 (BCLK)
| rowspan="4" | I<sup>2</sup>S
| Bit clock
|-
| 06 (LRCK)
| Channel clock
|-
| 07 (SDAT)
| Bit data
|-
| 08 (/HDPN)
| Headphone detect
|}
== HDMI connector mapping ==
Thanks to luck, it turns out that male HDMI connectors are - to some extent - electrically compatible with male EXT port connectors, allowing to use them as a replacement for a female EXT port connector:
* Using an HDMI plug may cause increased wear on the connector.
* A typical HDMI cable port lacks the plastic sleeve around the connector, leading to a loose connection.
** One solution is to 3D-print a sleeve to improve connection.
** Another solution is to include some type of LED/indicator in order to validate proper connection.
Nonetheless, due to the lack of availability of new EXT port connectors, this is a popular solution for DIY users and lower-end aftermarket accessories. The HDMI pinout maps as follows:
{| class="wikitable"
|-
! EXT !! HDMI
|-
| 01 (GND)
| 15 (SCL)
|-
| 02 (MOSI)
| 11 (TMDS Clock Shield)
|-
| 03 (MISO)
| 7 (TMDS Data 0 +)
|-
| 04 (+3V)
| 3 (TMDS Data 2 -)
|-
| 05 (BCLK)
| 4 (TMDS Data 1 +)
|-
| 06 (LRCK)
| 8 (TMDS Data 0 Shield)
|-
| 07 (SDAT)
| 12 (TMDS Clock -)
|-
| 08 (/HDPN)
| 16 (SDA)
|}
887631e64eb2c77ee97559a4e8054bc517419d86
Cartridge connector
0
44
190
2023-08-25T16:44:47Z
Asie
351
Created page with " == Pinout == <pre> Cartridge Console (label side) (back) ____________ |====| ____ |--01| -- GND ... \ | -02| <- CPU A15 ... | | -03| <- CPU A10 ... | | -04| <- CPU A11 ... | | -05| <- CPU A9 ... | | -06| <- CPU A8 ... | | -07| <- CPU A13 ... | | -08| <- CPU A14 ... | | -09| <- CPU A12 ... | | -10| <- CPU A7 ... | | -11| <- CPU A6 ... | | -12| <- CPU A5 ... | | -13| <- CPU A4 ... | | -14| <> D15 ... | | -15| <> D14 ... | |..."
wikitext
text/x-wiki
== Pinout ==
<pre>
Cartridge Console
(label side) (back)
____________
|====|
____ |--01| -- GND
... \ | -02| <- CPU A15
... | | -03| <- CPU A10
... | | -04| <- CPU A11
... | | -05| <- CPU A9
... | | -06| <- CPU A8
... | | -07| <- CPU A13
... | | -08| <- CPU A14
... | | -09| <- CPU A12
... | | -10| <- CPU A7
... | | -11| <- CPU A6
... | | -12| <- CPU A5
... | | -13| <- CPU A4
... | | -14| <> D15
... | | -15| <> D14
... | | -16| <> D7
... | | -17| <> D6
... | | -18| <> D5
... | | -19| <> D4
... | | -20| <> D3
... | | -21| <> D2
... | | -22| <> D1
... | | -23| <> D0
... | |--24| -- +3.3V
... | |--25| -- +3.3V
... | | -26| <- CPU A0
... | | -27| <- CPU A1
... | | -28| <- CPU A2
... | | -29| <- CPU A3
... | | -30| <- CPU A19
... | | -31| <- CPU A18
... | | -32| <- CPU A17
... | | -33| <- CPU A16
... | | -34| <> D8
... | | -35| <> D9
... | | -36| <> D10
... | | -37| <> D11
... | | -38| <> D12
... | | -39| <> D13
... | | -40| <- /Reset
... | | -41| <- /MBC
... | | -42| <- M/IO (Memory/IO)
... | | -43| <- /RD (Read enable)
... | | -44| <- /WR (Write enable)
... | | -45| <- /SEL (Cartridge select)
... | | -46| -> /IRQ (Interrupt request)
... | | -47| <- CLK (384 KHz clock)
... | |--48| -- GND
_______|====|
Cartridge Console
(label side) (back)
</pre>
2cbbd3d1bfa1bef4af87b44d1999c031d1930169
191
190
2023-08-25T16:45:35Z
Asie
351
/* Pinout */ art tweaks
wikitext
text/x-wiki
== Pinout ==
<pre>
Cartridge Console
(label side) (back)
____________
|====|
____ |--01| -- GND
... \ | -02| <- CPU A15
... | | -03| <- CPU A10
... | | -04| <- CPU A11
... | | -05| <- CPU A9
... | | -06| <- CPU A8
... | | -07| <- CPU A13
... | | -08| <- CPU A14
... | | -09| <- CPU A12
... | | -10| <- CPU A7
... | | -11| <- CPU A6
... | | -12| <- CPU A5
... | | -13| <- CPU A4
... | | -14| <> D15
... | | -15| <> D14
... | | -16| <> D7
... | | -17| <> D6
... | | -18| <> D5
... | | -19| <> D4
... | | -20| <> D3
... | | -21| <> D2
... | | -22| <> D1
... | | -23| <> D0
... | |--24| -- +3.3V
... | |--25| -- +3.3V
... | | -26| <- CPU A0
... | | -27| <- CPU A1
... | | -28| <- CPU A2
... | | -29| <- CPU A3
... | | -30| <- CPU A19
... | | -31| <- CPU A18
... | | -32| <- CPU A17
... | | -33| <- CPU A16
... | | -34| <> D8
... | | -35| <> D9
... | | -36| <> D10
... | | -37| <> D11
... | | -38| <> D12
... | | -39| <> D13
... | | -40| <- /Reset
... | | -41| <- /MBC
... | | -42| <- M/IO (Memory/IO)
... | | -43| <- /RD (Read enable)
... | | -44| <- /WR (Write enable)
... | | -45| <- /SEL (Cartridge select)
... | | -46| -> /IRQ (Interrupt request)
____/ | -47| <- CLK (384 KHz clock)
|--48| -- GND
_______|====|
Cartridge Console
(label side) (back)
</pre>
c0cc59ff44f9af3c33ac1388a1fb2c4f30dcae71
Cartridge
0
45
192
2023-08-25T16:48:46Z
Asie
351
Created page with "== Cartridge bus == The cartridge bus allows both memory access (to linear addresses 0x10000-0xFFFFF) and I/O access (to ports 0xC0-0xFF). To facilitate this, the Memory/IO pin is used: * When Memory/IO is asserted '''high''', all bus address pins specify the 20-bit linear memory address. * When Memory/IO is asserted '''low''', bus address pins 0-7 specify the port address bits 0-7, bus address pins 8-15 are low, bus address pins 16-19 specify the port address bits 4-..."
wikitext
text/x-wiki
== Cartridge bus ==
The cartridge bus allows both memory access (to linear addresses 0x10000-0xFFFFF) and I/O access (to ports 0xC0-0xFF).
To facilitate this, the Memory/IO pin is used:
* When Memory/IO is asserted '''high''', all bus address pins specify the 20-bit linear memory address.
* When Memory/IO is asserted '''low''', bus address pins 0-7 specify the port address bits 0-7, bus address pins 8-15 are low, bus address pins 16-19 specify the port address bits 4-7.
== Interrupts ==
The cartridge bus provides an /IRQ pin which can be used by the cartridge to assert an interrupt.
a4b2b9b9463bc4b4924369abb1f2d0b578e1de43
SoC
0
46
195
2023-08-25T16:55:56Z
Asie
351
Created page with "The WonderSwan SoC is a single-chip solution powering the entirety of the system's hardware - containing the CPU, most peripheral logic, as well as the internal RAM. There exist three variants of the SoC: * ASWAN, used in the WonderSwan, * SPHINX, used in the WonderSwan Color, * SPHINX2, used in the SwanCrystal. A fourth variant, CAIRO, was planned. It was designed as an ASWAN with a doubled clock speed and a built-in ADPCM decoder, but was never licensed for a commer..."
wikitext
text/x-wiki
The WonderSwan SoC is a single-chip solution powering the entirety of the system's hardware - containing the CPU, most peripheral logic, as well as the internal RAM.
There exist three variants of the SoC:
* ASWAN, used in the WonderSwan,
* SPHINX, used in the WonderSwan Color,
* SPHINX2, used in the SwanCrystal.
A fourth variant, CAIRO, was planned. It was designed as an ASWAN with a doubled clock speed and a built-in ADPCM decoder, but was never licensed for a commercial product.
== I/O ports ==
{{Anchor|System Control}}
=== System Control ($A0) ===
<pre>
7 bit 0
---- ----
t??? swcl
| ||||
| |||+- Boot ROM lockout: 0 = off, 1 = on
| ||+-- Color model: 0 = no, 1 = yes
| |+--- Cartridge bus width: 0 = 8-bit, 1 = 16-bit
| +---- Cartridge bus speed; 0 = 3 cycles, 1 = 1 cycle
+--------- MBC authentication successful?
</pre>
{{Anchor|System Control 2}}
=== System Control 2 ($60, color) ===
<pre>
7 bit 0
---- ----
c4C. ?.??
|||
||+------- 1 = 4bpp "chunky"; requires all previous
|+-------- 1 = 4bpp; requires all previous
+--------- 0 = mono, 1 = color; also controls access
to WSC-specific features (extra RAM, DMA, etc.)
</pre>
{{Anchor|System Control 3}}
=== System Control 3 ($62, color) ===
<pre>
7 bit 0
---- ----
S... ...p
| |
| +- 1 = Power off system
+--------- 0 = WonderSwan Color (SPHINX)
1 = SwanCrystal (SPHINX2)
</pre>
0ef957dff9fde2df44c7522d6cb571a31fadf3f5
WonderGate
0
14
196
47
2023-08-25T17:04:15Z
Asie
351
wikitext
text/x-wiki
The WonderGate is a PPP Internet adapter for the WonderSwan, utilizing a PDC-standard mobile phone as a modem.
== Commands ==
All command communication uses the following format over 9,600 baud [[UART]]:
{| class="wikitable"
|-
! Offset !! Length !! Description
|-
| $00 || 1 || Command type
|-
| $01 || 1 || Zero?
|-
| $02 || 1 || Remaining length (from $03 onwards)
|-
| $03 || 1 || Command
|-
| $04 || ... || Parameters
|}
The following command IDs will be provided in the <code>Type:Command</code> format.
=== Check PDC status ($01:$00) ===
=== Initialize adapter ($01:$02) ===
=== Dial phone number ($01:$08) ===
=== Hang up ($01:$0A) ===
=== Set PPP login/password ($01:$10) ===
=== Set DNS servers ($01:$11) ===
=== Get adapter status ($02:$01) ===
=== Deinitialize adapter ($0F:$FF) ===
=== Create socket ($11:$01) ===
=== Connect to socket ($11:$03) ===
=== Close socket ($11:$07) ===
=== Get host name/IP address ($11:$08) ===
=== Read line from socket ($11:$0D) ===
=== Write bytes to socket ($11:$0E) ===
=== Read bytes from socket ($11:$0F) ===
== Servers ==
{| class="wikitable"
|-
! Software !! Hostname
|-
| rowspan="2" | MobileWonderGate (web browser)
| [[WonderGate/bplXX.mopera.ne.jp|bpl01.mopera.ne.jp]]
|-
| [[WonderGate/bplXX.mopera.ne.jp|bpl02.mopera.ne.jp]]
|-
| Pocket Fighter
|
|-
| Rainbow Islands - Putty's Party
|
|-
| Star Hearts
|
|-
| Terrors 2
| [[WonderGate/terrors2.wgg.channel.or.jp|terrors2.wgg.channel.or.jp]]
|-
| Wizardry
|
|}
560a299a9e7c105b89960e231614a3dc17ec20c8
WonderBeat 9480
0
47
197
2023-08-27T07:44:01Z
Asie
351
stub
wikitext
text/x-wiki
The WonderBeat 9480 is the official WonderSwan headphone digital/analog converter.
== Links ==
* [http://perfectkiosk.net/stsws.html#sound_output_procedure STSWS - Sound - Output Procedure]
41fa99cceb6b7a1da508f77d384676ebae5f8fb6
WSdev Wiki
0
1
201
193
2023-08-27T10:52:54Z
Asie
351
wikitext
text/x-wiki
'''WonderSwan Development Wiki'''
== Reference ==
=== General ===
* [[Memory map]]
* [[I/O port map]]
* [[ROM header]]
* [[NEC V30MZ]] - the WonderSwan CPU (80186-compatible)
* [[Timing]]
=== Console components ===
* [[SoC]]
** [[Display]]
** [[Sound]]
*** [[Hyper Voice]]<sup>(color)</sup>
** [[Keypad]]
** [[Timers]]
** [[Interrupts]]
** [[UART]]
** [[DMA]]<sup>(color)</sup>
* [[Boot ROM]]
* [[EEPROM|Internal EEPROM]]
** [[Splash animation]]<sup>(color)</sup>
=== Cartridge components ===
* [[Cartridge]]
* [[Mapper]]
** [[Bandai 2001]]
** [[Bandai 2003]]
** [[KARNAK]]
* [[EEPROM]] (2001)
* [[Real-Time Clock]] (2003)
=== Pinouts ===
* [[Cartridge pinout]]
* [[Accessory port pinout]]
* [[2001 Mapper pinout]]
* [[2003 Mapper pinout]]
* [[KARNAK pinout]]
* [[GIZA pinout]]
* [[S-3511A pinout]]
=== Accessories ===
* [[WonderBeat 9480]] headphone adapter
* [[WonderBorg]] robot
* [[WonderGate]] mobile adapter
* [[WonderWave]] infrared adapter
=== WonderWitch ===
* [[WonderWitch]]
** [[WonderWitch/FreyaBIOS|FreyaBIOS]]
** [[WonderWitch/FreyaOS|FreyaOS]]
** [[WonderWitch .fx files|.fx file format]]
== Links ==
* [https://github.com/WonderfulToolchain/awesome-wsdev awesome-wsdev] - curated documentation/tools/source code link list
== MediaWiki ==
* [https://www.mediawiki.org/wiki/Special:MyLanguage/Help:Contents User's Guide]
* [https://www.mediawiki.org/wiki/Special:MyLanguage/Manual:FAQ MediaWiki FAQ]
* [[:Category:Deletion requests|Deletion requests]]
9d67876bf68dc4ff2486b2337155cdbfda28d8bb
250
201
2024-02-19T19:55:35Z
Asie
351
wikitext
text/x-wiki
'''WonderSwan Development Wiki'''
== Reference ==
=== General ===
* [[Memory map]]
* [[I/O port map]]
* [[ROM header]]
* [[NEC V30MZ]] - the WonderSwan CPU (80186-compatible)
* [[Timing]]
=== Console components ===
* [[SoC]]
** [[Display]]
** [[Sound]]
*** [[Hyper Voice]]<sup>(color)</sup>
** [[Keypad]]
** [[Timers]]
** [[Interrupts]]
** [[UART]]
** [[DMA]]<sup>(color)</sup>
* [[Boot ROM]]
* [[EEPROM|Internal EEPROM]]
** [[Splash animation]]<sup>(color)</sup>
=== Cartridge components ===
* [[Cartridge connector]]
* [[Mapper]]
** [[Bandai 2001]]
** [[Bandai 2003]]
** [[KARNAK]]
* [[EEPROM]] (2001)
* [[Real-Time Clock]] (2003)
=== Pinouts ===
* [[Cartridge connector#Pinout|Cartridge pinout]]
* [[Accessory port pinout]]
* [[2001 Mapper pinout]]
* [[2003 Mapper pinout]]
* [[KARNAK pinout]]
* [[GIZA pinout]]
* [[S-3511A pinout]]
=== Accessories ===
* [[WonderBeat 9480]] headphone adapter
* [[WonderBorg]] robot
* [[WonderGate]] mobile adapter
* [[WonderWave]] infrared adapter
=== WonderWitch ===
* [[WonderWitch]]
** [[WonderWitch/FreyaBIOS|FreyaBIOS]]
** [[WonderWitch/FreyaOS|FreyaOS]]
** [[WonderWitch .fx files|.fx file format]]
== Links ==
* [https://github.com/WonderfulToolchain/awesome-wsdev awesome-wsdev] - curated documentation/tools/source code link list
== MediaWiki ==
* [https://www.mediawiki.org/wiki/Special:MyLanguage/Help:Contents User's Guide]
* [https://www.mediawiki.org/wiki/Special:MyLanguage/Manual:FAQ MediaWiki FAQ]
* [[:Category:Deletion requests|Deletion requests]]
2348041c9592ef58865c9d69d5c918390e352085
EEPROM
0
35
202
199
2023-08-27T10:57:37Z
Asie
351
wikitext
text/x-wiki
The WonderSwan utilizes M93LCx6-compatible EEPROMs:
* in the SoC:
** 1 Kbit internal EEPROM (M93LC46-compatible) on the WonderSwan,
** 16 Kbit internal EEPROM (M93LC86-compatible) on the WonderSwan Color,
* on cartridges:
** 1 Kbit cartridge EEPROM (M93LC46-compatible)
** 8 Kbit cartridge EEPROM (M93LC76-compatible)
** 16 Kbit cartridge EEPROM (M93LC86-compatible)
Additional variants exists which were not seen on any production cartridge:
* 256 bit EEPROM (M93LC06-compatible)
* 2 Kbit EEPROM (M93LC56-compatible)
* 4 Kbit EEPROM (M93LC66-compatible)
== Commands ==
=== READ - Read Word ===
The READ command takes an address of a word (address 0 => bytes 0, 1; address 1 => bytes 2, 3; ...) and returns the word at that address.
=== WRITE - Write Word ===
The WRITE command takes an address of a word (address 0 => bytes 0, 1; address 1 => bytes 2, 3; ...) and the word to write to it, then writes the word.
=== ERASE - Erase Word ===
The ERASE command takes an address of a word (address 0 => bytes 0, 1; address 1 => bytes 2, 3; ...) and erases the word at that address, setting it to 0xFFFF.
=== WDS - Write Disable ===
TODO
=== WRAL - Write All ===
This command is not guaranteed to be present on all EEPROMs.
TODO
=== ERAL - Erase All ===
This command is not guaranteed to be present on all EEPROMs.
TODO
=== WEN - Write Enable ===
TODO
== I/O ports ==
The I/O ports listed refer to the internal EEPROM; for the cartridge EEPROM port numbers, refer to the [[Bandai 2001|mapper documentation]].
Note that on the original/"mono" WonderSwan, the data and command registers can ''only'' be accessed word-wide via even addresses: access to odd addresses whether byte or word-wide don't provide valid data. This has been fixed on the WonderSwan Color, even for "mono" compatibility mode.
{{Anchor|Internal EEPROM Data}}
=== Internal EEPROM Data ($BA, $BB) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
dddd dddd dddd dddd
|||| |||| |||| ||||
++++-++++--++++-++++- Data read from/written to the EEPROM.
</pre>
This port functions as a shared buffer for both "read" and "write" modes. (TODO: Verify)
{{Anchor|Internal EEPROM Command}}
=== Internal EEPROM Command ($BC, $BD) ===
<pre>
Command Pattern 1
15 bit 8 7 bit 0
---- ---- ---- ----
0000 0001 ooaa aaaa (¼, 1 Kbit - M93LC06/46)
0000 01oo aaaa aaaa (2, 4 Kbit - M93LC56/66)
0001 ooaa aaaa aaaa (8, 16 Kbit - M93LC76/86)
|||| |||| ||||
||++--++++-++++- Address (MSb .. LSb)
++-------------- Opcode:
01 - WRITE
10 - READ
11 - ERASE
</pre>
<pre>
Command Pattern 2
15 bit 8 7 bit 0
---- ---- ---- ----
0000 0001 00ss .... (1 Kbit - M93LC46)
0000 0100 ss.. .... (2, 4 Kbit - M93LC56/66)
0001 00ss .... .... (8, 16 Kbit - M93LC76/86)
||
++------------ Sub-Opcode:
00 - WDS
01 - WRAL
01 - ERAL
11 - WEN
</pre>
{{Anchor|Internal EEPROM Control}}
=== Internal EEPROM Control ($BE, $BF write) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
.... .... pswr ....
||||
|||+------ Read mode: 1 for READ command, 0 otherwise
||+------- Write mode: 1 for WRITE and WRAL command, 0 otherwise
|+-------- Short mode: 1 for ERASE, WDS, ERAL and WEN command, 0 otherwise
+--------- 1 to enable internal EEPROM write protection.
Cannot be cleared once set.
</pre>
The ''mode'' flags control the behaviour of the EEPROM interface:
* Read mode: Sends 16 bits from Command, then reads 16 bits to Data.
* Write mode: Sends 16 bits from Command, then 16 bits from Data. De-asserts Microwire chip select, then re-asserts it and waits for the EEPROM to confirm command completion.
* Short mode: Sends 16 bits from Command, de-asserts Microwire chip select.
Also note that nothing inside the SoC or 2001 checks that the contents of the command register matches the bit set in this register.
{{Anchor|Internal EEPROM Status}}
=== Internal EEPROM Status ($BE, $BF read) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
.... .... p... ..RD
| ||
| |+- 1 if a READ command has completed.
| +-- 0 if the EEPROM is busy,
| 1 if a command can be accepted (idle).
+--------- Internal EEPROM write protection:
0 = disabled, 1 = enabled
</pre>
== Internal EEPROM Layout ==
{| class="wikitable"
|-
! Offset !! Length !! Contents
|-
| $00 || 96 || Program data. Can be written by programs even if write protection has been enabled.
|-
| $60 || 16 || Owner name, custom character set.
|-
| $70 || 1 || Owner birthday year, BCD, first/higher two digits
|-
| $71 || 1 || Owner birthday year, BCD, last/lower two digits
|-
| $72 || 1 || Owner birthday month, BCD
|-
| $73 || 1 || Owner birthday day, BCD
|-
| $74 || 1 || Owner gender:<br/>
0 - ?<br/>
1 - Male<br/>
2 - Female
|-
| $75 || 1 || Owner blood type:<br/>
0 - ?<br/>
1 - A<br/>
2 - B<br/>
3 - AB<br/>
4 - 0
|-
| $76 || 1 | Last booted cartridge developer/publisher ID
|-
| $77 || 1 | Last booted cartridge game ID
|-
| $78 || 1 | Last booted cartridge game version
|-
| $7C || 1 | Stored cartridge ID/version change counter
|-
| $7D || 1 | Owner name change counter
|-
| $7E || 2 | System startup counter
|-
| $83 || 1 | Color console configuration
|-
| $84 || ? | [[Splash animation|Custom splash animation]], if present
|}
=== Owner name character set ===
{| class="wikitable"
|-
!
! <code>.0</code>
! <code>.1</code>
! <code>.2</code>
! <code>.3</code>
! <code>.4</code>
! <code>.5</code>
! <code>.6</code>
! <code>.7</code>
! <code>.8</code>
! <code>.9</code>
! <code>.A</code>
! <code>.B</code>
! <code>.C</code>
! <code>.D</code>
! <code>.E</code>
! <code>.F</code>
|-
! <code>0.</code>
| || 0 || 1 || 2 || 3 || 4 || 5 || 6 || 7 || 8 || 9 || A || B || C || D || E
|-
! <code>1.</code>
| F || G || H || I || J || K || L || M || N || O || P || Q || R || S || T || U
|-
! <code>2.</code>
| V || W || X || Y || Z || ♥ || ♪ || + || - || ? || .
!
!
!
!
!
|}
=== Color console configuration ===
<pre>
7 bit 0
---- ----
sc.. ..vv
|| ||
|| ++- Volume level
|+-------- Contrast (WSC): 0 = Low, 1 = High
+--------- Custom splash animation enabled
</pre>
== Hardware notes ==
EEPROM command bits are shifted out starting from the ''most'' significant bit of the port.
<pre>
+----> EEPROM Serial Data
|
[0] <= [0000 0001 ooaa aaaa]
EEPROM Command Port
</pre>
While the M93LCx6 family supports byte organization, the WonderSwan always uses word organization. As such, this implementation detail is omitted in this documentation.
== Errata ==
=== Non-word access on ASWAN ===
On the ASWAN SoC, accessing the internal EEPROM command ports as bytes only works correctly for even addresses. For odd addresses, these accesses return open bus; this means that unaligned word accesses also don't work, as they are converted to one odd and one even byte access internally.
It is recommended to only use aligned word port accesses to talk to the internal EEPROM.
This issue is not present on the SPHINX and newer SoCs, including in "mono" emulation mode, as well as the cartridge bus (which is always forced to be accessed per byte).
== Links ==
* [https://www.st.com/resource/en/datasheet/m93c46-w.pdf STMicroelectronics M93LCx6 datasheet]
b1b997dbd577c755b9dfda49f2965e22e306bfd2
203
202
2023-08-27T10:58:07Z
Asie
351
/* Internal EEPROM Layout */ fix table
wikitext
text/x-wiki
The WonderSwan utilizes M93LCx6-compatible EEPROMs:
* in the SoC:
** 1 Kbit internal EEPROM (M93LC46-compatible) on the WonderSwan,
** 16 Kbit internal EEPROM (M93LC86-compatible) on the WonderSwan Color,
* on cartridges:
** 1 Kbit cartridge EEPROM (M93LC46-compatible)
** 8 Kbit cartridge EEPROM (M93LC76-compatible)
** 16 Kbit cartridge EEPROM (M93LC86-compatible)
Additional variants exists which were not seen on any production cartridge:
* 256 bit EEPROM (M93LC06-compatible)
* 2 Kbit EEPROM (M93LC56-compatible)
* 4 Kbit EEPROM (M93LC66-compatible)
== Commands ==
=== READ - Read Word ===
The READ command takes an address of a word (address 0 => bytes 0, 1; address 1 => bytes 2, 3; ...) and returns the word at that address.
=== WRITE - Write Word ===
The WRITE command takes an address of a word (address 0 => bytes 0, 1; address 1 => bytes 2, 3; ...) and the word to write to it, then writes the word.
=== ERASE - Erase Word ===
The ERASE command takes an address of a word (address 0 => bytes 0, 1; address 1 => bytes 2, 3; ...) and erases the word at that address, setting it to 0xFFFF.
=== WDS - Write Disable ===
TODO
=== WRAL - Write All ===
This command is not guaranteed to be present on all EEPROMs.
TODO
=== ERAL - Erase All ===
This command is not guaranteed to be present on all EEPROMs.
TODO
=== WEN - Write Enable ===
TODO
== I/O ports ==
The I/O ports listed refer to the internal EEPROM; for the cartridge EEPROM port numbers, refer to the [[Bandai 2001|mapper documentation]].
Note that on the original/"mono" WonderSwan, the data and command registers can ''only'' be accessed word-wide via even addresses: access to odd addresses whether byte or word-wide don't provide valid data. This has been fixed on the WonderSwan Color, even for "mono" compatibility mode.
{{Anchor|Internal EEPROM Data}}
=== Internal EEPROM Data ($BA, $BB) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
dddd dddd dddd dddd
|||| |||| |||| ||||
++++-++++--++++-++++- Data read from/written to the EEPROM.
</pre>
This port functions as a shared buffer for both "read" and "write" modes. (TODO: Verify)
{{Anchor|Internal EEPROM Command}}
=== Internal EEPROM Command ($BC, $BD) ===
<pre>
Command Pattern 1
15 bit 8 7 bit 0
---- ---- ---- ----
0000 0001 ooaa aaaa (¼, 1 Kbit - M93LC06/46)
0000 01oo aaaa aaaa (2, 4 Kbit - M93LC56/66)
0001 ooaa aaaa aaaa (8, 16 Kbit - M93LC76/86)
|||| |||| ||||
||++--++++-++++- Address (MSb .. LSb)
++-------------- Opcode:
01 - WRITE
10 - READ
11 - ERASE
</pre>
<pre>
Command Pattern 2
15 bit 8 7 bit 0
---- ---- ---- ----
0000 0001 00ss .... (1 Kbit - M93LC46)
0000 0100 ss.. .... (2, 4 Kbit - M93LC56/66)
0001 00ss .... .... (8, 16 Kbit - M93LC76/86)
||
++------------ Sub-Opcode:
00 - WDS
01 - WRAL
01 - ERAL
11 - WEN
</pre>
{{Anchor|Internal EEPROM Control}}
=== Internal EEPROM Control ($BE, $BF write) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
.... .... pswr ....
||||
|||+------ Read mode: 1 for READ command, 0 otherwise
||+------- Write mode: 1 for WRITE and WRAL command, 0 otherwise
|+-------- Short mode: 1 for ERASE, WDS, ERAL and WEN command, 0 otherwise
+--------- 1 to enable internal EEPROM write protection.
Cannot be cleared once set.
</pre>
The ''mode'' flags control the behaviour of the EEPROM interface:
* Read mode: Sends 16 bits from Command, then reads 16 bits to Data.
* Write mode: Sends 16 bits from Command, then 16 bits from Data. De-asserts Microwire chip select, then re-asserts it and waits for the EEPROM to confirm command completion.
* Short mode: Sends 16 bits from Command, de-asserts Microwire chip select.
Also note that nothing inside the SoC or 2001 checks that the contents of the command register matches the bit set in this register.
{{Anchor|Internal EEPROM Status}}
=== Internal EEPROM Status ($BE, $BF read) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
.... .... p... ..RD
| ||
| |+- 1 if a READ command has completed.
| +-- 0 if the EEPROM is busy,
| 1 if a command can be accepted (idle).
+--------- Internal EEPROM write protection:
0 = disabled, 1 = enabled
</pre>
== Internal EEPROM Layout ==
{| class="wikitable"
|-
! Offset !! Length !! Contents
|-
| $00 || 96 || Program data. Can be written by programs even if write protection has been enabled.
|-
| $60 || 16 || Owner name, custom character set.
|-
| $70 || 1 || Owner birthday year, BCD, first/higher two digits
|-
| $71 || 1 || Owner birthday year, BCD, last/lower two digits
|-
| $72 || 1 || Owner birthday month, BCD
|-
| $73 || 1 || Owner birthday day, BCD
|-
| $74 || 1 || Owner gender:<br/>
0 - ?<br/>
1 - Male<br/>
2 - Female
|-
| $75 || 1 || Owner blood type:<br/>
0 - ?<br/>
1 - A<br/>
2 - B<br/>
3 - AB<br/>
4 - 0
|-
| $76 || 1 || Last booted cartridge developer/publisher ID
|-
| $77 || 1 || Last booted cartridge game ID
|-
| $78 || 1 || Last booted cartridge game version
|-
| $7C || 1 || Stored cartridge ID/version change counter
|-
| $7D || 1 || Owner name change counter
|-
| $7E || 2 || System startup counter
|-
| $83 || 1 || Color console configuration
|-
| $84 || ? || [[Splash animation|Custom splash animation]], if present
|}
=== Owner name character set ===
{| class="wikitable"
|-
!
! <code>.0</code>
! <code>.1</code>
! <code>.2</code>
! <code>.3</code>
! <code>.4</code>
! <code>.5</code>
! <code>.6</code>
! <code>.7</code>
! <code>.8</code>
! <code>.9</code>
! <code>.A</code>
! <code>.B</code>
! <code>.C</code>
! <code>.D</code>
! <code>.E</code>
! <code>.F</code>
|-
! <code>0.</code>
| || 0 || 1 || 2 || 3 || 4 || 5 || 6 || 7 || 8 || 9 || A || B || C || D || E
|-
! <code>1.</code>
| F || G || H || I || J || K || L || M || N || O || P || Q || R || S || T || U
|-
! <code>2.</code>
| V || W || X || Y || Z || ♥ || ♪ || + || - || ? || .
!
!
!
!
!
|}
=== Color console configuration ===
<pre>
7 bit 0
---- ----
sc.. ..vv
|| ||
|| ++- Volume level
|+-------- Contrast (WSC): 0 = Low, 1 = High
+--------- Custom splash animation enabled
</pre>
== Hardware notes ==
EEPROM command bits are shifted out starting from the ''most'' significant bit of the port.
<pre>
+----> EEPROM Serial Data
|
[0] <= [0000 0001 ooaa aaaa]
EEPROM Command Port
</pre>
While the M93LCx6 family supports byte organization, the WonderSwan always uses word organization. As such, this implementation detail is omitted in this documentation.
== Errata ==
=== Non-word access on ASWAN ===
On the ASWAN SoC, accessing the internal EEPROM command ports as bytes only works correctly for even addresses. For odd addresses, these accesses return open bus; this means that unaligned word accesses also don't work, as they are converted to one odd and one even byte access internally.
It is recommended to only use aligned word port accesses to talk to the internal EEPROM.
This issue is not present on the SPHINX and newer SoCs, including in "mono" emulation mode, as well as the cartridge bus (which is always forced to be accessed per byte).
== Links ==
* [https://www.st.com/resource/en/datasheet/m93c46-w.pdf STMicroelectronics M93LCx6 datasheet]
c8355281f5dbc89e876cf65bb7f8024b34062cb0
210
203
2023-08-27T19:24:55Z
Asie
351
wikitext
text/x-wiki
The WonderSwan utilizes M93LCx6-compatible EEPROMs:
* in the SoC:
** 1 Kbit internal EEPROM (M93LC46-compatible) on the WonderSwan,
** 16 Kbit internal EEPROM (M93LC86-compatible) on the WonderSwan Color,
* on cartridges:
** 1 Kbit cartridge EEPROM (M93LC46-compatible)
** 8 Kbit cartridge EEPROM (M93LC76-compatible)
** 16 Kbit cartridge EEPROM (M93LC86-compatible)
Additional variants exists which were not seen on any production cartridge:
* 256 bit EEPROM (M93LC06-compatible)
* 2 Kbit EEPROM (M93LC56-compatible)
* 4 Kbit EEPROM (M93LC66-compatible)
== Commands ==
=== READ - Read Word ===
The READ command takes an address of a word (address 0 => bytes 0, 1; address 1 => bytes 2, 3; ...) and returns the word at that address.
=== WRITE - Write Word ===
The WRITE command takes an address of a word (address 0 => bytes 0, 1; address 1 => bytes 2, 3; ...) and the word to write to it, then writes the word.
=== ERASE - Erase Word ===
The ERASE command takes an address of a word (address 0 => bytes 0, 1; address 1 => bytes 2, 3; ...) and erases the word at that address, setting it to 0xFFFF.
=== WDS - Write Disable ===
TODO
=== WRAL - Write All ===
This command is not guaranteed to be present on all EEPROMs.
TODO
=== ERAL - Erase All ===
This command is not guaranteed to be present on all EEPROMs.
TODO
=== WEN - Write Enable ===
TODO
== I/O ports ==
The I/O ports listed refer to the internal EEPROM; for the cartridge EEPROM port numbers, refer to the [[Bandai 2001|mapper documentation]].
It is recommended to only access the data and command ports with aligned word reads/writes; see the ''Errata'' section for more information.
{{Anchor|Internal EEPROM Data}}
=== Internal EEPROM Data ($BA, $BB) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
dddd dddd dddd dddd
|||| |||| |||| ||||
++++-++++--++++-++++- Data read from/written to the EEPROM.
</pre>
This port functions as a shared buffer for both "read" and "write" modes. (TODO: Verify)
{{Anchor|Internal EEPROM Command}}
=== Internal EEPROM Command ($BC, $BD) ===
<pre>
Command Pattern 1
15 bit 8 7 bit 0
---- ---- ---- ----
0000 0001 ooaa aaaa (¼, 1 Kbit - M93LC06/46)
0000 01oo aaaa aaaa (2, 4 Kbit - M93LC56/66)
0001 ooaa aaaa aaaa (8, 16 Kbit - M93LC76/86)
|||| |||| ||||
||++--++++-++++- Address (MSb .. LSb)
++-------------- Opcode:
01 - WRITE
10 - READ
11 - ERASE
</pre>
<pre>
Command Pattern 2
15 bit 8 7 bit 0
---- ---- ---- ----
0000 0001 00ss .... (1 Kbit - M93LC46)
0000 0100 ss.. .... (2, 4 Kbit - M93LC56/66)
0001 00ss .... .... (8, 16 Kbit - M93LC76/86)
||
++------------ Sub-Opcode:
00 - WDS
01 - WRAL
01 - ERAL
11 - WEN
</pre>
{{Anchor|Internal EEPROM Control}}
=== Internal EEPROM Control ($BE, $BF write) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
.... .... pswr ....
||||
|||+------ Read mode: 1 for READ command, 0 otherwise
||+------- Write mode: 1 for WRITE and WRAL command, 0 otherwise
|+-------- Short mode: 1 for ERASE, WDS, ERAL and WEN command, 0 otherwise
+--------- 1 to enable internal EEPROM write protection.
Cannot be cleared once set.
</pre>
The ''mode'' flags control the behaviour of the EEPROM interface:
* Read mode: Sends 16 bits from Command, then reads 16 bits to Data.
* Write mode: Sends 16 bits from Command, then 16 bits from Data. De-asserts Microwire chip select, then re-asserts it and waits for the EEPROM to confirm command completion.
* Short mode: Sends 16 bits from Command, de-asserts Microwire chip select.
Also note that nothing inside the SoC or 2001 checks that the contents of the command register matches the bit set in this register.
{{Anchor|Internal EEPROM Status}}
=== Internal EEPROM Status ($BE, $BF read) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
.... .... p... ..RD
| ||
| |+- 1 if a READ command has completed.
| +-- 0 if the EEPROM is busy,
| 1 if a command can be accepted (idle).
+--------- Internal EEPROM write protection:
0 = disabled, 1 = enabled
</pre>
== Internal EEPROM Layout ==
{| class="wikitable"
|-
! Offset !! Length !! Contents
|-
| $00 || 96 || Program data. Can be written by programs even if write protection has been enabled.
|-
| $60 || 16 || Owner name, custom character set.
|-
| $70 || 1 || Owner birthday year, BCD, first/higher two digits
|-
| $71 || 1 || Owner birthday year, BCD, last/lower two digits
|-
| $72 || 1 || Owner birthday month, BCD
|-
| $73 || 1 || Owner birthday day, BCD
|-
| $74 || 1 || Owner gender:<br/>
0 - ?<br/>
1 - Male<br/>
2 - Female
|-
| $75 || 1 || Owner blood type:<br/>
0 - ?<br/>
1 - A<br/>
2 - B<br/>
3 - AB<br/>
4 - 0
|-
| $76 || 1 || Last booted cartridge developer/publisher ID
|-
| $77 || 1 || Last booted cartridge game ID
|-
| $78 || 1 || Last booted cartridge game version
|-
| $7C || 1 || Stored cartridge ID/version change counter
|-
| $7D || 1 || Owner name change counter
|-
| $7E || 2 || System startup counter
|-
| $83 || 1 || Color console configuration
|-
| $84 || ? || [[Splash animation|Custom splash animation]], if present
|}
=== Owner name character set ===
{| class="wikitable"
|-
!
! <code>.0</code>
! <code>.1</code>
! <code>.2</code>
! <code>.3</code>
! <code>.4</code>
! <code>.5</code>
! <code>.6</code>
! <code>.7</code>
! <code>.8</code>
! <code>.9</code>
! <code>.A</code>
! <code>.B</code>
! <code>.C</code>
! <code>.D</code>
! <code>.E</code>
! <code>.F</code>
|-
! <code>0.</code>
| || 0 || 1 || 2 || 3 || 4 || 5 || 6 || 7 || 8 || 9 || A || B || C || D || E
|-
! <code>1.</code>
| F || G || H || I || J || K || L || M || N || O || P || Q || R || S || T || U
|-
! <code>2.</code>
| V || W || X || Y || Z || ♥ || ♪ || + || - || ? || .
!
!
!
!
!
|}
=== Color console configuration ===
<pre>
7 bit 0
---- ----
sc.. ..vv
|| ||
|| ++- Volume level
|+-------- Contrast (WSC): 0 = Low, 1 = High
+--------- Custom splash animation enabled
</pre>
== Hardware notes ==
EEPROM command bits are shifted out starting from the ''most'' significant bit of the port.
<pre>
+----> EEPROM Serial Data
|
[0] <= [0000 0001 ooaa aaaa]
EEPROM Command Port
</pre>
While the M93LCx6 family supports byte organization, the WonderSwan always uses word organization. As such, this implementation detail is omitted in this documentation.
== Errata ==
=== Non-word access on ASWAN ===
On the ASWAN SoC, accessing the internal EEPROM command ports as bytes only works correctly for even addresses. For odd addresses, these accesses return open bus; this means that unaligned word accesses also don't work, as they are converted to one odd and one even byte access internally.
It is recommended to only use aligned word port accesses to talk to the internal EEPROM.
This issue is not present on the SPHINX and newer SoCs, including in "mono" emulation mode, as well as the cartridge bus (which is always forced to be accessed per byte).
== Links ==
* [https://www.st.com/resource/en/datasheet/m93c46-w.pdf STMicroelectronics M93LCx6 datasheet]
3cb6f0ac40ab2536f4dde79286c964fc9606b757
211
210
2023-08-28T18:23:22Z
Lidnariq
7
/* Internal EEPROM Command ($BC, $BD) */ if i mention 93'06 once I should be consistent
wikitext
text/x-wiki
The WonderSwan utilizes M93LCx6-compatible EEPROMs:
* in the SoC:
** 1 Kbit internal EEPROM (M93LC46-compatible) on the WonderSwan,
** 16 Kbit internal EEPROM (M93LC86-compatible) on the WonderSwan Color,
* on cartridges:
** 1 Kbit cartridge EEPROM (M93LC46-compatible)
** 8 Kbit cartridge EEPROM (M93LC76-compatible)
** 16 Kbit cartridge EEPROM (M93LC86-compatible)
Additional variants exists which were not seen on any production cartridge:
* 256 bit EEPROM (M93LC06-compatible)
* 2 Kbit EEPROM (M93LC56-compatible)
* 4 Kbit EEPROM (M93LC66-compatible)
== Commands ==
=== READ - Read Word ===
The READ command takes an address of a word (address 0 => bytes 0, 1; address 1 => bytes 2, 3; ...) and returns the word at that address.
=== WRITE - Write Word ===
The WRITE command takes an address of a word (address 0 => bytes 0, 1; address 1 => bytes 2, 3; ...) and the word to write to it, then writes the word.
=== ERASE - Erase Word ===
The ERASE command takes an address of a word (address 0 => bytes 0, 1; address 1 => bytes 2, 3; ...) and erases the word at that address, setting it to 0xFFFF.
=== WDS - Write Disable ===
TODO
=== WRAL - Write All ===
This command is not guaranteed to be present on all EEPROMs.
TODO
=== ERAL - Erase All ===
This command is not guaranteed to be present on all EEPROMs.
TODO
=== WEN - Write Enable ===
TODO
== I/O ports ==
The I/O ports listed refer to the internal EEPROM; for the cartridge EEPROM port numbers, refer to the [[Bandai 2001|mapper documentation]].
It is recommended to only access the data and command ports with aligned word reads/writes; see the ''Errata'' section for more information.
{{Anchor|Internal EEPROM Data}}
=== Internal EEPROM Data ($BA, $BB) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
dddd dddd dddd dddd
|||| |||| |||| ||||
++++-++++--++++-++++- Data read from/written to the EEPROM.
</pre>
This port functions as a shared buffer for both "read" and "write" modes. (TODO: Verify)
{{Anchor|Internal EEPROM Command}}
=== Internal EEPROM Command ($BC, $BD) ===
<pre>
Command Pattern 1
15 bit 8 7 bit 0
---- ---- ---- ----
0000 0001 ooaa aaaa (¼, 1 Kbit - M93LC06/46)
0000 01oo aaaa aaaa (2, 4 Kbit - M93LC56/66)
0001 ooaa aaaa aaaa (8, 16 Kbit - M93LC76/86)
|||| |||| ||||
||++--++++-++++- Address (MSb .. LSb)
++-------------- Opcode:
01 - WRITE
10 - READ
11 - ERASE
</pre>
<pre>
Command Pattern 2
15 bit 8 7 bit 0
---- ---- ---- ----
0000 0001 00ss .... (¼, 1 Kbit - M93LC06/46)
0000 0100 ss.. .... (2, 4 Kbit - M93LC56/66)
0001 00ss .... .... (8, 16 Kbit - M93LC76/86)
||
++------------ Sub-Opcode:
00 - WDS
01 - WRAL
01 - ERAL
11 - WEN
</pre>
{{Anchor|Internal EEPROM Control}}
=== Internal EEPROM Control ($BE, $BF write) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
.... .... pswr ....
||||
|||+------ Read mode: 1 for READ command, 0 otherwise
||+------- Write mode: 1 for WRITE and WRAL command, 0 otherwise
|+-------- Short mode: 1 for ERASE, WDS, ERAL and WEN command, 0 otherwise
+--------- 1 to enable internal EEPROM write protection.
Cannot be cleared once set.
</pre>
The ''mode'' flags control the behaviour of the EEPROM interface:
* Read mode: Sends 16 bits from Command, then reads 16 bits to Data.
* Write mode: Sends 16 bits from Command, then 16 bits from Data. De-asserts Microwire chip select, then re-asserts it and waits for the EEPROM to confirm command completion.
* Short mode: Sends 16 bits from Command, de-asserts Microwire chip select.
Also note that nothing inside the SoC or 2001 checks that the contents of the command register matches the bit set in this register.
{{Anchor|Internal EEPROM Status}}
=== Internal EEPROM Status ($BE, $BF read) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
.... .... p... ..RD
| ||
| |+- 1 if a READ command has completed.
| +-- 0 if the EEPROM is busy,
| 1 if a command can be accepted (idle).
+--------- Internal EEPROM write protection:
0 = disabled, 1 = enabled
</pre>
== Internal EEPROM Layout ==
{| class="wikitable"
|-
! Offset !! Length !! Contents
|-
| $00 || 96 || Program data. Can be written by programs even if write protection has been enabled.
|-
| $60 || 16 || Owner name, custom character set.
|-
| $70 || 1 || Owner birthday year, BCD, first/higher two digits
|-
| $71 || 1 || Owner birthday year, BCD, last/lower two digits
|-
| $72 || 1 || Owner birthday month, BCD
|-
| $73 || 1 || Owner birthday day, BCD
|-
| $74 || 1 || Owner gender:<br/>
0 - ?<br/>
1 - Male<br/>
2 - Female
|-
| $75 || 1 || Owner blood type:<br/>
0 - ?<br/>
1 - A<br/>
2 - B<br/>
3 - AB<br/>
4 - 0
|-
| $76 || 1 || Last booted cartridge developer/publisher ID
|-
| $77 || 1 || Last booted cartridge game ID
|-
| $78 || 1 || Last booted cartridge game version
|-
| $7C || 1 || Stored cartridge ID/version change counter
|-
| $7D || 1 || Owner name change counter
|-
| $7E || 2 || System startup counter
|-
| $83 || 1 || Color console configuration
|-
| $84 || ? || [[Splash animation|Custom splash animation]], if present
|}
=== Owner name character set ===
{| class="wikitable"
|-
!
! <code>.0</code>
! <code>.1</code>
! <code>.2</code>
! <code>.3</code>
! <code>.4</code>
! <code>.5</code>
! <code>.6</code>
! <code>.7</code>
! <code>.8</code>
! <code>.9</code>
! <code>.A</code>
! <code>.B</code>
! <code>.C</code>
! <code>.D</code>
! <code>.E</code>
! <code>.F</code>
|-
! <code>0.</code>
| || 0 || 1 || 2 || 3 || 4 || 5 || 6 || 7 || 8 || 9 || A || B || C || D || E
|-
! <code>1.</code>
| F || G || H || I || J || K || L || M || N || O || P || Q || R || S || T || U
|-
! <code>2.</code>
| V || W || X || Y || Z || ♥ || ♪ || + || - || ? || .
!
!
!
!
!
|}
=== Color console configuration ===
<pre>
7 bit 0
---- ----
sc.. ..vv
|| ||
|| ++- Volume level
|+-------- Contrast (WSC): 0 = Low, 1 = High
+--------- Custom splash animation enabled
</pre>
== Hardware notes ==
EEPROM command bits are shifted out starting from the ''most'' significant bit of the port.
<pre>
+----> EEPROM Serial Data
|
[0] <= [0000 0001 ooaa aaaa]
EEPROM Command Port
</pre>
While the M93LCx6 family supports byte organization, the WonderSwan always uses word organization. As such, this implementation detail is omitted in this documentation.
== Errata ==
=== Non-word access on ASWAN ===
On the ASWAN SoC, accessing the internal EEPROM command ports as bytes only works correctly for even addresses. For odd addresses, these accesses return open bus; this means that unaligned word accesses also don't work, as they are converted to one odd and one even byte access internally.
It is recommended to only use aligned word port accesses to talk to the internal EEPROM.
This issue is not present on the SPHINX and newer SoCs, including in "mono" emulation mode, as well as the cartridge bus (which is always forced to be accessed per byte).
== Links ==
* [https://www.st.com/resource/en/datasheet/m93c46-w.pdf STMicroelectronics M93LCx6 datasheet]
4af9c8ee1901b872f2c4da118fb036cb0da42c2d
SoC
0
46
204
195
2023-08-27T11:04:10Z
Asie
351
add CAIRO reference
wikitext
text/x-wiki
The WonderSwan SoC is a single-chip solution powering the entirety of the system's hardware - containing the CPU, most peripheral logic, as well as the internal RAM.
There exist three variants of the SoC:
* ASWAN, used in the WonderSwan,
* SPHINX, used in the WonderSwan Color,
* SPHINX2, used in the SwanCrystal.
A fourth variant, CAIRO, was planned<ref>[https://web.archive.org/web/20071023111112/http://www.koto.co.jp/products/mono_sp.html CAIRO グラフィックス機能内蔵ローコストSoC - Wayback Machine]</ref>. It was designed as an ASWAN with a doubled clock speed and a built-in ADPCM decoder, but was never licensed for a commercial product.
== I/O ports ==
{{Anchor|System Control}}
=== System Control ($A0) ===
<pre>
7 bit 0
---- ----
t??? swcl
| ||||
| |||+- Boot ROM lockout: 0 = off, 1 = on
| ||+-- Color model: 0 = no, 1 = yes
| |+--- Cartridge bus width: 0 = 8-bit, 1 = 16-bit
| +---- Cartridge bus speed; 0 = 3 cycles, 1 = 1 cycle
+--------- MBC authentication successful?
</pre>
{{Anchor|System Control 2}}
=== System Control 2 ($60, color) ===
<pre>
7 bit 0
---- ----
c4C. ?.??
|||
||+------- 1 = 4bpp "chunky"; requires all previous
|+-------- 1 = 4bpp; requires all previous
+--------- 0 = mono, 1 = color; also controls access
to WSC-specific features (extra RAM, DMA, etc.)
</pre>
{{Anchor|System Control 3}}
=== System Control 3 ($62, color) ===
<pre>
7 bit 0
---- ----
S... ...p
| |
| +- 1 = Power off system
+--------- 0 = WonderSwan Color (SPHINX)
1 = SwanCrystal (SPHINX2)
</pre>
== Notes ==
<references />
8586f9f9316ce59d5a0c9d0c9f3033a4b39ca8ec
221
204
2023-08-29T21:42:13Z
Asie
351
un-swap cartridge bus speed
wikitext
text/x-wiki
The WonderSwan SoC is a single-chip solution powering the entirety of the system's hardware - containing the CPU, most peripheral logic, as well as the internal RAM.
There exist three variants of the SoC:
* ASWAN, used in the WonderSwan,
* SPHINX, used in the WonderSwan Color,
* SPHINX2, used in the SwanCrystal.
A fourth variant, CAIRO, was planned<ref>[https://web.archive.org/web/20071023111112/http://www.koto.co.jp/products/mono_sp.html CAIRO グラフィックス機能内蔵ローコストSoC - Wayback Machine]</ref>. It was designed as an ASWAN with a doubled clock speed and a built-in ADPCM decoder, but was never licensed for a commercial product.
== I/O ports ==
{{Anchor|System Control}}
=== System Control ($A0) ===
<pre>
7 bit 0
---- ----
t??? swcl
| ||||
| |||+- Boot ROM lockout: 0 = off, 1 = on
| ||+-- Color model: 0 = no, 1 = yes
| |+--- Cartridge bus width: 0 = 8-bit, 1 = 16-bit
| +---- Cartridge bus speed: 0 = 1 cycle, 1 = 3 cycles
+--------- MBC authentication successful?
</pre>
{{Anchor|System Control 2}}
=== System Control 2 ($60, color) ===
<pre>
7 bit 0
---- ----
c4C. ?.??
|||
||+------- 1 = 4bpp "chunky"; requires all previous
|+-------- 1 = 4bpp; requires all previous
+--------- 0 = mono, 1 = color; also controls access
to WSC-specific features (extra RAM, DMA, etc.)
</pre>
{{Anchor|System Control 3}}
=== System Control 3 ($62, color) ===
<pre>
7 bit 0
---- ----
S... ...p
| |
| +- 1 = Power off system
+--------- 0 = WonderSwan Color (SPHINX)
1 = SwanCrystal (SPHINX2)
</pre>
== Notes ==
<references />
be4eab6a52548138e3c92b2d8c694e872f9f4578
222
221
2023-08-29T21:52:10Z
Asie
351
document port $60 bit 1
wikitext
text/x-wiki
The WonderSwan SoC is a single-chip solution powering the entirety of the system's hardware - containing the CPU, most peripheral logic, as well as the internal RAM.
There exist three variants of the SoC:
* ASWAN, used in the WonderSwan,
* SPHINX, used in the WonderSwan Color,
* SPHINX2, used in the SwanCrystal.
A fourth variant, CAIRO, was planned<ref>[https://web.archive.org/web/20071023111112/http://www.koto.co.jp/products/mono_sp.html CAIRO グラフィックス機能内蔵ローコストSoC - Wayback Machine]</ref>. It was designed as an ASWAN with a doubled clock speed and a built-in ADPCM decoder, but was never licensed for a commercial product.
== I/O ports ==
{{Anchor|System Control}}
=== System Control ($A0) ===
<pre>
7 bit 0
---- ----
t??? swcl
| ||||
| |||+- Boot ROM lockout: 0 = off, 1 = on
| ||+-- Color model: 0 = no, 1 = yes
| |+--- Cartridge ROM width: 0 = 8-bit, 1 = 16-bit
| +---- Cartridge ROM wait state: 0 = +0 cycles, 1 = +2
+--------- MBC authentication successful?
</pre>
{{Anchor|System Control 2}}
=== System Control 2 ($60, color) ===
<pre>
7 bit 0
---- ----
c4C. ?.s?
||| |
||| +-- Cartridge SRAM wait state: 0 = +0 cycles, 1 = +1
||+------- 1 = 4bpp "chunky"; requires all previous
|+-------- 1 = 4bpp; requires all previous
+--------- 0 = mono, 1 = color; also controls access
to WSC-specific features (extra RAM, DMA, etc.)
</pre>
{{Anchor|System Control 3}}
=== System Control 3 ($62, color) ===
<pre>
7 bit 0
---- ----
S... ...p
| |
| +- 1 = Power off system
+--------- 0 = WonderSwan Color (SPHINX)
1 = SwanCrystal (SPHINX2)
</pre>
== Notes ==
<references />
170a8a82cf8d2101d8197568923e5207f538ca01
226
222
2023-08-30T18:42:38Z
Asie
351
/* System Control 2 ($60, color) */ document bit 3
wikitext
text/x-wiki
The WonderSwan SoC is a single-chip solution powering the entirety of the system's hardware - containing the CPU, most peripheral logic, as well as the internal RAM.
There exist three variants of the SoC:
* ASWAN, used in the WonderSwan,
* SPHINX, used in the WonderSwan Color,
* SPHINX2, used in the SwanCrystal.
A fourth variant, CAIRO, was planned<ref>[https://web.archive.org/web/20071023111112/http://www.koto.co.jp/products/mono_sp.html CAIRO グラフィックス機能内蔵ローコストSoC - Wayback Machine]</ref>. It was designed as an ASWAN with a doubled clock speed and a built-in ADPCM decoder, but was never licensed for a commercial product.
== I/O ports ==
{{Anchor|System Control}}
=== System Control ($A0) ===
<pre>
7 bit 0
---- ----
t??? swcl
| ||||
| |||+- Boot ROM lockout: 0 = off, 1 = on
| ||+-- Color model: 0 = no, 1 = yes
| |+--- Cartridge ROM width: 0 = 8-bit, 1 = 16-bit
| +---- Cartridge ROM wait state: 0 = +0 cycles, 1 = +2
+--------- MBC authentication successful?
</pre>
{{Anchor|System Control 2}}
=== System Control 2 ($60, color) ===
<pre>
7 bit 0
---- ----
c4C. i?s?
||| | |
||| | +-- Cartridge SRAM wait state: 0 = +0 cycles, 1 = +1
||| +---- Cartridge I/O wait state: 0 = +0 cycles, 1 = +1
||+------- 1 = 4bpp "chunky"; requires all previous
|+-------- 1 = 4bpp; requires all previous
+--------- 0 = mono, 1 = color; also controls access
to WSC-specific features (extra RAM, DMA, etc.)
</pre>
{{Anchor|System Control 3}}
=== System Control 3 ($62, color) ===
<pre>
7 bit 0
---- ----
S... ...p
| |
| +- 1 = Power off system
+--------- 0 = WonderSwan Color (SPHINX)
1 = SwanCrystal (SPHINX2)
</pre>
== Notes ==
<references />
ec56fa08192da5f9612392e358a8d0371bd13541
233
226
2023-09-01T14:16:49Z
Asie
351
hint at $60 bit 0
wikitext
text/x-wiki
The WonderSwan SoC is a single-chip solution powering the entirety of the system's hardware - containing the CPU, most peripheral logic, as well as the internal RAM.
There exist three variants of the SoC:
* ASWAN, used in the WonderSwan,
* SPHINX, used in the WonderSwan Color,
* SPHINX2, used in the SwanCrystal.
A fourth variant, CAIRO, was planned<ref>[https://web.archive.org/web/20071023111112/http://www.koto.co.jp/products/mono_sp.html CAIRO グラフィックス機能内蔵ローコストSoC - Wayback Machine]</ref>. It was designed as an ASWAN with a doubled clock speed and a built-in ADPCM decoder, but was never licensed for a commercial product.
== I/O ports ==
{{Anchor|System Control}}
=== System Control ($A0) ===
<pre>
7 bit 0
---- ----
t??? swcl
| ||||
| |||+- Boot ROM lockout: 0 = off, 1 = on
| ||+-- Color model: 0 = no, 1 = yes
| |+--- Cartridge ROM width: 0 = 8-bit, 1 = 16-bit
| +---- Cartridge ROM wait state: 0 = +0 cycles, 1 = +2
+--------- MBC authentication successful?
</pre>
{{Anchor|System Control 2}}
=== System Control 2 ($60, color) ===
<pre>
7 bit 0
---- ----
c4C. i?sl
||| | ||
||| | |+- Cartridge clock speed?
||| | +-- Cartridge SRAM wait state: 0 = +0 cycles, 1 = +1
||| +---- Cartridge I/O wait state: 0 = +0 cycles, 1 = +1
||+------- 1 = 4bpp "chunky"; requires all previous
|+-------- 1 = 4bpp; requires all previous
+--------- 0 = mono, 1 = color; also controls access
to WSC-specific features (extra RAM, DMA, etc.)
</pre>
{{Anchor|System Control 3}}
=== System Control 3 ($62, color) ===
<pre>
7 bit 0
---- ----
S... ...p
| |
| +- 1 = Power off system
+--------- 0 = WonderSwan Color (SPHINX)
1 = SwanCrystal (SPHINX2)
</pre>
== Notes ==
<references />
3de6f6d1cfab0fc08ba09e39ae12a55f3e2e08ee
244
233
2023-12-22T12:03:49Z
Asie
351
wikitext
text/x-wiki
The WonderSwan SoC is a single-chip solution powering the entirety of the system's hardware - containing the CPU, most peripheral logic, as well as the internal RAM.
There exist three variants of the SoC:
* ASWAN, used in the WonderSwan,
* SPHINX, used in the WonderSwan Color,
* SPHINX2, used in the SwanCrystal.
A fourth variant, CAIRO, was planned<ref>[https://web.archive.org/web/20071023111112/http://www.koto.co.jp/products/mono_sp.html CAIRO グラフィックス機能内蔵ローコストSoC - Wayback Machine]</ref>. It was designed as an ASWAN with a doubled clock speed and a built-in ADPCM decoder, but was never licensed for a commercial product.
== I/O ports ==
{{Anchor|System Control}}
=== System Control ($A0) ===
<pre>
7 bit 0
---- ----
t??? swcl
| ||||
| |||+- Boot ROM lockout: 0 = off, 1 = on
| ||+-- Color model: 0 = no, 1 = yes
| |+--- Cartridge ROM width: 0 = 8-bit, 1 = 16-bit
| +---- Cartridge ROM wait state: 0 = +0 cycles, 1 = +1
+--------- MBC authentication successful?
</pre>
{{Anchor|System Control 2}}
=== System Control 2 ($60, color) ===
<pre>
7 bit 0
---- ----
c4C. i?sl
||| | ||
||| | |+- Cartridge clock speed?
||| | +-- Cartridge SRAM wait state: 0 = +0 cycles, 1 = +1
||| +---- Cartridge I/O wait state: 0 = +0 cycles, 1 = +1
||+------- 1 = 4bpp "chunky"; requires all previous
|+-------- 1 = 4bpp; requires all previous
+--------- 0 = mono, 1 = color; also controls access
to WSC-specific features (extra RAM, DMA, etc.)
</pre>
{{Anchor|System Control 3}}
=== System Control 3 ($62, color) ===
<pre>
7 bit 0
---- ----
S... ...p
| |
| +- 1 = Power off system
+--------- 0 = WonderSwan Color (SPHINX)
1 = SwanCrystal (SPHINX2)
</pre>
== Notes ==
<references />
742a10368ba5e0b93955a5fbee4185f942b0acbf
Display
0
26
205
121
2023-08-27T11:11:51Z
Asie
351
clarify sprites, priority
wikitext
text/x-wiki
The WonderSwan's display functionality generally consists of:
* a 224x144 display clocked at ~75.47 Hz by default, capable of displaying:
** up to sixteen distinct shades of gray
** 12-bit RGB444 color<sup>(color)</sup>
* two 32x32 background layers ("screens"), capable of displaying up to 512 (1024<sup>(color)</sup>) distinct tiles,
* a sprite layer, capable of displaying up to 128 8x8 sprites (up to 32 per line),
* six LCD icons to the bottom or right of the display, usable as additional indicators.
== Components ==
=== Tiles ===
The "mono" WonderSwan can display up to 512 tiles stored in a planar format, with two bits total per pixel.
The planes are interleaved with each other; that is, two consecutive bytes form a full 8x1 row of the tile:
<pre>
plane 0 plane 1
byte N byte N+1
7 bit 0 7 bit 0 full tile
---- ---- ---- ----
.... ...1 .222 22.. .22222.1
.... ...1 2222 22.. 222222.1
.... .... 22.. .... 22......
...1 1... 22.2 2... --\ 22.33...
...1 1... 22.2 2... --/ 22.33...
.... .... 22.. .... 22......
.... .... .... .... ........
11.. .... .... .... 11......
</pre>
The WonderSwan Color extends this with an additional 512 tiles (available for screens only, not sprites) and support for three new modes.
* The first new mode is another two bit per pixel mode, but using color palettes instead of monochrome shades.
The latter two modes extend tiles to four bits per pixel.
* The first among them is the planar mode, which works similarly to the two bit per pixel mode:
<pre>
plane 0 plane 1 plane 2 plane 3
byte N byte N+1 byte N+2 byte N+3
7 bit 0 7 bit 0 7 bit 0 7 bit 0 full rows
---- ---- ---- ---- ---- ---- ---- ----
1.1. 1.1. 22.. 22.. 4444 .... .... .... --\ 7654321.
.1.1 .1.1 ..22 ..22 .... 4444 8888 8888 --/ 89ABCDEF
</pre>
* The second is the chunky mode, which instead stores each plane as consecutive bits, with each byte responsible for two of the eight pixels:
<pre>
pxl 1,0 pxl 2,3 pxl 5,4 pxl 7,6
byte N byte N+1 byte N+2 byte N+3
7 bit 0 7 bit 0 7 bit 0 7 bit 0 full rows
---- ---- ---- ---- ---- ---- ---- ----
.42. .421 .4.. .4.1 ..2. ..21 .... ...1 --\ 7654321.
8..1 8... 8.21 8.2. 84.1 84.. 8421 842. --/ 89ABCDEF
</pre>
=== Colors, Shades ===
The "mono" WonderSwan uses eight value indices, which are converted by a global look-up table to eight of the sixteen shades the LCD can display:
<pre>
Palette Global shade LUT
1 ===========> 2 ==========================> 5
^ (0, 2, 4, 6) ^ (1, 3, 5, 7, 9, 11, 13, 15) ^
| | |
Tile pixel Value Displayed shade
</pre>
In "color" mode, the WonderSwan instead loads RGB444 color values from a table in the console's internal RAM:
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
.... rrrr gggg bbbb
|||| |||| ||||
|||| |||| ++++- Blue (0-15)
|||| ++++------ Green (0-15)
++++------------ Red (0-15)
</pre>
No further processing or look-up tables are applied.
=== Palettes ===
The WonderSwan provides sixteen different palettes. All sixteen can be used for screens only, while the latter eight can be used for screens and sprites. In addition, the background color (for areas where no opaque pixel is drawn) can be selected arbitrarily from the color palette or from the shade LUT.
In two bit per pixel modes, palettes 0 - 3 and 8 - 11 are ''opaque'' (color zero is opaque, four distinct colors are usable), while palettes 4 - 7 and 12 - 15 are ''translucent'' (color zero is transparent, three distinct colors are usable). This applies in both mono and color modes.
In four bit per pixel modes, every palette is ''translucent'' (color zero is transparent, fifteen distinct colors are usable). The first entry of each palette can be used only for the background color.
Palettes 8-15 are also referred to as sprite palettes 0-7.
=== Screens ===
The WonderSwan can display up to two distinct 32x32 screens. These consist of 1024 two-byte cells:
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
vhbp pppt tttt tttt
|||| |||| |||| ||||
|||| |||+--++++-++++- Tile index (0-511)
|||+-+++------------- Palette (0-15)
||+------------------ Tile bank (0-1) - color only
|+------------------- Horizontal flip
+-------------------- Vertical flip
</pre>
=== Sprites ===
The WonderSwan can display up to 128 sprites at once. These are stored in a sprite table in RAM, which consists of up to 128 four-byte entries:
<pre>
(Byte 1) (Byte 0)
15 bit 8 7 bit 0
---- ---- ---- ----
vhPi pppt tttt tttt
|||| |||| |||| ||||
|||| |||+--++++-++++- Tile index (0-511) - only bank 0
|||| +++------------- Palette (0-7) - mapped to screen palettes 8-15
|||+----------------- Window location - 0 = inside, 1 = outside
||+------------------ Priority - 0 = behind Screen 2, 1 = in front of Screen 2
|+------------------- Horizontal flip
+-------------------- Vertical flip
(Byte 2)
7 bit 0
---- ----
yyyy yyyy
|||| ||||
++++-++++- Y coordinate
(Byte 3)
7 bit 0
---- ----
xxxx xxxx
|||| ||||
++++-++++- X coordinate
</pre>
For each row, the first 32 sprites for that row will be drawn - including sprites obscured by windows or outside of the visible range; only the Y coordinate determines this. The earlier among those sprites will be on top of the later ones.
=== Visibility priority ===
For display components, the visibility priority is as follows:
* Sprite 0, high priority
* Sprite 127, high priority
* Screen 2
* Sprite 0, low priority
* Sprite 127, low priority
* Screen 1
* Background color
=== Windows ===
Screen 2 and the sprite layer can optionally be restricted to a specific window.
In addition, one can control if a given element is rendered inside or outside that window. For Screen 2, this is controlled globally; for sprites, this is controlled per-sprite.
=== Icons ===
Finally, the WonderSwan features six LCD segment icons which are displayed to the right<sup>(color)</sup> or below<sup>(mono)</sup> the main display. These are, as follows:
* Aux 3 - large circle,
* Aux 2 - medium circle,
* Aux 1 - small circle,
* Horizontal orientation,
* Vertical orientation,
* Sleep.
== Interrupts ==
The display circuit generates two interrupts of its own:
* Display Interrupt Line Match - when <code>Display Current Line</code> == <code>Display Interrupt Line</code>, at the beginning of said line.
* Display Vertical Blank - when <code>Display Current Line</code> == <code>144</code>, at the beginning of said line.
It also provides a timing source for the two Horizontal and Vertical Blank [[Timers]], which provide their own respective interrupts.
== I/O ports ==
{{Anchor|Display Control}}
=== Display Control ($00) ===
<pre>
7 bit 0
---- ----
..ow Ws21
|| ||||
|| |||+- Enable Screen 1 layer
|| ||+-- Enable Screen 2 layer
|| |+--- Enable Sprite layer
|| +---- Enable Sprite window
|+------ Enable Screen 2 window
+------- Screen 2 window location:
0 = inside, 1 = outside
</pre>
{{Anchor|Display Background}}
=== Display Background Color ($01) ===
<pre>
(mono) (color)
7 bit 0 7 bit 0
---- ---- ---- ----
.... .sss pppp iiii
||| |||| ||||
+++- Value |||| ++++- Index in palette (0-15)
(0-7) ++++------ Color palette (0-15)
</pre>
{{Anchor|Display Current Line}}
=== Display Current Line ($02 read) ===
The current line being drawn by the display.
Note that lines are sent to the display with a one-line delay. This matters for color palette or shade LUT manipulation; changing these values when <code>current line == 1</code> will actually affect line 0.
{{Anchor|Display Interrupt Line}}
=== Display Interrupt Line ($03) ===
The line to emit an interrupt on.
{{Anchor|Sprite Table Address}}
=== Sprite Table Address ($04) ===
<pre>
7 bit 0
---- ----
..Aa aaaa
|| ||||
|+-++++- Address (bits 9-13)
+------- Address (bit 14) - color only
</pre>
{{Anchor|Sprite Table First}}
=== Sprite Table First ($05) ===
<pre>
7 bit 0
---- ----
.iii iiii
||| ||||
+++-++++- Index of first sprite entry to draw (0-127)
</pre>
{{Anchor|Sprite Table Count}}
=== Sprite Table Count ($06) ===
<pre>
7 bit 0
---- ----
cccc cccc
|||| ||||
++++-++++- Count of sprite entries to draw (1-128)
</pre>
{{Anchor|Screen Address}}
=== Screen Address ($07) ===
<pre>
7 bit 0
---- ----
2222 1111
|||| ||||
|||| |+++- Screen 1 address (bits 11-13)
|||| +---- Screen 1 address (bit 14) - color only
|+++------ Screen 2 address (bits 11-13)
+--------- Screen 2 address (bit 14) - color only
</pre>
{{Anchor|LCD Control}}
=== LCD Control ($14) ===
<pre>
7 bit 0
---- ----
.... ..Ce
||
|+- LCD Enable: 0 = sleep, 1 = enabled
+-- Contrast (WSC): 0 = low, 1 = high
</pre>
{{Anchor|LCD Icon Control}}
=== LCD Icon Control ($15) ===
<pre>
7 bit 0
---- ----
..32 1hvs
|| ||||
|| |||+- Sleep
|| ||+-- Vertical orientation
|| |+--- Horizontal orientation
|| +---- Aux 1
|+------ Aux 2
+------- Aux 3
</pre>
== Internal I/O ports ==
These I/O ports are said to be internal and not intended for use by commercial games.
{{Anchor|LCD Final Line}}
=== LCD Final Line ($16) ===
The final line preceding line counter restart. By default, this should be set to 158.
It is said setting this register to an odd value on SwanCrystal has an adverse effect to the LCD panel<ref>[http://daifukkat.su/docs/wsman/#REG_LCD_VSYNC REG_LCD_VSYNC - WSMan]</ref>, but the exact mechanism is unknown.
{{Anchor|LCD Back Porch Line}}
=== LCD Back Porch Line ($17, WSC only) ===
This port is available on the WonderSwan Color only - not the SwanCrystal!
The final line preceding the vertical back porch; by default, this should be set to 155.
The vertical back porch of the LCD is assumed to be 4 lines by some hardware, including IPS mods, as well as the official "TV Swan" capture device. Given that the first visible line is sent to the LCD on the display's line 1, this should be generally set to <code>LCD Final Line - 3</code>.
Conversely, it is said moving this value closer to vertical blank improves LCD visibility<ref>[http://daifukkat.su/docs/wsman/#REG_LCD_VTOTAL REG_LCD_VTOTAL - WSMan]</ref>, but the exact mechanism is unknown.
{{Anchor|LCD Status}}
=== LCD Status ($1A) ===
<pre>
7 bit 0
---- ----
...v vv.s
| || |
| || +- LCD sleep: 0 = no, 1 = sleep
| ||
| || Volume segments:
| |+--- Volume B (medium, high)
| +---- Volume A (low, high)
+------ Speaker
</pre>
=== LCD Timing Configuration ($70, $71, $72, $73, $74, $75, $76, $77 SwanCrystal only) ===
These eight bytes are read from internal EEPROM and configure unknown aspects of the console's TFT LCD panel.
They are only writable while the [[Boot ROM]] is unlocked - locking has the side effect of making them read-only.
== Notes ==
<references />
26225b25b1ed95f35aec585f66ee9f035ec34d01
206
205
2023-08-27T18:54:06Z
Asie
351
add missing ports
wikitext
text/x-wiki
The WonderSwan's display functionality generally consists of:
* a 224x144 display clocked at ~75.47 Hz by default, capable of displaying:
** up to sixteen distinct shades of gray
** 12-bit RGB444 color<sup>(color)</sup>
* two 32x32 background layers ("screens"), capable of displaying up to 512 (1024<sup>(color)</sup>) distinct tiles,
* a sprite layer, capable of displaying up to 128 8x8 sprites (up to 32 per line),
* six LCD icons to the bottom or right of the display, usable as additional indicators.
== Components ==
=== Tiles ===
The "mono" WonderSwan can display up to 512 tiles stored in a planar format, with two bits total per pixel.
The planes are interleaved with each other; that is, two consecutive bytes form a full 8x1 row of the tile:
<pre>
plane 0 plane 1
byte N byte N+1
7 bit 0 7 bit 0 full tile
---- ---- ---- ----
.... ...1 .222 22.. .22222.1
.... ...1 2222 22.. 222222.1
.... .... 22.. .... 22......
...1 1... 22.2 2... --\ 22.33...
...1 1... 22.2 2... --/ 22.33...
.... .... 22.. .... 22......
.... .... .... .... ........
11.. .... .... .... 11......
</pre>
The WonderSwan Color extends this with an additional 512 tiles (available for screens only, not sprites) and support for three new modes.
* The first new mode is another two bit per pixel mode, but using color palettes instead of monochrome shades.
The latter two modes extend tiles to four bits per pixel.
* The first among them is the planar mode, which works similarly to the two bit per pixel mode:
<pre>
plane 0 plane 1 plane 2 plane 3
byte N byte N+1 byte N+2 byte N+3
7 bit 0 7 bit 0 7 bit 0 7 bit 0 full rows
---- ---- ---- ---- ---- ---- ---- ----
1.1. 1.1. 22.. 22.. 4444 .... .... .... --\ 7654321.
.1.1 .1.1 ..22 ..22 .... 4444 8888 8888 --/ 89ABCDEF
</pre>
* The second is the chunky mode, which instead stores each plane as consecutive bits, with each byte responsible for two of the eight pixels:
<pre>
pxl 1,0 pxl 2,3 pxl 5,4 pxl 7,6
byte N byte N+1 byte N+2 byte N+3
7 bit 0 7 bit 0 7 bit 0 7 bit 0 full rows
---- ---- ---- ---- ---- ---- ---- ----
.42. .421 .4.. .4.1 ..2. ..21 .... ...1 --\ 7654321.
8..1 8... 8.21 8.2. 84.1 84.. 8421 842. --/ 89ABCDEF
</pre>
=== Colors, Shades ===
The "mono" WonderSwan uses eight value indices, which are converted by a global look-up table to eight of the sixteen shades the LCD can display:
<pre>
Palette Global shade LUT
1 ===========> 2 ==========================> 5
^ (0, 2, 4, 6) ^ (1, 3, 5, 7, 9, 11, 13, 15) ^
| | |
Tile pixel Value Displayed shade
</pre>
In "color" mode, the WonderSwan instead loads RGB444 color values from a table in the console's internal RAM:
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
.... rrrr gggg bbbb
|||| |||| ||||
|||| |||| ++++- Blue (0-15)
|||| ++++------ Green (0-15)
++++------------ Red (0-15)
</pre>
No further processing or look-up tables are applied.
=== Palettes ===
The WonderSwan provides sixteen different palettes. All sixteen can be used for screens only, while the latter eight can be used for screens and sprites. In addition, the background color (for areas where no opaque pixel is drawn) can be selected arbitrarily from the color palette or from the shade LUT.
In two bit per pixel modes, palettes 0 - 3 and 8 - 11 are ''opaque'' (color zero is opaque, four distinct colors are usable), while palettes 4 - 7 and 12 - 15 are ''translucent'' (color zero is transparent, three distinct colors are usable). This applies in both mono and color modes.
In four bit per pixel modes, every palette is ''translucent'' (color zero is transparent, fifteen distinct colors are usable). The first entry of each palette can be used only for the background color.
Palettes 8-15 are also referred to as sprite palettes 0-7.
=== Screens ===
The WonderSwan can display up to two distinct 32x32 screens. These consist of 1024 two-byte cells:
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
vhbp pppt tttt tttt
|||| |||| |||| ||||
|||| |||+--++++-++++- Tile index (0-511)
|||+-+++------------- Palette (0-15)
||+------------------ Tile bank (0-1) - color only
|+------------------- Horizontal flip
+-------------------- Vertical flip
</pre>
=== Sprites ===
The WonderSwan can display up to 128 sprites at once. These are stored in a sprite table in RAM, which consists of up to 128 four-byte entries:
<pre>
(Byte 1) (Byte 0)
15 bit 8 7 bit 0
---- ---- ---- ----
vhPi pppt tttt tttt
|||| |||| |||| ||||
|||| |||+--++++-++++- Tile index (0-511) - only bank 0
|||| +++------------- Palette (0-7) - mapped to screen palettes 8-15
|||+----------------- Window location - 0 = inside, 1 = outside
||+------------------ Priority - 0 = behind Screen 2, 1 = in front of Screen 2
|+------------------- Horizontal flip
+-------------------- Vertical flip
(Byte 2)
7 bit 0
---- ----
yyyy yyyy
|||| ||||
++++-++++- Y coordinate
(Byte 3)
7 bit 0
---- ----
xxxx xxxx
|||| ||||
++++-++++- X coordinate
</pre>
For each row, the first 32 sprites for that row will be drawn - including sprites obscured by windows or outside of the visible range; only the Y coordinate determines this. The earlier among those sprites will be on top of the later ones.
=== Visibility priority ===
For display components, the visibility priority is as follows:
* Sprite 0, high priority
* Sprite 127, high priority
* Screen 2
* Sprite 0, low priority
* Sprite 127, low priority
* Screen 1
* Background color
=== Windows ===
Screen 2 and the sprite layer can optionally be restricted to a specific window.
In addition, one can control if a given element is rendered inside or outside that window. For Screen 2, this is controlled globally; for sprites, this is controlled per-sprite.
=== Icons ===
Finally, the WonderSwan features six LCD segment icons which are displayed to the right<sup>(color)</sup> or below<sup>(mono)</sup> the main display. These are, as follows:
* Aux 3 - large circle,
* Aux 2 - medium circle,
* Aux 1 - small circle,
* Horizontal orientation,
* Vertical orientation,
* Sleep.
== Interrupts ==
The display circuit generates two interrupts of its own:
* Display Interrupt Line Match - when <code>Display Current Line</code> == <code>Display Interrupt Line</code>, at the beginning of said line.
* Display Vertical Blank - when <code>Display Current Line</code> == <code>144</code>, at the beginning of said line.
It also provides a timing source for the two Horizontal and Vertical Blank [[Timers]], which provide their own respective interrupts.
== I/O ports ==
{{Anchor|Display Control}}
=== Display Control ($00) ===
<pre>
7 bit 0
---- ----
..ow Ws21
|| ||||
|| |||+- Enable Screen 1 layer
|| ||+-- Enable Screen 2 layer
|| |+--- Enable Sprite layer
|| +---- Enable Sprite window
|+------ Enable Screen 2 window
+------- Screen 2 window location:
0 = inside, 1 = outside
</pre>
{{Anchor|Display Background}}
=== Display Background Color ($01) ===
<pre>
(mono) (color)
7 bit 0 7 bit 0
---- ---- ---- ----
.... .sss pppp iiii
||| |||| ||||
+++- Value |||| ++++- Index in palette (0-15)
(0-7) ++++------ Color palette (0-15)
</pre>
{{Anchor|Display Current Line}}
=== Display Current Line ($02 read) ===
The current line being drawn by the display.
Note that lines are sent to the display with a one-line delay. This matters for color palette or shade LUT manipulation; changing these values when <code>current line == 1</code> will actually affect line 0.
{{Anchor|Display Interrupt Line}}
=== Display Interrupt Line ($03) ===
The line to emit an interrupt on.
{{Anchor|Sprite Table Address}}
=== Sprite Table Address ($04) ===
<pre>
7 bit 0
---- ----
..Aa aaaa
|| ||||
|+-++++- Address (bits 9-13)
+------- Address (bit 14) - color only
</pre>
{{Anchor|Sprite Table First}}
=== Sprite Table First ($05) ===
<pre>
7 bit 0
---- ----
.iii iiii
||| ||||
+++-++++- Index of first sprite entry to draw (0-127)
</pre>
{{Anchor|Sprite Table Count}}
=== Sprite Table Count ($06) ===
<pre>
7 bit 0
---- ----
cccc cccc
|||| ||||
++++-++++- Count of sprite entries to draw (1-128)
</pre>
{{Anchor|Screen Address}}
=== Screen Address ($07) ===
<pre>
7 bit 0
---- ----
2222 1111
|||| ||||
|||| |+++- Screen 1 address (bits 11-13)
|||| +---- Screen 1 address (bit 14) - color only
|+++------ Screen 2 address (bits 11-13)
+--------- Screen 2 address (bit 14) - color only
</pre>
{{Anchor|Screen 2 Window}}
=== Screen 2 Window Left ($08) ===
=== Screen 2 Window Top ($09) ===
=== Screen 2 Window Right ($0A) ===
=== Screen 2 Window Bottom ($0B) ===
{{Anchor|Sprite Window}}
=== Sprite Window Left ($0C) ===
=== Sprite Window Top ($0D) ===
=== Sprite Window Right ($0E) ===
=== Sprite Window Bottom ($0F) ===
{{Anchor|Screen Scroll}}
=== Screen 1 Scroll X ($10) ===
=== Screen 1 Scroll Y ($11) ===
=== Screen 2 Scroll X ($12) ===
=== Screen 2 Scroll Y ($13) ===
{{Anchor|LCD Control}}
=== LCD Control ($14) ===
<pre>
7 bit 0
---- ----
.... ..Ce
||
|+- LCD Enable: 0 = sleep, 1 = enabled
+-- Contrast (WSC): 0 = low, 1 = high
</pre>
{{Anchor|LCD Icon Control}}
=== LCD Icon Control ($15) ===
<pre>
7 bit 0
---- ----
..32 1hvs
|| ||||
|| |||+- Sleep
|| ||+-- Vertical orientation
|| |+--- Horizontal orientation
|| +---- Aux 1
|+------ Aux 2
+------- Aux 3
</pre>
{{Anchor|LCD Mono Shade LUT}}
=== LCD Mono Shade LUT ($1C-$1F) ===
<pre>
$1C $1D $1E $1F
7 bit 0 7 bit 0 7 bit 0 7 bit 0
---- ---- ---- ---- ---- ---- ---- ----
1111 0000 3333 2222 5555 4444 7777 6666
</pre>
{{Anchor|LCD Mono Palette}}
=== LCD Mono Palette 0..15 ($20, $21 .. $3E, $3F) ===
The monochrome palette is laid out as sixteen words:
<pre>
N+1 N
15 bit 8 7 bit 0
---- ---- ---- ----
.333 .222 .111 .000
||| ||| ||| |||
||| ||| ||| +++- Shade LUT index for color 0
||| ||| +++------ Shade LUT index for color 1
||| +++------------ Shade LUT index for color 2
+++----------------- Shade LUT index for color 3
</pre>
== Internal I/O ports ==
These I/O ports are said to be internal and not intended for use by commercial games.
{{Anchor|LCD Final Line}}
=== LCD Final Line ($16) ===
The final line preceding line counter restart. By default, this should be set to 158.
It is said setting this register to an odd value on SwanCrystal has an adverse effect to the LCD panel<ref>[http://daifukkat.su/docs/wsman/#REG_LCD_VSYNC REG_LCD_VSYNC - WSMan]</ref>, but the exact mechanism is unknown.
{{Anchor|LCD Back Porch Line}}
=== LCD Back Porch Line ($17, WSC only) ===
This port is available on the WonderSwan Color only - not the SwanCrystal!
The final line preceding the vertical back porch; by default, this should be set to 155.
The vertical back porch of the LCD is assumed to be 4 lines by some hardware, including IPS mods, as well as the official "TV Swan" capture device. Given that the first visible line is sent to the LCD on the display's line 1, this should be generally set to <code>LCD Final Line - 3</code>.
Conversely, it is said moving this value closer to vertical blank improves LCD visibility<ref>[http://daifukkat.su/docs/wsman/#REG_LCD_VTOTAL REG_LCD_VTOTAL - WSMan]</ref>, but the exact mechanism is unknown.
{{Anchor|LCD Status}}
=== LCD Status ($1A) ===
<pre>
7 bit 0
---- ----
...v vv.s
| || |
| || +- LCD sleep: 0 = no, 1 = sleep
| ||
| || Volume segments:
| |+--- Volume B (medium, high)
| +---- Volume A (low, high)
+------ Speaker
</pre>
=== TFT LCD Configuration ($70, $71, $72, $73, $74, $75, $76, $77 SwanCrystal only) ===
These eight bytes are read from internal EEPROM and configure unknown aspects of the console's TFT LCD panel.
They are only writable while the [[Boot ROM]] is unlocked - locking has the side effect of making them read-only.
== Notes ==
<references />
e635deb6c68a54dc967c674b01a43e3814350254
NEC V30MZ
0
39
207
173
2023-08-27T18:55:20Z
Asie
351
add STSWS link for now
wikitext
text/x-wiki
The NEC V30MZ is the CPU component of the WonderSwan SoC.
Unlike the NEC V20/V30 CPU family, the V30MZ is fully compatible with the Intel 80186's documented behaviour, as well as some of its undocumented behaviour (such as the SALC opcode); it also omits the V20/V30's opcode extensions.
The NEC V30MZ datasheet uses distinct names for opcodes and registers (''NEC names''); as all homebrew compilers and assemblers for the platform utilize Intel's official naming (''Intel names''), the latter is what the wiki has standardized on.
== Sections ==
* [[NEC V30MZ/Undocumented|CPU undocumented behavior]]
== Links ==
* [https://www.ardent-tool.com/CPU/docs/NEC/V20-V30/v30mz.pdf NEC V30MZ datasheet]
* [http://perfectkiosk.net/stsws.html#cpu STSWS - CPU - V30MZ/V Series Microprocessor]
1134fde269d41cf3a206b1900a48bdcfc684a189
Sound
0
27
208
147
2023-08-27T18:56:37Z
Asie
351
wikitext
text/x-wiki
The WonderSwan features the following sound hardware:
* Four audio channels:
** channel 1 - wavetable (32 x 4-bit samples),
** channel 2 - wavetable or 8-bit unsigned PCM sample,
** channel 3 - wavetable with optional hardware sweep,
** channel 4 - wavetable or LFSR noise,
* [[Hyper Voice]]<sup>(color)</sup> - headphone output exclusive 16-bit stereo PCM output,
* 24000 Hz output:
** internal speaker - 8-bit, mono,
** headphone output - 16-bit, stereo.
[[Hyper Voice]] functionality is documented on its own sub-page.
== Mixing diagram ==
The sound is mixed as follows:
<pre>
Ch1 Ch2 Ch3 Ch4 Glossary: L = left, R = right, M = mono
| | | | Mnn = nn-bit mono
8 8 8 8 port $98 port $nn = value port
| | | | /
_V___V___V___V_ / _____ _____
| |--L10------+------| | | |
| + | | | + |--M11-->| >>r |--M8--> Speaker output
|_______________|--R10------|-+----|_____| / |_____|
/ _|_|_ / (r=0...3)
/ | | / \
port $96 | <<5 | port $9A \
|_____| \
| | port $91
| |
port $68 port $64 | |
/ _______________ \ __V_V__ _____
L8-->| (Color only) |--L16-->| |----------L16---| |
| Hyper Voice | | + + | | I2S |------> Headphone output
R8-->|_______________|--R16-->|_______|----------R16---|_____|
\ /
port $69 port $66
</pre>
== I/O Ports ==
{{Anchor|Sound Channel Frequency}}
=== Sound Channel Frequency ($80, $81; $82, $83; $84, $85; $86, $87) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
.... .ddd dddd dddd
||| |||| ||||
+++--++++-++++- Frequency divisor
</pre>
This frequency is used for wavetable output. It is calculated as follows: <code>sample rate = 3072000 Hz / (2048 - divisor)</code>.
Note that this refers to the sample rate of the ''wavetable'', and needs to be scaled accordingly for a given waveform when performing music playback.
{{Anchor|Sound Channel Volume}}
=== Sound Channel Volume ($88; $89; $8A; $8B) ===
<pre>
7 bit 0
---------
llll rrrr
|||| ||||
|||| ++++- Right channel volume (0-15)
++++------ Left channel volume (0-15)
</pre>
This volume is used for wavetable output.
The calculation to get an unsigned 8-bit sample out of a 4-bit wavetable sample / 4-bit volume pair is simple: <code>out_sample = sample * volume</code>. This means that the maximum sample in wavetable output mode is <code>15 * 15 = 225</code>.
{{Anchor|Sound Channel 2 Voice Sample}}
=== Sound Channel 2 Voice Sample ($89) ===
<pre>
7 bit 0
---- ----
ssss ssss
|||| ||||
++++-++++- Unsigned 8-bit PCM sample (0-255)
</pre>
This sample is used for voice output.
{{Anchor|Sound Channel 3 Sweep Amount}}
=== Sound Channel 3 Sweep Amount ($8C) ===
<pre>
7 bit 0
---- ----
vvvv vvvv
|||| ||||
++++-++++- Value; 8-bit, signed.
</pre>
This port is used for wavetable output with sweep enabled.
The signed value in this port will be added to the frequency divider for channel 3 every sweep step (as determined by the Sweep Ticks port). Wraparound is present - adding 1 to a frequency divider value of 2047 will cause it to roll over back to 0.
{{Anchor|Sound Channel 3 Sweep Ticks}}
=== Sound Channel 3 Sweep Ticks ($8D) ===
<pre>
7 bit 0
---- ----
...t tttt
| ||||
+-++++- Ticks per step - 1
</pre>
This port is used for wavetable output with sweep enabled.
Every <code>ttttt + 1</code> ticks, clocked at 375 Hz, the value in the Sweep Amount port will be added to the frequency divider for channel 3.
{{Anchor|Sound Channel 4 Noise Control}}
=== Sound Channel 4 Noise Control ($8E) ===
<pre>
7 bit 0
---- ----
...e rttt
| ||||
| |+++- LFSR tap mode
| +---- LFSR reset: 1 = reset shift register
+------ LFSR enabled: 0 = off, 1 = on
</pre>
This port is used for noise output.
{| class="wikitable"
|+ List of LFSR tap modes
! Tap mode
! Tap bit
! Sequence length
|-
| 0
| 14
| 32767
|-
| 1
| 10
| 1953
|-
| 2
| 13
| 254
|-
| 3
| 4
| 217
|-
| 4
| 8
| 73
|-
| 5
| 6
| 63
|-
| 6
| 9
| 42
|-
| 7
| 11
| 28
|}
Noise output works using the following algorithm, performed once per sample generated:
# Create a new bit by XORing bit 7 with the tap bit.
# Shift the LFSR register one bit to the left.
# Write the new bit as bit 0.
# Use the new bit as if it were a wavetable sample: 0 = 0, 1 = 15.
{{Anchor|Sound Wavetable Address}}
=== Sound Wavetable Address ($8F) ===
<pre>
7 bit 0
---- ----
wwww wwww
|||| ||||
++++-++++- Wavetable address (bits 6-13)
</pre>
The wavetable is 4 x 16 bytes long; each 16-byte block contains 32 4-bit samples for the relevant channel:
<pre>
Address $00 $01 $02 $03 $04 $05 $06 $07 $08 $09 $0A $0B $0C $0D $0E $0F
98 CB ED FF FF EF BD 8A 57 24 01 00 00 21 43 76
Sample
15 .. .. .. ## ## #. .. .. .. .. .. .. .. .. .. ..
14 .. .. .# || || |# .. .. .. .. .. .. .. .. .. ..
13 .. .. #| || || || #. .. .. .. .. .. .. .. .. ..
12 .. .# || || || || |. .. .. .. .. .. .. .. .. ..
11 .. #| || || || || |# .. .. .. .. .. .. .. .. ..
10 .. || || || || || || #. .. .. .. .. .. .. .. ..
9 .# || || || || || || |. .. .. .. .. .. .. .. ..
8 #| || || || || || || |# .. .. .. .. .. .. .. ..
7 || || || || || || || || #. .. .. .. .. .. .. .#
6 || || || || || || || || |. .. .. .. .. .. .. #|
5 || || || || || || || || |# .. .. .. .. .. .. ||
4 || || || || || || || || || #. .. .. .. .. .# ||
3 || || || || || || || || || |. .. .. .. .. #| ||
2 || || || || || || || || || |# .. .. .. .# || ||
1 || || || || || || || || || || #. .. .. #| || ||
0 || || || || || || || || || || |# ## ## || || ||
</pre>
Note that the ''higher'' bits - the first hexadecimal number - specify the ''later'' samples; that is to say, the nybbles of each sample are swapped relative to the wave drawing.
{{Anchor|Sound Channel Control}}
=== Sound Channel Control ($90) ===
<pre>
7 bit 0
---- ----
nsv. 4321
||| ||||
||| |||+- Channel 1 enable
||| ||+-- Channel 2 enable
||| |+--- Channel 3 enable
||| +---- Channel 4 enable
||+------- Channel 2 mode: 0 = wavetable, 1 = voice
|+-------- Channel 3 sweep: 0 = disable, 1 = enable
+--------- Channel 4 mode: 0 = wavetable, 1 = noise
</pre>
{{Anchor|Sound Output Control}}
=== Sound Output Control ($91) ===
<pre>
7 bit 0
---- ----
H... hrrs
| ||||
| |||+- Internal speaker output enable
| |++-- Internal speaker shift right value
| +---- Headphone output enable
+--------- Headphones connected: 1 if true
</pre>
It is a good idea to set the internal speaker shift right value correctly. If the value is too low, multi-channel music will clip; if the value is too high, single-channel PCM sample playback will be very quiet.
{{Anchor|Sound Channel 4 LFSR Register}}
=== Sound Channel 4 LFSR Register ($92, $93 read) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
.rrr rrrr rrrr rrrr
||| |||| |||| ||||
+++-++++--++++-++++- Shift register value
</pre>
{{Anchor|Sound Channel 2 Voice Volume}}
=== Sound Channel 2 Voice Volume ($94) ===
<pre>
7 bit 0
---- ----
.... lLrR
||||
|||+- Right channel 100% volume
||+-- Right channel 50% volume
|+--- Left channel 100% volume
+---- Left channel 50% volume
</pre>
This port is used for voice output.
The <code>50% volume</code> have no effect if their respective <code>100% volume</code> bits are set.
{{Anchor|Sound Channel Output Right}}
=== Sound Channel Output Right ($96, $97 read) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
.... ..ss ssss ssss
|| |||| ||||
++--++++-++++- Unsigned 10-bit sample
</pre>
{{Anchor|Sound Channel Output Left}}
=== Sound Channel Output Left ($98, $99 read) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
.... ..ss ssss ssss
|| |||| ||||
++--++++-++++- Unsigned 10-bit sample
</pre>
{{Anchor|Sound Channel Output Sum}}
=== Sound Channel Output Sum ($9A, $9B read) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
.... .sss ssss ssss
||| |||| ||||
+++--++++-++++- Unsigned 11-bit sample
</pre>
befcfbb2d9dcf9dd74a1fa4044a63c52b0eb9da5
209
208
2023-08-27T18:56:58Z
Asie
351
/* Mixing diagram */
wikitext
text/x-wiki
The WonderSwan features the following sound hardware:
* Four audio channels:
** channel 1 - wavetable (32 x 4-bit samples),
** channel 2 - wavetable or 8-bit unsigned PCM sample,
** channel 3 - wavetable with optional hardware sweep,
** channel 4 - wavetable or LFSR noise,
* [[Hyper Voice]]<sup>(color)</sup> - headphone output exclusive 16-bit stereo PCM output,
* 24000 Hz output:
** internal speaker - 8-bit, mono,
** headphone output - 16-bit, stereo.
[[Hyper Voice]] functionality is documented on its own sub-page.
== Mixing diagram ==
The sound is mixed as follows:
<pre>
Ch1 Ch2 Ch3 Ch4 Glossary: L = left, R = right, M = mono
| | | | Mnn = nn-bit mono
8 8 8 8 port $98 port $nn = value port
| | | | /
_V___V___V___V_ / _____ _____
| |--L10------+----->| | | |
| + | | | + |--M11-->| >>r |--M8--> Speaker output
|_______________|--R10------|-+--->|_____| / |_____|
/ _|_|_ / (r=0...3)
/ | | / \
port $96 | <<5 | port $9A \
|_____| \
| | port $91
| |
port $68 port $64 | |
/ _______________ \ __V_V__ _____
L8-->| (Color only) |--L16-->| |----------L16-->| |
| Hyper Voice | | + + | | I2S |------> Headphone output
R8-->|_______________|--R16-->|_______|----------R16-->|_____|
\ /
port $69 port $66
</pre>
== I/O Ports ==
{{Anchor|Sound Channel Frequency}}
=== Sound Channel Frequency ($80, $81; $82, $83; $84, $85; $86, $87) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
.... .ddd dddd dddd
||| |||| ||||
+++--++++-++++- Frequency divisor
</pre>
This frequency is used for wavetable output. It is calculated as follows: <code>sample rate = 3072000 Hz / (2048 - divisor)</code>.
Note that this refers to the sample rate of the ''wavetable'', and needs to be scaled accordingly for a given waveform when performing music playback.
{{Anchor|Sound Channel Volume}}
=== Sound Channel Volume ($88; $89; $8A; $8B) ===
<pre>
7 bit 0
---------
llll rrrr
|||| ||||
|||| ++++- Right channel volume (0-15)
++++------ Left channel volume (0-15)
</pre>
This volume is used for wavetable output.
The calculation to get an unsigned 8-bit sample out of a 4-bit wavetable sample / 4-bit volume pair is simple: <code>out_sample = sample * volume</code>. This means that the maximum sample in wavetable output mode is <code>15 * 15 = 225</code>.
{{Anchor|Sound Channel 2 Voice Sample}}
=== Sound Channel 2 Voice Sample ($89) ===
<pre>
7 bit 0
---- ----
ssss ssss
|||| ||||
++++-++++- Unsigned 8-bit PCM sample (0-255)
</pre>
This sample is used for voice output.
{{Anchor|Sound Channel 3 Sweep Amount}}
=== Sound Channel 3 Sweep Amount ($8C) ===
<pre>
7 bit 0
---- ----
vvvv vvvv
|||| ||||
++++-++++- Value; 8-bit, signed.
</pre>
This port is used for wavetable output with sweep enabled.
The signed value in this port will be added to the frequency divider for channel 3 every sweep step (as determined by the Sweep Ticks port). Wraparound is present - adding 1 to a frequency divider value of 2047 will cause it to roll over back to 0.
{{Anchor|Sound Channel 3 Sweep Ticks}}
=== Sound Channel 3 Sweep Ticks ($8D) ===
<pre>
7 bit 0
---- ----
...t tttt
| ||||
+-++++- Ticks per step - 1
</pre>
This port is used for wavetable output with sweep enabled.
Every <code>ttttt + 1</code> ticks, clocked at 375 Hz, the value in the Sweep Amount port will be added to the frequency divider for channel 3.
{{Anchor|Sound Channel 4 Noise Control}}
=== Sound Channel 4 Noise Control ($8E) ===
<pre>
7 bit 0
---- ----
...e rttt
| ||||
| |+++- LFSR tap mode
| +---- LFSR reset: 1 = reset shift register
+------ LFSR enabled: 0 = off, 1 = on
</pre>
This port is used for noise output.
{| class="wikitable"
|+ List of LFSR tap modes
! Tap mode
! Tap bit
! Sequence length
|-
| 0
| 14
| 32767
|-
| 1
| 10
| 1953
|-
| 2
| 13
| 254
|-
| 3
| 4
| 217
|-
| 4
| 8
| 73
|-
| 5
| 6
| 63
|-
| 6
| 9
| 42
|-
| 7
| 11
| 28
|}
Noise output works using the following algorithm, performed once per sample generated:
# Create a new bit by XORing bit 7 with the tap bit.
# Shift the LFSR register one bit to the left.
# Write the new bit as bit 0.
# Use the new bit as if it were a wavetable sample: 0 = 0, 1 = 15.
{{Anchor|Sound Wavetable Address}}
=== Sound Wavetable Address ($8F) ===
<pre>
7 bit 0
---- ----
wwww wwww
|||| ||||
++++-++++- Wavetable address (bits 6-13)
</pre>
The wavetable is 4 x 16 bytes long; each 16-byte block contains 32 4-bit samples for the relevant channel:
<pre>
Address $00 $01 $02 $03 $04 $05 $06 $07 $08 $09 $0A $0B $0C $0D $0E $0F
98 CB ED FF FF EF BD 8A 57 24 01 00 00 21 43 76
Sample
15 .. .. .. ## ## #. .. .. .. .. .. .. .. .. .. ..
14 .. .. .# || || |# .. .. .. .. .. .. .. .. .. ..
13 .. .. #| || || || #. .. .. .. .. .. .. .. .. ..
12 .. .# || || || || |. .. .. .. .. .. .. .. .. ..
11 .. #| || || || || |# .. .. .. .. .. .. .. .. ..
10 .. || || || || || || #. .. .. .. .. .. .. .. ..
9 .# || || || || || || |. .. .. .. .. .. .. .. ..
8 #| || || || || || || |# .. .. .. .. .. .. .. ..
7 || || || || || || || || #. .. .. .. .. .. .. .#
6 || || || || || || || || |. .. .. .. .. .. .. #|
5 || || || || || || || || |# .. .. .. .. .. .. ||
4 || || || || || || || || || #. .. .. .. .. .# ||
3 || || || || || || || || || |. .. .. .. .. #| ||
2 || || || || || || || || || |# .. .. .. .# || ||
1 || || || || || || || || || || #. .. .. #| || ||
0 || || || || || || || || || || |# ## ## || || ||
</pre>
Note that the ''higher'' bits - the first hexadecimal number - specify the ''later'' samples; that is to say, the nybbles of each sample are swapped relative to the wave drawing.
{{Anchor|Sound Channel Control}}
=== Sound Channel Control ($90) ===
<pre>
7 bit 0
---- ----
nsv. 4321
||| ||||
||| |||+- Channel 1 enable
||| ||+-- Channel 2 enable
||| |+--- Channel 3 enable
||| +---- Channel 4 enable
||+------- Channel 2 mode: 0 = wavetable, 1 = voice
|+-------- Channel 3 sweep: 0 = disable, 1 = enable
+--------- Channel 4 mode: 0 = wavetable, 1 = noise
</pre>
{{Anchor|Sound Output Control}}
=== Sound Output Control ($91) ===
<pre>
7 bit 0
---- ----
H... hrrs
| ||||
| |||+- Internal speaker output enable
| |++-- Internal speaker shift right value
| +---- Headphone output enable
+--------- Headphones connected: 1 if true
</pre>
It is a good idea to set the internal speaker shift right value correctly. If the value is too low, multi-channel music will clip; if the value is too high, single-channel PCM sample playback will be very quiet.
{{Anchor|Sound Channel 4 LFSR Register}}
=== Sound Channel 4 LFSR Register ($92, $93 read) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
.rrr rrrr rrrr rrrr
||| |||| |||| ||||
+++-++++--++++-++++- Shift register value
</pre>
{{Anchor|Sound Channel 2 Voice Volume}}
=== Sound Channel 2 Voice Volume ($94) ===
<pre>
7 bit 0
---- ----
.... lLrR
||||
|||+- Right channel 100% volume
||+-- Right channel 50% volume
|+--- Left channel 100% volume
+---- Left channel 50% volume
</pre>
This port is used for voice output.
The <code>50% volume</code> have no effect if their respective <code>100% volume</code> bits are set.
{{Anchor|Sound Channel Output Right}}
=== Sound Channel Output Right ($96, $97 read) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
.... ..ss ssss ssss
|| |||| ||||
++--++++-++++- Unsigned 10-bit sample
</pre>
{{Anchor|Sound Channel Output Left}}
=== Sound Channel Output Left ($98, $99 read) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
.... ..ss ssss ssss
|| |||| ||||
++--++++-++++- Unsigned 10-bit sample
</pre>
{{Anchor|Sound Channel Output Sum}}
=== Sound Channel Output Sum ($9A, $9B read) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
.... .sss ssss ssss
||| |||| ||||
+++--++++-++++- Unsigned 11-bit sample
</pre>
14bc5225f45fb299feb64dc59c548aee4adf01a2
Hyper Voice
0
30
212
131
2023-08-29T13:00:29Z
Asie
351
Fix formatting.
wikitext
text/x-wiki
Hyper Voice is a headphone-only sample output channel introduced with the WonderSwan Color. It allows converting 8-bit signed and unsigned, mono and stereo samples into 16-bit signed PCM sent directly to the headphone output, after mixing with the traditional four channels.
== I/O Ports ==
{{Anchor|Hyper Voice Output}}
=== Hyper Voice Left Output ($64, $65) ===
=== Hyper Voice Right Output ($66, $67) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
ssss ssss ssss ssss
|||| |||| |||| ||||
++++-++++--++++-++++- Signed 16-bit sample.
</pre>
Unlike the [[Sound]] sample output registers, these can be written to - allowing for direct 16-bit sample output.
{{Anchor|Hyper Voice Input}}
=== Hyper Voice Left Input ($68) ===
=== Hyper Voice Right Input ($69) ===
<pre>
7 bit 0
---- ----
ssss ssss
|||| ||||
++++-++++- 8-bit sample.
</pre>
These are typically written to by [[DMA|Sound DMA]], but can also be written to manually by the user.
{{Anchor|Hyper Voice Control}}
=== Hyper Voice Control ($6A, $6B) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
.mmc .... errr ffss
||| |||| ||||
||| |||| ||++- Shift/Volume:
||| |||| || 0 = 100% 1 = 50%
||| |||| || 2 = 25% 3 = 12.5%
||| |||| ++--- Input sample mode:
||| |||| 0 = Unsigned
||| |||| 1 = Unsigned, negate
||| |||| 2 = Signed
||| |||| 3 = Signed, ignore Shift/Volume
||| |+++------ Update sample rate/Divisor:
||| | 0 = 24000/1 = 24000 Hz
||| | 1 = 24000/2 = 12000 Hz
||| | 2 = 24000/3 = 8000 Hz
||| | 3 = 24000/4 = 6000 Hz
||| | 4 = 24000/5 = 4800 Hz
||| | 5 = 24000/6 = 4000 Hz
||| | 6 = 24000/8 = 3000 Hz
||| | 7 = 24000/12 = 2000 Hz
||| +--------- Enable: 0 = off, 1 = on
||+----------------- Input channel: 0 = left, 1 = right
++------------------ Channel mode:
0 = Stereo
1 = Mono, left channel only
2 = Mono, right channel only
3 = Mono, both channels
</pre>
36bfe25bb5c05c306501670681bb1124c7ba916f
214
212
2023-08-29T14:08:32Z
Asie
351
fix Control register
wikitext
text/x-wiki
Hyper Voice is a headphone-only sample output channel introduced with the WonderSwan Color. It allows converting 8-bit signed and unsigned, mono and stereo samples into 16-bit signed PCM sent directly to the headphone output, after mixing with the traditional four channels.
== I/O Ports ==
{{Anchor|Hyper Voice Output}}
=== Hyper Voice Left Output ($64, $65) ===
=== Hyper Voice Right Output ($66, $67) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
ssss ssss ssss ssss
|||| |||| |||| ||||
++++-++++--++++-++++- Signed 16-bit sample.
</pre>
Unlike the [[Sound]] sample output registers, these can be written to - allowing for direct 16-bit sample output.
{{Anchor|Hyper Voice Input}}
=== Hyper Voice Left Input ($68) ===
=== Hyper Voice Right Input ($69) ===
<pre>
7 bit 0
---- ----
ssss ssss
|||| ||||
++++-++++- 8-bit sample.
</pre>
These are typically written to by [[DMA|Sound DMA]], but can also be written to manually by the user.
{{Anchor|Hyper Voice Control}}
=== Hyper Voice Control ($6A, $6B) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
.mmc ???? errr ffss
||| |||| ||||
||| |||| ||++- Shift/Volume:
||| |||| || 0 = 100% 1 = 50%
||| |||| || 2 = 25% 3 = 12.5%
||| |||| ++--- Input sample mode:
||| |||| 0 = Unsigned
||| |||| 1 = Unsigned, negate
||| |||| 2 = Signed
||| |||| 3 = Signed, ignore Shift/Volume
||| |+++------ Update sample rate/Divisor:
||| | 0 = 24000/1 = 24000 Hz
||| | 1 = 24000/2 = 12000 Hz
||| | 2 = 24000/3 = 8000 Hz
||| | 3 = 24000/4 = 6000 Hz
||| | 4 = 24000/5 = 4800 Hz
||| | 5 = 24000/6 = 4000 Hz
||| | 6 = 24000/8 = 3000 Hz
||| | 7 = 24000/12 = 2000 Hz
||| +--------- Enable: 0 = off, 1 = on
||+----------------- Write 1 to reset input channel
++------------------ Channel mode:
0 = Stereo
1 = Mono, left channel only
2 = Mono, right channel only
3 = Mono, both channels
</pre>
008e952c7c184a0555969fc784c9d9bd0b6d66ac
216
214
2023-08-29T14:09:24Z
Asie
351
/* Hyper Voice Control ($6A, $6B) */
wikitext
text/x-wiki
Hyper Voice is a headphone-only sample output channel introduced with the WonderSwan Color. It allows converting 8-bit signed and unsigned, mono and stereo samples into 16-bit signed PCM sent directly to the headphone output, after mixing with the traditional four channels.
== I/O Ports ==
{{Anchor|Hyper Voice Output}}
=== Hyper Voice Left Output ($64, $65) ===
=== Hyper Voice Right Output ($66, $67) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
ssss ssss ssss ssss
|||| |||| |||| ||||
++++-++++--++++-++++- Signed 16-bit sample.
</pre>
Unlike the [[Sound]] sample output registers, these can be written to - allowing for direct 16-bit sample output.
{{Anchor|Hyper Voice Input}}
=== Hyper Voice Left Input ($68) ===
=== Hyper Voice Right Input ($69) ===
<pre>
7 bit 0
---- ----
ssss ssss
|||| ||||
++++-++++- 8-bit sample.
</pre>
These are typically written to by [[DMA|Sound DMA]], but can also be written to manually by the user.
{{Anchor|Hyper Voice Control}}
=== Hyper Voice Control ($6A, $6B) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
.mmc ???? errr ffss
||| |||| ||||
||| |||| ||++- Shift/Volume:
||| |||| || 0 = 100% 1 = 50%
||| |||| || 2 = 25% 3 = 12.5%
||| |||| ++--- Input sample mode:
||| |||| 0 = Unsigned
||| |||| 1 = Unsigned, negate
||| |||| 2 = Signed
||| |||| 3 = Signed, ignore Shift/Volume
||| |+++------ Update sample rate/Divisor:
||| | 0 = 24000/1 = 24000 Hz
||| | 1 = 24000/2 = 12000 Hz
||| | 2 = 24000/3 = 8000 Hz
||| | 3 = 24000/4 = 6000 Hz
||| | 4 = 24000/5 = 4800 Hz
||| | 5 = 24000/6 = 4000 Hz
||| | 6 = 24000/8 = 3000 Hz
||| | 7 = 24000/12 = 2000 Hz
||| +--------- Enable: 0 = off, 1 = on
||+----------------- Write 1 to reset DMA input channel to left
++------------------ Channel mode:
0 = Stereo
1 = Mono, left channel only
2 = Mono, right channel only
3 = Mono, both channels
</pre>
72a8611dd07235efcfba7fadcf68dbda4de2f77f
218
216
2023-08-29T14:20:04Z
Asie
351
wikitext
text/x-wiki
Hyper Voice is a headphone-only sample output channel introduced with the WonderSwan Color. It allows converting 8-bit signed and unsigned, mono and stereo samples into 16-bit signed PCM sent directly to the headphone output, after mixing with the traditional four channels.
== I/O Ports ==
{{Anchor|Hyper Voice Output}}
=== Hyper Voice Left Output ($64, $65 write) ===
=== Hyper Voice Right Output ($66, $67 write) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
ssss ssss ssss ssss
|||| |||| |||| ||||
++++-++++--++++-++++- Signed 16-bit sample.
</pre>
Unlike the [[Sound]] sample output registers, these can be written to - allowing for direct 16-bit sample output.
{{Anchor|Hyper Voice Input}}
=== Hyper Voice Left Input ($68 write) ===
=== Hyper Voice Right Input ($69 write) ===
<pre>
7 bit 0
---- ----
ssss ssss
|||| ||||
++++-++++- 8-bit sample.
</pre>
These are typically written to by [[DMA|Sound DMA]], but can also be written to manually by the user.
{{Anchor|Hyper Voice Control}}
=== Hyper Voice Control ($6A, $6B) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
.mmc ???? errr ffss
||| |||| ||||
||| |||| ||++- Shift/Volume:
||| |||| || 0 = 100% 1 = 50%
||| |||| || 2 = 25% 3 = 12.5%
||| |||| ++--- Input sample mode:
||| |||| 0 = Unsigned
||| |||| 1 = Unsigned, negate
||| |||| 2 = Signed
||| |||| 3 = Signed, ignore Shift/Volume
||| |+++------ Update sample rate/Divisor:
||| | 0 = 24000/1 = 24000 Hz
||| | 1 = 24000/2 = 12000 Hz
||| | 2 = 24000/3 = 8000 Hz
||| | 3 = 24000/4 = 6000 Hz
||| | 4 = 24000/5 = 4800 Hz
||| | 5 = 24000/6 = 4000 Hz
||| | 6 = 24000/8 = 3000 Hz
||| | 7 = 24000/12 = 2000 Hz
||| +--------- Enable: 0 = off, 1 = on
||+----------------- Write 1 to reset DMA input channel to left
++------------------ Channel mode:
0 = Stereo
1 = Mono, left channel only
2 = Mono, right channel only
3 = Mono, both channels
</pre>
026723482ae0e63e5c26ed68ac8a4e7342433738
I/O port map
0
8
213
200
2023-08-29T13:01:18Z
Asie
351
add hyperlinks for Hyper Voice ports
wikitext
text/x-wiki
The WonderSwan SoC has three general blocks of I/O port accesses:
{| class="wikitable"
! From !! To !! Holder !! Width
|-
| $00 || $B7 || WonderSwan SoC || 8/16-bit
|-
| $B8 || $BF || Internal EEPROM control || 16-bit
|-
| $C0 || $FF || Cartridge bus || 8-bit
|}
With the exception of internal EEPROM on the ASWAN, all unaligned 16-bit accesses can be converted to two 8-bit accesses with a 1-cycle penalty.
== I/O port map ==
* Superscripts are used to mark ports specific to a given mode or platform:
** Color mode: <sup>(color)</sup>. Such ports are only accessible when color mode is enabled through port <code>$60</code>.
** WS/WSC/SC console: <sup>(WS)</sup>, <sup>(WSC)</sup>, <sup>(SC)</sup>.
* If two Bits rows are provided, the second one refers to the "Color" mode.
* The Type can be: R - readable, W - writable, L - writable before boot ROM lockout, 8/16 - width (byte/word).
{| class="wikitable"
! Category
! Port
! Description
! Bits
! Type
! Notes
|-
! rowspan="45" | [[Display]]
! $00
| [[Display#Display Control|Display Control]]
| style="text-align: right" | <tt style="white-space: nowrap">..ow Ws21</tt>
| RW8
|
|-
! $01
| [[Display#Display Background|Display Background]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .sss</tt>
<tt style="white-space: nowrap">pppp iiii</tt>
| RW8
| Shade (s)
Palette (p), Index (i)
|-
! $02
| [[Display#Current Line|Display Current Line]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll</tt>
| R8
| Line (l)
|-
! $03
| [[Display#Interrupt Line|Display Interrupt Line]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll</tt>
| RW8
| Line (l)
|-
! $04
| [[Display#Sprite Table Address|Sprite Table Address]]
| style="text-align: right" | <tt style="white-space: nowrap">...a aaaa</tt>
<tt style="white-space: nowrap">..aa aaaa</tt>
| RW8
| Address >> 9 (a)
|-
! $05
| [[Display#Sprite Table First|Sprite Table First]]
| style="text-align: right" | <tt style="white-space: nowrap">.iii iiii</tt>
| RW8
| Index (i)
|-
! $06
| [[Display#Sprite Table Count|Sprite Table Count]]
| style="text-align: right" | <tt style="white-space: nowrap">cccc cccc</tt>
| RW8
| Count (c)
|-
! $07
| [[Display#Screen Address|Screen Address]]
| style="text-align: right" | <tt style="white-space: nowrap">.222 .111</tt>
<tt style="white-space: nowrap">2222 1111</tt>
| RW8
| Screen 1 address >> 11 (1)
Screen 2 address >> 11 (2)
|-
! $08
| [[Display#Screen 2 Window|Screen 2 Window Left]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $09
| [[Display#Screen 2 Window|Screen 2 Window Top]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $0A
| [[Display#Screen 2 Window|Screen 2 Window Right]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $0B
| [[Display#Screen 2 Window|Screen 2 Window Bottom]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $0B
| [[Display#Sprite Window|Sprite Window Left]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $0C
| [[Display#Sprite Window|Sprite Window Top]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $0E
| [[Display#Sprite Window|Sprite Window Right]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $0F
| [[Display#Sprite Window|Sprite Window Bottom]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $10
| [[Display#Screen Scroll|Screen 1 Scroll X]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $11
| [[Display#Screen Scroll|Screen 1 Scroll Y]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $12
| [[Display#Screen Scroll|Screen 2 Scroll X]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $13
| [[Display#Screen Scroll|Screen 2 Scroll Y]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $14
| [[Display#LCD Control|LCD Control]]
| style="text-align: right" | <tt style="white-space: nowrap">.... ..Ce</tt>
| RW8
| Contrast (C)<sup>(WSC)</sup>, Enable (e)
|-
! $15
| [[Display#LCD Icon Control|LCD Icon Control]]
| style="text-align: right" | <tt style="white-space: nowrap">..32 1hvs</tt>
| RW8
| Auxillary 3 (3), Auxillary 2 (2), Auxillary 1 (1),
Horizontal (h), Vertical (v), Sleep (s)
|-
! $16
| [[Display#LCD Final Line|LCD Final Line]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll</tt>
| RW8
| Line (l)
|-
! $17
| [[Display#LCD Back Porch Line|LCD Back Porch Line]]<sup>(WSC)</sup>
| style="text-align: right" | <tt style="white-space: nowrap">llll llll</tt>
| RW8
| Line (l)
|-
! $1A
| [[Display#LCD Status|LCD Status]]
| style="text-align: right" | <tt style="white-space: nowrap">...v vv.s</tt>
| RW8
| Volume segment status (v), Sleep (s)
|-
! $1C
| [[Display#LCD Mono Shade LUT|LCD Mono Shade LUT 0/1]]
| style="text-align: right" | <tt style="white-space: nowrap">1111 0000</tt>
| RW8
| Shade index
|-
! $1D
| [[Display#LCD Mono Shade LUT|LCD Mono Shade LUT 2/3]]
| style="text-align: right" | <tt style="white-space: nowrap">3333 2222</tt>
| RW8
| Shade index
|-
! $1E
| [[Display#LCD Mono Shade LUT|LCD Mono Shade LUT 4/5]]
| style="text-align: right" | <tt style="white-space: nowrap">5555 4444</tt>
| RW8
| Shade index
|-
! $1F
| [[Display#LCD Mono Shade LUT|LCD Mono Shade LUT 6/7]]
| style="text-align: right" | <tt style="white-space: nowrap">7777 6666</tt>
| RW8
| Shade index
|-
! $20
| [[Display#LCD Mono Palette|LCD Mono Palette 0]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $22
| [[Display#LCD Mono Palette|LCD Mono Palette 1]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $24
| [[Display#LCD Mono Palette|LCD Mono Palette 2]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $26
| [[Display#LCD Mono Palette|LCD Mono Palette 3]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $28
| [[Display#LCD Mono Palette|LCD Mono Palette 4]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $2A
| [[Display#LCD Mono Palette|LCD Mono Palette 5]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $2C
| [[Display#LCD Mono Palette|LCD Mono Palette 6]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $2E
| [[Display#LCD Mono Palette|LCD Mono Palette 7]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $30
| [[Display#LCD Mono Palette|LCD Mono Palette 8]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $32
| [[Display#LCD Mono Palette|LCD Mono Palette 9]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $34
| [[Display#LCD Mono Palette|LCD Mono Palette 10]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $36
| [[Display#LCD Mono Palette|LCD Mono Palette 11]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $38
| [[Display#LCD Mono Palette|LCD Mono Palette 12]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $3A
| [[Display#LCD Mono Palette|LCD Mono Palette 13]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $3C
| [[Display#LCD Mono Palette|LCD Mono Palette 14]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $3E
| [[Display#LCD Mono Palette|LCD Mono Palette 15]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! rowspan="10" | [[DMA]]<sup>(color)</sup>
! $40
| [[DMA#General DMA|GDMA Source Address Low]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll llll llll</tt>
| RW16
| Linear address, low 16 bits (l)
|-
! $42
| [[DMA#General DMA|GDMA Source Address High]]
| style="text-align: right" | <tt style="white-space: nowrap">.... hhhh</tt>
| RW8
| Linear address, high 4 bits (h)
|-
! $44
| [[DMA#General DMA|GDMA Destination Address]]
| style="text-align: right" | <tt style="white-space: nowrap">aaaa aaaa aaaa aaaa</tt>
| RW16
| IRAM address (a)
|-
! $46
| [[DMA#General DMA|GDMA Length]]
| style="text-align: right" | <tt style="white-space: nowrap">bbbb bbbb bbbb bbbb</tt>
| RW16
| Bytes (b)
|-
! $48
| [[DMA#General DMA|GDMA Control]]
| style="text-align: right" | <tt style="white-space: nowrap">ed.. ....</tt>
| RW8
| Enable (e), Decrement (d)
|-
! $4A
| [[DMA#Sound DMA|SDMA Source Address Low]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll llll llll</tt>
| RW16
| Linear address, low 16 bits (l)
|-
! $4C
| [[DMA#Sound DMA|SDMA Source Address High]]
| style="text-align: right" | <tt style="white-space: nowrap">.... hhhh</tt>
| RW8
| Linear address, high 4 bits (h)
|-
! $4E
| [[DMA#Sound DMA|SDMA Length Low]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll llll llll</tt>
| RW16
| Length, low 16 bits (l)
|-
! $50
| [[DMA#Sound DMA|SDMA Length High]]
| style="text-align: right" | <tt style="white-space: nowrap">.... hhhh</tt>
| RW8
| Length, high 4 bits (h)
|-
! $52
| [[DMA#Sound DMA|SDMA Control]]
| style="text-align: right" | <tt style="white-space: nowrap">ed.t r?ff</tt>
| RW8
| Enable (e), Decrement (d), Target (t),
Repeat (r), Frequency (f)
|-
! rowspan="2" | [[SoC]]<sup>(color)</sup>
! $60
| [[SoC#System Control 2|System Control 2]]
| style="text-align: right" | <tt style="white-space: nowrap">c4C. ?.??</tt>
| RW8
| Color (c), 4BPP (4), Chunky (C)
|-
! $62
| [[SoC#System Control 3|System Control 3]]
| style="text-align: right" | <tt style="white-space: nowrap">S... ...p</tt>
| RW8
| SwanCrystal (S), Power off (p)
|-
! rowspan="5" | [[Hyper Voice]]<sup>(color)</sup>
! $64
| [[Hyper Voice#Hyper Voice Output|Hyper Voice Left Output]]
| style="text-align: right" | <tt style="white-space: nowrap">ssss ssss ssss ssss</tt>
| W16
| Raw sample (s)
|-
! $66
| [[Hyper Voice#Hyper Voice Output|Hyper Voice Right Output]]
| style="text-align: right" | <tt style="white-space: nowrap">ssss ssss ssss ssss</tt>
| W16
| Raw sample (s)
|-
! $68
| [[Hyper Voice#Hyper Voice Input|Hyper Voice Left Input]]
| style="text-align: right" | <tt style="white-space: nowrap">ssss ssss</tt>
| 8
| Sample (s)
|-
! $69
| [[Hyper Voice#Hyper Voice Input|Hyper Voice Right Input]]
| style="text-align: right" | <tt style="white-space: nowrap">ssss ssss</tt>
| 8
| Sample (s)
|-
! $6A
| [[Hyper Voice#Hyper Voice Control|Hyper Voice Control]]
| style="text-align: right" | <tt style="white-space: nowrap">.mmc .... errr ffss</tt>
| RW16
| Mask (m), Channel (c), Enable (e),
Rate (r), Format (f), Shift (s)
|-
! rowspan="8" | [[Display]]<sup>(SC)</sup>
! $70
| LCD Timing Configuration 1?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $71
| LCD Timing Configuration 2?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $72
| LCD Timing Configuration 3?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $73
| LCD Timing Configuration 4?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $74
| LCD Timing Configuration 5?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $75
| LCD Timing Configuration 6?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $76
| LCD Timing Configuration 7?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $77
| LCD Timing Configuration 8?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! rowspan="21" | [[Sound]]
! $80
| [[Sound#Sound Channel Frequency|Sound Channel 1 Frequency]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .ddd dddd dddd</tt>
| RW16
| Divider (d)
|-
! $82
| [[Sound#Sound Channel Frequency|Sound Channel 2 Frequency]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .ddd dddd dddd</tt>
| RW16
| Divider (d)
|-
! $84
| [[Sound#Sound Channel Frequency|Sound Channel 3 Frequency]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .ddd dddd dddd</tt>
| RW16
| Divider (d)
|-
! $86
| [[Sound#Sound Channel Frequency|Sound Channel 4 Frequency]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .ddd dddd dddd</tt>
| RW16
| Divider (d)
|-
! $88
| [[Sound#Sound Channel Volume|Sound Channel 1 Volume]]
| style="text-align: right" | <tt style="white-space: nowrap">llll rrrr</tt>
| RW8
| Left (l), Right (r)
|-
! rowspan="2" | $89
| [[Sound#Sound Channel Volume|Sound Channel 2 Volume]]
| style="text-align: right" | <tt style="white-space: nowrap">llll rrrr</tt>
| RW8
| Left (l), Right (r)
|-
| [[Sound#Sound Channel 2 Voice Sample|Sound Channel 2 Voice Sample]]
| style="text-align: right" | <tt style="white-space: nowrap">ssss ssss</tt>
| RW8
| Sample (s)
|-
! $8A
| [[Sound#Sound Channel Volume|Sound Channel 3 Volume]]
| style="text-align: right" | <tt style="white-space: nowrap">llll rrrr</tt>
| RW8
| Left (l), Right (r)
|-
! $8B
| [[Sound#Sound Channel Volume|Sound Channel 4 Volume]]
| style="text-align: right" | <tt style="white-space: nowrap">llll rrrr</tt>
| RW8
| Left (l), Right (r)
|-
! $8C
| [[Sound#Sound Channel 3 Sweep Amount|Sound Channel 3 Sweep Amount]]
| style="text-align: right" | <tt style="white-space: nowrap">vvvv vvvv</tt>
| RW8
| Value (v)
|-
! $8D
| [[Sound#Sound Channel 3 Sweep Ticks|Sound Channel 3 Sweep Ticks]]
| style="text-align: right" | <tt style="white-space: nowrap">...t tttt</tt>
| RW8
| Ticks (t)
|-
! $8E
| [[Sound#Sound Channel 4 Noise Control|Sound Channel 4 Noise Control]]
| style="text-align: right" | <tt style="white-space: nowrap">...e rttt</tt>
| RW8
| Enable (e), Reset (r), Tap (t)
|-
! $8F
| [[Sound#Sound Wavetable Address|Sound Wavetable Address]]
| style="text-align: right" | <tt style="white-space: nowrap">wwww wwww</tt>
| RW8
| Address >> 6 (w)
|-
! $90
| [[Sound#Sound Channel Control|Sound Channel Control]]
| style="text-align: right" | <tt style="white-space: nowrap">nsv. 4321</tt>
| RW8
| Channel enable (1234)
Noise (n), Sweep (s), Voice (v)
|-
! $91
| [[Sound#Sound Output Control|Sound Output Control]]
| style="text-align: right" | <tt style="white-space: nowrap">H... hrrs</tt>
| RW8
| Headphones connected (H)
Headphone output (h)
Speaker output (s), range (r)
|-
! $92
| [[Sound#Sound Channel 4 LFSR Register|Sound Channel 4 LFSR Register]]
| style="text-align: right" | <tt style="white-space: nowrap">.rrr rrrr rrrr rrrr</tt>
| R16
| PRNG state (r)
|-
! $94
| [[Sound#Sound Channel 2 Voice Volume|Sound Channel 2 Voice Volume]]
| style="text-align: right" | <tt style="white-space: nowrap">.... lLrR</tt>
| RW8
| Left Half (l), Full (L)
Right Half (r), Full (R)
|-
! $96
| Sound Channel Output Right
| style="text-align: right" | <tt style="white-space: nowrap">.... ..ss ssss ssss</tt>
| R16
| Sample (s)
|-
! $98
| Sound Channel Output Left
| style="text-align: right" | <tt style="white-space: nowrap">.... ..ss ssss ssss</tt>
| R16
| Sample (s)
|-
! $9A
| Sound Channel Output Sum
| style="text-align: right" | <tt style="white-space: nowrap">.... .sss ssss ssss</tt>
| R16
| Sample (s)
|-
! $9E
| Sound Speaker Master Volume<sup>(color)</sup>
| style="text-align: right" | <tt style="white-space: nowrap">.... ..vv</tt>
| R8
| ?
|-
! [[SoC]]
! $A0
| [[SoC#System Control|System Control]]
| style="text-align: right" | <tt style="white-space: nowrap">t??? swcl</tt>
| RW8
| Test OK (t), ROM speed (s), ROM width (w),
Color system (c), Boot ROM lockout (l)
|-
! rowspan="5" | [[Timers]]
! $A2
| [[Timers#Timer Control|Timer Control]]
| style="text-align: right" | <tt style="white-space: nowrap">.... VvHh</tt>
| RW8
| Horizontal enable (h), auto reload (H)
Vertical enable (v), auto reload (V)
|-
! $A4
| [[Timers#Timer Reload|Horizontal Blank Timer Reload]]
| style="text-align: right" | <tt style="white-space: nowrap">tttt tttt tttt tttt</tt>
| RW16
| Ticks (t)
|-
! $A6
| [[Timers#Timer Reload|Vertical Blank Timer Reload]]
| style="text-align: right" | <tt style="white-space: nowrap">tttt tttt tttt tttt</tt>
| RW16
| Ticks (t)
|-
! $A8
| [[Timers#Timer Counter|Horizontal Blank Timer Counter]]
| style="text-align: right" | <tt style="white-space: nowrap">tttt tttt tttt tttt</tt>
| R16
| Ticks (t)
|-
! $AA
| [[Timers#Timer Counter|Vertical Blank Timer Counter]]
| style="text-align: right" | <tt style="white-space: nowrap">tttt tttt tttt tttt</tt>
| R16
| Ticks (t)
|-
! [[Interrupts]]
! $B0
| [[Interrupts#Interrupt Vector|Interrupt Vector]]
| style="text-align: right" | <tt style="white-space: nowrap">VVVV V...</tt>
| RW8
| Vector offset (v)
|-
! rowspan="2" | [[UART]]
! $B1
| [[UART#Serial Receive Data|Serial Receive Data]]
| style="text-align: right" | <tt style="white-space: nowrap">dddd dddd</tt>
| R8
| Receive buffer data (d)
|-
! $B1
| [[UART#Serial Transmit Data|Serial Transmit Data]]
| style="text-align: right" | <tt style="white-space: nowrap">dddd dddd</tt>
| W8
| Transmit buffer data (d)
|-
! [[Interrupts]]
! $B2
| [[Interrupts#Interrupt Enable|Interrupt Enable]]
| iiii iiii
| RW8
| Interrupt index (i)
|-
! rowspan="2" | [[UART]]
! $B3
| [[UART#Serial Status|Serial Status]]
| style="text-align: right" | <tt style="white-space: nowrap">eb.. .tor</tt>
| R8
| Enable (e), Baud rate (b),
Transfer ready (t), Overrun (o), Receive ready (r)
|-
! $B3
| [[UART#Serial Control|Serial Control]]
| style="text-align: right" | <tt style="white-space: nowrap">ebO. ....</tt>
| W8
| Enable (e), Baud rate (b), Reset Overrun (O)
|-
! [[Interrupts]]
! $B4
| [[Interrupts#Interrupt Status|Interrupt Status]]
| iiii iiii
| R8
| Interrupt index (i)
|-
! [[Keypad]]
! $B5
| [[Keypad|Keypad Scan]]
| style="text-align: right" | <tt style="white-space: nowrap">.iii oooo</tt>
| RW8
| Input row (i), Output column (o)
|-
! rowspan="2" | [[Interrupts]]
! $B6
| [[Interrupts#Interrupt Acknowledge|Interrupt Acknowledge]]
| iiii iiii
| R8?
| Interrupt index (i)
|-
! $B7
| [[Interrupts#Interrupt NMI Control|Interrupt NMI Control]]
| style="text-align: right" | <tt style="white-space: nowrap">...b ....</tt>
| RW8
| Low battery (b)
|-
! rowspan="4" | [[EEPROM|Internal EEPROM]]
! $BA
| [[EEPROM#Internal EEPROM Data|Internal EEPROM Data]]
| style="text-align: right" | <tt style="white-space: nowrap">dddd dddd dddd dddd</tt>
| RW16
| Data (d)
|-
! $BC
| [[EEPROM#Internal EEPROM Command|Internal EEPROM Command]]
|
| RW16
|
|-
! rowspan="2" | $BE
| [[EEPROM#Internal EEPROM Status|Internal EEPROM Status]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .... p... ..RD</tt>
| R16
| Protected (p), Ready (R), Done (D)
|-
| [[EEPROM#Internal EEPROM Control|Internal EEPROM Control]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .... pewr ....</tt>
| W16
| Protect (p), Erase (e), Write (w), Read (r)
|-
! [[Mapper|Cartridge]]
! $C0<br />
$FF
| Cartridge I/O
|
| RW8
| Forwarded by the SoC
|}
== I/O port routing ==
The [[NEC V30MZ]] supports 16-bit I/O port addresses. The WonderSwan SoC routes them using the following algorithm:
* If an address is between <code>$00B8</code> and <code>$00BF</code> inclusive, it is routed to the internal EEPROM control block.
* If an address is between <code>$00C0</code> and <code>$00FF</code> inclusive, it is routed to the cartride bus.
* If an address's bits <code>0</code> through <code>8</code> inclusive are between <code>$000</code> and <code>$0B7</code> inclusive, they are routed to the SoC block.
* If none of these conditions are reached, open bus is read.
On the monochrome models, as well as color models in mono emulation, open bus is always <code>0x90</code>.
811ca6c7bebfcc0cf1870ccd001beace6a5c7e96
215
213
2023-08-29T14:09:07Z
Asie
351
fix Hyper Voice ports
wikitext
text/x-wiki
The WonderSwan SoC has three general blocks of I/O port accesses:
{| class="wikitable"
! From !! To !! Holder !! Width
|-
| $00 || $B7 || WonderSwan SoC || 8/16-bit
|-
| $B8 || $BF || Internal EEPROM control || 16-bit
|-
| $C0 || $FF || Cartridge bus || 8-bit
|}
With the exception of internal EEPROM on the ASWAN, all unaligned 16-bit accesses can be converted to two 8-bit accesses with a 1-cycle penalty.
== I/O port map ==
* Superscripts are used to mark ports specific to a given mode or platform:
** Color mode: <sup>(color)</sup>. Such ports are only accessible when color mode is enabled through port <code>$60</code>.
** WS/WSC/SC console: <sup>(WS)</sup>, <sup>(WSC)</sup>, <sup>(SC)</sup>.
* If two Bits rows are provided, the second one refers to the "Color" mode.
* The Type can be: R - readable, W - writable, L - writable before boot ROM lockout, 8/16 - width (byte/word).
{| class="wikitable"
! Category
! Port
! Description
! Bits
! Type
! Notes
|-
! rowspan="45" | [[Display]]
! $00
| [[Display#Display Control|Display Control]]
| style="text-align: right" | <tt style="white-space: nowrap">..ow Ws21</tt>
| RW8
|
|-
! $01
| [[Display#Display Background|Display Background]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .sss</tt>
<tt style="white-space: nowrap">pppp iiii</tt>
| RW8
| Shade (s)
Palette (p), Index (i)
|-
! $02
| [[Display#Current Line|Display Current Line]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll</tt>
| R8
| Line (l)
|-
! $03
| [[Display#Interrupt Line|Display Interrupt Line]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll</tt>
| RW8
| Line (l)
|-
! $04
| [[Display#Sprite Table Address|Sprite Table Address]]
| style="text-align: right" | <tt style="white-space: nowrap">...a aaaa</tt>
<tt style="white-space: nowrap">..aa aaaa</tt>
| RW8
| Address >> 9 (a)
|-
! $05
| [[Display#Sprite Table First|Sprite Table First]]
| style="text-align: right" | <tt style="white-space: nowrap">.iii iiii</tt>
| RW8
| Index (i)
|-
! $06
| [[Display#Sprite Table Count|Sprite Table Count]]
| style="text-align: right" | <tt style="white-space: nowrap">cccc cccc</tt>
| RW8
| Count (c)
|-
! $07
| [[Display#Screen Address|Screen Address]]
| style="text-align: right" | <tt style="white-space: nowrap">.222 .111</tt>
<tt style="white-space: nowrap">2222 1111</tt>
| RW8
| Screen 1 address >> 11 (1)
Screen 2 address >> 11 (2)
|-
! $08
| [[Display#Screen 2 Window|Screen 2 Window Left]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $09
| [[Display#Screen 2 Window|Screen 2 Window Top]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $0A
| [[Display#Screen 2 Window|Screen 2 Window Right]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $0B
| [[Display#Screen 2 Window|Screen 2 Window Bottom]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $0B
| [[Display#Sprite Window|Sprite Window Left]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $0C
| [[Display#Sprite Window|Sprite Window Top]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $0E
| [[Display#Sprite Window|Sprite Window Right]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $0F
| [[Display#Sprite Window|Sprite Window Bottom]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $10
| [[Display#Screen Scroll|Screen 1 Scroll X]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $11
| [[Display#Screen Scroll|Screen 1 Scroll Y]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $12
| [[Display#Screen Scroll|Screen 2 Scroll X]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $13
| [[Display#Screen Scroll|Screen 2 Scroll Y]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $14
| [[Display#LCD Control|LCD Control]]
| style="text-align: right" | <tt style="white-space: nowrap">.... ..Ce</tt>
| RW8
| Contrast (C)<sup>(WSC)</sup>, Enable (e)
|-
! $15
| [[Display#LCD Icon Control|LCD Icon Control]]
| style="text-align: right" | <tt style="white-space: nowrap">..32 1hvs</tt>
| RW8
| Auxillary 3 (3), Auxillary 2 (2), Auxillary 1 (1),
Horizontal (h), Vertical (v), Sleep (s)
|-
! $16
| [[Display#LCD Final Line|LCD Final Line]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll</tt>
| RW8
| Line (l)
|-
! $17
| [[Display#LCD Back Porch Line|LCD Back Porch Line]]<sup>(WSC)</sup>
| style="text-align: right" | <tt style="white-space: nowrap">llll llll</tt>
| RW8
| Line (l)
|-
! $1A
| [[Display#LCD Status|LCD Status]]
| style="text-align: right" | <tt style="white-space: nowrap">...v vv.s</tt>
| RW8
| Volume segment status (v), Sleep (s)
|-
! $1C
| [[Display#LCD Mono Shade LUT|LCD Mono Shade LUT 0/1]]
| style="text-align: right" | <tt style="white-space: nowrap">1111 0000</tt>
| RW8
| Shade index
|-
! $1D
| [[Display#LCD Mono Shade LUT|LCD Mono Shade LUT 2/3]]
| style="text-align: right" | <tt style="white-space: nowrap">3333 2222</tt>
| RW8
| Shade index
|-
! $1E
| [[Display#LCD Mono Shade LUT|LCD Mono Shade LUT 4/5]]
| style="text-align: right" | <tt style="white-space: nowrap">5555 4444</tt>
| RW8
| Shade index
|-
! $1F
| [[Display#LCD Mono Shade LUT|LCD Mono Shade LUT 6/7]]
| style="text-align: right" | <tt style="white-space: nowrap">7777 6666</tt>
| RW8
| Shade index
|-
! $20
| [[Display#LCD Mono Palette|LCD Mono Palette 0]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $22
| [[Display#LCD Mono Palette|LCD Mono Palette 1]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $24
| [[Display#LCD Mono Palette|LCD Mono Palette 2]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $26
| [[Display#LCD Mono Palette|LCD Mono Palette 3]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $28
| [[Display#LCD Mono Palette|LCD Mono Palette 4]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $2A
| [[Display#LCD Mono Palette|LCD Mono Palette 5]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $2C
| [[Display#LCD Mono Palette|LCD Mono Palette 6]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $2E
| [[Display#LCD Mono Palette|LCD Mono Palette 7]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $30
| [[Display#LCD Mono Palette|LCD Mono Palette 8]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $32
| [[Display#LCD Mono Palette|LCD Mono Palette 9]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $34
| [[Display#LCD Mono Palette|LCD Mono Palette 10]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $36
| [[Display#LCD Mono Palette|LCD Mono Palette 11]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $38
| [[Display#LCD Mono Palette|LCD Mono Palette 12]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $3A
| [[Display#LCD Mono Palette|LCD Mono Palette 13]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $3C
| [[Display#LCD Mono Palette|LCD Mono Palette 14]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $3E
| [[Display#LCD Mono Palette|LCD Mono Palette 15]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! rowspan="10" | [[DMA]]<sup>(color)</sup>
! $40
| [[DMA#General DMA|GDMA Source Address Low]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll llll llll</tt>
| RW16
| Linear address, low 16 bits (l)
|-
! $42
| [[DMA#General DMA|GDMA Source Address High]]
| style="text-align: right" | <tt style="white-space: nowrap">.... hhhh</tt>
| RW8
| Linear address, high 4 bits (h)
|-
! $44
| [[DMA#General DMA|GDMA Destination Address]]
| style="text-align: right" | <tt style="white-space: nowrap">aaaa aaaa aaaa aaaa</tt>
| RW16
| IRAM address (a)
|-
! $46
| [[DMA#General DMA|GDMA Length]]
| style="text-align: right" | <tt style="white-space: nowrap">bbbb bbbb bbbb bbbb</tt>
| RW16
| Bytes (b)
|-
! $48
| [[DMA#General DMA|GDMA Control]]
| style="text-align: right" | <tt style="white-space: nowrap">ed.. ....</tt>
| RW8
| Enable (e), Decrement (d)
|-
! $4A
| [[DMA#Sound DMA|SDMA Source Address Low]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll llll llll</tt>
| RW16
| Linear address, low 16 bits (l)
|-
! $4C
| [[DMA#Sound DMA|SDMA Source Address High]]
| style="text-align: right" | <tt style="white-space: nowrap">.... hhhh</tt>
| RW8
| Linear address, high 4 bits (h)
|-
! $4E
| [[DMA#Sound DMA|SDMA Length Low]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll llll llll</tt>
| RW16
| Length, low 16 bits (l)
|-
! $50
| [[DMA#Sound DMA|SDMA Length High]]
| style="text-align: right" | <tt style="white-space: nowrap">.... hhhh</tt>
| RW8
| Length, high 4 bits (h)
|-
! $52
| [[DMA#Sound DMA|SDMA Control]]
| style="text-align: right" | <tt style="white-space: nowrap">ed.t r?ff</tt>
| RW8
| Enable (e), Decrement (d), Target (t),
Repeat (r), Frequency (f)
|-
! rowspan="2" | [[SoC]]<sup>(color)</sup>
! $60
| [[SoC#System Control 2|System Control 2]]
| style="text-align: right" | <tt style="white-space: nowrap">c4C. ?.??</tt>
| RW8
| Color (c), 4BPP (4), Chunky (C)
|-
! $62
| [[SoC#System Control 3|System Control 3]]
| style="text-align: right" | <tt style="white-space: nowrap">S... ...p</tt>
| RW8
| SwanCrystal (S), Power off (p)
|-
! rowspan="5" | [[Hyper Voice]]<sup>(color)</sup>
! $64
| [[Hyper Voice#Hyper Voice Output|Hyper Voice Left Output]]
| style="text-align: right" | <tt style="white-space: nowrap">ssss ssss ssss ssss</tt>
| W16
| Raw sample (s)
|-
! $66
| [[Hyper Voice#Hyper Voice Output|Hyper Voice Right Output]]
| style="text-align: right" | <tt style="white-space: nowrap">ssss ssss ssss ssss</tt>
| W16
| Raw sample (s)
|-
! $68
| [[Hyper Voice#Hyper Voice Input|Hyper Voice Left Input]]
| style="text-align: right" | <tt style="white-space: nowrap">ssss ssss</tt>
| W8
| Sample (s)
|-
! $69
| [[Hyper Voice#Hyper Voice Input|Hyper Voice Right Input]]
| style="text-align: right" | <tt style="white-space: nowrap">ssss ssss</tt>
| W8
| Sample (s)
|-
! $6A
| [[Hyper Voice#Hyper Voice Control|Hyper Voice Control]]
| style="text-align: right" | <tt style="white-space: nowrap">.mmc ???? errr ffss</tt>
| RW16
| Mask (m), Channel reset (c), Enable (e),
Rate (r), Format (f), Shift (s)
|-
! rowspan="8" | [[Display]]<sup>(SC)</sup>
! $70
| LCD Timing Configuration 1?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $71
| LCD Timing Configuration 2?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $72
| LCD Timing Configuration 3?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $73
| LCD Timing Configuration 4?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $74
| LCD Timing Configuration 5?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $75
| LCD Timing Configuration 6?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $76
| LCD Timing Configuration 7?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $77
| LCD Timing Configuration 8?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! rowspan="21" | [[Sound]]
! $80
| [[Sound#Sound Channel Frequency|Sound Channel 1 Frequency]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .ddd dddd dddd</tt>
| RW16
| Divider (d)
|-
! $82
| [[Sound#Sound Channel Frequency|Sound Channel 2 Frequency]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .ddd dddd dddd</tt>
| RW16
| Divider (d)
|-
! $84
| [[Sound#Sound Channel Frequency|Sound Channel 3 Frequency]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .ddd dddd dddd</tt>
| RW16
| Divider (d)
|-
! $86
| [[Sound#Sound Channel Frequency|Sound Channel 4 Frequency]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .ddd dddd dddd</tt>
| RW16
| Divider (d)
|-
! $88
| [[Sound#Sound Channel Volume|Sound Channel 1 Volume]]
| style="text-align: right" | <tt style="white-space: nowrap">llll rrrr</tt>
| RW8
| Left (l), Right (r)
|-
! rowspan="2" | $89
| [[Sound#Sound Channel Volume|Sound Channel 2 Volume]]
| style="text-align: right" | <tt style="white-space: nowrap">llll rrrr</tt>
| RW8
| Left (l), Right (r)
|-
| [[Sound#Sound Channel 2 Voice Sample|Sound Channel 2 Voice Sample]]
| style="text-align: right" | <tt style="white-space: nowrap">ssss ssss</tt>
| RW8
| Sample (s)
|-
! $8A
| [[Sound#Sound Channel Volume|Sound Channel 3 Volume]]
| style="text-align: right" | <tt style="white-space: nowrap">llll rrrr</tt>
| RW8
| Left (l), Right (r)
|-
! $8B
| [[Sound#Sound Channel Volume|Sound Channel 4 Volume]]
| style="text-align: right" | <tt style="white-space: nowrap">llll rrrr</tt>
| RW8
| Left (l), Right (r)
|-
! $8C
| [[Sound#Sound Channel 3 Sweep Amount|Sound Channel 3 Sweep Amount]]
| style="text-align: right" | <tt style="white-space: nowrap">vvvv vvvv</tt>
| RW8
| Value (v)
|-
! $8D
| [[Sound#Sound Channel 3 Sweep Ticks|Sound Channel 3 Sweep Ticks]]
| style="text-align: right" | <tt style="white-space: nowrap">...t tttt</tt>
| RW8
| Ticks (t)
|-
! $8E
| [[Sound#Sound Channel 4 Noise Control|Sound Channel 4 Noise Control]]
| style="text-align: right" | <tt style="white-space: nowrap">...e rttt</tt>
| RW8
| Enable (e), Reset (r), Tap (t)
|-
! $8F
| [[Sound#Sound Wavetable Address|Sound Wavetable Address]]
| style="text-align: right" | <tt style="white-space: nowrap">wwww wwww</tt>
| RW8
| Address >> 6 (w)
|-
! $90
| [[Sound#Sound Channel Control|Sound Channel Control]]
| style="text-align: right" | <tt style="white-space: nowrap">nsv. 4321</tt>
| RW8
| Channel enable (1234)
Noise (n), Sweep (s), Voice (v)
|-
! $91
| [[Sound#Sound Output Control|Sound Output Control]]
| style="text-align: right" | <tt style="white-space: nowrap">H... hrrs</tt>
| RW8
| Headphones connected (H)
Headphone output (h)
Speaker output (s), range (r)
|-
! $92
| [[Sound#Sound Channel 4 LFSR Register|Sound Channel 4 LFSR Register]]
| style="text-align: right" | <tt style="white-space: nowrap">.rrr rrrr rrrr rrrr</tt>
| R16
| PRNG state (r)
|-
! $94
| [[Sound#Sound Channel 2 Voice Volume|Sound Channel 2 Voice Volume]]
| style="text-align: right" | <tt style="white-space: nowrap">.... lLrR</tt>
| RW8
| Left Half (l), Full (L)
Right Half (r), Full (R)
|-
! $96
| Sound Channel Output Right
| style="text-align: right" | <tt style="white-space: nowrap">.... ..ss ssss ssss</tt>
| R16
| Sample (s)
|-
! $98
| Sound Channel Output Left
| style="text-align: right" | <tt style="white-space: nowrap">.... ..ss ssss ssss</tt>
| R16
| Sample (s)
|-
! $9A
| Sound Channel Output Sum
| style="text-align: right" | <tt style="white-space: nowrap">.... .sss ssss ssss</tt>
| R16
| Sample (s)
|-
! $9E
| Sound Speaker Master Volume<sup>(color)</sup>
| style="text-align: right" | <tt style="white-space: nowrap">.... ..vv</tt>
| R8
| ?
|-
! [[SoC]]
! $A0
| [[SoC#System Control|System Control]]
| style="text-align: right" | <tt style="white-space: nowrap">t??? swcl</tt>
| RW8
| Test OK (t), ROM speed (s), ROM width (w),
Color system (c), Boot ROM lockout (l)
|-
! rowspan="5" | [[Timers]]
! $A2
| [[Timers#Timer Control|Timer Control]]
| style="text-align: right" | <tt style="white-space: nowrap">.... VvHh</tt>
| RW8
| Horizontal enable (h), auto reload (H)
Vertical enable (v), auto reload (V)
|-
! $A4
| [[Timers#Timer Reload|Horizontal Blank Timer Reload]]
| style="text-align: right" | <tt style="white-space: nowrap">tttt tttt tttt tttt</tt>
| RW16
| Ticks (t)
|-
! $A6
| [[Timers#Timer Reload|Vertical Blank Timer Reload]]
| style="text-align: right" | <tt style="white-space: nowrap">tttt tttt tttt tttt</tt>
| RW16
| Ticks (t)
|-
! $A8
| [[Timers#Timer Counter|Horizontal Blank Timer Counter]]
| style="text-align: right" | <tt style="white-space: nowrap">tttt tttt tttt tttt</tt>
| R16
| Ticks (t)
|-
! $AA
| [[Timers#Timer Counter|Vertical Blank Timer Counter]]
| style="text-align: right" | <tt style="white-space: nowrap">tttt tttt tttt tttt</tt>
| R16
| Ticks (t)
|-
! [[Interrupts]]
! $B0
| [[Interrupts#Interrupt Vector|Interrupt Vector]]
| style="text-align: right" | <tt style="white-space: nowrap">VVVV V...</tt>
| RW8
| Vector offset (v)
|-
! rowspan="2" | [[UART]]
! $B1
| [[UART#Serial Receive Data|Serial Receive Data]]
| style="text-align: right" | <tt style="white-space: nowrap">dddd dddd</tt>
| R8
| Receive buffer data (d)
|-
! $B1
| [[UART#Serial Transmit Data|Serial Transmit Data]]
| style="text-align: right" | <tt style="white-space: nowrap">dddd dddd</tt>
| W8
| Transmit buffer data (d)
|-
! [[Interrupts]]
! $B2
| [[Interrupts#Interrupt Enable|Interrupt Enable]]
| iiii iiii
| RW8
| Interrupt index (i)
|-
! rowspan="2" | [[UART]]
! $B3
| [[UART#Serial Status|Serial Status]]
| style="text-align: right" | <tt style="white-space: nowrap">eb.. .tor</tt>
| R8
| Enable (e), Baud rate (b),
Transfer ready (t), Overrun (o), Receive ready (r)
|-
! $B3
| [[UART#Serial Control|Serial Control]]
| style="text-align: right" | <tt style="white-space: nowrap">ebO. ....</tt>
| W8
| Enable (e), Baud rate (b), Reset Overrun (O)
|-
! [[Interrupts]]
! $B4
| [[Interrupts#Interrupt Status|Interrupt Status]]
| iiii iiii
| R8
| Interrupt index (i)
|-
! [[Keypad]]
! $B5
| [[Keypad|Keypad Scan]]
| style="text-align: right" | <tt style="white-space: nowrap">.iii oooo</tt>
| RW8
| Input row (i), Output column (o)
|-
! rowspan="2" | [[Interrupts]]
! $B6
| [[Interrupts#Interrupt Acknowledge|Interrupt Acknowledge]]
| iiii iiii
| R8?
| Interrupt index (i)
|-
! $B7
| [[Interrupts#Interrupt NMI Control|Interrupt NMI Control]]
| style="text-align: right" | <tt style="white-space: nowrap">...b ....</tt>
| RW8
| Low battery (b)
|-
! rowspan="4" | [[EEPROM|Internal EEPROM]]
! $BA
| [[EEPROM#Internal EEPROM Data|Internal EEPROM Data]]
| style="text-align: right" | <tt style="white-space: nowrap">dddd dddd dddd dddd</tt>
| RW16
| Data (d)
|-
! $BC
| [[EEPROM#Internal EEPROM Command|Internal EEPROM Command]]
|
| RW16
|
|-
! rowspan="2" | $BE
| [[EEPROM#Internal EEPROM Status|Internal EEPROM Status]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .... p... ..RD</tt>
| R16
| Protected (p), Ready (R), Done (D)
|-
| [[EEPROM#Internal EEPROM Control|Internal EEPROM Control]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .... pewr ....</tt>
| W16
| Protect (p), Erase (e), Write (w), Read (r)
|-
! [[Mapper|Cartridge]]
! $C0<br />
$FF
| Cartridge I/O
|
| RW8
| Forwarded by the SoC
|}
== I/O port routing ==
The [[NEC V30MZ]] supports 16-bit I/O port addresses. The WonderSwan SoC routes them using the following algorithm:
* If an address is between <code>$00B8</code> and <code>$00BF</code> inclusive, it is routed to the internal EEPROM control block.
* If an address is between <code>$00C0</code> and <code>$00FF</code> inclusive, it is routed to the cartride bus.
* If an address's bits <code>0</code> through <code>8</code> inclusive are between <code>$000</code> and <code>$0B7</code> inclusive, they are routed to the SoC block.
* If none of these conditions are reached, open bus is read.
On the monochrome models, as well as color models in mono emulation, open bus is always <code>0x90</code>.
b2fb5d5e6f07ac069bae8c9fe2c9bb64d76f43ff
217
215
2023-08-29T14:18:39Z
Asie
351
add mystery port at $AC
wikitext
text/x-wiki
The WonderSwan SoC has three general blocks of I/O port accesses:
{| class="wikitable"
! From !! To !! Holder !! Width
|-
| $00 || $B7 || WonderSwan SoC || 8/16-bit
|-
| $B8 || $BF || Internal EEPROM control || 16-bit
|-
| $C0 || $FF || Cartridge bus || 8-bit
|}
With the exception of internal EEPROM on the ASWAN, all unaligned 16-bit accesses can be converted to two 8-bit accesses with a 1-cycle penalty.
== I/O port map ==
* Superscripts are used to mark ports specific to a given mode or platform:
** Color mode: <sup>(color)</sup>. Such ports are only accessible when color mode is enabled through port <code>$60</code>.
** WS/WSC/SC console: <sup>(WS)</sup>, <sup>(WSC)</sup>, <sup>(SC)</sup>.
* If two Bits rows are provided, the second one refers to the "Color" mode.
* The Type can be: R - readable, W - writable, L - writable before boot ROM lockout, 8/16 - width (byte/word).
{| class="wikitable"
! Category
! Port
! Description
! Bits
! Type
! Notes
|-
! rowspan="45" | [[Display]]
! $00
| [[Display#Display Control|Display Control]]
| style="text-align: right" | <tt style="white-space: nowrap">..ow Ws21</tt>
| RW8
|
|-
! $01
| [[Display#Display Background|Display Background]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .sss</tt>
<tt style="white-space: nowrap">pppp iiii</tt>
| RW8
| Shade (s)
Palette (p), Index (i)
|-
! $02
| [[Display#Current Line|Display Current Line]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll</tt>
| R8
| Line (l)
|-
! $03
| [[Display#Interrupt Line|Display Interrupt Line]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll</tt>
| RW8
| Line (l)
|-
! $04
| [[Display#Sprite Table Address|Sprite Table Address]]
| style="text-align: right" | <tt style="white-space: nowrap">...a aaaa</tt>
<tt style="white-space: nowrap">..aa aaaa</tt>
| RW8
| Address >> 9 (a)
|-
! $05
| [[Display#Sprite Table First|Sprite Table First]]
| style="text-align: right" | <tt style="white-space: nowrap">.iii iiii</tt>
| RW8
| Index (i)
|-
! $06
| [[Display#Sprite Table Count|Sprite Table Count]]
| style="text-align: right" | <tt style="white-space: nowrap">cccc cccc</tt>
| RW8
| Count (c)
|-
! $07
| [[Display#Screen Address|Screen Address]]
| style="text-align: right" | <tt style="white-space: nowrap">.222 .111</tt>
<tt style="white-space: nowrap">2222 1111</tt>
| RW8
| Screen 1 address >> 11 (1)
Screen 2 address >> 11 (2)
|-
! $08
| [[Display#Screen 2 Window|Screen 2 Window Left]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $09
| [[Display#Screen 2 Window|Screen 2 Window Top]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $0A
| [[Display#Screen 2 Window|Screen 2 Window Right]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $0B
| [[Display#Screen 2 Window|Screen 2 Window Bottom]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $0B
| [[Display#Sprite Window|Sprite Window Left]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $0C
| [[Display#Sprite Window|Sprite Window Top]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $0E
| [[Display#Sprite Window|Sprite Window Right]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $0F
| [[Display#Sprite Window|Sprite Window Bottom]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $10
| [[Display#Screen Scroll|Screen 1 Scroll X]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $11
| [[Display#Screen Scroll|Screen 1 Scroll Y]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $12
| [[Display#Screen Scroll|Screen 2 Scroll X]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $13
| [[Display#Screen Scroll|Screen 2 Scroll Y]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $14
| [[Display#LCD Control|LCD Control]]
| style="text-align: right" | <tt style="white-space: nowrap">.... ..Ce</tt>
| RW8
| Contrast (C)<sup>(WSC)</sup>, Enable (e)
|-
! $15
| [[Display#LCD Icon Control|LCD Icon Control]]
| style="text-align: right" | <tt style="white-space: nowrap">..32 1hvs</tt>
| RW8
| Auxillary 3 (3), Auxillary 2 (2), Auxillary 1 (1),
Horizontal (h), Vertical (v), Sleep (s)
|-
! $16
| [[Display#LCD Final Line|LCD Final Line]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll</tt>
| RW8
| Line (l)
|-
! $17
| [[Display#LCD Back Porch Line|LCD Back Porch Line]]<sup>(WSC)</sup>
| style="text-align: right" | <tt style="white-space: nowrap">llll llll</tt>
| RW8
| Line (l)
|-
! $1A
| [[Display#LCD Status|LCD Status]]
| style="text-align: right" | <tt style="white-space: nowrap">...v vv.s</tt>
| RW8
| Volume segment status (v), Sleep (s)
|-
! $1C
| [[Display#LCD Mono Shade LUT|LCD Mono Shade LUT 0/1]]
| style="text-align: right" | <tt style="white-space: nowrap">1111 0000</tt>
| RW8
| Shade index
|-
! $1D
| [[Display#LCD Mono Shade LUT|LCD Mono Shade LUT 2/3]]
| style="text-align: right" | <tt style="white-space: nowrap">3333 2222</tt>
| RW8
| Shade index
|-
! $1E
| [[Display#LCD Mono Shade LUT|LCD Mono Shade LUT 4/5]]
| style="text-align: right" | <tt style="white-space: nowrap">5555 4444</tt>
| RW8
| Shade index
|-
! $1F
| [[Display#LCD Mono Shade LUT|LCD Mono Shade LUT 6/7]]
| style="text-align: right" | <tt style="white-space: nowrap">7777 6666</tt>
| RW8
| Shade index
|-
! $20
| [[Display#LCD Mono Palette|LCD Mono Palette 0]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $22
| [[Display#LCD Mono Palette|LCD Mono Palette 1]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $24
| [[Display#LCD Mono Palette|LCD Mono Palette 2]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $26
| [[Display#LCD Mono Palette|LCD Mono Palette 3]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $28
| [[Display#LCD Mono Palette|LCD Mono Palette 4]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $2A
| [[Display#LCD Mono Palette|LCD Mono Palette 5]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $2C
| [[Display#LCD Mono Palette|LCD Mono Palette 6]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $2E
| [[Display#LCD Mono Palette|LCD Mono Palette 7]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $30
| [[Display#LCD Mono Palette|LCD Mono Palette 8]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $32
| [[Display#LCD Mono Palette|LCD Mono Palette 9]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $34
| [[Display#LCD Mono Palette|LCD Mono Palette 10]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $36
| [[Display#LCD Mono Palette|LCD Mono Palette 11]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $38
| [[Display#LCD Mono Palette|LCD Mono Palette 12]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $3A
| [[Display#LCD Mono Palette|LCD Mono Palette 13]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $3C
| [[Display#LCD Mono Palette|LCD Mono Palette 14]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $3E
| [[Display#LCD Mono Palette|LCD Mono Palette 15]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! rowspan="10" | [[DMA]]<sup>(color)</sup>
! $40
| [[DMA#General DMA|GDMA Source Address Low]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll llll llll</tt>
| RW16
| Linear address, low 16 bits (l)
|-
! $42
| [[DMA#General DMA|GDMA Source Address High]]
| style="text-align: right" | <tt style="white-space: nowrap">.... hhhh</tt>
| RW8
| Linear address, high 4 bits (h)
|-
! $44
| [[DMA#General DMA|GDMA Destination Address]]
| style="text-align: right" | <tt style="white-space: nowrap">aaaa aaaa aaaa aaaa</tt>
| RW16
| IRAM address (a)
|-
! $46
| [[DMA#General DMA|GDMA Length]]
| style="text-align: right" | <tt style="white-space: nowrap">bbbb bbbb bbbb bbbb</tt>
| RW16
| Bytes (b)
|-
! $48
| [[DMA#General DMA|GDMA Control]]
| style="text-align: right" | <tt style="white-space: nowrap">ed.. ....</tt>
| RW8
| Enable (e), Decrement (d)
|-
! $4A
| [[DMA#Sound DMA|SDMA Source Address Low]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll llll llll</tt>
| RW16
| Linear address, low 16 bits (l)
|-
! $4C
| [[DMA#Sound DMA|SDMA Source Address High]]
| style="text-align: right" | <tt style="white-space: nowrap">.... hhhh</tt>
| RW8
| Linear address, high 4 bits (h)
|-
! $4E
| [[DMA#Sound DMA|SDMA Length Low]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll llll llll</tt>
| RW16
| Length, low 16 bits (l)
|-
! $50
| [[DMA#Sound DMA|SDMA Length High]]
| style="text-align: right" | <tt style="white-space: nowrap">.... hhhh</tt>
| RW8
| Length, high 4 bits (h)
|-
! $52
| [[DMA#Sound DMA|SDMA Control]]
| style="text-align: right" | <tt style="white-space: nowrap">ed.t r?ff</tt>
| RW8
| Enable (e), Decrement (d), Target (t),
Repeat (r), Frequency (f)
|-
! rowspan="2" | [[SoC]]<sup>(color)</sup>
! $60
| [[SoC#System Control 2|System Control 2]]
| style="text-align: right" | <tt style="white-space: nowrap">c4C. ?.??</tt>
| RW8
| Color (c), 4BPP (4), Chunky (C)
|-
! $62
| [[SoC#System Control 3|System Control 3]]
| style="text-align: right" | <tt style="white-space: nowrap">S... ...p</tt>
| RW8
| SwanCrystal (S), Power off (p)
|-
! rowspan="5" | [[Hyper Voice]]<sup>(color)</sup>
! $64
| [[Hyper Voice#Hyper Voice Output|Hyper Voice Left Output]]
| style="text-align: right" | <tt style="white-space: nowrap">ssss ssss ssss ssss</tt>
| W16
| Raw sample (s)
|-
! $66
| [[Hyper Voice#Hyper Voice Output|Hyper Voice Right Output]]
| style="text-align: right" | <tt style="white-space: nowrap">ssss ssss ssss ssss</tt>
| W16
| Raw sample (s)
|-
! $68
| [[Hyper Voice#Hyper Voice Input|Hyper Voice Left Input]]
| style="text-align: right" | <tt style="white-space: nowrap">ssss ssss</tt>
| W8
| Sample (s)
|-
! $69
| [[Hyper Voice#Hyper Voice Input|Hyper Voice Right Input]]
| style="text-align: right" | <tt style="white-space: nowrap">ssss ssss</tt>
| W8
| Sample (s)
|-
! $6A
| [[Hyper Voice#Hyper Voice Control|Hyper Voice Control]]
| style="text-align: right" | <tt style="white-space: nowrap">.mmc ???? errr ffss</tt>
| RW16
| Mask (m), Channel reset (c), Enable (e),
Rate (r), Format (f), Shift (s)
|-
! rowspan="8" | [[Display]]<sup>(SC)</sup>
! $70
| LCD Timing Configuration 1?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $71
| LCD Timing Configuration 2?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $72
| LCD Timing Configuration 3?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $73
| LCD Timing Configuration 4?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $74
| LCD Timing Configuration 5?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $75
| LCD Timing Configuration 6?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $76
| LCD Timing Configuration 7?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $77
| LCD Timing Configuration 8?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! rowspan="21" | [[Sound]]
! $80
| [[Sound#Sound Channel Frequency|Sound Channel 1 Frequency]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .ddd dddd dddd</tt>
| RW16
| Divider (d)
|-
! $82
| [[Sound#Sound Channel Frequency|Sound Channel 2 Frequency]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .ddd dddd dddd</tt>
| RW16
| Divider (d)
|-
! $84
| [[Sound#Sound Channel Frequency|Sound Channel 3 Frequency]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .ddd dddd dddd</tt>
| RW16
| Divider (d)
|-
! $86
| [[Sound#Sound Channel Frequency|Sound Channel 4 Frequency]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .ddd dddd dddd</tt>
| RW16
| Divider (d)
|-
! $88
| [[Sound#Sound Channel Volume|Sound Channel 1 Volume]]
| style="text-align: right" | <tt style="white-space: nowrap">llll rrrr</tt>
| RW8
| Left (l), Right (r)
|-
! rowspan="2" | $89
| [[Sound#Sound Channel Volume|Sound Channel 2 Volume]]
| style="text-align: right" | <tt style="white-space: nowrap">llll rrrr</tt>
| RW8
| Left (l), Right (r)
|-
| [[Sound#Sound Channel 2 Voice Sample|Sound Channel 2 Voice Sample]]
| style="text-align: right" | <tt style="white-space: nowrap">ssss ssss</tt>
| RW8
| Sample (s)
|-
! $8A
| [[Sound#Sound Channel Volume|Sound Channel 3 Volume]]
| style="text-align: right" | <tt style="white-space: nowrap">llll rrrr</tt>
| RW8
| Left (l), Right (r)
|-
! $8B
| [[Sound#Sound Channel Volume|Sound Channel 4 Volume]]
| style="text-align: right" | <tt style="white-space: nowrap">llll rrrr</tt>
| RW8
| Left (l), Right (r)
|-
! $8C
| [[Sound#Sound Channel 3 Sweep Amount|Sound Channel 3 Sweep Amount]]
| style="text-align: right" | <tt style="white-space: nowrap">vvvv vvvv</tt>
| RW8
| Value (v)
|-
! $8D
| [[Sound#Sound Channel 3 Sweep Ticks|Sound Channel 3 Sweep Ticks]]
| style="text-align: right" | <tt style="white-space: nowrap">...t tttt</tt>
| RW8
| Ticks (t)
|-
! $8E
| [[Sound#Sound Channel 4 Noise Control|Sound Channel 4 Noise Control]]
| style="text-align: right" | <tt style="white-space: nowrap">...e rttt</tt>
| RW8
| Enable (e), Reset (r), Tap (t)
|-
! $8F
| [[Sound#Sound Wavetable Address|Sound Wavetable Address]]
| style="text-align: right" | <tt style="white-space: nowrap">wwww wwww</tt>
| RW8
| Address >> 6 (w)
|-
! $90
| [[Sound#Sound Channel Control|Sound Channel Control]]
| style="text-align: right" | <tt style="white-space: nowrap">nsv. 4321</tt>
| RW8
| Channel enable (1234)
Noise (n), Sweep (s), Voice (v)
|-
! $91
| [[Sound#Sound Output Control|Sound Output Control]]
| style="text-align: right" | <tt style="white-space: nowrap">H... hrrs</tt>
| RW8
| Headphones connected (H)
Headphone output (h)
Speaker output (s), range (r)
|-
! $92
| [[Sound#Sound Channel 4 LFSR Register|Sound Channel 4 LFSR Register]]
| style="text-align: right" | <tt style="white-space: nowrap">.rrr rrrr rrrr rrrr</tt>
| R16
| PRNG state (r)
|-
! $94
| [[Sound#Sound Channel 2 Voice Volume|Sound Channel 2 Voice Volume]]
| style="text-align: right" | <tt style="white-space: nowrap">.... lLrR</tt>
| RW8
| Left Half (l), Full (L)
Right Half (r), Full (R)
|-
! $96
| Sound Channel Output Right
| style="text-align: right" | <tt style="white-space: nowrap">.... ..ss ssss ssss</tt>
| R16
| Sample (s)
|-
! $98
| Sound Channel Output Left
| style="text-align: right" | <tt style="white-space: nowrap">.... ..ss ssss ssss</tt>
| R16
| Sample (s)
|-
! $9A
| Sound Channel Output Sum
| style="text-align: right" | <tt style="white-space: nowrap">.... .sss ssss ssss</tt>
| R16
| Sample (s)
|-
! $9E
| Sound Speaker Master Volume<sup>(color)</sup>
| style="text-align: right" | <tt style="white-space: nowrap">.... ..vv</tt>
| R8
| ?
|-
! [[SoC]]
! $A0
| [[SoC#System Control|System Control]]
| style="text-align: right" | <tt style="white-space: nowrap">t??? swcl</tt>
| RW8
| Test OK (t), ROM speed (s), ROM width (w),
Color system (c), Boot ROM lockout (l)
|-
! rowspan="5" | [[Timers]]
! $A2
| [[Timers#Timer Control|Timer Control]]
| style="text-align: right" | <tt style="white-space: nowrap">.... VvHh</tt>
| RW8
| Horizontal enable (h), auto reload (H)
Vertical enable (v), auto reload (V)
|-
! $A4
| [[Timers#Timer Reload|Horizontal Blank Timer Reload]]
| style="text-align: right" | <tt style="white-space: nowrap">tttt tttt tttt tttt</tt>
| RW16
| Ticks (t)
|-
! $A6
| [[Timers#Timer Reload|Vertical Blank Timer Reload]]
| style="text-align: right" | <tt style="white-space: nowrap">tttt tttt tttt tttt</tt>
| RW16
| Ticks (t)
|-
! $A8
| [[Timers#Timer Counter|Horizontal Blank Timer Counter]]
| style="text-align: right" | <tt style="white-space: nowrap">tttt tttt tttt tttt</tt>
| R16
| Ticks (t)
|-
! $AA
| [[Timers#Timer Counter|Vertical Blank Timer Counter]]
| style="text-align: right" | <tt style="white-space: nowrap">tttt tttt tttt tttt</tt>
| R16
| Ticks (t)
|-
! ?
! $AC
| ?
| style="text-align: right" | <tt style="white-space: nowrap">.... ...p</tt>
| W8?
| Power off (p)
|-
! [[Interrupts]]
! $B0
| [[Interrupts#Interrupt Vector|Interrupt Vector]]
| style="text-align: right" | <tt style="white-space: nowrap">VVVV V...</tt>
| RW8
| Vector offset (v)
|-
! rowspan="2" | [[UART]]
! $B1
| [[UART#Serial Receive Data|Serial Receive Data]]
| style="text-align: right" | <tt style="white-space: nowrap">dddd dddd</tt>
| R8
| Receive buffer data (d)
|-
! $B1
| [[UART#Serial Transmit Data|Serial Transmit Data]]
| style="text-align: right" | <tt style="white-space: nowrap">dddd dddd</tt>
| W8
| Transmit buffer data (d)
|-
! [[Interrupts]]
! $B2
| [[Interrupts#Interrupt Enable|Interrupt Enable]]
| iiii iiii
| RW8
| Interrupt index (i)
|-
! rowspan="2" | [[UART]]
! $B3
| [[UART#Serial Status|Serial Status]]
| style="text-align: right" | <tt style="white-space: nowrap">eb.. .tor</tt>
| R8
| Enable (e), Baud rate (b),
Transfer ready (t), Overrun (o), Receive ready (r)
|-
! $B3
| [[UART#Serial Control|Serial Control]]
| style="text-align: right" | <tt style="white-space: nowrap">ebO. ....</tt>
| W8
| Enable (e), Baud rate (b), Reset Overrun (O)
|-
! [[Interrupts]]
! $B4
| [[Interrupts#Interrupt Status|Interrupt Status]]
| iiii iiii
| R8
| Interrupt index (i)
|-
! [[Keypad]]
! $B5
| [[Keypad|Keypad Scan]]
| style="text-align: right" | <tt style="white-space: nowrap">.iii oooo</tt>
| RW8
| Input row (i), Output column (o)
|-
! rowspan="2" | [[Interrupts]]
! $B6
| [[Interrupts#Interrupt Acknowledge|Interrupt Acknowledge]]
| iiii iiii
| R8?
| Interrupt index (i)
|-
! $B7
| [[Interrupts#Interrupt NMI Control|Interrupt NMI Control]]
| style="text-align: right" | <tt style="white-space: nowrap">...b ....</tt>
| RW8
| Low battery (b)
|-
! rowspan="4" | [[EEPROM|Internal EEPROM]]
! $BA
| [[EEPROM#Internal EEPROM Data|Internal EEPROM Data]]
| style="text-align: right" | <tt style="white-space: nowrap">dddd dddd dddd dddd</tt>
| RW16
| Data (d)
|-
! $BC
| [[EEPROM#Internal EEPROM Command|Internal EEPROM Command]]
|
| RW16
|
|-
! rowspan="2" | $BE
| [[EEPROM#Internal EEPROM Status|Internal EEPROM Status]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .... p... ..RD</tt>
| R16
| Protected (p), Ready (R), Done (D)
|-
| [[EEPROM#Internal EEPROM Control|Internal EEPROM Control]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .... pewr ....</tt>
| W16
| Protect (p), Erase (e), Write (w), Read (r)
|-
! [[Mapper|Cartridge]]
! $C0<br />
$FF
| Cartridge I/O
|
| RW8
| Forwarded by the SoC
|}
== I/O port routing ==
The [[NEC V30MZ]] supports 16-bit I/O port addresses. The WonderSwan SoC routes them using the following algorithm:
* If an address is between <code>$00B8</code> and <code>$00BF</code> inclusive, it is routed to the internal EEPROM control block.
* If an address is between <code>$00C0</code> and <code>$00FF</code> inclusive, it is routed to the cartride bus.
* If an address's bits <code>0</code> through <code>8</code> inclusive are between <code>$000</code> and <code>$0B7</code> inclusive, they are routed to the SoC block.
* If none of these conditions are reached, open bus is read.
On the monochrome models, as well as color models in mono emulation, open bus is always <code>0x90</code>.
026be14a9d45a27822e2a28fb7296b5dfeef5a8e
219
217
2023-08-29T21:05:57Z
Asie
351
improve $B0 documentation
wikitext
text/x-wiki
The WonderSwan SoC has three general blocks of I/O port accesses:
{| class="wikitable"
! From !! To !! Holder !! Width
|-
| $00 || $B7 || WonderSwan SoC || 8/16-bit
|-
| $B8 || $BF || Internal EEPROM control || 16-bit
|-
| $C0 || $FF || Cartridge bus || 8-bit
|}
With the exception of internal EEPROM on the ASWAN, all unaligned 16-bit accesses can be converted to two 8-bit accesses with a 1-cycle penalty.
== I/O port map ==
* Superscripts are used to mark ports specific to a given mode or platform:
** Color mode: <sup>(color)</sup>. Such ports are only accessible when color mode is enabled through port <code>$60</code>.
** WS/WSC/SC console: <sup>(WS)</sup>, <sup>(WSC)</sup>, <sup>(SC)</sup>.
* If two Bits rows are provided, the second one refers to the "Color" mode.
* The Type can be: R - readable, W - writable, L - writable before boot ROM lockout, 8/16 - width (byte/word).
{| class="wikitable"
! Category
! Port
! Description
! Bits
! Type
! Notes
|-
! rowspan="45" | [[Display]]
! $00
| [[Display#Display Control|Display Control]]
| style="text-align: right" | <tt style="white-space: nowrap">..ow Ws21</tt>
| RW8
|
|-
! $01
| [[Display#Display Background|Display Background]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .sss</tt>
<tt style="white-space: nowrap">pppp iiii</tt>
| RW8
| Shade (s)
Palette (p), Index (i)
|-
! $02
| [[Display#Current Line|Display Current Line]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll</tt>
| R8
| Line (l)
|-
! $03
| [[Display#Interrupt Line|Display Interrupt Line]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll</tt>
| RW8
| Line (l)
|-
! $04
| [[Display#Sprite Table Address|Sprite Table Address]]
| style="text-align: right" | <tt style="white-space: nowrap">...a aaaa</tt>
<tt style="white-space: nowrap">..aa aaaa</tt>
| RW8
| Address >> 9 (a)
|-
! $05
| [[Display#Sprite Table First|Sprite Table First]]
| style="text-align: right" | <tt style="white-space: nowrap">.iii iiii</tt>
| RW8
| Index (i)
|-
! $06
| [[Display#Sprite Table Count|Sprite Table Count]]
| style="text-align: right" | <tt style="white-space: nowrap">cccc cccc</tt>
| RW8
| Count (c)
|-
! $07
| [[Display#Screen Address|Screen Address]]
| style="text-align: right" | <tt style="white-space: nowrap">.222 .111</tt>
<tt style="white-space: nowrap">2222 1111</tt>
| RW8
| Screen 1 address >> 11 (1)
Screen 2 address >> 11 (2)
|-
! $08
| [[Display#Screen 2 Window|Screen 2 Window Left]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $09
| [[Display#Screen 2 Window|Screen 2 Window Top]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $0A
| [[Display#Screen 2 Window|Screen 2 Window Right]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $0B
| [[Display#Screen 2 Window|Screen 2 Window Bottom]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $0B
| [[Display#Sprite Window|Sprite Window Left]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $0C
| [[Display#Sprite Window|Sprite Window Top]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $0E
| [[Display#Sprite Window|Sprite Window Right]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $0F
| [[Display#Sprite Window|Sprite Window Bottom]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $10
| [[Display#Screen Scroll|Screen 1 Scroll X]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $11
| [[Display#Screen Scroll|Screen 1 Scroll Y]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $12
| [[Display#Screen Scroll|Screen 2 Scroll X]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $13
| [[Display#Screen Scroll|Screen 2 Scroll Y]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $14
| [[Display#LCD Control|LCD Control]]
| style="text-align: right" | <tt style="white-space: nowrap">.... ..Ce</tt>
| RW8
| Contrast (C)<sup>(WSC)</sup>, Enable (e)
|-
! $15
| [[Display#LCD Icon Control|LCD Icon Control]]
| style="text-align: right" | <tt style="white-space: nowrap">..32 1hvs</tt>
| RW8
| Auxillary 3 (3), Auxillary 2 (2), Auxillary 1 (1),
Horizontal (h), Vertical (v), Sleep (s)
|-
! $16
| [[Display#LCD Final Line|LCD Final Line]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll</tt>
| RW8
| Line (l)
|-
! $17
| [[Display#LCD Back Porch Line|LCD Back Porch Line]]<sup>(WSC)</sup>
| style="text-align: right" | <tt style="white-space: nowrap">llll llll</tt>
| RW8
| Line (l)
|-
! $1A
| [[Display#LCD Status|LCD Status]]
| style="text-align: right" | <tt style="white-space: nowrap">...v vv.s</tt>
| RW8
| Volume segment status (v), Sleep (s)
|-
! $1C
| [[Display#LCD Mono Shade LUT|LCD Mono Shade LUT 0/1]]
| style="text-align: right" | <tt style="white-space: nowrap">1111 0000</tt>
| RW8
| Shade index
|-
! $1D
| [[Display#LCD Mono Shade LUT|LCD Mono Shade LUT 2/3]]
| style="text-align: right" | <tt style="white-space: nowrap">3333 2222</tt>
| RW8
| Shade index
|-
! $1E
| [[Display#LCD Mono Shade LUT|LCD Mono Shade LUT 4/5]]
| style="text-align: right" | <tt style="white-space: nowrap">5555 4444</tt>
| RW8
| Shade index
|-
! $1F
| [[Display#LCD Mono Shade LUT|LCD Mono Shade LUT 6/7]]
| style="text-align: right" | <tt style="white-space: nowrap">7777 6666</tt>
| RW8
| Shade index
|-
! $20
| [[Display#LCD Mono Palette|LCD Mono Palette 0]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $22
| [[Display#LCD Mono Palette|LCD Mono Palette 1]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $24
| [[Display#LCD Mono Palette|LCD Mono Palette 2]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $26
| [[Display#LCD Mono Palette|LCD Mono Palette 3]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $28
| [[Display#LCD Mono Palette|LCD Mono Palette 4]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $2A
| [[Display#LCD Mono Palette|LCD Mono Palette 5]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $2C
| [[Display#LCD Mono Palette|LCD Mono Palette 6]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $2E
| [[Display#LCD Mono Palette|LCD Mono Palette 7]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $30
| [[Display#LCD Mono Palette|LCD Mono Palette 8]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $32
| [[Display#LCD Mono Palette|LCD Mono Palette 9]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $34
| [[Display#LCD Mono Palette|LCD Mono Palette 10]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $36
| [[Display#LCD Mono Palette|LCD Mono Palette 11]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $38
| [[Display#LCD Mono Palette|LCD Mono Palette 12]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $3A
| [[Display#LCD Mono Palette|LCD Mono Palette 13]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $3C
| [[Display#LCD Mono Palette|LCD Mono Palette 14]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $3E
| [[Display#LCD Mono Palette|LCD Mono Palette 15]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! rowspan="10" | [[DMA]]<sup>(color)</sup>
! $40
| [[DMA#General DMA|GDMA Source Address Low]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll llll llll</tt>
| RW16
| Linear address, low 16 bits (l)
|-
! $42
| [[DMA#General DMA|GDMA Source Address High]]
| style="text-align: right" | <tt style="white-space: nowrap">.... hhhh</tt>
| RW8
| Linear address, high 4 bits (h)
|-
! $44
| [[DMA#General DMA|GDMA Destination Address]]
| style="text-align: right" | <tt style="white-space: nowrap">aaaa aaaa aaaa aaaa</tt>
| RW16
| IRAM address (a)
|-
! $46
| [[DMA#General DMA|GDMA Length]]
| style="text-align: right" | <tt style="white-space: nowrap">bbbb bbbb bbbb bbbb</tt>
| RW16
| Bytes (b)
|-
! $48
| [[DMA#General DMA|GDMA Control]]
| style="text-align: right" | <tt style="white-space: nowrap">ed.. ....</tt>
| RW8
| Enable (e), Decrement (d)
|-
! $4A
| [[DMA#Sound DMA|SDMA Source Address Low]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll llll llll</tt>
| RW16
| Linear address, low 16 bits (l)
|-
! $4C
| [[DMA#Sound DMA|SDMA Source Address High]]
| style="text-align: right" | <tt style="white-space: nowrap">.... hhhh</tt>
| RW8
| Linear address, high 4 bits (h)
|-
! $4E
| [[DMA#Sound DMA|SDMA Length Low]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll llll llll</tt>
| RW16
| Length, low 16 bits (l)
|-
! $50
| [[DMA#Sound DMA|SDMA Length High]]
| style="text-align: right" | <tt style="white-space: nowrap">.... hhhh</tt>
| RW8
| Length, high 4 bits (h)
|-
! $52
| [[DMA#Sound DMA|SDMA Control]]
| style="text-align: right" | <tt style="white-space: nowrap">ed.t r?ff</tt>
| RW8
| Enable (e), Decrement (d), Target (t),
Repeat (r), Frequency (f)
|-
! rowspan="2" | [[SoC]]<sup>(color)</sup>
! $60
| [[SoC#System Control 2|System Control 2]]
| style="text-align: right" | <tt style="white-space: nowrap">c4C. ?.??</tt>
| RW8
| Color (c), 4BPP (4), Chunky (C)
|-
! $62
| [[SoC#System Control 3|System Control 3]]
| style="text-align: right" | <tt style="white-space: nowrap">S... ...p</tt>
| RW8
| SwanCrystal (S), Power off (p)
|-
! rowspan="5" | [[Hyper Voice]]<sup>(color)</sup>
! $64
| [[Hyper Voice#Hyper Voice Output|Hyper Voice Left Output]]
| style="text-align: right" | <tt style="white-space: nowrap">ssss ssss ssss ssss</tt>
| W16
| Raw sample (s)
|-
! $66
| [[Hyper Voice#Hyper Voice Output|Hyper Voice Right Output]]
| style="text-align: right" | <tt style="white-space: nowrap">ssss ssss ssss ssss</tt>
| W16
| Raw sample (s)
|-
! $68
| [[Hyper Voice#Hyper Voice Input|Hyper Voice Left Input]]
| style="text-align: right" | <tt style="white-space: nowrap">ssss ssss</tt>
| W8
| Sample (s)
|-
! $69
| [[Hyper Voice#Hyper Voice Input|Hyper Voice Right Input]]
| style="text-align: right" | <tt style="white-space: nowrap">ssss ssss</tt>
| W8
| Sample (s)
|-
! $6A
| [[Hyper Voice#Hyper Voice Control|Hyper Voice Control]]
| style="text-align: right" | <tt style="white-space: nowrap">.mmc ???? errr ffss</tt>
| RW16
| Mask (m), Channel reset (c), Enable (e),
Rate (r), Format (f), Shift (s)
|-
! rowspan="8" | [[Display]]<sup>(SC)</sup>
! $70
| LCD Timing Configuration 1?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $71
| LCD Timing Configuration 2?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $72
| LCD Timing Configuration 3?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $73
| LCD Timing Configuration 4?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $74
| LCD Timing Configuration 5?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $75
| LCD Timing Configuration 6?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $76
| LCD Timing Configuration 7?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $77
| LCD Timing Configuration 8?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! rowspan="21" | [[Sound]]
! $80
| [[Sound#Sound Channel Frequency|Sound Channel 1 Frequency]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .ddd dddd dddd</tt>
| RW16
| Divider (d)
|-
! $82
| [[Sound#Sound Channel Frequency|Sound Channel 2 Frequency]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .ddd dddd dddd</tt>
| RW16
| Divider (d)
|-
! $84
| [[Sound#Sound Channel Frequency|Sound Channel 3 Frequency]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .ddd dddd dddd</tt>
| RW16
| Divider (d)
|-
! $86
| [[Sound#Sound Channel Frequency|Sound Channel 4 Frequency]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .ddd dddd dddd</tt>
| RW16
| Divider (d)
|-
! $88
| [[Sound#Sound Channel Volume|Sound Channel 1 Volume]]
| style="text-align: right" | <tt style="white-space: nowrap">llll rrrr</tt>
| RW8
| Left (l), Right (r)
|-
! rowspan="2" | $89
| [[Sound#Sound Channel Volume|Sound Channel 2 Volume]]
| style="text-align: right" | <tt style="white-space: nowrap">llll rrrr</tt>
| RW8
| Left (l), Right (r)
|-
| [[Sound#Sound Channel 2 Voice Sample|Sound Channel 2 Voice Sample]]
| style="text-align: right" | <tt style="white-space: nowrap">ssss ssss</tt>
| RW8
| Sample (s)
|-
! $8A
| [[Sound#Sound Channel Volume|Sound Channel 3 Volume]]
| style="text-align: right" | <tt style="white-space: nowrap">llll rrrr</tt>
| RW8
| Left (l), Right (r)
|-
! $8B
| [[Sound#Sound Channel Volume|Sound Channel 4 Volume]]
| style="text-align: right" | <tt style="white-space: nowrap">llll rrrr</tt>
| RW8
| Left (l), Right (r)
|-
! $8C
| [[Sound#Sound Channel 3 Sweep Amount|Sound Channel 3 Sweep Amount]]
| style="text-align: right" | <tt style="white-space: nowrap">vvvv vvvv</tt>
| RW8
| Value (v)
|-
! $8D
| [[Sound#Sound Channel 3 Sweep Ticks|Sound Channel 3 Sweep Ticks]]
| style="text-align: right" | <tt style="white-space: nowrap">...t tttt</tt>
| RW8
| Ticks (t)
|-
! $8E
| [[Sound#Sound Channel 4 Noise Control|Sound Channel 4 Noise Control]]
| style="text-align: right" | <tt style="white-space: nowrap">...e rttt</tt>
| RW8
| Enable (e), Reset (r), Tap (t)
|-
! $8F
| [[Sound#Sound Wavetable Address|Sound Wavetable Address]]
| style="text-align: right" | <tt style="white-space: nowrap">wwww wwww</tt>
| RW8
| Address >> 6 (w)
|-
! $90
| [[Sound#Sound Channel Control|Sound Channel Control]]
| style="text-align: right" | <tt style="white-space: nowrap">nsv. 4321</tt>
| RW8
| Channel enable (1234)
Noise (n), Sweep (s), Voice (v)
|-
! $91
| [[Sound#Sound Output Control|Sound Output Control]]
| style="text-align: right" | <tt style="white-space: nowrap">H... hrrs</tt>
| RW8
| Headphones connected (H)
Headphone output (h)
Speaker output (s), range (r)
|-
! $92
| [[Sound#Sound Channel 4 LFSR Register|Sound Channel 4 LFSR Register]]
| style="text-align: right" | <tt style="white-space: nowrap">.rrr rrrr rrrr rrrr</tt>
| R16
| PRNG state (r)
|-
! $94
| [[Sound#Sound Channel 2 Voice Volume|Sound Channel 2 Voice Volume]]
| style="text-align: right" | <tt style="white-space: nowrap">.... lLrR</tt>
| RW8
| Left Half (l), Full (L)
Right Half (r), Full (R)
|-
! $96
| Sound Channel Output Right
| style="text-align: right" | <tt style="white-space: nowrap">.... ..ss ssss ssss</tt>
| R16
| Sample (s)
|-
! $98
| Sound Channel Output Left
| style="text-align: right" | <tt style="white-space: nowrap">.... ..ss ssss ssss</tt>
| R16
| Sample (s)
|-
! $9A
| Sound Channel Output Sum
| style="text-align: right" | <tt style="white-space: nowrap">.... .sss ssss ssss</tt>
| R16
| Sample (s)
|-
! $9E
| Sound Speaker Master Volume<sup>(color)</sup>
| style="text-align: right" | <tt style="white-space: nowrap">.... ..vv</tt>
| R8
| ?
|-
! [[SoC]]
! $A0
| [[SoC#System Control|System Control]]
| style="text-align: right" | <tt style="white-space: nowrap">t??? swcl</tt>
| RW8
| Test OK (t), ROM speed (s), ROM width (w),
Color system (c), Boot ROM lockout (l)
|-
! rowspan="5" | [[Timers]]
! $A2
| [[Timers#Timer Control|Timer Control]]
| style="text-align: right" | <tt style="white-space: nowrap">.... VvHh</tt>
| RW8
| Horizontal enable (h), auto reload (H)
Vertical enable (v), auto reload (V)
|-
! $A4
| [[Timers#Timer Reload|Horizontal Blank Timer Reload]]
| style="text-align: right" | <tt style="white-space: nowrap">tttt tttt tttt tttt</tt>
| RW16
| Ticks (t)
|-
! $A6
| [[Timers#Timer Reload|Vertical Blank Timer Reload]]
| style="text-align: right" | <tt style="white-space: nowrap">tttt tttt tttt tttt</tt>
| RW16
| Ticks (t)
|-
! $A8
| [[Timers#Timer Counter|Horizontal Blank Timer Counter]]
| style="text-align: right" | <tt style="white-space: nowrap">tttt tttt tttt tttt</tt>
| R16
| Ticks (t)
|-
! $AA
| [[Timers#Timer Counter|Vertical Blank Timer Counter]]
| style="text-align: right" | <tt style="white-space: nowrap">tttt tttt tttt tttt</tt>
| R16
| Ticks (t)
|-
! ?
! $AC
| ?
| style="text-align: right" | <tt style="white-space: nowrap">.... ...p</tt>
| W8?
| Power off (p)
|-
! rowspan="2" | [[Interrupts]]
! rowspan="2" | $B0
| [[Interrupts#Interrupt Vector Offset|Interrupt Vector Offset]]
| style="text-align: right" | <tt style="white-space: nowrap">VVVV V...</tt>
| W8
| Vector offset (V)
|-
| [[Interrupts#Interrupt Vector Request|Interrupt Vector Request]]
| style="text-align: right" | <tt style="white-space: nowrap">vvvv vvvv</tt>
| R8
| Requested vector offset (v)
|-
! rowspan="2" | [[UART]]
! $B1
| [[UART#Serial Receive Data|Serial Receive Data]]
| style="text-align: right" | <tt style="white-space: nowrap">dddd dddd</tt>
| R8
| Receive buffer data (d)
|-
! $B1
| [[UART#Serial Transmit Data|Serial Transmit Data]]
| style="text-align: right" | <tt style="white-space: nowrap">dddd dddd</tt>
| W8
| Transmit buffer data (d)
|-
! [[Interrupts]]
! $B2
| [[Interrupts#Interrupt Enable|Interrupt Enable]]
| iiii iiii
| RW8
| Interrupt index (i)
|-
! rowspan="2" | [[UART]]
! $B3
| [[UART#Serial Status|Serial Status]]
| style="text-align: right" | <tt style="white-space: nowrap">eb.. .tor</tt>
| R8
| Enable (e), Baud rate (b),
Transfer ready (t), Overrun (o), Receive ready (r)
|-
! $B3
| [[UART#Serial Control|Serial Control]]
| style="text-align: right" | <tt style="white-space: nowrap">ebO. ....</tt>
| W8
| Enable (e), Baud rate (b), Reset Overrun (O)
|-
! [[Interrupts]]
! $B4
| [[Interrupts#Interrupt Status|Interrupt Status]]
| iiii iiii
| R8
| Interrupt index (i)
|-
! [[Keypad]]
! $B5
| [[Keypad|Keypad Scan]]
| style="text-align: right" | <tt style="white-space: nowrap">.iii oooo</tt>
| RW8
| Input row (i), Output column (o)
|-
! rowspan="2" | [[Interrupts]]
! $B6
| [[Interrupts#Interrupt Acknowledge|Interrupt Acknowledge]]
| iiii iiii
| R8?
| Interrupt index (i)
|-
! $B7
| [[Interrupts#Interrupt NMI Control|Interrupt NMI Control]]
| style="text-align: right" | <tt style="white-space: nowrap">...b ....</tt>
| RW8
| Low battery (b)
|-
! rowspan="4" | [[EEPROM|Internal EEPROM]]
! $BA
| [[EEPROM#Internal EEPROM Data|Internal EEPROM Data]]
| style="text-align: right" | <tt style="white-space: nowrap">dddd dddd dddd dddd</tt>
| RW16
| Data (d)
|-
! $BC
| [[EEPROM#Internal EEPROM Command|Internal EEPROM Command]]
|
| RW16
|
|-
! rowspan="2" | $BE
| [[EEPROM#Internal EEPROM Status|Internal EEPROM Status]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .... p... ..RD</tt>
| R16
| Protected (p), Ready (R), Done (D)
|-
| [[EEPROM#Internal EEPROM Control|Internal EEPROM Control]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .... pewr ....</tt>
| W16
| Protect (p), Erase (e), Write (w), Read (r)
|-
! [[Mapper|Cartridge]]
! $C0<br />
$FF
| Cartridge I/O
|
| RW8
| Forwarded by the SoC
|}
== I/O port routing ==
The [[NEC V30MZ]] supports 16-bit I/O port addresses. The WonderSwan SoC routes them using the following algorithm:
* If an address is between <code>$00B8</code> and <code>$00BF</code> inclusive, it is routed to the internal EEPROM control block.
* If an address is between <code>$00C0</code> and <code>$00FF</code> inclusive, it is routed to the cartride bus.
* If an address's bits <code>0</code> through <code>8</code> inclusive are between <code>$000</code> and <code>$0B7</code> inclusive, they are routed to the SoC block.
* If none of these conditions are reached, open bus is read.
On the monochrome models, as well as color models in mono emulation, open bus is always <code>0x90</code>.
89474dbf48c06718c6d84d0c2119f652dd3376af
223
219
2023-08-29T21:52:53Z
Asie
351
document port $60 bit 1
wikitext
text/x-wiki
The WonderSwan SoC has three general blocks of I/O port accesses:
{| class="wikitable"
! From !! To !! Holder !! Width
|-
| $00 || $B7 || WonderSwan SoC || 8/16-bit
|-
| $B8 || $BF || Internal EEPROM control || 16-bit
|-
| $C0 || $FF || Cartridge bus || 8-bit
|}
With the exception of internal EEPROM on the ASWAN, all unaligned 16-bit accesses can be converted to two 8-bit accesses with a 1-cycle penalty.
== I/O port map ==
* Superscripts are used to mark ports specific to a given mode or platform:
** Color mode: <sup>(color)</sup>. Such ports are only accessible when color mode is enabled through port <code>$60</code>.
** WS/WSC/SC console: <sup>(WS)</sup>, <sup>(WSC)</sup>, <sup>(SC)</sup>.
* If two Bits rows are provided, the second one refers to the "Color" mode.
* The Type can be: R - readable, W - writable, L - writable before boot ROM lockout, 8/16 - width (byte/word).
{| class="wikitable"
! Category
! Port
! Description
! Bits
! Type
! Notes
|-
! rowspan="45" | [[Display]]
! $00
| [[Display#Display Control|Display Control]]
| style="text-align: right" | <tt style="white-space: nowrap">..ow Ws21</tt>
| RW8
|
|-
! $01
| [[Display#Display Background|Display Background]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .sss</tt>
<tt style="white-space: nowrap">pppp iiii</tt>
| RW8
| Shade (s)
Palette (p), Index (i)
|-
! $02
| [[Display#Current Line|Display Current Line]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll</tt>
| R8
| Line (l)
|-
! $03
| [[Display#Interrupt Line|Display Interrupt Line]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll</tt>
| RW8
| Line (l)
|-
! $04
| [[Display#Sprite Table Address|Sprite Table Address]]
| style="text-align: right" | <tt style="white-space: nowrap">...a aaaa</tt>
<tt style="white-space: nowrap">..aa aaaa</tt>
| RW8
| Address >> 9 (a)
|-
! $05
| [[Display#Sprite Table First|Sprite Table First]]
| style="text-align: right" | <tt style="white-space: nowrap">.iii iiii</tt>
| RW8
| Index (i)
|-
! $06
| [[Display#Sprite Table Count|Sprite Table Count]]
| style="text-align: right" | <tt style="white-space: nowrap">cccc cccc</tt>
| RW8
| Count (c)
|-
! $07
| [[Display#Screen Address|Screen Address]]
| style="text-align: right" | <tt style="white-space: nowrap">.222 .111</tt>
<tt style="white-space: nowrap">2222 1111</tt>
| RW8
| Screen 1 address >> 11 (1)
Screen 2 address >> 11 (2)
|-
! $08
| [[Display#Screen 2 Window|Screen 2 Window Left]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $09
| [[Display#Screen 2 Window|Screen 2 Window Top]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $0A
| [[Display#Screen 2 Window|Screen 2 Window Right]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $0B
| [[Display#Screen 2 Window|Screen 2 Window Bottom]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $0B
| [[Display#Sprite Window|Sprite Window Left]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $0C
| [[Display#Sprite Window|Sprite Window Top]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $0E
| [[Display#Sprite Window|Sprite Window Right]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $0F
| [[Display#Sprite Window|Sprite Window Bottom]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $10
| [[Display#Screen Scroll|Screen 1 Scroll X]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $11
| [[Display#Screen Scroll|Screen 1 Scroll Y]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $12
| [[Display#Screen Scroll|Screen 2 Scroll X]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $13
| [[Display#Screen Scroll|Screen 2 Scroll Y]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $14
| [[Display#LCD Control|LCD Control]]
| style="text-align: right" | <tt style="white-space: nowrap">.... ..Ce</tt>
| RW8
| Contrast (C)<sup>(WSC)</sup>, Enable (e)
|-
! $15
| [[Display#LCD Icon Control|LCD Icon Control]]
| style="text-align: right" | <tt style="white-space: nowrap">..32 1hvs</tt>
| RW8
| Auxillary 3 (3), Auxillary 2 (2), Auxillary 1 (1),
Horizontal (h), Vertical (v), Sleep (s)
|-
! $16
| [[Display#LCD Final Line|LCD Final Line]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll</tt>
| RW8
| Line (l)
|-
! $17
| [[Display#LCD Back Porch Line|LCD Back Porch Line]]<sup>(WSC)</sup>
| style="text-align: right" | <tt style="white-space: nowrap">llll llll</tt>
| RW8
| Line (l)
|-
! $1A
| [[Display#LCD Status|LCD Status]]
| style="text-align: right" | <tt style="white-space: nowrap">...v vv.s</tt>
| RW8
| Volume segment status (v), Sleep (s)
|-
! $1C
| [[Display#LCD Mono Shade LUT|LCD Mono Shade LUT 0/1]]
| style="text-align: right" | <tt style="white-space: nowrap">1111 0000</tt>
| RW8
| Shade index
|-
! $1D
| [[Display#LCD Mono Shade LUT|LCD Mono Shade LUT 2/3]]
| style="text-align: right" | <tt style="white-space: nowrap">3333 2222</tt>
| RW8
| Shade index
|-
! $1E
| [[Display#LCD Mono Shade LUT|LCD Mono Shade LUT 4/5]]
| style="text-align: right" | <tt style="white-space: nowrap">5555 4444</tt>
| RW8
| Shade index
|-
! $1F
| [[Display#LCD Mono Shade LUT|LCD Mono Shade LUT 6/7]]
| style="text-align: right" | <tt style="white-space: nowrap">7777 6666</tt>
| RW8
| Shade index
|-
! $20
| [[Display#LCD Mono Palette|LCD Mono Palette 0]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $22
| [[Display#LCD Mono Palette|LCD Mono Palette 1]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $24
| [[Display#LCD Mono Palette|LCD Mono Palette 2]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $26
| [[Display#LCD Mono Palette|LCD Mono Palette 3]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $28
| [[Display#LCD Mono Palette|LCD Mono Palette 4]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $2A
| [[Display#LCD Mono Palette|LCD Mono Palette 5]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $2C
| [[Display#LCD Mono Palette|LCD Mono Palette 6]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $2E
| [[Display#LCD Mono Palette|LCD Mono Palette 7]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $30
| [[Display#LCD Mono Palette|LCD Mono Palette 8]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $32
| [[Display#LCD Mono Palette|LCD Mono Palette 9]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $34
| [[Display#LCD Mono Palette|LCD Mono Palette 10]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $36
| [[Display#LCD Mono Palette|LCD Mono Palette 11]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $38
| [[Display#LCD Mono Palette|LCD Mono Palette 12]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $3A
| [[Display#LCD Mono Palette|LCD Mono Palette 13]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $3C
| [[Display#LCD Mono Palette|LCD Mono Palette 14]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $3E
| [[Display#LCD Mono Palette|LCD Mono Palette 15]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! rowspan="10" | [[DMA]]<sup>(color)</sup>
! $40
| [[DMA#General DMA|GDMA Source Address Low]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll llll llll</tt>
| RW16
| Linear address, low 16 bits (l)
|-
! $42
| [[DMA#General DMA|GDMA Source Address High]]
| style="text-align: right" | <tt style="white-space: nowrap">.... hhhh</tt>
| RW8
| Linear address, high 4 bits (h)
|-
! $44
| [[DMA#General DMA|GDMA Destination Address]]
| style="text-align: right" | <tt style="white-space: nowrap">aaaa aaaa aaaa aaaa</tt>
| RW16
| IRAM address (a)
|-
! $46
| [[DMA#General DMA|GDMA Length]]
| style="text-align: right" | <tt style="white-space: nowrap">bbbb bbbb bbbb bbbb</tt>
| RW16
| Bytes (b)
|-
! $48
| [[DMA#General DMA|GDMA Control]]
| style="text-align: right" | <tt style="white-space: nowrap">ed.. ....</tt>
| RW8
| Enable (e), Decrement (d)
|-
! $4A
| [[DMA#Sound DMA|SDMA Source Address Low]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll llll llll</tt>
| RW16
| Linear address, low 16 bits (l)
|-
! $4C
| [[DMA#Sound DMA|SDMA Source Address High]]
| style="text-align: right" | <tt style="white-space: nowrap">.... hhhh</tt>
| RW8
| Linear address, high 4 bits (h)
|-
! $4E
| [[DMA#Sound DMA|SDMA Length Low]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll llll llll</tt>
| RW16
| Length, low 16 bits (l)
|-
! $50
| [[DMA#Sound DMA|SDMA Length High]]
| style="text-align: right" | <tt style="white-space: nowrap">.... hhhh</tt>
| RW8
| Length, high 4 bits (h)
|-
! $52
| [[DMA#Sound DMA|SDMA Control]]
| style="text-align: right" | <tt style="white-space: nowrap">ed.t r?ff</tt>
| RW8
| Enable (e), Decrement (d), Target (t),
Repeat (r), Frequency (f)
|-
! rowspan="2" | [[SoC]]<sup>(color)</sup>
! $60
| [[SoC#System Control 2|System Control 2]]
| style="text-align: right" | <tt style="white-space: nowrap">c4C. ?.s?</tt>
| RW8
| Color (c), 4BPP (4), Chunky (C)<br/>
SRAM wait state (s)
|-
! $62
| [[SoC#System Control 3|System Control 3]]
| style="text-align: right" | <tt style="white-space: nowrap">S... ...p</tt>
| RW8
| SwanCrystal (S), Power off (p)
|-
! rowspan="5" | [[Hyper Voice]]<sup>(color)</sup>
! $64
| [[Hyper Voice#Hyper Voice Output|Hyper Voice Left Output]]
| style="text-align: right" | <tt style="white-space: nowrap">ssss ssss ssss ssss</tt>
| W16
| Raw sample (s)
|-
! $66
| [[Hyper Voice#Hyper Voice Output|Hyper Voice Right Output]]
| style="text-align: right" | <tt style="white-space: nowrap">ssss ssss ssss ssss</tt>
| W16
| Raw sample (s)
|-
! $68
| [[Hyper Voice#Hyper Voice Input|Hyper Voice Left Input]]
| style="text-align: right" | <tt style="white-space: nowrap">ssss ssss</tt>
| W8
| Sample (s)
|-
! $69
| [[Hyper Voice#Hyper Voice Input|Hyper Voice Right Input]]
| style="text-align: right" | <tt style="white-space: nowrap">ssss ssss</tt>
| W8
| Sample (s)
|-
! $6A
| [[Hyper Voice#Hyper Voice Control|Hyper Voice Control]]
| style="text-align: right" | <tt style="white-space: nowrap">.mmc ???? errr ffss</tt>
| RW16
| Mask (m), Channel reset (c), Enable (e),
Rate (r), Format (f), Shift (s)
|-
! rowspan="8" | [[Display]]<sup>(SC)</sup>
! $70
| LCD Timing Configuration 1?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $71
| LCD Timing Configuration 2?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $72
| LCD Timing Configuration 3?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $73
| LCD Timing Configuration 4?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $74
| LCD Timing Configuration 5?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $75
| LCD Timing Configuration 6?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $76
| LCD Timing Configuration 7?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $77
| LCD Timing Configuration 8?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! rowspan="21" | [[Sound]]
! $80
| [[Sound#Sound Channel Frequency|Sound Channel 1 Frequency]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .ddd dddd dddd</tt>
| RW16
| Divider (d)
|-
! $82
| [[Sound#Sound Channel Frequency|Sound Channel 2 Frequency]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .ddd dddd dddd</tt>
| RW16
| Divider (d)
|-
! $84
| [[Sound#Sound Channel Frequency|Sound Channel 3 Frequency]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .ddd dddd dddd</tt>
| RW16
| Divider (d)
|-
! $86
| [[Sound#Sound Channel Frequency|Sound Channel 4 Frequency]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .ddd dddd dddd</tt>
| RW16
| Divider (d)
|-
! $88
| [[Sound#Sound Channel Volume|Sound Channel 1 Volume]]
| style="text-align: right" | <tt style="white-space: nowrap">llll rrrr</tt>
| RW8
| Left (l), Right (r)
|-
! rowspan="2" | $89
| [[Sound#Sound Channel Volume|Sound Channel 2 Volume]]
| style="text-align: right" | <tt style="white-space: nowrap">llll rrrr</tt>
| RW8
| Left (l), Right (r)
|-
| [[Sound#Sound Channel 2 Voice Sample|Sound Channel 2 Voice Sample]]
| style="text-align: right" | <tt style="white-space: nowrap">ssss ssss</tt>
| RW8
| Sample (s)
|-
! $8A
| [[Sound#Sound Channel Volume|Sound Channel 3 Volume]]
| style="text-align: right" | <tt style="white-space: nowrap">llll rrrr</tt>
| RW8
| Left (l), Right (r)
|-
! $8B
| [[Sound#Sound Channel Volume|Sound Channel 4 Volume]]
| style="text-align: right" | <tt style="white-space: nowrap">llll rrrr</tt>
| RW8
| Left (l), Right (r)
|-
! $8C
| [[Sound#Sound Channel 3 Sweep Amount|Sound Channel 3 Sweep Amount]]
| style="text-align: right" | <tt style="white-space: nowrap">vvvv vvvv</tt>
| RW8
| Value (v)
|-
! $8D
| [[Sound#Sound Channel 3 Sweep Ticks|Sound Channel 3 Sweep Ticks]]
| style="text-align: right" | <tt style="white-space: nowrap">...t tttt</tt>
| RW8
| Ticks (t)
|-
! $8E
| [[Sound#Sound Channel 4 Noise Control|Sound Channel 4 Noise Control]]
| style="text-align: right" | <tt style="white-space: nowrap">...e rttt</tt>
| RW8
| Enable (e), Reset (r), Tap (t)
|-
! $8F
| [[Sound#Sound Wavetable Address|Sound Wavetable Address]]
| style="text-align: right" | <tt style="white-space: nowrap">wwww wwww</tt>
| RW8
| Address >> 6 (w)
|-
! $90
| [[Sound#Sound Channel Control|Sound Channel Control]]
| style="text-align: right" | <tt style="white-space: nowrap">nsv. 4321</tt>
| RW8
| Channel enable (1234)
Noise (n), Sweep (s), Voice (v)
|-
! $91
| [[Sound#Sound Output Control|Sound Output Control]]
| style="text-align: right" | <tt style="white-space: nowrap">H... hrrs</tt>
| RW8
| Headphones connected (H)
Headphone output (h)
Speaker output (s), range (r)
|-
! $92
| [[Sound#Sound Channel 4 LFSR Register|Sound Channel 4 LFSR Register]]
| style="text-align: right" | <tt style="white-space: nowrap">.rrr rrrr rrrr rrrr</tt>
| R16
| PRNG state (r)
|-
! $94
| [[Sound#Sound Channel 2 Voice Volume|Sound Channel 2 Voice Volume]]
| style="text-align: right" | <tt style="white-space: nowrap">.... lLrR</tt>
| RW8
| Left Half (l), Full (L)
Right Half (r), Full (R)
|-
! $96
| Sound Channel Output Right
| style="text-align: right" | <tt style="white-space: nowrap">.... ..ss ssss ssss</tt>
| R16
| Sample (s)
|-
! $98
| Sound Channel Output Left
| style="text-align: right" | <tt style="white-space: nowrap">.... ..ss ssss ssss</tt>
| R16
| Sample (s)
|-
! $9A
| Sound Channel Output Sum
| style="text-align: right" | <tt style="white-space: nowrap">.... .sss ssss ssss</tt>
| R16
| Sample (s)
|-
! $9E
| Sound Speaker Master Volume<sup>(color)</sup>
| style="text-align: right" | <tt style="white-space: nowrap">.... ..vv</tt>
| R8
| ?
|-
! [[SoC]]
! $A0
| [[SoC#System Control|System Control]]
| style="text-align: right" | <tt style="white-space: nowrap">t??? swcl</tt>
| RW8
| Test OK (t), ROM wait state (s), ROM width (w),
Color system (c), Boot ROM lockout (l)
|-
! rowspan="5" | [[Timers]]
! $A2
| [[Timers#Timer Control|Timer Control]]
| style="text-align: right" | <tt style="white-space: nowrap">.... VvHh</tt>
| RW8
| Horizontal enable (h), auto reload (H)
Vertical enable (v), auto reload (V)
|-
! $A4
| [[Timers#Timer Reload|Horizontal Blank Timer Reload]]
| style="text-align: right" | <tt style="white-space: nowrap">tttt tttt tttt tttt</tt>
| RW16
| Ticks (t)
|-
! $A6
| [[Timers#Timer Reload|Vertical Blank Timer Reload]]
| style="text-align: right" | <tt style="white-space: nowrap">tttt tttt tttt tttt</tt>
| RW16
| Ticks (t)
|-
! $A8
| [[Timers#Timer Counter|Horizontal Blank Timer Counter]]
| style="text-align: right" | <tt style="white-space: nowrap">tttt tttt tttt tttt</tt>
| R16
| Ticks (t)
|-
! $AA
| [[Timers#Timer Counter|Vertical Blank Timer Counter]]
| style="text-align: right" | <tt style="white-space: nowrap">tttt tttt tttt tttt</tt>
| R16
| Ticks (t)
|-
! ?
! $AC
| ?
| style="text-align: right" | <tt style="white-space: nowrap">.... ...p</tt>
| W8?
| Power off (p)
|-
! rowspan="2" | [[Interrupts]]
! rowspan="2" | $B0
| [[Interrupts#Interrupt Vector Offset|Interrupt Vector Offset]]
| style="text-align: right" | <tt style="white-space: nowrap">VVVV V...</tt>
| W8
| Vector offset (V)
|-
| [[Interrupts#Interrupt Vector Request|Interrupt Vector Request]]
| style="text-align: right" | <tt style="white-space: nowrap">vvvv vvvv</tt>
| R8
| Requested vector offset (v)
|-
! rowspan="2" | [[UART]]
! $B1
| [[UART#Serial Receive Data|Serial Receive Data]]
| style="text-align: right" | <tt style="white-space: nowrap">dddd dddd</tt>
| R8
| Receive buffer data (d)
|-
! $B1
| [[UART#Serial Transmit Data|Serial Transmit Data]]
| style="text-align: right" | <tt style="white-space: nowrap">dddd dddd</tt>
| W8
| Transmit buffer data (d)
|-
! [[Interrupts]]
! $B2
| [[Interrupts#Interrupt Enable|Interrupt Enable]]
| iiii iiii
| RW8
| Interrupt index (i)
|-
! rowspan="2" | [[UART]]
! $B3
| [[UART#Serial Status|Serial Status]]
| style="text-align: right" | <tt style="white-space: nowrap">eb.. .tor</tt>
| R8
| Enable (e), Baud rate (b),
Transfer ready (t), Overrun (o), Receive ready (r)
|-
! $B3
| [[UART#Serial Control|Serial Control]]
| style="text-align: right" | <tt style="white-space: nowrap">ebO. ....</tt>
| W8
| Enable (e), Baud rate (b), Reset Overrun (O)
|-
! [[Interrupts]]
! $B4
| [[Interrupts#Interrupt Status|Interrupt Status]]
| iiii iiii
| R8
| Interrupt index (i)
|-
! [[Keypad]]
! $B5
| [[Keypad|Keypad Scan]]
| style="text-align: right" | <tt style="white-space: nowrap">.iii oooo</tt>
| RW8
| Input row (i), Output column (o)
|-
! rowspan="2" | [[Interrupts]]
! $B6
| [[Interrupts#Interrupt Acknowledge|Interrupt Acknowledge]]
| iiii iiii
| R8?
| Interrupt index (i)
|-
! $B7
| [[Interrupts#Interrupt NMI Control|Interrupt NMI Control]]
| style="text-align: right" | <tt style="white-space: nowrap">...b ....</tt>
| RW8
| Low battery (b)
|-
! rowspan="4" | [[EEPROM|Internal EEPROM]]
! $BA
| [[EEPROM#Internal EEPROM Data|Internal EEPROM Data]]
| style="text-align: right" | <tt style="white-space: nowrap">dddd dddd dddd dddd</tt>
| RW16
| Data (d)
|-
! $BC
| [[EEPROM#Internal EEPROM Command|Internal EEPROM Command]]
|
| RW16
|
|-
! rowspan="2" | $BE
| [[EEPROM#Internal EEPROM Status|Internal EEPROM Status]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .... p... ..RD</tt>
| R16
| Protected (p), Ready (R), Done (D)
|-
| [[EEPROM#Internal EEPROM Control|Internal EEPROM Control]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .... pewr ....</tt>
| W16
| Protect (p), Erase (e), Write (w), Read (r)
|-
! [[Mapper|Cartridge]]
! $C0<br />
$FF
| Cartridge I/O
|
| RW8
| Forwarded by the SoC
|}
== I/O port routing ==
The [[NEC V30MZ]] supports 16-bit I/O port addresses. The WonderSwan SoC routes them using the following algorithm:
* If an address is between <code>$00B8</code> and <code>$00BF</code> inclusive, it is routed to the internal EEPROM control block.
* If an address is between <code>$00C0</code> and <code>$00FF</code> inclusive, it is routed to the cartride bus.
* If an address's bits <code>0</code> through <code>8</code> inclusive are between <code>$000</code> and <code>$0B7</code> inclusive, they are routed to the SoC block.
* If none of these conditions are reached, open bus is read.
On the monochrome models, as well as color models in mono emulation, open bus is always <code>0x90</code>.
814477d25b1aa209869e3842c8a10893f70ce09e
224
223
2023-08-29T22:05:06Z
Asie
351
update $9E
wikitext
text/x-wiki
The WonderSwan SoC has three general blocks of I/O port accesses:
{| class="wikitable"
! From !! To !! Holder !! Width
|-
| $00 || $B7 || WonderSwan SoC || 8/16-bit
|-
| $B8 || $BF || Internal EEPROM control || 16-bit
|-
| $C0 || $FF || Cartridge bus || 8-bit
|}
With the exception of internal EEPROM on the ASWAN, all unaligned 16-bit accesses can be converted to two 8-bit accesses with a 1-cycle penalty.
== I/O port map ==
* Superscripts are used to mark ports specific to a given mode or platform:
** Color mode: <sup>(color)</sup>. Such ports are only accessible when color mode is enabled through port <code>$60</code>.
** WS/WSC/SC console: <sup>(WS)</sup>, <sup>(WSC)</sup>, <sup>(SC)</sup>.
* If two Bits rows are provided, the second one refers to the "Color" mode.
* The Type can be: R - readable, W - writable, L - writable before boot ROM lockout, 8/16 - width (byte/word).
{| class="wikitable"
! Category
! Port
! Description
! Bits
! Type
! Notes
|-
! rowspan="45" | [[Display]]
! $00
| [[Display#Display Control|Display Control]]
| style="text-align: right" | <tt style="white-space: nowrap">..ow Ws21</tt>
| RW8
|
|-
! $01
| [[Display#Display Background|Display Background]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .sss</tt>
<tt style="white-space: nowrap">pppp iiii</tt>
| RW8
| Shade (s)
Palette (p), Index (i)
|-
! $02
| [[Display#Current Line|Display Current Line]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll</tt>
| R8
| Line (l)
|-
! $03
| [[Display#Interrupt Line|Display Interrupt Line]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll</tt>
| RW8
| Line (l)
|-
! $04
| [[Display#Sprite Table Address|Sprite Table Address]]
| style="text-align: right" | <tt style="white-space: nowrap">...a aaaa</tt>
<tt style="white-space: nowrap">..aa aaaa</tt>
| RW8
| Address >> 9 (a)
|-
! $05
| [[Display#Sprite Table First|Sprite Table First]]
| style="text-align: right" | <tt style="white-space: nowrap">.iii iiii</tt>
| RW8
| Index (i)
|-
! $06
| [[Display#Sprite Table Count|Sprite Table Count]]
| style="text-align: right" | <tt style="white-space: nowrap">cccc cccc</tt>
| RW8
| Count (c)
|-
! $07
| [[Display#Screen Address|Screen Address]]
| style="text-align: right" | <tt style="white-space: nowrap">.222 .111</tt>
<tt style="white-space: nowrap">2222 1111</tt>
| RW8
| Screen 1 address >> 11 (1)
Screen 2 address >> 11 (2)
|-
! $08
| [[Display#Screen 2 Window|Screen 2 Window Left]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $09
| [[Display#Screen 2 Window|Screen 2 Window Top]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $0A
| [[Display#Screen 2 Window|Screen 2 Window Right]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $0B
| [[Display#Screen 2 Window|Screen 2 Window Bottom]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $0B
| [[Display#Sprite Window|Sprite Window Left]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $0C
| [[Display#Sprite Window|Sprite Window Top]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $0E
| [[Display#Sprite Window|Sprite Window Right]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $0F
| [[Display#Sprite Window|Sprite Window Bottom]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $10
| [[Display#Screen Scroll|Screen 1 Scroll X]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $11
| [[Display#Screen Scroll|Screen 1 Scroll Y]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $12
| [[Display#Screen Scroll|Screen 2 Scroll X]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $13
| [[Display#Screen Scroll|Screen 2 Scroll Y]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $14
| [[Display#LCD Control|LCD Control]]
| style="text-align: right" | <tt style="white-space: nowrap">.... ..Ce</tt>
| RW8
| Contrast (C)<sup>(WSC)</sup>, Enable (e)
|-
! $15
| [[Display#LCD Icon Control|LCD Icon Control]]
| style="text-align: right" | <tt style="white-space: nowrap">..32 1hvs</tt>
| RW8
| Auxillary 3 (3), Auxillary 2 (2), Auxillary 1 (1),
Horizontal (h), Vertical (v), Sleep (s)
|-
! $16
| [[Display#LCD Final Line|LCD Final Line]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll</tt>
| RW8
| Line (l)
|-
! $17
| [[Display#LCD Back Porch Line|LCD Back Porch Line]]<sup>(WSC)</sup>
| style="text-align: right" | <tt style="white-space: nowrap">llll llll</tt>
| RW8
| Line (l)
|-
! $1A
| [[Display#LCD Status|LCD Status]]
| style="text-align: right" | <tt style="white-space: nowrap">...v vv.s</tt>
| RW8
| Volume segment status (v), Sleep (s)
|-
! $1C
| [[Display#LCD Mono Shade LUT|LCD Mono Shade LUT 0/1]]
| style="text-align: right" | <tt style="white-space: nowrap">1111 0000</tt>
| RW8
| Shade index
|-
! $1D
| [[Display#LCD Mono Shade LUT|LCD Mono Shade LUT 2/3]]
| style="text-align: right" | <tt style="white-space: nowrap">3333 2222</tt>
| RW8
| Shade index
|-
! $1E
| [[Display#LCD Mono Shade LUT|LCD Mono Shade LUT 4/5]]
| style="text-align: right" | <tt style="white-space: nowrap">5555 4444</tt>
| RW8
| Shade index
|-
! $1F
| [[Display#LCD Mono Shade LUT|LCD Mono Shade LUT 6/7]]
| style="text-align: right" | <tt style="white-space: nowrap">7777 6666</tt>
| RW8
| Shade index
|-
! $20
| [[Display#LCD Mono Palette|LCD Mono Palette 0]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $22
| [[Display#LCD Mono Palette|LCD Mono Palette 1]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $24
| [[Display#LCD Mono Palette|LCD Mono Palette 2]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $26
| [[Display#LCD Mono Palette|LCD Mono Palette 3]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $28
| [[Display#LCD Mono Palette|LCD Mono Palette 4]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $2A
| [[Display#LCD Mono Palette|LCD Mono Palette 5]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $2C
| [[Display#LCD Mono Palette|LCD Mono Palette 6]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $2E
| [[Display#LCD Mono Palette|LCD Mono Palette 7]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $30
| [[Display#LCD Mono Palette|LCD Mono Palette 8]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $32
| [[Display#LCD Mono Palette|LCD Mono Palette 9]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $34
| [[Display#LCD Mono Palette|LCD Mono Palette 10]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $36
| [[Display#LCD Mono Palette|LCD Mono Palette 11]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $38
| [[Display#LCD Mono Palette|LCD Mono Palette 12]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $3A
| [[Display#LCD Mono Palette|LCD Mono Palette 13]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $3C
| [[Display#LCD Mono Palette|LCD Mono Palette 14]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $3E
| [[Display#LCD Mono Palette|LCD Mono Palette 15]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! rowspan="10" | [[DMA]]<sup>(color)</sup>
! $40
| [[DMA#General DMA|GDMA Source Address Low]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll llll llll</tt>
| RW16
| Linear address, low 16 bits (l)
|-
! $42
| [[DMA#General DMA|GDMA Source Address High]]
| style="text-align: right" | <tt style="white-space: nowrap">.... hhhh</tt>
| RW8
| Linear address, high 4 bits (h)
|-
! $44
| [[DMA#General DMA|GDMA Destination Address]]
| style="text-align: right" | <tt style="white-space: nowrap">aaaa aaaa aaaa aaaa</tt>
| RW16
| IRAM address (a)
|-
! $46
| [[DMA#General DMA|GDMA Length]]
| style="text-align: right" | <tt style="white-space: nowrap">bbbb bbbb bbbb bbbb</tt>
| RW16
| Bytes (b)
|-
! $48
| [[DMA#General DMA|GDMA Control]]
| style="text-align: right" | <tt style="white-space: nowrap">ed.. ....</tt>
| RW8
| Enable (e), Decrement (d)
|-
! $4A
| [[DMA#Sound DMA|SDMA Source Address Low]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll llll llll</tt>
| RW16
| Linear address, low 16 bits (l)
|-
! $4C
| [[DMA#Sound DMA|SDMA Source Address High]]
| style="text-align: right" | <tt style="white-space: nowrap">.... hhhh</tt>
| RW8
| Linear address, high 4 bits (h)
|-
! $4E
| [[DMA#Sound DMA|SDMA Length Low]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll llll llll</tt>
| RW16
| Length, low 16 bits (l)
|-
! $50
| [[DMA#Sound DMA|SDMA Length High]]
| style="text-align: right" | <tt style="white-space: nowrap">.... hhhh</tt>
| RW8
| Length, high 4 bits (h)
|-
! $52
| [[DMA#Sound DMA|SDMA Control]]
| style="text-align: right" | <tt style="white-space: nowrap">ed.t r?ff</tt>
| RW8
| Enable (e), Decrement (d), Target (t),
Repeat (r), Frequency (f)
|-
! rowspan="2" | [[SoC]]<sup>(color)</sup>
! $60
| [[SoC#System Control 2|System Control 2]]
| style="text-align: right" | <tt style="white-space: nowrap">c4C. ?.s?</tt>
| RW8
| Color (c), 4BPP (4), Chunky (C)<br/>
SRAM wait state (s)
|-
! $62
| [[SoC#System Control 3|System Control 3]]
| style="text-align: right" | <tt style="white-space: nowrap">S... ...p</tt>
| RW8
| SwanCrystal (S), Power off (p)
|-
! rowspan="5" | [[Hyper Voice]]<sup>(color)</sup>
! $64
| [[Hyper Voice#Hyper Voice Output|Hyper Voice Left Output]]
| style="text-align: right" | <tt style="white-space: nowrap">ssss ssss ssss ssss</tt>
| W16
| Raw sample (s)
|-
! $66
| [[Hyper Voice#Hyper Voice Output|Hyper Voice Right Output]]
| style="text-align: right" | <tt style="white-space: nowrap">ssss ssss ssss ssss</tt>
| W16
| Raw sample (s)
|-
! $68
| [[Hyper Voice#Hyper Voice Input|Hyper Voice Left Input]]
| style="text-align: right" | <tt style="white-space: nowrap">ssss ssss</tt>
| W8
| Sample (s)
|-
! $69
| [[Hyper Voice#Hyper Voice Input|Hyper Voice Right Input]]
| style="text-align: right" | <tt style="white-space: nowrap">ssss ssss</tt>
| W8
| Sample (s)
|-
! $6A
| [[Hyper Voice#Hyper Voice Control|Hyper Voice Control]]
| style="text-align: right" | <tt style="white-space: nowrap">.mmc ???? errr ffss</tt>
| RW16
| Mask (m), Channel reset (c), Enable (e),
Rate (r), Format (f), Shift (s)
|-
! rowspan="8" | [[Display]]<sup>(SC)</sup>
! $70
| LCD Timing Configuration 1?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $71
| LCD Timing Configuration 2?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $72
| LCD Timing Configuration 3?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $73
| LCD Timing Configuration 4?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $74
| LCD Timing Configuration 5?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $75
| LCD Timing Configuration 6?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $76
| LCD Timing Configuration 7?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $77
| LCD Timing Configuration 8?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! rowspan="21" | [[Sound]]
! $80
| [[Sound#Sound Channel Frequency|Sound Channel 1 Frequency]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .ddd dddd dddd</tt>
| RW16
| Divider (d)
|-
! $82
| [[Sound#Sound Channel Frequency|Sound Channel 2 Frequency]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .ddd dddd dddd</tt>
| RW16
| Divider (d)
|-
! $84
| [[Sound#Sound Channel Frequency|Sound Channel 3 Frequency]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .ddd dddd dddd</tt>
| RW16
| Divider (d)
|-
! $86
| [[Sound#Sound Channel Frequency|Sound Channel 4 Frequency]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .ddd dddd dddd</tt>
| RW16
| Divider (d)
|-
! $88
| [[Sound#Sound Channel Volume|Sound Channel 1 Volume]]
| style="text-align: right" | <tt style="white-space: nowrap">llll rrrr</tt>
| RW8
| Left (l), Right (r)
|-
! rowspan="2" | $89
| [[Sound#Sound Channel Volume|Sound Channel 2 Volume]]
| style="text-align: right" | <tt style="white-space: nowrap">llll rrrr</tt>
| RW8
| Left (l), Right (r)
|-
| [[Sound#Sound Channel 2 Voice Sample|Sound Channel 2 Voice Sample]]
| style="text-align: right" | <tt style="white-space: nowrap">ssss ssss</tt>
| RW8
| Sample (s)
|-
! $8A
| [[Sound#Sound Channel Volume|Sound Channel 3 Volume]]
| style="text-align: right" | <tt style="white-space: nowrap">llll rrrr</tt>
| RW8
| Left (l), Right (r)
|-
! $8B
| [[Sound#Sound Channel Volume|Sound Channel 4 Volume]]
| style="text-align: right" | <tt style="white-space: nowrap">llll rrrr</tt>
| RW8
| Left (l), Right (r)
|-
! $8C
| [[Sound#Sound Channel 3 Sweep Amount|Sound Channel 3 Sweep Amount]]
| style="text-align: right" | <tt style="white-space: nowrap">vvvv vvvv</tt>
| RW8
| Value (v)
|-
! $8D
| [[Sound#Sound Channel 3 Sweep Ticks|Sound Channel 3 Sweep Ticks]]
| style="text-align: right" | <tt style="white-space: nowrap">...t tttt</tt>
| RW8
| Ticks (t)
|-
! $8E
| [[Sound#Sound Channel 4 Noise Control|Sound Channel 4 Noise Control]]
| style="text-align: right" | <tt style="white-space: nowrap">...e rttt</tt>
| RW8
| Enable (e), Reset (r), Tap (t)
|-
! $8F
| [[Sound#Sound Wavetable Address|Sound Wavetable Address]]
| style="text-align: right" | <tt style="white-space: nowrap">wwww wwww</tt>
| RW8
| Address >> 6 (w)
|-
! $90
| [[Sound#Sound Channel Control|Sound Channel Control]]
| style="text-align: right" | <tt style="white-space: nowrap">nsv. 4321</tt>
| RW8
| Channel enable (1234)
Noise (n), Sweep (s), Voice (v)
|-
! $91
| [[Sound#Sound Output Control|Sound Output Control]]
| style="text-align: right" | <tt style="white-space: nowrap">H... hrrs</tt>
| RW8
| Headphones connected (H)
Headphone output (h)
Speaker output (s), range (r)
|-
! $92
| [[Sound#Sound Channel 4 LFSR Register|Sound Channel 4 LFSR Register]]
| style="text-align: right" | <tt style="white-space: nowrap">.rrr rrrr rrrr rrrr</tt>
| R16
| PRNG state (r)
|-
! $94
| [[Sound#Sound Channel 2 Voice Volume|Sound Channel 2 Voice Volume]]
| style="text-align: right" | <tt style="white-space: nowrap">.... lLrR</tt>
| RW8
| Left Half (l), Full (L)
Right Half (r), Full (R)
|-
! $96
| Sound Channel Output Right
| style="text-align: right" | <tt style="white-space: nowrap">.... ..ss ssss ssss</tt>
| R16
| Sample (s)
|-
! $98
| Sound Channel Output Left
| style="text-align: right" | <tt style="white-space: nowrap">.... ..ss ssss ssss</tt>
| R16
| Sample (s)
|-
! $9A
| Sound Channel Output Sum
| style="text-align: right" | <tt style="white-space: nowrap">.... .sss ssss ssss</tt>
| R16
| Sample (s)
|-
! $9E
| Sound Speaker Master Volume<sup>(color)</sup>
| style="text-align: right" | <tt style="white-space: nowrap">.... ..vv</tt>
| RW8
| Master volume (v)
|-
! [[SoC]]
! $A0
| [[SoC#System Control|System Control]]
| style="text-align: right" | <tt style="white-space: nowrap">t??? swcl</tt>
| RW8
| Test OK (t), ROM wait state (s), ROM width (w),
Color system (c), Boot ROM lockout (l)
|-
! rowspan="5" | [[Timers]]
! $A2
| [[Timers#Timer Control|Timer Control]]
| style="text-align: right" | <tt style="white-space: nowrap">.... VvHh</tt>
| RW8
| Horizontal enable (h), auto reload (H)
Vertical enable (v), auto reload (V)
|-
! $A4
| [[Timers#Timer Reload|Horizontal Blank Timer Reload]]
| style="text-align: right" | <tt style="white-space: nowrap">tttt tttt tttt tttt</tt>
| RW16
| Ticks (t)
|-
! $A6
| [[Timers#Timer Reload|Vertical Blank Timer Reload]]
| style="text-align: right" | <tt style="white-space: nowrap">tttt tttt tttt tttt</tt>
| RW16
| Ticks (t)
|-
! $A8
| [[Timers#Timer Counter|Horizontal Blank Timer Counter]]
| style="text-align: right" | <tt style="white-space: nowrap">tttt tttt tttt tttt</tt>
| R16
| Ticks (t)
|-
! $AA
| [[Timers#Timer Counter|Vertical Blank Timer Counter]]
| style="text-align: right" | <tt style="white-space: nowrap">tttt tttt tttt tttt</tt>
| R16
| Ticks (t)
|-
! ?
! $AC
| ?
| style="text-align: right" | <tt style="white-space: nowrap">.... ...p</tt>
| W8?
| Power off (p)
|-
! rowspan="2" | [[Interrupts]]
! rowspan="2" | $B0
| [[Interrupts#Interrupt Vector Offset|Interrupt Vector Offset]]
| style="text-align: right" | <tt style="white-space: nowrap">VVVV V...</tt>
| W8
| Vector offset (V)
|-
| [[Interrupts#Interrupt Vector Request|Interrupt Vector Request]]
| style="text-align: right" | <tt style="white-space: nowrap">vvvv vvvv</tt>
| R8
| Requested vector offset (v)
|-
! rowspan="2" | [[UART]]
! $B1
| [[UART#Serial Receive Data|Serial Receive Data]]
| style="text-align: right" | <tt style="white-space: nowrap">dddd dddd</tt>
| R8
| Receive buffer data (d)
|-
! $B1
| [[UART#Serial Transmit Data|Serial Transmit Data]]
| style="text-align: right" | <tt style="white-space: nowrap">dddd dddd</tt>
| W8
| Transmit buffer data (d)
|-
! [[Interrupts]]
! $B2
| [[Interrupts#Interrupt Enable|Interrupt Enable]]
| iiii iiii
| RW8
| Interrupt index (i)
|-
! rowspan="2" | [[UART]]
! $B3
| [[UART#Serial Status|Serial Status]]
| style="text-align: right" | <tt style="white-space: nowrap">eb.. .tor</tt>
| R8
| Enable (e), Baud rate (b),
Transfer ready (t), Overrun (o), Receive ready (r)
|-
! $B3
| [[UART#Serial Control|Serial Control]]
| style="text-align: right" | <tt style="white-space: nowrap">ebO. ....</tt>
| W8
| Enable (e), Baud rate (b), Reset Overrun (O)
|-
! [[Interrupts]]
! $B4
| [[Interrupts#Interrupt Status|Interrupt Status]]
| iiii iiii
| R8
| Interrupt index (i)
|-
! [[Keypad]]
! $B5
| [[Keypad|Keypad Scan]]
| style="text-align: right" | <tt style="white-space: nowrap">.iii oooo</tt>
| RW8
| Input row (i), Output column (o)
|-
! rowspan="2" | [[Interrupts]]
! $B6
| [[Interrupts#Interrupt Acknowledge|Interrupt Acknowledge]]
| iiii iiii
| R8?
| Interrupt index (i)
|-
! $B7
| [[Interrupts#Interrupt NMI Control|Interrupt NMI Control]]
| style="text-align: right" | <tt style="white-space: nowrap">...b ....</tt>
| RW8
| Low battery (b)
|-
! rowspan="4" | [[EEPROM|Internal EEPROM]]
! $BA
| [[EEPROM#Internal EEPROM Data|Internal EEPROM Data]]
| style="text-align: right" | <tt style="white-space: nowrap">dddd dddd dddd dddd</tt>
| RW16
| Data (d)
|-
! $BC
| [[EEPROM#Internal EEPROM Command|Internal EEPROM Command]]
|
| RW16
|
|-
! rowspan="2" | $BE
| [[EEPROM#Internal EEPROM Status|Internal EEPROM Status]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .... p... ..RD</tt>
| R16
| Protected (p), Ready (R), Done (D)
|-
| [[EEPROM#Internal EEPROM Control|Internal EEPROM Control]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .... pewr ....</tt>
| W16
| Protect (p), Erase (e), Write (w), Read (r)
|-
! [[Mapper|Cartridge]]
! $C0<br />
$FF
| Cartridge I/O
|
| RW8
| Forwarded by the SoC
|}
== I/O port routing ==
The [[NEC V30MZ]] supports 16-bit I/O port addresses. The WonderSwan SoC routes them using the following algorithm:
* If an address is between <code>$00B8</code> and <code>$00BF</code> inclusive, it is routed to the internal EEPROM control block.
* If an address is between <code>$00C0</code> and <code>$00FF</code> inclusive, it is routed to the cartride bus.
* If an address's bits <code>0</code> through <code>8</code> inclusive are between <code>$000</code> and <code>$0B7</code> inclusive, they are routed to the SoC block.
* If none of these conditions are reached, open bus is read.
On the monochrome models, as well as color models in mono emulation, open bus is always <code>0x90</code>.
acbe4a04540381351636033517ccc736afe03d16
227
224
2023-08-30T18:43:00Z
Asie
351
document port $60 bit 3
wikitext
text/x-wiki
The WonderSwan SoC has three general blocks of I/O port accesses:
{| class="wikitable"
! From !! To !! Holder !! Width
|-
| $00 || $B7 || WonderSwan SoC || 8/16-bit
|-
| $B8 || $BF || Internal EEPROM control || 16-bit
|-
| $C0 || $FF || Cartridge bus || 8-bit
|}
With the exception of internal EEPROM on the ASWAN, all unaligned 16-bit accesses can be converted to two 8-bit accesses with a 1-cycle penalty.
== I/O port map ==
* Superscripts are used to mark ports specific to a given mode or platform:
** Color mode: <sup>(color)</sup>. Such ports are only accessible when color mode is enabled through port <code>$60</code>.
** WS/WSC/SC console: <sup>(WS)</sup>, <sup>(WSC)</sup>, <sup>(SC)</sup>.
* If two Bits rows are provided, the second one refers to the "Color" mode.
* The Type can be: R - readable, W - writable, L - writable before boot ROM lockout, 8/16 - width (byte/word).
{| class="wikitable"
! Category
! Port
! Description
! Bits
! Type
! Notes
|-
! rowspan="45" | [[Display]]
! $00
| [[Display#Display Control|Display Control]]
| style="text-align: right" | <tt style="white-space: nowrap">..ow Ws21</tt>
| RW8
|
|-
! $01
| [[Display#Display Background|Display Background]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .sss</tt>
<tt style="white-space: nowrap">pppp iiii</tt>
| RW8
| Shade (s)
Palette (p), Index (i)
|-
! $02
| [[Display#Current Line|Display Current Line]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll</tt>
| R8
| Line (l)
|-
! $03
| [[Display#Interrupt Line|Display Interrupt Line]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll</tt>
| RW8
| Line (l)
|-
! $04
| [[Display#Sprite Table Address|Sprite Table Address]]
| style="text-align: right" | <tt style="white-space: nowrap">...a aaaa</tt>
<tt style="white-space: nowrap">..aa aaaa</tt>
| RW8
| Address >> 9 (a)
|-
! $05
| [[Display#Sprite Table First|Sprite Table First]]
| style="text-align: right" | <tt style="white-space: nowrap">.iii iiii</tt>
| RW8
| Index (i)
|-
! $06
| [[Display#Sprite Table Count|Sprite Table Count]]
| style="text-align: right" | <tt style="white-space: nowrap">cccc cccc</tt>
| RW8
| Count (c)
|-
! $07
| [[Display#Screen Address|Screen Address]]
| style="text-align: right" | <tt style="white-space: nowrap">.222 .111</tt>
<tt style="white-space: nowrap">2222 1111</tt>
| RW8
| Screen 1 address >> 11 (1)
Screen 2 address >> 11 (2)
|-
! $08
| [[Display#Screen 2 Window|Screen 2 Window Left]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $09
| [[Display#Screen 2 Window|Screen 2 Window Top]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $0A
| [[Display#Screen 2 Window|Screen 2 Window Right]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $0B
| [[Display#Screen 2 Window|Screen 2 Window Bottom]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $0B
| [[Display#Sprite Window|Sprite Window Left]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $0C
| [[Display#Sprite Window|Sprite Window Top]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $0E
| [[Display#Sprite Window|Sprite Window Right]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $0F
| [[Display#Sprite Window|Sprite Window Bottom]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $10
| [[Display#Screen Scroll|Screen 1 Scroll X]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $11
| [[Display#Screen Scroll|Screen 1 Scroll Y]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $12
| [[Display#Screen Scroll|Screen 2 Scroll X]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $13
| [[Display#Screen Scroll|Screen 2 Scroll Y]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $14
| [[Display#LCD Control|LCD Control]]
| style="text-align: right" | <tt style="white-space: nowrap">.... ..Ce</tt>
| RW8
| Contrast (C)<sup>(WSC)</sup>, Enable (e)
|-
! $15
| [[Display#LCD Icon Control|LCD Icon Control]]
| style="text-align: right" | <tt style="white-space: nowrap">..32 1hvs</tt>
| RW8
| Auxillary 3 (3), Auxillary 2 (2), Auxillary 1 (1),
Horizontal (h), Vertical (v), Sleep (s)
|-
! $16
| [[Display#LCD Final Line|LCD Final Line]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll</tt>
| RW8
| Line (l)
|-
! $17
| [[Display#LCD Back Porch Line|LCD Back Porch Line]]<sup>(WSC)</sup>
| style="text-align: right" | <tt style="white-space: nowrap">llll llll</tt>
| RW8
| Line (l)
|-
! $1A
| [[Display#LCD Status|LCD Status]]
| style="text-align: right" | <tt style="white-space: nowrap">...v vv.s</tt>
| RW8
| Volume segment status (v), Sleep (s)
|-
! $1C
| [[Display#LCD Mono Shade LUT|LCD Mono Shade LUT 0/1]]
| style="text-align: right" | <tt style="white-space: nowrap">1111 0000</tt>
| RW8
| Shade index
|-
! $1D
| [[Display#LCD Mono Shade LUT|LCD Mono Shade LUT 2/3]]
| style="text-align: right" | <tt style="white-space: nowrap">3333 2222</tt>
| RW8
| Shade index
|-
! $1E
| [[Display#LCD Mono Shade LUT|LCD Mono Shade LUT 4/5]]
| style="text-align: right" | <tt style="white-space: nowrap">5555 4444</tt>
| RW8
| Shade index
|-
! $1F
| [[Display#LCD Mono Shade LUT|LCD Mono Shade LUT 6/7]]
| style="text-align: right" | <tt style="white-space: nowrap">7777 6666</tt>
| RW8
| Shade index
|-
! $20
| [[Display#LCD Mono Palette|LCD Mono Palette 0]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $22
| [[Display#LCD Mono Palette|LCD Mono Palette 1]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $24
| [[Display#LCD Mono Palette|LCD Mono Palette 2]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $26
| [[Display#LCD Mono Palette|LCD Mono Palette 3]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $28
| [[Display#LCD Mono Palette|LCD Mono Palette 4]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $2A
| [[Display#LCD Mono Palette|LCD Mono Palette 5]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $2C
| [[Display#LCD Mono Palette|LCD Mono Palette 6]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $2E
| [[Display#LCD Mono Palette|LCD Mono Palette 7]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $30
| [[Display#LCD Mono Palette|LCD Mono Palette 8]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $32
| [[Display#LCD Mono Palette|LCD Mono Palette 9]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $34
| [[Display#LCD Mono Palette|LCD Mono Palette 10]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $36
| [[Display#LCD Mono Palette|LCD Mono Palette 11]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $38
| [[Display#LCD Mono Palette|LCD Mono Palette 12]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $3A
| [[Display#LCD Mono Palette|LCD Mono Palette 13]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $3C
| [[Display#LCD Mono Palette|LCD Mono Palette 14]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $3E
| [[Display#LCD Mono Palette|LCD Mono Palette 15]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! rowspan="10" | [[DMA]]<sup>(color)</sup>
! $40
| [[DMA#General DMA|GDMA Source Address Low]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll llll llll</tt>
| RW16
| Linear address, low 16 bits (l)
|-
! $42
| [[DMA#General DMA|GDMA Source Address High]]
| style="text-align: right" | <tt style="white-space: nowrap">.... hhhh</tt>
| RW8
| Linear address, high 4 bits (h)
|-
! $44
| [[DMA#General DMA|GDMA Destination Address]]
| style="text-align: right" | <tt style="white-space: nowrap">aaaa aaaa aaaa aaaa</tt>
| RW16
| IRAM address (a)
|-
! $46
| [[DMA#General DMA|GDMA Length]]
| style="text-align: right" | <tt style="white-space: nowrap">bbbb bbbb bbbb bbbb</tt>
| RW16
| Bytes (b)
|-
! $48
| [[DMA#General DMA|GDMA Control]]
| style="text-align: right" | <tt style="white-space: nowrap">ed.. ....</tt>
| RW8
| Enable (e), Decrement (d)
|-
! $4A
| [[DMA#Sound DMA|SDMA Source Address Low]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll llll llll</tt>
| RW16
| Linear address, low 16 bits (l)
|-
! $4C
| [[DMA#Sound DMA|SDMA Source Address High]]
| style="text-align: right" | <tt style="white-space: nowrap">.... hhhh</tt>
| RW8
| Linear address, high 4 bits (h)
|-
! $4E
| [[DMA#Sound DMA|SDMA Length Low]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll llll llll</tt>
| RW16
| Length, low 16 bits (l)
|-
! $50
| [[DMA#Sound DMA|SDMA Length High]]
| style="text-align: right" | <tt style="white-space: nowrap">.... hhhh</tt>
| RW8
| Length, high 4 bits (h)
|-
! $52
| [[DMA#Sound DMA|SDMA Control]]
| style="text-align: right" | <tt style="white-space: nowrap">ed.t r?ff</tt>
| RW8
| Enable (e), Decrement (d), Target (t),
Repeat (r), Frequency (f)
|-
! rowspan="2" | [[SoC]]<sup>(color)</sup>
! $60
| [[SoC#System Control 2|System Control 2]]
| style="text-align: right" | <tt style="white-space: nowrap">c4C. i?s?</tt>
| RW8
| Color (c), 4BPP (4), Chunky (C)<br/>
I/O wait state (i), SRAM wait state (s)
|-
! $62
| [[SoC#System Control 3|System Control 3]]
| style="text-align: right" | <tt style="white-space: nowrap">S... ...p</tt>
| RW8
| SwanCrystal (S), Power off (p)
|-
! rowspan="5" | [[Hyper Voice]]<sup>(color)</sup>
! $64
| [[Hyper Voice#Hyper Voice Output|Hyper Voice Left Output]]
| style="text-align: right" | <tt style="white-space: nowrap">ssss ssss ssss ssss</tt>
| W16
| Raw sample (s)
|-
! $66
| [[Hyper Voice#Hyper Voice Output|Hyper Voice Right Output]]
| style="text-align: right" | <tt style="white-space: nowrap">ssss ssss ssss ssss</tt>
| W16
| Raw sample (s)
|-
! $68
| [[Hyper Voice#Hyper Voice Input|Hyper Voice Left Input]]
| style="text-align: right" | <tt style="white-space: nowrap">ssss ssss</tt>
| W8
| Sample (s)
|-
! $69
| [[Hyper Voice#Hyper Voice Input|Hyper Voice Right Input]]
| style="text-align: right" | <tt style="white-space: nowrap">ssss ssss</tt>
| W8
| Sample (s)
|-
! $6A
| [[Hyper Voice#Hyper Voice Control|Hyper Voice Control]]
| style="text-align: right" | <tt style="white-space: nowrap">.mmc ???? errr ffss</tt>
| RW16
| Mask (m), Channel reset (c), Enable (e),
Rate (r), Format (f), Shift (s)
|-
! rowspan="8" | [[Display]]<sup>(SC)</sup>
! $70
| LCD Timing Configuration 1?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $71
| LCD Timing Configuration 2?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $72
| LCD Timing Configuration 3?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $73
| LCD Timing Configuration 4?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $74
| LCD Timing Configuration 5?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $75
| LCD Timing Configuration 6?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $76
| LCD Timing Configuration 7?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $77
| LCD Timing Configuration 8?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! rowspan="21" | [[Sound]]
! $80
| [[Sound#Sound Channel Frequency|Sound Channel 1 Frequency]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .ddd dddd dddd</tt>
| RW16
| Divider (d)
|-
! $82
| [[Sound#Sound Channel Frequency|Sound Channel 2 Frequency]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .ddd dddd dddd</tt>
| RW16
| Divider (d)
|-
! $84
| [[Sound#Sound Channel Frequency|Sound Channel 3 Frequency]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .ddd dddd dddd</tt>
| RW16
| Divider (d)
|-
! $86
| [[Sound#Sound Channel Frequency|Sound Channel 4 Frequency]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .ddd dddd dddd</tt>
| RW16
| Divider (d)
|-
! $88
| [[Sound#Sound Channel Volume|Sound Channel 1 Volume]]
| style="text-align: right" | <tt style="white-space: nowrap">llll rrrr</tt>
| RW8
| Left (l), Right (r)
|-
! rowspan="2" | $89
| [[Sound#Sound Channel Volume|Sound Channel 2 Volume]]
| style="text-align: right" | <tt style="white-space: nowrap">llll rrrr</tt>
| RW8
| Left (l), Right (r)
|-
| [[Sound#Sound Channel 2 Voice Sample|Sound Channel 2 Voice Sample]]
| style="text-align: right" | <tt style="white-space: nowrap">ssss ssss</tt>
| RW8
| Sample (s)
|-
! $8A
| [[Sound#Sound Channel Volume|Sound Channel 3 Volume]]
| style="text-align: right" | <tt style="white-space: nowrap">llll rrrr</tt>
| RW8
| Left (l), Right (r)
|-
! $8B
| [[Sound#Sound Channel Volume|Sound Channel 4 Volume]]
| style="text-align: right" | <tt style="white-space: nowrap">llll rrrr</tt>
| RW8
| Left (l), Right (r)
|-
! $8C
| [[Sound#Sound Channel 3 Sweep Amount|Sound Channel 3 Sweep Amount]]
| style="text-align: right" | <tt style="white-space: nowrap">vvvv vvvv</tt>
| RW8
| Value (v)
|-
! $8D
| [[Sound#Sound Channel 3 Sweep Ticks|Sound Channel 3 Sweep Ticks]]
| style="text-align: right" | <tt style="white-space: nowrap">...t tttt</tt>
| RW8
| Ticks (t)
|-
! $8E
| [[Sound#Sound Channel 4 Noise Control|Sound Channel 4 Noise Control]]
| style="text-align: right" | <tt style="white-space: nowrap">...e rttt</tt>
| RW8
| Enable (e), Reset (r), Tap (t)
|-
! $8F
| [[Sound#Sound Wavetable Address|Sound Wavetable Address]]
| style="text-align: right" | <tt style="white-space: nowrap">wwww wwww</tt>
| RW8
| Address >> 6 (w)
|-
! $90
| [[Sound#Sound Channel Control|Sound Channel Control]]
| style="text-align: right" | <tt style="white-space: nowrap">nsv. 4321</tt>
| RW8
| Channel enable (1234)
Noise (n), Sweep (s), Voice (v)
|-
! $91
| [[Sound#Sound Output Control|Sound Output Control]]
| style="text-align: right" | <tt style="white-space: nowrap">H... hrrs</tt>
| RW8
| Headphones connected (H)
Headphone output (h)
Speaker output (s), range (r)
|-
! $92
| [[Sound#Sound Channel 4 LFSR Register|Sound Channel 4 LFSR Register]]
| style="text-align: right" | <tt style="white-space: nowrap">.rrr rrrr rrrr rrrr</tt>
| R16
| PRNG state (r)
|-
! $94
| [[Sound#Sound Channel 2 Voice Volume|Sound Channel 2 Voice Volume]]
| style="text-align: right" | <tt style="white-space: nowrap">.... lLrR</tt>
| RW8
| Left Half (l), Full (L)
Right Half (r), Full (R)
|-
! $96
| Sound Channel Output Right
| style="text-align: right" | <tt style="white-space: nowrap">.... ..ss ssss ssss</tt>
| R16
| Sample (s)
|-
! $98
| Sound Channel Output Left
| style="text-align: right" | <tt style="white-space: nowrap">.... ..ss ssss ssss</tt>
| R16
| Sample (s)
|-
! $9A
| Sound Channel Output Sum
| style="text-align: right" | <tt style="white-space: nowrap">.... .sss ssss ssss</tt>
| R16
| Sample (s)
|-
! $9E
| Sound Speaker Master Volume<sup>(color)</sup>
| style="text-align: right" | <tt style="white-space: nowrap">.... ..vv</tt>
| RW8
| Master volume (v)
|-
! [[SoC]]
! $A0
| [[SoC#System Control|System Control]]
| style="text-align: right" | <tt style="white-space: nowrap">t??? swcl</tt>
| RW8
| Test OK (t), ROM wait state (s), ROM width (w),
Color system (c), Boot ROM lockout (l)
|-
! rowspan="5" | [[Timers]]
! $A2
| [[Timers#Timer Control|Timer Control]]
| style="text-align: right" | <tt style="white-space: nowrap">.... VvHh</tt>
| RW8
| Horizontal enable (h), auto reload (H)
Vertical enable (v), auto reload (V)
|-
! $A4
| [[Timers#Timer Reload|Horizontal Blank Timer Reload]]
| style="text-align: right" | <tt style="white-space: nowrap">tttt tttt tttt tttt</tt>
| RW16
| Ticks (t)
|-
! $A6
| [[Timers#Timer Reload|Vertical Blank Timer Reload]]
| style="text-align: right" | <tt style="white-space: nowrap">tttt tttt tttt tttt</tt>
| RW16
| Ticks (t)
|-
! $A8
| [[Timers#Timer Counter|Horizontal Blank Timer Counter]]
| style="text-align: right" | <tt style="white-space: nowrap">tttt tttt tttt tttt</tt>
| R16
| Ticks (t)
|-
! $AA
| [[Timers#Timer Counter|Vertical Blank Timer Counter]]
| style="text-align: right" | <tt style="white-space: nowrap">tttt tttt tttt tttt</tt>
| R16
| Ticks (t)
|-
! ?
! $AC
| ?
| style="text-align: right" | <tt style="white-space: nowrap">.... ...p</tt>
| W8?
| Power off (p)
|-
! rowspan="2" | [[Interrupts]]
! rowspan="2" | $B0
| [[Interrupts#Interrupt Vector Offset|Interrupt Vector Offset]]
| style="text-align: right" | <tt style="white-space: nowrap">VVVV V...</tt>
| W8
| Vector offset (V)
|-
| [[Interrupts#Interrupt Vector Request|Interrupt Vector Request]]
| style="text-align: right" | <tt style="white-space: nowrap">vvvv vvvv</tt>
| R8
| Requested vector offset (v)
|-
! rowspan="2" | [[UART]]
! $B1
| [[UART#Serial Receive Data|Serial Receive Data]]
| style="text-align: right" | <tt style="white-space: nowrap">dddd dddd</tt>
| R8
| Receive buffer data (d)
|-
! $B1
| [[UART#Serial Transmit Data|Serial Transmit Data]]
| style="text-align: right" | <tt style="white-space: nowrap">dddd dddd</tt>
| W8
| Transmit buffer data (d)
|-
! [[Interrupts]]
! $B2
| [[Interrupts#Interrupt Enable|Interrupt Enable]]
| iiii iiii
| RW8
| Interrupt index (i)
|-
! rowspan="2" | [[UART]]
! $B3
| [[UART#Serial Status|Serial Status]]
| style="text-align: right" | <tt style="white-space: nowrap">eb.. .tor</tt>
| R8
| Enable (e), Baud rate (b),
Transfer ready (t), Overrun (o), Receive ready (r)
|-
! $B3
| [[UART#Serial Control|Serial Control]]
| style="text-align: right" | <tt style="white-space: nowrap">ebO. ....</tt>
| W8
| Enable (e), Baud rate (b), Reset Overrun (O)
|-
! [[Interrupts]]
! $B4
| [[Interrupts#Interrupt Status|Interrupt Status]]
| iiii iiii
| R8
| Interrupt index (i)
|-
! [[Keypad]]
! $B5
| [[Keypad|Keypad Scan]]
| style="text-align: right" | <tt style="white-space: nowrap">.iii oooo</tt>
| RW8
| Input row (i), Output column (o)
|-
! rowspan="2" | [[Interrupts]]
! $B6
| [[Interrupts#Interrupt Acknowledge|Interrupt Acknowledge]]
| iiii iiii
| R8?
| Interrupt index (i)
|-
! $B7
| [[Interrupts#Interrupt NMI Control|Interrupt NMI Control]]
| style="text-align: right" | <tt style="white-space: nowrap">...b ....</tt>
| RW8
| Low battery (b)
|-
! rowspan="4" | [[EEPROM|Internal EEPROM]]
! $BA
| [[EEPROM#Internal EEPROM Data|Internal EEPROM Data]]
| style="text-align: right" | <tt style="white-space: nowrap">dddd dddd dddd dddd</tt>
| RW16
| Data (d)
|-
! $BC
| [[EEPROM#Internal EEPROM Command|Internal EEPROM Command]]
|
| RW16
|
|-
! rowspan="2" | $BE
| [[EEPROM#Internal EEPROM Status|Internal EEPROM Status]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .... p... ..RD</tt>
| R16
| Protected (p), Ready (R), Done (D)
|-
| [[EEPROM#Internal EEPROM Control|Internal EEPROM Control]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .... pewr ....</tt>
| W16
| Protect (p), Erase (e), Write (w), Read (r)
|-
! [[Mapper|Cartridge]]
! $C0<br />
$FF
| Cartridge I/O
|
| RW8
| Forwarded by the SoC
|}
== I/O port routing ==
The [[NEC V30MZ]] supports 16-bit I/O port addresses. The WonderSwan SoC routes them using the following algorithm:
* If an address is between <code>$00B8</code> and <code>$00BF</code> inclusive, it is routed to the internal EEPROM control block.
* If an address is between <code>$00C0</code> and <code>$00FF</code> inclusive, it is routed to the cartride bus.
* If an address's bits <code>0</code> through <code>8</code> inclusive are between <code>$000</code> and <code>$0B7</code> inclusive, they are routed to the SoC block.
* If none of these conditions are reached, open bus is read.
On the monochrome models, as well as color models in mono emulation, open bus is always <code>0x90</code>.
1ff6d7864fdc7a6652746bc1840fe01edbc14fff
228
227
2023-08-30T18:45:37Z
Asie
351
wikitext
text/x-wiki
The WonderSwan SoC has three general blocks of I/O port accesses:
{| class="wikitable"
! From !! To !! Holder !! Width !! Speed
|-
| $00 || $B7 || WonderSwan SoC || 16-bit || 1 cycle
|-
| $B8 || $BF || Internal EEPROM control || 16-bit || 1 cycle
|-
| $C0 || $FF || Cartridge bus || 8-bit || 1<sup>(color)</sup>/2 cycles (configurable)
|}
With the exception of internal EEPROM on the ASWAN, all unaligned 16-bit accesses can be converted to two 8-bit accesses with a 1-cycle penalty.
== I/O port map ==
* Superscripts are used to mark ports specific to a given mode or platform:
** Color mode: <sup>(color)</sup>. Such ports are only accessible when color mode is enabled through port <code>$60</code>.
** WS/WSC/SC console: <sup>(WS)</sup>, <sup>(WSC)</sup>, <sup>(SC)</sup>.
* If two Bits rows are provided, the second one refers to the "Color" mode.
* The Type can be: R - readable, W - writable, L - writable before boot ROM lockout, 8/16 - width (byte/word).
{| class="wikitable"
! Category
! Port
! Description
! Bits
! Type
! Notes
|-
! rowspan="45" | [[Display]]
! $00
| [[Display#Display Control|Display Control]]
| style="text-align: right" | <tt style="white-space: nowrap">..ow Ws21</tt>
| RW8
|
|-
! $01
| [[Display#Display Background|Display Background]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .sss</tt>
<tt style="white-space: nowrap">pppp iiii</tt>
| RW8
| Shade (s)
Palette (p), Index (i)
|-
! $02
| [[Display#Current Line|Display Current Line]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll</tt>
| R8
| Line (l)
|-
! $03
| [[Display#Interrupt Line|Display Interrupt Line]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll</tt>
| RW8
| Line (l)
|-
! $04
| [[Display#Sprite Table Address|Sprite Table Address]]
| style="text-align: right" | <tt style="white-space: nowrap">...a aaaa</tt>
<tt style="white-space: nowrap">..aa aaaa</tt>
| RW8
| Address >> 9 (a)
|-
! $05
| [[Display#Sprite Table First|Sprite Table First]]
| style="text-align: right" | <tt style="white-space: nowrap">.iii iiii</tt>
| RW8
| Index (i)
|-
! $06
| [[Display#Sprite Table Count|Sprite Table Count]]
| style="text-align: right" | <tt style="white-space: nowrap">cccc cccc</tt>
| RW8
| Count (c)
|-
! $07
| [[Display#Screen Address|Screen Address]]
| style="text-align: right" | <tt style="white-space: nowrap">.222 .111</tt>
<tt style="white-space: nowrap">2222 1111</tt>
| RW8
| Screen 1 address >> 11 (1)
Screen 2 address >> 11 (2)
|-
! $08
| [[Display#Screen 2 Window|Screen 2 Window Left]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $09
| [[Display#Screen 2 Window|Screen 2 Window Top]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $0A
| [[Display#Screen 2 Window|Screen 2 Window Right]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $0B
| [[Display#Screen 2 Window|Screen 2 Window Bottom]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $0B
| [[Display#Sprite Window|Sprite Window Left]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $0C
| [[Display#Sprite Window|Sprite Window Top]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $0E
| [[Display#Sprite Window|Sprite Window Right]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $0F
| [[Display#Sprite Window|Sprite Window Bottom]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $10
| [[Display#Screen Scroll|Screen 1 Scroll X]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $11
| [[Display#Screen Scroll|Screen 1 Scroll Y]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $12
| [[Display#Screen Scroll|Screen 2 Scroll X]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $13
| [[Display#Screen Scroll|Screen 2 Scroll Y]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $14
| [[Display#LCD Control|LCD Control]]
| style="text-align: right" | <tt style="white-space: nowrap">.... ..Ce</tt>
| RW8
| Contrast (C)<sup>(WSC)</sup>, Enable (e)
|-
! $15
| [[Display#LCD Icon Control|LCD Icon Control]]
| style="text-align: right" | <tt style="white-space: nowrap">..32 1hvs</tt>
| RW8
| Auxillary 3 (3), Auxillary 2 (2), Auxillary 1 (1),
Horizontal (h), Vertical (v), Sleep (s)
|-
! $16
| [[Display#LCD Final Line|LCD Final Line]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll</tt>
| RW8
| Line (l)
|-
! $17
| [[Display#LCD Back Porch Line|LCD Back Porch Line]]<sup>(WSC)</sup>
| style="text-align: right" | <tt style="white-space: nowrap">llll llll</tt>
| RW8
| Line (l)
|-
! $1A
| [[Display#LCD Status|LCD Status]]
| style="text-align: right" | <tt style="white-space: nowrap">...v vv.s</tt>
| RW8
| Volume segment status (v), Sleep (s)
|-
! $1C
| [[Display#LCD Mono Shade LUT|LCD Mono Shade LUT 0/1]]
| style="text-align: right" | <tt style="white-space: nowrap">1111 0000</tt>
| RW8
| Shade index
|-
! $1D
| [[Display#LCD Mono Shade LUT|LCD Mono Shade LUT 2/3]]
| style="text-align: right" | <tt style="white-space: nowrap">3333 2222</tt>
| RW8
| Shade index
|-
! $1E
| [[Display#LCD Mono Shade LUT|LCD Mono Shade LUT 4/5]]
| style="text-align: right" | <tt style="white-space: nowrap">5555 4444</tt>
| RW8
| Shade index
|-
! $1F
| [[Display#LCD Mono Shade LUT|LCD Mono Shade LUT 6/7]]
| style="text-align: right" | <tt style="white-space: nowrap">7777 6666</tt>
| RW8
| Shade index
|-
! $20
| [[Display#LCD Mono Palette|LCD Mono Palette 0]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $22
| [[Display#LCD Mono Palette|LCD Mono Palette 1]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $24
| [[Display#LCD Mono Palette|LCD Mono Palette 2]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $26
| [[Display#LCD Mono Palette|LCD Mono Palette 3]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $28
| [[Display#LCD Mono Palette|LCD Mono Palette 4]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $2A
| [[Display#LCD Mono Palette|LCD Mono Palette 5]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $2C
| [[Display#LCD Mono Palette|LCD Mono Palette 6]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $2E
| [[Display#LCD Mono Palette|LCD Mono Palette 7]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $30
| [[Display#LCD Mono Palette|LCD Mono Palette 8]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $32
| [[Display#LCD Mono Palette|LCD Mono Palette 9]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $34
| [[Display#LCD Mono Palette|LCD Mono Palette 10]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $36
| [[Display#LCD Mono Palette|LCD Mono Palette 11]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $38
| [[Display#LCD Mono Palette|LCD Mono Palette 12]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $3A
| [[Display#LCD Mono Palette|LCD Mono Palette 13]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $3C
| [[Display#LCD Mono Palette|LCD Mono Palette 14]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $3E
| [[Display#LCD Mono Palette|LCD Mono Palette 15]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! rowspan="10" | [[DMA]]<sup>(color)</sup>
! $40
| [[DMA#General DMA|GDMA Source Address Low]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll llll llll</tt>
| RW16
| Linear address, low 16 bits (l)
|-
! $42
| [[DMA#General DMA|GDMA Source Address High]]
| style="text-align: right" | <tt style="white-space: nowrap">.... hhhh</tt>
| RW8
| Linear address, high 4 bits (h)
|-
! $44
| [[DMA#General DMA|GDMA Destination Address]]
| style="text-align: right" | <tt style="white-space: nowrap">aaaa aaaa aaaa aaaa</tt>
| RW16
| IRAM address (a)
|-
! $46
| [[DMA#General DMA|GDMA Length]]
| style="text-align: right" | <tt style="white-space: nowrap">bbbb bbbb bbbb bbbb</tt>
| RW16
| Bytes (b)
|-
! $48
| [[DMA#General DMA|GDMA Control]]
| style="text-align: right" | <tt style="white-space: nowrap">ed.. ....</tt>
| RW8
| Enable (e), Decrement (d)
|-
! $4A
| [[DMA#Sound DMA|SDMA Source Address Low]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll llll llll</tt>
| RW16
| Linear address, low 16 bits (l)
|-
! $4C
| [[DMA#Sound DMA|SDMA Source Address High]]
| style="text-align: right" | <tt style="white-space: nowrap">.... hhhh</tt>
| RW8
| Linear address, high 4 bits (h)
|-
! $4E
| [[DMA#Sound DMA|SDMA Length Low]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll llll llll</tt>
| RW16
| Length, low 16 bits (l)
|-
! $50
| [[DMA#Sound DMA|SDMA Length High]]
| style="text-align: right" | <tt style="white-space: nowrap">.... hhhh</tt>
| RW8
| Length, high 4 bits (h)
|-
! $52
| [[DMA#Sound DMA|SDMA Control]]
| style="text-align: right" | <tt style="white-space: nowrap">ed.t r?ff</tt>
| RW8
| Enable (e), Decrement (d), Target (t),
Repeat (r), Frequency (f)
|-
! rowspan="2" | [[SoC]]<sup>(color)</sup>
! $60
| [[SoC#System Control 2|System Control 2]]
| style="text-align: right" | <tt style="white-space: nowrap">c4C. i?s?</tt>
| RW8
| Color (c), 4BPP (4), Chunky (C)<br/>
I/O wait state (i), SRAM wait state (s)
|-
! $62
| [[SoC#System Control 3|System Control 3]]
| style="text-align: right" | <tt style="white-space: nowrap">S... ...p</tt>
| RW8
| SwanCrystal (S), Power off (p)
|-
! rowspan="5" | [[Hyper Voice]]<sup>(color)</sup>
! $64
| [[Hyper Voice#Hyper Voice Output|Hyper Voice Left Output]]
| style="text-align: right" | <tt style="white-space: nowrap">ssss ssss ssss ssss</tt>
| W16
| Raw sample (s)
|-
! $66
| [[Hyper Voice#Hyper Voice Output|Hyper Voice Right Output]]
| style="text-align: right" | <tt style="white-space: nowrap">ssss ssss ssss ssss</tt>
| W16
| Raw sample (s)
|-
! $68
| [[Hyper Voice#Hyper Voice Input|Hyper Voice Left Input]]
| style="text-align: right" | <tt style="white-space: nowrap">ssss ssss</tt>
| W8
| Sample (s)
|-
! $69
| [[Hyper Voice#Hyper Voice Input|Hyper Voice Right Input]]
| style="text-align: right" | <tt style="white-space: nowrap">ssss ssss</tt>
| W8
| Sample (s)
|-
! $6A
| [[Hyper Voice#Hyper Voice Control|Hyper Voice Control]]
| style="text-align: right" | <tt style="white-space: nowrap">.mmc ???? errr ffss</tt>
| RW16
| Mask (m), Channel reset (c), Enable (e),
Rate (r), Format (f), Shift (s)
|-
! rowspan="8" | [[Display]]<sup>(SC)</sup>
! $70
| LCD Timing Configuration 1?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $71
| LCD Timing Configuration 2?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $72
| LCD Timing Configuration 3?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $73
| LCD Timing Configuration 4?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $74
| LCD Timing Configuration 5?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $75
| LCD Timing Configuration 6?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $76
| LCD Timing Configuration 7?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $77
| LCD Timing Configuration 8?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! rowspan="21" | [[Sound]]
! $80
| [[Sound#Sound Channel Frequency|Sound Channel 1 Frequency]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .ddd dddd dddd</tt>
| RW16
| Divider (d)
|-
! $82
| [[Sound#Sound Channel Frequency|Sound Channel 2 Frequency]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .ddd dddd dddd</tt>
| RW16
| Divider (d)
|-
! $84
| [[Sound#Sound Channel Frequency|Sound Channel 3 Frequency]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .ddd dddd dddd</tt>
| RW16
| Divider (d)
|-
! $86
| [[Sound#Sound Channel Frequency|Sound Channel 4 Frequency]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .ddd dddd dddd</tt>
| RW16
| Divider (d)
|-
! $88
| [[Sound#Sound Channel Volume|Sound Channel 1 Volume]]
| style="text-align: right" | <tt style="white-space: nowrap">llll rrrr</tt>
| RW8
| Left (l), Right (r)
|-
! rowspan="2" | $89
| [[Sound#Sound Channel Volume|Sound Channel 2 Volume]]
| style="text-align: right" | <tt style="white-space: nowrap">llll rrrr</tt>
| RW8
| Left (l), Right (r)
|-
| [[Sound#Sound Channel 2 Voice Sample|Sound Channel 2 Voice Sample]]
| style="text-align: right" | <tt style="white-space: nowrap">ssss ssss</tt>
| RW8
| Sample (s)
|-
! $8A
| [[Sound#Sound Channel Volume|Sound Channel 3 Volume]]
| style="text-align: right" | <tt style="white-space: nowrap">llll rrrr</tt>
| RW8
| Left (l), Right (r)
|-
! $8B
| [[Sound#Sound Channel Volume|Sound Channel 4 Volume]]
| style="text-align: right" | <tt style="white-space: nowrap">llll rrrr</tt>
| RW8
| Left (l), Right (r)
|-
! $8C
| [[Sound#Sound Channel 3 Sweep Amount|Sound Channel 3 Sweep Amount]]
| style="text-align: right" | <tt style="white-space: nowrap">vvvv vvvv</tt>
| RW8
| Value (v)
|-
! $8D
| [[Sound#Sound Channel 3 Sweep Ticks|Sound Channel 3 Sweep Ticks]]
| style="text-align: right" | <tt style="white-space: nowrap">...t tttt</tt>
| RW8
| Ticks (t)
|-
! $8E
| [[Sound#Sound Channel 4 Noise Control|Sound Channel 4 Noise Control]]
| style="text-align: right" | <tt style="white-space: nowrap">...e rttt</tt>
| RW8
| Enable (e), Reset (r), Tap (t)
|-
! $8F
| [[Sound#Sound Wavetable Address|Sound Wavetable Address]]
| style="text-align: right" | <tt style="white-space: nowrap">wwww wwww</tt>
| RW8
| Address >> 6 (w)
|-
! $90
| [[Sound#Sound Channel Control|Sound Channel Control]]
| style="text-align: right" | <tt style="white-space: nowrap">nsv. 4321</tt>
| RW8
| Channel enable (1234)
Noise (n), Sweep (s), Voice (v)
|-
! $91
| [[Sound#Sound Output Control|Sound Output Control]]
| style="text-align: right" | <tt style="white-space: nowrap">H... hrrs</tt>
| RW8
| Headphones connected (H)
Headphone output (h)
Speaker output (s), range (r)
|-
! $92
| [[Sound#Sound Channel 4 LFSR Register|Sound Channel 4 LFSR Register]]
| style="text-align: right" | <tt style="white-space: nowrap">.rrr rrrr rrrr rrrr</tt>
| R16
| PRNG state (r)
|-
! $94
| [[Sound#Sound Channel 2 Voice Volume|Sound Channel 2 Voice Volume]]
| style="text-align: right" | <tt style="white-space: nowrap">.... lLrR</tt>
| RW8
| Left Half (l), Full (L)
Right Half (r), Full (R)
|-
! $96
| Sound Channel Output Right
| style="text-align: right" | <tt style="white-space: nowrap">.... ..ss ssss ssss</tt>
| R16
| Sample (s)
|-
! $98
| Sound Channel Output Left
| style="text-align: right" | <tt style="white-space: nowrap">.... ..ss ssss ssss</tt>
| R16
| Sample (s)
|-
! $9A
| Sound Channel Output Sum
| style="text-align: right" | <tt style="white-space: nowrap">.... .sss ssss ssss</tt>
| R16
| Sample (s)
|-
! $9E
| Sound Speaker Master Volume<sup>(color)</sup>
| style="text-align: right" | <tt style="white-space: nowrap">.... ..vv</tt>
| RW8
| Master volume (v)
|-
! [[SoC]]
! $A0
| [[SoC#System Control|System Control]]
| style="text-align: right" | <tt style="white-space: nowrap">t??? swcl</tt>
| RW8
| Test OK (t), ROM wait state (s), ROM width (w),
Color system (c), Boot ROM lockout (l)
|-
! rowspan="5" | [[Timers]]
! $A2
| [[Timers#Timer Control|Timer Control]]
| style="text-align: right" | <tt style="white-space: nowrap">.... VvHh</tt>
| RW8
| Horizontal enable (h), auto reload (H)
Vertical enable (v), auto reload (V)
|-
! $A4
| [[Timers#Timer Reload|Horizontal Blank Timer Reload]]
| style="text-align: right" | <tt style="white-space: nowrap">tttt tttt tttt tttt</tt>
| RW16
| Ticks (t)
|-
! $A6
| [[Timers#Timer Reload|Vertical Blank Timer Reload]]
| style="text-align: right" | <tt style="white-space: nowrap">tttt tttt tttt tttt</tt>
| RW16
| Ticks (t)
|-
! $A8
| [[Timers#Timer Counter|Horizontal Blank Timer Counter]]
| style="text-align: right" | <tt style="white-space: nowrap">tttt tttt tttt tttt</tt>
| R16
| Ticks (t)
|-
! $AA
| [[Timers#Timer Counter|Vertical Blank Timer Counter]]
| style="text-align: right" | <tt style="white-space: nowrap">tttt tttt tttt tttt</tt>
| R16
| Ticks (t)
|-
! ?
! $AC
| ?
| style="text-align: right" | <tt style="white-space: nowrap">.... ...p</tt>
| W8?
| Power off (p)
|-
! rowspan="2" | [[Interrupts]]
! rowspan="2" | $B0
| [[Interrupts#Interrupt Vector Offset|Interrupt Vector Offset]]
| style="text-align: right" | <tt style="white-space: nowrap">VVVV V...</tt>
| W8
| Vector offset (V)
|-
| [[Interrupts#Interrupt Vector Request|Interrupt Vector Request]]
| style="text-align: right" | <tt style="white-space: nowrap">vvvv vvvv</tt>
| R8
| Requested vector offset (v)
|-
! rowspan="2" | [[UART]]
! $B1
| [[UART#Serial Receive Data|Serial Receive Data]]
| style="text-align: right" | <tt style="white-space: nowrap">dddd dddd</tt>
| R8
| Receive buffer data (d)
|-
! $B1
| [[UART#Serial Transmit Data|Serial Transmit Data]]
| style="text-align: right" | <tt style="white-space: nowrap">dddd dddd</tt>
| W8
| Transmit buffer data (d)
|-
! [[Interrupts]]
! $B2
| [[Interrupts#Interrupt Enable|Interrupt Enable]]
| iiii iiii
| RW8
| Interrupt index (i)
|-
! rowspan="2" | [[UART]]
! $B3
| [[UART#Serial Status|Serial Status]]
| style="text-align: right" | <tt style="white-space: nowrap">eb.. .tor</tt>
| R8
| Enable (e), Baud rate (b),
Transfer ready (t), Overrun (o), Receive ready (r)
|-
! $B3
| [[UART#Serial Control|Serial Control]]
| style="text-align: right" | <tt style="white-space: nowrap">ebO. ....</tt>
| W8
| Enable (e), Baud rate (b), Reset Overrun (O)
|-
! [[Interrupts]]
! $B4
| [[Interrupts#Interrupt Status|Interrupt Status]]
| iiii iiii
| R8
| Interrupt index (i)
|-
! [[Keypad]]
! $B5
| [[Keypad|Keypad Scan]]
| style="text-align: right" | <tt style="white-space: nowrap">.iii oooo</tt>
| RW8
| Input row (i), Output column (o)
|-
! rowspan="2" | [[Interrupts]]
! $B6
| [[Interrupts#Interrupt Acknowledge|Interrupt Acknowledge]]
| iiii iiii
| R8?
| Interrupt index (i)
|-
! $B7
| [[Interrupts#Interrupt NMI Control|Interrupt NMI Control]]
| style="text-align: right" | <tt style="white-space: nowrap">...b ....</tt>
| RW8
| Low battery (b)
|-
! rowspan="4" | [[EEPROM|Internal EEPROM]]
! $BA
| [[EEPROM#Internal EEPROM Data|Internal EEPROM Data]]
| style="text-align: right" | <tt style="white-space: nowrap">dddd dddd dddd dddd</tt>
| RW16
| Data (d)
|-
! $BC
| [[EEPROM#Internal EEPROM Command|Internal EEPROM Command]]
|
| RW16
|
|-
! rowspan="2" | $BE
| [[EEPROM#Internal EEPROM Status|Internal EEPROM Status]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .... p... ..RD</tt>
| R16
| Protected (p), Ready (R), Done (D)
|-
| [[EEPROM#Internal EEPROM Control|Internal EEPROM Control]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .... pewr ....</tt>
| W16
| Protect (p), Erase (e), Write (w), Read (r)
|-
! [[Mapper|Cartridge]]
! $C0<br />
$FF
| Cartridge I/O
|
| RW8
| Forwarded by the SoC
|}
== I/O port routing ==
The [[NEC V30MZ]] supports 16-bit I/O port addresses. The WonderSwan SoC routes them using the following algorithm:
* If an address is between <code>$00B8</code> and <code>$00BF</code> inclusive, it is routed to the internal EEPROM control block.
* If an address is between <code>$00C0</code> and <code>$00FF</code> inclusive, it is routed to the cartride bus.
* If an address's bits <code>0</code> through <code>8</code> inclusive are between <code>$000</code> and <code>$0B7</code> inclusive, they are routed to the SoC block.
* If none of these conditions are reached, open bus is read.
On the monochrome models, as well as color models in mono emulation, open bus is always <code>0x90</code>.
ddc304c397ddd81ae7a23270104150c941efb010
230
228
2023-08-30T20:39:20Z
Asie
351
adjust GDMA ports
wikitext
text/x-wiki
The WonderSwan SoC has three general blocks of I/O port accesses:
{| class="wikitable"
! From !! To !! Holder !! Width !! Speed
|-
| $00 || $B7 || WonderSwan SoC || 16-bit || 1 cycle
|-
| $B8 || $BF || Internal EEPROM control || 16-bit || 1 cycle
|-
| $C0 || $FF || Cartridge bus || 8-bit || 1<sup>(color)</sup>/2 cycles (configurable)
|}
With the exception of internal EEPROM on the ASWAN, all unaligned 16-bit accesses can be converted to two 8-bit accesses with a 1-cycle penalty.
== I/O port map ==
* Superscripts are used to mark ports specific to a given mode or platform:
** Color mode: <sup>(color)</sup>. Such ports are only accessible when color mode is enabled through port <code>$60</code>.
** WS/WSC/SC console: <sup>(WS)</sup>, <sup>(WSC)</sup>, <sup>(SC)</sup>.
* If two Bits rows are provided, the second one refers to the "Color" mode.
* The Type can be: R - readable, W - writable, L - writable before boot ROM lockout, 8/16 - width (byte/word).
{| class="wikitable"
! Category
! Port
! Description
! Bits
! Type
! Notes
|-
! rowspan="45" | [[Display]]
! $00
| [[Display#Display Control|Display Control]]
| style="text-align: right" | <tt style="white-space: nowrap">..ow Ws21</tt>
| RW8
|
|-
! $01
| [[Display#Display Background|Display Background]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .sss</tt>
<tt style="white-space: nowrap">pppp iiii</tt>
| RW8
| Shade (s)
Palette (p), Index (i)
|-
! $02
| [[Display#Current Line|Display Current Line]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll</tt>
| R8
| Line (l)
|-
! $03
| [[Display#Interrupt Line|Display Interrupt Line]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll</tt>
| RW8
| Line (l)
|-
! $04
| [[Display#Sprite Table Address|Sprite Table Address]]
| style="text-align: right" | <tt style="white-space: nowrap">...a aaaa</tt>
<tt style="white-space: nowrap">..aa aaaa</tt>
| RW8
| Address >> 9 (a)
|-
! $05
| [[Display#Sprite Table First|Sprite Table First]]
| style="text-align: right" | <tt style="white-space: nowrap">.iii iiii</tt>
| RW8
| Index (i)
|-
! $06
| [[Display#Sprite Table Count|Sprite Table Count]]
| style="text-align: right" | <tt style="white-space: nowrap">cccc cccc</tt>
| RW8
| Count (c)
|-
! $07
| [[Display#Screen Address|Screen Address]]
| style="text-align: right" | <tt style="white-space: nowrap">.222 .111</tt>
<tt style="white-space: nowrap">2222 1111</tt>
| RW8
| Screen 1 address >> 11 (1)
Screen 2 address >> 11 (2)
|-
! $08
| [[Display#Screen 2 Window|Screen 2 Window Left]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $09
| [[Display#Screen 2 Window|Screen 2 Window Top]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $0A
| [[Display#Screen 2 Window|Screen 2 Window Right]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $0B
| [[Display#Screen 2 Window|Screen 2 Window Bottom]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $0B
| [[Display#Sprite Window|Sprite Window Left]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $0C
| [[Display#Sprite Window|Sprite Window Top]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $0E
| [[Display#Sprite Window|Sprite Window Right]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $0F
| [[Display#Sprite Window|Sprite Window Bottom]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $10
| [[Display#Screen Scroll|Screen 1 Scroll X]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $11
| [[Display#Screen Scroll|Screen 1 Scroll Y]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $12
| [[Display#Screen Scroll|Screen 2 Scroll X]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $13
| [[Display#Screen Scroll|Screen 2 Scroll Y]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $14
| [[Display#LCD Control|LCD Control]]
| style="text-align: right" | <tt style="white-space: nowrap">.... ..Ce</tt>
| RW8
| Contrast (C)<sup>(WSC)</sup>, Enable (e)
|-
! $15
| [[Display#LCD Icon Control|LCD Icon Control]]
| style="text-align: right" | <tt style="white-space: nowrap">..32 1hvs</tt>
| RW8
| Auxillary 3 (3), Auxillary 2 (2), Auxillary 1 (1),
Horizontal (h), Vertical (v), Sleep (s)
|-
! $16
| [[Display#LCD Final Line|LCD Final Line]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll</tt>
| RW8
| Line (l)
|-
! $17
| [[Display#LCD Back Porch Line|LCD Back Porch Line]]<sup>(WSC)</sup>
| style="text-align: right" | <tt style="white-space: nowrap">llll llll</tt>
| RW8
| Line (l)
|-
! $1A
| [[Display#LCD Status|LCD Status]]
| style="text-align: right" | <tt style="white-space: nowrap">...v vv.s</tt>
| RW8
| Volume segment status (v), Sleep (s)
|-
! $1C
| [[Display#LCD Mono Shade LUT|LCD Mono Shade LUT 0/1]]
| style="text-align: right" | <tt style="white-space: nowrap">1111 0000</tt>
| RW8
| Shade index
|-
! $1D
| [[Display#LCD Mono Shade LUT|LCD Mono Shade LUT 2/3]]
| style="text-align: right" | <tt style="white-space: nowrap">3333 2222</tt>
| RW8
| Shade index
|-
! $1E
| [[Display#LCD Mono Shade LUT|LCD Mono Shade LUT 4/5]]
| style="text-align: right" | <tt style="white-space: nowrap">5555 4444</tt>
| RW8
| Shade index
|-
! $1F
| [[Display#LCD Mono Shade LUT|LCD Mono Shade LUT 6/7]]
| style="text-align: right" | <tt style="white-space: nowrap">7777 6666</tt>
| RW8
| Shade index
|-
! $20
| [[Display#LCD Mono Palette|LCD Mono Palette 0]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $22
| [[Display#LCD Mono Palette|LCD Mono Palette 1]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $24
| [[Display#LCD Mono Palette|LCD Mono Palette 2]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $26
| [[Display#LCD Mono Palette|LCD Mono Palette 3]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $28
| [[Display#LCD Mono Palette|LCD Mono Palette 4]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $2A
| [[Display#LCD Mono Palette|LCD Mono Palette 5]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $2C
| [[Display#LCD Mono Palette|LCD Mono Palette 6]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $2E
| [[Display#LCD Mono Palette|LCD Mono Palette 7]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $30
| [[Display#LCD Mono Palette|LCD Mono Palette 8]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $32
| [[Display#LCD Mono Palette|LCD Mono Palette 9]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $34
| [[Display#LCD Mono Palette|LCD Mono Palette 10]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $36
| [[Display#LCD Mono Palette|LCD Mono Palette 11]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $38
| [[Display#LCD Mono Palette|LCD Mono Palette 12]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $3A
| [[Display#LCD Mono Palette|LCD Mono Palette 13]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $3C
| [[Display#LCD Mono Palette|LCD Mono Palette 14]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $3E
| [[Display#LCD Mono Palette|LCD Mono Palette 15]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! rowspan="10" | [[DMA]]<sup>(color)</sup>
! $40
| [[DMA#General DMA|GDMA Source Address Low]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll llll lll.</tt>
| RW16
| Linear address, low 16 bits (l)
|-
! $42
| [[DMA#General DMA|GDMA Source Address High]]
| style="text-align: right" | <tt style="white-space: nowrap">.... hhhh</tt>
| RW8
| Linear address, high 4 bits (h)
|-
! $44
| [[DMA#General DMA|GDMA Destination Address]]
| style="text-align: right" | <tt style="white-space: nowrap">aaaa aaaa aaaa aaa.</tt>
| RW16
| IRAM address (a)
|-
! $46
| [[DMA#General DMA|GDMA Length]]
| style="text-align: right" | <tt style="white-space: nowrap">bbbb bbbb bbbb bbb.</tt>
| RW16
| Bytes (b)
|-
! $48
| [[DMA#General DMA|GDMA Control]]
| style="text-align: right" | <tt style="white-space: nowrap">ed.. ....</tt>
| RW8
| Enable (e), Decrement (d)
|-
! $4A
| [[DMA#Sound DMA|SDMA Source Address Low]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll llll llll</tt>
| RW16
| Linear address, low 16 bits (l)
|-
! $4C
| [[DMA#Sound DMA|SDMA Source Address High]]
| style="text-align: right" | <tt style="white-space: nowrap">.... hhhh</tt>
| RW8
| Linear address, high 4 bits (h)
|-
! $4E
| [[DMA#Sound DMA|SDMA Length Low]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll llll llll</tt>
| RW16
| Length, low 16 bits (l)
|-
! $50
| [[DMA#Sound DMA|SDMA Length High]]
| style="text-align: right" | <tt style="white-space: nowrap">.... hhhh</tt>
| RW8
| Length, high 4 bits (h)
|-
! $52
| [[DMA#Sound DMA|SDMA Control]]
| style="text-align: right" | <tt style="white-space: nowrap">ed.t r?ff</tt>
| RW8
| Enable (e), Decrement (d), Target (t),
Repeat (r), Frequency (f)
|-
! rowspan="2" | [[SoC]]<sup>(color)</sup>
! $60
| [[SoC#System Control 2|System Control 2]]
| style="text-align: right" | <tt style="white-space: nowrap">c4C. i?s?</tt>
| RW8
| Color (c), 4BPP (4), Chunky (C)<br/>
I/O wait state (i), SRAM wait state (s)
|-
! $62
| [[SoC#System Control 3|System Control 3]]
| style="text-align: right" | <tt style="white-space: nowrap">S... ...p</tt>
| RW8
| SwanCrystal (S), Power off (p)
|-
! rowspan="5" | [[Hyper Voice]]<sup>(color)</sup>
! $64
| [[Hyper Voice#Hyper Voice Output|Hyper Voice Left Output]]
| style="text-align: right" | <tt style="white-space: nowrap">ssss ssss ssss ssss</tt>
| W16
| Raw sample (s)
|-
! $66
| [[Hyper Voice#Hyper Voice Output|Hyper Voice Right Output]]
| style="text-align: right" | <tt style="white-space: nowrap">ssss ssss ssss ssss</tt>
| W16
| Raw sample (s)
|-
! $68
| [[Hyper Voice#Hyper Voice Input|Hyper Voice Left Input]]
| style="text-align: right" | <tt style="white-space: nowrap">ssss ssss</tt>
| W8
| Sample (s)
|-
! $69
| [[Hyper Voice#Hyper Voice Input|Hyper Voice Right Input]]
| style="text-align: right" | <tt style="white-space: nowrap">ssss ssss</tt>
| W8
| Sample (s)
|-
! $6A
| [[Hyper Voice#Hyper Voice Control|Hyper Voice Control]]
| style="text-align: right" | <tt style="white-space: nowrap">.mmc ???? errr ffss</tt>
| RW16
| Mask (m), Channel reset (c), Enable (e),
Rate (r), Format (f), Shift (s)
|-
! rowspan="8" | [[Display]]<sup>(SC)</sup>
! $70
| LCD Timing Configuration 1?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $71
| LCD Timing Configuration 2?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $72
| LCD Timing Configuration 3?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $73
| LCD Timing Configuration 4?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $74
| LCD Timing Configuration 5?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $75
| LCD Timing Configuration 6?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $76
| LCD Timing Configuration 7?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $77
| LCD Timing Configuration 8?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! rowspan="21" | [[Sound]]
! $80
| [[Sound#Sound Channel Frequency|Sound Channel 1 Frequency]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .ddd dddd dddd</tt>
| RW16
| Divider (d)
|-
! $82
| [[Sound#Sound Channel Frequency|Sound Channel 2 Frequency]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .ddd dddd dddd</tt>
| RW16
| Divider (d)
|-
! $84
| [[Sound#Sound Channel Frequency|Sound Channel 3 Frequency]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .ddd dddd dddd</tt>
| RW16
| Divider (d)
|-
! $86
| [[Sound#Sound Channel Frequency|Sound Channel 4 Frequency]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .ddd dddd dddd</tt>
| RW16
| Divider (d)
|-
! $88
| [[Sound#Sound Channel Volume|Sound Channel 1 Volume]]
| style="text-align: right" | <tt style="white-space: nowrap">llll rrrr</tt>
| RW8
| Left (l), Right (r)
|-
! rowspan="2" | $89
| [[Sound#Sound Channel Volume|Sound Channel 2 Volume]]
| style="text-align: right" | <tt style="white-space: nowrap">llll rrrr</tt>
| RW8
| Left (l), Right (r)
|-
| [[Sound#Sound Channel 2 Voice Sample|Sound Channel 2 Voice Sample]]
| style="text-align: right" | <tt style="white-space: nowrap">ssss ssss</tt>
| RW8
| Sample (s)
|-
! $8A
| [[Sound#Sound Channel Volume|Sound Channel 3 Volume]]
| style="text-align: right" | <tt style="white-space: nowrap">llll rrrr</tt>
| RW8
| Left (l), Right (r)
|-
! $8B
| [[Sound#Sound Channel Volume|Sound Channel 4 Volume]]
| style="text-align: right" | <tt style="white-space: nowrap">llll rrrr</tt>
| RW8
| Left (l), Right (r)
|-
! $8C
| [[Sound#Sound Channel 3 Sweep Amount|Sound Channel 3 Sweep Amount]]
| style="text-align: right" | <tt style="white-space: nowrap">vvvv vvvv</tt>
| RW8
| Value (v)
|-
! $8D
| [[Sound#Sound Channel 3 Sweep Ticks|Sound Channel 3 Sweep Ticks]]
| style="text-align: right" | <tt style="white-space: nowrap">...t tttt</tt>
| RW8
| Ticks (t)
|-
! $8E
| [[Sound#Sound Channel 4 Noise Control|Sound Channel 4 Noise Control]]
| style="text-align: right" | <tt style="white-space: nowrap">...e rttt</tt>
| RW8
| Enable (e), Reset (r), Tap (t)
|-
! $8F
| [[Sound#Sound Wavetable Address|Sound Wavetable Address]]
| style="text-align: right" | <tt style="white-space: nowrap">wwww wwww</tt>
| RW8
| Address >> 6 (w)
|-
! $90
| [[Sound#Sound Channel Control|Sound Channel Control]]
| style="text-align: right" | <tt style="white-space: nowrap">nsv. 4321</tt>
| RW8
| Channel enable (1234)
Noise (n), Sweep (s), Voice (v)
|-
! $91
| [[Sound#Sound Output Control|Sound Output Control]]
| style="text-align: right" | <tt style="white-space: nowrap">H... hrrs</tt>
| RW8
| Headphones connected (H)
Headphone output (h)
Speaker output (s), range (r)
|-
! $92
| [[Sound#Sound Channel 4 LFSR Register|Sound Channel 4 LFSR Register]]
| style="text-align: right" | <tt style="white-space: nowrap">.rrr rrrr rrrr rrrr</tt>
| R16
| PRNG state (r)
|-
! $94
| [[Sound#Sound Channel 2 Voice Volume|Sound Channel 2 Voice Volume]]
| style="text-align: right" | <tt style="white-space: nowrap">.... lLrR</tt>
| RW8
| Left Half (l), Full (L)
Right Half (r), Full (R)
|-
! $96
| Sound Channel Output Right
| style="text-align: right" | <tt style="white-space: nowrap">.... ..ss ssss ssss</tt>
| R16
| Sample (s)
|-
! $98
| Sound Channel Output Left
| style="text-align: right" | <tt style="white-space: nowrap">.... ..ss ssss ssss</tt>
| R16
| Sample (s)
|-
! $9A
| Sound Channel Output Sum
| style="text-align: right" | <tt style="white-space: nowrap">.... .sss ssss ssss</tt>
| R16
| Sample (s)
|-
! $9E
| Sound Speaker Master Volume<sup>(color)</sup>
| style="text-align: right" | <tt style="white-space: nowrap">.... ..vv</tt>
| RW8
| Master volume (v)
|-
! [[SoC]]
! $A0
| [[SoC#System Control|System Control]]
| style="text-align: right" | <tt style="white-space: nowrap">t??? swcl</tt>
| RW8
| Test OK (t), ROM wait state (s), ROM width (w),
Color system (c), Boot ROM lockout (l)
|-
! rowspan="5" | [[Timers]]
! $A2
| [[Timers#Timer Control|Timer Control]]
| style="text-align: right" | <tt style="white-space: nowrap">.... VvHh</tt>
| RW8
| Horizontal enable (h), auto reload (H)
Vertical enable (v), auto reload (V)
|-
! $A4
| [[Timers#Timer Reload|Horizontal Blank Timer Reload]]
| style="text-align: right" | <tt style="white-space: nowrap">tttt tttt tttt tttt</tt>
| RW16
| Ticks (t)
|-
! $A6
| [[Timers#Timer Reload|Vertical Blank Timer Reload]]
| style="text-align: right" | <tt style="white-space: nowrap">tttt tttt tttt tttt</tt>
| RW16
| Ticks (t)
|-
! $A8
| [[Timers#Timer Counter|Horizontal Blank Timer Counter]]
| style="text-align: right" | <tt style="white-space: nowrap">tttt tttt tttt tttt</tt>
| R16
| Ticks (t)
|-
! $AA
| [[Timers#Timer Counter|Vertical Blank Timer Counter]]
| style="text-align: right" | <tt style="white-space: nowrap">tttt tttt tttt tttt</tt>
| R16
| Ticks (t)
|-
! ?
! $AC
| ?
| style="text-align: right" | <tt style="white-space: nowrap">.... ...p</tt>
| W8?
| Power off (p)
|-
! rowspan="2" | [[Interrupts]]
! rowspan="2" | $B0
| [[Interrupts#Interrupt Vector Offset|Interrupt Vector Offset]]
| style="text-align: right" | <tt style="white-space: nowrap">VVVV V...</tt>
| W8
| Vector offset (V)
|-
| [[Interrupts#Interrupt Vector Request|Interrupt Vector Request]]
| style="text-align: right" | <tt style="white-space: nowrap">vvvv vvvv</tt>
| R8
| Requested vector offset (v)
|-
! rowspan="2" | [[UART]]
! $B1
| [[UART#Serial Receive Data|Serial Receive Data]]
| style="text-align: right" | <tt style="white-space: nowrap">dddd dddd</tt>
| R8
| Receive buffer data (d)
|-
! $B1
| [[UART#Serial Transmit Data|Serial Transmit Data]]
| style="text-align: right" | <tt style="white-space: nowrap">dddd dddd</tt>
| W8
| Transmit buffer data (d)
|-
! [[Interrupts]]
! $B2
| [[Interrupts#Interrupt Enable|Interrupt Enable]]
| iiii iiii
| RW8
| Interrupt index (i)
|-
! rowspan="2" | [[UART]]
! $B3
| [[UART#Serial Status|Serial Status]]
| style="text-align: right" | <tt style="white-space: nowrap">eb.. .tor</tt>
| R8
| Enable (e), Baud rate (b),
Transfer ready (t), Overrun (o), Receive ready (r)
|-
! $B3
| [[UART#Serial Control|Serial Control]]
| style="text-align: right" | <tt style="white-space: nowrap">ebO. ....</tt>
| W8
| Enable (e), Baud rate (b), Reset Overrun (O)
|-
! [[Interrupts]]
! $B4
| [[Interrupts#Interrupt Status|Interrupt Status]]
| iiii iiii
| R8
| Interrupt index (i)
|-
! [[Keypad]]
! $B5
| [[Keypad|Keypad Scan]]
| style="text-align: right" | <tt style="white-space: nowrap">.iii oooo</tt>
| RW8
| Input row (i), Output column (o)
|-
! rowspan="2" | [[Interrupts]]
! $B6
| [[Interrupts#Interrupt Acknowledge|Interrupt Acknowledge]]
| iiii iiii
| R8?
| Interrupt index (i)
|-
! $B7
| [[Interrupts#Interrupt NMI Control|Interrupt NMI Control]]
| style="text-align: right" | <tt style="white-space: nowrap">...b ....</tt>
| RW8
| Low battery (b)
|-
! rowspan="4" | [[EEPROM|Internal EEPROM]]
! $BA
| [[EEPROM#Internal EEPROM Data|Internal EEPROM Data]]
| style="text-align: right" | <tt style="white-space: nowrap">dddd dddd dddd dddd</tt>
| RW16
| Data (d)
|-
! $BC
| [[EEPROM#Internal EEPROM Command|Internal EEPROM Command]]
|
| RW16
|
|-
! rowspan="2" | $BE
| [[EEPROM#Internal EEPROM Status|Internal EEPROM Status]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .... p... ..RD</tt>
| R16
| Protected (p), Ready (R), Done (D)
|-
| [[EEPROM#Internal EEPROM Control|Internal EEPROM Control]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .... pewr ....</tt>
| W16
| Protect (p), Erase (e), Write (w), Read (r)
|-
! [[Mapper|Cartridge]]
! $C0<br />
$FF
| Cartridge I/O
|
| RW8
| Forwarded by the SoC
|}
== I/O port routing ==
The [[NEC V30MZ]] supports 16-bit I/O port addresses. The WonderSwan SoC routes them using the following algorithm:
* If an address is between <code>$00B8</code> and <code>$00BF</code> inclusive, it is routed to the internal EEPROM control block.
* If an address is between <code>$00C0</code> and <code>$00FF</code> inclusive, it is routed to the cartride bus.
* If an address's bits <code>0</code> through <code>8</code> inclusive are between <code>$000</code> and <code>$0B7</code> inclusive, they are routed to the SoC block.
* If none of these conditions are reached, open bus is read.
On the monochrome models, as well as color models in mono emulation, open bus is always <code>0x90</code>.
24ccfa4b5e117db1474ab67659fcaa26e66ebf62
232
230
2023-09-01T14:16:10Z
Asie
351
update port $52, $60
wikitext
text/x-wiki
The WonderSwan SoC has three general blocks of I/O port accesses:
{| class="wikitable"
! From !! To !! Holder !! Width !! Speed
|-
| $00 || $B7 || WonderSwan SoC || 16-bit || 1 cycle
|-
| $B8 || $BF || Internal EEPROM control || 16-bit || 1 cycle
|-
| $C0 || $FF || Cartridge bus || 8-bit || 1<sup>(color)</sup>/2 cycles (configurable)
|}
With the exception of internal EEPROM on the ASWAN, all unaligned 16-bit accesses can be converted to two 8-bit accesses with a 1-cycle penalty.
== I/O port map ==
* Superscripts are used to mark ports specific to a given mode or platform:
** Color mode: <sup>(color)</sup>. Such ports are only accessible when color mode is enabled through port <code>$60</code>.
** WS/WSC/SC console: <sup>(WS)</sup>, <sup>(WSC)</sup>, <sup>(SC)</sup>.
* If two Bits rows are provided, the second one refers to the "Color" mode.
* The Type can be: R - readable, W - writable, L - writable before boot ROM lockout, 8/16 - width (byte/word).
{| class="wikitable"
! Category
! Port
! Description
! Bits
! Type
! Notes
|-
! rowspan="45" | [[Display]]
! $00
| [[Display#Display Control|Display Control]]
| style="text-align: right" | <tt style="white-space: nowrap">..ow Ws21</tt>
| RW8
|
|-
! $01
| [[Display#Display Background|Display Background]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .sss</tt>
<tt style="white-space: nowrap">pppp iiii</tt>
| RW8
| Shade (s)
Palette (p), Index (i)
|-
! $02
| [[Display#Current Line|Display Current Line]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll</tt>
| R8
| Line (l)
|-
! $03
| [[Display#Interrupt Line|Display Interrupt Line]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll</tt>
| RW8
| Line (l)
|-
! $04
| [[Display#Sprite Table Address|Sprite Table Address]]
| style="text-align: right" | <tt style="white-space: nowrap">...a aaaa</tt>
<tt style="white-space: nowrap">..aa aaaa</tt>
| RW8
| Address >> 9 (a)
|-
! $05
| [[Display#Sprite Table First|Sprite Table First]]
| style="text-align: right" | <tt style="white-space: nowrap">.iii iiii</tt>
| RW8
| Index (i)
|-
! $06
| [[Display#Sprite Table Count|Sprite Table Count]]
| style="text-align: right" | <tt style="white-space: nowrap">cccc cccc</tt>
| RW8
| Count (c)
|-
! $07
| [[Display#Screen Address|Screen Address]]
| style="text-align: right" | <tt style="white-space: nowrap">.222 .111</tt>
<tt style="white-space: nowrap">2222 1111</tt>
| RW8
| Screen 1 address >> 11 (1)
Screen 2 address >> 11 (2)
|-
! $08
| [[Display#Screen 2 Window|Screen 2 Window Left]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $09
| [[Display#Screen 2 Window|Screen 2 Window Top]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $0A
| [[Display#Screen 2 Window|Screen 2 Window Right]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $0B
| [[Display#Screen 2 Window|Screen 2 Window Bottom]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $0B
| [[Display#Sprite Window|Sprite Window Left]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $0C
| [[Display#Sprite Window|Sprite Window Top]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $0E
| [[Display#Sprite Window|Sprite Window Right]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $0F
| [[Display#Sprite Window|Sprite Window Bottom]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $10
| [[Display#Screen Scroll|Screen 1 Scroll X]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $11
| [[Display#Screen Scroll|Screen 1 Scroll Y]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $12
| [[Display#Screen Scroll|Screen 2 Scroll X]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $13
| [[Display#Screen Scroll|Screen 2 Scroll Y]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $14
| [[Display#LCD Control|LCD Control]]
| style="text-align: right" | <tt style="white-space: nowrap">.... ..Ce</tt>
| RW8
| Contrast (C)<sup>(WSC)</sup>, Enable (e)
|-
! $15
| [[Display#LCD Icon Control|LCD Icon Control]]
| style="text-align: right" | <tt style="white-space: nowrap">..32 1hvs</tt>
| RW8
| Auxillary 3 (3), Auxillary 2 (2), Auxillary 1 (1),
Horizontal (h), Vertical (v), Sleep (s)
|-
! $16
| [[Display#LCD Final Line|LCD Final Line]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll</tt>
| RW8
| Line (l)
|-
! $17
| [[Display#LCD Back Porch Line|LCD Back Porch Line]]<sup>(WSC)</sup>
| style="text-align: right" | <tt style="white-space: nowrap">llll llll</tt>
| RW8
| Line (l)
|-
! $1A
| [[Display#LCD Status|LCD Status]]
| style="text-align: right" | <tt style="white-space: nowrap">...v vv.s</tt>
| RW8
| Volume segment status (v), Sleep (s)
|-
! $1C
| [[Display#LCD Mono Shade LUT|LCD Mono Shade LUT 0/1]]
| style="text-align: right" | <tt style="white-space: nowrap">1111 0000</tt>
| RW8
| Shade index
|-
! $1D
| [[Display#LCD Mono Shade LUT|LCD Mono Shade LUT 2/3]]
| style="text-align: right" | <tt style="white-space: nowrap">3333 2222</tt>
| RW8
| Shade index
|-
! $1E
| [[Display#LCD Mono Shade LUT|LCD Mono Shade LUT 4/5]]
| style="text-align: right" | <tt style="white-space: nowrap">5555 4444</tt>
| RW8
| Shade index
|-
! $1F
| [[Display#LCD Mono Shade LUT|LCD Mono Shade LUT 6/7]]
| style="text-align: right" | <tt style="white-space: nowrap">7777 6666</tt>
| RW8
| Shade index
|-
! $20
| [[Display#LCD Mono Palette|LCD Mono Palette 0]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $22
| [[Display#LCD Mono Palette|LCD Mono Palette 1]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $24
| [[Display#LCD Mono Palette|LCD Mono Palette 2]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $26
| [[Display#LCD Mono Palette|LCD Mono Palette 3]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $28
| [[Display#LCD Mono Palette|LCD Mono Palette 4]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $2A
| [[Display#LCD Mono Palette|LCD Mono Palette 5]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $2C
| [[Display#LCD Mono Palette|LCD Mono Palette 6]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $2E
| [[Display#LCD Mono Palette|LCD Mono Palette 7]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $30
| [[Display#LCD Mono Palette|LCD Mono Palette 8]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $32
| [[Display#LCD Mono Palette|LCD Mono Palette 9]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $34
| [[Display#LCD Mono Palette|LCD Mono Palette 10]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $36
| [[Display#LCD Mono Palette|LCD Mono Palette 11]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $38
| [[Display#LCD Mono Palette|LCD Mono Palette 12]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $3A
| [[Display#LCD Mono Palette|LCD Mono Palette 13]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $3C
| [[Display#LCD Mono Palette|LCD Mono Palette 14]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $3E
| [[Display#LCD Mono Palette|LCD Mono Palette 15]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! rowspan="10" | [[DMA]]<sup>(color)</sup>
! $40
| [[DMA#General DMA|GDMA Source Address Low]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll llll lll.</tt>
| RW16
| Linear address, low 16 bits (l)
|-
! $42
| [[DMA#General DMA|GDMA Source Address High]]
| style="text-align: right" | <tt style="white-space: nowrap">.... hhhh</tt>
| RW8
| Linear address, high 4 bits (h)
|-
! $44
| [[DMA#General DMA|GDMA Destination Address]]
| style="text-align: right" | <tt style="white-space: nowrap">aaaa aaaa aaaa aaa.</tt>
| RW16
| IRAM address (a)
|-
! $46
| [[DMA#General DMA|GDMA Length]]
| style="text-align: right" | <tt style="white-space: nowrap">bbbb bbbb bbbb bbb.</tt>
| RW16
| Bytes (b)
|-
! $48
| [[DMA#General DMA|GDMA Control]]
| style="text-align: right" | <tt style="white-space: nowrap">ed.. ....</tt>
| RW8
| Enable (e), Decrement (d)
|-
! $4A
| [[DMA#Sound DMA|SDMA Source Address Low]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll llll llll</tt>
| RW16
| Linear address, low 16 bits (l)
|-
! $4C
| [[DMA#Sound DMA|SDMA Source Address High]]
| style="text-align: right" | <tt style="white-space: nowrap">.... hhhh</tt>
| RW8
| Linear address, high 4 bits (h)
|-
! $4E
| [[DMA#Sound DMA|SDMA Length Low]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll llll llll</tt>
| RW16
| Length, low 16 bits (l)
|-
! $50
| [[DMA#Sound DMA|SDMA Length High]]
| style="text-align: right" | <tt style="white-space: nowrap">.... hhhh</tt>
| RW8
| Length, high 4 bits (h)
|-
! $52
| [[DMA#Sound DMA|SDMA Control]]
| style="text-align: right" | <tt style="white-space: nowrap">ed.t rhff</tt>
| RW8
| Enable (e), Decrement (d), Target (t),
Repeat (r), Hold (h), Frequency (f)
|-
! rowspan="2" | [[SoC]]<sup>(color)</sup>
! $60
| [[SoC#System Control 2|System Control 2]]
| style="text-align: right" | <tt style="white-space: nowrap">c4C. i?sl</tt>
| RW8
| Color (c), 4BPP (4), Chunky (C),<br/>
Cart I/O wait state (i), SRAM wait state (s),<br/>
Cart clock speed (l).
|-
! $62
| [[SoC#System Control 3|System Control 3]]
| style="text-align: right" | <tt style="white-space: nowrap">S... ...p</tt>
| RW8
| SwanCrystal (S), Power off (p)
|-
! rowspan="5" | [[Hyper Voice]]<sup>(color)</sup>
! $64
| [[Hyper Voice#Hyper Voice Output|Hyper Voice Left Output]]
| style="text-align: right" | <tt style="white-space: nowrap">ssss ssss ssss ssss</tt>
| W16
| Raw sample (s)
|-
! $66
| [[Hyper Voice#Hyper Voice Output|Hyper Voice Right Output]]
| style="text-align: right" | <tt style="white-space: nowrap">ssss ssss ssss ssss</tt>
| W16
| Raw sample (s)
|-
! $68
| [[Hyper Voice#Hyper Voice Input|Hyper Voice Left Input]]
| style="text-align: right" | <tt style="white-space: nowrap">ssss ssss</tt>
| W8
| Sample (s)
|-
! $69
| [[Hyper Voice#Hyper Voice Input|Hyper Voice Right Input]]
| style="text-align: right" | <tt style="white-space: nowrap">ssss ssss</tt>
| W8
| Sample (s)
|-
! $6A
| [[Hyper Voice#Hyper Voice Control|Hyper Voice Control]]
| style="text-align: right" | <tt style="white-space: nowrap">.mmc ???? errr ffss</tt>
| RW16
| Mask (m), Channel reset (c), Enable (e),
Rate (r), Format (f), Shift (s)
|-
! rowspan="8" | [[Display]]<sup>(SC)</sup>
! $70
| LCD Timing Configuration 1?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $71
| LCD Timing Configuration 2?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $72
| LCD Timing Configuration 3?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $73
| LCD Timing Configuration 4?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $74
| LCD Timing Configuration 5?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $75
| LCD Timing Configuration 6?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $76
| LCD Timing Configuration 7?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $77
| LCD Timing Configuration 8?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! rowspan="21" | [[Sound]]
! $80
| [[Sound#Sound Channel Frequency|Sound Channel 1 Frequency]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .ddd dddd dddd</tt>
| RW16
| Divider (d)
|-
! $82
| [[Sound#Sound Channel Frequency|Sound Channel 2 Frequency]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .ddd dddd dddd</tt>
| RW16
| Divider (d)
|-
! $84
| [[Sound#Sound Channel Frequency|Sound Channel 3 Frequency]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .ddd dddd dddd</tt>
| RW16
| Divider (d)
|-
! $86
| [[Sound#Sound Channel Frequency|Sound Channel 4 Frequency]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .ddd dddd dddd</tt>
| RW16
| Divider (d)
|-
! $88
| [[Sound#Sound Channel Volume|Sound Channel 1 Volume]]
| style="text-align: right" | <tt style="white-space: nowrap">llll rrrr</tt>
| RW8
| Left (l), Right (r)
|-
! rowspan="2" | $89
| [[Sound#Sound Channel Volume|Sound Channel 2 Volume]]
| style="text-align: right" | <tt style="white-space: nowrap">llll rrrr</tt>
| RW8
| Left (l), Right (r)
|-
| [[Sound#Sound Channel 2 Voice Sample|Sound Channel 2 Voice Sample]]
| style="text-align: right" | <tt style="white-space: nowrap">ssss ssss</tt>
| RW8
| Sample (s)
|-
! $8A
| [[Sound#Sound Channel Volume|Sound Channel 3 Volume]]
| style="text-align: right" | <tt style="white-space: nowrap">llll rrrr</tt>
| RW8
| Left (l), Right (r)
|-
! $8B
| [[Sound#Sound Channel Volume|Sound Channel 4 Volume]]
| style="text-align: right" | <tt style="white-space: nowrap">llll rrrr</tt>
| RW8
| Left (l), Right (r)
|-
! $8C
| [[Sound#Sound Channel 3 Sweep Amount|Sound Channel 3 Sweep Amount]]
| style="text-align: right" | <tt style="white-space: nowrap">vvvv vvvv</tt>
| RW8
| Value (v)
|-
! $8D
| [[Sound#Sound Channel 3 Sweep Ticks|Sound Channel 3 Sweep Ticks]]
| style="text-align: right" | <tt style="white-space: nowrap">...t tttt</tt>
| RW8
| Ticks (t)
|-
! $8E
| [[Sound#Sound Channel 4 Noise Control|Sound Channel 4 Noise Control]]
| style="text-align: right" | <tt style="white-space: nowrap">...e rttt</tt>
| RW8
| Enable (e), Reset (r), Tap (t)
|-
! $8F
| [[Sound#Sound Wavetable Address|Sound Wavetable Address]]
| style="text-align: right" | <tt style="white-space: nowrap">wwww wwww</tt>
| RW8
| Address >> 6 (w)
|-
! $90
| [[Sound#Sound Channel Control|Sound Channel Control]]
| style="text-align: right" | <tt style="white-space: nowrap">nsv. 4321</tt>
| RW8
| Channel enable (1234)
Noise (n), Sweep (s), Voice (v)
|-
! $91
| [[Sound#Sound Output Control|Sound Output Control]]
| style="text-align: right" | <tt style="white-space: nowrap">H... hrrs</tt>
| RW8
| Headphones connected (H)
Headphone output (h)
Speaker output (s), range (r)
|-
! $92
| [[Sound#Sound Channel 4 LFSR Register|Sound Channel 4 LFSR Register]]
| style="text-align: right" | <tt style="white-space: nowrap">.rrr rrrr rrrr rrrr</tt>
| R16
| PRNG state (r)
|-
! $94
| [[Sound#Sound Channel 2 Voice Volume|Sound Channel 2 Voice Volume]]
| style="text-align: right" | <tt style="white-space: nowrap">.... lLrR</tt>
| RW8
| Left Half (l), Full (L)
Right Half (r), Full (R)
|-
! $96
| Sound Channel Output Right
| style="text-align: right" | <tt style="white-space: nowrap">.... ..ss ssss ssss</tt>
| R16
| Sample (s)
|-
! $98
| Sound Channel Output Left
| style="text-align: right" | <tt style="white-space: nowrap">.... ..ss ssss ssss</tt>
| R16
| Sample (s)
|-
! $9A
| Sound Channel Output Sum
| style="text-align: right" | <tt style="white-space: nowrap">.... .sss ssss ssss</tt>
| R16
| Sample (s)
|-
! $9E
| Sound Speaker Master Volume<sup>(color)</sup>
| style="text-align: right" | <tt style="white-space: nowrap">.... ..vv</tt>
| RW8
| Master volume (v)
|-
! [[SoC]]
! $A0
| [[SoC#System Control|System Control]]
| style="text-align: right" | <tt style="white-space: nowrap">t??? swcl</tt>
| RW8
| Test OK (t), ROM wait state (s), ROM width (w),
Color system (c), Boot ROM lockout (l)
|-
! rowspan="5" | [[Timers]]
! $A2
| [[Timers#Timer Control|Timer Control]]
| style="text-align: right" | <tt style="white-space: nowrap">.... VvHh</tt>
| RW8
| Horizontal enable (h), auto reload (H)
Vertical enable (v), auto reload (V)
|-
! $A4
| [[Timers#Timer Reload|Horizontal Blank Timer Reload]]
| style="text-align: right" | <tt style="white-space: nowrap">tttt tttt tttt tttt</tt>
| RW16
| Ticks (t)
|-
! $A6
| [[Timers#Timer Reload|Vertical Blank Timer Reload]]
| style="text-align: right" | <tt style="white-space: nowrap">tttt tttt tttt tttt</tt>
| RW16
| Ticks (t)
|-
! $A8
| [[Timers#Timer Counter|Horizontal Blank Timer Counter]]
| style="text-align: right" | <tt style="white-space: nowrap">tttt tttt tttt tttt</tt>
| R16
| Ticks (t)
|-
! $AA
| [[Timers#Timer Counter|Vertical Blank Timer Counter]]
| style="text-align: right" | <tt style="white-space: nowrap">tttt tttt tttt tttt</tt>
| R16
| Ticks (t)
|-
! ?
! $AC
| ?
| style="text-align: right" | <tt style="white-space: nowrap">.... ...p</tt>
| W8?
| Power off (p)
|-
! rowspan="2" | [[Interrupts]]
! rowspan="2" | $B0
| [[Interrupts#Interrupt Vector Offset|Interrupt Vector Offset]]
| style="text-align: right" | <tt style="white-space: nowrap">VVVV V...</tt>
| W8
| Vector offset (V)
|-
| [[Interrupts#Interrupt Vector Request|Interrupt Vector Request]]
| style="text-align: right" | <tt style="white-space: nowrap">vvvv vvvv</tt>
| R8
| Requested vector offset (v)
|-
! rowspan="2" | [[UART]]
! $B1
| [[UART#Serial Receive Data|Serial Receive Data]]
| style="text-align: right" | <tt style="white-space: nowrap">dddd dddd</tt>
| R8
| Receive buffer data (d)
|-
! $B1
| [[UART#Serial Transmit Data|Serial Transmit Data]]
| style="text-align: right" | <tt style="white-space: nowrap">dddd dddd</tt>
| W8
| Transmit buffer data (d)
|-
! [[Interrupts]]
! $B2
| [[Interrupts#Interrupt Enable|Interrupt Enable]]
| iiii iiii
| RW8
| Interrupt index (i)
|-
! rowspan="2" | [[UART]]
! $B3
| [[UART#Serial Status|Serial Status]]
| style="text-align: right" | <tt style="white-space: nowrap">eb.. .tor</tt>
| R8
| Enable (e), Baud rate (b),
Transfer ready (t), Overrun (o), Receive ready (r)
|-
! $B3
| [[UART#Serial Control|Serial Control]]
| style="text-align: right" | <tt style="white-space: nowrap">ebO. ....</tt>
| W8
| Enable (e), Baud rate (b), Reset Overrun (O)
|-
! [[Interrupts]]
! $B4
| [[Interrupts#Interrupt Status|Interrupt Status]]
| iiii iiii
| R8
| Interrupt index (i)
|-
! [[Keypad]]
! $B5
| [[Keypad|Keypad Scan]]
| style="text-align: right" | <tt style="white-space: nowrap">.iii oooo</tt>
| RW8
| Input row (i), Output column (o)
|-
! rowspan="2" | [[Interrupts]]
! $B6
| [[Interrupts#Interrupt Acknowledge|Interrupt Acknowledge]]
| iiii iiii
| R8?
| Interrupt index (i)
|-
! $B7
| [[Interrupts#Interrupt NMI Control|Interrupt NMI Control]]
| style="text-align: right" | <tt style="white-space: nowrap">...b ....</tt>
| RW8
| Low battery (b)
|-
! rowspan="4" | [[EEPROM|Internal EEPROM]]
! $BA
| [[EEPROM#Internal EEPROM Data|Internal EEPROM Data]]
| style="text-align: right" | <tt style="white-space: nowrap">dddd dddd dddd dddd</tt>
| RW16
| Data (d)
|-
! $BC
| [[EEPROM#Internal EEPROM Command|Internal EEPROM Command]]
|
| RW16
|
|-
! rowspan="2" | $BE
| [[EEPROM#Internal EEPROM Status|Internal EEPROM Status]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .... p... ..RD</tt>
| R16
| Protected (p), Ready (R), Done (D)
|-
| [[EEPROM#Internal EEPROM Control|Internal EEPROM Control]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .... pewr ....</tt>
| W16
| Protect (p), Erase (e), Write (w), Read (r)
|-
! [[Mapper|Cartridge]]
! $C0<br />
$FF
| Cartridge I/O
|
| RW8
| Forwarded by the SoC
|}
== I/O port routing ==
The [[NEC V30MZ]] supports 16-bit I/O port addresses. The WonderSwan SoC routes them using the following algorithm:
* If an address is between <code>$00B8</code> and <code>$00BF</code> inclusive, it is routed to the internal EEPROM control block.
* If an address is between <code>$00C0</code> and <code>$00FF</code> inclusive, it is routed to the cartride bus.
* If an address's bits <code>0</code> through <code>8</code> inclusive are between <code>$000</code> and <code>$0B7</code> inclusive, they are routed to the SoC block.
* If none of these conditions are reached, open bus is read.
On the monochrome models, as well as color models in mono emulation, open bus is always <code>0x90</code>.
bf7ea2e16ea78b9b74b3414cecb83ae09b05ad65
234
232
2023-09-01T14:18:31Z
Asie
351
fix port $B6
wikitext
text/x-wiki
The WonderSwan SoC has three general blocks of I/O port accesses:
{| class="wikitable"
! From !! To !! Holder !! Width !! Speed
|-
| $00 || $B7 || WonderSwan SoC || 16-bit || 1 cycle
|-
| $B8 || $BF || Internal EEPROM control || 16-bit || 1 cycle
|-
| $C0 || $FF || Cartridge bus || 8-bit || 1<sup>(color)</sup>/2 cycles (configurable)
|}
With the exception of internal EEPROM on the ASWAN, all unaligned 16-bit accesses can be converted to two 8-bit accesses with a 1-cycle penalty.
== I/O port map ==
* Superscripts are used to mark ports specific to a given mode or platform:
** Color mode: <sup>(color)</sup>. Such ports are only accessible when color mode is enabled through port <code>$60</code>.
** WS/WSC/SC console: <sup>(WS)</sup>, <sup>(WSC)</sup>, <sup>(SC)</sup>.
* If two Bits rows are provided, the second one refers to the "Color" mode.
* The Type can be: R - readable, W - writable, L - writable before boot ROM lockout, 8/16 - width (byte/word).
{| class="wikitable"
! Category
! Port
! Description
! Bits
! Type
! Notes
|-
! rowspan="45" | [[Display]]
! $00
| [[Display#Display Control|Display Control]]
| style="text-align: right" | <tt style="white-space: nowrap">..ow Ws21</tt>
| RW8
|
|-
! $01
| [[Display#Display Background|Display Background]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .sss</tt>
<tt style="white-space: nowrap">pppp iiii</tt>
| RW8
| Shade (s)
Palette (p), Index (i)
|-
! $02
| [[Display#Current Line|Display Current Line]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll</tt>
| R8
| Line (l)
|-
! $03
| [[Display#Interrupt Line|Display Interrupt Line]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll</tt>
| RW8
| Line (l)
|-
! $04
| [[Display#Sprite Table Address|Sprite Table Address]]
| style="text-align: right" | <tt style="white-space: nowrap">...a aaaa</tt>
<tt style="white-space: nowrap">..aa aaaa</tt>
| RW8
| Address >> 9 (a)
|-
! $05
| [[Display#Sprite Table First|Sprite Table First]]
| style="text-align: right" | <tt style="white-space: nowrap">.iii iiii</tt>
| RW8
| Index (i)
|-
! $06
| [[Display#Sprite Table Count|Sprite Table Count]]
| style="text-align: right" | <tt style="white-space: nowrap">cccc cccc</tt>
| RW8
| Count (c)
|-
! $07
| [[Display#Screen Address|Screen Address]]
| style="text-align: right" | <tt style="white-space: nowrap">.222 .111</tt>
<tt style="white-space: nowrap">2222 1111</tt>
| RW8
| Screen 1 address >> 11 (1)
Screen 2 address >> 11 (2)
|-
! $08
| [[Display#Screen 2 Window|Screen 2 Window Left]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $09
| [[Display#Screen 2 Window|Screen 2 Window Top]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $0A
| [[Display#Screen 2 Window|Screen 2 Window Right]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $0B
| [[Display#Screen 2 Window|Screen 2 Window Bottom]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $0B
| [[Display#Sprite Window|Sprite Window Left]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $0C
| [[Display#Sprite Window|Sprite Window Top]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $0E
| [[Display#Sprite Window|Sprite Window Right]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $0F
| [[Display#Sprite Window|Sprite Window Bottom]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $10
| [[Display#Screen Scroll|Screen 1 Scroll X]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $11
| [[Display#Screen Scroll|Screen 1 Scroll Y]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $12
| [[Display#Screen Scroll|Screen 2 Scroll X]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $13
| [[Display#Screen Scroll|Screen 2 Scroll Y]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $14
| [[Display#LCD Control|LCD Control]]
| style="text-align: right" | <tt style="white-space: nowrap">.... ..Ce</tt>
| RW8
| Contrast (C)<sup>(WSC)</sup>, Enable (e)
|-
! $15
| [[Display#LCD Icon Control|LCD Icon Control]]
| style="text-align: right" | <tt style="white-space: nowrap">..32 1hvs</tt>
| RW8
| Auxillary 3 (3), Auxillary 2 (2), Auxillary 1 (1),
Horizontal (h), Vertical (v), Sleep (s)
|-
! $16
| [[Display#LCD Final Line|LCD Final Line]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll</tt>
| RW8
| Line (l)
|-
! $17
| [[Display#LCD Back Porch Line|LCD Back Porch Line]]<sup>(WSC)</sup>
| style="text-align: right" | <tt style="white-space: nowrap">llll llll</tt>
| RW8
| Line (l)
|-
! $1A
| [[Display#LCD Status|LCD Status]]
| style="text-align: right" | <tt style="white-space: nowrap">...v vv.s</tt>
| RW8
| Volume segment status (v), Sleep (s)
|-
! $1C
| [[Display#LCD Mono Shade LUT|LCD Mono Shade LUT 0/1]]
| style="text-align: right" | <tt style="white-space: nowrap">1111 0000</tt>
| RW8
| Shade index
|-
! $1D
| [[Display#LCD Mono Shade LUT|LCD Mono Shade LUT 2/3]]
| style="text-align: right" | <tt style="white-space: nowrap">3333 2222</tt>
| RW8
| Shade index
|-
! $1E
| [[Display#LCD Mono Shade LUT|LCD Mono Shade LUT 4/5]]
| style="text-align: right" | <tt style="white-space: nowrap">5555 4444</tt>
| RW8
| Shade index
|-
! $1F
| [[Display#LCD Mono Shade LUT|LCD Mono Shade LUT 6/7]]
| style="text-align: right" | <tt style="white-space: nowrap">7777 6666</tt>
| RW8
| Shade index
|-
! $20
| [[Display#LCD Mono Palette|LCD Mono Palette 0]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $22
| [[Display#LCD Mono Palette|LCD Mono Palette 1]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $24
| [[Display#LCD Mono Palette|LCD Mono Palette 2]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $26
| [[Display#LCD Mono Palette|LCD Mono Palette 3]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $28
| [[Display#LCD Mono Palette|LCD Mono Palette 4]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $2A
| [[Display#LCD Mono Palette|LCD Mono Palette 5]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $2C
| [[Display#LCD Mono Palette|LCD Mono Palette 6]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $2E
| [[Display#LCD Mono Palette|LCD Mono Palette 7]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $30
| [[Display#LCD Mono Palette|LCD Mono Palette 8]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $32
| [[Display#LCD Mono Palette|LCD Mono Palette 9]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $34
| [[Display#LCD Mono Palette|LCD Mono Palette 10]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $36
| [[Display#LCD Mono Palette|LCD Mono Palette 11]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $38
| [[Display#LCD Mono Palette|LCD Mono Palette 12]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $3A
| [[Display#LCD Mono Palette|LCD Mono Palette 13]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $3C
| [[Display#LCD Mono Palette|LCD Mono Palette 14]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $3E
| [[Display#LCD Mono Palette|LCD Mono Palette 15]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! rowspan="10" | [[DMA]]<sup>(color)</sup>
! $40
| [[DMA#General DMA|GDMA Source Address Low]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll llll lll.</tt>
| RW16
| Linear address, low 16 bits (l)
|-
! $42
| [[DMA#General DMA|GDMA Source Address High]]
| style="text-align: right" | <tt style="white-space: nowrap">.... hhhh</tt>
| RW8
| Linear address, high 4 bits (h)
|-
! $44
| [[DMA#General DMA|GDMA Destination Address]]
| style="text-align: right" | <tt style="white-space: nowrap">aaaa aaaa aaaa aaa.</tt>
| RW16
| IRAM address (a)
|-
! $46
| [[DMA#General DMA|GDMA Length]]
| style="text-align: right" | <tt style="white-space: nowrap">bbbb bbbb bbbb bbb.</tt>
| RW16
| Bytes (b)
|-
! $48
| [[DMA#General DMA|GDMA Control]]
| style="text-align: right" | <tt style="white-space: nowrap">ed.. ....</tt>
| RW8
| Enable (e), Decrement (d)
|-
! $4A
| [[DMA#Sound DMA|SDMA Source Address Low]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll llll llll</tt>
| RW16
| Linear address, low 16 bits (l)
|-
! $4C
| [[DMA#Sound DMA|SDMA Source Address High]]
| style="text-align: right" | <tt style="white-space: nowrap">.... hhhh</tt>
| RW8
| Linear address, high 4 bits (h)
|-
! $4E
| [[DMA#Sound DMA|SDMA Length Low]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll llll llll</tt>
| RW16
| Length, low 16 bits (l)
|-
! $50
| [[DMA#Sound DMA|SDMA Length High]]
| style="text-align: right" | <tt style="white-space: nowrap">.... hhhh</tt>
| RW8
| Length, high 4 bits (h)
|-
! $52
| [[DMA#Sound DMA|SDMA Control]]
| style="text-align: right" | <tt style="white-space: nowrap">ed.t rhff</tt>
| RW8
| Enable (e), Decrement (d), Target (t),
Repeat (r), Hold (h), Frequency (f)
|-
! rowspan="2" | [[SoC]]<sup>(color)</sup>
! $60
| [[SoC#System Control 2|System Control 2]]
| style="text-align: right" | <tt style="white-space: nowrap">c4C. i?sl</tt>
| RW8
| Color (c), 4BPP (4), Chunky (C),<br/>
Cart I/O wait state (i), SRAM wait state (s),<br/>
Cart clock speed (l).
|-
! $62
| [[SoC#System Control 3|System Control 3]]
| style="text-align: right" | <tt style="white-space: nowrap">S... ...p</tt>
| RW8
| SwanCrystal (S), Power off (p)
|-
! rowspan="5" | [[Hyper Voice]]<sup>(color)</sup>
! $64
| [[Hyper Voice#Hyper Voice Output|Hyper Voice Left Output]]
| style="text-align: right" | <tt style="white-space: nowrap">ssss ssss ssss ssss</tt>
| W16
| Raw sample (s)
|-
! $66
| [[Hyper Voice#Hyper Voice Output|Hyper Voice Right Output]]
| style="text-align: right" | <tt style="white-space: nowrap">ssss ssss ssss ssss</tt>
| W16
| Raw sample (s)
|-
! $68
| [[Hyper Voice#Hyper Voice Input|Hyper Voice Left Input]]
| style="text-align: right" | <tt style="white-space: nowrap">ssss ssss</tt>
| W8
| Sample (s)
|-
! $69
| [[Hyper Voice#Hyper Voice Input|Hyper Voice Right Input]]
| style="text-align: right" | <tt style="white-space: nowrap">ssss ssss</tt>
| W8
| Sample (s)
|-
! $6A
| [[Hyper Voice#Hyper Voice Control|Hyper Voice Control]]
| style="text-align: right" | <tt style="white-space: nowrap">.mmc ???? errr ffss</tt>
| RW16
| Mask (m), Channel reset (c), Enable (e),
Rate (r), Format (f), Shift (s)
|-
! rowspan="8" | [[Display]]<sup>(SC)</sup>
! $70
| LCD Timing Configuration 1?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $71
| LCD Timing Configuration 2?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $72
| LCD Timing Configuration 3?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $73
| LCD Timing Configuration 4?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $74
| LCD Timing Configuration 5?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $75
| LCD Timing Configuration 6?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $76
| LCD Timing Configuration 7?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $77
| LCD Timing Configuration 8?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! rowspan="21" | [[Sound]]
! $80
| [[Sound#Sound Channel Frequency|Sound Channel 1 Frequency]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .ddd dddd dddd</tt>
| RW16
| Divider (d)
|-
! $82
| [[Sound#Sound Channel Frequency|Sound Channel 2 Frequency]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .ddd dddd dddd</tt>
| RW16
| Divider (d)
|-
! $84
| [[Sound#Sound Channel Frequency|Sound Channel 3 Frequency]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .ddd dddd dddd</tt>
| RW16
| Divider (d)
|-
! $86
| [[Sound#Sound Channel Frequency|Sound Channel 4 Frequency]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .ddd dddd dddd</tt>
| RW16
| Divider (d)
|-
! $88
| [[Sound#Sound Channel Volume|Sound Channel 1 Volume]]
| style="text-align: right" | <tt style="white-space: nowrap">llll rrrr</tt>
| RW8
| Left (l), Right (r)
|-
! rowspan="2" | $89
| [[Sound#Sound Channel Volume|Sound Channel 2 Volume]]
| style="text-align: right" | <tt style="white-space: nowrap">llll rrrr</tt>
| RW8
| Left (l), Right (r)
|-
| [[Sound#Sound Channel 2 Voice Sample|Sound Channel 2 Voice Sample]]
| style="text-align: right" | <tt style="white-space: nowrap">ssss ssss</tt>
| RW8
| Sample (s)
|-
! $8A
| [[Sound#Sound Channel Volume|Sound Channel 3 Volume]]
| style="text-align: right" | <tt style="white-space: nowrap">llll rrrr</tt>
| RW8
| Left (l), Right (r)
|-
! $8B
| [[Sound#Sound Channel Volume|Sound Channel 4 Volume]]
| style="text-align: right" | <tt style="white-space: nowrap">llll rrrr</tt>
| RW8
| Left (l), Right (r)
|-
! $8C
| [[Sound#Sound Channel 3 Sweep Amount|Sound Channel 3 Sweep Amount]]
| style="text-align: right" | <tt style="white-space: nowrap">vvvv vvvv</tt>
| RW8
| Value (v)
|-
! $8D
| [[Sound#Sound Channel 3 Sweep Ticks|Sound Channel 3 Sweep Ticks]]
| style="text-align: right" | <tt style="white-space: nowrap">...t tttt</tt>
| RW8
| Ticks (t)
|-
! $8E
| [[Sound#Sound Channel 4 Noise Control|Sound Channel 4 Noise Control]]
| style="text-align: right" | <tt style="white-space: nowrap">...e rttt</tt>
| RW8
| Enable (e), Reset (r), Tap (t)
|-
! $8F
| [[Sound#Sound Wavetable Address|Sound Wavetable Address]]
| style="text-align: right" | <tt style="white-space: nowrap">wwww wwww</tt>
| RW8
| Address >> 6 (w)
|-
! $90
| [[Sound#Sound Channel Control|Sound Channel Control]]
| style="text-align: right" | <tt style="white-space: nowrap">nsv. 4321</tt>
| RW8
| Channel enable (1234)
Noise (n), Sweep (s), Voice (v)
|-
! $91
| [[Sound#Sound Output Control|Sound Output Control]]
| style="text-align: right" | <tt style="white-space: nowrap">H... hrrs</tt>
| RW8
| Headphones connected (H)
Headphone output (h)
Speaker output (s), range (r)
|-
! $92
| [[Sound#Sound Channel 4 LFSR Register|Sound Channel 4 LFSR Register]]
| style="text-align: right" | <tt style="white-space: nowrap">.rrr rrrr rrrr rrrr</tt>
| R16
| PRNG state (r)
|-
! $94
| [[Sound#Sound Channel 2 Voice Volume|Sound Channel 2 Voice Volume]]
| style="text-align: right" | <tt style="white-space: nowrap">.... lLrR</tt>
| RW8
| Left Half (l), Full (L)
Right Half (r), Full (R)
|-
! $96
| Sound Channel Output Right
| style="text-align: right" | <tt style="white-space: nowrap">.... ..ss ssss ssss</tt>
| R16
| Sample (s)
|-
! $98
| Sound Channel Output Left
| style="text-align: right" | <tt style="white-space: nowrap">.... ..ss ssss ssss</tt>
| R16
| Sample (s)
|-
! $9A
| Sound Channel Output Sum
| style="text-align: right" | <tt style="white-space: nowrap">.... .sss ssss ssss</tt>
| R16
| Sample (s)
|-
! $9E
| Sound Speaker Master Volume<sup>(color)</sup>
| style="text-align: right" | <tt style="white-space: nowrap">.... ..vv</tt>
| RW8
| Master volume (v)
|-
! [[SoC]]
! $A0
| [[SoC#System Control|System Control]]
| style="text-align: right" | <tt style="white-space: nowrap">t??? swcl</tt>
| RW8
| Test OK (t), ROM wait state (s), ROM width (w),
Color system (c), Boot ROM lockout (l)
|-
! rowspan="5" | [[Timers]]
! $A2
| [[Timers#Timer Control|Timer Control]]
| style="text-align: right" | <tt style="white-space: nowrap">.... VvHh</tt>
| RW8
| Horizontal enable (h), auto reload (H)
Vertical enable (v), auto reload (V)
|-
! $A4
| [[Timers#Timer Reload|Horizontal Blank Timer Reload]]
| style="text-align: right" | <tt style="white-space: nowrap">tttt tttt tttt tttt</tt>
| RW16
| Ticks (t)
|-
! $A6
| [[Timers#Timer Reload|Vertical Blank Timer Reload]]
| style="text-align: right" | <tt style="white-space: nowrap">tttt tttt tttt tttt</tt>
| RW16
| Ticks (t)
|-
! $A8
| [[Timers#Timer Counter|Horizontal Blank Timer Counter]]
| style="text-align: right" | <tt style="white-space: nowrap">tttt tttt tttt tttt</tt>
| R16
| Ticks (t)
|-
! $AA
| [[Timers#Timer Counter|Vertical Blank Timer Counter]]
| style="text-align: right" | <tt style="white-space: nowrap">tttt tttt tttt tttt</tt>
| R16
| Ticks (t)
|-
! ?
! $AC
| ?
| style="text-align: right" | <tt style="white-space: nowrap">.... ...p</tt>
| W8?
| Power off (p)
|-
! rowspan="2" | [[Interrupts]]
! rowspan="2" | $B0
| [[Interrupts#Interrupt Vector Offset|Interrupt Vector Offset]]
| style="text-align: right" | <tt style="white-space: nowrap">VVVV V...</tt>
| W8
| Vector offset (V)
|-
| [[Interrupts#Interrupt Vector Request|Interrupt Vector Request]]
| style="text-align: right" | <tt style="white-space: nowrap">vvvv vvvv</tt>
| R8
| Requested vector offset (v)
|-
! rowspan="2" | [[UART]]
! $B1
| [[UART#Serial Receive Data|Serial Receive Data]]
| style="text-align: right" | <tt style="white-space: nowrap">dddd dddd</tt>
| R8
| Receive buffer data (d)
|-
! $B1
| [[UART#Serial Transmit Data|Serial Transmit Data]]
| style="text-align: right" | <tt style="white-space: nowrap">dddd dddd</tt>
| W8
| Transmit buffer data (d)
|-
! [[Interrupts]]
! $B2
| [[Interrupts#Interrupt Enable|Interrupt Enable]]
| iiii iiii
| RW8
| Interrupt index (i)
|-
! rowspan="2" | [[UART]]
! $B3
| [[UART#Serial Status|Serial Status]]
| style="text-align: right" | <tt style="white-space: nowrap">eb.. .tor</tt>
| R8
| Enable (e), Baud rate (b),
Transfer ready (t), Overrun (o), Receive ready (r)
|-
! $B3
| [[UART#Serial Control|Serial Control]]
| style="text-align: right" | <tt style="white-space: nowrap">ebO. ....</tt>
| W8
| Enable (e), Baud rate (b), Reset Overrun (O)
|-
! [[Interrupts]]
! $B4
| [[Interrupts#Interrupt Status|Interrupt Status]]
| iiii iiii
| R8
| Interrupt index (i)
|-
! [[Keypad]]
! $B5
| [[Keypad|Keypad Scan]]
| style="text-align: right" | <tt style="white-space: nowrap">.iii oooo</tt>
| RW8
| Input row (i), Output column (o)
|-
! rowspan="2" | [[Interrupts]]
! $B6
| [[Interrupts#Interrupt Acknowledge|Interrupt Acknowledge]]
| iiii iiii
| W8
| Interrupt index (i)
|-
! $B7
| [[Interrupts#Interrupt NMI Control|Interrupt NMI Control]]
| style="text-align: right" | <tt style="white-space: nowrap">...b ....</tt>
| RW8
| Low battery (b)
|-
! rowspan="4" | [[EEPROM|Internal EEPROM]]
! $BA
| [[EEPROM#Internal EEPROM Data|Internal EEPROM Data]]
| style="text-align: right" | <tt style="white-space: nowrap">dddd dddd dddd dddd</tt>
| RW16
| Data (d)
|-
! $BC
| [[EEPROM#Internal EEPROM Command|Internal EEPROM Command]]
|
| RW16
|
|-
! rowspan="2" | $BE
| [[EEPROM#Internal EEPROM Status|Internal EEPROM Status]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .... p... ..RD</tt>
| R16
| Protected (p), Ready (R), Done (D)
|-
| [[EEPROM#Internal EEPROM Control|Internal EEPROM Control]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .... pewr ....</tt>
| W16
| Protect (p), Erase (e), Write (w), Read (r)
|-
! [[Mapper|Cartridge]]
! $C0<br />
$FF
| Cartridge I/O
|
| RW8
| Forwarded by the SoC
|}
== I/O port routing ==
The [[NEC V30MZ]] supports 16-bit I/O port addresses. The WonderSwan SoC routes them using the following algorithm:
* If an address is between <code>$00B8</code> and <code>$00BF</code> inclusive, it is routed to the internal EEPROM control block.
* If an address is between <code>$00C0</code> and <code>$00FF</code> inclusive, it is routed to the cartride bus.
* If an address's bits <code>0</code> through <code>8</code> inclusive are between <code>$000</code> and <code>$0B7</code> inclusive, they are routed to the SoC block.
* If none of these conditions are reached, open bus is read.
On the monochrome models, as well as color models in mono emulation, open bus is always <code>0x90</code>.
3ebfc6c9b834d075944bad053ae17ec1774f349f
245
234
2024-02-08T22:16:48Z
Fiskbit
37
/* I/O port map */ Formatting.
wikitext
text/x-wiki
The WonderSwan SoC has three general blocks of I/O port accesses:
{| class="wikitable"
! From !! To !! Holder !! Width !! Speed
|-
| $00 || $B7 || WonderSwan SoC || 16-bit || 1 cycle
|-
| $B8 || $BF || Internal EEPROM control || 16-bit || 1 cycle
|-
| $C0 || $FF || Cartridge bus || 8-bit || 1<sup>(color)</sup>/2 cycles (configurable)
|}
With the exception of internal EEPROM on the ASWAN, all unaligned 16-bit accesses can be converted to two 8-bit accesses with a 1-cycle penalty.
== I/O port map ==
* Superscripts are used to mark ports specific to a given mode or platform:
** Color mode: <sup>(color)</sup>. Such ports are only accessible when color mode is enabled through port <code>$60</code>.
** WS/WSC/SC console: <sup>(WS)</sup>, <sup>(WSC)</sup>, <sup>(SC)</sup>.
* If two Bits rows are provided, the second one refers to the "Color" mode.
* The Type can be: R - readable, W - writable, L - writable before boot ROM lockout, 8/16 - width (byte/word).
{| class="wikitable"
! Category
! Port
! Description
! Bits
! Type
! Notes
|-
! rowspan="45" | [[Display]]
! $00
| [[Display#Display Control|Display Control]]
| style="text-align: right" | <tt style="white-space: nowrap">..ow Ws21</tt>
| RW8
|
|-
! $01
| [[Display#Display Background|Display Background]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .sss</tt>
<tt style="white-space: nowrap">pppp iiii</tt>
| RW8
| Shade (s)
Palette (p), Index (i)
|-
! $02
| [[Display#Current Line|Display Current Line]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll</tt>
| R8
| Line (l)
|-
! $03
| [[Display#Interrupt Line|Display Interrupt Line]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll</tt>
| RW8
| Line (l)
|-
! $04
| [[Display#Sprite Table Address|Sprite Table Address]]
| style="text-align: right" | <tt style="white-space: nowrap">...a aaaa</tt>
<tt style="white-space: nowrap">..aa aaaa</tt>
| RW8
| Address >> 9 (a)
|-
! $05
| [[Display#Sprite Table First|Sprite Table First]]
| style="text-align: right" | <tt style="white-space: nowrap">.iii iiii</tt>
| RW8
| Index (i)
|-
! $06
| [[Display#Sprite Table Count|Sprite Table Count]]
| style="text-align: right" | <tt style="white-space: nowrap">cccc cccc</tt>
| RW8
| Count (c)
|-
! $07
| [[Display#Screen Address|Screen Address]]
| style="text-align: right" | <tt style="white-space: nowrap">.222 .111</tt>
<tt style="white-space: nowrap">2222 1111</tt>
| RW8
| Screen 1 address >> 11 (1)
Screen 2 address >> 11 (2)
|-
! $08
| [[Display#Screen 2 Window|Screen 2 Window Left]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $09
| [[Display#Screen 2 Window|Screen 2 Window Top]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $0A
| [[Display#Screen 2 Window|Screen 2 Window Right]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $0B
| [[Display#Screen 2 Window|Screen 2 Window Bottom]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $0B
| [[Display#Sprite Window|Sprite Window Left]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $0C
| [[Display#Sprite Window|Sprite Window Top]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $0E
| [[Display#Sprite Window|Sprite Window Right]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $0F
| [[Display#Sprite Window|Sprite Window Bottom]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $10
| [[Display#Screen Scroll|Screen 1 Scroll X]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $11
| [[Display#Screen Scroll|Screen 1 Scroll Y]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $12
| [[Display#Screen Scroll|Screen 2 Scroll X]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $13
| [[Display#Screen Scroll|Screen 2 Scroll Y]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $14
| [[Display#LCD Control|LCD Control]]
| style="text-align: right" | <tt style="white-space: nowrap">.... ..Ce</tt>
| RW8
| Contrast (C)<sup>(WSC)</sup>, Enable (e)
|-
! $15
| [[Display#LCD Icon Control|LCD Icon Control]]
| style="text-align: right" | <tt style="white-space: nowrap">..32 1hvs</tt>
| RW8
| Auxillary 3 (3), Auxillary 2 (2), Auxillary 1 (1),
Horizontal (h), Vertical (v), Sleep (s)
|-
! $16
| [[Display#LCD Final Line|LCD Final Line]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll</tt>
| RW8
| Line (l)
|-
! $17
| [[Display#LCD Back Porch Line|LCD Back Porch Line]]<sup>(WSC)</sup>
| style="text-align: right" | <tt style="white-space: nowrap">llll llll</tt>
| RW8
| Line (l)
|-
! $1A
| [[Display#LCD Status|LCD Status]]
| style="text-align: right" | <tt style="white-space: nowrap">...v vv.s</tt>
| RW8
| Volume segment status (v), Sleep (s)
|-
! $1C
| [[Display#LCD Mono Shade LUT|LCD Mono Shade LUT 0/1]]
| style="text-align: right" | <tt style="white-space: nowrap">1111 0000</tt>
| RW8
| Shade index
|-
! $1D
| [[Display#LCD Mono Shade LUT|LCD Mono Shade LUT 2/3]]
| style="text-align: right" | <tt style="white-space: nowrap">3333 2222</tt>
| RW8
| Shade index
|-
! $1E
| [[Display#LCD Mono Shade LUT|LCD Mono Shade LUT 4/5]]
| style="text-align: right" | <tt style="white-space: nowrap">5555 4444</tt>
| RW8
| Shade index
|-
! $1F
| [[Display#LCD Mono Shade LUT|LCD Mono Shade LUT 6/7]]
| style="text-align: right" | <tt style="white-space: nowrap">7777 6666</tt>
| RW8
| Shade index
|-
! $20
| [[Display#LCD Mono Palette|LCD Mono Palette 0]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $22
| [[Display#LCD Mono Palette|LCD Mono Palette 1]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $24
| [[Display#LCD Mono Palette|LCD Mono Palette 2]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $26
| [[Display#LCD Mono Palette|LCD Mono Palette 3]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $28
| [[Display#LCD Mono Palette|LCD Mono Palette 4]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $2A
| [[Display#LCD Mono Palette|LCD Mono Palette 5]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $2C
| [[Display#LCD Mono Palette|LCD Mono Palette 6]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $2E
| [[Display#LCD Mono Palette|LCD Mono Palette 7]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $30
| [[Display#LCD Mono Palette|LCD Mono Palette 8]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $32
| [[Display#LCD Mono Palette|LCD Mono Palette 9]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $34
| [[Display#LCD Mono Palette|LCD Mono Palette 10]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $36
| [[Display#LCD Mono Palette|LCD Mono Palette 11]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $38
| [[Display#LCD Mono Palette|LCD Mono Palette 12]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $3A
| [[Display#LCD Mono Palette|LCD Mono Palette 13]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $3C
| [[Display#LCD Mono Palette|LCD Mono Palette 14]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $3E
| [[Display#LCD Mono Palette|LCD Mono Palette 15]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! rowspan="10" | [[DMA]]<sup>(color)</sup>
! $40
| [[DMA#General DMA|GDMA Source Address Low]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll llll lll.</tt>
| RW16
| Linear address, low 16 bits (l)
|-
! $42
| [[DMA#General DMA|GDMA Source Address High]]
| style="text-align: right" | <tt style="white-space: nowrap">.... hhhh</tt>
| RW8
| Linear address, high 4 bits (h)
|-
! $44
| [[DMA#General DMA|GDMA Destination Address]]
| style="text-align: right" | <tt style="white-space: nowrap">aaaa aaaa aaaa aaa.</tt>
| RW16
| IRAM address (a)
|-
! $46
| [[DMA#General DMA|GDMA Length]]
| style="text-align: right" | <tt style="white-space: nowrap">bbbb bbbb bbbb bbb.</tt>
| RW16
| Bytes (b)
|-
! $48
| [[DMA#General DMA|GDMA Control]]
| style="text-align: right" | <tt style="white-space: nowrap">ed.. ....</tt>
| RW8
| Enable (e), Decrement (d)
|-
! $4A
| [[DMA#Sound DMA|SDMA Source Address Low]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll llll llll</tt>
| RW16
| Linear address, low 16 bits (l)
|-
! $4C
| [[DMA#Sound DMA|SDMA Source Address High]]
| style="text-align: right" | <tt style="white-space: nowrap">.... hhhh</tt>
| RW8
| Linear address, high 4 bits (h)
|-
! $4E
| [[DMA#Sound DMA|SDMA Length Low]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll llll llll</tt>
| RW16
| Length, low 16 bits (l)
|-
! $50
| [[DMA#Sound DMA|SDMA Length High]]
| style="text-align: right" | <tt style="white-space: nowrap">.... hhhh</tt>
| RW8
| Length, high 4 bits (h)
|-
! $52
| [[DMA#Sound DMA|SDMA Control]]
| style="text-align: right" | <tt style="white-space: nowrap">ed.t rhff</tt>
| RW8
| Enable (e), Decrement (d), Target (t),
Repeat (r), Hold (h), Frequency (f)
|-
! rowspan="2" | [[SoC]]<sup>(color)</sup>
! $60
| [[SoC#System Control 2|System Control 2]]
| style="text-align: right" | <tt style="white-space: nowrap">c4C. i?sl</tt>
| RW8
| Color (c), 4BPP (4), Chunky (C),<br/>
Cart I/O wait state (i), SRAM wait state (s),<br/>
Cart clock speed (l).
|-
! $62
| [[SoC#System Control 3|System Control 3]]
| style="text-align: right" | <tt style="white-space: nowrap">S... ...p</tt>
| RW8
| SwanCrystal (S), Power off (p)
|-
! rowspan="5" | [[Hyper Voice]]<sup>(color)</sup>
! $64
| [[Hyper Voice#Hyper Voice Output|Hyper Voice Left Output]]
| style="text-align: right" | <tt style="white-space: nowrap">ssss ssss ssss ssss</tt>
| W16
| Raw sample (s)
|-
! $66
| [[Hyper Voice#Hyper Voice Output|Hyper Voice Right Output]]
| style="text-align: right" | <tt style="white-space: nowrap">ssss ssss ssss ssss</tt>
| W16
| Raw sample (s)
|-
! $68
| [[Hyper Voice#Hyper Voice Input|Hyper Voice Left Input]]
| style="text-align: right" | <tt style="white-space: nowrap">ssss ssss</tt>
| W8
| Sample (s)
|-
! $69
| [[Hyper Voice#Hyper Voice Input|Hyper Voice Right Input]]
| style="text-align: right" | <tt style="white-space: nowrap">ssss ssss</tt>
| W8
| Sample (s)
|-
! $6A
| [[Hyper Voice#Hyper Voice Control|Hyper Voice Control]]
| style="text-align: right" | <tt style="white-space: nowrap">.mmc ???? errr ffss</tt>
| RW16
| Mask (m), Channel reset (c), Enable (e),
Rate (r), Format (f), Shift (s)
|-
! rowspan="8" | [[Display]]<sup>(SC)</sup>
! $70
| LCD Timing Configuration 1?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $71
| LCD Timing Configuration 2?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $72
| LCD Timing Configuration 3?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $73
| LCD Timing Configuration 4?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $74
| LCD Timing Configuration 5?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $75
| LCD Timing Configuration 6?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $76
| LCD Timing Configuration 7?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $77
| LCD Timing Configuration 8?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! rowspan="21" | [[Sound]]
! $80
| [[Sound#Sound Channel Frequency|Sound Channel 1 Frequency]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .ddd dddd dddd</tt>
| RW16
| Divider (d)
|-
! $82
| [[Sound#Sound Channel Frequency|Sound Channel 2 Frequency]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .ddd dddd dddd</tt>
| RW16
| Divider (d)
|-
! $84
| [[Sound#Sound Channel Frequency|Sound Channel 3 Frequency]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .ddd dddd dddd</tt>
| RW16
| Divider (d)
|-
! $86
| [[Sound#Sound Channel Frequency|Sound Channel 4 Frequency]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .ddd dddd dddd</tt>
| RW16
| Divider (d)
|-
! $88
| [[Sound#Sound Channel Volume|Sound Channel 1 Volume]]
| style="text-align: right" | <tt style="white-space: nowrap">llll rrrr</tt>
| RW8
| Left (l), Right (r)
|-
! rowspan="2" | $89
| [[Sound#Sound Channel Volume|Sound Channel 2 Volume]]
| style="text-align: right" | <tt style="white-space: nowrap">llll rrrr</tt>
| RW8
| Left (l), Right (r)
|-
| [[Sound#Sound Channel 2 Voice Sample|Sound Channel 2 Voice Sample]]
| style="text-align: right" | <tt style="white-space: nowrap">ssss ssss</tt>
| RW8
| Sample (s)
|-
! $8A
| [[Sound#Sound Channel Volume|Sound Channel 3 Volume]]
| style="text-align: right" | <tt style="white-space: nowrap">llll rrrr</tt>
| RW8
| Left (l), Right (r)
|-
! $8B
| [[Sound#Sound Channel Volume|Sound Channel 4 Volume]]
| style="text-align: right" | <tt style="white-space: nowrap">llll rrrr</tt>
| RW8
| Left (l), Right (r)
|-
! $8C
| [[Sound#Sound Channel 3 Sweep Amount|Sound Channel 3 Sweep Amount]]
| style="text-align: right" | <tt style="white-space: nowrap">vvvv vvvv</tt>
| RW8
| Value (v)
|-
! $8D
| [[Sound#Sound Channel 3 Sweep Ticks|Sound Channel 3 Sweep Ticks]]
| style="text-align: right" | <tt style="white-space: nowrap">...t tttt</tt>
| RW8
| Ticks (t)
|-
! $8E
| [[Sound#Sound Channel 4 Noise Control|Sound Channel 4 Noise Control]]
| style="text-align: right" | <tt style="white-space: nowrap">...e rttt</tt>
| RW8
| Enable (e), Reset (r), Tap (t)
|-
! $8F
| [[Sound#Sound Wavetable Address|Sound Wavetable Address]]
| style="text-align: right" | <tt style="white-space: nowrap">wwww wwww</tt>
| RW8
| Address >> 6 (w)
|-
! $90
| [[Sound#Sound Channel Control|Sound Channel Control]]
| style="text-align: right" | <tt style="white-space: nowrap">nsv. 4321</tt>
| RW8
| Channel enable (1234)
Noise (n), Sweep (s), Voice (v)
|-
! $91
| [[Sound#Sound Output Control|Sound Output Control]]
| style="text-align: right" | <tt style="white-space: nowrap">H... hrrs</tt>
| RW8
| Headphones connected (H)
Headphone output (h)
Speaker output (s), range (r)
|-
! $92
| [[Sound#Sound Channel 4 LFSR Register|Sound Channel 4 LFSR Register]]
| style="text-align: right" | <tt style="white-space: nowrap">.rrr rrrr rrrr rrrr</tt>
| R16
| PRNG state (r)
|-
! $94
| [[Sound#Sound Channel 2 Voice Volume|Sound Channel 2 Voice Volume]]
| style="text-align: right" | <tt style="white-space: nowrap">.... lLrR</tt>
| RW8
| Left Half (l), Full (L)
Right Half (r), Full (R)
|-
! $96
| Sound Channel Output Right
| style="text-align: right" | <tt style="white-space: nowrap">.... ..ss ssss ssss</tt>
| R16
| Sample (s)
|-
! $98
| Sound Channel Output Left
| style="text-align: right" | <tt style="white-space: nowrap">.... ..ss ssss ssss</tt>
| R16
| Sample (s)
|-
! $9A
| Sound Channel Output Sum
| style="text-align: right" | <tt style="white-space: nowrap">.... .sss ssss ssss</tt>
| R16
| Sample (s)
|-
! $9E
| Sound Speaker Master Volume<sup>(color)</sup>
| style="text-align: right" | <tt style="white-space: nowrap">.... ..vv</tt>
| RW8
| Master volume (v)
|-
! [[SoC]]
! $A0
| [[SoC#System Control|System Control]]
| style="text-align: right" | <tt style="white-space: nowrap">t??? swcl</tt>
| RW8
| Test OK (t), ROM wait state (s), ROM width (w),
Color system (c), Boot ROM lockout (l)
|-
! rowspan="5" | [[Timers]]
! $A2
| [[Timers#Timer Control|Timer Control]]
| style="text-align: right" | <tt style="white-space: nowrap">.... VvHh</tt>
| RW8
| Horizontal enable (h), auto reload (H)
Vertical enable (v), auto reload (V)
|-
! $A4
| [[Timers#Timer Reload|Horizontal Blank Timer Reload]]
| style="text-align: right" | <tt style="white-space: nowrap">tttt tttt tttt tttt</tt>
| RW16
| Ticks (t)
|-
! $A6
| [[Timers#Timer Reload|Vertical Blank Timer Reload]]
| style="text-align: right" | <tt style="white-space: nowrap">tttt tttt tttt tttt</tt>
| RW16
| Ticks (t)
|-
! $A8
| [[Timers#Timer Counter|Horizontal Blank Timer Counter]]
| style="text-align: right" | <tt style="white-space: nowrap">tttt tttt tttt tttt</tt>
| R16
| Ticks (t)
|-
! $AA
| [[Timers#Timer Counter|Vertical Blank Timer Counter]]
| style="text-align: right" | <tt style="white-space: nowrap">tttt tttt tttt tttt</tt>
| R16
| Ticks (t)
|-
! ?
! $AC
| ?
| style="text-align: right" | <tt style="white-space: nowrap">.... ...p</tt>
| W8?
| Power off (p)
|-
! rowspan="2" | [[Interrupts]]
! rowspan="2" | $B0
| [[Interrupts#Interrupt Vector Offset|Interrupt Vector Offset]]
| style="text-align: right" | <tt style="white-space: nowrap">VVVV V...</tt>
| W8
| Vector offset (V)
|-
| [[Interrupts#Interrupt Vector Request|Interrupt Vector Request]]
| style="text-align: right" | <tt style="white-space: nowrap">vvvv vvvv</tt>
| R8
| Requested vector offset (v)
|-
! rowspan="2" | [[UART]]
! $B1
| [[UART#Serial Receive Data|Serial Receive Data]]
| style="text-align: right" | <tt style="white-space: nowrap">dddd dddd</tt>
| R8
| Receive buffer data (d)
|-
! $B1
| [[UART#Serial Transmit Data|Serial Transmit Data]]
| style="text-align: right" | <tt style="white-space: nowrap">dddd dddd</tt>
| W8
| Transmit buffer data (d)
|-
! [[Interrupts]]
! $B2
| [[Interrupts#Interrupt Enable|Interrupt Enable]]
| style="text-align: right" | <tt style="white-space: nowrap">iiii iiii</tt>
| RW8
| Interrupt index (i)
|-
! rowspan="2" | [[UART]]
! $B3
| [[UART#Serial Status|Serial Status]]
| style="text-align: right" | <tt style="white-space: nowrap">eb.. .tor</tt>
| R8
| Enable (e), Baud rate (b),
Transfer ready (t), Overrun (o), Receive ready (r)
|-
! $B3
| [[UART#Serial Control|Serial Control]]
| style="text-align: right" | <tt style="white-space: nowrap">ebO. ....</tt>
| W8
| Enable (e), Baud rate (b), Reset Overrun (O)
|-
! [[Interrupts]]
! $B4
| [[Interrupts#Interrupt Status|Interrupt Status]]
| style="text-align: right" | <tt style="white-space: nowrap">iiii iiii</tt>
| R8
| Interrupt index (i)
|-
! [[Keypad]]
! $B5
| [[Keypad|Keypad Scan]]
| style="text-align: right" | <tt style="white-space: nowrap">.iii oooo</tt>
| RW8
| Input row (i), Output column (o)
|-
! rowspan="2" | [[Interrupts]]
! $B6
| [[Interrupts#Interrupt Acknowledge|Interrupt Acknowledge]]
| style="text-align: right" | <tt style="white-space: nowrap">iiii iiii</tt>
| W8
| Interrupt index (i)
|-
! $B7
| [[Interrupts#Interrupt NMI Control|Interrupt NMI Control]]
| style="text-align: right" | <tt style="white-space: nowrap">...b ....</tt>
| RW8
| Low battery (b)
|-
! rowspan="4" | [[EEPROM|Internal EEPROM]]
! $BA
| [[EEPROM#Internal EEPROM Data|Internal EEPROM Data]]
| style="text-align: right" | <tt style="white-space: nowrap">dddd dddd dddd dddd</tt>
| RW16
| Data (d)
|-
! $BC
| [[EEPROM#Internal EEPROM Command|Internal EEPROM Command]]
|
| RW16
|
|-
! rowspan="2" | $BE
| [[EEPROM#Internal EEPROM Status|Internal EEPROM Status]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .... p... ..RD</tt>
| R16
| Protected (p), Ready (R), Done (D)
|-
| [[EEPROM#Internal EEPROM Control|Internal EEPROM Control]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .... pewr ....</tt>
| W16
| Protect (p), Erase (e), Write (w), Read (r)
|-
! [[Mapper|Cartridge]]
! $C0<br />...<br />
$FF
| Cartridge I/O
|
| RW8
| Forwarded by the SoC
|}
== I/O port routing ==
The [[NEC V30MZ]] supports 16-bit I/O port addresses. The WonderSwan SoC routes them using the following algorithm:
* If an address is between <code>$00B8</code> and <code>$00BF</code> inclusive, it is routed to the internal EEPROM control block.
* If an address is between <code>$00C0</code> and <code>$00FF</code> inclusive, it is routed to the cartride bus.
* If an address's bits <code>0</code> through <code>8</code> inclusive are between <code>$000</code> and <code>$0B7</code> inclusive, they are routed to the SoC block.
* If none of these conditions are reached, open bus is read.
On the monochrome models, as well as color models in mono emulation, open bus is always <code>0x90</code>.
c253ae2d2f246460b468c130b35326a7253b2f26
Interrupts
0
22
220
116
2023-08-29T21:07:20Z
Asie
351
wikitext
text/x-wiki
== Interrupts ==
The WonderSwan features fourteen different interrupts:
* CPU interrupts - six provided by the V30MZ CPU ($00-$05),
* Hardware interrupts - eight provided by the SoC's hardware ($00-$07, or $08-$0F, or $10-$1F, or ... $F8-$FF - controlled by an offset <code>V</code>):
** Level - will be constantly requested while the prerequisite condition is true; interruption can only be prevented by resolving the condition or disabling the interrupt;
** Edge - will only be requested when the prerequisite condition ''becomes'' true; acknowledging the interrupt prevents further interruption.
The user can additionally define and use any of the 256 interrupt vectors in their own code.
{| class="wikitable"
|+ List of WonderSwan interrupts
! Source
! Type
! Index
! Description
|-
! rowspan="6" | CPU
| rowspan="6" | N/A
| $00
| DIV or IDIV instruction divide error<br/>
(division by zero or result overflow)
|-
| $01
| Single-step (T flag)
|-
| $02
| NMI (non-maskable interrupt)
|-
| $03
| INT 3 opcode
|-
| $04
| INTO opcode (if V = 1)
|-
| $05
| BOUND opcode (if index out of bounds)
|-
! rowspan="8" | Hardware
| Level
| V + 0
| [[UART|UART Send Ready]]
|-
| Edge
| V + 1
| [[Keypad|Key Pressed]]
|-
| rowspan="2" | Level
| V + 2
| [[Cartridge|Cartridge IRQ]]
|-
| V + 3
| [[UART|UART Receive Ready]]
|-
| rowspan="4" | Edge
| V + 4
| [[Display|Display Interrupt Line Match]]
|-
| V + 5
| [[Timers|Vertical Blank Timer]]
|-
| V + 6
| [[Display|Display Vertical Blank]]
|-
| V + 7
| [[Timers|Horizontal Blank Timer]]
|}
== I/O ports ==
{{Anchor|Interrupt Vector Offset}}
=== Interrupt Vector Offset ($B0 write) ===
<pre>
7 bit 0
---- ----
VVVV V...
|||| ||||
++++-++++- Interrupt vector offset
</pre>
{{Anchor|Interrupt Vector Request}}
=== Interrupt Vector Request ($B0 read) ===
<pre>
7 bit 0
---- ----
vvvv vvvv
|||| ||||
++++-++++- Interrupt vector requested
from the CPU.
</pre>
* Bits <code>3 .. 7</code> of this will always equal the user-provided vector offset.
* Bits <code>0 .. 2</code> of this will always equal the highest set bit index of Interrupt Status; if all bits in Interrupt Status are clear, they will equal <code>0</code>.
{{Anchor|Interrupt Enable}}
=== Interrupt Enable ($B2) ===
<pre>
7 bit 0
---- ----
iiii iiii
|||| ||||
++++-++++- Hardware interrupt to enable
(acts as a mask)
</pre>
{{Anchor|Interrupt Status}}
=== Interrupt Status ($B4 read)===
<pre>
7 bit 0
---- ----
iiii iiii
|||| ||||
++++-++++- 1 if interrupt requested
</pre>
{{Anchor|Interrupt Acknowledge}}
=== Interrupt Acknowledge ($B6 write)===
<pre>
7 bit 0
---- ----
iiii iiii
|||| ||||
++++-++++- Write 1 to clear interrupt request
</pre>
{{Anchor|Interrupt NMI Control}}
=== Interrupt NMI Control ($B7)===
<pre>
7 bit 0
---- ----
...b ....
|
+----- Enable NMI on low battery detection
</pre>
20815c76159f41c73341fb4cd2b5dbb9d96a50b7
246
220
2024-02-08T22:18:17Z
Fiskbit
37
/* Interrupt Vector Offset ($B0 write) */ Formatting.
wikitext
text/x-wiki
== Interrupts ==
The WonderSwan features fourteen different interrupts:
* CPU interrupts - six provided by the V30MZ CPU ($00-$05),
* Hardware interrupts - eight provided by the SoC's hardware ($00-$07, or $08-$0F, or $10-$1F, or ... $F8-$FF - controlled by an offset <code>V</code>):
** Level - will be constantly requested while the prerequisite condition is true; interruption can only be prevented by resolving the condition or disabling the interrupt;
** Edge - will only be requested when the prerequisite condition ''becomes'' true; acknowledging the interrupt prevents further interruption.
The user can additionally define and use any of the 256 interrupt vectors in their own code.
{| class="wikitable"
|+ List of WonderSwan interrupts
! Source
! Type
! Index
! Description
|-
! rowspan="6" | CPU
| rowspan="6" | N/A
| $00
| DIV or IDIV instruction divide error<br/>
(division by zero or result overflow)
|-
| $01
| Single-step (T flag)
|-
| $02
| NMI (non-maskable interrupt)
|-
| $03
| INT 3 opcode
|-
| $04
| INTO opcode (if V = 1)
|-
| $05
| BOUND opcode (if index out of bounds)
|-
! rowspan="8" | Hardware
| Level
| V + 0
| [[UART|UART Send Ready]]
|-
| Edge
| V + 1
| [[Keypad|Key Pressed]]
|-
| rowspan="2" | Level
| V + 2
| [[Cartridge|Cartridge IRQ]]
|-
| V + 3
| [[UART|UART Receive Ready]]
|-
| rowspan="4" | Edge
| V + 4
| [[Display|Display Interrupt Line Match]]
|-
| V + 5
| [[Timers|Vertical Blank Timer]]
|-
| V + 6
| [[Display|Display Vertical Blank]]
|-
| V + 7
| [[Timers|Horizontal Blank Timer]]
|}
== I/O ports ==
{{Anchor|Interrupt Vector Offset}}
=== Interrupt Vector Offset ($B0 write) ===
<pre>
7 bit 0
---- ----
VVVV V...
|||| |
++++-+---- Interrupt vector offset
</pre>
{{Anchor|Interrupt Vector Request}}
=== Interrupt Vector Request ($B0 read) ===
<pre>
7 bit 0
---- ----
vvvv vvvv
|||| ||||
++++-++++- Interrupt vector requested
from the CPU.
</pre>
* Bits <code>3 .. 7</code> of this will always equal the user-provided vector offset.
* Bits <code>0 .. 2</code> of this will always equal the highest set bit index of Interrupt Status; if all bits in Interrupt Status are clear, they will equal <code>0</code>.
{{Anchor|Interrupt Enable}}
=== Interrupt Enable ($B2) ===
<pre>
7 bit 0
---- ----
iiii iiii
|||| ||||
++++-++++- Hardware interrupt to enable
(acts as a mask)
</pre>
{{Anchor|Interrupt Status}}
=== Interrupt Status ($B4 read)===
<pre>
7 bit 0
---- ----
iiii iiii
|||| ||||
++++-++++- 1 if interrupt requested
</pre>
{{Anchor|Interrupt Acknowledge}}
=== Interrupt Acknowledge ($B6 write)===
<pre>
7 bit 0
---- ----
iiii iiii
|||| ||||
++++-++++- Write 1 to clear interrupt request
</pre>
{{Anchor|Interrupt NMI Control}}
=== Interrupt NMI Control ($B7)===
<pre>
7 bit 0
---- ----
...b ....
|
+----- Enable NMI on low battery detection
</pre>
aa800009ef2735c9fddcb46077a282361de2c48a
247
246
2024-02-08T22:19:42Z
Fiskbit
37
/* Interrupt Vector Request ($B0 read) */ Bit direction (high to low).
wikitext
text/x-wiki
== Interrupts ==
The WonderSwan features fourteen different interrupts:
* CPU interrupts - six provided by the V30MZ CPU ($00-$05),
* Hardware interrupts - eight provided by the SoC's hardware ($00-$07, or $08-$0F, or $10-$1F, or ... $F8-$FF - controlled by an offset <code>V</code>):
** Level - will be constantly requested while the prerequisite condition is true; interruption can only be prevented by resolving the condition or disabling the interrupt;
** Edge - will only be requested when the prerequisite condition ''becomes'' true; acknowledging the interrupt prevents further interruption.
The user can additionally define and use any of the 256 interrupt vectors in their own code.
{| class="wikitable"
|+ List of WonderSwan interrupts
! Source
! Type
! Index
! Description
|-
! rowspan="6" | CPU
| rowspan="6" | N/A
| $00
| DIV or IDIV instruction divide error<br/>
(division by zero or result overflow)
|-
| $01
| Single-step (T flag)
|-
| $02
| NMI (non-maskable interrupt)
|-
| $03
| INT 3 opcode
|-
| $04
| INTO opcode (if V = 1)
|-
| $05
| BOUND opcode (if index out of bounds)
|-
! rowspan="8" | Hardware
| Level
| V + 0
| [[UART|UART Send Ready]]
|-
| Edge
| V + 1
| [[Keypad|Key Pressed]]
|-
| rowspan="2" | Level
| V + 2
| [[Cartridge|Cartridge IRQ]]
|-
| V + 3
| [[UART|UART Receive Ready]]
|-
| rowspan="4" | Edge
| V + 4
| [[Display|Display Interrupt Line Match]]
|-
| V + 5
| [[Timers|Vertical Blank Timer]]
|-
| V + 6
| [[Display|Display Vertical Blank]]
|-
| V + 7
| [[Timers|Horizontal Blank Timer]]
|}
== I/O ports ==
{{Anchor|Interrupt Vector Offset}}
=== Interrupt Vector Offset ($B0 write) ===
<pre>
7 bit 0
---- ----
VVVV V...
|||| |
++++-+---- Interrupt vector offset
</pre>
{{Anchor|Interrupt Vector Request}}
=== Interrupt Vector Request ($B0 read) ===
<pre>
7 bit 0
---- ----
vvvv vvvv
|||| ||||
++++-++++- Interrupt vector requested
from the CPU.
</pre>
* Bits <code>7 .. 3</code> of this will always equal the user-provided vector offset.
* Bits <code>2 .. 0</code> of this will always equal the highest set bit index of Interrupt Status; if all bits in Interrupt Status are clear, they will equal <code>0</code>.
{{Anchor|Interrupt Enable}}
=== Interrupt Enable ($B2) ===
<pre>
7 bit 0
---- ----
iiii iiii
|||| ||||
++++-++++- Hardware interrupt to enable
(acts as a mask)
</pre>
{{Anchor|Interrupt Status}}
=== Interrupt Status ($B4 read)===
<pre>
7 bit 0
---- ----
iiii iiii
|||| ||||
++++-++++- 1 if interrupt requested
</pre>
{{Anchor|Interrupt Acknowledge}}
=== Interrupt Acknowledge ($B6 write)===
<pre>
7 bit 0
---- ----
iiii iiii
|||| ||||
++++-++++- Write 1 to clear interrupt request
</pre>
{{Anchor|Interrupt NMI Control}}
=== Interrupt NMI Control ($B7)===
<pre>
7 bit 0
---- ----
...b ....
|
+----- Enable NMI on low battery detection
</pre>
531e6603789f1b5d9b5d1b32d3e29e2d820b5fe1
Memory map
0
25
225
93
2023-08-30T17:33:44Z
Asie
351
wikitext
text/x-wiki
The WonderSwan's SoC enforces the following memory map layout:
{| class="wikitable"
|+ WonderSwan SoC linear memory map
! Bus
! colspan="2" | Address range
! Access width
! Access speed
! Read/Write
|-
| Internal
| colspan="2" style="text-align: center;" | 0x00000<br/>0x0FFFF
| 16-bit
| 1 cycle
| RW
|-
| rowspan="2" | Cartridge
| rowspan="2" style="text-align: center;" | 0x10000<br/>0xFFFFF
| style="text-align: center;" | 0x10000<br/>0x1FFFF
| 8-bit
| 1<sup>(color)</sup>/2 cycles (configurable)
| RW
|-
| style="text-align: center;" | 0x20000<br/>0xFFFFF
| 8/16-bit (configurable)
| 1/3 cycles (configurable)
| R
|}
== Internal ==
The WonderSwan SoC features an unified memory architecture; that is, the CPU, [[Display]] and [[Sound]] components can access the RAM in time divisions of the chip's clock.
This allows for a mostly CPU-stall-free development experience, but restricts memory layouting. First of all, some elements of the memory live at fixed locations:
{| class="wikitable"
|+ WonderSwan SoC internal memory map
! Address
! WonderSwan
! WonderSwan Color (2BPP mode)
! WonderSwan Color (4BPP mode)
|-
| style="text-align: center;" | 0x0000
| colspan="3" style="text-align: center;" | '''Interrupt vectors''' (256 x 32-bit segment:offset address)
|-
| style="text-align: center;" | 0x0400
| colspan="3" style="text-align: center;" | Free RAM
|-
| style="text-align: center;" | 0x2000
| colspan="2" style="text-align: center;" | '''Tile data (bank 0)'''
| style="text-align: center;" | Free RAM
|-
| style="text-align: center;" | 0x4000
! rowspan="6" style="text-align: center;" |
| style="text-align: center;" | '''Tile data (bank 1)'''
| rowspan="2" style="text-align: center;" | '''Tile data (bank 0)'''
|-
| style="text-align: center;" | 0x6000
| rowspan="2" style="text-align: center;" | Free RAM
|-
| style="text-align: center;" | 0x8000
| style="text-align: center;" | '''Tile data (bank 1)'''
|-
| style="text-align: center;" | 0xC000
| colspan="2" style="text-align: center;" | Free RAM
|-
| style="text-align: center;" | 0xFE00
| rowspan="2" colspan="2" style="text-align: center;" | '''Color palette'''
|-
| style="text-align: center;" | 0xFFFF
|}
In addition, some elements can be placed at configurable locations in RAM, but with restrictions:
{| class="wikitable"
|+ WonderSwan SoC internal memory layout limitations
! Type
! Lowest address
! Highest address
! Alignment
|-
| Screen
| style="text-align: center;" | 0x0000
| style="text-align: center;" | 0x3800<br/>0x7800<sup>(color)</sup>
| 0x800 (2048) bytes
|-
| Sprite table
| style="text-align: center;" | 0x0000
| style="text-align: center;" | 0x3E00<br/>0x7E00<sup>(color)</sup>
| 0x200 (512) bytes
|-
| Sound wave table
| style="text-align: center;" | 0x0000
| style="text-align: center;" | 0x3FC0
| 0x40 (64) bytes
|}
Remember that just because an element exists in memory, it doesn't have to be fully utilized; for example, it is common for a WonderSwan game to only reserve sixteen out of the 256 interrupt vectors, reusing the remaining 240 as general RAM space.
== Cartridge ==
The cartridge part of the memory map is fully controlled by the cartridge bus; this is usually subdivided further by a [[Mapper]]. There exists a standard layout common to all official mappers:
{| class="wikitable"
|+ Standard mapper linear memory map
! Address range
! Bank
|-
| style="text-align: center;" | 0x10000<br/>0x1FFFF
| SRAM (or flashable ROM)
|-
| style="text-align: center;" | 0x20000<br/>0x2FFFF
| ROM bank 0
|-
| style="text-align: center;" | 0x30000<br/>0x3FFFF
| ROM bank 1
|-
| style="text-align: center;" | 0x40000<br/>0xFFFFF
| ROM linear (EX) bank
|}
54e83a69cd08da7c36b7aa1d01f5bb22266a4b79
DMA
0
31
229
145
2023-08-30T20:38:33Z
Asie
351
wikitext
text/x-wiki
The WonderSwan Color introduced two DMA blocks:
* General DMA (GDMA) - allowing for fast IRAM/ROM -> IRAM transfers,
* Sound DMA (SDMA) - allowing for IRAM/ROM -> sound transfers in a much less CPU-intensive way than an interrupt.
== General DMA ==
{{Anchor|GDMA Source Address Low}}
{{Anchor|GDMA Source Address High}}
=== GDMA Source Address ($40, $41, $42) ===
<pre>
23 bit 16 15 bit 8 7 bit 0
---- ---- ---- ---- ---- ----
.... hhhh llll llll llll lll.
|||| |||| |||| |||| |||
++++---++++-++++---++++-++++- Linear source address
($00000 - $FFFFE)
</pre>
DMA allows source addresses which can be accessed with a 16-bit width and without waitstates; any attempt to access SRAM (8-bit width) or "slow" ROM ($A0 bit 3 set) will cause DMA to immediately return, even if in the middle of a transfer.
{{Anchor|GDMA Destination Address}}
=== GDMA Destination Address ($44, $45) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
aaaa aaaa aaaa aaa.
|||| |||| |||| |||
++++-++++--++++-+++-- Destination address in IRAM
</pre>
GDMA allows destination addresses in IRAM.
{{Anchor|GDMA Length}}
=== GDMA Length ($46, $47) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
bbbb bbbb bbbb bbb.
|||| |||| |||| |||
++++-++++--++++-+++-- Transfer length, in words
(if including bit 0: in bytes)
</pre>
{{Anchor|GDMA Control}}
=== GDMA Control ($48) ===
<pre>
7 bit 0
---- ----
ed.. ....
||
|+-------- Direction: 0 = increment, 1 = decrement
+--------- Enable DMA: 0 = off, 1 = on
</pre>
The CPU is stalled immediately after General DMA is enabled. General DMA takes <code>(5 + 2 * words)</code> cycles to complete, where <code>words</code> is the number of words (2-bytes) transferred.
== Sound DMA ==
Sound DMA is a specialized form of General DMA with a hard-coded destination and built-in timer logic. As such, all of the rules for GDMA apply to SDMA as well.
Due to its need to access the external cartridge bus, Sound DMA steals 7 cycles - the same amount of time GDMA would take for transferring one byte - every 128 cycles. These are always cycles <code>{117, 118, 119, 120, 121, 122, 123} mod 128</code>.
TODO: How does Sound DMA interact with the cartridge waitstate configuration?
{{Anchor|SDMA Source Address Low}}
{{Anchor|SDMA Source Address High}}
=== SDMA Source Address ($4A, $4B, $4C) ===
<pre>
23 bit 16 15 bit 8 7 bit 0
---- ---- ---- ---- ---- ----
.... hhhh llll llll llll llll
|||| |||| |||| |||| ||||
++++---++++-++++---++++-++++- Linear source address
($00000 - $FFFFF)
</pre>
{{Anchor|SDMA Length}}
=== SDMA Length ($4E, $4F, $50) ===
<pre>
23 bit 16 15 bit 8 7 bit 0
---- ---- ---- ---- ---- ----
.... hhhh llll llll llll llll
|||| |||| |||| |||| ||||
++++---++++-++++---++++-++++- Transfer length, in bytes
</pre>
{{Anchor|SDMA Control}}
=== SDMA Control ($52) ===
<pre>
7 bit 0
---- ----
ed.t r?ff
|| | | ||
|| | | ++- Frequency/Rate:
|| | | 0 = 24000/1 = 24000 Hz
|| | | 1 = 24000/2 = 12000 Hz
|| | | 2 = 24000/4 = 6000 Hz
|| | | 3 = 24000/6 = 4000 Hz
|| | +---- Repeat: 0 = one-shot, 1 = auto-repeat
|| +------ Target:
|| 0 = Channel 2 (port $89)
|| 1 = Hyper Voice
|+-------- Direction: 0 = increment, 1 = decrement
+--------- Enable DMA: 0 = off, 1 = on
</pre>
f7213bdf3e3bc506340f6c8578ba016cf0aece96
231
229
2023-09-01T14:14:57Z
Asie
351
document SDMA hold and bus behaviour
wikitext
text/x-wiki
The WonderSwan Color introduced two DMA blocks:
* General DMA (GDMA) - allowing for fast IRAM/ROM -> IRAM transfers,
* Sound DMA (SDMA) - allowing for IRAM/ROM -> sound transfers in a much less CPU-intensive way than an interrupt.
== General DMA ==
{{Anchor|GDMA Source Address Low}}
{{Anchor|GDMA Source Address High}}
=== GDMA Source Address ($40, $41, $42) ===
<pre>
23 bit 16 15 bit 8 7 bit 0
---- ---- ---- ---- ---- ----
.... hhhh llll llll llll lll.
|||| |||| |||| |||| |||
++++---++++-++++---++++-++++- Linear source address
($00000 - $FFFFE)
</pre>
DMA allows source addresses which can be accessed with a 16-bit width and without waitstates; any attempt to access SRAM (8-bit width) or "slow" ROM ($A0 bit 3 set) will cause DMA to immediately return, even if in the middle of a transfer.
{{Anchor|GDMA Destination Address}}
=== GDMA Destination Address ($44, $45) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
aaaa aaaa aaaa aaa.
|||| |||| |||| |||
++++-++++--++++-+++-- Destination address in IRAM
</pre>
GDMA allows destination addresses in IRAM.
{{Anchor|GDMA Length}}
=== GDMA Length ($46, $47) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
bbbb bbbb bbbb bbb.
|||| |||| |||| |||
++++-++++--++++-+++-- Transfer length, in words
(if including bit 0: in bytes)
</pre>
{{Anchor|GDMA Control}}
=== GDMA Control ($48) ===
<pre>
7 bit 0
---- ----
ed.. ....
||
|+-------- Direction: 0 = increment, 1 = decrement
+--------- Enable DMA: 0 = off, 1 = on
</pre>
The CPU is stalled immediately after General DMA is enabled. General DMA takes <code>(5 + 2 * words)</code> cycles to complete, where <code>words</code> is the number of words (2-bytes) transferred.
== Sound DMA ==
Sound DMA is a specialized form of General DMA with a hard-coded destination and built-in timer logic. As such, all of the rules for GDMA apply to SDMA as well.
Due to its need to access the external cartridge bus, Sound DMA steals 7 cycles - the same amount of time GDMA would take for transferring one byte - every 128 cycles. These are always cycles <code>{117, 118, 119, 120, 121, 122, 123} mod 128</code>.
Sound DMA supports ''holding'' - if enabled, the offset/length counters will be paused, allowing for resuming without losing auto-repeat state. The DMA cycles still occur, but they write <code>$00</code> to the target port instead of the in-memory value.
While General DMA uses word access, Sound DMA uses byte access. This means that SRAM is supported as an input source. Also unlike General DMA, streaming from "slow" (>1 cycle) locations is supported; doing so lengthens Sound DMA by the difference.
{{Anchor|SDMA Source Address Low}}
{{Anchor|SDMA Source Address High}}
=== SDMA Source Address ($4A, $4B, $4C) ===
<pre>
23 bit 16 15 bit 8 7 bit 0
---- ---- ---- ---- ---- ----
.... hhhh llll llll llll llll
|||| |||| |||| |||| ||||
++++---++++-++++---++++-++++- Linear source address
($00000 - $FFFFF)
</pre>
{{Anchor|SDMA Length}}
=== SDMA Length ($4E, $4F, $50) ===
<pre>
23 bit 16 15 bit 8 7 bit 0
---- ---- ---- ---- ---- ----
.... hhhh llll llll llll llll
|||| |||| |||| |||| ||||
++++---++++-++++---++++-++++- Transfer length, in bytes
</pre>
{{Anchor|SDMA Control}}
=== SDMA Control ($52) ===
<pre>
7 bit 0
---- ----
ed.t rhff
|| | ||||
|| | ||++- Frequency/Rate:
|| | || 0 = 24000/6 = 4000 Hz
|| | || 1 = 24000/4 = 6000 Hz
|| | || 2 = 24000/2 = 12000 Hz
|| | || 3 = 24000/1 = 24000 Hz
|| | |+--- Hold: 0 = normal playback, 1 = hold
|| | +---- Repeat: 0 = one-shot, 1 = auto-repeat
|| +------ Target:
|| 0 = Channel 2 (port $89)
|| 1 = Hyper Voice
|+-------- Direction: 0 = increment, 1 = decrement
+--------- Enable DMA: 0 = off, 1 = on
</pre>
1c976f5961ec78bdd2d5e5f18c693cc5781aa3f1
235
231
2023-09-02T13:20:19Z
Asie
351
wikitext
text/x-wiki
The WonderSwan Color introduced two DMA blocks:
* General DMA (GDMA) - allowing for fast IRAM/ROM -> IRAM transfers,
* Sound DMA (SDMA) - allowing for IRAM/ROM -> sound transfers in a much less CPU-intensive way than an interrupt.
== General DMA ==
{{Anchor|GDMA Source Address Low}}
{{Anchor|GDMA Source Address High}}
=== GDMA Source Address ($40, $41, $42) ===
<pre>
23 bit 16 15 bit 8 7 bit 0
---- ---- ---- ---- ---- ----
.... hhhh llll llll llll lll.
|||| |||| |||| |||| |||
++++---++++-++++---++++-++++- Linear source address
($00000 - $FFFFE)
</pre>
DMA allows source addresses which can be accessed with a 16-bit width and without waitstates; any attempt to access SRAM (8-bit width) or "slow" ROM ($A0 bit 3 set) will cause DMA to immediately return, even if in the middle of a transfer.
{{Anchor|GDMA Destination Address}}
=== GDMA Destination Address ($44, $45) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
aaaa aaaa aaaa aaa.
|||| |||| |||| |||
++++-++++--++++-+++-- Destination address in IRAM
</pre>
GDMA allows destination addresses in IRAM.
{{Anchor|GDMA Length}}
=== GDMA Length ($46, $47) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
bbbb bbbb bbbb bbb.
|||| |||| |||| |||
++++-++++--++++-+++-- Transfer length, in words
(if including bit 0: in bytes)
</pre>
{{Anchor|GDMA Control}}
=== GDMA Control ($48) ===
<pre>
7 bit 0
---- ----
ed.. ....
||
|+-------- Direction: 0 = increment, 1 = decrement
+--------- Enable DMA: 0 = off, 1 = on
</pre>
The CPU is stalled immediately after General DMA is enabled. General DMA takes <code>(5 + 2 * words)</code> cycles to complete, where <code>words</code> is the number of words (2-bytes) transferred.
== Sound DMA ==
Due to its need to access the external cartridge bus, Sound DMA steals 7 cycles - the same amount of time GDMA would take for transferring one byte - every 128 cycles. These are always cycles <code>{117, 118, 119, 120, 121, 122, 123} mod 128</code>.
Sound DMA supports ''holding'' - if enabled, the offset/length counters will be paused, allowing for resuming without losing auto-repeat state. The DMA cycles still occur, but they write <code>$00</code> to the target port instead of the in-memory value.
Sound DMA support ''repeat'' - if enabled, the offset/length counter will have their last written values restored upon the length counter reaching 0. The offset/length counters are copied when their respective ports are written to.
While General DMA uses word access, Sound DMA uses byte access. This means that SRAM is supported as an input source. Also unlike General DMA, streaming from "slow" (>1 cycle) locations is supported; doing so lengthens Sound DMA by the difference.
{{Anchor|SDMA Source Address Low}}
{{Anchor|SDMA Source Address High}}
=== SDMA Source Address ($4A, $4B, $4C) ===
<pre>
23 bit 16 15 bit 8 7 bit 0
---- ---- ---- ---- ---- ----
.... hhhh llll llll llll llll
|||| |||| |||| |||| ||||
++++---++++-++++---++++-++++- Linear source address
($00000 - $FFFFF)
</pre>
{{Anchor|SDMA Length}}
=== SDMA Length ($4E, $4F, $50) ===
<pre>
23 bit 16 15 bit 8 7 bit 0
---- ---- ---- ---- ---- ----
.... hhhh llll llll llll llll
|||| |||| |||| |||| ||||
++++---++++-++++---++++-++++- Transfer length, in bytes
</pre>
{{Anchor|SDMA Control}}
=== SDMA Control ($52) ===
<pre>
7 bit 0
---- ----
ed.t rhff
|| | ||||
|| | ||++- Frequency/Rate:
|| | || 0 = 24000/6 = 4000 Hz
|| | || 1 = 24000/4 = 6000 Hz
|| | || 2 = 24000/2 = 12000 Hz
|| | || 3 = 24000/1 = 24000 Hz
|| | |+--- Hold: 0 = normal playback, 1 = hold
|| | +---- Repeat: 0 = one-shot, 1 = auto-repeat
|| +------ Target:
|| 0 = Channel 2 (port $89)
|| 1 = Hyper Voice
|+-------- Direction: 0 = increment, 1 = decrement
+--------- Enable DMA: 0 = off, 1 = on
</pre>
f4b79c22e2b9f96e40fe2245bdee91ebe14d1f2f
236
235
2023-09-02T13:30:07Z
Asie
351
wikitext
text/x-wiki
The WonderSwan Color introduced two DMA blocks:
* General DMA (GDMA) - allowing for fast IRAM/ROM -> IRAM transfers,
* Sound DMA (SDMA) - allowing for IRAM/ROM -> sound transfers in a much less CPU-intensive way than an interrupt.
== General DMA ==
{{Anchor|GDMA Source Address Low}}
{{Anchor|GDMA Source Address High}}
=== GDMA Source Address ($40, $41, $42) ===
<pre>
23 bit 16 15 bit 8 7 bit 0
---- ---- ---- ---- ---- ----
.... hhhh llll llll llll lll.
|||| |||| |||| |||| |||
++++---++++-++++---++++-++++- Linear source address
($00000 - $FFFFE)
</pre>
DMA allows source addresses which can be accessed with a 16-bit width and without waitstates; any attempt to access SRAM (8-bit width) or "slow" ROM ($A0 bit 3 set) will cause DMA to immediately return, even if in the middle of a transfer.
{{Anchor|GDMA Destination Address}}
=== GDMA Destination Address ($44, $45) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
aaaa aaaa aaaa aaa.
|||| |||| |||| |||
++++-++++--++++-+++-- Destination address in IRAM
</pre>
GDMA allows destination addresses in IRAM.
{{Anchor|GDMA Length}}
=== GDMA Length ($46, $47) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
bbbb bbbb bbbb bbb.
|||| |||| |||| |||
++++-++++--++++-+++-- Transfer length, in words
(if including bit 0: in bytes)
</pre>
{{Anchor|GDMA Control}}
=== GDMA Control ($48) ===
<pre>
7 bit 0
---- ----
ed.. ....
||
|+-------- Direction: 0 = increment, 1 = decrement
+--------- Enable DMA: 0 = off, 1 = on
</pre>
The CPU is stalled immediately after General DMA is enabled. General DMA takes <code>(5 + 2 * words)</code> cycles to complete, where <code>words</code> is the number of words (2-bytes) transferred.
== Sound DMA ==
Due to its need to access the external cartridge bus, Sound DMA steals 7 cycles - the same amount of time GDMA would take for transferring one byte - every 128 cycles. These are always cycles <code>{117, 118, 119, 120, 121, 122, 123} mod 128</code>.
Sound DMA supports ''holding'' - if enabled, the offset/length counters will be paused, allowing for resuming without losing auto-repeat state. The DMA cycles still occur, but they write <code>$00</code> to the target port instead of the in-memory value.
Sound DMA supports ''repeat'' - if enabled, the offset/length counter will have their last written values restored upon the length counter reaching 0. The offset/length counters are copied when their respective ports are written to.
While General DMA uses word access, Sound DMA uses byte access. This means that SRAM is supported as an input source. Also unlike General DMA, streaming from "slow" (>1 cycle) locations is supported; doing so lengthens Sound DMA by the difference.
Sound DMA updates offset/length counters live; the changed values are accessible through the respective I/O ports, and written changes are immediately reflected in the DMA's behaviour.
{{Anchor|SDMA Source Address Low}}
{{Anchor|SDMA Source Address High}}
=== SDMA Source Address ($4A, $4B, $4C) ===
<pre>
23 bit 16 15 bit 8 7 bit 0
---- ---- ---- ---- ---- ----
.... hhhh llll llll llll llll
|||| |||| |||| |||| ||||
++++---++++-++++---++++-++++- Linear source address
($00000 - $FFFFF)
</pre>
{{Anchor|SDMA Length}}
=== SDMA Length ($4E, $4F, $50) ===
<pre>
23 bit 16 15 bit 8 7 bit 0
---- ---- ---- ---- ---- ----
.... hhhh llll llll llll llll
|||| |||| |||| |||| ||||
++++---++++-++++---++++-++++- Transfer length, in bytes
</pre>
{{Anchor|SDMA Control}}
=== SDMA Control ($52) ===
<pre>
7 bit 0
---- ----
ed.t rhff
|| | ||||
|| | ||++- Frequency/Rate:
|| | || 0 = 24000/6 = 4000 Hz
|| | || 1 = 24000/4 = 6000 Hz
|| | || 2 = 24000/2 = 12000 Hz
|| | || 3 = 24000/1 = 24000 Hz
|| | |+--- Hold: 0 = normal playback, 1 = hold
|| | +---- Repeat: 0 = one-shot, 1 = auto-repeat
|| +------ Target:
|| 0 = Channel 2 (port $89)
|| 1 = Hyper Voice
|+-------- Direction: 0 = increment, 1 = decrement
+--------- Enable DMA: 0 = off, 1 = on
</pre>
33b28c32db8eb9d48009d2e6c1b46df5e51484f6
237
236
2023-09-02T15:27:05Z
Asie
351
wikitext
text/x-wiki
The WonderSwan Color introduced two DMA blocks:
* General DMA (GDMA) - allowing for fast IRAM/ROM -> IRAM transfers,
* Sound DMA (SDMA) - allowing for IRAM/ROM -> sound transfers in a much less CPU-intensive way than an interrupt.
== General DMA ==
{{Anchor|GDMA Source Address Low}}
{{Anchor|GDMA Source Address High}}
=== GDMA Source Address ($40, $41, $42) ===
<pre>
23 bit 16 15 bit 8 7 bit 0
---- ---- ---- ---- ---- ----
.... hhhh llll llll llll lll.
|||| |||| |||| |||| |||
++++---++++-++++---++++-++++- Linear source address
($00000 - $FFFFE)
</pre>
DMA allows source addresses which can be accessed with a 16-bit width and without waitstates; any attempt to access SRAM (8-bit width) or "slow" ROM ($A0 bit 3 set) will cause DMA to immediately return, even if in the middle of a transfer.
{{Anchor|GDMA Destination Address}}
=== GDMA Destination Address ($44, $45) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
aaaa aaaa aaaa aaa.
|||| |||| |||| |||
++++-++++--++++-+++-- Destination address in IRAM
</pre>
GDMA allows destination addresses in IRAM.
{{Anchor|GDMA Length}}
=== GDMA Length ($46, $47) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
bbbb bbbb bbbb bbb.
|||| |||| |||| |||
++++-++++--++++-+++-- Transfer length, in words
(if including bit 0: in bytes)
</pre>
{{Anchor|GDMA Control}}
=== GDMA Control ($48) ===
<pre>
7 bit 0
---- ----
ed.. ....
||
|+-------- Direction: 0 = increment, 1 = decrement
+--------- Enable DMA: 0 = off, 1 = on
</pre>
The CPU is stalled immediately after General DMA is enabled. General DMA takes <code>(5 + 2 * words)</code> cycles to complete, where <code>words</code> is the number of words (2-bytes) transferred.
== Sound DMA ==
Due to its need to access the external cartridge bus, Sound DMA steals 7 cycles - the same amount of time GDMA would take for transferring one byte - every 128 cycles. These are always cycles <code>{117, 118, 119, 120, 121, 122, 123} mod 128</code>.
Sound DMA supports ''holding'' - if enabled, the offset/length counters will be paused, allowing for resuming without losing auto-repeat state. The DMA cycles still occur, but they write <code>$00</code> to the target port instead of the in-memory value.
Sound DMA supports ''repeat'' - if enabled, the offset/length counter will have their last written values restored upon the length counter reaching 0. The offset/length counters are copied when their respective ports are written to.
While General DMA uses word access, Sound DMA uses byte access. This means that SRAM is supported as an input source. Also unlike General DMA, streaming from "slow" (>1 cycle) locations is supported; doing so lengthens Sound DMA by the difference.
Sound DMA updates offset/length counters live; the changed values are accessible through the respective I/O ports, and written changes are immediately reflected in the DMA's behaviour.
The enable/disable bit of Sound DMA does not affect the offset/length counters in any way; for example, if a sample is stopped mid-playthrough, then started again, it will pick up right where it left off.
{{Anchor|SDMA Source Address Low}}
{{Anchor|SDMA Source Address High}}
=== SDMA Source Address ($4A, $4B, $4C) ===
<pre>
23 bit 16 15 bit 8 7 bit 0
---- ---- ---- ---- ---- ----
.... hhhh llll llll llll llll
|||| |||| |||| |||| ||||
++++---++++-++++---++++-++++- Linear source address
($00000 - $FFFFF)
</pre>
{{Anchor|SDMA Length}}
=== SDMA Length ($4E, $4F, $50) ===
<pre>
23 bit 16 15 bit 8 7 bit 0
---- ---- ---- ---- ---- ----
.... hhhh llll llll llll llll
|||| |||| |||| |||| ||||
++++---++++-++++---++++-++++- Transfer length, in bytes
</pre>
{{Anchor|SDMA Control}}
=== SDMA Control ($52) ===
<pre>
7 bit 0
---- ----
ed.t rhff
|| | ||||
|| | ||++- Frequency/Rate:
|| | || 0 = 24000/6 = 4000 Hz
|| | || 1 = 24000/4 = 6000 Hz
|| | || 2 = 24000/2 = 12000 Hz
|| | || 3 = 24000/1 = 24000 Hz
|| | |+--- Hold: 0 = normal playback, 1 = hold
|| | +---- Repeat: 0 = one-shot, 1 = auto-repeat
|| +------ Target:
|| 0 = Channel 2 (port $89)
|| 1 = Hyper Voice
|+-------- Direction: 0 = increment, 1 = decrement
+--------- Enable DMA: 0 = off, 1 = on
</pre>
ba578dcd1b3ccf3488aec9caa3052ca65e22f411
238
237
2023-09-02T15:34:22Z
Asie
351
wikitext
text/x-wiki
The WonderSwan Color introduced two DMA blocks:
* General DMA (GDMA) - allowing for fast IRAM/ROM -> IRAM transfers,
* Sound DMA (SDMA) - allowing for IRAM/ROM -> sound transfers in a much less CPU-intensive way than an interrupt.
== General DMA ==
{{Anchor|GDMA Source Address Low}}
{{Anchor|GDMA Source Address High}}
=== GDMA Source Address ($40, $41, $42) ===
<pre>
23 bit 16 15 bit 8 7 bit 0
---- ---- ---- ---- ---- ----
.... hhhh llll llll llll lll.
|||| |||| |||| |||| |||
++++---++++-++++---++++-++++- Linear source address
($00000 - $FFFFE)
</pre>
DMA allows source addresses which can be accessed with a 16-bit width and without waitstates; any attempt to access SRAM (8-bit width) or "slow" ROM ($A0 bit 3 set) will cause DMA to immediately return, even if in the middle of a transfer.
{{Anchor|GDMA Destination Address}}
=== GDMA Destination Address ($44, $45) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
aaaa aaaa aaaa aaa.
|||| |||| |||| |||
++++-++++--++++-+++-- Destination address in IRAM
</pre>
GDMA allows destination addresses in IRAM.
{{Anchor|GDMA Length}}
=== GDMA Length ($46, $47) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
bbbb bbbb bbbb bbb.
|||| |||| |||| |||
++++-++++--++++-+++-- Transfer length, in words
(if including bit 0: in bytes)
</pre>
{{Anchor|GDMA Control}}
=== GDMA Control ($48) ===
<pre>
7 bit 0
---- ----
ed.. ....
||
|+-------- Direction: 0 = increment, 1 = decrement
+--------- Enable DMA: 0 = off, 1 = on
</pre>
The CPU is stalled immediately after General DMA is enabled. General DMA takes <code>(5 + 2 * words)</code> cycles to complete, where <code>words</code> is the number of words (2-bytes) transferred.
== Sound DMA ==
Sound DMA allows copying sample data to either Channel 2 or Hyper Voice automatically while incurring a much lower cost than that of a CPU interrupt.
Features:
* 4000, 6000, 12000, 24000 Hz sample rates.
* '''Auto-repeat''': If enabled, every time the length counter reaches 0, a shadowed copy of the offset and length as written to the I/O ports will be restored. If disabled, bit 7 will automatically clear on transfer completion, same as with General DMA.
* '''Holding''': If enabled, the offset/length counters will be paused, and $00 will be written on every Sound DMA tick as opposed to the value in memory. This does not impact the timing of Sound DMA.
When playing back sound, the visible ports ($4A-$4C, $4E-$50) are the ones updated live; any edits to them are reflected immediately, as well as written to the shadow copy used for auto-repeat.
The enable/disable bit of Sound DMA does not affect the offset/length counters in any way; for example, if a sample is stopped mid-playthrough, then started again, it will pick up right where it left off.
Unlike General DMA, Sound DMA copies data per byte. This means that SRAM is supported as an input source. Also unlike General DMA, streaming from "slow" (>1 cycle) locations is supported; doing so lengthens the duration of Sound DMA. Due to its need to access the external cartridge bus, Sound DMA must use cycles normally reserved for the CPU; it uses <code>6 + N</code> cycles every 128 cycles, always starting from cycle <code>117 mod 128</code>. <code>N</code> refers to the access time of the area from which audio is being streamed from, and is typically 1 cycle.
{{Anchor|SDMA Source Address Low}}
{{Anchor|SDMA Source Address High}}
=== SDMA Source Address ($4A, $4B, $4C) ===
<pre>
23 bit 16 15 bit 8 7 bit 0
---- ---- ---- ---- ---- ----
.... hhhh llll llll llll llll
|||| |||| |||| |||| ||||
++++---++++-++++---++++-++++- Linear source address
($00000 - $FFFFF)
</pre>
Upon writing to any of the bytes, said byte (and only said byte) is copied to a shadow register, used for restoring the offset/length counter when auto-repeat is enabled.
{{Anchor|SDMA Length}}
=== SDMA Length ($4E, $4F, $50) ===
<pre>
23 bit 16 15 bit 8 7 bit 0
---- ---- ---- ---- ---- ----
.... hhhh llll llll llll llll
|||| |||| |||| |||| ||||
++++---++++-++++---++++-++++- Transfer length, in bytes
</pre>
Upon writing to any of the bytes, said byte (and only said byte) is copied to a shadow register, used for restoring the offset/length counter when auto-repeat is enabled.
{{Anchor|SDMA Control}}
=== SDMA Control ($52) ===
<pre>
7 bit 0
---- ----
ed.t rhff
|| | ||||
|| | ||++- Frequency/Rate:
|| | || 0 = 24000/6 = 4000 Hz
|| | || 1 = 24000/4 = 6000 Hz
|| | || 2 = 24000/2 = 12000 Hz
|| | || 3 = 24000/1 = 24000 Hz
|| | |+--- Hold: 0 = normal playback, 1 = hold
|| | +---- Repeat: 0 = one-shot, 1 = auto-repeat
|| +------ Target:
|| 0 = Channel 2 (port $89)
|| 1 = Hyper Voice
|+-------- Direction: 0 = increment, 1 = decrement
+--------- Enable DMA: 0 = off, 1 = on
</pre>
3053a97e9d2b0b92388d4b96ecef0b55c88ead08
WonderWitch/FreyaBIOS
0
42
239
182
2023-09-09T06:07:46Z
Asie
351
add Fonts section
wikitext
text/x-wiki
FreyaBIOS is a boot program and hardware abstraction layer for [[WonderWitch]], present in the top-most (last) 64 KB of any WonderWitch cartridge.
It provides the following functionality:
* bring-up code,
* interrupt-based hardware abstraction layer, providing a more user-friendly (and less direct) interface to the WonderSwan hardware,
* 8x8 ASCII and kanji fonts,
* a monitor program, allowing FreyaOS recovery and updates via XMODEM.
Other functionality (like file system access) is instead included as part of [[WonderWitch/FreyaOS|FreyaOS]]' system libraries; some other functionality (like WonderSwan Color support is implemented as part of the development tooling.
== Revisions ==
TODO
== Fonts ==
As part of its ROM image, FreyaBIOS provides two fonts:
* an 8x8 ASCII font,
* an 8x8 Shift-JIS kanji font - [http://hp.vector.co.jp/authors/VA002310/original.html ELISA FONT].
== Interrupts ==
* [[WonderWitch/FreyaBIOS/Exit|Exit]] (INT $10)
* [[WonderWitch/FreyaBIOS/Key|Key]] (INT $11)
* [[WonderWitch/FreyaBIOS/Display|Display]] (INT $12)
* [[WonderWitch/FreyaBIOS/Text|Text]] (INT $13)
* [[WonderWitch/FreyaBIOS/Communication|Communication]] (INT $14)
* [[WonderWitch/FreyaBIOS/Sound|Sound]] (INT $15)
* [[WonderWitch/FreyaBIOS/Timer|Timer]] (INT $16)
* [[WonderWitch/FreyaBIOS/System|System]] (INT $17)
* [[WonderWitch/FreyaBIOS/Bank|Bank]] (INT $18)
== Freya Monitor ==
TODO
296072457def02e62380fd6d12d7ed5390a700bf
WonderWitch .fx files
0
6
240
16
2023-09-09T06:15:37Z
Asie
351
fix formatting
wikitext
text/x-wiki
[[FreyaOS]] uses [[XMODEM]] transfers to send and receive files through the serial port. These transfers do not include any file metadata by default - such as the file's name, size, permissions or creation date. As such, .fx files are used - binary files with a special 128-byte header<ref>XMODEM transfers are performed in 128-byte blocks; this allows fetching the file's metadata as the first block</ref>.
== Format ==
{| class="wikitable"
|+ Header contents
|-
! Offset !! Length !! Contents
|-
| $00 || 4 || Magic string: <code>#!ws</code>
|-
| $04 || 60 || Padding; typically 0xFF.
|-
| $40 || 16 || File name; zero-terminated Shift-JIS string.
|-
| $50 || 24 || User-friendly file name; zero-terminated Shift-JIS string.
FreyaOS displays the first 12 characters in its file selector.
|-
| $68 || 4 || ?
|-
| $6C || 4 || Total file size, in bytes, excluding the header.
|-
| $70 || 2 || XMODEM chunk count - above file size divided by 128, then rounded up.
|-
| $72 || 2 || File mode
|-
| $74 || 4 || Modification time - seconds since January 1st, 2000.
|-
| $78 || 4 || ?
|-
| $7C || 4 || Offset to resource data, bytes excluding header; -1 if not present.
|}
=== File mode ===
----
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
???? ???? ??i? ?rwx
| |||
| ||+- Execute
| |+-- Write
| +--- Read
+------- Intermediate library
</pre>
70db9f39d629134f64dabbb28838e102b2f6fb7f
241
240
2023-09-09T06:15:44Z
Asie
351
wikitext
text/x-wiki
[[FreyaOS]] uses [[XMODEM]] transfers to send and receive files through the serial port. These transfers do not include any file metadata by default - such as the file's name, size, permissions or creation date. As such, .fx files are used - binary files with a special 128-byte header<ref>XMODEM transfers are performed in 128-byte blocks; this allows fetching the file's metadata as the first block</ref>.
== Format ==
{| class="wikitable"
|+ Header contents
|-
! Offset !! Length !! Contents
|-
| $00 || 4 || Magic string: <code>#!ws</code>
|-
| $04 || 60 || Padding; typically 0xFF.
|-
| $40 || 16 || File name; zero-terminated Shift-JIS string.
|-
| $50 || 24 || User-friendly file name; zero-terminated Shift-JIS string.
FreyaOS displays the first 12 characters in its file selector.
|-
| $68 || 4 || ?
|-
| $6C || 4 || Total file size, in bytes, excluding the header.
|-
| $70 || 2 || XMODEM chunk count - above file size divided by 128, then rounded up.
|-
| $72 || 2 || File mode
|-
| $74 || 4 || Modification time - seconds since January 1st, 2000.
|-
| $78 || 4 || ?
|-
| $7C || 4 || Offset to resource data, bytes excluding header; -1 if not present.
|}
=== File mode ===
----
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
???? ???? ??i? ?rwx
| |||
| ||+- Execute
| |+-- Write
| +--- Read
+------- Intermediate library
</pre>
92d7c9a78d22152db7c15d4f7dd06d46996c782b
ROM header
0
5
242
122
2023-09-23T15:22:41Z
Asie
351
wikitext
text/x-wiki
Every WonderSwan ROM contains a header. It is stored at the end - final sixteen bytes - of the ROM image.
== ROM header ==
Parts of this header are validated or otherwise used by the console's [[boot ROM]] - they are marked in '''bold'''.
{| class="wikitable"
|+ Header contents
|-
! Offset !! Length !! Contents
|-
| '''$0''' || '''5''' || Far jump instruction: '''0xEA''', offset, segment.
|-
| '''$5''' || '''1''' || '''Maintenance'''
|-
| $6 || 1 || Developer/Publisher ID
|-
| $7 || 1 || Color
|-
| $8 || 1 || Game ID (binary-coded decimal)
|-
| '''$9''' || '''1''' || '''Game version? / Safe mode'''
|-
| $A || 1 || ROM size
|-
| $B || 1 || Save type/size
|-
| '''$C''' || '''1''' || '''Flags'''
|-
| $D || 1 || Mapper
|-
| $E || 2 || Checksum (sum of all ROM bytes excluding the checksum)
|}
=== Maintenance ($5) ===
----
<pre>
7 bit 0
---- ----
s... 0000
| ||||
| ++++- Must be zero; otherwise the console will prohibit execution.
| Purpose unknown.
+--------- (Color) Splash bypass: 0 = Disable, 1 = Enable.
Bypasses the custom boot splash stored in the console's
internal EEPROM; presumably used for bricked console recovery.
</pre>
=== Developer/Publisher ID ($6) ===
----
{| class="wikitable"
|+ Known official developer/publisher IDs
|-
! ID !! Publisher code !! Publisher
|-
| $01 || BAN || Bandai
|-
| $02 || TAT || Taito
|-
| $03 || TMY || Tomy
|-
| $04 || KEX || Koei
|-
| $05 || DTE || Data East
|-
| $06 || AAE || Asmik Ace
|-
| $07 || MDE || Media Entertainment
|-
| $08 || NHB || Nichibutsu
|-
| $0A || CCJ || Coconuts Japan
|-
| $0B || SUM || Sammy
|-
| $0C || SUN || Sunsoft
|-
| $0D || PAW || Mebius
|-
| $0E || BPR || Banpresto
|-
| $10 || JLC || Jaleco
|-
| $11 || MGA || Imagineer
|-
| $12 || KNM || Konami
|-
| $16 || KBS || Kobunsha
|-
| $17 || BTM || Bottom Up
|-
| $18 || KGT || Kaga Tech
|-
| $19 || SRV || Sunrise
|-
| $1A || CFT || Cyber Front
|-
| $1B || MGH || Megahouse
|-
| $1D || BEC || Interbec
|-
| $1E || NAP || Nihon Application
|-
| $1F || BVL || Bandai Visual
|-
| $20 || ATN || Athena
|-
| $21 || KDX || KID
|-
| $22 || HAL || HAL Corporation
|-
| $23 || YKE || Yuki Enterprise
|-
| $24 || OMN || Omega Micott
|-
| $25 || LAY || Layup
|-
| $26 || KDK || Kadokawa Shoten
|-
| $27 || SHL || Shall Luck
|-
| $28 || SQR || Squaresoft
|-
| $2A || SCC || ?
|-
| $2B || TMC || Tom Create
|-
| $2D || NMC || Namco
|-
| $2E || SES || ?
|-
| $2F || HTR || ?
|-
| $31 || VGD || Vanguard
|-
| $32 || MGT || Megatron
|-
| $33 || WIZ || Wiz
|-
| $35 || TAN || Tanita
|-
| $36 || CPC || Capcom
|}
Note that IDs $00 and $01 are used across a variety of commercial games. Homebrew is known to use arbitrary values in this field.
=== Color ($7) ===
----
<pre>
7 bit 0
---- ----
???? ???c
|
+- 0 = Monochrome only, 1 = Supports Color mode.
</pre>
=== Game version? / Safe mode ($9) ===
----
<pre>
7 bit 0
---- ----
pvvv vvvv
|||| ||||
|+++ ++++- Game version?
+--------- Internal EEPROM write protect: 0 = Enable, 1 = Disable.
This prohibits writing to the internal EEPROM for addresses
0x60 and above (user settings, custom splash screen).
Games are expected to enable write protection; however, the
WonderWitch is factory configured with it disabled.
</pre>
=== ROM size ($A) ===
----
Unofficial/inferred ROM size values are marked in ''italic''.
{| class="wikitable"
|+ ROM size values
|-
! ID !! Size
|-
| ''$00'' || ''1 Mbit (128 KiB)''
|-
| ''$01'' || ''2 Mbit (256 KiB)''
|-
| $02 || 4 Mbit (512 KiB)
|-
| $03 || 8 Mbit (1 MiB)
|-
| $04 || 16 Mbit (2 MiB)
|-
| ''$05'' || ''24 Mbit (3 MiB)''
|-
| $06 || 32 Mbit (4 MiB)
|-
| ''$07'' || ''48 Mbit (6 MiB)''
|-
| $08 || 64 Mbit (8 MiB)
|-
| $09 || 128 Mbit (16 MiB)
|-
| ''$0A'' || ''256 Mbit (32 MiB)''
|-
| ''$0B'' || ''512 Mbit (64 MiB)''
|}
Note that ROM sizes over 16 MiB are not supported by the [[Bandai 2001]] mapper. The [[Bandai 2003]] mapper is limited to 64 MiB.
=== Save type/size ($B) ===
----
{| class="wikitable"
|+ Save type values
|-
! ID !! Type !! Size
|-
| $00 || colspan="2" style="text-align:center;" | None
|-
| $01 || rowspan="5" | SRAM || 64 Kbit (8 KiB)
|-
| $02 || 256 Kbit (32 KiB)
|-
| $03 || 1 Mbit (128 KiB)
|-
| $04 || 2 Mbit (256 KiB)
|-
| $05 || 4 Mbit (512 KiB)
|-
| $10 || rowspan="3" | EEPROM || 1 Kbit (128 B)
|-
| $20 || 16 Kbit (2 KiB)
|-
| $50 || 8 Kbit (1 KiB)
|}
=== Flags ($C) ===
----
<pre>
7 bit 0
---- ----
???? ?SBv
|||
||+- Starting screen orientation: 0 = Horizontal, 1 = Vertical.
|| Controls the splash screen's orientation.
|+-- ROM bus width: 0 = 16-bit, 1 = 8-bit.
+--- ROM access time: 0 = 3 CPU cycles, 1 = 1 CPU cycle.
</pre>
=== Mapper ($D) ===
----
{| class="wikitable"
|+ Known mapper types
|-
! ID !! Mapper
|-
| $00 || [[Bandai 2001]] or [[KARNAK]]
|-
| $01 || [[Bandai 2003]]
|}
7422b5c38b6f99de41ba7f3a19e7fffbbfc9efa4
Cartridge connector
0
44
243
191
2023-10-10T19:58:22Z
Asie
351
fix typo
wikitext
text/x-wiki
== Pinout ==
<pre>
Cartridge Console
(label side) (back)
____________
|====|
____ |--01| -- GND
... \ | -02| <- CPU A15
... | | -03| <- CPU A10
... | | -04| <- CPU A11
... | | -05| <- CPU A9
... | | -06| <- CPU A8
... | | -07| <- CPU A13
... | | -08| <- CPU A14
... | | -09| <- CPU A12
... | | -10| <- CPU A7
... | | -11| <- CPU A6
... | | -12| <- CPU A5
... | | -13| <- CPU A4
... | | -14| <> D15
... | | -15| <> D14
... | | -16| <> D7
... | | -17| <> D6
... | | -18| <> D5
... | | -19| <> D4
... | | -20| <> D3
... | | -21| <> D2
... | | -22| <> D1
... | | -23| <> D0
... | |--24| -- +3.3V
... | |--25| -- +3.3V
... | | -26| <- CPU A0
... | | -27| <- CPU A1
... | | -28| <- CPU A2
... | | -29| <- CPU A3
... | | -30| <- CPU A19
... | | -31| <- CPU A18
... | | -32| <- CPU A17
... | | -33| <- CPU A16
... | | -34| <> D8
... | | -35| <> D9
... | | -36| <> D10
... | | -37| <> D11
... | | -38| <> D12
... | | -39| <> D13
... | | -40| <- /Reset
... | | -41| -> /MBC
... | | -42| <- M/IO (Memory/IO)
... | | -43| <- /RD (Read enable)
... | | -44| <- /WR (Write enable)
... | | -45| <- /SEL (Cartridge select)
... | | -46| -> /IRQ (Interrupt request)
____/ | -47| <- CLK (384 KHz clock)
|--48| -- GND
_______|====|
Cartridge Console
(label side) (back)
</pre>
1e1b09ee24d8830b1af1690a62a95bf9967d0412
248
243
2024-02-19T19:55:05Z
Asie
351
Asie moved page [[Cartridge pinout]] to [[Cartridge connector]]: Unify with NESdev/SNESdev Wiki standards
wikitext
text/x-wiki
== Pinout ==
<pre>
Cartridge Console
(label side) (back)
____________
|====|
____ |--01| -- GND
... \ | -02| <- CPU A15
... | | -03| <- CPU A10
... | | -04| <- CPU A11
... | | -05| <- CPU A9
... | | -06| <- CPU A8
... | | -07| <- CPU A13
... | | -08| <- CPU A14
... | | -09| <- CPU A12
... | | -10| <- CPU A7
... | | -11| <- CPU A6
... | | -12| <- CPU A5
... | | -13| <- CPU A4
... | | -14| <> D15
... | | -15| <> D14
... | | -16| <> D7
... | | -17| <> D6
... | | -18| <> D5
... | | -19| <> D4
... | | -20| <> D3
... | | -21| <> D2
... | | -22| <> D1
... | | -23| <> D0
... | |--24| -- +3.3V
... | |--25| -- +3.3V
... | | -26| <- CPU A0
... | | -27| <- CPU A1
... | | -28| <- CPU A2
... | | -29| <- CPU A3
... | | -30| <- CPU A19
... | | -31| <- CPU A18
... | | -32| <- CPU A17
... | | -33| <- CPU A16
... | | -34| <> D8
... | | -35| <> D9
... | | -36| <> D10
... | | -37| <> D11
... | | -38| <> D12
... | | -39| <> D13
... | | -40| <- /Reset
... | | -41| -> /MBC
... | | -42| <- M/IO (Memory/IO)
... | | -43| <- /RD (Read enable)
... | | -44| <- /WR (Write enable)
... | | -45| <- /SEL (Cartridge select)
... | | -46| -> /IRQ (Interrupt request)
____/ | -47| <- CLK (384 KHz clock)
|--48| -- GND
_______|====|
Cartridge Console
(label side) (back)
</pre>
1e1b09ee24d8830b1af1690a62a95bf9967d0412
Cartridge pinout
0
48
249
2024-02-19T19:55:05Z
Asie
351
Asie moved page [[Cartridge pinout]] to [[Cartridge connector]]: Unify with NESdev/SNESdev Wiki standards
wikitext
text/x-wiki
#REDIRECT [[Cartridge connector]]
187b95c038ee2082373630c9084bea1edf721e64
Cartridge connector
0
44
251
248
2024-02-19T20:21:49Z
Asie
351
expanded with RSDuck's notes
wikitext
text/x-wiki
== Memory access ==
Both the ROM and the SRAM chip use a standard asynchronous memory interface.
It is presumed that:
* the CPU sets the address lines after the rising edge of '''/OE''' while '''/OE''' is high,
* the CPU sets the data lines after the falling edge of '''/OE''', while '''/OE''' is low (TODO: only confirmed for I/O writes),
* the CPU latches the data lines on the subsequent rising edge of '''/OE'''.
Memory may be accessed in 8-bit or 16-bit mode. SRAM reads/writes always happen in 8-bit mode, while ROM reads/writes can happen in 8-bit or 16-bit mode depending on [[ROM header|header]] configuration.
Note that in 16-bit mode, the output on address line '''A0''' is undetermined and should be ignored.
== Pinout ==
<pre>
Cartridge Console
(label side) (back)
____________
|====|
____ |--01| -- GND
... \ | -02| <- CPU A15
... | | -03| <- CPU A10
... | | -04| <- CPU A11
... | | -05| <- CPU A9
... | | -06| <- CPU A8
... | | -07| <- CPU A13
... | | -08| <- CPU A14
... | | -09| <- CPU A12
... | | -10| <- CPU A7
... | | -11| <- CPU A6
... | | -12| <- CPU A5
... | | -13| <- CPU A4
... | | -14| <> D15
... | | -15| <> D14
... | | -16| <> D7
... | | -17| <> D6
... | | -18| <> D5
... | | -19| <> D4
... | | -20| <> D3
... | | -21| <> D2
... | | -22| <> D1
... | | -23| <> D0
... | |--24| -- +3.3V
... | |--25| -- +3.3V
... | | -26| <- CPU A0
... | | -27| <- CPU A1
... | | -28| <- CPU A2
... | | -29| <- CPU A3
... | | -30| <- CPU A19
... | | -31| <- CPU A18
... | | -32| <- CPU A17
... | | -33| <- CPU A16
... | | -34| <> D8
... | | -35| <> D9
... | | -36| <> D10
... | | -37| <> D11
... | | -38| <> D12
... | | -39| <> D13
... | | -40| <- /RESET
... | | -41| -> /MBC
... | | -42| <- M/IO (Memory/IO)
... | | -43| <- /RD (Read enable)
... | | -44| <- /WR (Write enable)
... | | -45| <- /SEL (Cartridge select)
... | | -46| -> /IRQ (Interrupt request)
____/ | -47| <- CLK
|--48| -- GND
_______|====|
Cartridge Console
(label side) (back)
</pre>
== Mechanical details ==
{| class="wikitable"
|-
! Distance !! Length (in mm)
|-
| Distance pad to pad || 1.25
|-
| Left edge to first pad || 0.7
|-
| Last pad to right edge || 0.95
|-
| Bottom edge to longer pads (GND, Vcc) || 0.5
|-
| Bottom edge to shorter pads || 1
|}
== Signal descriptions ==
* '''/RESET''': Reset signal output from the console. On a mono WonderSwan, it stays low for about 18 milliseconds after power-up.
* '''/MBC''': Authentication handshake signal. A cartridge is required to communicate over this pin shortly after reset.
* '''M/IO''': Memory/IO bus selection. The cartridge bus allows both memory access (to linear addresses 0x10000-0xFFFFF) and I/O access (to ports 0xC0-0xFF):
** When Memory/IO is '''high''', pins A0-A19 specify the 20-bit linear memory address.
** When Memory/IO is '''low''', pins A0-A7 specify the 8-bit I/O port address, pins A8-A15 are low, pins A16-A19 are a copy of the I/O port address bits 4-7.
* '''/IRQ''': Cartridge interrupt. When this pin is pulled low, the console will trigger a maskable cartridge interrupt.
* '''CLK''': A clock provided by the console. This pin outputs a frequency of 384 KHz, derived from the 12.288 MHz system clock; on the WonderSwan Color, it can optionally be configured by software to provide a 6.144 MHz frequency instead.
== Timing requirements ==
The '''/OE''' or '''/WE''' signal appear to have a frequency of about 3.072 MHz, derived from the 12.288 MHz system clock. This leaves half this period, so about 162 ns, to handle one memory access.
TODO: Verify how using ROM/SRAM wait states affects this.
== Authentication handshake ==
Shortly after '''/RESET''' goes high, a handshake between the SoC and the cartridge is performed, in order:
* '''/MBC''' is held high.
* On the rising edge of '''CLK''', '''A0'''-'''A3''' are set to 0x5 and '''A16'''-'''A19''' are set to 0xA.
* The cartridge continues to hold '''/MBC''' high for three additional '''CLK''' rising edges. Note that the SoC appears to allow some variance in this number of cycles.
* For each subsequent rising edge of '''CLK''', the cartridge is expected to output the following binary sequence through its '''/MBC''' pin: <code>1000101000101000000111</code>.
* After this is finished, '''/MBC''' is expected to stay high indefinitely.
On a successful handshake, the [[SoC]] sets bit 7 of the System Control I/O port. The boot ROM will refuse to boot the cartridge if this bit is not set; on the WonderSwan Color, it will refuse to start the system at all.
An example public domain (CC0) VHDL implementation by trap15 is available [https://bitbucket.org/trap15/mbc-unlock here].
fdcb2f83672d2a6b91227892a7e1b6ec13979c7f
252
251
2024-02-19T20:25:53Z
Asie
351
wikitext
text/x-wiki
== Memory access ==
Both the ROM and the SRAM chip use a standard asynchronous memory interface.
It is presumed that:
* the CPU sets the address lines after the rising edge of '''/OE''' while '''/OE''' is high,
* the CPU sets the data lines after the falling edge of '''/OE''', while '''/OE''' is low (TODO: only confirmed for I/O writes),
* the CPU latches the data lines on the subsequent rising edge of '''/OE'''.
Memory may be accessed in 8-bit or 16-bit mode. SRAM reads/writes always happen in 8-bit mode, while ROM reads/writes can happen in 8-bit or 16-bit mode depending on [[ROM header|header]] configuration.
Note that in 16-bit mode, the output on address line '''A0''' is undetermined and should be ignored.
== Pinout ==
<pre>
Cartridge Console
(label side) (back)
____________
|====|
____ |--01| -- GND
... \ | -02| <- CPU A15
... | | -03| <- CPU A10
... | | -04| <- CPU A11
... | | -05| <- CPU A9
... | | -06| <- CPU A8
... | | -07| <- CPU A13
... | | -08| <- CPU A14
... | | -09| <- CPU A12
... | | -10| <- CPU A7
... | | -11| <- CPU A6
... | | -12| <- CPU A5
... | | -13| <- CPU A4
... | | -14| <> D15
... | | -15| <> D14
... | | -16| <> D7
... | | -17| <> D6
... | | -18| <> D5
... | | -19| <> D4
... | | -20| <> D3
... | | -21| <> D2
... | | -22| <> D1
... | | -23| <> D0
... | |--24| -- +3.3V
... | |--25| -- +3.3V
... | | -26| <- CPU A0
... | | -27| <- CPU A1
... | | -28| <- CPU A2
... | | -29| <- CPU A3
... | | -30| <- CPU A19
... | | -31| <- CPU A18
... | | -32| <- CPU A17
... | | -33| <- CPU A16
... | | -34| <> D8
... | | -35| <> D9
... | | -36| <> D10
... | | -37| <> D11
... | | -38| <> D12
... | | -39| <> D13
... | | -40| <- /RESET
... | | -41| -> /MBC
... | | -42| <- M/IO (Memory/IO)
... | | -43| <- /RD (Read enable)
... | | -44| <- /WR (Write enable)
... | | -45| <- /SEL (Cartridge select)
... | | -46| -> /IRQ (Interrupt request)
____/ | -47| <- CLK
|--48| -- GND
_______|====|
Cartridge Console
(label side) (back)
</pre>
== Mechanical details ==
{| class="wikitable"
|-
! Distance !! Length (in mm)
|-
| Distance pad to pad || 1.25
|-
| Left edge to first pad || 0.7
|-
| Last pad to right edge || 0.95
|-
| Bottom edge to longer pads (GND, Vcc) || 0.5
|-
| Bottom edge to shorter pads || 1
|}
== Signal descriptions ==
* '''/RESET''': Reset signal output from the console. On a mono WonderSwan, it stays low for about 18 milliseconds after power-up.
* '''/MBC''': Authentication handshake signal. A cartridge is required to communicate over this pin shortly after reset.
* '''M/IO''': Memory/IO bus selection. The cartridge bus allows both memory access (to linear addresses 0x10000-0xFFFFF) and I/O access (to ports 0xC0-0xFF):
** When Memory/IO is '''high''', pins A0-A19 specify the 20-bit linear memory address.
** When Memory/IO is '''low''', pins A0-A7 specify the 8-bit I/O port address, pins A8-A15 are low, pins A16-A19 are a copy of the I/O port address bits 4-7.
* '''/IRQ''': Cartridge interrupt. When this pin is pulled low, the console will trigger a maskable cartridge interrupt.
* '''CLK''': A clock provided by the console. This pin outputs a frequency of 384 KHz, derived from the 12.288 MHz system clock; on the WonderSwan Color, it can optionally be configured by software to provide a 6.144 MHz frequency instead.
== Timing requirements ==
The '''/OE''' or '''/WE''' signal appear to have a frequency of about 3.072 MHz, derived from the 12.288 MHz system clock. This leaves half this period, so about 162 ns, to handle one memory access.
TODO: Verify how using ROM/SRAM wait states affects this.
== Authentication handshake ==
Shortly after '''/RESET''' goes high, a handshake between the SoC and the cartridge is performed, in order:
* '''/MBC''' is held high. '''A0'''-'''A3''' are set to 0xA and '''A16'''-'''A19''' are set to 0x5.
* On a rising edge of '''CLK''', '''A0'''-'''A3''' are set to 0x5 and '''A16'''-'''A19''' are set to 0xA.
* The cartridge continues to hold '''/MBC''' high for three additional '''CLK''' rising edges. Note that the SoC appears to allow some variance in this number of cycles.
* For each subsequent rising edge of '''CLK''', the cartridge is expected to output the following binary sequence through its '''/MBC''' pin: <code>1000101000101000000111</code>.
* After this is finished, '''/MBC''' is expected to stay high indefinitely.
On a successful handshake, the [[SoC]] sets bit 7 of the System Control I/O port. The boot ROM will refuse to boot the cartridge if this bit is not set; on the WonderSwan Color, it will refuse to start the system at all.
An example public domain (CC0) VHDL implementation by trap15 is available [https://bitbucket.org/trap15/mbc-unlock here].
423f6189b4f995d2da11047d47223398549307c8
254
252
2024-02-20T08:51:05Z
Generic
362
clarify when which signals change
wikitext
text/x-wiki
== Memory access ==
Both the ROM and the SRAM chip use a standard asynchronous memory interface.
It is presumed that:
* the CPU sets the address lines before each memory access while '''/OE''' or '''/WE''' respectively are still high,
* for writes the CPU sets the data lines with the falling edge of '''/WE''' (TODO: only confirmed for I/O writes),
* for reads the CPU latches the data lines on the subsequent rising edge of '''/OE'''.
Memory may be accessed in 8-bit or 16-bit mode. SRAM reads/writes always happen in 8-bit mode, while ROM reads/writes can happen in 8-bit or 16-bit mode depending on [[ROM header|header]] configuration.
Note that in 16-bit mode, the output on address line '''A0''' is undetermined and should be ignored.
== Pinout ==
<pre>
Cartridge Console
(label side) (back)
____________
|====|
____ |--01| -- GND
... \ | -02| <- CPU A15
... | | -03| <- CPU A10
... | | -04| <- CPU A11
... | | -05| <- CPU A9
... | | -06| <- CPU A8
... | | -07| <- CPU A13
... | | -08| <- CPU A14
... | | -09| <- CPU A12
... | | -10| <- CPU A7
... | | -11| <- CPU A6
... | | -12| <- CPU A5
... | | -13| <- CPU A4
... | | -14| <> D15
... | | -15| <> D14
... | | -16| <> D7
... | | -17| <> D6
... | | -18| <> D5
... | | -19| <> D4
... | | -20| <> D3
... | | -21| <> D2
... | | -22| <> D1
... | | -23| <> D0
... | |--24| -- +3.3V
... | |--25| -- +3.3V
... | | -26| <- CPU A0
... | | -27| <- CPU A1
... | | -28| <- CPU A2
... | | -29| <- CPU A3
... | | -30| <- CPU A19
... | | -31| <- CPU A18
... | | -32| <- CPU A17
... | | -33| <- CPU A16
... | | -34| <> D8
... | | -35| <> D9
... | | -36| <> D10
... | | -37| <> D11
... | | -38| <> D12
... | | -39| <> D13
... | | -40| <- /RESET
... | | -41| -> /MBC
... | | -42| <- M/IO (Memory/IO)
... | | -43| <- /RD (Read enable)
... | | -44| <- /WR (Write enable)
... | | -45| <- /SEL (Cartridge select)
... | | -46| -> /IRQ (Interrupt request)
____/ | -47| <- CLK
|--48| -- GND
_______|====|
Cartridge Console
(label side) (back)
</pre>
== Mechanical details ==
{| class="wikitable"
|-
! Distance !! Length (in mm)
|-
| Distance pad to pad || 1.25
|-
| Left edge to first pad || 0.7
|-
| Last pad to right edge || 0.95
|-
| Bottom edge to longer pads (GND, Vcc) || 0.5
|-
| Bottom edge to shorter pads || 1
|}
== Signal descriptions ==
* '''/RESET''': Reset signal output from the console. On a mono WonderSwan, it stays low for about 18 milliseconds after power-up.
* '''/MBC''': Authentication handshake signal. A cartridge is required to communicate over this pin shortly after reset.
* '''M/IO''': Memory/IO bus selection. The cartridge bus allows both memory access (to linear addresses 0x10000-0xFFFFF) and I/O access (to ports 0xC0-0xFF):
** When Memory/IO is '''high''', pins A0-A19 specify the 20-bit linear memory address.
** When Memory/IO is '''low''', pins A0-A7 specify the 8-bit I/O port address, pins A8-A15 are low, pins A16-A19 are a copy of the I/O port address bits 4-7.
* '''/IRQ''': Cartridge interrupt. When this pin is pulled low, the console will trigger a maskable cartridge interrupt.
* '''CLK''': A clock provided by the console. This pin outputs a frequency of 384 KHz, derived from the 12.288 MHz system clock; on the WonderSwan Color, it can optionally be configured by software to provide a 6.144 MHz frequency instead.
== Timing requirements ==
The '''/OE''' or '''/WE''' signal appear to have a frequency of about 3.072 MHz, derived from the 12.288 MHz system clock. This leaves half this period, so about 162 ns, to handle one memory access.
TODO: Verify how using ROM/SRAM wait states affects this.
== Authentication handshake ==
Shortly after '''/RESET''' goes high, a handshake between the SoC and the cartridge is performed, in order:
* '''/MBC''' is held high. '''A0'''-'''A3''' are set to 0xA and '''A16'''-'''A19''' are set to 0x5.
* On a rising edge of '''CLK''', '''A0'''-'''A3''' are set to 0x5 and '''A16'''-'''A19''' are set to 0xA.
* The cartridge continues to hold '''/MBC''' high for three additional '''CLK''' rising edges. Note that the SoC appears to allow some variance in this number of cycles.
* For each subsequent rising edge of '''CLK''', the cartridge is expected to output the following binary sequence through its '''/MBC''' pin: <code>1000101000101000000111</code>.
* After this is finished, '''/MBC''' is expected to stay high indefinitely.
On a successful handshake, the [[SoC]] sets bit 7 of the System Control I/O port. The boot ROM will refuse to boot the cartridge if this bit is not set; on the WonderSwan Color, it will refuse to start the system at all.
An example public domain (CC0) VHDL implementation by trap15 is available [https://bitbucket.org/trap15/mbc-unlock here].
9fb3c63065f63e54a75118ad50edcddb9cc1dffe
Bandai 2003
0
13
253
170
2024-02-19T20:27:35Z
Asie
351
wikitext
text/x-wiki
The Bandai 2003 (LUXSOR2) is one of the two mappers used in WonderSwan cartridges.
In addition to the normal [[Mapper]] banking interface, Bandai's 2003 adds registers for an RTC interface, GPO pins, self flashing, and accessing more than 16MiB of ROM.
{| class="wikitable"
! Category
! Port
! Description
! Bits
! Type
! Notes
|-
! rowspan="3" | RTC
! rowspan="2" | $CA
| RTC Command
| style="text-align: right" | <tt style="white-space: nowrap">...1 CCCC</tt>
| W8
| Command (C)
|-
| RTC Status
| style="text-align: right" | <tt style="white-space: nowrap">D00B CCCC</tt>
| R8
| Busy (B), Command (C), Data needed (D)
|-
! $CB
| RTC Payload
| style="text-align: right" | <tt style="white-space: nowrap">dddd dddd</tt>
| RW8
| Data (d)
|-
! rowspan="2" | GPO
! $CC
| GPO Data Direction
| style="text-align: right" | <tt style="white-space: nowrap">0000 oooo</tt>
| RW8
| 1 = output, 0 = high-impedance (weak pull-down)
|-
! $CD
| GPO Data
| style="text-align: right" | <tt style="white-space: nowrap">0000 dddd</tt>
| RW8
| 1 = 3V, if enabled by data direction
|-
! Self-Flash
! $CE
| Self-Flash Control
| style="text-align: right" | <tt style="white-space: nowrap">0000 000r</tt>
| RW8
| 1 = ROM is accessible at segment 0x1000;
0 = RAM instead.
|-
! rowspan="4" | Extended bankswitching
! $CF
| ROM Linear (EX) Bank
| style="text-align: right" | <tt style="white-space: nowrap">00bb bbbb</tt>
| RW8
| Selects a 1MiB bank accessed via segments 0x4000 through 0xF000. Identical to the register at 0xC0.
|-
! $D0
| RAM(/ROM) Bank
| style="text-align: right" | <tt style="white-space: nowrap">0000 00bb bbbb bbbb</tt>
| RW16
| Selects a 64KiB bank accessed via segment 0x1000. Lower 8 bits are identical to the register at 0xC1.
|-
! $D2
| ROM0 Bank
| style="text-align: right" | <tt style="white-space: nowrap">0000 00bb bbbb bbbb</tt>
| RW16
| Selects a 64KiB bank accessed via segment 0x2000. Lower 8 bits are identical to the register at 0xC2.
|-
! $D4
| ROM1 Bank
| style="text-align: right" | <tt style="white-space: nowrap">0000 00bb bbbb bbbb</tt>
| RW16
| Selects a 64KiB bank accessed via segment 0x3000. Lower 8 bits are identical to the register at 0xC3.
|}
Not all PCBs are wired to support self-flashing. Not all ROMs have the needed /BYTE pin. Even on PCBs without support, ROM can still be enabled by writing to port $CE.
== 2003 RTC interface ==
The 2003's RTC interface is a simple half-duplex SPI-like protocol. A write to $CA will start a transaction, depending on the exact value written.
If there is no external S-3511A, all bytes will read back as $FF due to a weak pull-up inside the 2003.
For specifics of what the S-3511A expects to be done with these bytes, see [[Real-Time Clock]].
(Put logic analyzer traces here)
Values are as follows:
=== $00-$0F, $1C-$1F ===
Immediately stop the transaction. This cannot be safely used to abort an ongoing transaction, because the 2003 still relays the 384kHz clock. In contrast, normal termination stops relaying that clock.
=== $10, $11 ===
Send command byte ($60 or $61 respectively) and stop.
=== $12 ===
Send command byte ($62), then send byte stored in $CB, then stop. The 2003 expects that the value in $CB is valid and does not pause if the CPU hasn't yet written a value.
=== $13 ===
Send command byte ($63), then receive byte, then stop. After the "data needed" is set or the "busy" bit is clear the value can be read from $CB.
=== $14 ===
Send command byte ($64), then send seven bytes of payload, then stop. The 2003 expects that the ''first'' byte is preloaded in $CB, but pauses for the CPU to write each subsequent byte by setting the "Data needed" bit.
=== $15 ===
Send command byte ($65), then receive seven bytes of payload, then stop. The 2003 pauses for the CPU to read each subsequent byte by setting the "Data needed" bit.
=== $16 ===
Send command byte ($66), then send three bytes of payload, then stop.
=== $17 ===
Send command byte ($67), then receive three bytes of payload, then stop.
=== $18, $1A ===
Send command byte ($68 or $6A), then send two bytes of payload, then stop.
=== $19, $1B ===
Send command byte ($69 or $6B), then receive two bytes of payload, then stop.
== Lockout ==
Unlike the 2001 mapper, the 2003 mapper checks for the address line changes which are part of the authentication handshake after power-up. Until this handshake occurs, ROM access is inhibited. (TODO: How exactly?)
1cecca796fa1e97a8801d1c17f659a04a6a68714
Display
0
26
255
206
2024-03-15T17:32:50Z
Asie
351
/* Tiles */ Fix chunky/packed mode documentation
wikitext
text/x-wiki
The WonderSwan's display functionality generally consists of:
* a 224x144 display clocked at ~75.47 Hz by default, capable of displaying:
** up to sixteen distinct shades of gray
** 12-bit RGB444 color<sup>(color)</sup>
* two 32x32 background layers ("screens"), capable of displaying up to 512 (1024<sup>(color)</sup>) distinct tiles,
* a sprite layer, capable of displaying up to 128 8x8 sprites (up to 32 per line),
* six LCD icons to the bottom or right of the display, usable as additional indicators.
== Components ==
=== Tiles ===
The "mono" WonderSwan can display up to 512 tiles stored in a planar format, with two bits total per pixel.
The planes are interleaved with each other; that is, two consecutive bytes form a full 8x1 row of the tile:
<pre>
plane 0 plane 1
byte N byte N+1
7 bit 0 7 bit 0 full tile
---- ---- ---- ----
.... ...1 .222 22.. .22222.1
.... ...1 2222 22.. 222222.1
.... .... 22.. .... 22......
...1 1... 22.2 2... --\ 22.33...
...1 1... 22.2 2... --/ 22.33...
.... .... 22.. .... 22......
.... .... .... .... ........
11.. .... .... .... 11......
</pre>
The WonderSwan Color extends this with an additional 512 tiles (available for screens only, not sprites) and support for three new modes.
* The first new mode is another two bit per pixel mode, but using color palettes instead of monochrome shades.
The latter two modes extend tiles to four bits per pixel.
* The first among them is the planar mode, which works similarly to the two bit per pixel mode:
<pre>
plane 0 plane 1 plane 2 plane 3
byte N byte N+1 byte N+2 byte N+3
7 bit 0 7 bit 0 7 bit 0 7 bit 0 full rows
---- ---- ---- ---- ---- ---- ---- ----
1.1. 1.1. 22.. 22.. 4444 .... .... .... --\ 7654321.
.1.1 .1.1 ..22 ..22 .... 4444 8888 8888 --/ 89ABCDEF
</pre>
* The second is the chunky (packed) mode, which instead stores each plane as consecutive bits, with each byte responsible for two of the eight pixels:
<pre>
byte N byte N+1 byte N+2 byte N+3
pxl0 pxl1 pxl2 pxl3 pxl4 pxl5 pxl6 pxl7
7 bit 0 7 bit 0 7 bit 0 7 bit 0 full rows
---- ---- ---- ---- ---- ---- ---- ----
.42. .421 .4.. .4.1 ..2. ..21 .... ...1 --\ 7654321.
8..1 8... 8.21 8.2. 84.1 84.. 8421 842. --/ 89ABCDEF
</pre>
=== Colors, Shades ===
The "mono" WonderSwan uses eight value indices, which are converted by a global look-up table to eight of the sixteen shades the LCD can display:
<pre>
Palette Global shade LUT
1 ===========> 2 ==========================> 5
^ (0, 2, 4, 6) ^ (1, 3, 5, 7, 9, 11, 13, 15) ^
| | |
Tile pixel Value Displayed shade
</pre>
In "color" mode, the WonderSwan instead loads RGB444 color values from a table in the console's internal RAM:
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
.... rrrr gggg bbbb
|||| |||| ||||
|||| |||| ++++- Blue (0-15)
|||| ++++------ Green (0-15)
++++------------ Red (0-15)
</pre>
No further processing or look-up tables are applied.
=== Palettes ===
The WonderSwan provides sixteen different palettes. All sixteen can be used for screens only, while the latter eight can be used for screens and sprites. In addition, the background color (for areas where no opaque pixel is drawn) can be selected arbitrarily from the color palette or from the shade LUT.
In two bit per pixel modes, palettes 0 - 3 and 8 - 11 are ''opaque'' (color zero is opaque, four distinct colors are usable), while palettes 4 - 7 and 12 - 15 are ''translucent'' (color zero is transparent, three distinct colors are usable). This applies in both mono and color modes.
In four bit per pixel modes, every palette is ''translucent'' (color zero is transparent, fifteen distinct colors are usable). The first entry of each palette can be used only for the background color.
Palettes 8-15 are also referred to as sprite palettes 0-7.
=== Screens ===
The WonderSwan can display up to two distinct 32x32 screens. These consist of 1024 two-byte cells:
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
vhbp pppt tttt tttt
|||| |||| |||| ||||
|||| |||+--++++-++++- Tile index (0-511)
|||+-+++------------- Palette (0-15)
||+------------------ Tile bank (0-1) - color only
|+------------------- Horizontal flip
+-------------------- Vertical flip
</pre>
=== Sprites ===
The WonderSwan can display up to 128 sprites at once. These are stored in a sprite table in RAM, which consists of up to 128 four-byte entries:
<pre>
(Byte 1) (Byte 0)
15 bit 8 7 bit 0
---- ---- ---- ----
vhPi pppt tttt tttt
|||| |||| |||| ||||
|||| |||+--++++-++++- Tile index (0-511) - only bank 0
|||| +++------------- Palette (0-7) - mapped to screen palettes 8-15
|||+----------------- Window location - 0 = inside, 1 = outside
||+------------------ Priority - 0 = behind Screen 2, 1 = in front of Screen 2
|+------------------- Horizontal flip
+-------------------- Vertical flip
(Byte 2)
7 bit 0
---- ----
yyyy yyyy
|||| ||||
++++-++++- Y coordinate
(Byte 3)
7 bit 0
---- ----
xxxx xxxx
|||| ||||
++++-++++- X coordinate
</pre>
For each row, the first 32 sprites for that row will be drawn - including sprites obscured by windows or outside of the visible range; only the Y coordinate determines this. The earlier among those sprites will be on top of the later ones.
=== Visibility priority ===
For display components, the visibility priority is as follows:
* Sprite 0, high priority
* Sprite 127, high priority
* Screen 2
* Sprite 0, low priority
* Sprite 127, low priority
* Screen 1
* Background color
=== Windows ===
Screen 2 and the sprite layer can optionally be restricted to a specific window.
In addition, one can control if a given element is rendered inside or outside that window. For Screen 2, this is controlled globally; for sprites, this is controlled per-sprite.
=== Icons ===
Finally, the WonderSwan features six LCD segment icons which are displayed to the right<sup>(color)</sup> or below<sup>(mono)</sup> the main display. These are, as follows:
* Aux 3 - large circle,
* Aux 2 - medium circle,
* Aux 1 - small circle,
* Horizontal orientation,
* Vertical orientation,
* Sleep.
== Interrupts ==
The display circuit generates two interrupts of its own:
* Display Interrupt Line Match - when <code>Display Current Line</code> == <code>Display Interrupt Line</code>, at the beginning of said line.
* Display Vertical Blank - when <code>Display Current Line</code> == <code>144</code>, at the beginning of said line.
It also provides a timing source for the two Horizontal and Vertical Blank [[Timers]], which provide their own respective interrupts.
== I/O ports ==
{{Anchor|Display Control}}
=== Display Control ($00) ===
<pre>
7 bit 0
---- ----
..ow Ws21
|| ||||
|| |||+- Enable Screen 1 layer
|| ||+-- Enable Screen 2 layer
|| |+--- Enable Sprite layer
|| +---- Enable Sprite window
|+------ Enable Screen 2 window
+------- Screen 2 window location:
0 = inside, 1 = outside
</pre>
{{Anchor|Display Background}}
=== Display Background Color ($01) ===
<pre>
(mono) (color)
7 bit 0 7 bit 0
---- ---- ---- ----
.... .sss pppp iiii
||| |||| ||||
+++- Value |||| ++++- Index in palette (0-15)
(0-7) ++++------ Color palette (0-15)
</pre>
{{Anchor|Display Current Line}}
=== Display Current Line ($02 read) ===
The current line being drawn by the display.
Note that lines are sent to the display with a one-line delay. This matters for color palette or shade LUT manipulation; changing these values when <code>current line == 1</code> will actually affect line 0.
{{Anchor|Display Interrupt Line}}
=== Display Interrupt Line ($03) ===
The line to emit an interrupt on.
{{Anchor|Sprite Table Address}}
=== Sprite Table Address ($04) ===
<pre>
7 bit 0
---- ----
..Aa aaaa
|| ||||
|+-++++- Address (bits 9-13)
+------- Address (bit 14) - color only
</pre>
{{Anchor|Sprite Table First}}
=== Sprite Table First ($05) ===
<pre>
7 bit 0
---- ----
.iii iiii
||| ||||
+++-++++- Index of first sprite entry to draw (0-127)
</pre>
{{Anchor|Sprite Table Count}}
=== Sprite Table Count ($06) ===
<pre>
7 bit 0
---- ----
cccc cccc
|||| ||||
++++-++++- Count of sprite entries to draw (1-128)
</pre>
{{Anchor|Screen Address}}
=== Screen Address ($07) ===
<pre>
7 bit 0
---- ----
2222 1111
|||| ||||
|||| |+++- Screen 1 address (bits 11-13)
|||| +---- Screen 1 address (bit 14) - color only
|+++------ Screen 2 address (bits 11-13)
+--------- Screen 2 address (bit 14) - color only
</pre>
{{Anchor|Screen 2 Window}}
=== Screen 2 Window Left ($08) ===
=== Screen 2 Window Top ($09) ===
=== Screen 2 Window Right ($0A) ===
=== Screen 2 Window Bottom ($0B) ===
{{Anchor|Sprite Window}}
=== Sprite Window Left ($0C) ===
=== Sprite Window Top ($0D) ===
=== Sprite Window Right ($0E) ===
=== Sprite Window Bottom ($0F) ===
{{Anchor|Screen Scroll}}
=== Screen 1 Scroll X ($10) ===
=== Screen 1 Scroll Y ($11) ===
=== Screen 2 Scroll X ($12) ===
=== Screen 2 Scroll Y ($13) ===
{{Anchor|LCD Control}}
=== LCD Control ($14) ===
<pre>
7 bit 0
---- ----
.... ..Ce
||
|+- LCD Enable: 0 = sleep, 1 = enabled
+-- Contrast (WSC): 0 = low, 1 = high
</pre>
{{Anchor|LCD Icon Control}}
=== LCD Icon Control ($15) ===
<pre>
7 bit 0
---- ----
..32 1hvs
|| ||||
|| |||+- Sleep
|| ||+-- Vertical orientation
|| |+--- Horizontal orientation
|| +---- Aux 1
|+------ Aux 2
+------- Aux 3
</pre>
{{Anchor|LCD Mono Shade LUT}}
=== LCD Mono Shade LUT ($1C-$1F) ===
<pre>
$1C $1D $1E $1F
7 bit 0 7 bit 0 7 bit 0 7 bit 0
---- ---- ---- ---- ---- ---- ---- ----
1111 0000 3333 2222 5555 4444 7777 6666
</pre>
{{Anchor|LCD Mono Palette}}
=== LCD Mono Palette 0..15 ($20, $21 .. $3E, $3F) ===
The monochrome palette is laid out as sixteen words:
<pre>
N+1 N
15 bit 8 7 bit 0
---- ---- ---- ----
.333 .222 .111 .000
||| ||| ||| |||
||| ||| ||| +++- Shade LUT index for color 0
||| ||| +++------ Shade LUT index for color 1
||| +++------------ Shade LUT index for color 2
+++----------------- Shade LUT index for color 3
</pre>
== Internal I/O ports ==
These I/O ports are said to be internal and not intended for use by commercial games.
{{Anchor|LCD Final Line}}
=== LCD Final Line ($16) ===
The final line preceding line counter restart. By default, this should be set to 158.
It is said setting this register to an odd value on SwanCrystal has an adverse effect to the LCD panel<ref>[http://daifukkat.su/docs/wsman/#REG_LCD_VSYNC REG_LCD_VSYNC - WSMan]</ref>, but the exact mechanism is unknown.
{{Anchor|LCD Back Porch Line}}
=== LCD Back Porch Line ($17, WSC only) ===
This port is available on the WonderSwan Color only - not the SwanCrystal!
The final line preceding the vertical back porch; by default, this should be set to 155.
The vertical back porch of the LCD is assumed to be 4 lines by some hardware, including IPS mods, as well as the official "TV Swan" capture device. Given that the first visible line is sent to the LCD on the display's line 1, this should be generally set to <code>LCD Final Line - 3</code>.
Conversely, it is said moving this value closer to vertical blank improves LCD visibility<ref>[http://daifukkat.su/docs/wsman/#REG_LCD_VTOTAL REG_LCD_VTOTAL - WSMan]</ref>, but the exact mechanism is unknown.
{{Anchor|LCD Status}}
=== LCD Status ($1A) ===
<pre>
7 bit 0
---- ----
...v vv.s
| || |
| || +- LCD sleep: 0 = no, 1 = sleep
| ||
| || Volume segments:
| |+--- Volume B (medium, high)
| +---- Volume A (low, high)
+------ Speaker
</pre>
=== TFT LCD Configuration ($70, $71, $72, $73, $74, $75, $76, $77 SwanCrystal only) ===
These eight bytes are read from internal EEPROM and configure unknown aspects of the console's TFT LCD panel.
They are only writable while the [[Boot ROM]] is unlocked - locking has the side effect of making them read-only.
== Notes ==
<references />
1d1d01156c67d9d5053ae21e2a843fa6809cd57b
256
255
2024-03-15T17:33:40Z
Asie
351
wikitext
text/x-wiki
The WonderSwan's display functionality generally consists of:
* a 224x144 display clocked at ~75.47 Hz by default, capable of displaying:
** up to sixteen distinct shades of gray
** 12-bit RGB444 color<sup>(color)</sup>
* two 32x32 background layers ("screens"), capable of displaying up to 512 (1024<sup>(color)</sup>) distinct tiles,
* a sprite layer, capable of displaying up to 128 8x8 sprites (up to 32 per line),
* six LCD icons to the bottom or right of the display, usable as additional indicators.
== Components ==
=== Tiles ===
The "mono" WonderSwan can display up to 512 tiles stored in a planar format, with two bits total per pixel.
The planes are interleaved with each other; that is, two consecutive bytes form a full 8x1 row of the tile:
<pre>
plane 0 plane 1
byte N byte N+1
7 bit 0 7 bit 0 full tile
---- ---- ---- ----
.... ...1 .222 22.. .22222.1
.... ...1 2222 22.. 222222.1
.... .... 22.. .... 22......
...1 1... 22.2 2... --\ 22.33...
...1 1... 22.2 2... --/ 22.33...
.... .... 22.. .... 22......
.... .... .... .... ........
11.. .... .... .... 11......
</pre>
The WonderSwan Color extends this with an additional 512 tiles (available for screens only, not sprites) and support for three new modes.
* The first new mode is another two bit per pixel mode, but using color palettes instead of monochrome shades.
The latter two modes extend tiles to four bits per pixel.
* The first among them is the planar mode, which works similarly to the two bit per pixel mode:
<pre>
plane 0 plane 1 plane 2 plane 3
byte N byte N+1 byte N+2 byte N+3
7 bit 0 7 bit 0 7 bit 0 7 bit 0 full rows
---- ---- ---- ---- ---- ---- ---- ----
1.1. 1.1. 22.. 22.. 4444 .... .... .... --\ 7654321.
.1.1 .1.1 ..22 ..22 .... 4444 8888 8888 --/ 89ABCDEF
</pre>
* The second is the chunky (packed) mode, which instead stores each plane as consecutive bits, with each byte responsible for two of the eight pixels:
<pre>
byte N byte N+1 byte N+2 byte N+3
pxl0 pxl1 pxl2 pxl3 pxl4 pxl5 pxl6 pxl7
7 bit 0 7 bit 0 7 bit 0 7 bit 0 full rows
---- ---- ---- ---- ---- ---- ---- ----
.421 .42. .4.1 .4.. ..21 ..2. ...1 .... --\ 7654321.
8... 8..1 8.2. 8.21 84.. 84.1 842. 8421 --/ 89ABCDEF
</pre>
=== Colors, Shades ===
The "mono" WonderSwan uses eight value indices, which are converted by a global look-up table to eight of the sixteen shades the LCD can display:
<pre>
Palette Global shade LUT
1 ===========> 2 ==========================> 5
^ (0, 2, 4, 6) ^ (1, 3, 5, 7, 9, 11, 13, 15) ^
| | |
Tile pixel Value Displayed shade
</pre>
In "color" mode, the WonderSwan instead loads RGB444 color values from a table in the console's internal RAM:
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
.... rrrr gggg bbbb
|||| |||| ||||
|||| |||| ++++- Blue (0-15)
|||| ++++------ Green (0-15)
++++------------ Red (0-15)
</pre>
No further processing or look-up tables are applied.
=== Palettes ===
The WonderSwan provides sixteen different palettes. All sixteen can be used for screens only, while the latter eight can be used for screens and sprites. In addition, the background color (for areas where no opaque pixel is drawn) can be selected arbitrarily from the color palette or from the shade LUT.
In two bit per pixel modes, palettes 0 - 3 and 8 - 11 are ''opaque'' (color zero is opaque, four distinct colors are usable), while palettes 4 - 7 and 12 - 15 are ''translucent'' (color zero is transparent, three distinct colors are usable). This applies in both mono and color modes.
In four bit per pixel modes, every palette is ''translucent'' (color zero is transparent, fifteen distinct colors are usable). The first entry of each palette can be used only for the background color.
Palettes 8-15 are also referred to as sprite palettes 0-7.
=== Screens ===
The WonderSwan can display up to two distinct 32x32 screens. These consist of 1024 two-byte cells:
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
vhbp pppt tttt tttt
|||| |||| |||| ||||
|||| |||+--++++-++++- Tile index (0-511)
|||+-+++------------- Palette (0-15)
||+------------------ Tile bank (0-1) - color only
|+------------------- Horizontal flip
+-------------------- Vertical flip
</pre>
=== Sprites ===
The WonderSwan can display up to 128 sprites at once. These are stored in a sprite table in RAM, which consists of up to 128 four-byte entries:
<pre>
(Byte 1) (Byte 0)
15 bit 8 7 bit 0
---- ---- ---- ----
vhPi pppt tttt tttt
|||| |||| |||| ||||
|||| |||+--++++-++++- Tile index (0-511) - only bank 0
|||| +++------------- Palette (0-7) - mapped to screen palettes 8-15
|||+----------------- Window location - 0 = inside, 1 = outside
||+------------------ Priority - 0 = behind Screen 2, 1 = in front of Screen 2
|+------------------- Horizontal flip
+-------------------- Vertical flip
(Byte 2)
7 bit 0
---- ----
yyyy yyyy
|||| ||||
++++-++++- Y coordinate
(Byte 3)
7 bit 0
---- ----
xxxx xxxx
|||| ||||
++++-++++- X coordinate
</pre>
For each row, the first 32 sprites for that row will be drawn - including sprites obscured by windows or outside of the visible range; only the Y coordinate determines this. The earlier among those sprites will be on top of the later ones.
=== Visibility priority ===
For display components, the visibility priority is as follows:
* Sprite 0, high priority
* Sprite 127, high priority
* Screen 2
* Sprite 0, low priority
* Sprite 127, low priority
* Screen 1
* Background color
=== Windows ===
Screen 2 and the sprite layer can optionally be restricted to a specific window.
In addition, one can control if a given element is rendered inside or outside that window. For Screen 2, this is controlled globally; for sprites, this is controlled per-sprite.
=== Icons ===
Finally, the WonderSwan features six LCD segment icons which are displayed to the right<sup>(color)</sup> or below<sup>(mono)</sup> the main display. These are, as follows:
* Aux 3 - large circle,
* Aux 2 - medium circle,
* Aux 1 - small circle,
* Horizontal orientation,
* Vertical orientation,
* Sleep.
== Interrupts ==
The display circuit generates two interrupts of its own:
* Display Interrupt Line Match - when <code>Display Current Line</code> == <code>Display Interrupt Line</code>, at the beginning of said line.
* Display Vertical Blank - when <code>Display Current Line</code> == <code>144</code>, at the beginning of said line.
It also provides a timing source for the two Horizontal and Vertical Blank [[Timers]], which provide their own respective interrupts.
== I/O ports ==
{{Anchor|Display Control}}
=== Display Control ($00) ===
<pre>
7 bit 0
---- ----
..ow Ws21
|| ||||
|| |||+- Enable Screen 1 layer
|| ||+-- Enable Screen 2 layer
|| |+--- Enable Sprite layer
|| +---- Enable Sprite window
|+------ Enable Screen 2 window
+------- Screen 2 window location:
0 = inside, 1 = outside
</pre>
{{Anchor|Display Background}}
=== Display Background Color ($01) ===
<pre>
(mono) (color)
7 bit 0 7 bit 0
---- ---- ---- ----
.... .sss pppp iiii
||| |||| ||||
+++- Value |||| ++++- Index in palette (0-15)
(0-7) ++++------ Color palette (0-15)
</pre>
{{Anchor|Display Current Line}}
=== Display Current Line ($02 read) ===
The current line being drawn by the display.
Note that lines are sent to the display with a one-line delay. This matters for color palette or shade LUT manipulation; changing these values when <code>current line == 1</code> will actually affect line 0.
{{Anchor|Display Interrupt Line}}
=== Display Interrupt Line ($03) ===
The line to emit an interrupt on.
{{Anchor|Sprite Table Address}}
=== Sprite Table Address ($04) ===
<pre>
7 bit 0
---- ----
..Aa aaaa
|| ||||
|+-++++- Address (bits 9-13)
+------- Address (bit 14) - color only
</pre>
{{Anchor|Sprite Table First}}
=== Sprite Table First ($05) ===
<pre>
7 bit 0
---- ----
.iii iiii
||| ||||
+++-++++- Index of first sprite entry to draw (0-127)
</pre>
{{Anchor|Sprite Table Count}}
=== Sprite Table Count ($06) ===
<pre>
7 bit 0
---- ----
cccc cccc
|||| ||||
++++-++++- Count of sprite entries to draw (1-128)
</pre>
{{Anchor|Screen Address}}
=== Screen Address ($07) ===
<pre>
7 bit 0
---- ----
2222 1111
|||| ||||
|||| |+++- Screen 1 address (bits 11-13)
|||| +---- Screen 1 address (bit 14) - color only
|+++------ Screen 2 address (bits 11-13)
+--------- Screen 2 address (bit 14) - color only
</pre>
{{Anchor|Screen 2 Window}}
=== Screen 2 Window Left ($08) ===
=== Screen 2 Window Top ($09) ===
=== Screen 2 Window Right ($0A) ===
=== Screen 2 Window Bottom ($0B) ===
{{Anchor|Sprite Window}}
=== Sprite Window Left ($0C) ===
=== Sprite Window Top ($0D) ===
=== Sprite Window Right ($0E) ===
=== Sprite Window Bottom ($0F) ===
{{Anchor|Screen Scroll}}
=== Screen 1 Scroll X ($10) ===
=== Screen 1 Scroll Y ($11) ===
=== Screen 2 Scroll X ($12) ===
=== Screen 2 Scroll Y ($13) ===
{{Anchor|LCD Control}}
=== LCD Control ($14) ===
<pre>
7 bit 0
---- ----
.... ..Ce
||
|+- LCD Enable: 0 = sleep, 1 = enabled
+-- Contrast (WSC): 0 = low, 1 = high
</pre>
{{Anchor|LCD Icon Control}}
=== LCD Icon Control ($15) ===
<pre>
7 bit 0
---- ----
..32 1hvs
|| ||||
|| |||+- Sleep
|| ||+-- Vertical orientation
|| |+--- Horizontal orientation
|| +---- Aux 1
|+------ Aux 2
+------- Aux 3
</pre>
{{Anchor|LCD Mono Shade LUT}}
=== LCD Mono Shade LUT ($1C-$1F) ===
<pre>
$1C $1D $1E $1F
7 bit 0 7 bit 0 7 bit 0 7 bit 0
---- ---- ---- ---- ---- ---- ---- ----
1111 0000 3333 2222 5555 4444 7777 6666
</pre>
{{Anchor|LCD Mono Palette}}
=== LCD Mono Palette 0..15 ($20, $21 .. $3E, $3F) ===
The monochrome palette is laid out as sixteen words:
<pre>
N+1 N
15 bit 8 7 bit 0
---- ---- ---- ----
.333 .222 .111 .000
||| ||| ||| |||
||| ||| ||| +++- Shade LUT index for color 0
||| ||| +++------ Shade LUT index for color 1
||| +++------------ Shade LUT index for color 2
+++----------------- Shade LUT index for color 3
</pre>
== Internal I/O ports ==
These I/O ports are said to be internal and not intended for use by commercial games.
{{Anchor|LCD Final Line}}
=== LCD Final Line ($16) ===
The final line preceding line counter restart. By default, this should be set to 158.
It is said setting this register to an odd value on SwanCrystal has an adverse effect to the LCD panel<ref>[http://daifukkat.su/docs/wsman/#REG_LCD_VSYNC REG_LCD_VSYNC - WSMan]</ref>, but the exact mechanism is unknown.
{{Anchor|LCD Back Porch Line}}
=== LCD Back Porch Line ($17, WSC only) ===
This port is available on the WonderSwan Color only - not the SwanCrystal!
The final line preceding the vertical back porch; by default, this should be set to 155.
The vertical back porch of the LCD is assumed to be 4 lines by some hardware, including IPS mods, as well as the official "TV Swan" capture device. Given that the first visible line is sent to the LCD on the display's line 1, this should be generally set to <code>LCD Final Line - 3</code>.
Conversely, it is said moving this value closer to vertical blank improves LCD visibility<ref>[http://daifukkat.su/docs/wsman/#REG_LCD_VTOTAL REG_LCD_VTOTAL - WSMan]</ref>, but the exact mechanism is unknown.
{{Anchor|LCD Status}}
=== LCD Status ($1A) ===
<pre>
7 bit 0
---- ----
...v vv.s
| || |
| || +- LCD sleep: 0 = no, 1 = sleep
| ||
| || Volume segments:
| |+--- Volume B (medium, high)
| +---- Volume A (low, high)
+------ Speaker
</pre>
=== TFT LCD Configuration ($70, $71, $72, $73, $74, $75, $76, $77 SwanCrystal only) ===
These eight bytes are read from internal EEPROM and configure unknown aspects of the console's TFT LCD panel.
They are only writable while the [[Boot ROM]] is unlocked - locking has the side effect of making them read-only.
== Notes ==
<references />
fdb999a44a5a9735973b72157c6dd0969878069e
296
256
2024-07-10T18:45:48Z
Asie
351
/* LCD Final Line ($16) */
wikitext
text/x-wiki
The WonderSwan's display functionality generally consists of:
* a 224x144 display clocked at ~75.47 Hz by default, capable of displaying:
** up to sixteen distinct shades of gray
** 12-bit RGB444 color<sup>(color)</sup>
* two 32x32 background layers ("screens"), capable of displaying up to 512 (1024<sup>(color)</sup>) distinct tiles,
* a sprite layer, capable of displaying up to 128 8x8 sprites (up to 32 per line),
* six LCD icons to the bottom or right of the display, usable as additional indicators.
== Components ==
=== Tiles ===
The "mono" WonderSwan can display up to 512 tiles stored in a planar format, with two bits total per pixel.
The planes are interleaved with each other; that is, two consecutive bytes form a full 8x1 row of the tile:
<pre>
plane 0 plane 1
byte N byte N+1
7 bit 0 7 bit 0 full tile
---- ---- ---- ----
.... ...1 .222 22.. .22222.1
.... ...1 2222 22.. 222222.1
.... .... 22.. .... 22......
...1 1... 22.2 2... --\ 22.33...
...1 1... 22.2 2... --/ 22.33...
.... .... 22.. .... 22......
.... .... .... .... ........
11.. .... .... .... 11......
</pre>
The WonderSwan Color extends this with an additional 512 tiles (available for screens only, not sprites) and support for three new modes.
* The first new mode is another two bit per pixel mode, but using color palettes instead of monochrome shades.
The latter two modes extend tiles to four bits per pixel.
* The first among them is the planar mode, which works similarly to the two bit per pixel mode:
<pre>
plane 0 plane 1 plane 2 plane 3
byte N byte N+1 byte N+2 byte N+3
7 bit 0 7 bit 0 7 bit 0 7 bit 0 full rows
---- ---- ---- ---- ---- ---- ---- ----
1.1. 1.1. 22.. 22.. 4444 .... .... .... --\ 7654321.
.1.1 .1.1 ..22 ..22 .... 4444 8888 8888 --/ 89ABCDEF
</pre>
* The second is the chunky (packed) mode, which instead stores each plane as consecutive bits, with each byte responsible for two of the eight pixels:
<pre>
byte N byte N+1 byte N+2 byte N+3
pxl0 pxl1 pxl2 pxl3 pxl4 pxl5 pxl6 pxl7
7 bit 0 7 bit 0 7 bit 0 7 bit 0 full rows
---- ---- ---- ---- ---- ---- ---- ----
.421 .42. .4.1 .4.. ..21 ..2. ...1 .... --\ 7654321.
8... 8..1 8.2. 8.21 84.. 84.1 842. 8421 --/ 89ABCDEF
</pre>
=== Colors, Shades ===
The "mono" WonderSwan uses eight value indices, which are converted by a global look-up table to eight of the sixteen shades the LCD can display:
<pre>
Palette Global shade LUT
1 ===========> 2 ==========================> 5
^ (0, 2, 4, 6) ^ (1, 3, 5, 7, 9, 11, 13, 15) ^
| | |
Tile pixel Value Displayed shade
</pre>
In "color" mode, the WonderSwan instead loads RGB444 color values from a table in the console's internal RAM:
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
.... rrrr gggg bbbb
|||| |||| ||||
|||| |||| ++++- Blue (0-15)
|||| ++++------ Green (0-15)
++++------------ Red (0-15)
</pre>
No further processing or look-up tables are applied.
=== Palettes ===
The WonderSwan provides sixteen different palettes. All sixteen can be used for screens only, while the latter eight can be used for screens and sprites. In addition, the background color (for areas where no opaque pixel is drawn) can be selected arbitrarily from the color palette or from the shade LUT.
In two bit per pixel modes, palettes 0 - 3 and 8 - 11 are ''opaque'' (color zero is opaque, four distinct colors are usable), while palettes 4 - 7 and 12 - 15 are ''translucent'' (color zero is transparent, three distinct colors are usable). This applies in both mono and color modes.
In four bit per pixel modes, every palette is ''translucent'' (color zero is transparent, fifteen distinct colors are usable). The first entry of each palette can be used only for the background color.
Palettes 8-15 are also referred to as sprite palettes 0-7.
=== Screens ===
The WonderSwan can display up to two distinct 32x32 screens. These consist of 1024 two-byte cells:
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
vhbp pppt tttt tttt
|||| |||| |||| ||||
|||| |||+--++++-++++- Tile index (0-511)
|||+-+++------------- Palette (0-15)
||+------------------ Tile bank (0-1) - color only
|+------------------- Horizontal flip
+-------------------- Vertical flip
</pre>
=== Sprites ===
The WonderSwan can display up to 128 sprites at once. These are stored in a sprite table in RAM, which consists of up to 128 four-byte entries:
<pre>
(Byte 1) (Byte 0)
15 bit 8 7 bit 0
---- ---- ---- ----
vhPi pppt tttt tttt
|||| |||| |||| ||||
|||| |||+--++++-++++- Tile index (0-511) - only bank 0
|||| +++------------- Palette (0-7) - mapped to screen palettes 8-15
|||+----------------- Window location - 0 = inside, 1 = outside
||+------------------ Priority - 0 = behind Screen 2, 1 = in front of Screen 2
|+------------------- Horizontal flip
+-------------------- Vertical flip
(Byte 2)
7 bit 0
---- ----
yyyy yyyy
|||| ||||
++++-++++- Y coordinate
(Byte 3)
7 bit 0
---- ----
xxxx xxxx
|||| ||||
++++-++++- X coordinate
</pre>
For each row, the first 32 sprites for that row will be drawn - including sprites obscured by windows or outside of the visible range; only the Y coordinate determines this. The earlier among those sprites will be on top of the later ones.
=== Visibility priority ===
For display components, the visibility priority is as follows:
* Sprite 0, high priority
* Sprite 127, high priority
* Screen 2
* Sprite 0, low priority
* Sprite 127, low priority
* Screen 1
* Background color
=== Windows ===
Screen 2 and the sprite layer can optionally be restricted to a specific window.
In addition, one can control if a given element is rendered inside or outside that window. For Screen 2, this is controlled globally; for sprites, this is controlled per-sprite.
=== Icons ===
Finally, the WonderSwan features six LCD segment icons which are displayed to the right<sup>(color)</sup> or below<sup>(mono)</sup> the main display. These are, as follows:
* Aux 3 - large circle,
* Aux 2 - medium circle,
* Aux 1 - small circle,
* Horizontal orientation,
* Vertical orientation,
* Sleep.
== Interrupts ==
The display circuit generates two interrupts of its own:
* Display Interrupt Line Match - when <code>Display Current Line</code> == <code>Display Interrupt Line</code>, at the beginning of said line.
* Display Vertical Blank - when <code>Display Current Line</code> == <code>144</code>, at the beginning of said line.
It also provides a timing source for the two Horizontal and Vertical Blank [[Timers]], which provide their own respective interrupts.
== I/O ports ==
{{Anchor|Display Control}}
=== Display Control ($00) ===
<pre>
7 bit 0
---- ----
..ow Ws21
|| ||||
|| |||+- Enable Screen 1 layer
|| ||+-- Enable Screen 2 layer
|| |+--- Enable Sprite layer
|| +---- Enable Sprite window
|+------ Enable Screen 2 window
+------- Screen 2 window location:
0 = inside, 1 = outside
</pre>
{{Anchor|Display Background}}
=== Display Background Color ($01) ===
<pre>
(mono) (color)
7 bit 0 7 bit 0
---- ---- ---- ----
.... .sss pppp iiii
||| |||| ||||
+++- Value |||| ++++- Index in palette (0-15)
(0-7) ++++------ Color palette (0-15)
</pre>
{{Anchor|Display Current Line}}
=== Display Current Line ($02 read) ===
The current line being drawn by the display.
Note that lines are sent to the display with a one-line delay. This matters for color palette or shade LUT manipulation; changing these values when <code>current line == 1</code> will actually affect line 0.
{{Anchor|Display Interrupt Line}}
=== Display Interrupt Line ($03) ===
The line to emit an interrupt on.
{{Anchor|Sprite Table Address}}
=== Sprite Table Address ($04) ===
<pre>
7 bit 0
---- ----
..Aa aaaa
|| ||||
|+-++++- Address (bits 9-13)
+------- Address (bit 14) - color only
</pre>
{{Anchor|Sprite Table First}}
=== Sprite Table First ($05) ===
<pre>
7 bit 0
---- ----
.iii iiii
||| ||||
+++-++++- Index of first sprite entry to draw (0-127)
</pre>
{{Anchor|Sprite Table Count}}
=== Sprite Table Count ($06) ===
<pre>
7 bit 0
---- ----
cccc cccc
|||| ||||
++++-++++- Count of sprite entries to draw (1-128)
</pre>
{{Anchor|Screen Address}}
=== Screen Address ($07) ===
<pre>
7 bit 0
---- ----
2222 1111
|||| ||||
|||| |+++- Screen 1 address (bits 11-13)
|||| +---- Screen 1 address (bit 14) - color only
|+++------ Screen 2 address (bits 11-13)
+--------- Screen 2 address (bit 14) - color only
</pre>
{{Anchor|Screen 2 Window}}
=== Screen 2 Window Left ($08) ===
=== Screen 2 Window Top ($09) ===
=== Screen 2 Window Right ($0A) ===
=== Screen 2 Window Bottom ($0B) ===
{{Anchor|Sprite Window}}
=== Sprite Window Left ($0C) ===
=== Sprite Window Top ($0D) ===
=== Sprite Window Right ($0E) ===
=== Sprite Window Bottom ($0F) ===
{{Anchor|Screen Scroll}}
=== Screen 1 Scroll X ($10) ===
=== Screen 1 Scroll Y ($11) ===
=== Screen 2 Scroll X ($12) ===
=== Screen 2 Scroll Y ($13) ===
{{Anchor|LCD Control}}
=== LCD Control ($14) ===
<pre>
7 bit 0
---- ----
.... ..Ce
||
|+- LCD Enable: 0 = sleep, 1 = enabled
+-- Contrast (WSC): 0 = low, 1 = high
</pre>
{{Anchor|LCD Icon Control}}
=== LCD Icon Control ($15) ===
<pre>
7 bit 0
---- ----
..32 1hvs
|| ||||
|| |||+- Sleep
|| ||+-- Vertical orientation
|| |+--- Horizontal orientation
|| +---- Aux 1
|+------ Aux 2
+------- Aux 3
</pre>
{{Anchor|LCD Mono Shade LUT}}
=== LCD Mono Shade LUT ($1C-$1F) ===
<pre>
$1C $1D $1E $1F
7 bit 0 7 bit 0 7 bit 0 7 bit 0
---- ---- ---- ---- ---- ---- ---- ----
1111 0000 3333 2222 5555 4444 7777 6666
</pre>
{{Anchor|LCD Mono Palette}}
=== LCD Mono Palette 0..15 ($20, $21 .. $3E, $3F) ===
The monochrome palette is laid out as sixteen words:
<pre>
N+1 N
15 bit 8 7 bit 0
---- ---- ---- ----
.333 .222 .111 .000
||| ||| ||| |||
||| ||| ||| +++- Shade LUT index for color 0
||| ||| +++------ Shade LUT index for color 1
||| +++------------ Shade LUT index for color 2
+++----------------- Shade LUT index for color 3
</pre>
== Internal I/O ports ==
These I/O ports are said to be internal and not intended for use by commercial games.
{{Anchor|LCD Final Line}}
=== LCD Final Line ($16) ===
The final line preceding line counter restart and the beginning of active display. By default, this is set to 158, which equals 159 total lines per frame.
It is said setting this register to an odd value on SwanCrystal has an adverse effect to the LCD panel<ref>[http://daifukkat.su/docs/wsman/#REG_LCD_VSYNC REG_LCD_VSYNC - WSMan]</ref>, but the exact mechanism is unknown.
{{Anchor|LCD Back Porch Line}}
=== LCD Back Porch Line ($17, WSC only) ===
This port is available on the WonderSwan Color only - not the SwanCrystal!
The final line preceding the vertical back porch; by default, this should be set to 155.
The vertical back porch of the LCD is assumed to be 4 lines by some hardware, including IPS mods, as well as the official "TV Swan" capture device. Given that the first visible line is sent to the LCD on the display's line 1, this should be generally set to <code>LCD Final Line - 3</code>.
Conversely, it is said moving this value closer to vertical blank improves LCD visibility<ref>[http://daifukkat.su/docs/wsman/#REG_LCD_VTOTAL REG_LCD_VTOTAL - WSMan]</ref>, but the exact mechanism is unknown.
{{Anchor|LCD Status}}
=== LCD Status ($1A) ===
<pre>
7 bit 0
---- ----
...v vv.s
| || |
| || +- LCD sleep: 0 = no, 1 = sleep
| ||
| || Volume segments:
| |+--- Volume B (medium, high)
| +---- Volume A (low, high)
+------ Speaker
</pre>
=== TFT LCD Configuration ($70, $71, $72, $73, $74, $75, $76, $77 SwanCrystal only) ===
These eight bytes are read from internal EEPROM and configure unknown aspects of the console's TFT LCD panel.
They are only writable while the [[Boot ROM]] is unlocked - locking has the side effect of making them read-only.
== Notes ==
<references />
79df6403eb2df6d3c14148ede560698806c76d63
297
296
2024-07-10T18:47:42Z
Asie
351
/* Internal I/O ports */ fix references
wikitext
text/x-wiki
The WonderSwan's display functionality generally consists of:
* a 224x144 display clocked at ~75.47 Hz by default, capable of displaying:
** up to sixteen distinct shades of gray
** 12-bit RGB444 color<sup>(color)</sup>
* two 32x32 background layers ("screens"), capable of displaying up to 512 (1024<sup>(color)</sup>) distinct tiles,
* a sprite layer, capable of displaying up to 128 8x8 sprites (up to 32 per line),
* six LCD icons to the bottom or right of the display, usable as additional indicators.
== Components ==
=== Tiles ===
The "mono" WonderSwan can display up to 512 tiles stored in a planar format, with two bits total per pixel.
The planes are interleaved with each other; that is, two consecutive bytes form a full 8x1 row of the tile:
<pre>
plane 0 plane 1
byte N byte N+1
7 bit 0 7 bit 0 full tile
---- ---- ---- ----
.... ...1 .222 22.. .22222.1
.... ...1 2222 22.. 222222.1
.... .... 22.. .... 22......
...1 1... 22.2 2... --\ 22.33...
...1 1... 22.2 2... --/ 22.33...
.... .... 22.. .... 22......
.... .... .... .... ........
11.. .... .... .... 11......
</pre>
The WonderSwan Color extends this with an additional 512 tiles (available for screens only, not sprites) and support for three new modes.
* The first new mode is another two bit per pixel mode, but using color palettes instead of monochrome shades.
The latter two modes extend tiles to four bits per pixel.
* The first among them is the planar mode, which works similarly to the two bit per pixel mode:
<pre>
plane 0 plane 1 plane 2 plane 3
byte N byte N+1 byte N+2 byte N+3
7 bit 0 7 bit 0 7 bit 0 7 bit 0 full rows
---- ---- ---- ---- ---- ---- ---- ----
1.1. 1.1. 22.. 22.. 4444 .... .... .... --\ 7654321.
.1.1 .1.1 ..22 ..22 .... 4444 8888 8888 --/ 89ABCDEF
</pre>
* The second is the chunky (packed) mode, which instead stores each plane as consecutive bits, with each byte responsible for two of the eight pixels:
<pre>
byte N byte N+1 byte N+2 byte N+3
pxl0 pxl1 pxl2 pxl3 pxl4 pxl5 pxl6 pxl7
7 bit 0 7 bit 0 7 bit 0 7 bit 0 full rows
---- ---- ---- ---- ---- ---- ---- ----
.421 .42. .4.1 .4.. ..21 ..2. ...1 .... --\ 7654321.
8... 8..1 8.2. 8.21 84.. 84.1 842. 8421 --/ 89ABCDEF
</pre>
=== Colors, Shades ===
The "mono" WonderSwan uses eight value indices, which are converted by a global look-up table to eight of the sixteen shades the LCD can display:
<pre>
Palette Global shade LUT
1 ===========> 2 ==========================> 5
^ (0, 2, 4, 6) ^ (1, 3, 5, 7, 9, 11, 13, 15) ^
| | |
Tile pixel Value Displayed shade
</pre>
In "color" mode, the WonderSwan instead loads RGB444 color values from a table in the console's internal RAM:
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
.... rrrr gggg bbbb
|||| |||| ||||
|||| |||| ++++- Blue (0-15)
|||| ++++------ Green (0-15)
++++------------ Red (0-15)
</pre>
No further processing or look-up tables are applied.
=== Palettes ===
The WonderSwan provides sixteen different palettes. All sixteen can be used for screens only, while the latter eight can be used for screens and sprites. In addition, the background color (for areas where no opaque pixel is drawn) can be selected arbitrarily from the color palette or from the shade LUT.
In two bit per pixel modes, palettes 0 - 3 and 8 - 11 are ''opaque'' (color zero is opaque, four distinct colors are usable), while palettes 4 - 7 and 12 - 15 are ''translucent'' (color zero is transparent, three distinct colors are usable). This applies in both mono and color modes.
In four bit per pixel modes, every palette is ''translucent'' (color zero is transparent, fifteen distinct colors are usable). The first entry of each palette can be used only for the background color.
Palettes 8-15 are also referred to as sprite palettes 0-7.
=== Screens ===
The WonderSwan can display up to two distinct 32x32 screens. These consist of 1024 two-byte cells:
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
vhbp pppt tttt tttt
|||| |||| |||| ||||
|||| |||+--++++-++++- Tile index (0-511)
|||+-+++------------- Palette (0-15)
||+------------------ Tile bank (0-1) - color only
|+------------------- Horizontal flip
+-------------------- Vertical flip
</pre>
=== Sprites ===
The WonderSwan can display up to 128 sprites at once. These are stored in a sprite table in RAM, which consists of up to 128 four-byte entries:
<pre>
(Byte 1) (Byte 0)
15 bit 8 7 bit 0
---- ---- ---- ----
vhPi pppt tttt tttt
|||| |||| |||| ||||
|||| |||+--++++-++++- Tile index (0-511) - only bank 0
|||| +++------------- Palette (0-7) - mapped to screen palettes 8-15
|||+----------------- Window location - 0 = inside, 1 = outside
||+------------------ Priority - 0 = behind Screen 2, 1 = in front of Screen 2
|+------------------- Horizontal flip
+-------------------- Vertical flip
(Byte 2)
7 bit 0
---- ----
yyyy yyyy
|||| ||||
++++-++++- Y coordinate
(Byte 3)
7 bit 0
---- ----
xxxx xxxx
|||| ||||
++++-++++- X coordinate
</pre>
For each row, the first 32 sprites for that row will be drawn - including sprites obscured by windows or outside of the visible range; only the Y coordinate determines this. The earlier among those sprites will be on top of the later ones.
=== Visibility priority ===
For display components, the visibility priority is as follows:
* Sprite 0, high priority
* Sprite 127, high priority
* Screen 2
* Sprite 0, low priority
* Sprite 127, low priority
* Screen 1
* Background color
=== Windows ===
Screen 2 and the sprite layer can optionally be restricted to a specific window.
In addition, one can control if a given element is rendered inside or outside that window. For Screen 2, this is controlled globally; for sprites, this is controlled per-sprite.
=== Icons ===
Finally, the WonderSwan features six LCD segment icons which are displayed to the right<sup>(color)</sup> or below<sup>(mono)</sup> the main display. These are, as follows:
* Aux 3 - large circle,
* Aux 2 - medium circle,
* Aux 1 - small circle,
* Horizontal orientation,
* Vertical orientation,
* Sleep.
== Interrupts ==
The display circuit generates two interrupts of its own:
* Display Interrupt Line Match - when <code>Display Current Line</code> == <code>Display Interrupt Line</code>, at the beginning of said line.
* Display Vertical Blank - when <code>Display Current Line</code> == <code>144</code>, at the beginning of said line.
It also provides a timing source for the two Horizontal and Vertical Blank [[Timers]], which provide their own respective interrupts.
== I/O ports ==
{{Anchor|Display Control}}
=== Display Control ($00) ===
<pre>
7 bit 0
---- ----
..ow Ws21
|| ||||
|| |||+- Enable Screen 1 layer
|| ||+-- Enable Screen 2 layer
|| |+--- Enable Sprite layer
|| +---- Enable Sprite window
|+------ Enable Screen 2 window
+------- Screen 2 window location:
0 = inside, 1 = outside
</pre>
{{Anchor|Display Background}}
=== Display Background Color ($01) ===
<pre>
(mono) (color)
7 bit 0 7 bit 0
---- ---- ---- ----
.... .sss pppp iiii
||| |||| ||||
+++- Value |||| ++++- Index in palette (0-15)
(0-7) ++++------ Color palette (0-15)
</pre>
{{Anchor|Display Current Line}}
=== Display Current Line ($02 read) ===
The current line being drawn by the display.
Note that lines are sent to the display with a one-line delay. This matters for color palette or shade LUT manipulation; changing these values when <code>current line == 1</code> will actually affect line 0.
{{Anchor|Display Interrupt Line}}
=== Display Interrupt Line ($03) ===
The line to emit an interrupt on.
{{Anchor|Sprite Table Address}}
=== Sprite Table Address ($04) ===
<pre>
7 bit 0
---- ----
..Aa aaaa
|| ||||
|+-++++- Address (bits 9-13)
+------- Address (bit 14) - color only
</pre>
{{Anchor|Sprite Table First}}
=== Sprite Table First ($05) ===
<pre>
7 bit 0
---- ----
.iii iiii
||| ||||
+++-++++- Index of first sprite entry to draw (0-127)
</pre>
{{Anchor|Sprite Table Count}}
=== Sprite Table Count ($06) ===
<pre>
7 bit 0
---- ----
cccc cccc
|||| ||||
++++-++++- Count of sprite entries to draw (1-128)
</pre>
{{Anchor|Screen Address}}
=== Screen Address ($07) ===
<pre>
7 bit 0
---- ----
2222 1111
|||| ||||
|||| |+++- Screen 1 address (bits 11-13)
|||| +---- Screen 1 address (bit 14) - color only
|+++------ Screen 2 address (bits 11-13)
+--------- Screen 2 address (bit 14) - color only
</pre>
{{Anchor|Screen 2 Window}}
=== Screen 2 Window Left ($08) ===
=== Screen 2 Window Top ($09) ===
=== Screen 2 Window Right ($0A) ===
=== Screen 2 Window Bottom ($0B) ===
{{Anchor|Sprite Window}}
=== Sprite Window Left ($0C) ===
=== Sprite Window Top ($0D) ===
=== Sprite Window Right ($0E) ===
=== Sprite Window Bottom ($0F) ===
{{Anchor|Screen Scroll}}
=== Screen 1 Scroll X ($10) ===
=== Screen 1 Scroll Y ($11) ===
=== Screen 2 Scroll X ($12) ===
=== Screen 2 Scroll Y ($13) ===
{{Anchor|LCD Control}}
=== LCD Control ($14) ===
<pre>
7 bit 0
---- ----
.... ..Ce
||
|+- LCD Enable: 0 = sleep, 1 = enabled
+-- Contrast (WSC): 0 = low, 1 = high
</pre>
{{Anchor|LCD Icon Control}}
=== LCD Icon Control ($15) ===
<pre>
7 bit 0
---- ----
..32 1hvs
|| ||||
|| |||+- Sleep
|| ||+-- Vertical orientation
|| |+--- Horizontal orientation
|| +---- Aux 1
|+------ Aux 2
+------- Aux 3
</pre>
{{Anchor|LCD Mono Shade LUT}}
=== LCD Mono Shade LUT ($1C-$1F) ===
<pre>
$1C $1D $1E $1F
7 bit 0 7 bit 0 7 bit 0 7 bit 0
---- ---- ---- ---- ---- ---- ---- ----
1111 0000 3333 2222 5555 4444 7777 6666
</pre>
{{Anchor|LCD Mono Palette}}
=== LCD Mono Palette 0..15 ($20, $21 .. $3E, $3F) ===
The monochrome palette is laid out as sixteen words:
<pre>
N+1 N
15 bit 8 7 bit 0
---- ---- ---- ----
.333 .222 .111 .000
||| ||| ||| |||
||| ||| ||| +++- Shade LUT index for color 0
||| ||| +++------ Shade LUT index for color 1
||| +++------------ Shade LUT index for color 2
+++----------------- Shade LUT index for color 3
</pre>
== Internal I/O ports ==
These I/O ports are said to be internal and not intended for use by commercial games.
{{Anchor|LCD Final Line}}
=== LCD Final Line ($16) ===
The final line preceding line counter restart and the beginning of active display. By default, this is set to 158, which equals 159 total lines per frame.
It is said setting this register to an odd value on SwanCrystal has an adverse effect to the LCD panel<ref>[http://daifukkat.su/docs/wsman/#REG_LCD_VTOTAL REG_LCD_VTOTAL - WSMan]</ref>, but the exact mechanism is unknown.
{{Anchor|LCD Back Porch Line}}
=== LCD Back Porch Line ($17, WSC only) ===
This port is available on the WonderSwan Color only - not the SwanCrystal!
The final line preceding the vertical back porch; by default, this should be set to 155.
The vertical back porch of the LCD is assumed to be 4 lines by some hardware, including IPS mods, as well as the official "TV Swan" capture device. Given that the first visible line is sent to the LCD on the display's line 1, this should be generally set to <code>LCD Final Line - 3</code>.
Conversely, it is said moving this value closer to vertical blank improves LCD visibility<ref>[http://daifukkat.su/docs/wsman/#REG_LCD_VSYNC REG_LCD_VSYNC - WSMan]</ref>, but the exact mechanism is unknown.
{{Anchor|LCD Status}}
=== LCD Status ($1A) ===
<pre>
7 bit 0
---- ----
...v vv.s
| || |
| || +- LCD sleep: 0 = no, 1 = sleep
| ||
| || Volume segments:
| |+--- Volume B (medium, high)
| +---- Volume A (low, high)
+------ Speaker
</pre>
=== TFT LCD Configuration ($70, $71, $72, $73, $74, $75, $76, $77 SwanCrystal only) ===
These eight bytes are read from internal EEPROM and configure unknown aspects of the console's TFT LCD panel.
They are only writable while the [[Boot ROM]] is unlocked - locking has the side effect of making them read-only.
== Notes ==
<references />
704d2dfb34790d97ae068ee8ff03e8e6d9743044
298
297
2024-07-12T19:25:49Z
Asie
351
/* Tiles */ rewrite the whole thing to be more clear
wikitext
text/x-wiki
The WonderSwan's display functionality generally consists of:
* a 224x144 display clocked at ~75.47 Hz by default, capable of displaying:
** up to sixteen distinct shades of gray
** 12-bit RGB444 color<sup>(color)</sup>
* two 32x32 background layers ("screens"), capable of displaying up to 512 (1024<sup>(color)</sup>) distinct tiles,
* a sprite layer, capable of displaying up to 128 8x8 sprites (up to 32 per line),
* six LCD icons to the bottom or right of the display, usable as additional indicators.
== Components ==
=== Tiles ===
The WonderSwan can display up to 512 distinct tiles at a time, with two bits of palette index information for every pixel.
The WonderSwan Color expands this to 1024 distinct tiles for background (with 512 remaining the limit for sprites), while also introducing modes with four bits of palette index information for every pixel.
==== 2 bits per pixel, planar ====
The tiles are stored in an interleaved planar format, with two bits total for every pixel. Odd bytes store the first plane (bit 0 of each pixel), while even bytes store the second plane (bit 1 of each pixel).
<pre>
tile data (16 bytes)
01 7C 01 FC 00 C0 18 D8 18 D8 00 C0 00 00 C0 00
||
\/
plane 0 plane 1
7 bit 0 7 bit 0 full tile
---- ---- ---- ----
.... ...1 = 01 .222 22.. = 7C .22222.1
.... ...1 = 01 2222 22.. = FC 222222.1
.... .... = 00 22.. .... = C0 22......
...1 1... = 18 22.2 2... = D8 --\ 22.33...
...1 1... = 18 22.2 2... = D8 --/ 22.33...
.... .... = 00 22.. .... = C0 22......
.... .... = 00 .... .... = 00 ........
11.. .... = C0 .... .... = 00 11......
</pre>
This matches the format used by the Game Boy.
==== 4 bits per pixel, planar ====
This mode is stored in a manner similar to the 2 bits per pixel mode, but with an additional two planes for bit 2 and bit 3 of each pixel's palette index, expanding the tile data to 32 bytes.
<pre>
tile data (32 bytes)
54 32 01 00 54 32 F1 00 54 32 01 F0 54 32 F1 F0 04 02 01 00 F8 04 02 01 00 F8 04 02 00 00 F8 04
||
\/
plane 0 plane 1 plane 2 plane 3
7 bit 0 7 bit 0 7 bit 0 7 bit 0 full tile
---- ---- ---- ---- ---- ---- ---- ----
.1.1 .1.. = 54 ..22 ..2. = 32 .... ...4 = 01 .... .... = 00 .123.124
.1.1 .1.. = 54 ..22 ..2. = 32 4444 ...4 = F1 .... .... = 00 4567.124
.1.1 .1.. = 54 ..22 ..2. = 32 .... ...4 = 01 8888 .... = F0 89AB.124
.1.1 .1.. = 54 ..22 ..2. = 32 4444 ...4 = F1 8888 .... = F0 --\ CDEF.124
.... .1.. = 04 .... ..2. = 02 .... ...4 = 01 .... .... = 00 --/ .....124
1111 1... = F8 .... .2.. = 04 .... ..4. = 02 .... ...8 = 01 11111248
.... .... = 00 2222 2... = F8 .... .4.. = 04 .... ..8. = 02 2222248.
.... .... = 00 .... .... = 00 4444 4... = F8 .... .8.. = 04 444448..
</pre>
This format matches the one used by the Sega Master System and Game Gear family of consoles.
==== 4 bits per pixel, packed ====
Unlike the previous two formats, in the packed format each byte stores the complete palette index of two pixels - the high four bits store the left pixel, while the low four bits store the right pixel. Four such bytes make up a row of eight pixels from left to right.
<pre>
tile data (32 bytes)
01 23 01 24 45 67 01 24 89 AB 01 24 CD EF 01 24 00 00 01 24 11 11 12 48 22 22 24 80 44 44 48 00
||
\/
byte 0 1 2 3
bits 7-4 3-0 7-4 3-0 7-4 3-0 7-4 3-0
pixel 0 1 2 3 4 5 6 7
--- --- --- --- --- --- --- ---
. 1 = 01 2 3 = 23 . 1 = 01 2 4 = 24 .123.124
4 5 = 45 6 7 = 67 . 1 = 01 2 4 = 24 4567.124
8 9 = 89 A B = AB . 1 = 01 2 4 = 24 89AB.124
C D = CD E F = EF . 1 = 01 2 4 = 24 --\ CDEF.124
. . = 00 . . = 00 . 1 = 01 2 4 = 24 --/ .....124
1 1 = 11 1 1 = 11 1 2 = 12 4 8 = 48 11111248
2 2 = 22 2 2 = 22 2 4 = 24 8 . = 80 2222248.
4 4 = 44 4 4 = 44 4 8 = 48 . . = 00 444448..
</pre>
This format matches the one used by the Mega Drive console.
=== Colors, Shades ===
The "mono" WonderSwan uses eight value indices, which are converted by a global look-up table to eight of the sixteen shades the LCD can display:
<pre>
Palette Global shade LUT
1 ===========> 2 ==========================> 5
^ (0, 2, 4, 6) ^ (1, 3, 5, 7, 9, 11, 13, 15) ^
| | |
Tile pixel Value Displayed shade
</pre>
In "color" mode, the WonderSwan instead loads RGB444 color values from a table in the console's internal RAM:
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
.... rrrr gggg bbbb
|||| |||| ||||
|||| |||| ++++- Blue (0-15)
|||| ++++------ Green (0-15)
++++------------ Red (0-15)
</pre>
No further processing or look-up tables are applied.
=== Palettes ===
The WonderSwan provides sixteen different palettes. All sixteen can be used for screens only, while the latter eight can be used for screens and sprites. In addition, the background color (for areas where no opaque pixel is drawn) can be selected arbitrarily from the color palette or from the shade LUT.
In two bit per pixel modes, palettes 0 - 3 and 8 - 11 are ''opaque'' (color zero is opaque, four distinct colors are usable), while palettes 4 - 7 and 12 - 15 are ''translucent'' (color zero is transparent, three distinct colors are usable). This applies in both mono and color modes.
In four bit per pixel modes, every palette is ''translucent'' (color zero is transparent, fifteen distinct colors are usable). The first entry of each palette can be used only for the background color.
Palettes 8-15 are also referred to as sprite palettes 0-7.
=== Screens ===
The WonderSwan can display up to two distinct 32x32 screens. These consist of 1024 two-byte cells:
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
vhbp pppt tttt tttt
|||| |||| |||| ||||
|||| |||+--++++-++++- Tile index (0-511)
|||+-+++------------- Palette (0-15)
||+------------------ Tile bank (0-1) - color only
|+------------------- Horizontal flip
+-------------------- Vertical flip
</pre>
=== Sprites ===
The WonderSwan can display up to 128 sprites at once. These are stored in a sprite table in RAM, which consists of up to 128 four-byte entries:
<pre>
(Byte 1) (Byte 0)
15 bit 8 7 bit 0
---- ---- ---- ----
vhPi pppt tttt tttt
|||| |||| |||| ||||
|||| |||+--++++-++++- Tile index (0-511) - only bank 0
|||| +++------------- Palette (0-7) - mapped to screen palettes 8-15
|||+----------------- Window location - 0 = inside, 1 = outside
||+------------------ Priority - 0 = behind Screen 2, 1 = in front of Screen 2
|+------------------- Horizontal flip
+-------------------- Vertical flip
(Byte 2)
7 bit 0
---- ----
yyyy yyyy
|||| ||||
++++-++++- Y coordinate
(Byte 3)
7 bit 0
---- ----
xxxx xxxx
|||| ||||
++++-++++- X coordinate
</pre>
For each row, the first 32 sprites for that row will be drawn - including sprites obscured by windows or outside of the visible range; only the Y coordinate determines this. The earlier among those sprites will be on top of the later ones.
=== Visibility priority ===
For display components, the visibility priority is as follows:
* Sprite 0, high priority
* Sprite 127, high priority
* Screen 2
* Sprite 0, low priority
* Sprite 127, low priority
* Screen 1
* Background color
=== Windows ===
Screen 2 and the sprite layer can optionally be restricted to a specific window.
In addition, one can control if a given element is rendered inside or outside that window. For Screen 2, this is controlled globally; for sprites, this is controlled per-sprite.
=== Icons ===
Finally, the WonderSwan features six LCD segment icons which are displayed to the right<sup>(color)</sup> or below<sup>(mono)</sup> the main display. These are, as follows:
* Aux 3 - large circle,
* Aux 2 - medium circle,
* Aux 1 - small circle,
* Horizontal orientation,
* Vertical orientation,
* Sleep.
== Interrupts ==
The display circuit generates two interrupts of its own:
* Display Interrupt Line Match - when <code>Display Current Line</code> == <code>Display Interrupt Line</code>, at the beginning of said line.
* Display Vertical Blank - when <code>Display Current Line</code> == <code>144</code>, at the beginning of said line.
It also provides a timing source for the two Horizontal and Vertical Blank [[Timers]], which provide their own respective interrupts.
== I/O ports ==
{{Anchor|Display Control}}
=== Display Control ($00) ===
<pre>
7 bit 0
---- ----
..ow Ws21
|| ||||
|| |||+- Enable Screen 1 layer
|| ||+-- Enable Screen 2 layer
|| |+--- Enable Sprite layer
|| +---- Enable Sprite window
|+------ Enable Screen 2 window
+------- Screen 2 window location:
0 = inside, 1 = outside
</pre>
{{Anchor|Display Background}}
=== Display Background Color ($01) ===
<pre>
(mono) (color)
7 bit 0 7 bit 0
---- ---- ---- ----
.... .sss pppp iiii
||| |||| ||||
+++- Value |||| ++++- Index in palette (0-15)
(0-7) ++++------ Color palette (0-15)
</pre>
{{Anchor|Display Current Line}}
=== Display Current Line ($02 read) ===
The current line being drawn by the display.
Note that lines are sent to the display with a one-line delay. This matters for color palette or shade LUT manipulation; changing these values when <code>current line == 1</code> will actually affect line 0.
{{Anchor|Display Interrupt Line}}
=== Display Interrupt Line ($03) ===
The line to emit an interrupt on.
{{Anchor|Sprite Table Address}}
=== Sprite Table Address ($04) ===
<pre>
7 bit 0
---- ----
..Aa aaaa
|| ||||
|+-++++- Address (bits 9-13)
+------- Address (bit 14) - color only
</pre>
{{Anchor|Sprite Table First}}
=== Sprite Table First ($05) ===
<pre>
7 bit 0
---- ----
.iii iiii
||| ||||
+++-++++- Index of first sprite entry to draw (0-127)
</pre>
{{Anchor|Sprite Table Count}}
=== Sprite Table Count ($06) ===
<pre>
7 bit 0
---- ----
cccc cccc
|||| ||||
++++-++++- Count of sprite entries to draw (1-128)
</pre>
{{Anchor|Screen Address}}
=== Screen Address ($07) ===
<pre>
7 bit 0
---- ----
2222 1111
|||| ||||
|||| |+++- Screen 1 address (bits 11-13)
|||| +---- Screen 1 address (bit 14) - color only
|+++------ Screen 2 address (bits 11-13)
+--------- Screen 2 address (bit 14) - color only
</pre>
{{Anchor|Screen 2 Window}}
=== Screen 2 Window Left ($08) ===
=== Screen 2 Window Top ($09) ===
=== Screen 2 Window Right ($0A) ===
=== Screen 2 Window Bottom ($0B) ===
{{Anchor|Sprite Window}}
=== Sprite Window Left ($0C) ===
=== Sprite Window Top ($0D) ===
=== Sprite Window Right ($0E) ===
=== Sprite Window Bottom ($0F) ===
{{Anchor|Screen Scroll}}
=== Screen 1 Scroll X ($10) ===
=== Screen 1 Scroll Y ($11) ===
=== Screen 2 Scroll X ($12) ===
=== Screen 2 Scroll Y ($13) ===
{{Anchor|LCD Control}}
=== LCD Control ($14) ===
<pre>
7 bit 0
---- ----
.... ..Ce
||
|+- LCD Enable: 0 = sleep, 1 = enabled
+-- Contrast (WSC): 0 = low, 1 = high
</pre>
{{Anchor|LCD Icon Control}}
=== LCD Icon Control ($15) ===
<pre>
7 bit 0
---- ----
..32 1hvs
|| ||||
|| |||+- Sleep
|| ||+-- Vertical orientation
|| |+--- Horizontal orientation
|| +---- Aux 1
|+------ Aux 2
+------- Aux 3
</pre>
{{Anchor|LCD Mono Shade LUT}}
=== LCD Mono Shade LUT ($1C-$1F) ===
<pre>
$1C $1D $1E $1F
7 bit 0 7 bit 0 7 bit 0 7 bit 0
---- ---- ---- ---- ---- ---- ---- ----
1111 0000 3333 2222 5555 4444 7777 6666
</pre>
{{Anchor|LCD Mono Palette}}
=== LCD Mono Palette 0..15 ($20, $21 .. $3E, $3F) ===
The monochrome palette is laid out as sixteen words:
<pre>
N+1 N
15 bit 8 7 bit 0
---- ---- ---- ----
.333 .222 .111 .000
||| ||| ||| |||
||| ||| ||| +++- Shade LUT index for color 0
||| ||| +++------ Shade LUT index for color 1
||| +++------------ Shade LUT index for color 2
+++----------------- Shade LUT index for color 3
</pre>
== Internal I/O ports ==
These I/O ports are said to be internal and not intended for use by commercial games.
{{Anchor|LCD Final Line}}
=== LCD Final Line ($16) ===
The final line preceding line counter restart and the beginning of active display. By default, this is set to 158, which equals 159 total lines per frame.
It is said setting this register to an odd value on SwanCrystal has an adverse effect to the LCD panel<ref>[http://daifukkat.su/docs/wsman/#REG_LCD_VTOTAL REG_LCD_VTOTAL - WSMan]</ref>, but the exact mechanism is unknown.
{{Anchor|LCD Back Porch Line}}
=== LCD Back Porch Line ($17, WSC only) ===
This port is available on the WonderSwan Color only - not the SwanCrystal!
The final line preceding the vertical back porch; by default, this should be set to 155.
The vertical back porch of the LCD is assumed to be 4 lines by some hardware, including IPS mods, as well as the official "TV Swan" capture device. Given that the first visible line is sent to the LCD on the display's line 1, this should be generally set to <code>LCD Final Line - 3</code>.
Conversely, it is said moving this value closer to vertical blank improves LCD visibility<ref>[http://daifukkat.su/docs/wsman/#REG_LCD_VSYNC REG_LCD_VSYNC - WSMan]</ref>, but the exact mechanism is unknown.
{{Anchor|LCD Status}}
=== LCD Status ($1A) ===
<pre>
7 bit 0
---- ----
...v vv.s
| || |
| || +- LCD sleep: 0 = no, 1 = sleep
| ||
| || Volume segments:
| |+--- Volume B (medium, high)
| +---- Volume A (low, high)
+------ Speaker
</pre>
=== TFT LCD Configuration ($70, $71, $72, $73, $74, $75, $76, $77 SwanCrystal only) ===
These eight bytes are read from internal EEPROM and configure unknown aspects of the console's TFT LCD panel.
They are only writable while the [[Boot ROM]] is unlocked - locking has the side effect of making them read-only.
== Notes ==
<references />
9690497871a4cbee439f89ae7b116726a6384a12
299
298
2024-07-12T19:37:12Z
Asie
351
/* Components */ rewrite the palette section too
wikitext
text/x-wiki
The WonderSwan's display functionality generally consists of:
* a 224x144 display clocked at ~75.47 Hz by default, capable of displaying:
** up to sixteen distinct shades of gray
** 12-bit RGB444 color<sup>(color)</sup>
* two 32x32 background layers ("screens"), capable of displaying up to 512 (1024<sup>(color)</sup>) distinct tiles,
* a sprite layer, capable of displaying up to 128 8x8 sprites (up to 32 per line),
* six LCD icons to the bottom or right of the display, usable as additional indicators.
== Components ==
=== Tiles ===
The WonderSwan can display up to 512 distinct tiles at a time, with two bits of palette index information for every pixel.
The WonderSwan Color expands this to 1024 distinct tiles for background (with 512 remaining the limit for sprites), while also introducing modes with four bits of palette index information for every pixel.
==== 2 bits per pixel, planar ====
The tiles are stored in an interleaved planar format, with two bits total for every pixel. Odd bytes store the first plane (bit 0 of each pixel), while even bytes store the second plane (bit 1 of each pixel).
<pre>
tile data (16 bytes)
01 7C 01 FC 00 C0 18 D8 18 D8 00 C0 00 00 C0 00
||
\/
plane 0 plane 1
7 bit 0 7 bit 0 full tile
---- ---- ---- ----
.... ...1 = 01 .222 22.. = 7C .22222.1
.... ...1 = 01 2222 22.. = FC 222222.1
.... .... = 00 22.. .... = C0 22......
...1 1... = 18 22.2 2... = D8 --\ 22.33...
...1 1... = 18 22.2 2... = D8 --/ 22.33...
.... .... = 00 22.. .... = C0 22......
.... .... = 00 .... .... = 00 ........
11.. .... = C0 .... .... = 00 11......
</pre>
This matches the format used by the Game Boy.
==== 4 bits per pixel, planar ====
This mode is stored in a manner similar to the 2 bits per pixel mode, but with an additional two planes for bit 2 and bit 3 of each pixel's palette index, expanding the tile data to 32 bytes.
<pre>
tile data (32 bytes)
54 32 01 00 54 32 F1 00 54 32 01 F0 54 32 F1 F0 04 02 01 00 F8 04 02 01 00 F8 04 02 00 00 F8 04
||
\/
plane 0 plane 1 plane 2 plane 3
7 bit 0 7 bit 0 7 bit 0 7 bit 0 full tile
---- ---- ---- ---- ---- ---- ---- ----
.1.1 .1.. = 54 ..22 ..2. = 32 .... ...4 = 01 .... .... = 00 .123.124
.1.1 .1.. = 54 ..22 ..2. = 32 4444 ...4 = F1 .... .... = 00 4567.124
.1.1 .1.. = 54 ..22 ..2. = 32 .... ...4 = 01 8888 .... = F0 89AB.124
.1.1 .1.. = 54 ..22 ..2. = 32 4444 ...4 = F1 8888 .... = F0 --\ CDEF.124
.... .1.. = 04 .... ..2. = 02 .... ...4 = 01 .... .... = 00 --/ .....124
1111 1... = F8 .... .2.. = 04 .... ..4. = 02 .... ...8 = 01 11111248
.... .... = 00 2222 2... = F8 .... .4.. = 04 .... ..8. = 02 2222248.
.... .... = 00 .... .... = 00 4444 4... = F8 .... .8.. = 04 444448..
</pre>
This format matches the one used by the Sega Master System and Game Gear family of consoles.
==== 4 bits per pixel, packed ====
Unlike the previous two formats, in the packed format each byte stores the complete palette index of two pixels - the high four bits store the left pixel, while the low four bits store the right pixel. Four such bytes make up a row of eight pixels from left to right.
<pre>
tile data (32 bytes)
01 23 01 24 45 67 01 24 89 AB 01 24 CD EF 01 24 00 00 01 24 11 11 12 48 22 22 24 80 44 44 48 00
||
\/
byte 0 1 2 3
bits 7-4 3-0 7-4 3-0 7-4 3-0 7-4 3-0
pixel 0 1 2 3 4 5 6 7
--- --- --- --- --- --- --- ---
. 1 = 01 2 3 = 23 . 1 = 01 2 4 = 24 .123.124
4 5 = 45 6 7 = 67 . 1 = 01 2 4 = 24 4567.124
8 9 = 89 A B = AB . 1 = 01 2 4 = 24 89AB.124
C D = CD E F = EF . 1 = 01 2 4 = 24 --\ CDEF.124
. . = 00 . . = 00 . 1 = 01 2 4 = 24 --/ .....124
1 1 = 11 1 1 = 11 1 2 = 12 4 8 = 48 11111248
2 2 = 22 2 2 = 22 2 4 = 24 8 . = 80 2222248.
4 4 = 44 4 4 = 44 4 8 = 48 . . = 00 444448..
</pre>
This format matches the one used by the Mega Drive console.
=== Palettes ===
The WonderSwan provides sixteen different palettes. Palettes 0-7 can be used for the two screens only, while palettes 8-15 can be used for both screens and sprites.
==== Mono ====
In ''mono'' modes, palettes are stored in I/O ports 0x20 through 0x3F. Each palette contains four three-bit entries, which are pointers into a global, four-bit shade lookup table:
<pre>
Palette Global shade LUT
1 ===========> 2 ==========================> 5
^ (0, 2, 4, 6) ^ (1, 3, 5, 7, 9, 11, 13, 15) ^
| | |
Palette index Value Displayed shade
</pre>
The shade value corresponds to the darkness of the pixel: shade 0 is the brightest, while shade 15 is the darkest.
==== Color ====
In ''color'' modes, palettes are stored as 16-bit words in memory addresses 0xFE00 through 0xFFFF, without additional lookup tables:
<pre>
Address
15 bit 8 7 bit 0
---- ---- ---- ----
1111 111p pppi iii.
| |||| |||
| |||+-+++- Index in palette (0-15)
+--+++------ Palette number (0-15)
Data
15 bit 8 7 bit 0
---- ---- ---- ----
.... rrrr gggg bbbb
|||| |||| ||||
|||| |||| ++++- Blue (0-15)
|||| ++++------ Green (0-15)
++++------------ Red (0-15)
</pre>
In 2 bits per pixel color modes, palette entries 4 through 15 are not used.
==== Transparency ====
In two bit per pixel modes:
- Palettes 0-3 and 8-11 are ''opaque''. For these, index zero is treated as opaque.
- Palettes 4-7 and 12-15 are ''translucent''. For these, index zero is treated as transparent. This means that the color/shade value set to it is ignored, and only three distinct colors/shades can be used for tiles.
In four bit per pixel modes, all palettes are ''translucent''. Index zero is always treated as transparent, and fifteen different colors/shades can be used for tiles.
=== Background color ===
The background color is displayed if no ''opaque'' pixel from screens or sprites is drawn. This color is set in I/O port ''0x01'':
- In mono modes, it is set to an entry in the shade lookup table (0-7),
- In color modes, it is set to an entry in the color palette (0-255). Note that this allows you to use the first color (color zero) of any palette, which is normally ignored and assumed to be ''transparent''.
=== Screens ===
The WonderSwan can display up to two distinct 32x32 screens. These consist of 1024 two-byte cells:
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
vhbp pppt tttt tttt
|||| |||| |||| ||||
|||| |||+--++++-++++- Tile index (0-511)
|||+-+++------------- Palette (0-15)
||+------------------ Tile bank (0-1) - color only
|+------------------- Horizontal flip
+-------------------- Vertical flip
</pre>
=== Sprites ===
The WonderSwan can display up to 128 sprites at once. These are stored in a sprite table in RAM, which consists of up to 128 four-byte entries:
<pre>
(Byte 1) (Byte 0)
15 bit 8 7 bit 0
---- ---- ---- ----
vhPi pppt tttt tttt
|||| |||| |||| ||||
|||| |||+--++++-++++- Tile index (0-511) - only bank 0
|||| +++------------- Palette (0-7) - mapped to screen palettes 8-15
|||+----------------- Window location - 0 = inside, 1 = outside
||+------------------ Priority - 0 = behind Screen 2, 1 = in front of Screen 2
|+------------------- Horizontal flip
+-------------------- Vertical flip
(Byte 2)
7 bit 0
---- ----
yyyy yyyy
|||| ||||
++++-++++- Y coordinate
(Byte 3)
7 bit 0
---- ----
xxxx xxxx
|||| ||||
++++-++++- X coordinate
</pre>
For each row, the first 32 sprites for that row will be drawn - including sprites obscured by windows or outside of the visible range; only the Y coordinate determines this. The earlier among those sprites will be on top of the later ones.
=== Visibility priority ===
For display components, the visibility priority is as follows:
* Sprite 0, high priority
* Sprite 127, high priority
* Screen 2
* Sprite 0, low priority
* Sprite 127, low priority
* Screen 1
* Background color
=== Windows ===
Screen 2 and the sprite layer can optionally be restricted to a specific window.
In addition, one can control if a given element is rendered inside or outside that window. For Screen 2, this is controlled globally; for sprites, this is controlled per-sprite.
=== Icons ===
The WonderSwan features six LCD segment icons which are displayed to the right<sup>(color)</sup> or below<sup>(mono)</sup> the main display. These are, as follows:
* Aux 3 - large circle,
* Aux 2 - medium circle,
* Aux 1 - small circle,
* Horizontal orientation,
* Vertical orientation,
* Sleep.
== Interrupts ==
The display circuit generates two interrupts of its own:
* Display Interrupt Line Match - when <code>Display Current Line</code> == <code>Display Interrupt Line</code>, at the beginning of said line.
* Display Vertical Blank - when <code>Display Current Line</code> == <code>144</code>, at the beginning of said line.
It also provides a timing source for the two Horizontal and Vertical Blank [[Timers]], which provide their own respective interrupts.
== I/O ports ==
{{Anchor|Display Control}}
=== Display Control ($00) ===
<pre>
7 bit 0
---- ----
..ow Ws21
|| ||||
|| |||+- Enable Screen 1 layer
|| ||+-- Enable Screen 2 layer
|| |+--- Enable Sprite layer
|| +---- Enable Sprite window
|+------ Enable Screen 2 window
+------- Screen 2 window location:
0 = inside, 1 = outside
</pre>
{{Anchor|Display Background}}
=== Display Background Color ($01) ===
<pre>
(mono) (color)
7 bit 0 7 bit 0
---- ---- ---- ----
.... .sss pppp iiii
||| |||| ||||
+++- Value |||| ++++- Index in palette (0-15)
(0-7) ++++------ Color palette (0-15)
</pre>
{{Anchor|Display Current Line}}
=== Display Current Line ($02 read) ===
The current line being drawn by the display.
Note that lines are sent to the display with a one-line delay. This matters for color palette or shade LUT manipulation; changing these values when <code>current line == 1</code> will actually affect line 0.
{{Anchor|Display Interrupt Line}}
=== Display Interrupt Line ($03) ===
The line to emit an interrupt on.
{{Anchor|Sprite Table Address}}
=== Sprite Table Address ($04) ===
<pre>
7 bit 0
---- ----
..Aa aaaa
|| ||||
|+-++++- Address (bits 9-13)
+------- Address (bit 14) - color only
</pre>
{{Anchor|Sprite Table First}}
=== Sprite Table First ($05) ===
<pre>
7 bit 0
---- ----
.iii iiii
||| ||||
+++-++++- Index of first sprite entry to draw (0-127)
</pre>
{{Anchor|Sprite Table Count}}
=== Sprite Table Count ($06) ===
<pre>
7 bit 0
---- ----
cccc cccc
|||| ||||
++++-++++- Count of sprite entries to draw (1-128)
</pre>
{{Anchor|Screen Address}}
=== Screen Address ($07) ===
<pre>
7 bit 0
---- ----
2222 1111
|||| ||||
|||| |+++- Screen 1 address (bits 11-13)
|||| +---- Screen 1 address (bit 14) - color only
|+++------ Screen 2 address (bits 11-13)
+--------- Screen 2 address (bit 14) - color only
</pre>
{{Anchor|Screen 2 Window}}
=== Screen 2 Window Left ($08) ===
=== Screen 2 Window Top ($09) ===
=== Screen 2 Window Right ($0A) ===
=== Screen 2 Window Bottom ($0B) ===
{{Anchor|Sprite Window}}
=== Sprite Window Left ($0C) ===
=== Sprite Window Top ($0D) ===
=== Sprite Window Right ($0E) ===
=== Sprite Window Bottom ($0F) ===
{{Anchor|Screen Scroll}}
=== Screen 1 Scroll X ($10) ===
=== Screen 1 Scroll Y ($11) ===
=== Screen 2 Scroll X ($12) ===
=== Screen 2 Scroll Y ($13) ===
{{Anchor|LCD Control}}
=== LCD Control ($14) ===
<pre>
7 bit 0
---- ----
.... ..Ce
||
|+- LCD Enable: 0 = sleep, 1 = enabled
+-- Contrast (WSC): 0 = low, 1 = high
</pre>
{{Anchor|LCD Icon Control}}
=== LCD Icon Control ($15) ===
<pre>
7 bit 0
---- ----
..32 1hvs
|| ||||
|| |||+- Sleep
|| ||+-- Vertical orientation
|| |+--- Horizontal orientation
|| +---- Aux 1
|+------ Aux 2
+------- Aux 3
</pre>
{{Anchor|LCD Mono Shade LUT}}
=== LCD Mono Shade LUT ($1C-$1F) ===
<pre>
$1C $1D $1E $1F
7 bit 0 7 bit 0 7 bit 0 7 bit 0
---- ---- ---- ---- ---- ---- ---- ----
1111 0000 3333 2222 5555 4444 7777 6666
</pre>
{{Anchor|LCD Mono Palette}}
=== LCD Mono Palette 0..15 ($20, $21 .. $3E, $3F) ===
The monochrome palette is laid out as sixteen words:
<pre>
N+1 N
15 bit 8 7 bit 0
---- ---- ---- ----
.333 .222 .111 .000
||| ||| ||| |||
||| ||| ||| +++- Shade LUT index for color 0
||| ||| +++------ Shade LUT index for color 1
||| +++------------ Shade LUT index for color 2
+++----------------- Shade LUT index for color 3
</pre>
== Internal I/O ports ==
These I/O ports are said to be internal and not intended for use by commercial games.
{{Anchor|LCD Final Line}}
=== LCD Final Line ($16) ===
The final line preceding line counter restart and the beginning of active display. By default, this is set to 158, which equals 159 total lines per frame.
It is said setting this register to an odd value on SwanCrystal has an adverse effect to the LCD panel<ref>[http://daifukkat.su/docs/wsman/#REG_LCD_VTOTAL REG_LCD_VTOTAL - WSMan]</ref>, but the exact mechanism is unknown.
{{Anchor|LCD Back Porch Line}}
=== LCD Back Porch Line ($17, WSC only) ===
This port is available on the WonderSwan Color only - not the SwanCrystal!
The final line preceding the vertical back porch; by default, this should be set to 155.
The vertical back porch of the LCD is assumed to be 4 lines by some hardware, including IPS mods, as well as the official "TV Swan" capture device. Given that the first visible line is sent to the LCD on the display's line 1, this should be generally set to <code>LCD Final Line - 3</code>.
Conversely, it is said moving this value closer to vertical blank improves LCD visibility<ref>[http://daifukkat.su/docs/wsman/#REG_LCD_VSYNC REG_LCD_VSYNC - WSMan]</ref>, but the exact mechanism is unknown.
{{Anchor|LCD Status}}
=== LCD Status ($1A) ===
<pre>
7 bit 0
---- ----
...v vv.s
| || |
| || +- LCD sleep: 0 = no, 1 = sleep
| ||
| || Volume segments:
| |+--- Volume B (medium, high)
| +---- Volume A (low, high)
+------ Speaker
</pre>
=== TFT LCD Configuration ($70, $71, $72, $73, $74, $75, $76, $77 SwanCrystal only) ===
These eight bytes are read from internal EEPROM and configure unknown aspects of the console's TFT LCD panel.
They are only writable while the [[Boot ROM]] is unlocked - locking has the side effect of making them read-only.
== Notes ==
<references />
a87d911b2933cc02d657ffe56a0575202f1450b3
300
299
2024-07-12T19:38:43Z
Asie
351
/* Components */
wikitext
text/x-wiki
The WonderSwan's display functionality generally consists of:
* a 224x144 display clocked at ~75.47 Hz by default, capable of displaying:
** up to sixteen distinct shades of gray
** 12-bit RGB444 color<sup>(color)</sup>
* two 32x32 background layers ("screens"), capable of displaying up to 512 (1024<sup>(color)</sup>) distinct tiles,
* a sprite layer, capable of displaying up to 128 8x8 sprites (up to 32 per line),
* six LCD icons to the bottom or right of the display, usable as additional indicators.
== Components ==
=== Tiles ===
The WonderSwan can display up to 512 distinct tiles at a time, with two bits of palette index information for every pixel.
The WonderSwan Color expands this to 1024 distinct tiles for background (with 512 remaining the limit for sprites), while also introducing modes with four bits of palette index information for every pixel.
==== 2 bits per pixel, planar ====
The tiles are stored in an interleaved planar format, with two bits total for every pixel. Odd bytes store the first plane (bit 0 of each pixel), while even bytes store the second plane (bit 1 of each pixel).
<pre>
tile data (16 bytes)
01 7C 01 FC 00 C0 18 D8 18 D8 00 C0 00 00 C0 00
||
\/
plane 0 plane 1
7 bit 0 7 bit 0 full tile
---- ---- ---- ----
.... ...1 = 01 .222 22.. = 7C .22222.1
.... ...1 = 01 2222 22.. = FC 222222.1
.... .... = 00 22.. .... = C0 22......
...1 1... = 18 22.2 2... = D8 --\ 22.33...
...1 1... = 18 22.2 2... = D8 --/ 22.33...
.... .... = 00 22.. .... = C0 22......
.... .... = 00 .... .... = 00 ........
11.. .... = C0 .... .... = 00 11......
</pre>
This matches the format used by the Game Boy.
==== 4 bits per pixel, planar ====
This mode is stored in a manner similar to the 2 bits per pixel mode, but with an additional two planes for bit 2 and bit 3 of each pixel's palette index, expanding the tile data to 32 bytes.
<pre>
tile data (32 bytes)
54 32 01 00 54 32 F1 00 54 32 01 F0 54 32 F1 F0 04 02 01 00 F8 04 02 01 00 F8 04 02 00 00 F8 04
||
\/
plane 0 plane 1 plane 2 plane 3
7 bit 0 7 bit 0 7 bit 0 7 bit 0 full tile
---- ---- ---- ---- ---- ---- ---- ----
.1.1 .1.. = 54 ..22 ..2. = 32 .... ...4 = 01 .... .... = 00 .123.124
.1.1 .1.. = 54 ..22 ..2. = 32 4444 ...4 = F1 .... .... = 00 4567.124
.1.1 .1.. = 54 ..22 ..2. = 32 .... ...4 = 01 8888 .... = F0 89AB.124
.1.1 .1.. = 54 ..22 ..2. = 32 4444 ...4 = F1 8888 .... = F0 --\ CDEF.124
.... .1.. = 04 .... ..2. = 02 .... ...4 = 01 .... .... = 00 --/ .....124
1111 1... = F8 .... .2.. = 04 .... ..4. = 02 .... ...8 = 01 11111248
.... .... = 00 2222 2... = F8 .... .4.. = 04 .... ..8. = 02 2222248.
.... .... = 00 .... .... = 00 4444 4... = F8 .... .8.. = 04 444448..
</pre>
This format matches the one used by the Sega Master System and Game Gear family of consoles.
==== 4 bits per pixel, packed ====
Unlike the previous two formats, in the packed format each byte stores the complete palette index of two pixels - the high four bits store the left pixel, while the low four bits store the right pixel. Four such bytes make up a row of eight pixels from left to right.
<pre>
tile data (32 bytes)
01 23 01 24 45 67 01 24 89 AB 01 24 CD EF 01 24 00 00 01 24 11 11 12 48 22 22 24 80 44 44 48 00
||
\/
byte 0 1 2 3
bits 7-4 3-0 7-4 3-0 7-4 3-0 7-4 3-0
pixel 0 1 2 3 4 5 6 7 full tile
--- --- --- --- --- --- --- ---
. 1 = 01 2 3 = 23 . 1 = 01 2 4 = 24 .123.124 = 01 23 01 24
4 5 = 45 6 7 = 67 . 1 = 01 2 4 = 24 4567.124 = 45 67 01 24
8 9 = 89 A B = AB . 1 = 01 2 4 = 24 89AB.124 = 89 AB 01 24
C D = CD E F = EF . 1 = 01 2 4 = 24 --\ CDEF.124 = CD EF 01 24
. . = 00 . . = 00 . 1 = 01 2 4 = 24 --/ .....124 = 00 00 01 24
1 1 = 11 1 1 = 11 1 2 = 12 4 8 = 48 11111248 = 11 11 12 48
2 2 = 22 2 2 = 22 2 4 = 24 8 . = 80 2222248. = 22 22 24 80
4 4 = 44 4 4 = 44 4 8 = 48 . . = 00 444448.. = 44 44 48 00
</pre>
This format matches the one used by the Mega Drive console.
=== Palettes ===
The WonderSwan provides sixteen different palettes. Palettes 0-7 can be used for the two screens only, while palettes 8-15 can be used for both screens and sprites.
==== Mono ====
In ''mono'' modes, palettes are stored in I/O ports 0x20 through 0x3F. Each palette contains four three-bit entries, which are pointers into a global, four-bit shade lookup table:
<pre>
Palette Global shade LUT
1 ===========> 2 ==========================> 5
^ (0, 2, 4, 6) ^ (1, 3, 5, 7, 9, 11, 13, 15) ^
| | |
Palette index Value Displayed shade
</pre>
The shade value corresponds to the darkness of the pixel: shade 0 is the brightest, while shade 15 is the darkest.
==== Color ====
In ''color'' modes, palettes are stored as 16-bit words in memory addresses 0xFE00 through 0xFFFF, without additional lookup tables:
<pre>
Address
15 bit 8 7 bit 0
---- ---- ---- ----
1111 111p pppi iii.
| |||| |||
| |||+-+++- Index in palette (0-15)
+--+++------ Palette number (0-15)
Data
15 bit 8 7 bit 0
---- ---- ---- ----
.... rrrr gggg bbbb
|||| |||| ||||
|||| |||| ++++- Blue (0-15)
|||| ++++------ Green (0-15)
++++------------ Red (0-15)
</pre>
In 2 bits per pixel color modes, palette entries 4 through 15 are not used.
==== Transparency ====
In two bit per pixel modes:
- Palettes 0-3 and 8-11 are ''opaque''. For these, index zero is treated as opaque.
- Palettes 4-7 and 12-15 are ''translucent''. For these, index zero is treated as transparent. This means that the color/shade value set to it is ignored, and only three distinct colors/shades can be used for tiles.
In four bit per pixel modes, all palettes are ''translucent''. Index zero is always treated as transparent, and fifteen different colors/shades can be used for tiles.
=== Background color ===
The background color is displayed if no ''opaque'' pixel from screens or sprites is drawn. This color is set in I/O port ''0x01'':
- In mono modes, it is set to an entry in the shade lookup table (0-7),
- In color modes, it is set to an entry in the color palette (0-255). Note that this allows you to use the first color (color zero) of any palette, which is normally ignored and assumed to be ''transparent''.
=== Screens ===
The WonderSwan can display up to two distinct 32x32 screens. These consist of 1024 two-byte cells:
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
vhbp pppt tttt tttt
|||| |||| |||| ||||
|||| |||+--++++-++++- Tile index (0-511)
|||+-+++------------- Palette (0-15)
||+------------------ Tile bank (0-1) - color only
|+------------------- Horizontal flip
+-------------------- Vertical flip
</pre>
=== Sprites ===
The WonderSwan can display up to 128 sprites at once. These are stored in a sprite table in RAM, which consists of up to 128 four-byte entries:
<pre>
(Byte 1) (Byte 0)
15 bit 8 7 bit 0
---- ---- ---- ----
vhPi pppt tttt tttt
|||| |||| |||| ||||
|||| |||+--++++-++++- Tile index (0-511) - only bank 0
|||| +++------------- Palette (0-7) - mapped to screen palettes 8-15
|||+----------------- Window location - 0 = inside, 1 = outside
||+------------------ Priority - 0 = behind Screen 2, 1 = in front of Screen 2
|+------------------- Horizontal flip
+-------------------- Vertical flip
(Byte 2)
7 bit 0
---- ----
yyyy yyyy
|||| ||||
++++-++++- Y coordinate
(Byte 3)
7 bit 0
---- ----
xxxx xxxx
|||| ||||
++++-++++- X coordinate
</pre>
For each row, the first 32 sprites for that row will be drawn - including sprites obscured by windows or outside of the visible range; only the Y coordinate determines this. The earlier among those sprites will be on top of the later ones.
=== Visibility priority ===
For display components, the visibility priority is as follows:
* Sprite 0, high priority
* Sprite 127, high priority
* Screen 2
* Sprite 0, low priority
* Sprite 127, low priority
* Screen 1
* Background color
=== Windows ===
Screen 2 and the sprite layer can optionally be restricted to a specific window.
In addition, one can control if a given element is rendered inside or outside that window. For Screen 2, this is controlled globally; for sprites, this is controlled per-sprite.
=== Icons ===
The WonderSwan features six LCD segment icons which are displayed to the right<sup>(color)</sup> or below<sup>(mono)</sup> the main display. These are, as follows:
* Aux 3 - large circle,
* Aux 2 - medium circle,
* Aux 1 - small circle,
* Horizontal orientation,
* Vertical orientation,
* Sleep.
== Interrupts ==
The display circuit generates two interrupts of its own:
* Display Interrupt Line Match - when <code>Display Current Line</code> == <code>Display Interrupt Line</code>, at the beginning of said line.
* Display Vertical Blank - when <code>Display Current Line</code> == <code>144</code>, at the beginning of said line.
It also provides a timing source for the two Horizontal and Vertical Blank [[Timers]], which provide their own respective interrupts.
== I/O ports ==
{{Anchor|Display Control}}
=== Display Control ($00) ===
<pre>
7 bit 0
---- ----
..ow Ws21
|| ||||
|| |||+- Enable Screen 1 layer
|| ||+-- Enable Screen 2 layer
|| |+--- Enable Sprite layer
|| +---- Enable Sprite window
|+------ Enable Screen 2 window
+------- Screen 2 window location:
0 = inside, 1 = outside
</pre>
{{Anchor|Display Background}}
=== Display Background Color ($01) ===
<pre>
(mono) (color)
7 bit 0 7 bit 0
---- ---- ---- ----
.... .sss pppp iiii
||| |||| ||||
+++- Value |||| ++++- Index in palette (0-15)
(0-7) ++++------ Color palette (0-15)
</pre>
{{Anchor|Display Current Line}}
=== Display Current Line ($02 read) ===
The current line being drawn by the display.
Note that lines are sent to the display with a one-line delay. This matters for color palette or shade LUT manipulation; changing these values when <code>current line == 1</code> will actually affect line 0.
{{Anchor|Display Interrupt Line}}
=== Display Interrupt Line ($03) ===
The line to emit an interrupt on.
{{Anchor|Sprite Table Address}}
=== Sprite Table Address ($04) ===
<pre>
7 bit 0
---- ----
..Aa aaaa
|| ||||
|+-++++- Address (bits 9-13)
+------- Address (bit 14) - color only
</pre>
{{Anchor|Sprite Table First}}
=== Sprite Table First ($05) ===
<pre>
7 bit 0
---- ----
.iii iiii
||| ||||
+++-++++- Index of first sprite entry to draw (0-127)
</pre>
{{Anchor|Sprite Table Count}}
=== Sprite Table Count ($06) ===
<pre>
7 bit 0
---- ----
cccc cccc
|||| ||||
++++-++++- Count of sprite entries to draw (1-128)
</pre>
{{Anchor|Screen Address}}
=== Screen Address ($07) ===
<pre>
7 bit 0
---- ----
2222 1111
|||| ||||
|||| |+++- Screen 1 address (bits 11-13)
|||| +---- Screen 1 address (bit 14) - color only
|+++------ Screen 2 address (bits 11-13)
+--------- Screen 2 address (bit 14) - color only
</pre>
{{Anchor|Screen 2 Window}}
=== Screen 2 Window Left ($08) ===
=== Screen 2 Window Top ($09) ===
=== Screen 2 Window Right ($0A) ===
=== Screen 2 Window Bottom ($0B) ===
{{Anchor|Sprite Window}}
=== Sprite Window Left ($0C) ===
=== Sprite Window Top ($0D) ===
=== Sprite Window Right ($0E) ===
=== Sprite Window Bottom ($0F) ===
{{Anchor|Screen Scroll}}
=== Screen 1 Scroll X ($10) ===
=== Screen 1 Scroll Y ($11) ===
=== Screen 2 Scroll X ($12) ===
=== Screen 2 Scroll Y ($13) ===
{{Anchor|LCD Control}}
=== LCD Control ($14) ===
<pre>
7 bit 0
---- ----
.... ..Ce
||
|+- LCD Enable: 0 = sleep, 1 = enabled
+-- Contrast (WSC): 0 = low, 1 = high
</pre>
{{Anchor|LCD Icon Control}}
=== LCD Icon Control ($15) ===
<pre>
7 bit 0
---- ----
..32 1hvs
|| ||||
|| |||+- Sleep
|| ||+-- Vertical orientation
|| |+--- Horizontal orientation
|| +---- Aux 1
|+------ Aux 2
+------- Aux 3
</pre>
{{Anchor|LCD Mono Shade LUT}}
=== LCD Mono Shade LUT ($1C-$1F) ===
<pre>
$1C $1D $1E $1F
7 bit 0 7 bit 0 7 bit 0 7 bit 0
---- ---- ---- ---- ---- ---- ---- ----
1111 0000 3333 2222 5555 4444 7777 6666
</pre>
{{Anchor|LCD Mono Palette}}
=== LCD Mono Palette 0..15 ($20, $21 .. $3E, $3F) ===
The monochrome palette is laid out as sixteen words:
<pre>
N+1 N
15 bit 8 7 bit 0
---- ---- ---- ----
.333 .222 .111 .000
||| ||| ||| |||
||| ||| ||| +++- Shade LUT index for color 0
||| ||| +++------ Shade LUT index for color 1
||| +++------------ Shade LUT index for color 2
+++----------------- Shade LUT index for color 3
</pre>
== Internal I/O ports ==
These I/O ports are said to be internal and not intended for use by commercial games.
{{Anchor|LCD Final Line}}
=== LCD Final Line ($16) ===
The final line preceding line counter restart and the beginning of active display. By default, this is set to 158, which equals 159 total lines per frame.
It is said setting this register to an odd value on SwanCrystal has an adverse effect to the LCD panel<ref>[http://daifukkat.su/docs/wsman/#REG_LCD_VTOTAL REG_LCD_VTOTAL - WSMan]</ref>, but the exact mechanism is unknown.
{{Anchor|LCD Back Porch Line}}
=== LCD Back Porch Line ($17, WSC only) ===
This port is available on the WonderSwan Color only - not the SwanCrystal!
The final line preceding the vertical back porch; by default, this should be set to 155.
The vertical back porch of the LCD is assumed to be 4 lines by some hardware, including IPS mods, as well as the official "TV Swan" capture device. Given that the first visible line is sent to the LCD on the display's line 1, this should be generally set to <code>LCD Final Line - 3</code>.
Conversely, it is said moving this value closer to vertical blank improves LCD visibility<ref>[http://daifukkat.su/docs/wsman/#REG_LCD_VSYNC REG_LCD_VSYNC - WSMan]</ref>, but the exact mechanism is unknown.
{{Anchor|LCD Status}}
=== LCD Status ($1A) ===
<pre>
7 bit 0
---- ----
...v vv.s
| || |
| || +- LCD sleep: 0 = no, 1 = sleep
| ||
| || Volume segments:
| |+--- Volume B (medium, high)
| +---- Volume A (low, high)
+------ Speaker
</pre>
=== TFT LCD Configuration ($70, $71, $72, $73, $74, $75, $76, $77 SwanCrystal only) ===
These eight bytes are read from internal EEPROM and configure unknown aspects of the console's TFT LCD panel.
They are only writable while the [[Boot ROM]] is unlocked - locking has the side effect of making them read-only.
== Notes ==
<references />
8d6668a9c78f70d4093ea0b83291a52468d370a4
WonderWitch/FreyaOS
0
49
257
2024-03-17T05:54:09Z
Asie
351
Created page with "FreyaOS is an operating system and library set for [[WonderWitch]], present in the second-to-last 64 KB of any WonderWitch cartridge. It provides the following library functionality: * process management, * file system access, * [[WonderWitch/IL|IL]] library management. It additionally provides an user interface, which allows launching programs and performing file management/transfer operations. == Revisions == * FreyaOS 1.0.0 * FreyaOS 1.0.2 (September 2nd, 2000 <r..."
wikitext
text/x-wiki
FreyaOS is an operating system and library set for [[WonderWitch]], present in the second-to-last 64 KB of any WonderWitch cartridge.
It provides the following library functionality:
* process management,
* file system access,
* [[WonderWitch/IL|IL]] library management.
It additionally provides an user interface, which allows launching programs and performing file management/transfer operations.
== Revisions ==
* FreyaOS 1.0.0
* FreyaOS 1.0.2 (September 2nd, 2000 <ref>[http://wonderwitch.qute.co.jp/announce/archives/msg00001.html FreyaOS バージョンアップのお知らせ]</ref>)
* FreyaOS 1.0.3 (November 1st, 2000 <ref>[http://wonderwitch.qute.co.jp/announce/archives/msg00004.html FreyaOS バージョンアップのお知らせ]</ref>)
* FreyaOS 1.1.0 (December 24th, 2000 <ref name="history2001">[http://wonderwitch.qute.co.jp/history200107.htm WonderWitch これまでの歩み]</ref>)
* FreyaOS 1.1.1 (February 7th, 2001 <ref name="history2001"/>)
* FreyaOS 1.1.2 (June 20th, 2001 <ref name="history2001"/>)
* FreyaOS 1.1.3 (June 26th, 2001 <ref name="history2001"/>)
* FreyaOS 1.1.4 (September 27th, 2001 <ref name="history2002">[http://wonderwitch.qute.co.jp/history200207.htm WonderWitch これまでの歩み 2002]</ref>)
* FreyaOS 1.1.5 (March 5th, 2002 <ref name="history2001"/>)
* FreyaOS 1.1.6 beta1 (April 30th, 2002 <ref>[http://wonderwitch.qute.co.jp/announce/archives/msg00321.html FreyaOS βバージョン提供のお知らせ]</ref>)
** Fixed IRAM corruption when calling ''open()''/''stat()'' after initializing SoundIL.
* FreyaOS 1.2.0 (July 13th, 2002 <ref>[http://wonderwitch.qute.co.jp/index_wwp.html WonderWitchプレーヤー サポートページ]</ref>)
** Validated for SwanCrystal consoles.
* FreyaOS 1.2.0S
** Special, stripped-down version of FreyaOS 1.2.0 used on pre-programmed Judgement Silversword and Dicing Knight cartridges.
== Notes ==
<references />
299619a0c8ce55fa1b91f2feaf339fc18cab3928
258
257
2024-03-17T05:54:46Z
Asie
351
wikitext
text/x-wiki
FreyaOS is an operating system and library set for [[WonderWitch]], present in the second-to-last 64 KB of any WonderWitch cartridge.
It provides the following library functionality:
* process management,
* file system access,
* [[WonderWitch/IL|IL]] library management.
It additionally provides an user interface, which allows launching programs and performing file management/transfer operations.
== Revisions ==
* FreyaOS 1.0.0
* FreyaOS 1.0.2 (September 2nd, 2000 <ref>[http://wonderwitch.qute.co.jp/announce/archives/msg00001.html FreyaOS バージョンアップのお知らせ]</ref>)
* FreyaOS 1.0.3 (November 1st, 2000 <ref>[http://wonderwitch.qute.co.jp/announce/archives/msg00004.html FreyaOS バージョンアップのお知らせ]</ref>)
* FreyaOS 1.1.0 (December 24th, 2000 <ref name="history2001">[http://wonderwitch.qute.co.jp/history200107.htm WonderWitch これまでの歩み]</ref>)
* FreyaOS 1.1.1 (February 7th, 2001 <ref name="history2001"/>)
* FreyaOS 1.1.2 (June 20th, 2001 <ref name="history2001"/>)
* FreyaOS 1.1.3 (June 26th, 2001 <ref name="history2001"/>)
* FreyaOS 1.1.4 (September 27th, 2001 <ref name="history2002">[http://wonderwitch.qute.co.jp/history200207.htm WonderWitch これまでの歩み 2002]</ref>)
* FreyaOS 1.1.5 (March 5th, 2002 <ref name="history2002"/>)
* FreyaOS 1.1.6 beta1 (April 30th, 2002 <ref>[http://wonderwitch.qute.co.jp/announce/archives/msg00321.html FreyaOS βバージョン提供のお知らせ]</ref>)
** Fixed IRAM corruption when calling ''open()''/''stat()'' after initializing SoundIL.
* FreyaOS 1.2.0 (July 13th, 2002 <ref>[http://wonderwitch.qute.co.jp/index_wwp.html WonderWitchプレーヤー サポートページ]</ref>)
** Validated for SwanCrystal consoles.
* FreyaOS 1.2.0S
** Special, stripped-down version of FreyaOS 1.2.0 used on pre-programmed Judgement Silversword and Dicing Knight cartridges.
== Notes ==
<references />
38907a0014bd1d47b10ef1d878ebd333d1bcd0a8
260
258
2024-03-17T05:59:31Z
Asie
351
wikitext
text/x-wiki
FreyaOS is an operating system and library set for [[WonderWitch]], present in the second-to-last 64 KB of any WonderWitch cartridge.
It provides the following library functionality:
* process management,
* file system access,
* [[WonderWitch/IL|IL]] library management.
It additionally provides an user interface, which allows launching programs and performing file management/transfer operations.
== Revisions ==
* FreyaOS 1.0.0
* FreyaOS 1.0.2 (September 2nd, 2000 <ref>[http://wonderwitch.qute.co.jp/announce/archives/msg00001.html FreyaOS バージョンアップのお知らせ]</ref>)
* FreyaOS 1.0.3 (November 1st, 2000 <ref>[http://wonderwitch.qute.co.jp/announce/archives/msg00004.html FreyaOS バージョンアップのお知らせ]</ref>)
* FreyaOS 1.1.0 (December 24th, 2000 <ref name="history2001">[http://wonderwitch.qute.co.jp/history200107.htm WonderWitch これまでの歩み]</ref>)
* FreyaOS 1.1.1 (February 7th, 2001 <ref name="history2001"/>)
* FreyaOS 1.1.2 (June 20th, 2001 <ref name="history2001"/>)
* FreyaOS 1.1.3 (June 26th, 2001 <ref name="history2001"/>)
* FreyaOS 1.1.4 (September 27th, 2001 <ref name="history2002">[http://wonderwitch.qute.co.jp/history200207.htm WonderWitch これまでの歩み 2002]</ref>)
* FreyaOS 1.1.5 (March 5th, 2002 <ref name="history2002"/>)
* FreyaOS 1.1.6 beta1 (April 30th, 2002 <ref>[http://wonderwitch.qute.co.jp/announce/archives/msg00321.html FreyaOS βバージョン提供のお知らせ]</ref>)
** Fixed IRAM corruption when calling ''open()''/''stat()'' after initializing SoundIL.
* FreyaOS 1.2.0 (July 13th, 2002 <ref>[http://wonderwitch.qute.co.jp/index_wwp.html WonderWitchプレーヤー サポートページ]</ref>)
** Validated for SwanCrystal consoles.
* FreyaOS 1.2.0S
** Special, stripped-down version of FreyaOS 1.2.0 used on pre-programmed Judgement Silversword and Dicing Knight cartridges.
== Documentation ==
* [[WonderWitch .fx files|.fx file format]]
== Notes ==
<references />
b43f4b45d5f03774a8eea8a1634aabfe410421e0
WonderWitch .fx files
0
6
259
241
2024-03-17T05:59:09Z
Asie
351
wikitext
text/x-wiki
[[WonderWitch/FreyaOS|FreyaOS]] uses [[XMODEM]] transfers to send and receive files through the serial port. These transfers do not include any file metadata by default - such as the file's name, size, permissions or creation date. As such, .fx files are used - binary files with a special 128-byte header<ref>XMODEM transfers are performed in 128-byte blocks; this allows fetching the file's metadata as the first block</ref>.
== Format ==
{| class="wikitable"
|+ Header contents
|-
! Offset !! Length !! Contents
|-
| $00 || 4 || Magic string: <code>#!ws</code>
|-
| $04 || 60 || Padding; typically 0xFF.
|-
| $40 || 16 || File name; zero-terminated Shift-JIS string.
|-
| $50 || 24 || User-friendly file name; zero-terminated Shift-JIS string.
FreyaOS displays the first 12 characters in its file selector.
|-
| $68 || 4 || ?
|-
| $6C || 4 || Total file size, in bytes, excluding the header.
|-
| $70 || 2 || XMODEM chunk count - above file size divided by 128, then rounded up.
|-
| $72 || 2 || File mode
|-
| $74 || 4 || Modification time - seconds since January 1st, 2000.
|-
| $78 || 4 || ?
|-
| $7C || 4 || Offset to resource data, bytes excluding header; -1 if not present.
|}
=== File mode ===
----
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
???? ???? ??i? ?rwx
| |||
| ||+- Execute
| |+-- Write
| +--- Read
+------- Intermediate library
</pre>
29cc8fb61f943a9cd919df2e7bf3d3e117f8104f
WonderWitch
0
41
261
180
2024-03-17T06:05:20Z
Asie
351
wikitext
text/x-wiki
The WonderWitch is an official homebrew development kit released by Qute Corporation on July 18th, 2000.
== Hardware ==
The WonderWitch cartridge is based on the [[Bandai 2003]] mapper. It provides an RTC, as well as NOR self-flashing functionality using the Fujitsu MBM29DL400TC chip.
There were three ways available to acquire WonderWitch cartridges:
* '''WonderWitch''', a software development kit containing a reflashable cartridge, a WonderSwan<->RS-232 adapter, a development manual and a development tool CD;
* '''WonderWitch Player''', a priced-down user-only version omitting the development manual and tooling;
* The VAR program, allowing independent creators to buy reflashable cartridges in bulk, in units of 20 or 100.
== Software ==
=== Interrupt vectors ===
{| class="wikitable"
! Start
! End
! Description
|-
| 0x00
| 0x07
| CPU interrupts
|-
| 0x08
| 0x0F
|
|-
| 0x10
| 0x18
| [[WonderWitch/FreyaBIOS|FreyaBIOS]] interrupts
|-
| 0x19
| 0x27
|
|-
| 0x28
| 0x2F
| SoC interrupts
|-
| 0x30
| 0x32
| [[WonderWitch/FreyaOS|FreyaOS]] interrupts
|}
=== Memory layout ===
The 512KB of NOR flash memory is mapped and partitioned as follows:
{| class="wikitable"
! Linear address
! Size
! Description
|-
| 0x8nnnn
| rowspan="6" | 384 KB
| rowspan="6" | [[WonderWitch/File system|File system]]
|-
| 0x9nnnn
|-
| 0xAnnnn
|-
| 0xBnnnn
|-
| 0xCnnnn
|-
| 0xDnnnn
|-
| 0xEnnnn
| 64 KB
| [[WonderWitch/FreyaOS|FreyaOS]]
|-
| 0xFnnnn
| 64 KB
| [[WonderWitch/FreyaBIOS|FreyaBIOS]]
|}
Internal console RAM is generally managed by [[WonderWitch/FreyaBIOS|FreyaBIOS]], while SRAM is managed by [[WonderWitch/FreyaOS|FreyaOS]].
== Development Tools ==
TODO
== Links ==
* [https://github.com/up-n-atom/WonderWitch/blob/main/Datasheets/MBM29DL400BC-12PFTN_to_MBM29DL400TC-90PFTN.pdf Fujitsu MBM29DL400TC datasheet]
acc5c0ac8e8da6f06edfa2a58dbdc08759bf56fa
Hyper Voice
0
30
262
218
2024-03-24T06:36:02Z
Asie
351
document volume/mode interplay
wikitext
text/x-wiki
Hyper Voice is a headphone-only sample output channel introduced with the WonderSwan Color. It allows converting 8-bit signed and unsigned, mono and stereo samples into 16-bit signed PCM sent directly to the headphone output, after mixing with the traditional four channels.
== I/O Ports ==
{{Anchor|Hyper Voice Output}}
=== Hyper Voice Left Output ($64, $65 write) ===
=== Hyper Voice Right Output ($66, $67 write) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
ssss ssss ssss ssss
|||| |||| |||| ||||
++++-++++--++++-++++- Signed 16-bit sample.
</pre>
Unlike the [[Sound]] sample output registers, these can be written to - allowing for direct 16-bit sample output.
{{Anchor|Hyper Voice Input}}
=== Hyper Voice Left Input ($68 write) ===
=== Hyper Voice Right Input ($69 write) ===
<pre>
7 bit 0
---- ----
ssss ssss
|||| ||||
++++-++++- 8-bit sample.
</pre>
These are typically written to by [[DMA|Sound DMA]], but can also be written to manually by the user.
{{Anchor|Hyper Voice Control}}
=== Hyper Voice Control ($6A, $6B) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
.mmc ???? errr ffss
||| |||| ||||
||| |||| ||++- Shift/Volume:
||| |||| || 0 = 100% 1 = 50%
||| |||| || 2 = 25% 3 = 12.5%
||| |||| ++--- Volume scaling algorithm:
||| |||| 0 = Unsigned
||| |||| 1 = Unsigned, negated
||| |||| 2 = Signed
||| |||| 3 = Ignored
||| |+++------ Update sample rate/Divisor:
||| | 0 = 24000/1 = 24000 Hz
||| | 1 = 24000/2 = 12000 Hz
||| | 2 = 24000/3 = 8000 Hz
||| | 3 = 24000/4 = 6000 Hz
||| | 4 = 24000/5 = 4800 Hz
||| | 5 = 24000/6 = 4000 Hz
||| | 6 = 24000/8 = 3000 Hz
||| | 7 = 24000/12 = 2000 Hz
||| +--------- Enable: 0 = off, 1 = on
||+----------------- Write 1 to reset DMA input channel to left
++------------------ Channel mode:
0 = Stereo
1 = Mono, left channel only
2 = Mono, right channel only
3 = Mono, both channels
</pre>
{| class="wikitable"
|+ Volume scaling algorithms - resulting sample ranges
! Algorithm/Volume
! 100%
! 50%
! 25%
! 12.5%
|-
| Unsigned
| 0x0000 .. 0xFFFF
| 0x8000 .. 0xFFFF
| 0x8000 .. 0xBFFF
| 0x8000 .. 0x9FFF
|-
| Unsigned, negated
| 0x0000 .. 0xFFFF
| 0x0000 .. 0x7FFF
| 0x4000 .. 0x7FFF
| 0x6000 .. 0x7FFF
|-
| Signed
| 0x0000 .. 0xFFFF
| 0x4000 .. 0xBFFF
| 0x6000 .. 0x9FFF
| 0x7000 .. 0x8FFF
|-
| Ignored
| 0x0000 .. 0xFFFF
| 0x0000 .. 0xFFFF
| 0x0000 .. 0xFFFF
| 0x0000 .. 0xFFFF
|}
839e753360d79e723480b8cf3712cb5ddbe56556
263
262
2024-03-24T06:37:14Z
Asie
351
/* Hyper Voice Control ($6A, $6B) */
wikitext
text/x-wiki
Hyper Voice is a headphone-only sample output channel introduced with the WonderSwan Color. It allows converting 8-bit signed and unsigned, mono and stereo samples into 16-bit signed PCM sent directly to the headphone output, after mixing with the traditional four channels.
== I/O Ports ==
{{Anchor|Hyper Voice Output}}
=== Hyper Voice Left Output ($64, $65 write) ===
=== Hyper Voice Right Output ($66, $67 write) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
ssss ssss ssss ssss
|||| |||| |||| ||||
++++-++++--++++-++++- Signed 16-bit sample.
</pre>
Unlike the [[Sound]] sample output registers, these can be written to - allowing for direct 16-bit sample output.
{{Anchor|Hyper Voice Input}}
=== Hyper Voice Left Input ($68 write) ===
=== Hyper Voice Right Input ($69 write) ===
<pre>
7 bit 0
---- ----
ssss ssss
|||| ||||
++++-++++- 8-bit sample.
</pre>
These are typically written to by [[DMA|Sound DMA]], but can also be written to manually by the user.
{{Anchor|Hyper Voice Control}}
=== Hyper Voice Control ($6A, $6B) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
.mmc ???? errr ffss
||| |||| ||||
||| |||| ||++- Shift/Volume:
||| |||| || 0 = 100% 1 = 50%
||| |||| || 2 = 25% 3 = 12.5%
||| |||| ++--- Volume scaling algorithm:
||| |||| 0 = Unsigned
||| |||| 1 = Unsigned, negated
||| |||| 2 = Signed
||| |||| 3 = Ignored
||| |+++------ Update sample rate/Divisor:
||| | 0 = 24000/1 = 24000 Hz
||| | 1 = 24000/2 = 12000 Hz
||| | 2 = 24000/3 = 8000 Hz
||| | 3 = 24000/4 = 6000 Hz
||| | 4 = 24000/5 = 4800 Hz
||| | 5 = 24000/6 = 4000 Hz
||| | 6 = 24000/8 = 3000 Hz
||| | 7 = 24000/12 = 2000 Hz
||| +--------- Enable: 0 = off, 1 = on
||+----------------- Reset: When 1 is written, the following DMA sample
will be used for the left channel.
++------------------ Channel mode:
0 = Stereo
1 = Mono, left channel only
2 = Mono, right channel only
3 = Mono, both channels
</pre>
{| class="wikitable"
|+ Volume scaling algorithms - resulting sample ranges
! Algorithm/Volume
! 100%
! 50%
! 25%
! 12.5%
|-
| Unsigned
| 0x0000 .. 0xFFFF
| 0x8000 .. 0xFFFF
| 0x8000 .. 0xBFFF
| 0x8000 .. 0x9FFF
|-
| Unsigned, negated
| 0x0000 .. 0xFFFF
| 0x0000 .. 0x7FFF
| 0x4000 .. 0x7FFF
| 0x6000 .. 0x7FFF
|-
| Signed
| 0x0000 .. 0xFFFF
| 0x4000 .. 0xBFFF
| 0x6000 .. 0x9FFF
| 0x7000 .. 0x8FFF
|-
| Ignored
| 0x0000 .. 0xFFFF
| 0x0000 .. 0xFFFF
| 0x0000 .. 0xFFFF
| 0x0000 .. 0xFFFF
|}
449ec68ecb8b401b14cc64627d454771d454567e
264
263
2024-03-24T06:37:23Z
Asie
351
/* Hyper Voice Control ($6A, $6B) */
wikitext
text/x-wiki
Hyper Voice is a headphone-only sample output channel introduced with the WonderSwan Color. It allows converting 8-bit signed and unsigned, mono and stereo samples into 16-bit signed PCM sent directly to the headphone output, after mixing with the traditional four channels.
== I/O Ports ==
{{Anchor|Hyper Voice Output}}
=== Hyper Voice Left Output ($64, $65 write) ===
=== Hyper Voice Right Output ($66, $67 write) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
ssss ssss ssss ssss
|||| |||| |||| ||||
++++-++++--++++-++++- Signed 16-bit sample.
</pre>
Unlike the [[Sound]] sample output registers, these can be written to - allowing for direct 16-bit sample output.
{{Anchor|Hyper Voice Input}}
=== Hyper Voice Left Input ($68 write) ===
=== Hyper Voice Right Input ($69 write) ===
<pre>
7 bit 0
---- ----
ssss ssss
|||| ||||
++++-++++- 8-bit sample.
</pre>
These are typically written to by [[DMA|Sound DMA]], but can also be written to manually by the user.
{{Anchor|Hyper Voice Control}}
=== Hyper Voice Control ($6A, $6B) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
.mmc ???? errr ffss
||| |||| ||||
||| |||| ||++- Shift/Volume:
||| |||| || 0 = 100% 1 = 50%
||| |||| || 2 = 25% 3 = 12.5%
||| |||| ++--- Volume scaling algorithm:
||| |||| 0 = Unsigned
||| |||| 1 = Unsigned, negated
||| |||| 2 = Signed
||| |||| 3 = Ignored
||| |+++------ Update sample rate/Divisor:
||| | 0 = 24000/1 = 24000 Hz
||| | 1 = 24000/2 = 12000 Hz
||| | 2 = 24000/3 = 8000 Hz
||| | 3 = 24000/4 = 6000 Hz
||| | 4 = 24000/5 = 4800 Hz
||| | 5 = 24000/6 = 4000 Hz
||| | 6 = 24000/8 = 3000 Hz
||| | 7 = 24000/12 = 2000 Hz
||| +--------- Enable: 0 = off, 1 = on
||+----------------- Reset: When 1 is written, the following DMA sample
|| will be used for the left channel.
++------------------ Channel mode:
0 = Stereo
1 = Mono, left channel only
2 = Mono, right channel only
3 = Mono, both channels
</pre>
{| class="wikitable"
|+ Volume scaling algorithms - resulting sample ranges
! Algorithm/Volume
! 100%
! 50%
! 25%
! 12.5%
|-
| Unsigned
| 0x0000 .. 0xFFFF
| 0x8000 .. 0xFFFF
| 0x8000 .. 0xBFFF
| 0x8000 .. 0x9FFF
|-
| Unsigned, negated
| 0x0000 .. 0xFFFF
| 0x0000 .. 0x7FFF
| 0x4000 .. 0x7FFF
| 0x6000 .. 0x7FFF
|-
| Signed
| 0x0000 .. 0xFFFF
| 0x4000 .. 0xBFFF
| 0x6000 .. 0x9FFF
| 0x7000 .. 0x8FFF
|-
| Ignored
| 0x0000 .. 0xFFFF
| 0x0000 .. 0xFFFF
| 0x0000 .. 0xFFFF
| 0x0000 .. 0xFFFF
|}
7e08f2874cfda2a5a7952faba7e9df2dd8d6f845
265
264
2024-03-24T12:52:08Z
Asie
351
wikitext
text/x-wiki
Hyper Voice is a headphone-only sample output channel introduced with the WonderSwan Color. It allows converting 8-bit signed and unsigned, mono and stereo samples into 16-bit signed PCM sent directly to the headphone output, after mixing with the traditional four channels.
== I/O Ports ==
{{Anchor|Hyper Voice Output}}
=== Hyper Voice Left Output ($64, $65 write) ===
=== Hyper Voice Right Output ($66, $67 write) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
ssss ssss ssss ssss
|||| |||| |||| ||||
++++-++++--++++-++++- Signed 16-bit sample.
</pre>
Unlike the [[Sound]] sample output registers, these can be written to - allowing for direct 16-bit sample output.
{{Anchor|Hyper Voice Input}}
=== Hyper Voice Left Input ($68 write) ===
=== Hyper Voice Right Input ($69 write) ===
<pre>
7 bit 0
---- ----
ssss ssss
|||| ||||
++++-++++- 8-bit sample.
</pre>
These are typically written to by [[DMA|Sound DMA]], but can also be written to manually by the user.
{{Anchor|Hyper Voice Control}}
=== Hyper Voice Control ($6A, $6B) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
.mmc ???? errr ffss
||| |||| ||||
||| |||| ||++- Shift/Volume:
||| |||| || 0 = 100% 1 = 50%
||| |||| || 2 = 25% 3 = 12.5%
||| |||| ++--- Sample scaling mode:
||| |||| 0 = Unsigned
||| |||| 1 = Unsigned, negated
||| |||| 2 = Signed
||| |||| 3 = Ignored
||| |+++------ Update sample rate/Divisor:
||| | 0 = 24000/1 = 24000 Hz
||| | 1 = 24000/2 = 12000 Hz
||| | 2 = 24000/3 = 8000 Hz
||| | 3 = 24000/4 = 6000 Hz
||| | 4 = 24000/5 = 4800 Hz
||| | 5 = 24000/6 = 4000 Hz
||| | 6 = 24000/8 = 3000 Hz
||| | 7 = 24000/12 = 2000 Hz
||| +--------- Enable: 0 = off, 1 = on
||+----------------- Reset: When 1 is written, the following DMA sample
|| will be used for the left channel.
++------------------ Channel mode:
0 = Stereo
1 = Mono, left channel only
2 = Mono, right channel only
3 = Mono, both channels
</pre>
Input samples are treated as signed 8-bit values. If volume is not 100% and sample scaling mode is not ignored, they may instead be treated as unsigned and/or be rescaled to the following value ranges:
{| class="wikitable"
|+ Sample scaling modes - resulting sample ranges
! Algorithm/Volume
! 100%
! 50%
! 25%
! 12.5%
|-
| Unsigned
| 0x0000 .. 0xFFFF
| 0x8000 .. 0xFFFF
| 0x8000 .. 0xBFFF
| 0x8000 .. 0x9FFF
|-
| Unsigned, negated
| 0x0000 .. 0xFFFF
| 0x0000 .. 0x7FFF
| 0x4000 .. 0x7FFF
| 0x6000 .. 0x7FFF
|-
| Signed
| 0x0000 .. 0xFFFF
| 0x4000 .. 0xBFFF
| 0x6000 .. 0x9FFF
| 0x7000 .. 0x8FFF
|-
| Ignored
| 0x0000 .. 0xFFFF
| 0x0000 .. 0xFFFF
| 0x0000 .. 0xFFFF
| 0x0000 .. 0xFFFF
|}
cfe5292c8884f73d041673cb37934ef75a4633a7
266
265
2024-03-24T13:50:30Z
Asie
351
wikitext
text/x-wiki
Hyper Voice is a headphone-only sample output channel introduced with the WonderSwan Color. It allows converting 8-bit signed and unsigned, mono and stereo samples into 16-bit signed PCM sent directly to the headphone output, after mixing with the traditional four channels.
== I/O Ports ==
{{Anchor|Hyper Voice Output}}
=== Hyper Voice Left Output ($64, $65 write) ===
=== Hyper Voice Right Output ($66, $67 write) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
ssss ssss ssss ssss
|||| |||| |||| ||||
++++-++++--++++-++++- Signed 16-bit sample.
</pre>
Unlike the [[Sound]] sample output registers, these can be written to - allowing for direct 16-bit sample output.
{{Anchor|Hyper Voice Input}}
=== Hyper Voice Input ($69 write) ===
<pre>
7 bit 0
---- ----
ssss ssss
|||| ||||
++++-++++- Signed 8-bit sample.
</pre>
Hyper Voice samples are typically written by [[DMA|Sound DMA]], but can also be written manually by the user. In the latter case, the "channel mode" setting is ignored - it always behaves as if it were in "stereo" mode, writing one channel after the other in sequence.
{{Anchor|Hyper Voice Control}}
=== Hyper Voice Control ($6A, $6B) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
.mmc ???? errr ffss
||| |||| ||||
||| |||| ||++- Shift/Volume:
||| |||| || 0 = 100% 1 = 50%
||| |||| || 2 = 25% 3 = 12.5%
||| |||| ++--- Sample scaling mode:
||| |||| 0 = Unsigned
||| |||| 1 = Unsigned, negated
||| |||| 2 = Signed
||| |||| 3 = Ignored
||| |+++------ Update sample rate/Divisor:
||| | 0 = 24000/1 = 24000 Hz
||| | 1 = 24000/2 = 12000 Hz
||| | 2 = 24000/3 = 8000 Hz
||| | 3 = 24000/4 = 6000 Hz
||| | 4 = 24000/5 = 4800 Hz
||| | 5 = 24000/6 = 4000 Hz
||| | 6 = 24000/8 = 3000 Hz
||| | 7 = 24000/12 = 2000 Hz
||| +--------- Enable: 0 = off, 1 = on
||+----------------- Reset: When 1 is written, the following DMA sample
|| will be used for the left channel.
++------------------ Channel mode:
0 = Stereo
1 = Mono, left channel only
2 = Mono, right channel only
3 = Mono, both channels
</pre>
Input samples are treated as signed 8-bit values. If volume is not 100% and sample scaling mode is not ignored, they may instead be treated as unsigned and/or be rescaled to the following value ranges:
{| class="wikitable"
|+ Sample scaling modes - resulting sample ranges
! Algorithm/Volume
! 100%
! 50%
! 25%
! 12.5%
|-
| Unsigned
| 0x0000 .. 0xFFFF
| 0x8000 .. 0xFFFF
| 0x8000 .. 0xBFFF
| 0x8000 .. 0x9FFF
|-
| Unsigned, negated
| 0x0000 .. 0xFFFF
| 0x0000 .. 0x7FFF
| 0x4000 .. 0x7FFF
| 0x6000 .. 0x7FFF
|-
| Signed
| 0x0000 .. 0xFFFF
| 0x4000 .. 0xBFFF
| 0x6000 .. 0x9FFF
| 0x7000 .. 0x8FFF
|-
| Ignored
| 0x0000 .. 0xFFFF
| 0x0000 .. 0xFFFF
| 0x0000 .. 0xFFFF
| 0x0000 .. 0xFFFF
|}
d7ce4578dfd2acba817e8e14e30c222236da97c3
271
266
2024-03-29T14:52:51Z
Asie
351
/* Hyper Voice Control ($6A, $6B) */
wikitext
text/x-wiki
Hyper Voice is a headphone-only sample output channel introduced with the WonderSwan Color. It allows converting 8-bit signed and unsigned, mono and stereo samples into 16-bit signed PCM sent directly to the headphone output, after mixing with the traditional four channels.
== I/O Ports ==
{{Anchor|Hyper Voice Output}}
=== Hyper Voice Left Output ($64, $65 write) ===
=== Hyper Voice Right Output ($66, $67 write) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
ssss ssss ssss ssss
|||| |||| |||| ||||
++++-++++--++++-++++- Signed 16-bit sample.
</pre>
Unlike the [[Sound]] sample output registers, these can be written to - allowing for direct 16-bit sample output.
{{Anchor|Hyper Voice Input}}
=== Hyper Voice Input ($69 write) ===
<pre>
7 bit 0
---- ----
ssss ssss
|||| ||||
++++-++++- Signed 8-bit sample.
</pre>
Hyper Voice samples are typically written by [[DMA|Sound DMA]], but can also be written manually by the user. In the latter case, the "channel mode" setting is ignored - it always behaves as if it were in "stereo" mode, writing one channel after the other in sequence.
{{Anchor|Hyper Voice Control}}
=== Hyper Voice Control ($6A, $6B) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
.mmc ???? errr ffss
||| |||| ||||
||| |||| ||++- Shift/Volume:
||| |||| || 0 = 100% 1 = 50%
||| |||| || 2 = 25% 3 = 12.5%
||| |||| ++--- Sample scaling mode:
||| |||| 0 = Unsigned
||| |||| 1 = Unsigned, negated
||| |||| 2 = Signed
||| |||| 3 = Ignored
||| |+++------ Update sample rate/Divisor:
||| | 0 = 24000/1 = 24000 Hz
||| | 1 = 24000/2 = 12000 Hz
||| | 2 = 24000/3 = 8000 Hz
||| | 3 = 24000/4 = 6000 Hz
||| | 4 = 24000/5 = 4800 Hz
||| | 5 = 24000/6 = 4000 Hz
||| | 6 = 24000/8 = 3000 Hz
||| | 7 = 24000/12 = 2000 Hz
||| +--------- Enable: 0 = off, 1 = on
||+----------------- Reset: When 1 is written, the following DMA sample
|| will be used for the left channel.
++------------------ Channel mode:
0 = Stereo
1 = Mono, left channel only
2 = Mono, right channel only
3 = Mono, both channels
</pre>
Internally, 8-bit values of the form <tt style="white-space: nowrap">Vvvv vvvv</tt> are transformed to signed 16-bit samples based on the scaling mode as follows:
{| class="wikitable"
! Sample scaling mode
! Bit representation
|-
| Unsigned
| <tt style="white-space: nowrap">000 Vvvv vvvv 0000 0000</tt>
|-
| Unsigned, negated
| <tt style="white-space: nowrap">111 Vvvv vvvv 0000 0000</tt>
|-
| Signed
| <tt style="white-space: nowrap">VVV Vvvv vvvv 0000 0000</tt>
|-
| Ignored
| <tt style="white-space: nowrap">___ Vvvv vvvv 0000 0000</tt>
|}
With the exception of the Ignored mode, the resulting value is shifted right by <code>Shift</code> bits, and the result's bottom 16 bits are used as the sample.
e9e367ea2972c2bdd3775be6343aa72346201b98
272
271
2024-03-29T14:53:36Z
Asie
351
wikitext
text/x-wiki
Hyper Voice is a headphone-only sample output channel introduced with the WonderSwan Color. It allows converting 8-bit signed and unsigned, mono and stereo samples into 16-bit signed PCM sent directly to the headphone output, after mixing with the traditional four channels.
== I/O Ports ==
{{Anchor|Hyper Voice Output}}
=== Hyper Voice Left Output ($64, $65 write) ===
=== Hyper Voice Right Output ($66, $67 write) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
ssss ssss ssss ssss
|||| |||| |||| ||||
++++-++++--++++-++++- Signed 16-bit sample.
</pre>
Unlike the [[Sound]] sample output registers, these can be written to - allowing for direct 16-bit sample output.
{{Anchor|Hyper Voice Input}}
=== Hyper Voice Input ($69 write) ===
<pre>
7 bit 0
---- ----
ssss ssss
|||| ||||
++++-++++- Signed 8-bit sample.
</pre>
Hyper Voice samples are typically written by [[DMA|Sound DMA]], but can also be written manually by the user. In the latter case, the "channel mode" setting is ignored - it always behaves as if it were in "stereo" mode, writing one channel after the other in sequence.
{{Anchor|Hyper Voice Control}}
=== Hyper Voice Control ($6A, $6B) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
.mmc ???? errr ffss
||| |||| ||||
||| |||| ||++- Shift/Volume:
||| |||| || 0 = 100% 1 = 50%
||| |||| || 2 = 25% 3 = 12.5%
||| |||| ++--- Sample scaling mode:
||| |||| 0 = Unsigned
||| |||| 1 = Unsigned, negated
||| |||| 2 = Signed
||| |||| 3 = Ignored
||| |+++------ Update sample rate/Divisor:
||| | 0 = 24000/1 = 24000 Hz
||| | 1 = 24000/2 = 12000 Hz
||| | 2 = 24000/3 = 8000 Hz
||| | 3 = 24000/4 = 6000 Hz
||| | 4 = 24000/5 = 4800 Hz
||| | 5 = 24000/6 = 4000 Hz
||| | 6 = 24000/8 = 3000 Hz
||| | 7 = 24000/12 = 2000 Hz
||| +--------- Enable: 0 = off, 1 = on
||+----------------- Reset: When 1 is written, the following DMA sample
|| will be used for the left channel.
++------------------ Channel mode:
0 = Stereo
1 = Mono, left channel only
2 = Mono, right channel only
3 = Mono, both channels
</pre>
Internally, 8-bit values of the form <tt style="white-space: nowrap">Vvvv vvvv</tt> are transformed to signed 16-bit samples based on the scaling mode as follows, where <code>V</code> represents the highest, 7th bit of the input value:
{| class="wikitable"
! Sample scaling mode
! Bit representation
|-
| Unsigned
| <tt style="white-space: nowrap">000 Vvvv vvvv 0000 0000</tt>
|-
| Unsigned, negated
| <tt style="white-space: nowrap">111 Vvvv vvvv 0000 0000</tt>
|-
| Signed
| <tt style="white-space: nowrap">VVV Vvvv vvvv 0000 0000</tt>
|-
| Ignored
| <tt style="white-space: nowrap">___ Vvvv vvvv 0000 0000</tt>
|}
With the exception of the Ignored mode, the resulting value is shifted right by <code>Shift</code> bits, and the result's bottom 16 bits are used as the sample.
54c33a7b427322ee727dffa222dedf8d631e5154
I/O port map
0
8
267
245
2024-03-24T13:51:18Z
Asie
351
wikitext
text/x-wiki
The WonderSwan SoC has three general blocks of I/O port accesses:
{| class="wikitable"
! From !! To !! Holder !! Width !! Speed
|-
| $00 || $B7 || WonderSwan SoC || 16-bit || 1 cycle
|-
| $B8 || $BF || Internal EEPROM control || 16-bit || 1 cycle
|-
| $C0 || $FF || Cartridge bus || 8-bit || 1<sup>(color)</sup>/2 cycles (configurable)
|}
With the exception of internal EEPROM on the ASWAN, all unaligned 16-bit accesses can be converted to two 8-bit accesses with a 1-cycle penalty.
== I/O port map ==
* Superscripts are used to mark ports specific to a given mode or platform:
** Color mode: <sup>(color)</sup>. Such ports are only accessible when color mode is enabled through port <code>$60</code>.
** WS/WSC/SC console: <sup>(WS)</sup>, <sup>(WSC)</sup>, <sup>(SC)</sup>.
* If two Bits rows are provided, the second one refers to the "Color" mode.
* The Type can be: R - readable, W - writable, L - writable before boot ROM lockout, 8/16 - width (byte/word).
{| class="wikitable"
! Category
! Port
! Description
! Bits
! Type
! Notes
|-
! rowspan="45" | [[Display]]
! $00
| [[Display#Display Control|Display Control]]
| style="text-align: right" | <tt style="white-space: nowrap">..ow Ws21</tt>
| RW8
|
|-
! $01
| [[Display#Display Background|Display Background]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .sss</tt>
<tt style="white-space: nowrap">pppp iiii</tt>
| RW8
| Shade (s)
Palette (p), Index (i)
|-
! $02
| [[Display#Current Line|Display Current Line]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll</tt>
| R8
| Line (l)
|-
! $03
| [[Display#Interrupt Line|Display Interrupt Line]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll</tt>
| RW8
| Line (l)
|-
! $04
| [[Display#Sprite Table Address|Sprite Table Address]]
| style="text-align: right" | <tt style="white-space: nowrap">...a aaaa</tt>
<tt style="white-space: nowrap">..aa aaaa</tt>
| RW8
| Address >> 9 (a)
|-
! $05
| [[Display#Sprite Table First|Sprite Table First]]
| style="text-align: right" | <tt style="white-space: nowrap">.iii iiii</tt>
| RW8
| Index (i)
|-
! $06
| [[Display#Sprite Table Count|Sprite Table Count]]
| style="text-align: right" | <tt style="white-space: nowrap">cccc cccc</tt>
| RW8
| Count (c)
|-
! $07
| [[Display#Screen Address|Screen Address]]
| style="text-align: right" | <tt style="white-space: nowrap">.222 .111</tt>
<tt style="white-space: nowrap">2222 1111</tt>
| RW8
| Screen 1 address >> 11 (1)
Screen 2 address >> 11 (2)
|-
! $08
| [[Display#Screen 2 Window|Screen 2 Window Left]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $09
| [[Display#Screen 2 Window|Screen 2 Window Top]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $0A
| [[Display#Screen 2 Window|Screen 2 Window Right]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $0B
| [[Display#Screen 2 Window|Screen 2 Window Bottom]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $0B
| [[Display#Sprite Window|Sprite Window Left]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $0C
| [[Display#Sprite Window|Sprite Window Top]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $0E
| [[Display#Sprite Window|Sprite Window Right]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $0F
| [[Display#Sprite Window|Sprite Window Bottom]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $10
| [[Display#Screen Scroll|Screen 1 Scroll X]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $11
| [[Display#Screen Scroll|Screen 1 Scroll Y]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $12
| [[Display#Screen Scroll|Screen 2 Scroll X]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $13
| [[Display#Screen Scroll|Screen 2 Scroll Y]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $14
| [[Display#LCD Control|LCD Control]]
| style="text-align: right" | <tt style="white-space: nowrap">.... ..Ce</tt>
| RW8
| Contrast (C)<sup>(WSC)</sup>, Enable (e)
|-
! $15
| [[Display#LCD Icon Control|LCD Icon Control]]
| style="text-align: right" | <tt style="white-space: nowrap">..32 1hvs</tt>
| RW8
| Auxillary 3 (3), Auxillary 2 (2), Auxillary 1 (1),
Horizontal (h), Vertical (v), Sleep (s)
|-
! $16
| [[Display#LCD Final Line|LCD Final Line]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll</tt>
| RW8
| Line (l)
|-
! $17
| [[Display#LCD Back Porch Line|LCD Back Porch Line]]<sup>(WSC)</sup>
| style="text-align: right" | <tt style="white-space: nowrap">llll llll</tt>
| RW8
| Line (l)
|-
! $1A
| [[Display#LCD Status|LCD Status]]
| style="text-align: right" | <tt style="white-space: nowrap">...v vv.s</tt>
| RW8
| Volume segment status (v), Sleep (s)
|-
! $1C
| [[Display#LCD Mono Shade LUT|LCD Mono Shade LUT 0/1]]
| style="text-align: right" | <tt style="white-space: nowrap">1111 0000</tt>
| RW8
| Shade index
|-
! $1D
| [[Display#LCD Mono Shade LUT|LCD Mono Shade LUT 2/3]]
| style="text-align: right" | <tt style="white-space: nowrap">3333 2222</tt>
| RW8
| Shade index
|-
! $1E
| [[Display#LCD Mono Shade LUT|LCD Mono Shade LUT 4/5]]
| style="text-align: right" | <tt style="white-space: nowrap">5555 4444</tt>
| RW8
| Shade index
|-
! $1F
| [[Display#LCD Mono Shade LUT|LCD Mono Shade LUT 6/7]]
| style="text-align: right" | <tt style="white-space: nowrap">7777 6666</tt>
| RW8
| Shade index
|-
! $20
| [[Display#LCD Mono Palette|LCD Mono Palette 0]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $22
| [[Display#LCD Mono Palette|LCD Mono Palette 1]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $24
| [[Display#LCD Mono Palette|LCD Mono Palette 2]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $26
| [[Display#LCD Mono Palette|LCD Mono Palette 3]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $28
| [[Display#LCD Mono Palette|LCD Mono Palette 4]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $2A
| [[Display#LCD Mono Palette|LCD Mono Palette 5]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $2C
| [[Display#LCD Mono Palette|LCD Mono Palette 6]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $2E
| [[Display#LCD Mono Palette|LCD Mono Palette 7]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $30
| [[Display#LCD Mono Palette|LCD Mono Palette 8]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $32
| [[Display#LCD Mono Palette|LCD Mono Palette 9]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $34
| [[Display#LCD Mono Palette|LCD Mono Palette 10]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $36
| [[Display#LCD Mono Palette|LCD Mono Palette 11]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $38
| [[Display#LCD Mono Palette|LCD Mono Palette 12]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $3A
| [[Display#LCD Mono Palette|LCD Mono Palette 13]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $3C
| [[Display#LCD Mono Palette|LCD Mono Palette 14]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $3E
| [[Display#LCD Mono Palette|LCD Mono Palette 15]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! rowspan="10" | [[DMA]]<sup>(color)</sup>
! $40
| [[DMA#General DMA|GDMA Source Address Low]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll llll lll.</tt>
| RW16
| Linear address, low 16 bits (l)
|-
! $42
| [[DMA#General DMA|GDMA Source Address High]]
| style="text-align: right" | <tt style="white-space: nowrap">.... hhhh</tt>
| RW8
| Linear address, high 4 bits (h)
|-
! $44
| [[DMA#General DMA|GDMA Destination Address]]
| style="text-align: right" | <tt style="white-space: nowrap">aaaa aaaa aaaa aaa.</tt>
| RW16
| IRAM address (a)
|-
! $46
| [[DMA#General DMA|GDMA Length]]
| style="text-align: right" | <tt style="white-space: nowrap">bbbb bbbb bbbb bbb.</tt>
| RW16
| Bytes (b)
|-
! $48
| [[DMA#General DMA|GDMA Control]]
| style="text-align: right" | <tt style="white-space: nowrap">ed.. ....</tt>
| RW8
| Enable (e), Decrement (d)
|-
! $4A
| [[DMA#Sound DMA|SDMA Source Address Low]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll llll llll</tt>
| RW16
| Linear address, low 16 bits (l)
|-
! $4C
| [[DMA#Sound DMA|SDMA Source Address High]]
| style="text-align: right" | <tt style="white-space: nowrap">.... hhhh</tt>
| RW8
| Linear address, high 4 bits (h)
|-
! $4E
| [[DMA#Sound DMA|SDMA Length Low]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll llll llll</tt>
| RW16
| Length, low 16 bits (l)
|-
! $50
| [[DMA#Sound DMA|SDMA Length High]]
| style="text-align: right" | <tt style="white-space: nowrap">.... hhhh</tt>
| RW8
| Length, high 4 bits (h)
|-
! $52
| [[DMA#Sound DMA|SDMA Control]]
| style="text-align: right" | <tt style="white-space: nowrap">ed.t rhff</tt>
| RW8
| Enable (e), Decrement (d), Target (t),
Repeat (r), Hold (h), Frequency (f)
|-
! rowspan="2" | [[SoC]]<sup>(color)</sup>
! $60
| [[SoC#System Control 2|System Control 2]]
| style="text-align: right" | <tt style="white-space: nowrap">c4C. i?sl</tt>
| RW8
| Color (c), 4BPP (4), Chunky (C),<br/>
Cart I/O wait state (i), SRAM wait state (s),<br/>
Cart clock speed (l).
|-
! $62
| [[SoC#System Control 3|System Control 3]]
| style="text-align: right" | <tt style="white-space: nowrap">S... ...p</tt>
| RW8
| SwanCrystal (S), Power off (p)
|-
! rowspan="5" | [[Hyper Voice]]<sup>(color)</sup>
! $64
| [[Hyper Voice#Hyper Voice Output|Hyper Voice Left Output]]
| style="text-align: right" | <tt style="white-space: nowrap">ssss ssss ssss ssss</tt>
| W16
| Raw sample (s)
|-
! $66
| [[Hyper Voice#Hyper Voice Output|Hyper Voice Right Output]]
| style="text-align: right" | <tt style="white-space: nowrap">ssss ssss ssss ssss</tt>
| W16
| Raw sample (s)
|-
! $69
| [[Hyper Voice#Hyper Voice Input|Hyper Voice Right Input]]
| style="text-align: right" | <tt style="white-space: nowrap">ssss ssss</tt>
| W8
| Sample (s)
|-
! $6A
| [[Hyper Voice#Hyper Voice Control|Hyper Voice Control]]
| style="text-align: right" | <tt style="white-space: nowrap">.mmc ???? errr ffss</tt>
| RW16
| Mask (m), Channel reset (c), Enable (e),
Rate (r), Format (f), Shift (s)
|-
! rowspan="8" | [[Display]]<sup>(SC)</sup>
! $70
| LCD Timing Configuration 1?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $71
| LCD Timing Configuration 2?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $72
| LCD Timing Configuration 3?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $73
| LCD Timing Configuration 4?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $74
| LCD Timing Configuration 5?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $75
| LCD Timing Configuration 6?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $76
| LCD Timing Configuration 7?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $77
| LCD Timing Configuration 8?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! rowspan="21" | [[Sound]]
! $80
| [[Sound#Sound Channel Frequency|Sound Channel 1 Frequency]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .ddd dddd dddd</tt>
| RW16
| Divider (d)
|-
! $82
| [[Sound#Sound Channel Frequency|Sound Channel 2 Frequency]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .ddd dddd dddd</tt>
| RW16
| Divider (d)
|-
! $84
| [[Sound#Sound Channel Frequency|Sound Channel 3 Frequency]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .ddd dddd dddd</tt>
| RW16
| Divider (d)
|-
! $86
| [[Sound#Sound Channel Frequency|Sound Channel 4 Frequency]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .ddd dddd dddd</tt>
| RW16
| Divider (d)
|-
! $88
| [[Sound#Sound Channel Volume|Sound Channel 1 Volume]]
| style="text-align: right" | <tt style="white-space: nowrap">llll rrrr</tt>
| RW8
| Left (l), Right (r)
|-
! rowspan="2" | $89
| [[Sound#Sound Channel Volume|Sound Channel 2 Volume]]
| style="text-align: right" | <tt style="white-space: nowrap">llll rrrr</tt>
| RW8
| Left (l), Right (r)
|-
| [[Sound#Sound Channel 2 Voice Sample|Sound Channel 2 Voice Sample]]
| style="text-align: right" | <tt style="white-space: nowrap">ssss ssss</tt>
| RW8
| Sample (s)
|-
! $8A
| [[Sound#Sound Channel Volume|Sound Channel 3 Volume]]
| style="text-align: right" | <tt style="white-space: nowrap">llll rrrr</tt>
| RW8
| Left (l), Right (r)
|-
! $8B
| [[Sound#Sound Channel Volume|Sound Channel 4 Volume]]
| style="text-align: right" | <tt style="white-space: nowrap">llll rrrr</tt>
| RW8
| Left (l), Right (r)
|-
! $8C
| [[Sound#Sound Channel 3 Sweep Amount|Sound Channel 3 Sweep Amount]]
| style="text-align: right" | <tt style="white-space: nowrap">vvvv vvvv</tt>
| RW8
| Value (v)
|-
! $8D
| [[Sound#Sound Channel 3 Sweep Ticks|Sound Channel 3 Sweep Ticks]]
| style="text-align: right" | <tt style="white-space: nowrap">...t tttt</tt>
| RW8
| Ticks (t)
|-
! $8E
| [[Sound#Sound Channel 4 Noise Control|Sound Channel 4 Noise Control]]
| style="text-align: right" | <tt style="white-space: nowrap">...e rttt</tt>
| RW8
| Enable (e), Reset (r), Tap (t)
|-
! $8F
| [[Sound#Sound Wavetable Address|Sound Wavetable Address]]
| style="text-align: right" | <tt style="white-space: nowrap">wwww wwww</tt>
| RW8
| Address >> 6 (w)
|-
! $90
| [[Sound#Sound Channel Control|Sound Channel Control]]
| style="text-align: right" | <tt style="white-space: nowrap">nsv. 4321</tt>
| RW8
| Channel enable (1234)
Noise (n), Sweep (s), Voice (v)
|-
! $91
| [[Sound#Sound Output Control|Sound Output Control]]
| style="text-align: right" | <tt style="white-space: nowrap">H... hrrs</tt>
| RW8
| Headphones connected (H)
Headphone output (h)
Speaker output (s), range (r)
|-
! $92
| [[Sound#Sound Channel 4 LFSR Register|Sound Channel 4 LFSR Register]]
| style="text-align: right" | <tt style="white-space: nowrap">.rrr rrrr rrrr rrrr</tt>
| R16
| PRNG state (r)
|-
! $94
| [[Sound#Sound Channel 2 Voice Volume|Sound Channel 2 Voice Volume]]
| style="text-align: right" | <tt style="white-space: nowrap">.... lLrR</tt>
| RW8
| Left Half (l), Full (L)
Right Half (r), Full (R)
|-
! $95
| [[Sound#Sound Test|Sound Test]]
| style="text-align: right" | <tt style="white-space: nowrap">425? ???h</tt>
| RW8
|
|-
! $96
| Sound Channel Output Right
| style="text-align: right" | <tt style="white-space: nowrap">.... ..ss ssss ssss</tt>
| R16
| Sample (s)
|-
! $98
| Sound Channel Output Left
| style="text-align: right" | <tt style="white-space: nowrap">.... ..ss ssss ssss</tt>
| R16
| Sample (s)
|-
! $9A
| Sound Channel Output Sum
| style="text-align: right" | <tt style="white-space: nowrap">.... .sss ssss ssss</tt>
| R16
| Sample (s)
|-
! $9E
| Sound Speaker Master Volume<sup>(color)</sup>
| style="text-align: right" | <tt style="white-space: nowrap">.... ..vv</tt>
| RW8
| Master volume (v)
|-
! [[SoC]]
! $A0
| [[SoC#System Control|System Control]]
| style="text-align: right" | <tt style="white-space: nowrap">t??? swcl</tt>
| RW8
| Test OK (t), ROM wait state (s), ROM width (w),
Color system (c), Boot ROM lockout (l)
|-
! rowspan="5" | [[Timers]]
! $A2
| [[Timers#Timer Control|Timer Control]]
| style="text-align: right" | <tt style="white-space: nowrap">.... VvHh</tt>
| RW8
| Horizontal enable (h), auto reload (H)
Vertical enable (v), auto reload (V)
|-
! $A4
| [[Timers#Timer Reload|Horizontal Blank Timer Reload]]
| style="text-align: right" | <tt style="white-space: nowrap">tttt tttt tttt tttt</tt>
| RW16
| Ticks (t)
|-
! $A6
| [[Timers#Timer Reload|Vertical Blank Timer Reload]]
| style="text-align: right" | <tt style="white-space: nowrap">tttt tttt tttt tttt</tt>
| RW16
| Ticks (t)
|-
! $A8
| [[Timers#Timer Counter|Horizontal Blank Timer Counter]]
| style="text-align: right" | <tt style="white-space: nowrap">tttt tttt tttt tttt</tt>
| R16
| Ticks (t)
|-
! $AA
| [[Timers#Timer Counter|Vertical Blank Timer Counter]]
| style="text-align: right" | <tt style="white-space: nowrap">tttt tttt tttt tttt</tt>
| R16
| Ticks (t)
|-
! ?
! $AC
| ?
| style="text-align: right" | <tt style="white-space: nowrap">.... ...p</tt>
| W8?
| Power off (p)
|-
! rowspan="2" | [[Interrupts]]
! rowspan="2" | $B0
| [[Interrupts#Interrupt Vector Offset|Interrupt Vector Offset]]
| style="text-align: right" | <tt style="white-space: nowrap">VVVV V...</tt>
| W8
| Vector offset (V)
|-
| [[Interrupts#Interrupt Vector Request|Interrupt Vector Request]]
| style="text-align: right" | <tt style="white-space: nowrap">vvvv vvvv</tt>
| R8
| Requested vector offset (v)
|-
! rowspan="2" | [[UART]]
! $B1
| [[UART#Serial Receive Data|Serial Receive Data]]
| style="text-align: right" | <tt style="white-space: nowrap">dddd dddd</tt>
| R8
| Receive buffer data (d)
|-
! $B1
| [[UART#Serial Transmit Data|Serial Transmit Data]]
| style="text-align: right" | <tt style="white-space: nowrap">dddd dddd</tt>
| W8
| Transmit buffer data (d)
|-
! [[Interrupts]]
! $B2
| [[Interrupts#Interrupt Enable|Interrupt Enable]]
| style="text-align: right" | <tt style="white-space: nowrap">iiii iiii</tt>
| RW8
| Interrupt index (i)
|-
! rowspan="2" | [[UART]]
! $B3
| [[UART#Serial Status|Serial Status]]
| style="text-align: right" | <tt style="white-space: nowrap">eb.. .tor</tt>
| R8
| Enable (e), Baud rate (b),
Transfer ready (t), Overrun (o), Receive ready (r)
|-
! $B3
| [[UART#Serial Control|Serial Control]]
| style="text-align: right" | <tt style="white-space: nowrap">ebO. ....</tt>
| W8
| Enable (e), Baud rate (b), Reset Overrun (O)
|-
! [[Interrupts]]
! $B4
| [[Interrupts#Interrupt Status|Interrupt Status]]
| style="text-align: right" | <tt style="white-space: nowrap">iiii iiii</tt>
| R8
| Interrupt index (i)
|-
! [[Keypad]]
! $B5
| [[Keypad|Keypad Scan]]
| style="text-align: right" | <tt style="white-space: nowrap">.iii oooo</tt>
| RW8
| Input row (i), Output column (o)
|-
! rowspan="2" | [[Interrupts]]
! $B6
| [[Interrupts#Interrupt Acknowledge|Interrupt Acknowledge]]
| style="text-align: right" | <tt style="white-space: nowrap">iiii iiii</tt>
| W8
| Interrupt index (i)
|-
! $B7
| [[Interrupts#Interrupt NMI Control|Interrupt NMI Control]]
| style="text-align: right" | <tt style="white-space: nowrap">...b ....</tt>
| RW8
| Low battery (b)
|-
! rowspan="4" | [[EEPROM|Internal EEPROM]]
! $BA
| [[EEPROM#Internal EEPROM Data|Internal EEPROM Data]]
| style="text-align: right" | <tt style="white-space: nowrap">dddd dddd dddd dddd</tt>
| RW16
| Data (d)
|-
! $BC
| [[EEPROM#Internal EEPROM Command|Internal EEPROM Command]]
|
| RW16
|
|-
! rowspan="2" | $BE
| [[EEPROM#Internal EEPROM Status|Internal EEPROM Status]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .... p... ..RD</tt>
| R16
| Protected (p), Ready (R), Done (D)
|-
| [[EEPROM#Internal EEPROM Control|Internal EEPROM Control]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .... pewr ....</tt>
| W16
| Protect (p), Erase (e), Write (w), Read (r)
|-
! [[Mapper|Cartridge]]
! $C0<br />...<br />
$FF
| Cartridge I/O
|
| RW8
| Forwarded by the SoC
|}
== I/O port routing ==
The [[NEC V30MZ]] supports 16-bit I/O port addresses. The WonderSwan SoC routes them using the following algorithm:
* If an address is between <code>$00B8</code> and <code>$00BF</code> inclusive, it is routed to the internal EEPROM control block.
* If an address is between <code>$00C0</code> and <code>$00FF</code> inclusive, it is routed to the cartride bus.
* If an address's bits <code>0</code> through <code>8</code> inclusive are between <code>$000</code> and <code>$0B7</code> inclusive, they are routed to the SoC block.
* If none of these conditions are reached, open bus is read.
On the monochrome models, as well as color models in mono emulation, open bus is always <code>0x90</code>.
6bf63392834634fecf72c1190ae345e0fc8442f0
268
267
2024-03-24T13:52:14Z
Asie
351
wikitext
text/x-wiki
The WonderSwan SoC has three general blocks of I/O port accesses:
{| class="wikitable"
! From !! To !! Holder !! Width !! Speed
|-
| $00 || $B7 || WonderSwan SoC || 16-bit || 1 cycle
|-
| $B8 || $BF || Internal EEPROM control || 16-bit || 1 cycle
|-
| $C0 || $FF || Cartridge bus || 8-bit || 1<sup>(color)</sup>/2 cycles (configurable)
|}
With the exception of internal EEPROM on the ASWAN, all unaligned 16-bit accesses can be converted to two 8-bit accesses with a 1-cycle penalty.
== I/O port map ==
* Superscripts are used to mark ports specific to a given mode or platform:
** Color mode: <sup>(color)</sup>. Such ports are only accessible when color mode is enabled through port <code>$60</code>.
** WS/WSC/SC console: <sup>(WS)</sup>, <sup>(WSC)</sup>, <sup>(SC)</sup>.
* If two Bits rows are provided, the second one refers to the "Color" mode.
* The Type can be: R - readable, W - writable, L - writable before boot ROM lockout, 8/16 - width (byte/word).
{| class="wikitable"
! Category
! Port
! Description
! Bits
! Type
! Notes
|-
! rowspan="45" | [[Display]]
! $00
| [[Display#Display Control|Display Control]]
| style="text-align: right" | <tt style="white-space: nowrap">..ow Ws21</tt>
| RW8
|
|-
! $01
| [[Display#Display Background|Display Background]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .sss</tt>
<tt style="white-space: nowrap">pppp iiii</tt>
| RW8
| Shade (s)
Palette (p), Index (i)
|-
! $02
| [[Display#Current Line|Display Current Line]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll</tt>
| R8
| Line (l)
|-
! $03
| [[Display#Interrupt Line|Display Interrupt Line]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll</tt>
| RW8
| Line (l)
|-
! $04
| [[Display#Sprite Table Address|Sprite Table Address]]
| style="text-align: right" | <tt style="white-space: nowrap">...a aaaa</tt>
<tt style="white-space: nowrap">..aa aaaa</tt>
| RW8
| Address >> 9 (a)
|-
! $05
| [[Display#Sprite Table First|Sprite Table First]]
| style="text-align: right" | <tt style="white-space: nowrap">.iii iiii</tt>
| RW8
| Index (i)
|-
! $06
| [[Display#Sprite Table Count|Sprite Table Count]]
| style="text-align: right" | <tt style="white-space: nowrap">cccc cccc</tt>
| RW8
| Count (c)
|-
! $07
| [[Display#Screen Address|Screen Address]]
| style="text-align: right" | <tt style="white-space: nowrap">.222 .111</tt>
<tt style="white-space: nowrap">2222 1111</tt>
| RW8
| Screen 1 address >> 11 (1)
Screen 2 address >> 11 (2)
|-
! $08
| [[Display#Screen 2 Window|Screen 2 Window Left]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $09
| [[Display#Screen 2 Window|Screen 2 Window Top]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $0A
| [[Display#Screen 2 Window|Screen 2 Window Right]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $0B
| [[Display#Screen 2 Window|Screen 2 Window Bottom]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $0B
| [[Display#Sprite Window|Sprite Window Left]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $0C
| [[Display#Sprite Window|Sprite Window Top]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $0E
| [[Display#Sprite Window|Sprite Window Right]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $0F
| [[Display#Sprite Window|Sprite Window Bottom]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $10
| [[Display#Screen Scroll|Screen 1 Scroll X]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $11
| [[Display#Screen Scroll|Screen 1 Scroll Y]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $12
| [[Display#Screen Scroll|Screen 2 Scroll X]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $13
| [[Display#Screen Scroll|Screen 2 Scroll Y]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $14
| [[Display#LCD Control|LCD Control]]
| style="text-align: right" | <tt style="white-space: nowrap">.... ..Ce</tt>
| RW8
| Contrast (C)<sup>(WSC)</sup>, Enable (e)
|-
! $15
| [[Display#LCD Icon Control|LCD Icon Control]]
| style="text-align: right" | <tt style="white-space: nowrap">..32 1hvs</tt>
| RW8
| Auxillary 3 (3), Auxillary 2 (2), Auxillary 1 (1),
Horizontal (h), Vertical (v), Sleep (s)
|-
! $16
| [[Display#LCD Final Line|LCD Final Line]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll</tt>
| RW8
| Line (l)
|-
! $17
| [[Display#LCD Back Porch Line|LCD Back Porch Line]]<sup>(WSC)</sup>
| style="text-align: right" | <tt style="white-space: nowrap">llll llll</tt>
| RW8
| Line (l)
|-
! $1A
| [[Display#LCD Status|LCD Status]]
| style="text-align: right" | <tt style="white-space: nowrap">...v vv.s</tt>
| RW8
| Volume segment status (v), Sleep (s)
|-
! $1C
| [[Display#LCD Mono Shade LUT|LCD Mono Shade LUT 0/1]]
| style="text-align: right" | <tt style="white-space: nowrap">1111 0000</tt>
| RW8
| Shade index
|-
! $1D
| [[Display#LCD Mono Shade LUT|LCD Mono Shade LUT 2/3]]
| style="text-align: right" | <tt style="white-space: nowrap">3333 2222</tt>
| RW8
| Shade index
|-
! $1E
| [[Display#LCD Mono Shade LUT|LCD Mono Shade LUT 4/5]]
| style="text-align: right" | <tt style="white-space: nowrap">5555 4444</tt>
| RW8
| Shade index
|-
! $1F
| [[Display#LCD Mono Shade LUT|LCD Mono Shade LUT 6/7]]
| style="text-align: right" | <tt style="white-space: nowrap">7777 6666</tt>
| RW8
| Shade index
|-
! $20
| [[Display#LCD Mono Palette|LCD Mono Palette 0]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $22
| [[Display#LCD Mono Palette|LCD Mono Palette 1]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $24
| [[Display#LCD Mono Palette|LCD Mono Palette 2]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $26
| [[Display#LCD Mono Palette|LCD Mono Palette 3]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $28
| [[Display#LCD Mono Palette|LCD Mono Palette 4]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $2A
| [[Display#LCD Mono Palette|LCD Mono Palette 5]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $2C
| [[Display#LCD Mono Palette|LCD Mono Palette 6]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $2E
| [[Display#LCD Mono Palette|LCD Mono Palette 7]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $30
| [[Display#LCD Mono Palette|LCD Mono Palette 8]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $32
| [[Display#LCD Mono Palette|LCD Mono Palette 9]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $34
| [[Display#LCD Mono Palette|LCD Mono Palette 10]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $36
| [[Display#LCD Mono Palette|LCD Mono Palette 11]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $38
| [[Display#LCD Mono Palette|LCD Mono Palette 12]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $3A
| [[Display#LCD Mono Palette|LCD Mono Palette 13]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $3C
| [[Display#LCD Mono Palette|LCD Mono Palette 14]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $3E
| [[Display#LCD Mono Palette|LCD Mono Palette 15]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! rowspan="10" | [[DMA]]<sup>(color)</sup>
! $40
| [[DMA#General DMA|GDMA Source Address Low]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll llll lll.</tt>
| RW16
| Linear address, low 16 bits (l)
|-
! $42
| [[DMA#General DMA|GDMA Source Address High]]
| style="text-align: right" | <tt style="white-space: nowrap">.... hhhh</tt>
| RW8
| Linear address, high 4 bits (h)
|-
! $44
| [[DMA#General DMA|GDMA Destination Address]]
| style="text-align: right" | <tt style="white-space: nowrap">aaaa aaaa aaaa aaa.</tt>
| RW16
| IRAM address (a)
|-
! $46
| [[DMA#General DMA|GDMA Length]]
| style="text-align: right" | <tt style="white-space: nowrap">bbbb bbbb bbbb bbb.</tt>
| RW16
| Bytes (b)
|-
! $48
| [[DMA#General DMA|GDMA Control]]
| style="text-align: right" | <tt style="white-space: nowrap">ed.. ....</tt>
| RW8
| Enable (e), Decrement (d)
|-
! $4A
| [[DMA#Sound DMA|SDMA Source Address Low]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll llll llll</tt>
| RW16
| Linear address, low 16 bits (l)
|-
! $4C
| [[DMA#Sound DMA|SDMA Source Address High]]
| style="text-align: right" | <tt style="white-space: nowrap">.... hhhh</tt>
| RW8
| Linear address, high 4 bits (h)
|-
! $4E
| [[DMA#Sound DMA|SDMA Length Low]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll llll llll</tt>
| RW16
| Length, low 16 bits (l)
|-
! $50
| [[DMA#Sound DMA|SDMA Length High]]
| style="text-align: right" | <tt style="white-space: nowrap">.... hhhh</tt>
| RW8
| Length, high 4 bits (h)
|-
! $52
| [[DMA#Sound DMA|SDMA Control]]
| style="text-align: right" | <tt style="white-space: nowrap">ed.t rhff</tt>
| RW8
| Enable (e), Decrement (d), Target (t),
Repeat (r), Hold (h), Frequency (f)
|-
! rowspan="2" | [[SoC]]<sup>(color)</sup>
! $60
| [[SoC#System Control 2|System Control 2]]
| style="text-align: right" | <tt style="white-space: nowrap">c4C. i?sl</tt>
| RW8
| Color (c), 4BPP (4), Chunky (C),<br/>
Cart I/O wait state (i), SRAM wait state (s),<br/>
Cart clock speed (l).
|-
! $62
| [[SoC#System Control 3|System Control 3]]
| style="text-align: right" | <tt style="white-space: nowrap">S... ...p</tt>
| RW8
| SwanCrystal (S), Power off (p)
|-
! rowspan="4" | [[Hyper Voice]]<sup>(color)</sup>
! $64
| [[Hyper Voice#Hyper Voice Output|Hyper Voice Left Output]]
| style="text-align: right" | <tt style="white-space: nowrap">ssss ssss ssss ssss</tt>
| W16
| Raw sample (s)
|-
! $66
| [[Hyper Voice#Hyper Voice Output|Hyper Voice Right Output]]
| style="text-align: right" | <tt style="white-space: nowrap">ssss ssss ssss ssss</tt>
| W16
| Raw sample (s)
|-
! $69
| [[Hyper Voice#Hyper Voice Input|Hyper Voice Right Input]]
| style="text-align: right" | <tt style="white-space: nowrap">ssss ssss</tt>
| W8
| Sample (s)
|-
! $6A
| [[Hyper Voice#Hyper Voice Control|Hyper Voice Control]]
| style="text-align: right" | <tt style="white-space: nowrap">.mmc ???? errr ffss</tt>
| RW16
| Mask (m), Channel reset (c), Enable (e),
Rate (r), Format (f), Shift (s)
|-
! rowspan="8" | [[Display]]<sup>(SC)</sup>
! $70
| LCD Timing Configuration 1?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $71
| LCD Timing Configuration 2?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $72
| LCD Timing Configuration 3?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $73
| LCD Timing Configuration 4?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $74
| LCD Timing Configuration 5?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $75
| LCD Timing Configuration 6?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $76
| LCD Timing Configuration 7?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $77
| LCD Timing Configuration 8?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! rowspan="22" | [[Sound]]
! $80
| [[Sound#Sound Channel Frequency|Sound Channel 1 Frequency]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .ddd dddd dddd</tt>
| RW16
| Divider (d)
|-
! $82
| [[Sound#Sound Channel Frequency|Sound Channel 2 Frequency]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .ddd dddd dddd</tt>
| RW16
| Divider (d)
|-
! $84
| [[Sound#Sound Channel Frequency|Sound Channel 3 Frequency]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .ddd dddd dddd</tt>
| RW16
| Divider (d)
|-
! $86
| [[Sound#Sound Channel Frequency|Sound Channel 4 Frequency]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .ddd dddd dddd</tt>
| RW16
| Divider (d)
|-
! $88
| [[Sound#Sound Channel Volume|Sound Channel 1 Volume]]
| style="text-align: right" | <tt style="white-space: nowrap">llll rrrr</tt>
| RW8
| Left (l), Right (r)
|-
! rowspan="2" | $89
| [[Sound#Sound Channel Volume|Sound Channel 2 Volume]]
| style="text-align: right" | <tt style="white-space: nowrap">llll rrrr</tt>
| RW8
| Left (l), Right (r)
|-
| [[Sound#Sound Channel 2 Voice Sample|Sound Channel 2 Voice Sample]]
| style="text-align: right" | <tt style="white-space: nowrap">ssss ssss</tt>
| RW8
| Sample (s)
|-
! $8A
| [[Sound#Sound Channel Volume|Sound Channel 3 Volume]]
| style="text-align: right" | <tt style="white-space: nowrap">llll rrrr</tt>
| RW8
| Left (l), Right (r)
|-
! $8B
| [[Sound#Sound Channel Volume|Sound Channel 4 Volume]]
| style="text-align: right" | <tt style="white-space: nowrap">llll rrrr</tt>
| RW8
| Left (l), Right (r)
|-
! $8C
| [[Sound#Sound Channel 3 Sweep Amount|Sound Channel 3 Sweep Amount]]
| style="text-align: right" | <tt style="white-space: nowrap">vvvv vvvv</tt>
| RW8
| Value (v)
|-
! $8D
| [[Sound#Sound Channel 3 Sweep Ticks|Sound Channel 3 Sweep Ticks]]
| style="text-align: right" | <tt style="white-space: nowrap">...t tttt</tt>
| RW8
| Ticks (t)
|-
! $8E
| [[Sound#Sound Channel 4 Noise Control|Sound Channel 4 Noise Control]]
| style="text-align: right" | <tt style="white-space: nowrap">...e rttt</tt>
| RW8
| Enable (e), Reset (r), Tap (t)
|-
! $8F
| [[Sound#Sound Wavetable Address|Sound Wavetable Address]]
| style="text-align: right" | <tt style="white-space: nowrap">wwww wwww</tt>
| RW8
| Address >> 6 (w)
|-
! $90
| [[Sound#Sound Channel Control|Sound Channel Control]]
| style="text-align: right" | <tt style="white-space: nowrap">nsv. 4321</tt>
| RW8
| Channel enable (1234)
Noise (n), Sweep (s), Voice (v)
|-
! $91
| [[Sound#Sound Output Control|Sound Output Control]]
| style="text-align: right" | <tt style="white-space: nowrap">H... hrrs</tt>
| RW8
| Headphones connected (H)
Headphone output (h)
Speaker output (s), range (r)
|-
! $92
| [[Sound#Sound Channel 4 LFSR Register|Sound Channel 4 LFSR Register]]
| style="text-align: right" | <tt style="white-space: nowrap">.rrr rrrr rrrr rrrr</tt>
| R16
| PRNG state (r)
|-
! $94
| [[Sound#Sound Channel 2 Voice Volume|Sound Channel 2 Voice Volume]]
| style="text-align: right" | <tt style="white-space: nowrap">.... lLrR</tt>
| RW8
| Left Half (l), Full (L)
Right Half (r), Full (R)
|-
! $95
| [[Sound#Sound Test|Sound Test]]
| style="text-align: right" | <tt style="white-space: nowrap">425? ???h</tt>
| RW8
|
|-
! $96
| Sound Channel Output Right
| style="text-align: right" | <tt style="white-space: nowrap">.... ..ss ssss ssss</tt>
| R16
| Sample (s)
|-
! $98
| Sound Channel Output Left
| style="text-align: right" | <tt style="white-space: nowrap">.... ..ss ssss ssss</tt>
| R16
| Sample (s)
|-
! $9A
| Sound Channel Output Sum
| style="text-align: right" | <tt style="white-space: nowrap">.... .sss ssss ssss</tt>
| R16
| Sample (s)
|-
! $9E
| Sound Speaker Main Volume<sup>(color)</sup>
| style="text-align: right" | <tt style="white-space: nowrap">.... ..vv</tt>
| RW8
| Main volume (v)
|-
! [[SoC]]
! $A0
| [[SoC#System Control|System Control]]
| style="text-align: right" | <tt style="white-space: nowrap">t??? swcl</tt>
| RW8
| Test OK (t), ROM wait state (s), ROM width (w),
Color system (c), Boot ROM lockout (l)
|-
! rowspan="5" | [[Timers]]
! $A2
| [[Timers#Timer Control|Timer Control]]
| style="text-align: right" | <tt style="white-space: nowrap">.... VvHh</tt>
| RW8
| Horizontal enable (h), auto reload (H)
Vertical enable (v), auto reload (V)
|-
! $A4
| [[Timers#Timer Reload|Horizontal Blank Timer Reload]]
| style="text-align: right" | <tt style="white-space: nowrap">tttt tttt tttt tttt</tt>
| RW16
| Ticks (t)
|-
! $A6
| [[Timers#Timer Reload|Vertical Blank Timer Reload]]
| style="text-align: right" | <tt style="white-space: nowrap">tttt tttt tttt tttt</tt>
| RW16
| Ticks (t)
|-
! $A8
| [[Timers#Timer Counter|Horizontal Blank Timer Counter]]
| style="text-align: right" | <tt style="white-space: nowrap">tttt tttt tttt tttt</tt>
| R16
| Ticks (t)
|-
! $AA
| [[Timers#Timer Counter|Vertical Blank Timer Counter]]
| style="text-align: right" | <tt style="white-space: nowrap">tttt tttt tttt tttt</tt>
| R16
| Ticks (t)
|-
! ?
! $AC
| ?
| style="text-align: right" | <tt style="white-space: nowrap">.... ...p</tt>
| W8?
| Power off (p)
|-
! rowspan="2" | [[Interrupts]]
! rowspan="2" | $B0
| [[Interrupts#Interrupt Vector Offset|Interrupt Vector Offset]]
| style="text-align: right" | <tt style="white-space: nowrap">VVVV V...</tt>
| W8
| Vector offset (V)
|-
| [[Interrupts#Interrupt Vector Request|Interrupt Vector Request]]
| style="text-align: right" | <tt style="white-space: nowrap">vvvv vvvv</tt>
| R8
| Requested vector offset (v)
|-
! rowspan="2" | [[UART]]
! $B1
| [[UART#Serial Receive Data|Serial Receive Data]]
| style="text-align: right" | <tt style="white-space: nowrap">dddd dddd</tt>
| R8
| Receive buffer data (d)
|-
! $B1
| [[UART#Serial Transmit Data|Serial Transmit Data]]
| style="text-align: right" | <tt style="white-space: nowrap">dddd dddd</tt>
| W8
| Transmit buffer data (d)
|-
! [[Interrupts]]
! $B2
| [[Interrupts#Interrupt Enable|Interrupt Enable]]
| style="text-align: right" | <tt style="white-space: nowrap">iiii iiii</tt>
| RW8
| Interrupt index (i)
|-
! rowspan="2" | [[UART]]
! $B3
| [[UART#Serial Status|Serial Status]]
| style="text-align: right" | <tt style="white-space: nowrap">eb.. .tor</tt>
| R8
| Enable (e), Baud rate (b),
Transfer ready (t), Overrun (o), Receive ready (r)
|-
! $B3
| [[UART#Serial Control|Serial Control]]
| style="text-align: right" | <tt style="white-space: nowrap">ebO. ....</tt>
| W8
| Enable (e), Baud rate (b), Reset Overrun (O)
|-
! [[Interrupts]]
! $B4
| [[Interrupts#Interrupt Status|Interrupt Status]]
| style="text-align: right" | <tt style="white-space: nowrap">iiii iiii</tt>
| R8
| Interrupt index (i)
|-
! [[Keypad]]
! $B5
| [[Keypad|Keypad Scan]]
| style="text-align: right" | <tt style="white-space: nowrap">.iii oooo</tt>
| RW8
| Input row (i), Output column (o)
|-
! rowspan="2" | [[Interrupts]]
! $B6
| [[Interrupts#Interrupt Acknowledge|Interrupt Acknowledge]]
| style="text-align: right" | <tt style="white-space: nowrap">iiii iiii</tt>
| W8
| Interrupt index (i)
|-
! $B7
| [[Interrupts#Interrupt NMI Control|Interrupt NMI Control]]
| style="text-align: right" | <tt style="white-space: nowrap">...b ....</tt>
| RW8
| Low battery (b)
|-
! rowspan="4" | [[EEPROM|Internal EEPROM]]
! $BA
| [[EEPROM#Internal EEPROM Data|Internal EEPROM Data]]
| style="text-align: right" | <tt style="white-space: nowrap">dddd dddd dddd dddd</tt>
| RW16
| Data (d)
|-
! $BC
| [[EEPROM#Internal EEPROM Command|Internal EEPROM Command]]
|
| RW16
|
|-
! rowspan="2" | $BE
| [[EEPROM#Internal EEPROM Status|Internal EEPROM Status]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .... p... ..RD</tt>
| R16
| Protected (p), Ready (R), Done (D)
|-
| [[EEPROM#Internal EEPROM Control|Internal EEPROM Control]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .... pewr ....</tt>
| W16
| Protect (p), Erase (e), Write (w), Read (r)
|-
! [[Mapper|Cartridge]]
! $C0<br />...<br />
$FF
| Cartridge I/O
|
| RW8
| Forwarded by the SoC
|}
== I/O port routing ==
The [[NEC V30MZ]] supports 16-bit I/O port addresses. The WonderSwan SoC routes them using the following algorithm:
* If an address is between <code>$00B8</code> and <code>$00BF</code> inclusive, it is routed to the internal EEPROM control block.
* If an address is between <code>$00C0</code> and <code>$00FF</code> inclusive, it is routed to the cartride bus.
* If an address's bits <code>0</code> through <code>8</code> inclusive are between <code>$000</code> and <code>$0B7</code> inclusive, they are routed to the SoC block.
* If none of these conditions are reached, open bus is read.
On the monochrome models, as well as color models in mono emulation, open bus is always <code>0x90</code>.
99731c1f55ad1d1f4f7212628a781d130350fdfb
Sound
0
27
269
209
2024-03-24T13:54:46Z
Asie
351
wikitext
text/x-wiki
The WonderSwan features the following sound hardware:
* Four audio channels:
** channel 1 - wavetable (32 x 4-bit samples),
** channel 2 - wavetable or 8-bit unsigned PCM sample,
** channel 3 - wavetable with optional hardware sweep,
** channel 4 - wavetable or LFSR noise,
* [[Hyper Voice]]<sup>(color)</sup> - headphone output exclusive 16-bit stereo PCM output,
* 24000 Hz output:
** internal speaker - 8-bit, mono,
** headphone output - 16-bit, stereo.
[[Hyper Voice]] functionality is documented on its own sub-page.
== Mixing diagram ==
The sound is mixed as follows:
<pre>
Ch1 Ch2 Ch3 Ch4 Glossary: L = left, R = right, M = mono
| | | | Mnn = nn-bit mono
8 8 8 8 port $98 port $nn = value port
| | | | /
_V___V___V___V_ / _____ _____
| |--L10------+----->| | | |
| + | | | + |--M11-->| >>r |--M8--> Speaker output
|_______________|--R10------|-+--->|_____| / |_____|
/ _|_|_ / (r=0...3)
/ | | / \
port $96 | <<5 | port $9A \
|_____| \
| | port $91
| |
port $68 port $64 | |
/ _______________ \ __V_V__ _____
L8-->| (Color only) |--L16-->| |----------L16-->| |
| Hyper Voice | | + + | | I2S |------> Headphone output
R8-->|_______________|--R16-->|_______|----------R16-->|_____|
\ /
port $69 port $66
</pre>
== I/O Ports ==
{{Anchor|Sound Channel Frequency}}
=== Sound Channel Frequency ($80, $81; $82, $83; $84, $85; $86, $87) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
.... .ddd dddd dddd
||| |||| ||||
+++--++++-++++- Frequency divisor
</pre>
This frequency is used for wavetable output. It is calculated as follows: <code>sample rate = 3072000 Hz / (2048 - divisor)</code>.
Note that this refers to the sample rate of the ''wavetable'', and needs to be scaled accordingly for a given waveform when performing music playback.
{{Anchor|Sound Channel Volume}}
=== Sound Channel Volume ($88; $89; $8A; $8B) ===
<pre>
7 bit 0
---------
llll rrrr
|||| ||||
|||| ++++- Right channel volume (0-15)
++++------ Left channel volume (0-15)
</pre>
This volume is used for wavetable output.
The calculation to get an unsigned 8-bit sample out of a 4-bit wavetable sample / 4-bit volume pair is simple: <code>out_sample = sample * volume</code>. This means that the maximum sample in wavetable output mode is <code>15 * 15 = 225</code>.
{{Anchor|Sound Channel 2 Voice Sample}}
=== Sound Channel 2 Voice Sample ($89) ===
<pre>
7 bit 0
---- ----
ssss ssss
|||| ||||
++++-++++- Unsigned 8-bit PCM sample (0-255)
</pre>
This sample is used for voice output.
{{Anchor|Sound Channel 3 Sweep Amount}}
=== Sound Channel 3 Sweep Amount ($8C) ===
<pre>
7 bit 0
---- ----
vvvv vvvv
|||| ||||
++++-++++- Value; 8-bit, signed.
</pre>
This port is used for wavetable output with sweep enabled.
The signed value in this port will be added to the frequency divider for channel 3 every sweep step (as determined by the Sweep Ticks port). Wraparound is present - adding 1 to a frequency divider value of 2047 will cause it to roll over back to 0.
{{Anchor|Sound Channel 3 Sweep Ticks}}
=== Sound Channel 3 Sweep Ticks ($8D) ===
<pre>
7 bit 0
---- ----
...t tttt
| ||||
+-++++- Ticks per step - 1
</pre>
This port is used for wavetable output with sweep enabled.
Every <code>ttttt + 1</code> ticks, clocked at 375 Hz, the value in the Sweep Amount port will be added to the frequency divider for channel 3.
{{Anchor|Sound Channel 4 Noise Control}}
=== Sound Channel 4 Noise Control ($8E) ===
<pre>
7 bit 0
---- ----
...e rttt
| ||||
| |+++- LFSR tap mode
| +---- LFSR reset: 1 = reset shift register
+------ LFSR enabled: 0 = off, 1 = on
</pre>
This port is used for noise output.
{| class="wikitable"
|+ List of LFSR tap modes
! Tap mode
! Tap bit
! Sequence length
|-
| 0
| 14
| 32767
|-
| 1
| 10
| 1953
|-
| 2
| 13
| 254
|-
| 3
| 4
| 217
|-
| 4
| 8
| 73
|-
| 5
| 6
| 63
|-
| 6
| 9
| 42
|-
| 7
| 11
| 28
|}
Noise output works using the following algorithm, performed once per sample generated:
# Create a new bit by XORing bit 7 with the tap bit.
# Shift the LFSR register one bit to the left.
# Write the new bit as bit 0.
# Use the new bit as if it were a wavetable sample: 0 = 0, 1 = 15.
{{Anchor|Sound Wavetable Address}}
=== Sound Wavetable Address ($8F) ===
<pre>
7 bit 0
---- ----
wwww wwww
|||| ||||
++++-++++- Wavetable address (bits 6-13)
</pre>
The wavetable is 4 x 16 bytes long; each 16-byte block contains 32 4-bit samples for the relevant channel:
<pre>
Address $00 $01 $02 $03 $04 $05 $06 $07 $08 $09 $0A $0B $0C $0D $0E $0F
98 CB ED FF FF EF BD 8A 57 24 01 00 00 21 43 76
Sample
15 .. .. .. ## ## #. .. .. .. .. .. .. .. .. .. ..
14 .. .. .# || || |# .. .. .. .. .. .. .. .. .. ..
13 .. .. #| || || || #. .. .. .. .. .. .. .. .. ..
12 .. .# || || || || |. .. .. .. .. .. .. .. .. ..
11 .. #| || || || || |# .. .. .. .. .. .. .. .. ..
10 .. || || || || || || #. .. .. .. .. .. .. .. ..
9 .# || || || || || || |. .. .. .. .. .. .. .. ..
8 #| || || || || || || |# .. .. .. .. .. .. .. ..
7 || || || || || || || || #. .. .. .. .. .. .. .#
6 || || || || || || || || |. .. .. .. .. .. .. #|
5 || || || || || || || || |# .. .. .. .. .. .. ||
4 || || || || || || || || || #. .. .. .. .. .# ||
3 || || || || || || || || || |. .. .. .. .. #| ||
2 || || || || || || || || || |# .. .. .. .# || ||
1 || || || || || || || || || || #. .. .. #| || ||
0 || || || || || || || || || || |# ## ## || || ||
</pre>
Note that the ''higher'' bits - the first hexadecimal number - specify the ''later'' samples; that is to say, the nybbles of each sample are swapped relative to the wave drawing.
{{Anchor|Sound Channel Control}}
=== Sound Channel Control ($90) ===
<pre>
7 bit 0
---- ----
nsv. 4321
||| ||||
||| |||+- Channel 1 enable
||| ||+-- Channel 2 enable
||| |+--- Channel 3 enable
||| +---- Channel 4 enable
||+------- Channel 2 mode: 0 = wavetable, 1 = voice
|+-------- Channel 3 sweep: 0 = disable, 1 = enable
+--------- Channel 4 mode: 0 = wavetable, 1 = noise
</pre>
{{Anchor|Sound Output Control}}
=== Sound Output Control ($91) ===
<pre>
7 bit 0
---- ----
H... hrrs
| ||||
| |||+- Internal speaker output enable
| |++-- Internal speaker shift right value
| +---- Headphone output enable
+--------- Headphones connected: 1 if true
</pre>
It is a good idea to set the internal speaker shift right value correctly. If the value is too low, multi-channel music will clip; if the value is too high, single-channel PCM sample playback will be very quiet.
{{Anchor|Sound Channel 4 LFSR Register}}
=== Sound Channel 4 LFSR Register ($92, $93 read) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
.rrr rrrr rrrr rrrr
||| |||| |||| ||||
+++-++++--++++-++++- Shift register value
</pre>
{{Anchor|Sound Channel 2 Voice Volume}}
=== Sound Channel 2 Voice Volume ($94) ===
<pre>
7 bit 0
---- ----
.... lLrR
||||
|||+- Right channel 100% volume
||+-- Right channel 50% volume
|+--- Left channel 100% volume
+---- Left channel 50% volume
</pre>
This port is used for voice output.
The <code>50% volume</code> have no effect if their respective <code>100% volume</code> bits are set.
{{Anchor|Sound Test}}
=== Sound Test ($95) ===
<pre>
7 bit 0
---- ----
425? ???h
||| |
||| +- Hold Ch1-4 output updates
||+------- Force L10/R10 outputs to 0x55
|+-------- Force Ch1-4 outputs to 0x02
+--------- Force Ch1-4 outputs to 0x044
</pre>
{{Anchor|Sound Channel Output Right}}
=== Sound Channel Output Right ($96, $97 read) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
.... ..ss ssss ssss
|| |||| ||||
++--++++-++++- Unsigned 10-bit sample
</pre>
{{Anchor|Sound Channel Output Left}}
=== Sound Channel Output Left ($98, $99 read) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
.... ..ss ssss ssss
|| |||| ||||
++--++++-++++- Unsigned 10-bit sample
</pre>
{{Anchor|Sound Channel Output Sum}}
=== Sound Channel Output Sum ($9A, $9B read) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
.... .sss ssss ssss
||| |||| ||||
+++--++++-++++- Unsigned 11-bit sample
</pre>
17ccfd4bbc171ffdb0b9b44207716c1c8152277a
270
269
2024-03-24T13:54:57Z
Asie
351
/* Sound Test ($95) */
wikitext
text/x-wiki
The WonderSwan features the following sound hardware:
* Four audio channels:
** channel 1 - wavetable (32 x 4-bit samples),
** channel 2 - wavetable or 8-bit unsigned PCM sample,
** channel 3 - wavetable with optional hardware sweep,
** channel 4 - wavetable or LFSR noise,
* [[Hyper Voice]]<sup>(color)</sup> - headphone output exclusive 16-bit stereo PCM output,
* 24000 Hz output:
** internal speaker - 8-bit, mono,
** headphone output - 16-bit, stereo.
[[Hyper Voice]] functionality is documented on its own sub-page.
== Mixing diagram ==
The sound is mixed as follows:
<pre>
Ch1 Ch2 Ch3 Ch4 Glossary: L = left, R = right, M = mono
| | | | Mnn = nn-bit mono
8 8 8 8 port $98 port $nn = value port
| | | | /
_V___V___V___V_ / _____ _____
| |--L10------+----->| | | |
| + | | | + |--M11-->| >>r |--M8--> Speaker output
|_______________|--R10------|-+--->|_____| / |_____|
/ _|_|_ / (r=0...3)
/ | | / \
port $96 | <<5 | port $9A \
|_____| \
| | port $91
| |
port $68 port $64 | |
/ _______________ \ __V_V__ _____
L8-->| (Color only) |--L16-->| |----------L16-->| |
| Hyper Voice | | + + | | I2S |------> Headphone output
R8-->|_______________|--R16-->|_______|----------R16-->|_____|
\ /
port $69 port $66
</pre>
== I/O Ports ==
{{Anchor|Sound Channel Frequency}}
=== Sound Channel Frequency ($80, $81; $82, $83; $84, $85; $86, $87) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
.... .ddd dddd dddd
||| |||| ||||
+++--++++-++++- Frequency divisor
</pre>
This frequency is used for wavetable output. It is calculated as follows: <code>sample rate = 3072000 Hz / (2048 - divisor)</code>.
Note that this refers to the sample rate of the ''wavetable'', and needs to be scaled accordingly for a given waveform when performing music playback.
{{Anchor|Sound Channel Volume}}
=== Sound Channel Volume ($88; $89; $8A; $8B) ===
<pre>
7 bit 0
---------
llll rrrr
|||| ||||
|||| ++++- Right channel volume (0-15)
++++------ Left channel volume (0-15)
</pre>
This volume is used for wavetable output.
The calculation to get an unsigned 8-bit sample out of a 4-bit wavetable sample / 4-bit volume pair is simple: <code>out_sample = sample * volume</code>. This means that the maximum sample in wavetable output mode is <code>15 * 15 = 225</code>.
{{Anchor|Sound Channel 2 Voice Sample}}
=== Sound Channel 2 Voice Sample ($89) ===
<pre>
7 bit 0
---- ----
ssss ssss
|||| ||||
++++-++++- Unsigned 8-bit PCM sample (0-255)
</pre>
This sample is used for voice output.
{{Anchor|Sound Channel 3 Sweep Amount}}
=== Sound Channel 3 Sweep Amount ($8C) ===
<pre>
7 bit 0
---- ----
vvvv vvvv
|||| ||||
++++-++++- Value; 8-bit, signed.
</pre>
This port is used for wavetable output with sweep enabled.
The signed value in this port will be added to the frequency divider for channel 3 every sweep step (as determined by the Sweep Ticks port). Wraparound is present - adding 1 to a frequency divider value of 2047 will cause it to roll over back to 0.
{{Anchor|Sound Channel 3 Sweep Ticks}}
=== Sound Channel 3 Sweep Ticks ($8D) ===
<pre>
7 bit 0
---- ----
...t tttt
| ||||
+-++++- Ticks per step - 1
</pre>
This port is used for wavetable output with sweep enabled.
Every <code>ttttt + 1</code> ticks, clocked at 375 Hz, the value in the Sweep Amount port will be added to the frequency divider for channel 3.
{{Anchor|Sound Channel 4 Noise Control}}
=== Sound Channel 4 Noise Control ($8E) ===
<pre>
7 bit 0
---- ----
...e rttt
| ||||
| |+++- LFSR tap mode
| +---- LFSR reset: 1 = reset shift register
+------ LFSR enabled: 0 = off, 1 = on
</pre>
This port is used for noise output.
{| class="wikitable"
|+ List of LFSR tap modes
! Tap mode
! Tap bit
! Sequence length
|-
| 0
| 14
| 32767
|-
| 1
| 10
| 1953
|-
| 2
| 13
| 254
|-
| 3
| 4
| 217
|-
| 4
| 8
| 73
|-
| 5
| 6
| 63
|-
| 6
| 9
| 42
|-
| 7
| 11
| 28
|}
Noise output works using the following algorithm, performed once per sample generated:
# Create a new bit by XORing bit 7 with the tap bit.
# Shift the LFSR register one bit to the left.
# Write the new bit as bit 0.
# Use the new bit as if it were a wavetable sample: 0 = 0, 1 = 15.
{{Anchor|Sound Wavetable Address}}
=== Sound Wavetable Address ($8F) ===
<pre>
7 bit 0
---- ----
wwww wwww
|||| ||||
++++-++++- Wavetable address (bits 6-13)
</pre>
The wavetable is 4 x 16 bytes long; each 16-byte block contains 32 4-bit samples for the relevant channel:
<pre>
Address $00 $01 $02 $03 $04 $05 $06 $07 $08 $09 $0A $0B $0C $0D $0E $0F
98 CB ED FF FF EF BD 8A 57 24 01 00 00 21 43 76
Sample
15 .. .. .. ## ## #. .. .. .. .. .. .. .. .. .. ..
14 .. .. .# || || |# .. .. .. .. .. .. .. .. .. ..
13 .. .. #| || || || #. .. .. .. .. .. .. .. .. ..
12 .. .# || || || || |. .. .. .. .. .. .. .. .. ..
11 .. #| || || || || |# .. .. .. .. .. .. .. .. ..
10 .. || || || || || || #. .. .. .. .. .. .. .. ..
9 .# || || || || || || |. .. .. .. .. .. .. .. ..
8 #| || || || || || || |# .. .. .. .. .. .. .. ..
7 || || || || || || || || #. .. .. .. .. .. .. .#
6 || || || || || || || || |. .. .. .. .. .. .. #|
5 || || || || || || || || |# .. .. .. .. .. .. ||
4 || || || || || || || || || #. .. .. .. .. .# ||
3 || || || || || || || || || |. .. .. .. .. #| ||
2 || || || || || || || || || |# .. .. .. .# || ||
1 || || || || || || || || || || #. .. .. #| || ||
0 || || || || || || || || || || |# ## ## || || ||
</pre>
Note that the ''higher'' bits - the first hexadecimal number - specify the ''later'' samples; that is to say, the nybbles of each sample are swapped relative to the wave drawing.
{{Anchor|Sound Channel Control}}
=== Sound Channel Control ($90) ===
<pre>
7 bit 0
---- ----
nsv. 4321
||| ||||
||| |||+- Channel 1 enable
||| ||+-- Channel 2 enable
||| |+--- Channel 3 enable
||| +---- Channel 4 enable
||+------- Channel 2 mode: 0 = wavetable, 1 = voice
|+-------- Channel 3 sweep: 0 = disable, 1 = enable
+--------- Channel 4 mode: 0 = wavetable, 1 = noise
</pre>
{{Anchor|Sound Output Control}}
=== Sound Output Control ($91) ===
<pre>
7 bit 0
---- ----
H... hrrs
| ||||
| |||+- Internal speaker output enable
| |++-- Internal speaker shift right value
| +---- Headphone output enable
+--------- Headphones connected: 1 if true
</pre>
It is a good idea to set the internal speaker shift right value correctly. If the value is too low, multi-channel music will clip; if the value is too high, single-channel PCM sample playback will be very quiet.
{{Anchor|Sound Channel 4 LFSR Register}}
=== Sound Channel 4 LFSR Register ($92, $93 read) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
.rrr rrrr rrrr rrrr
||| |||| |||| ||||
+++-++++--++++-++++- Shift register value
</pre>
{{Anchor|Sound Channel 2 Voice Volume}}
=== Sound Channel 2 Voice Volume ($94) ===
<pre>
7 bit 0
---- ----
.... lLrR
||||
|||+- Right channel 100% volume
||+-- Right channel 50% volume
|+--- Left channel 100% volume
+---- Left channel 50% volume
</pre>
This port is used for voice output.
The <code>50% volume</code> have no effect if their respective <code>100% volume</code> bits are set.
{{Anchor|Sound Test}}
=== Sound Test ($95) ===
<pre>
7 bit 0
---- ----
425? ???h
||| |
||| +- Hold Ch1-4 output updates
||+------- Force L10/R10 outputs to 0x55
|+-------- Force Ch1-4 outputs to 0x02
+--------- Force Ch1-4 outputs to 0x04
</pre>
{{Anchor|Sound Channel Output Right}}
=== Sound Channel Output Right ($96, $97 read) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
.... ..ss ssss ssss
|| |||| ||||
++--++++-++++- Unsigned 10-bit sample
</pre>
{{Anchor|Sound Channel Output Left}}
=== Sound Channel Output Left ($98, $99 read) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
.... ..ss ssss ssss
|| |||| ||||
++--++++-++++- Unsigned 10-bit sample
</pre>
{{Anchor|Sound Channel Output Sum}}
=== Sound Channel Output Sum ($9A, $9B read) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
.... .sss ssss ssss
||| |||| ||||
+++--++++-++++- Unsigned 11-bit sample
</pre>
7bfa225ec5268c76098d51426e8de0704567eb35
275
270
2024-04-03T16:18:51Z
Asie
351
/* Sound Output Control ($91) */
wikitext
text/x-wiki
The WonderSwan features the following sound hardware:
* Four audio channels:
** channel 1 - wavetable (32 x 4-bit samples),
** channel 2 - wavetable or 8-bit unsigned PCM sample,
** channel 3 - wavetable with optional hardware sweep,
** channel 4 - wavetable or LFSR noise,
* [[Hyper Voice]]<sup>(color)</sup> - headphone output exclusive 16-bit stereo PCM output,
* 24000 Hz output:
** internal speaker - 8-bit, mono,
** headphone output - 16-bit, stereo.
[[Hyper Voice]] functionality is documented on its own sub-page.
== Mixing diagram ==
The sound is mixed as follows:
<pre>
Ch1 Ch2 Ch3 Ch4 Glossary: L = left, R = right, M = mono
| | | | Mnn = nn-bit mono
8 8 8 8 port $98 port $nn = value port
| | | | /
_V___V___V___V_ / _____ _____
| |--L10------+----->| | | |
| + | | | + |--M11-->| >>r |--M8--> Speaker output
|_______________|--R10------|-+--->|_____| / |_____|
/ _|_|_ / (r=0...3)
/ | | / \
port $96 | <<5 | port $9A \
|_____| \
| | port $91
| |
port $68 port $64 | |
/ _______________ \ __V_V__ _____
L8-->| (Color only) |--L16-->| |----------L16-->| |
| Hyper Voice | | + + | | I2S |------> Headphone output
R8-->|_______________|--R16-->|_______|----------R16-->|_____|
\ /
port $69 port $66
</pre>
== I/O Ports ==
{{Anchor|Sound Channel Frequency}}
=== Sound Channel Frequency ($80, $81; $82, $83; $84, $85; $86, $87) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
.... .ddd dddd dddd
||| |||| ||||
+++--++++-++++- Frequency divisor
</pre>
This frequency is used for wavetable output. It is calculated as follows: <code>sample rate = 3072000 Hz / (2048 - divisor)</code>.
Note that this refers to the sample rate of the ''wavetable'', and needs to be scaled accordingly for a given waveform when performing music playback.
{{Anchor|Sound Channel Volume}}
=== Sound Channel Volume ($88; $89; $8A; $8B) ===
<pre>
7 bit 0
---------
llll rrrr
|||| ||||
|||| ++++- Right channel volume (0-15)
++++------ Left channel volume (0-15)
</pre>
This volume is used for wavetable output.
The calculation to get an unsigned 8-bit sample out of a 4-bit wavetable sample / 4-bit volume pair is simple: <code>out_sample = sample * volume</code>. This means that the maximum sample in wavetable output mode is <code>15 * 15 = 225</code>.
{{Anchor|Sound Channel 2 Voice Sample}}
=== Sound Channel 2 Voice Sample ($89) ===
<pre>
7 bit 0
---- ----
ssss ssss
|||| ||||
++++-++++- Unsigned 8-bit PCM sample (0-255)
</pre>
This sample is used for voice output.
{{Anchor|Sound Channel 3 Sweep Amount}}
=== Sound Channel 3 Sweep Amount ($8C) ===
<pre>
7 bit 0
---- ----
vvvv vvvv
|||| ||||
++++-++++- Value; 8-bit, signed.
</pre>
This port is used for wavetable output with sweep enabled.
The signed value in this port will be added to the frequency divider for channel 3 every sweep step (as determined by the Sweep Ticks port). Wraparound is present - adding 1 to a frequency divider value of 2047 will cause it to roll over back to 0.
{{Anchor|Sound Channel 3 Sweep Ticks}}
=== Sound Channel 3 Sweep Ticks ($8D) ===
<pre>
7 bit 0
---- ----
...t tttt
| ||||
+-++++- Ticks per step - 1
</pre>
This port is used for wavetable output with sweep enabled.
Every <code>ttttt + 1</code> ticks, clocked at 375 Hz, the value in the Sweep Amount port will be added to the frequency divider for channel 3.
{{Anchor|Sound Channel 4 Noise Control}}
=== Sound Channel 4 Noise Control ($8E) ===
<pre>
7 bit 0
---- ----
...e rttt
| ||||
| |+++- LFSR tap mode
| +---- LFSR reset: 1 = reset shift register
+------ LFSR enabled: 0 = off, 1 = on
</pre>
This port is used for noise output.
{| class="wikitable"
|+ List of LFSR tap modes
! Tap mode
! Tap bit
! Sequence length
|-
| 0
| 14
| 32767
|-
| 1
| 10
| 1953
|-
| 2
| 13
| 254
|-
| 3
| 4
| 217
|-
| 4
| 8
| 73
|-
| 5
| 6
| 63
|-
| 6
| 9
| 42
|-
| 7
| 11
| 28
|}
Noise output works using the following algorithm, performed once per sample generated:
# Create a new bit by XORing bit 7 with the tap bit.
# Shift the LFSR register one bit to the left.
# Write the new bit as bit 0.
# Use the new bit as if it were a wavetable sample: 0 = 0, 1 = 15.
{{Anchor|Sound Wavetable Address}}
=== Sound Wavetable Address ($8F) ===
<pre>
7 bit 0
---- ----
wwww wwww
|||| ||||
++++-++++- Wavetable address (bits 6-13)
</pre>
The wavetable is 4 x 16 bytes long; each 16-byte block contains 32 4-bit samples for the relevant channel:
<pre>
Address $00 $01 $02 $03 $04 $05 $06 $07 $08 $09 $0A $0B $0C $0D $0E $0F
98 CB ED FF FF EF BD 8A 57 24 01 00 00 21 43 76
Sample
15 .. .. .. ## ## #. .. .. .. .. .. .. .. .. .. ..
14 .. .. .# || || |# .. .. .. .. .. .. .. .. .. ..
13 .. .. #| || || || #. .. .. .. .. .. .. .. .. ..
12 .. .# || || || || |. .. .. .. .. .. .. .. .. ..
11 .. #| || || || || |# .. .. .. .. .. .. .. .. ..
10 .. || || || || || || #. .. .. .. .. .. .. .. ..
9 .# || || || || || || |. .. .. .. .. .. .. .. ..
8 #| || || || || || || |# .. .. .. .. .. .. .. ..
7 || || || || || || || || #. .. .. .. .. .. .. .#
6 || || || || || || || || |. .. .. .. .. .. .. #|
5 || || || || || || || || |# .. .. .. .. .. .. ||
4 || || || || || || || || || #. .. .. .. .. .# ||
3 || || || || || || || || || |. .. .. .. .. #| ||
2 || || || || || || || || || |# .. .. .. .# || ||
1 || || || || || || || || || || #. .. .. #| || ||
0 || || || || || || || || || || |# ## ## || || ||
</pre>
Note that the ''higher'' bits - the first hexadecimal number - specify the ''later'' samples; that is to say, the nybbles of each sample are swapped relative to the wave drawing.
{{Anchor|Sound Channel Control}}
=== Sound Channel Control ($90) ===
<pre>
7 bit 0
---- ----
nsv. 4321
||| ||||
||| |||+- Channel 1 enable
||| ||+-- Channel 2 enable
||| |+--- Channel 3 enable
||| +---- Channel 4 enable
||+------- Channel 2 mode: 0 = wavetable, 1 = voice
|+-------- Channel 3 sweep: 0 = disable, 1 = enable
+--------- Channel 4 mode: 0 = wavetable, 1 = noise
</pre>
{{Anchor|Sound Output Control}}
=== Sound Output Control ($91) ===
<pre>
7 bit 0
---- ----
H... hrrs
| ||||
| |||+- Internal speaker output enable
| |++-- Internal speaker shift/volume:
| | 0 = 100% 1 = 50%
| | 2 = 25% 3 = 12.5%
| +---- Headphone output enable
+--------- Headphones connected, 1 if true
</pre>
For correct playback on the internal speaker, it is important to set the shift/volume correctly, to match the peak summed output of the first four channels. If the value is too low, music using multiple loud channels will wrap, causing audible distortion. If the value is too high, single-channel PCM sample playback will be very quiet.
{{Anchor|Sound Channel 4 LFSR Register}}
=== Sound Channel 4 LFSR Register ($92, $93 read) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
.rrr rrrr rrrr rrrr
||| |||| |||| ||||
+++-++++--++++-++++- Shift register value
</pre>
{{Anchor|Sound Channel 2 Voice Volume}}
=== Sound Channel 2 Voice Volume ($94) ===
<pre>
7 bit 0
---- ----
.... lLrR
||||
|||+- Right channel 100% volume
||+-- Right channel 50% volume
|+--- Left channel 100% volume
+---- Left channel 50% volume
</pre>
This port is used for voice output.
The <code>50% volume</code> have no effect if their respective <code>100% volume</code> bits are set.
{{Anchor|Sound Test}}
=== Sound Test ($95) ===
<pre>
7 bit 0
---- ----
425? ???h
||| |
||| +- Hold Ch1-4 output updates
||+------- Force L10/R10 outputs to 0x55
|+-------- Force Ch1-4 outputs to 0x02
+--------- Force Ch1-4 outputs to 0x04
</pre>
{{Anchor|Sound Channel Output Right}}
=== Sound Channel Output Right ($96, $97 read) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
.... ..ss ssss ssss
|| |||| ||||
++--++++-++++- Unsigned 10-bit sample
</pre>
{{Anchor|Sound Channel Output Left}}
=== Sound Channel Output Left ($98, $99 read) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
.... ..ss ssss ssss
|| |||| ||||
++--++++-++++- Unsigned 10-bit sample
</pre>
{{Anchor|Sound Channel Output Sum}}
=== Sound Channel Output Sum ($9A, $9B read) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
.... .sss ssss ssss
||| |||| ||||
+++--++++-++++- Unsigned 11-bit sample
</pre>
a7c78b145a8ea8b8c9116407d5812cbf857c4d9b
276
275
2024-04-03T16:44:09Z
Asie
351
/* Sound Test ($95) */ document bits 1, 2, 3
wikitext
text/x-wiki
The WonderSwan features the following sound hardware:
* Four audio channels:
** channel 1 - wavetable (32 x 4-bit samples),
** channel 2 - wavetable or 8-bit unsigned PCM sample,
** channel 3 - wavetable with optional hardware sweep,
** channel 4 - wavetable or LFSR noise,
* [[Hyper Voice]]<sup>(color)</sup> - headphone output exclusive 16-bit stereo PCM output,
* 24000 Hz output:
** internal speaker - 8-bit, mono,
** headphone output - 16-bit, stereo.
[[Hyper Voice]] functionality is documented on its own sub-page.
== Mixing diagram ==
The sound is mixed as follows:
<pre>
Ch1 Ch2 Ch3 Ch4 Glossary: L = left, R = right, M = mono
| | | | Mnn = nn-bit mono
8 8 8 8 port $98 port $nn = value port
| | | | /
_V___V___V___V_ / _____ _____
| |--L10------+----->| | | |
| + | | | + |--M11-->| >>r |--M8--> Speaker output
|_______________|--R10------|-+--->|_____| / |_____|
/ _|_|_ / (r=0...3)
/ | | / \
port $96 | <<5 | port $9A \
|_____| \
| | port $91
| |
port $68 port $64 | |
/ _______________ \ __V_V__ _____
L8-->| (Color only) |--L16-->| |----------L16-->| |
| Hyper Voice | | + + | | I2S |------> Headphone output
R8-->|_______________|--R16-->|_______|----------R16-->|_____|
\ /
port $69 port $66
</pre>
== I/O Ports ==
{{Anchor|Sound Channel Frequency}}
=== Sound Channel Frequency ($80, $81; $82, $83; $84, $85; $86, $87) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
.... .ddd dddd dddd
||| |||| ||||
+++--++++-++++- Frequency divisor
</pre>
This frequency is used for wavetable output. It is calculated as follows: <code>sample rate = 3072000 Hz / (2048 - divisor)</code>.
Note that this refers to the sample rate of the ''wavetable'', and needs to be scaled accordingly for a given waveform when performing music playback.
{{Anchor|Sound Channel Volume}}
=== Sound Channel Volume ($88; $89; $8A; $8B) ===
<pre>
7 bit 0
---------
llll rrrr
|||| ||||
|||| ++++- Right channel volume (0-15)
++++------ Left channel volume (0-15)
</pre>
This volume is used for wavetable output.
The calculation to get an unsigned 8-bit sample out of a 4-bit wavetable sample / 4-bit volume pair is simple: <code>out_sample = sample * volume</code>. This means that the maximum sample in wavetable output mode is <code>15 * 15 = 225</code>.
{{Anchor|Sound Channel 2 Voice Sample}}
=== Sound Channel 2 Voice Sample ($89) ===
<pre>
7 bit 0
---- ----
ssss ssss
|||| ||||
++++-++++- Unsigned 8-bit PCM sample (0-255)
</pre>
This sample is used for voice output.
{{Anchor|Sound Channel 3 Sweep Amount}}
=== Sound Channel 3 Sweep Amount ($8C) ===
<pre>
7 bit 0
---- ----
vvvv vvvv
|||| ||||
++++-++++- Value; 8-bit, signed.
</pre>
This port is used for wavetable output with sweep enabled.
The signed value in this port will be added to the frequency divider for channel 3 every sweep step (as determined by the Sweep Ticks port). Wraparound is present - adding 1 to a frequency divider value of 2047 will cause it to roll over back to 0.
{{Anchor|Sound Channel 3 Sweep Ticks}}
=== Sound Channel 3 Sweep Ticks ($8D) ===
<pre>
7 bit 0
---- ----
...t tttt
| ||||
+-++++- Ticks per step - 1
</pre>
This port is used for wavetable output with sweep enabled.
Every <code>ttttt + 1</code> ticks, clocked at 375 Hz, the value in the Sweep Amount port will be added to the frequency divider for channel 3.
{{Anchor|Sound Channel 4 Noise Control}}
=== Sound Channel 4 Noise Control ($8E) ===
<pre>
7 bit 0
---- ----
...e rttt
| ||||
| |+++- LFSR tap mode
| +---- LFSR reset: 1 = reset shift register
+------ LFSR enabled: 0 = off, 1 = on
</pre>
This port is used for noise output.
{| class="wikitable"
|+ List of LFSR tap modes
! Tap mode
! Tap bit
! Sequence length
|-
| 0
| 14
| 32767
|-
| 1
| 10
| 1953
|-
| 2
| 13
| 254
|-
| 3
| 4
| 217
|-
| 4
| 8
| 73
|-
| 5
| 6
| 63
|-
| 6
| 9
| 42
|-
| 7
| 11
| 28
|}
Noise output works using the following algorithm, performed once per sample generated:
# Create a new bit by XORing bit 7 with the tap bit.
# Shift the LFSR register one bit to the left.
# Write the new bit as bit 0.
# Use the new bit as if it were a wavetable sample: 0 = 0, 1 = 15.
{{Anchor|Sound Wavetable Address}}
=== Sound Wavetable Address ($8F) ===
<pre>
7 bit 0
---- ----
wwww wwww
|||| ||||
++++-++++- Wavetable address (bits 6-13)
</pre>
The wavetable is 4 x 16 bytes long; each 16-byte block contains 32 4-bit samples for the relevant channel:
<pre>
Address $00 $01 $02 $03 $04 $05 $06 $07 $08 $09 $0A $0B $0C $0D $0E $0F
98 CB ED FF FF EF BD 8A 57 24 01 00 00 21 43 76
Sample
15 .. .. .. ## ## #. .. .. .. .. .. .. .. .. .. ..
14 .. .. .# || || |# .. .. .. .. .. .. .. .. .. ..
13 .. .. #| || || || #. .. .. .. .. .. .. .. .. ..
12 .. .# || || || || |. .. .. .. .. .. .. .. .. ..
11 .. #| || || || || |# .. .. .. .. .. .. .. .. ..
10 .. || || || || || || #. .. .. .. .. .. .. .. ..
9 .# || || || || || || |. .. .. .. .. .. .. .. ..
8 #| || || || || || || |# .. .. .. .. .. .. .. ..
7 || || || || || || || || #. .. .. .. .. .. .. .#
6 || || || || || || || || |. .. .. .. .. .. .. #|
5 || || || || || || || || |# .. .. .. .. .. .. ||
4 || || || || || || || || || #. .. .. .. .. .# ||
3 || || || || || || || || || |. .. .. .. .. #| ||
2 || || || || || || || || || |# .. .. .. .# || ||
1 || || || || || || || || || || #. .. .. #| || ||
0 || || || || || || || || || || |# ## ## || || ||
</pre>
Note that the ''higher'' bits - the first hexadecimal number - specify the ''later'' samples; that is to say, the nybbles of each sample are swapped relative to the wave drawing.
{{Anchor|Sound Channel Control}}
=== Sound Channel Control ($90) ===
<pre>
7 bit 0
---- ----
nsv. 4321
||| ||||
||| |||+- Channel 1 enable
||| ||+-- Channel 2 enable
||| |+--- Channel 3 enable
||| +---- Channel 4 enable
||+------- Channel 2 mode: 0 = wavetable, 1 = voice
|+-------- Channel 3 sweep: 0 = disable, 1 = enable
+--------- Channel 4 mode: 0 = wavetable, 1 = noise
</pre>
{{Anchor|Sound Output Control}}
=== Sound Output Control ($91) ===
<pre>
7 bit 0
---- ----
H... hrrs
| ||||
| |||+- Internal speaker output enable
| |++-- Internal speaker shift/volume:
| | 0 = 100% 1 = 50%
| | 2 = 25% 3 = 12.5%
| +---- Headphone output enable
+--------- Headphones connected, 1 if true
</pre>
For correct playback on the internal speaker, it is important to set the shift/volume correctly, to match the peak summed output of the first four channels. If the value is too low, music using multiple loud channels will wrap, causing audible distortion. If the value is too high, single-channel PCM sample playback will be very quiet.
{{Anchor|Sound Channel 4 LFSR Register}}
=== Sound Channel 4 LFSR Register ($92, $93 read) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
.rrr rrrr rrrr rrrr
||| |||| |||| ||||
+++-++++--++++-++++- Shift register value
</pre>
{{Anchor|Sound Channel 2 Voice Volume}}
=== Sound Channel 2 Voice Volume ($94) ===
<pre>
7 bit 0
---- ----
.... lLrR
||||
|||+- Right channel 100% volume
||+-- Right channel 50% volume
|+--- Left channel 100% volume
+---- Left channel 50% volume
</pre>
This port is used for voice output.
The <code>50% volume</code> have no effect if their respective <code>100% volume</code> bits are set.
{{Anchor|Sound Test}}
=== Sound Test ($95) ===
<pre>
7 bit 0
---- ----
425? llsh
||| ||||
||| |||+- Hold Ch1-4 output updates
||| ||+-- Use 3072000 Hz CPU clock for sweep
||| ++--- Hold noise LFSR output
||| (Differences between bit 2/3
||| behavior are unknown)
||+------- Force L10/R10 outputs to 0x55
|+-------- Force Ch1-4 outputs to 0x02
+--------- Force Ch1-4 outputs to 0x04
</pre>
{{Anchor|Sound Channel Output Right}}
=== Sound Channel Output Right ($96, $97 read) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
.... ..ss ssss ssss
|| |||| ||||
++--++++-++++- Unsigned 10-bit sample
</pre>
{{Anchor|Sound Channel Output Left}}
=== Sound Channel Output Left ($98, $99 read) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
.... ..ss ssss ssss
|| |||| ||||
++--++++-++++- Unsigned 10-bit sample
</pre>
{{Anchor|Sound Channel Output Sum}}
=== Sound Channel Output Sum ($9A, $9B read) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
.... .sss ssss ssss
||| |||| ||||
+++--++++-++++- Unsigned 11-bit sample
</pre>
290e51dae8167425aa57272b09878ca69cfd6b87
ROM header
0
5
273
242
2024-04-02T18:30:33Z
Asie
351
/* Save type/size ($B) */
wikitext
text/x-wiki
Every WonderSwan ROM contains a header. It is stored at the end - final sixteen bytes - of the ROM image.
== ROM header ==
Parts of this header are validated or otherwise used by the console's [[boot ROM]] - they are marked in '''bold'''.
{| class="wikitable"
|+ Header contents
|-
! Offset !! Length !! Contents
|-
| '''$0''' || '''5''' || Far jump instruction: '''0xEA''', offset, segment.
|-
| '''$5''' || '''1''' || '''Maintenance'''
|-
| $6 || 1 || Developer/Publisher ID
|-
| $7 || 1 || Color
|-
| $8 || 1 || Game ID (binary-coded decimal)
|-
| '''$9''' || '''1''' || '''Game version? / Safe mode'''
|-
| $A || 1 || ROM size
|-
| $B || 1 || Save type/size
|-
| '''$C''' || '''1''' || '''Flags'''
|-
| $D || 1 || Mapper
|-
| $E || 2 || Checksum (sum of all ROM bytes excluding the checksum)
|}
=== Maintenance ($5) ===
----
<pre>
7 bit 0
---- ----
s... 0000
| ||||
| ++++- Must be zero; otherwise the console will prohibit execution.
| Purpose unknown.
+--------- (Color) Splash bypass: 0 = Disable, 1 = Enable.
Bypasses the custom boot splash stored in the console's
internal EEPROM; presumably used for bricked console recovery.
</pre>
=== Developer/Publisher ID ($6) ===
----
{| class="wikitable"
|+ Known official developer/publisher IDs
|-
! ID !! Publisher code !! Publisher
|-
| $01 || BAN || Bandai
|-
| $02 || TAT || Taito
|-
| $03 || TMY || Tomy
|-
| $04 || KEX || Koei
|-
| $05 || DTE || Data East
|-
| $06 || AAE || Asmik Ace
|-
| $07 || MDE || Media Entertainment
|-
| $08 || NHB || Nichibutsu
|-
| $0A || CCJ || Coconuts Japan
|-
| $0B || SUM || Sammy
|-
| $0C || SUN || Sunsoft
|-
| $0D || PAW || Mebius
|-
| $0E || BPR || Banpresto
|-
| $10 || JLC || Jaleco
|-
| $11 || MGA || Imagineer
|-
| $12 || KNM || Konami
|-
| $16 || KBS || Kobunsha
|-
| $17 || BTM || Bottom Up
|-
| $18 || KGT || Kaga Tech
|-
| $19 || SRV || Sunrise
|-
| $1A || CFT || Cyber Front
|-
| $1B || MGH || Megahouse
|-
| $1D || BEC || Interbec
|-
| $1E || NAP || Nihon Application
|-
| $1F || BVL || Bandai Visual
|-
| $20 || ATN || Athena
|-
| $21 || KDX || KID
|-
| $22 || HAL || HAL Corporation
|-
| $23 || YKE || Yuki Enterprise
|-
| $24 || OMN || Omega Micott
|-
| $25 || LAY || Layup
|-
| $26 || KDK || Kadokawa Shoten
|-
| $27 || SHL || Shall Luck
|-
| $28 || SQR || Squaresoft
|-
| $2A || SCC || ?
|-
| $2B || TMC || Tom Create
|-
| $2D || NMC || Namco
|-
| $2E || SES || ?
|-
| $2F || HTR || ?
|-
| $31 || VGD || Vanguard
|-
| $32 || MGT || Megatron
|-
| $33 || WIZ || Wiz
|-
| $35 || TAN || Tanita
|-
| $36 || CPC || Capcom
|}
Note that IDs $00 and $01 are used across a variety of commercial games. Homebrew is known to use arbitrary values in this field.
=== Color ($7) ===
----
<pre>
7 bit 0
---- ----
???? ???c
|
+- 0 = Monochrome only, 1 = Supports Color mode.
</pre>
=== Game version? / Safe mode ($9) ===
----
<pre>
7 bit 0
---- ----
pvvv vvvv
|||| ||||
|+++ ++++- Game version?
+--------- Internal EEPROM write protect: 0 = Enable, 1 = Disable.
This prohibits writing to the internal EEPROM for addresses
0x60 and above (user settings, custom splash screen).
Games are expected to enable write protection; however, the
WonderWitch is factory configured with it disabled.
</pre>
=== ROM size ($A) ===
----
Unofficial/inferred ROM size values are marked in ''italic''.
{| class="wikitable"
|+ ROM size values
|-
! ID !! Size
|-
| ''$00'' || ''1 Mbit (128 KiB)''
|-
| ''$01'' || ''2 Mbit (256 KiB)''
|-
| $02 || 4 Mbit (512 KiB)
|-
| $03 || 8 Mbit (1 MiB)
|-
| $04 || 16 Mbit (2 MiB)
|-
| ''$05'' || ''24 Mbit (3 MiB)''
|-
| $06 || 32 Mbit (4 MiB)
|-
| ''$07'' || ''48 Mbit (6 MiB)''
|-
| $08 || 64 Mbit (8 MiB)
|-
| $09 || 128 Mbit (16 MiB)
|-
| ''$0A'' || ''256 Mbit (32 MiB)''
|-
| ''$0B'' || ''512 Mbit (64 MiB)''
|}
Note that ROM sizes over 16 MiB are not supported by the [[Bandai 2001]] mapper. The [[Bandai 2003]] mapper is limited to 64 MiB.
=== Save type/size ($B) ===
----
{| class="wikitable"
|+ Save type values
|-
! ID !! Type !! Size
|-
| $00 || colspan="2" style="text-align:center;" | None
|-
| $01 || rowspan="5" | SRAM || rowspan="2" | 256 Kbit (32 KiB)
|-
| $02
|-
| $03 || 1 Mbit (128 KiB)
|-
| $04 || 2 Mbit (256 KiB)
|-
| $05 || 4 Mbit (512 KiB)
|-
| $10 || rowspan="3" | EEPROM || 1 Kbit (128 B)
|-
| $20 || 16 Kbit (2 KiB)
|-
| $50 || 8 Kbit (1 KiB)
|}
Note that while ID ''$01'' is commonly documented as ''64 Kbit'', all known cartridges using that value come with ''256 Kbit'' SRAM chips. This requires further investigation.
=== Flags ($C) ===
----
<pre>
7 bit 0
---- ----
???? ?SBv
|||
||+- Starting screen orientation: 0 = Horizontal, 1 = Vertical.
|| Controls the splash screen's orientation.
|+-- ROM bus width: 0 = 16-bit, 1 = 8-bit.
+--- ROM access time: 0 = 3 CPU cycles, 1 = 1 CPU cycle.
</pre>
=== Mapper ($D) ===
----
{| class="wikitable"
|+ Known mapper types
|-
! ID !! Mapper
|-
| $00 || [[Bandai 2001]] or [[KARNAK]]
|-
| $01 || [[Bandai 2003]]
|}
c498482d4f203bd7ccbacdb203ca7261033e6c20
274
273
2024-04-02T18:30:52Z
Asie
351
/* Save type/size ($B) */
wikitext
text/x-wiki
Every WonderSwan ROM contains a header. It is stored at the end - final sixteen bytes - of the ROM image.
== ROM header ==
Parts of this header are validated or otherwise used by the console's [[boot ROM]] - they are marked in '''bold'''.
{| class="wikitable"
|+ Header contents
|-
! Offset !! Length !! Contents
|-
| '''$0''' || '''5''' || Far jump instruction: '''0xEA''', offset, segment.
|-
| '''$5''' || '''1''' || '''Maintenance'''
|-
| $6 || 1 || Developer/Publisher ID
|-
| $7 || 1 || Color
|-
| $8 || 1 || Game ID (binary-coded decimal)
|-
| '''$9''' || '''1''' || '''Game version? / Safe mode'''
|-
| $A || 1 || ROM size
|-
| $B || 1 || Save type/size
|-
| '''$C''' || '''1''' || '''Flags'''
|-
| $D || 1 || Mapper
|-
| $E || 2 || Checksum (sum of all ROM bytes excluding the checksum)
|}
=== Maintenance ($5) ===
----
<pre>
7 bit 0
---- ----
s... 0000
| ||||
| ++++- Must be zero; otherwise the console will prohibit execution.
| Purpose unknown.
+--------- (Color) Splash bypass: 0 = Disable, 1 = Enable.
Bypasses the custom boot splash stored in the console's
internal EEPROM; presumably used for bricked console recovery.
</pre>
=== Developer/Publisher ID ($6) ===
----
{| class="wikitable"
|+ Known official developer/publisher IDs
|-
! ID !! Publisher code !! Publisher
|-
| $01 || BAN || Bandai
|-
| $02 || TAT || Taito
|-
| $03 || TMY || Tomy
|-
| $04 || KEX || Koei
|-
| $05 || DTE || Data East
|-
| $06 || AAE || Asmik Ace
|-
| $07 || MDE || Media Entertainment
|-
| $08 || NHB || Nichibutsu
|-
| $0A || CCJ || Coconuts Japan
|-
| $0B || SUM || Sammy
|-
| $0C || SUN || Sunsoft
|-
| $0D || PAW || Mebius
|-
| $0E || BPR || Banpresto
|-
| $10 || JLC || Jaleco
|-
| $11 || MGA || Imagineer
|-
| $12 || KNM || Konami
|-
| $16 || KBS || Kobunsha
|-
| $17 || BTM || Bottom Up
|-
| $18 || KGT || Kaga Tech
|-
| $19 || SRV || Sunrise
|-
| $1A || CFT || Cyber Front
|-
| $1B || MGH || Megahouse
|-
| $1D || BEC || Interbec
|-
| $1E || NAP || Nihon Application
|-
| $1F || BVL || Bandai Visual
|-
| $20 || ATN || Athena
|-
| $21 || KDX || KID
|-
| $22 || HAL || HAL Corporation
|-
| $23 || YKE || Yuki Enterprise
|-
| $24 || OMN || Omega Micott
|-
| $25 || LAY || Layup
|-
| $26 || KDK || Kadokawa Shoten
|-
| $27 || SHL || Shall Luck
|-
| $28 || SQR || Squaresoft
|-
| $2A || SCC || ?
|-
| $2B || TMC || Tom Create
|-
| $2D || NMC || Namco
|-
| $2E || SES || ?
|-
| $2F || HTR || ?
|-
| $31 || VGD || Vanguard
|-
| $32 || MGT || Megatron
|-
| $33 || WIZ || Wiz
|-
| $35 || TAN || Tanita
|-
| $36 || CPC || Capcom
|}
Note that IDs $00 and $01 are used across a variety of commercial games. Homebrew is known to use arbitrary values in this field.
=== Color ($7) ===
----
<pre>
7 bit 0
---- ----
???? ???c
|
+- 0 = Monochrome only, 1 = Supports Color mode.
</pre>
=== Game version? / Safe mode ($9) ===
----
<pre>
7 bit 0
---- ----
pvvv vvvv
|||| ||||
|+++ ++++- Game version?
+--------- Internal EEPROM write protect: 0 = Enable, 1 = Disable.
This prohibits writing to the internal EEPROM for addresses
0x60 and above (user settings, custom splash screen).
Games are expected to enable write protection; however, the
WonderWitch is factory configured with it disabled.
</pre>
=== ROM size ($A) ===
----
Unofficial/inferred ROM size values are marked in ''italic''.
{| class="wikitable"
|+ ROM size values
|-
! ID !! Size
|-
| ''$00'' || ''1 Mbit (128 KiB)''
|-
| ''$01'' || ''2 Mbit (256 KiB)''
|-
| $02 || 4 Mbit (512 KiB)
|-
| $03 || 8 Mbit (1 MiB)
|-
| $04 || 16 Mbit (2 MiB)
|-
| ''$05'' || ''24 Mbit (3 MiB)''
|-
| $06 || 32 Mbit (4 MiB)
|-
| ''$07'' || ''48 Mbit (6 MiB)''
|-
| $08 || 64 Mbit (8 MiB)
|-
| $09 || 128 Mbit (16 MiB)
|-
| ''$0A'' || ''256 Mbit (32 MiB)''
|-
| ''$0B'' || ''512 Mbit (64 MiB)''
|}
Note that ROM sizes over 16 MiB are not supported by the [[Bandai 2001]] mapper. The [[Bandai 2003]] mapper is limited to 64 MiB.
=== Save type/size ($B) ===
----
{| class="wikitable"
|+ Save type values
|-
! ID !! Type !! Size
|-
| $00 || colspan="2" style="text-align:center;" | None
|-
| $01 || rowspan="5" | SRAM || rowspan="2" | 256 Kbit (32 KiB)
|-
| $02
|-
| $03 || 1 Mbit (128 KiB)
|-
| $04 || 2 Mbit (256 KiB)
|-
| $05 || 4 Mbit (512 KiB)
|-
| $10 || rowspan="3" | EEPROM || 1 Kbit (128 B)
|-
| $20 || 16 Kbit (2 KiB)
|-
| $50 || 8 Kbit (1 KiB)
|}
Note that while ID <code>$01</code> is commonly documented as <code>64 Kbit</code>, all known cartridges using that value come with <code>256 Kbit</code> SRAM chips. This requires further investigation.
=== Flags ($C) ===
----
<pre>
7 bit 0
---- ----
???? ?SBv
|||
||+- Starting screen orientation: 0 = Horizontal, 1 = Vertical.
|| Controls the splash screen's orientation.
|+-- ROM bus width: 0 = 16-bit, 1 = 8-bit.
+--- ROM access time: 0 = 3 CPU cycles, 1 = 1 CPU cycle.
</pre>
=== Mapper ($D) ===
----
{| class="wikitable"
|+ Known mapper types
|-
! ID !! Mapper
|-
| $00 || [[Bandai 2001]] or [[KARNAK]]
|-
| $01 || [[Bandai 2003]]
|}
bdf0f8593c07d92b4051121648b8be9e058ebaf7
EEPROM
0
35
277
211
2024-05-28T14:02:50Z
Asie
351
/* Internal EEPROM Command ($BC, $BD) */
wikitext
text/x-wiki
The WonderSwan utilizes M93LCx6-compatible EEPROMs:
* in the SoC:
** 1 Kbit internal EEPROM (M93LC46-compatible) on the WonderSwan,
** 16 Kbit internal EEPROM (M93LC86-compatible) on the WonderSwan Color,
* on cartridges:
** 1 Kbit cartridge EEPROM (M93LC46-compatible)
** 8 Kbit cartridge EEPROM (M93LC76-compatible)
** 16 Kbit cartridge EEPROM (M93LC86-compatible)
Additional variants exists which were not seen on any production cartridge:
* 256 bit EEPROM (M93LC06-compatible)
* 2 Kbit EEPROM (M93LC56-compatible)
* 4 Kbit EEPROM (M93LC66-compatible)
== Commands ==
=== READ - Read Word ===
The READ command takes an address of a word (address 0 => bytes 0, 1; address 1 => bytes 2, 3; ...) and returns the word at that address.
=== WRITE - Write Word ===
The WRITE command takes an address of a word (address 0 => bytes 0, 1; address 1 => bytes 2, 3; ...) and the word to write to it, then writes the word.
=== ERASE - Erase Word ===
The ERASE command takes an address of a word (address 0 => bytes 0, 1; address 1 => bytes 2, 3; ...) and erases the word at that address, setting it to 0xFFFF.
=== WDS - Write Disable ===
TODO
=== WRAL - Write All ===
This command is not guaranteed to be present on all EEPROMs.
TODO
=== ERAL - Erase All ===
This command is not guaranteed to be present on all EEPROMs.
TODO
=== WEN - Write Enable ===
TODO
== I/O ports ==
The I/O ports listed refer to the internal EEPROM; for the cartridge EEPROM port numbers, refer to the [[Bandai 2001|mapper documentation]].
It is recommended to only access the data and command ports with aligned word reads/writes; see the ''Errata'' section for more information.
{{Anchor|Internal EEPROM Data}}
=== Internal EEPROM Data ($BA, $BB) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
dddd dddd dddd dddd
|||| |||| |||| ||||
++++-++++--++++-++++- Data read from/written to the EEPROM.
</pre>
This port functions as a shared buffer for both "read" and "write" modes. (TODO: Verify)
{{Anchor|Internal EEPROM Command}}
=== Internal EEPROM Command ($BC, $BD) ===
<pre>
Command Pattern 1
15 bit 8 7 bit 0
---- ---- ---- ----
0000 0001 ooaa aaaa (¼, 1 Kbit - M93LC06/46)
0000 01oo aaaa aaaa (2, 4 Kbit - M93LC56/66)
0001 ooaa aaaa aaaa (8, 16 Kbit - M93LC76/86)
|||| |||| ||||
||++--++++-++++- Address (MSb .. LSb)
++-------------- Opcode:
01 - WRITE
10 - READ
11 - ERASE
</pre>
<pre>
Command Pattern 2
15 bit 8 7 bit 0
---- ---- ---- ----
0000 0001 00ss .... (¼, 1 Kbit - M93LC06/46)
0000 0100 ss.. .... (2, 4 Kbit - M93LC56/66)
0001 00ss .... .... (8, 16 Kbit - M93LC76/86)
||
++------------ Sub-Opcode:
00 - WDS
01 - WRAL
01 - ERAL
11 - WEN
</pre>
The value written to this port can be read back; it is not affected by ''EEPROM Control''.
{{Anchor|Internal EEPROM Control}}
=== Internal EEPROM Control ($BE, $BF write) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
.... .... pswr ....
||||
|||+------ Read mode: 1 for READ command, 0 otherwise
||+------- Write mode: 1 for WRITE and WRAL command, 0 otherwise
|+-------- Short mode: 1 for ERASE, WDS, ERAL and WEN command, 0 otherwise
+--------- 1 to enable internal EEPROM write protection.
Cannot be cleared once set.
</pre>
The ''mode'' flags control the behaviour of the EEPROM interface:
* Read mode: Sends 16 bits from Command, then reads 16 bits to Data.
* Write mode: Sends 16 bits from Command, then 16 bits from Data. De-asserts Microwire chip select, then re-asserts it and waits for the EEPROM to confirm command completion.
* Short mode: Sends 16 bits from Command, de-asserts Microwire chip select.
Also note that nothing inside the SoC or 2001 checks that the contents of the command register matches the bit set in this register.
{{Anchor|Internal EEPROM Status}}
=== Internal EEPROM Status ($BE, $BF read) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
.... .... p... ..RD
| ||
| |+- 1 if a READ command has completed.
| +-- 0 if the EEPROM is busy,
| 1 if a command can be accepted (idle).
+--------- Internal EEPROM write protection:
0 = disabled, 1 = enabled
</pre>
== Internal EEPROM Layout ==
{| class="wikitable"
|-
! Offset !! Length !! Contents
|-
| $00 || 96 || Program data. Can be written by programs even if write protection has been enabled.
|-
| $60 || 16 || Owner name, custom character set.
|-
| $70 || 1 || Owner birthday year, BCD, first/higher two digits
|-
| $71 || 1 || Owner birthday year, BCD, last/lower two digits
|-
| $72 || 1 || Owner birthday month, BCD
|-
| $73 || 1 || Owner birthday day, BCD
|-
| $74 || 1 || Owner gender:<br/>
0 - ?<br/>
1 - Male<br/>
2 - Female
|-
| $75 || 1 || Owner blood type:<br/>
0 - ?<br/>
1 - A<br/>
2 - B<br/>
3 - AB<br/>
4 - 0
|-
| $76 || 1 || Last booted cartridge developer/publisher ID
|-
| $77 || 1 || Last booted cartridge game ID
|-
| $78 || 1 || Last booted cartridge game version
|-
| $7C || 1 || Stored cartridge ID/version change counter
|-
| $7D || 1 || Owner name change counter
|-
| $7E || 2 || System startup counter
|-
| $83 || 1 || Color console configuration
|-
| $84 || ? || [[Splash animation|Custom splash animation]], if present
|}
=== Owner name character set ===
{| class="wikitable"
|-
!
! <code>.0</code>
! <code>.1</code>
! <code>.2</code>
! <code>.3</code>
! <code>.4</code>
! <code>.5</code>
! <code>.6</code>
! <code>.7</code>
! <code>.8</code>
! <code>.9</code>
! <code>.A</code>
! <code>.B</code>
! <code>.C</code>
! <code>.D</code>
! <code>.E</code>
! <code>.F</code>
|-
! <code>0.</code>
| || 0 || 1 || 2 || 3 || 4 || 5 || 6 || 7 || 8 || 9 || A || B || C || D || E
|-
! <code>1.</code>
| F || G || H || I || J || K || L || M || N || O || P || Q || R || S || T || U
|-
! <code>2.</code>
| V || W || X || Y || Z || ♥ || ♪ || + || - || ? || .
!
!
!
!
!
|}
=== Color console configuration ===
<pre>
7 bit 0
---- ----
sc.. ..vv
|| ||
|| ++- Volume level
|+-------- Contrast (WSC): 0 = Low, 1 = High
+--------- Custom splash animation enabled
</pre>
== Hardware notes ==
EEPROM command bits are shifted out starting from the ''most'' significant bit of the port.
<pre>
+----> EEPROM Serial Data
|
[0] <= [0000 0001 ooaa aaaa]
EEPROM Command Port
</pre>
While the M93LCx6 family supports byte organization, the WonderSwan always uses word organization. As such, this implementation detail is omitted in this documentation.
== Errata ==
=== Non-word access on ASWAN ===
On the ASWAN SoC, accessing the internal EEPROM command ports as bytes only works correctly for even addresses. For odd addresses, these accesses return open bus; this means that unaligned word accesses also don't work, as they are converted to one odd and one even byte access internally.
It is recommended to only use aligned word port accesses to talk to the internal EEPROM.
This issue is not present on the SPHINX and newer SoCs, including in "mono" emulation mode, as well as the cartridge bus (which is always forced to be accessed per byte).
== Links ==
* [https://www.st.com/resource/en/datasheet/m93c46-w.pdf STMicroelectronics M93LCx6 datasheet]
ca05e8797987c8434aa8afae74791e395fa03d10
278
277
2024-05-28T14:06:01Z
Asie
351
/* Internal EEPROM Status ($BE, $BF read) */
wikitext
text/x-wiki
The WonderSwan utilizes M93LCx6-compatible EEPROMs:
* in the SoC:
** 1 Kbit internal EEPROM (M93LC46-compatible) on the WonderSwan,
** 16 Kbit internal EEPROM (M93LC86-compatible) on the WonderSwan Color,
* on cartridges:
** 1 Kbit cartridge EEPROM (M93LC46-compatible)
** 8 Kbit cartridge EEPROM (M93LC76-compatible)
** 16 Kbit cartridge EEPROM (M93LC86-compatible)
Additional variants exists which were not seen on any production cartridge:
* 256 bit EEPROM (M93LC06-compatible)
* 2 Kbit EEPROM (M93LC56-compatible)
* 4 Kbit EEPROM (M93LC66-compatible)
== Commands ==
=== READ - Read Word ===
The READ command takes an address of a word (address 0 => bytes 0, 1; address 1 => bytes 2, 3; ...) and returns the word at that address.
=== WRITE - Write Word ===
The WRITE command takes an address of a word (address 0 => bytes 0, 1; address 1 => bytes 2, 3; ...) and the word to write to it, then writes the word.
=== ERASE - Erase Word ===
The ERASE command takes an address of a word (address 0 => bytes 0, 1; address 1 => bytes 2, 3; ...) and erases the word at that address, setting it to 0xFFFF.
=== WDS - Write Disable ===
TODO
=== WRAL - Write All ===
This command is not guaranteed to be present on all EEPROMs.
TODO
=== ERAL - Erase All ===
This command is not guaranteed to be present on all EEPROMs.
TODO
=== WEN - Write Enable ===
TODO
== I/O ports ==
The I/O ports listed refer to the internal EEPROM; for the cartridge EEPROM port numbers, refer to the [[Bandai 2001|mapper documentation]].
It is recommended to only access the data and command ports with aligned word reads/writes; see the ''Errata'' section for more information.
{{Anchor|Internal EEPROM Data}}
=== Internal EEPROM Data ($BA, $BB) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
dddd dddd dddd dddd
|||| |||| |||| ||||
++++-++++--++++-++++- Data read from/written to the EEPROM.
</pre>
This port functions as a shared buffer for both "read" and "write" modes. (TODO: Verify)
{{Anchor|Internal EEPROM Command}}
=== Internal EEPROM Command ($BC, $BD) ===
<pre>
Command Pattern 1
15 bit 8 7 bit 0
---- ---- ---- ----
0000 0001 ooaa aaaa (¼, 1 Kbit - M93LC06/46)
0000 01oo aaaa aaaa (2, 4 Kbit - M93LC56/66)
0001 ooaa aaaa aaaa (8, 16 Kbit - M93LC76/86)
|||| |||| ||||
||++--++++-++++- Address (MSb .. LSb)
++-------------- Opcode:
01 - WRITE
10 - READ
11 - ERASE
</pre>
<pre>
Command Pattern 2
15 bit 8 7 bit 0
---- ---- ---- ----
0000 0001 00ss .... (¼, 1 Kbit - M93LC06/46)
0000 0100 ss.. .... (2, 4 Kbit - M93LC56/66)
0001 00ss .... .... (8, 16 Kbit - M93LC76/86)
||
++------------ Sub-Opcode:
00 - WDS
01 - WRAL
01 - ERAL
11 - WEN
</pre>
The value written to this port can be read back; it is not affected by ''EEPROM Control''.
{{Anchor|Internal EEPROM Control}}
=== Internal EEPROM Control ($BE, $BF write) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
.... .... pswr ....
||||
|||+------ Read mode: 1 for READ command, 0 otherwise
||+------- Write mode: 1 for WRITE and WRAL command, 0 otherwise
|+-------- Short mode: 1 for ERASE, WDS, ERAL and WEN command, 0 otherwise
+--------- 1 to enable internal EEPROM write protection.
Cannot be cleared once set.
</pre>
The ''mode'' flags control the behaviour of the EEPROM interface:
* Read mode: Sends 16 bits from Command, then reads 16 bits to Data.
* Write mode: Sends 16 bits from Command, then 16 bits from Data. De-asserts Microwire chip select, then re-asserts it and waits for the EEPROM to confirm command completion.
* Short mode: Sends 16 bits from Command, de-asserts Microwire chip select.
Also note that nothing inside the SoC or 2001 checks that the contents of the command register matches the bit set in this register.
{{Anchor|Internal EEPROM Status}}
=== Internal EEPROM Status ($BE, $BF read) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
.... .... p... ..RD
| ||
| |+- 0 after a Read command is initiated,
| | 1 once a Read command is completed.
| | Unaffected by Write/Erase commands.
| +-- 0 if the EEPROM is busy,
| 1 if a command can be accepted (idle).
+--------- Internal EEPROM write protection:
0 = disabled, 1 = enabled
</pre>
== Internal EEPROM Layout ==
{| class="wikitable"
|-
! Offset !! Length !! Contents
|-
| $00 || 96 || Program data. Can be written by programs even if write protection has been enabled.
|-
| $60 || 16 || Owner name, custom character set.
|-
| $70 || 1 || Owner birthday year, BCD, first/higher two digits
|-
| $71 || 1 || Owner birthday year, BCD, last/lower two digits
|-
| $72 || 1 || Owner birthday month, BCD
|-
| $73 || 1 || Owner birthday day, BCD
|-
| $74 || 1 || Owner gender:<br/>
0 - ?<br/>
1 - Male<br/>
2 - Female
|-
| $75 || 1 || Owner blood type:<br/>
0 - ?<br/>
1 - A<br/>
2 - B<br/>
3 - AB<br/>
4 - 0
|-
| $76 || 1 || Last booted cartridge developer/publisher ID
|-
| $77 || 1 || Last booted cartridge game ID
|-
| $78 || 1 || Last booted cartridge game version
|-
| $7C || 1 || Stored cartridge ID/version change counter
|-
| $7D || 1 || Owner name change counter
|-
| $7E || 2 || System startup counter
|-
| $83 || 1 || Color console configuration
|-
| $84 || ? || [[Splash animation|Custom splash animation]], if present
|}
=== Owner name character set ===
{| class="wikitable"
|-
!
! <code>.0</code>
! <code>.1</code>
! <code>.2</code>
! <code>.3</code>
! <code>.4</code>
! <code>.5</code>
! <code>.6</code>
! <code>.7</code>
! <code>.8</code>
! <code>.9</code>
! <code>.A</code>
! <code>.B</code>
! <code>.C</code>
! <code>.D</code>
! <code>.E</code>
! <code>.F</code>
|-
! <code>0.</code>
| || 0 || 1 || 2 || 3 || 4 || 5 || 6 || 7 || 8 || 9 || A || B || C || D || E
|-
! <code>1.</code>
| F || G || H || I || J || K || L || M || N || O || P || Q || R || S || T || U
|-
! <code>2.</code>
| V || W || X || Y || Z || ♥ || ♪ || + || - || ? || .
!
!
!
!
!
|}
=== Color console configuration ===
<pre>
7 bit 0
---- ----
sc.. ..vv
|| ||
|| ++- Volume level
|+-------- Contrast (WSC): 0 = Low, 1 = High
+--------- Custom splash animation enabled
</pre>
== Hardware notes ==
EEPROM command bits are shifted out starting from the ''most'' significant bit of the port.
<pre>
+----> EEPROM Serial Data
|
[0] <= [0000 0001 ooaa aaaa]
EEPROM Command Port
</pre>
While the M93LCx6 family supports byte organization, the WonderSwan always uses word organization. As such, this implementation detail is omitted in this documentation.
== Errata ==
=== Non-word access on ASWAN ===
On the ASWAN SoC, accessing the internal EEPROM command ports as bytes only works correctly for even addresses. For odd addresses, these accesses return open bus; this means that unaligned word accesses also don't work, as they are converted to one odd and one even byte access internally.
It is recommended to only use aligned word port accesses to talk to the internal EEPROM.
This issue is not present on the SPHINX and newer SoCs, including in "mono" emulation mode, as well as the cartridge bus (which is always forced to be accessed per byte).
== Links ==
* [https://www.st.com/resource/en/datasheet/m93c46-w.pdf STMicroelectronics M93LCx6 datasheet]
2f428cc2c380f6fc2ef9fe547b285b6bcce828ee
279
278
2024-05-28T14:07:08Z
Asie
351
/* Internal EEPROM Control ($BE, $BF write) */
wikitext
text/x-wiki
The WonderSwan utilizes M93LCx6-compatible EEPROMs:
* in the SoC:
** 1 Kbit internal EEPROM (M93LC46-compatible) on the WonderSwan,
** 16 Kbit internal EEPROM (M93LC86-compatible) on the WonderSwan Color,
* on cartridges:
** 1 Kbit cartridge EEPROM (M93LC46-compatible)
** 8 Kbit cartridge EEPROM (M93LC76-compatible)
** 16 Kbit cartridge EEPROM (M93LC86-compatible)
Additional variants exists which were not seen on any production cartridge:
* 256 bit EEPROM (M93LC06-compatible)
* 2 Kbit EEPROM (M93LC56-compatible)
* 4 Kbit EEPROM (M93LC66-compatible)
== Commands ==
=== READ - Read Word ===
The READ command takes an address of a word (address 0 => bytes 0, 1; address 1 => bytes 2, 3; ...) and returns the word at that address.
=== WRITE - Write Word ===
The WRITE command takes an address of a word (address 0 => bytes 0, 1; address 1 => bytes 2, 3; ...) and the word to write to it, then writes the word.
=== ERASE - Erase Word ===
The ERASE command takes an address of a word (address 0 => bytes 0, 1; address 1 => bytes 2, 3; ...) and erases the word at that address, setting it to 0xFFFF.
=== WDS - Write Disable ===
TODO
=== WRAL - Write All ===
This command is not guaranteed to be present on all EEPROMs.
TODO
=== ERAL - Erase All ===
This command is not guaranteed to be present on all EEPROMs.
TODO
=== WEN - Write Enable ===
TODO
== I/O ports ==
The I/O ports listed refer to the internal EEPROM; for the cartridge EEPROM port numbers, refer to the [[Bandai 2001|mapper documentation]].
It is recommended to only access the data and command ports with aligned word reads/writes; see the ''Errata'' section for more information.
{{Anchor|Internal EEPROM Data}}
=== Internal EEPROM Data ($BA, $BB) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
dddd dddd dddd dddd
|||| |||| |||| ||||
++++-++++--++++-++++- Data read from/written to the EEPROM.
</pre>
This port functions as a shared buffer for both "read" and "write" modes. (TODO: Verify)
{{Anchor|Internal EEPROM Command}}
=== Internal EEPROM Command ($BC, $BD) ===
<pre>
Command Pattern 1
15 bit 8 7 bit 0
---- ---- ---- ----
0000 0001 ooaa aaaa (¼, 1 Kbit - M93LC06/46)
0000 01oo aaaa aaaa (2, 4 Kbit - M93LC56/66)
0001 ooaa aaaa aaaa (8, 16 Kbit - M93LC76/86)
|||| |||| ||||
||++--++++-++++- Address (MSb .. LSb)
++-------------- Opcode:
01 - WRITE
10 - READ
11 - ERASE
</pre>
<pre>
Command Pattern 2
15 bit 8 7 bit 0
---- ---- ---- ----
0000 0001 00ss .... (¼, 1 Kbit - M93LC06/46)
0000 0100 ss.. .... (2, 4 Kbit - M93LC56/66)
0001 00ss .... .... (8, 16 Kbit - M93LC76/86)
||
++------------ Sub-Opcode:
00 - WDS
01 - WRAL
01 - ERAL
11 - WEN
</pre>
The value written to this port can be read back; it is not affected by ''EEPROM Control''.
{{Anchor|Internal EEPROM Control}}
=== Internal EEPROM Control ($BE, $BF write) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
.... .... pswr ....
||||
|||+------ Read mode: 1 for READ command, 0 otherwise
||+------- Write mode: 1 for WRITE and WRAL command, 0 otherwise
|+-------- Short mode: 1 for ERASE, WDS, ERAL and WEN command, 0 otherwise
+--------- 1 to enable internal EEPROM write protection.
Cannot be cleared once set.
</pre>
The ''mode'' flags control the behaviour of the EEPROM interface:
* Read mode: Sends 16 bits from Command, then reads 16 bits to Data.
* Write mode: Sends 16 bits from Command, then 16 bits from Data. De-asserts Microwire chip select, then re-asserts it and waits for the EEPROM to confirm command completion.
* Short mode: Sends 16 bits from Command, de-asserts Microwire chip select.
Also note that nothing inside the SoC or 2001 checks that the contents of the command register matches the bit set in this register.
{{Anchor|Internal EEPROM Status}}
=== Internal EEPROM Status ($BE, $BF read) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
.... .... p... ..RD
| ||
| |+- 0 after a Read command is initiated,
| | 1 once a Read command is completed.
| | Unaffected by Write/Erase commands.
| +-- 0 if the EEPROM is busy,
| 1 if a command can be accepted (idle).
+--------- Internal EEPROM write protection:
0 = disabled, 1 = enabled
</pre>
== Internal EEPROM Layout ==
{| class="wikitable"
|-
! Offset !! Length !! Contents
|-
| $00 || 96 || Program data. Can be written by programs even if write protection has been enabled.
|-
| $60 || 16 || Owner name, custom character set.
|-
| $70 || 1 || Owner birthday year, BCD, first/higher two digits
|-
| $71 || 1 || Owner birthday year, BCD, last/lower two digits
|-
| $72 || 1 || Owner birthday month, BCD
|-
| $73 || 1 || Owner birthday day, BCD
|-
| $74 || 1 || Owner gender:<br/>
0 - ?<br/>
1 - Male<br/>
2 - Female
|-
| $75 || 1 || Owner blood type:<br/>
0 - ?<br/>
1 - A<br/>
2 - B<br/>
3 - AB<br/>
4 - 0
|-
| $76 || 1 || Last booted cartridge developer/publisher ID
|-
| $77 || 1 || Last booted cartridge game ID
|-
| $78 || 1 || Last booted cartridge game version
|-
| $7C || 1 || Stored cartridge ID/version change counter
|-
| $7D || 1 || Owner name change counter
|-
| $7E || 2 || System startup counter
|-
| $83 || 1 || Color console configuration
|-
| $84 || ? || [[Splash animation|Custom splash animation]], if present
|}
=== Owner name character set ===
{| class="wikitable"
|-
!
! <code>.0</code>
! <code>.1</code>
! <code>.2</code>
! <code>.3</code>
! <code>.4</code>
! <code>.5</code>
! <code>.6</code>
! <code>.7</code>
! <code>.8</code>
! <code>.9</code>
! <code>.A</code>
! <code>.B</code>
! <code>.C</code>
! <code>.D</code>
! <code>.E</code>
! <code>.F</code>
|-
! <code>0.</code>
| || 0 || 1 || 2 || 3 || 4 || 5 || 6 || 7 || 8 || 9 || A || B || C || D || E
|-
! <code>1.</code>
| F || G || H || I || J || K || L || M || N || O || P || Q || R || S || T || U
|-
! <code>2.</code>
| V || W || X || Y || Z || ♥ || ♪ || + || - || ? || .
!
!
!
!
!
|}
=== Color console configuration ===
<pre>
7 bit 0
---- ----
sc.. ..vv
|| ||
|| ++- Volume level
|+-------- Contrast (WSC): 0 = Low, 1 = High
+--------- Custom splash animation enabled
</pre>
== Hardware notes ==
EEPROM command bits are shifted out starting from the ''most'' significant bit of the port.
<pre>
+----> EEPROM Serial Data
|
[0] <= [0000 0001 ooaa aaaa]
EEPROM Command Port
</pre>
While the M93LCx6 family supports byte organization, the WonderSwan always uses word organization. As such, this implementation detail is omitted in this documentation.
== Errata ==
=== Non-word access on ASWAN ===
On the ASWAN SoC, accessing the internal EEPROM command ports as bytes only works correctly for even addresses. For odd addresses, these accesses return open bus; this means that unaligned word accesses also don't work, as they are converted to one odd and one even byte access internally.
It is recommended to only use aligned word port accesses to talk to the internal EEPROM.
This issue is not present on the SPHINX and newer SoCs, including in "mono" emulation mode, as well as the cartridge bus (which is always forced to be accessed per byte).
== Links ==
* [https://www.st.com/resource/en/datasheet/m93c46-w.pdf STMicroelectronics M93LCx6 datasheet]
d61d9c9a699558cabcb856b37b6f2cd589feb1dd
280
279
2024-05-28T14:07:14Z
Asie
351
/* Internal EEPROM Status ($BE, $BF read) */
wikitext
text/x-wiki
The WonderSwan utilizes M93LCx6-compatible EEPROMs:
* in the SoC:
** 1 Kbit internal EEPROM (M93LC46-compatible) on the WonderSwan,
** 16 Kbit internal EEPROM (M93LC86-compatible) on the WonderSwan Color,
* on cartridges:
** 1 Kbit cartridge EEPROM (M93LC46-compatible)
** 8 Kbit cartridge EEPROM (M93LC76-compatible)
** 16 Kbit cartridge EEPROM (M93LC86-compatible)
Additional variants exists which were not seen on any production cartridge:
* 256 bit EEPROM (M93LC06-compatible)
* 2 Kbit EEPROM (M93LC56-compatible)
* 4 Kbit EEPROM (M93LC66-compatible)
== Commands ==
=== READ - Read Word ===
The READ command takes an address of a word (address 0 => bytes 0, 1; address 1 => bytes 2, 3; ...) and returns the word at that address.
=== WRITE - Write Word ===
The WRITE command takes an address of a word (address 0 => bytes 0, 1; address 1 => bytes 2, 3; ...) and the word to write to it, then writes the word.
=== ERASE - Erase Word ===
The ERASE command takes an address of a word (address 0 => bytes 0, 1; address 1 => bytes 2, 3; ...) and erases the word at that address, setting it to 0xFFFF.
=== WDS - Write Disable ===
TODO
=== WRAL - Write All ===
This command is not guaranteed to be present on all EEPROMs.
TODO
=== ERAL - Erase All ===
This command is not guaranteed to be present on all EEPROMs.
TODO
=== WEN - Write Enable ===
TODO
== I/O ports ==
The I/O ports listed refer to the internal EEPROM; for the cartridge EEPROM port numbers, refer to the [[Bandai 2001|mapper documentation]].
It is recommended to only access the data and command ports with aligned word reads/writes; see the ''Errata'' section for more information.
{{Anchor|Internal EEPROM Data}}
=== Internal EEPROM Data ($BA, $BB) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
dddd dddd dddd dddd
|||| |||| |||| ||||
++++-++++--++++-++++- Data read from/written to the EEPROM.
</pre>
This port functions as a shared buffer for both "read" and "write" modes. (TODO: Verify)
{{Anchor|Internal EEPROM Command}}
=== Internal EEPROM Command ($BC, $BD) ===
<pre>
Command Pattern 1
15 bit 8 7 bit 0
---- ---- ---- ----
0000 0001 ooaa aaaa (¼, 1 Kbit - M93LC06/46)
0000 01oo aaaa aaaa (2, 4 Kbit - M93LC56/66)
0001 ooaa aaaa aaaa (8, 16 Kbit - M93LC76/86)
|||| |||| ||||
||++--++++-++++- Address (MSb .. LSb)
++-------------- Opcode:
01 - WRITE
10 - READ
11 - ERASE
</pre>
<pre>
Command Pattern 2
15 bit 8 7 bit 0
---- ---- ---- ----
0000 0001 00ss .... (¼, 1 Kbit - M93LC06/46)
0000 0100 ss.. .... (2, 4 Kbit - M93LC56/66)
0001 00ss .... .... (8, 16 Kbit - M93LC76/86)
||
++------------ Sub-Opcode:
00 - WDS
01 - WRAL
01 - ERAL
11 - WEN
</pre>
The value written to this port can be read back; it is not affected by ''EEPROM Control''.
{{Anchor|Internal EEPROM Control}}
=== Internal EEPROM Control ($BE, $BF write) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
.... .... pswr ....
||||
|||+------ Read mode: 1 for READ command, 0 otherwise
||+------- Write mode: 1 for WRITE and WRAL command, 0 otherwise
|+-------- Short mode: 1 for ERASE, WDS, ERAL and WEN command, 0 otherwise
+--------- 1 to enable internal EEPROM write protection.
Cannot be cleared once set.
</pre>
The ''mode'' flags control the behaviour of the EEPROM interface:
* Read mode: Sends 16 bits from Command, then reads 16 bits to Data.
* Write mode: Sends 16 bits from Command, then 16 bits from Data. De-asserts Microwire chip select, then re-asserts it and waits for the EEPROM to confirm command completion.
* Short mode: Sends 16 bits from Command, de-asserts Microwire chip select.
Also note that nothing inside the SoC or 2001 checks that the contents of the command register matches the bit set in this register.
{{Anchor|Internal EEPROM Status}}
=== Internal EEPROM Status ($BE, $BF read) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
.... .... p... ..rd
| ||
| |+- 0 after a Read command is initiated,
| | 1 once a Read command is completed.
| | Unaffected by Write/Erase commands.
| +-- 0 if the EEPROM is busy,
| 1 if a command can be accepted (idle).
+--------- Internal EEPROM write protection:
0 = disabled, 1 = enabled
</pre>
== Internal EEPROM Layout ==
{| class="wikitable"
|-
! Offset !! Length !! Contents
|-
| $00 || 96 || Program data. Can be written by programs even if write protection has been enabled.
|-
| $60 || 16 || Owner name, custom character set.
|-
| $70 || 1 || Owner birthday year, BCD, first/higher two digits
|-
| $71 || 1 || Owner birthday year, BCD, last/lower two digits
|-
| $72 || 1 || Owner birthday month, BCD
|-
| $73 || 1 || Owner birthday day, BCD
|-
| $74 || 1 || Owner gender:<br/>
0 - ?<br/>
1 - Male<br/>
2 - Female
|-
| $75 || 1 || Owner blood type:<br/>
0 - ?<br/>
1 - A<br/>
2 - B<br/>
3 - AB<br/>
4 - 0
|-
| $76 || 1 || Last booted cartridge developer/publisher ID
|-
| $77 || 1 || Last booted cartridge game ID
|-
| $78 || 1 || Last booted cartridge game version
|-
| $7C || 1 || Stored cartridge ID/version change counter
|-
| $7D || 1 || Owner name change counter
|-
| $7E || 2 || System startup counter
|-
| $83 || 1 || Color console configuration
|-
| $84 || ? || [[Splash animation|Custom splash animation]], if present
|}
=== Owner name character set ===
{| class="wikitable"
|-
!
! <code>.0</code>
! <code>.1</code>
! <code>.2</code>
! <code>.3</code>
! <code>.4</code>
! <code>.5</code>
! <code>.6</code>
! <code>.7</code>
! <code>.8</code>
! <code>.9</code>
! <code>.A</code>
! <code>.B</code>
! <code>.C</code>
! <code>.D</code>
! <code>.E</code>
! <code>.F</code>
|-
! <code>0.</code>
| || 0 || 1 || 2 || 3 || 4 || 5 || 6 || 7 || 8 || 9 || A || B || C || D || E
|-
! <code>1.</code>
| F || G || H || I || J || K || L || M || N || O || P || Q || R || S || T || U
|-
! <code>2.</code>
| V || W || X || Y || Z || ♥ || ♪ || + || - || ? || .
!
!
!
!
!
|}
=== Color console configuration ===
<pre>
7 bit 0
---- ----
sc.. ..vv
|| ||
|| ++- Volume level
|+-------- Contrast (WSC): 0 = Low, 1 = High
+--------- Custom splash animation enabled
</pre>
== Hardware notes ==
EEPROM command bits are shifted out starting from the ''most'' significant bit of the port.
<pre>
+----> EEPROM Serial Data
|
[0] <= [0000 0001 ooaa aaaa]
EEPROM Command Port
</pre>
While the M93LCx6 family supports byte organization, the WonderSwan always uses word organization. As such, this implementation detail is omitted in this documentation.
== Errata ==
=== Non-word access on ASWAN ===
On the ASWAN SoC, accessing the internal EEPROM command ports as bytes only works correctly for even addresses. For odd addresses, these accesses return open bus; this means that unaligned word accesses also don't work, as they are converted to one odd and one even byte access internally.
It is recommended to only use aligned word port accesses to talk to the internal EEPROM.
This issue is not present on the SPHINX and newer SoCs, including in "mono" emulation mode, as well as the cartridge bus (which is always forced to be accessed per byte).
== Links ==
* [https://www.st.com/resource/en/datasheet/m93c46-w.pdf STMicroelectronics M93LCx6 datasheet]
2a973f19a21d1071367a2ccf3b4187e7c30fdcf9
281
280
2024-05-28T14:07:25Z
Asie
351
/* Internal EEPROM Control ($BE, $BF write) */
wikitext
text/x-wiki
The WonderSwan utilizes M93LCx6-compatible EEPROMs:
* in the SoC:
** 1 Kbit internal EEPROM (M93LC46-compatible) on the WonderSwan,
** 16 Kbit internal EEPROM (M93LC86-compatible) on the WonderSwan Color,
* on cartridges:
** 1 Kbit cartridge EEPROM (M93LC46-compatible)
** 8 Kbit cartridge EEPROM (M93LC76-compatible)
** 16 Kbit cartridge EEPROM (M93LC86-compatible)
Additional variants exists which were not seen on any production cartridge:
* 256 bit EEPROM (M93LC06-compatible)
* 2 Kbit EEPROM (M93LC56-compatible)
* 4 Kbit EEPROM (M93LC66-compatible)
== Commands ==
=== READ - Read Word ===
The READ command takes an address of a word (address 0 => bytes 0, 1; address 1 => bytes 2, 3; ...) and returns the word at that address.
=== WRITE - Write Word ===
The WRITE command takes an address of a word (address 0 => bytes 0, 1; address 1 => bytes 2, 3; ...) and the word to write to it, then writes the word.
=== ERASE - Erase Word ===
The ERASE command takes an address of a word (address 0 => bytes 0, 1; address 1 => bytes 2, 3; ...) and erases the word at that address, setting it to 0xFFFF.
=== WDS - Write Disable ===
TODO
=== WRAL - Write All ===
This command is not guaranteed to be present on all EEPROMs.
TODO
=== ERAL - Erase All ===
This command is not guaranteed to be present on all EEPROMs.
TODO
=== WEN - Write Enable ===
TODO
== I/O ports ==
The I/O ports listed refer to the internal EEPROM; for the cartridge EEPROM port numbers, refer to the [[Bandai 2001|mapper documentation]].
It is recommended to only access the data and command ports with aligned word reads/writes; see the ''Errata'' section for more information.
{{Anchor|Internal EEPROM Data}}
=== Internal EEPROM Data ($BA, $BB) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
dddd dddd dddd dddd
|||| |||| |||| ||||
++++-++++--++++-++++- Data read from/written to the EEPROM.
</pre>
This port functions as a shared buffer for both "read" and "write" modes. (TODO: Verify)
{{Anchor|Internal EEPROM Command}}
=== Internal EEPROM Command ($BC, $BD) ===
<pre>
Command Pattern 1
15 bit 8 7 bit 0
---- ---- ---- ----
0000 0001 ooaa aaaa (¼, 1 Kbit - M93LC06/46)
0000 01oo aaaa aaaa (2, 4 Kbit - M93LC56/66)
0001 ooaa aaaa aaaa (8, 16 Kbit - M93LC76/86)
|||| |||| ||||
||++--++++-++++- Address (MSb .. LSb)
++-------------- Opcode:
01 - WRITE
10 - READ
11 - ERASE
</pre>
<pre>
Command Pattern 2
15 bit 8 7 bit 0
---- ---- ---- ----
0000 0001 00ss .... (¼, 1 Kbit - M93LC06/46)
0000 0100 ss.. .... (2, 4 Kbit - M93LC56/66)
0001 00ss .... .... (8, 16 Kbit - M93LC76/86)
||
++------------ Sub-Opcode:
00 - WDS
01 - WRAL
01 - ERAL
11 - WEN
</pre>
The value written to this port can be read back; it is not affected by ''EEPROM Control''.
{{Anchor|Internal EEPROM Control}}
=== Internal EEPROM Control ($BE, $BF write) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
.... .... PSWR ....
||||
|||+------ Read mode: 1 for READ command, 0 otherwise
||+------- Write mode: 1 for WRITE and WRAL command, 0 otherwise
|+-------- Short mode: 1 for ERASE, WDS, ERAL and WEN command, 0 otherwise
+--------- 1 to enable internal EEPROM write protection.
Cannot be cleared once set.
</pre>
The ''mode'' flags control the behaviour of the EEPROM interface:
* Read mode: Sends 16 bits from Command, then reads 16 bits to Data.
* Write mode: Sends 16 bits from Command, then 16 bits from Data. De-asserts Microwire chip select, then re-asserts it and waits for the EEPROM to confirm command completion.
* Short mode: Sends 16 bits from Command, de-asserts Microwire chip select.
Also note that nothing inside the SoC or 2001 checks that the contents of the command register matches the bit set in this register.
{{Anchor|Internal EEPROM Status}}
=== Internal EEPROM Status ($BE, $BF read) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
.... .... p... ..rd
| ||
| |+- 0 after a Read command is initiated,
| | 1 once a Read command is completed.
| | Unaffected by Write/Erase commands.
| +-- 0 if the EEPROM is busy,
| 1 if a command can be accepted (idle).
+--------- Internal EEPROM write protection:
0 = disabled, 1 = enabled
</pre>
== Internal EEPROM Layout ==
{| class="wikitable"
|-
! Offset !! Length !! Contents
|-
| $00 || 96 || Program data. Can be written by programs even if write protection has been enabled.
|-
| $60 || 16 || Owner name, custom character set.
|-
| $70 || 1 || Owner birthday year, BCD, first/higher two digits
|-
| $71 || 1 || Owner birthday year, BCD, last/lower two digits
|-
| $72 || 1 || Owner birthday month, BCD
|-
| $73 || 1 || Owner birthday day, BCD
|-
| $74 || 1 || Owner gender:<br/>
0 - ?<br/>
1 - Male<br/>
2 - Female
|-
| $75 || 1 || Owner blood type:<br/>
0 - ?<br/>
1 - A<br/>
2 - B<br/>
3 - AB<br/>
4 - 0
|-
| $76 || 1 || Last booted cartridge developer/publisher ID
|-
| $77 || 1 || Last booted cartridge game ID
|-
| $78 || 1 || Last booted cartridge game version
|-
| $7C || 1 || Stored cartridge ID/version change counter
|-
| $7D || 1 || Owner name change counter
|-
| $7E || 2 || System startup counter
|-
| $83 || 1 || Color console configuration
|-
| $84 || ? || [[Splash animation|Custom splash animation]], if present
|}
=== Owner name character set ===
{| class="wikitable"
|-
!
! <code>.0</code>
! <code>.1</code>
! <code>.2</code>
! <code>.3</code>
! <code>.4</code>
! <code>.5</code>
! <code>.6</code>
! <code>.7</code>
! <code>.8</code>
! <code>.9</code>
! <code>.A</code>
! <code>.B</code>
! <code>.C</code>
! <code>.D</code>
! <code>.E</code>
! <code>.F</code>
|-
! <code>0.</code>
| || 0 || 1 || 2 || 3 || 4 || 5 || 6 || 7 || 8 || 9 || A || B || C || D || E
|-
! <code>1.</code>
| F || G || H || I || J || K || L || M || N || O || P || Q || R || S || T || U
|-
! <code>2.</code>
| V || W || X || Y || Z || ♥ || ♪ || + || - || ? || .
!
!
!
!
!
|}
=== Color console configuration ===
<pre>
7 bit 0
---- ----
sc.. ..vv
|| ||
|| ++- Volume level
|+-------- Contrast (WSC): 0 = Low, 1 = High
+--------- Custom splash animation enabled
</pre>
== Hardware notes ==
EEPROM command bits are shifted out starting from the ''most'' significant bit of the port.
<pre>
+----> EEPROM Serial Data
|
[0] <= [0000 0001 ooaa aaaa]
EEPROM Command Port
</pre>
While the M93LCx6 family supports byte organization, the WonderSwan always uses word organization. As such, this implementation detail is omitted in this documentation.
== Errata ==
=== Non-word access on ASWAN ===
On the ASWAN SoC, accessing the internal EEPROM command ports as bytes only works correctly for even addresses. For odd addresses, these accesses return open bus; this means that unaligned word accesses also don't work, as they are converted to one odd and one even byte access internally.
It is recommended to only use aligned word port accesses to talk to the internal EEPROM.
This issue is not present on the SPHINX and newer SoCs, including in "mono" emulation mode, as well as the cartridge bus (which is always forced to be accessed per byte).
== Links ==
* [https://www.st.com/resource/en/datasheet/m93c46-w.pdf STMicroelectronics M93LCx6 datasheet]
f25d5c847c04df893df4e5b637de7743f7cb6a8f
282
281
2024-05-28T14:07:30Z
Asie
351
/* Internal EEPROM Status ($BE, $BF read) */
wikitext
text/x-wiki
The WonderSwan utilizes M93LCx6-compatible EEPROMs:
* in the SoC:
** 1 Kbit internal EEPROM (M93LC46-compatible) on the WonderSwan,
** 16 Kbit internal EEPROM (M93LC86-compatible) on the WonderSwan Color,
* on cartridges:
** 1 Kbit cartridge EEPROM (M93LC46-compatible)
** 8 Kbit cartridge EEPROM (M93LC76-compatible)
** 16 Kbit cartridge EEPROM (M93LC86-compatible)
Additional variants exists which were not seen on any production cartridge:
* 256 bit EEPROM (M93LC06-compatible)
* 2 Kbit EEPROM (M93LC56-compatible)
* 4 Kbit EEPROM (M93LC66-compatible)
== Commands ==
=== READ - Read Word ===
The READ command takes an address of a word (address 0 => bytes 0, 1; address 1 => bytes 2, 3; ...) and returns the word at that address.
=== WRITE - Write Word ===
The WRITE command takes an address of a word (address 0 => bytes 0, 1; address 1 => bytes 2, 3; ...) and the word to write to it, then writes the word.
=== ERASE - Erase Word ===
The ERASE command takes an address of a word (address 0 => bytes 0, 1; address 1 => bytes 2, 3; ...) and erases the word at that address, setting it to 0xFFFF.
=== WDS - Write Disable ===
TODO
=== WRAL - Write All ===
This command is not guaranteed to be present on all EEPROMs.
TODO
=== ERAL - Erase All ===
This command is not guaranteed to be present on all EEPROMs.
TODO
=== WEN - Write Enable ===
TODO
== I/O ports ==
The I/O ports listed refer to the internal EEPROM; for the cartridge EEPROM port numbers, refer to the [[Bandai 2001|mapper documentation]].
It is recommended to only access the data and command ports with aligned word reads/writes; see the ''Errata'' section for more information.
{{Anchor|Internal EEPROM Data}}
=== Internal EEPROM Data ($BA, $BB) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
dddd dddd dddd dddd
|||| |||| |||| ||||
++++-++++--++++-++++- Data read from/written to the EEPROM.
</pre>
This port functions as a shared buffer for both "read" and "write" modes. (TODO: Verify)
{{Anchor|Internal EEPROM Command}}
=== Internal EEPROM Command ($BC, $BD) ===
<pre>
Command Pattern 1
15 bit 8 7 bit 0
---- ---- ---- ----
0000 0001 ooaa aaaa (¼, 1 Kbit - M93LC06/46)
0000 01oo aaaa aaaa (2, 4 Kbit - M93LC56/66)
0001 ooaa aaaa aaaa (8, 16 Kbit - M93LC76/86)
|||| |||| ||||
||++--++++-++++- Address (MSb .. LSb)
++-------------- Opcode:
01 - WRITE
10 - READ
11 - ERASE
</pre>
<pre>
Command Pattern 2
15 bit 8 7 bit 0
---- ---- ---- ----
0000 0001 00ss .... (¼, 1 Kbit - M93LC06/46)
0000 0100 ss.. .... (2, 4 Kbit - M93LC56/66)
0001 00ss .... .... (8, 16 Kbit - M93LC76/86)
||
++------------ Sub-Opcode:
00 - WDS
01 - WRAL
01 - ERAL
11 - WEN
</pre>
The value written to this port can be read back; it is not affected by ''EEPROM Control''.
{{Anchor|Internal EEPROM Control}}
=== Internal EEPROM Control ($BE, $BF write) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
.... .... PSWR ....
||||
|||+------ Read mode: 1 for READ command, 0 otherwise
||+------- Write mode: 1 for WRITE and WRAL command, 0 otherwise
|+-------- Short mode: 1 for ERASE, WDS, ERAL and WEN command, 0 otherwise
+--------- 1 to enable internal EEPROM write protection.
Cannot be cleared once set.
</pre>
The ''mode'' flags control the behaviour of the EEPROM interface:
* Read mode: Sends 16 bits from Command, then reads 16 bits to Data.
* Write mode: Sends 16 bits from Command, then 16 bits from Data. De-asserts Microwire chip select, then re-asserts it and waits for the EEPROM to confirm command completion.
* Short mode: Sends 16 bits from Command, de-asserts Microwire chip select.
Also note that nothing inside the SoC or 2001 checks that the contents of the command register matches the bit set in this register.
{{Anchor|Internal EEPROM Status}}
=== Internal EEPROM Status ($BE, $BF read) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
.... .... P... ..rd
| ||
| |+- 0 after a Read command is initiated,
| | 1 once a Read command is completed.
| | Unaffected by Write/Erase commands.
| +-- 0 if the EEPROM is busy,
| 1 if a command can be accepted (idle).
+--------- Internal EEPROM write protection:
0 = disabled, 1 = enabled
</pre>
== Internal EEPROM Layout ==
{| class="wikitable"
|-
! Offset !! Length !! Contents
|-
| $00 || 96 || Program data. Can be written by programs even if write protection has been enabled.
|-
| $60 || 16 || Owner name, custom character set.
|-
| $70 || 1 || Owner birthday year, BCD, first/higher two digits
|-
| $71 || 1 || Owner birthday year, BCD, last/lower two digits
|-
| $72 || 1 || Owner birthday month, BCD
|-
| $73 || 1 || Owner birthday day, BCD
|-
| $74 || 1 || Owner gender:<br/>
0 - ?<br/>
1 - Male<br/>
2 - Female
|-
| $75 || 1 || Owner blood type:<br/>
0 - ?<br/>
1 - A<br/>
2 - B<br/>
3 - AB<br/>
4 - 0
|-
| $76 || 1 || Last booted cartridge developer/publisher ID
|-
| $77 || 1 || Last booted cartridge game ID
|-
| $78 || 1 || Last booted cartridge game version
|-
| $7C || 1 || Stored cartridge ID/version change counter
|-
| $7D || 1 || Owner name change counter
|-
| $7E || 2 || System startup counter
|-
| $83 || 1 || Color console configuration
|-
| $84 || ? || [[Splash animation|Custom splash animation]], if present
|}
=== Owner name character set ===
{| class="wikitable"
|-
!
! <code>.0</code>
! <code>.1</code>
! <code>.2</code>
! <code>.3</code>
! <code>.4</code>
! <code>.5</code>
! <code>.6</code>
! <code>.7</code>
! <code>.8</code>
! <code>.9</code>
! <code>.A</code>
! <code>.B</code>
! <code>.C</code>
! <code>.D</code>
! <code>.E</code>
! <code>.F</code>
|-
! <code>0.</code>
| || 0 || 1 || 2 || 3 || 4 || 5 || 6 || 7 || 8 || 9 || A || B || C || D || E
|-
! <code>1.</code>
| F || G || H || I || J || K || L || M || N || O || P || Q || R || S || T || U
|-
! <code>2.</code>
| V || W || X || Y || Z || ♥ || ♪ || + || - || ? || .
!
!
!
!
!
|}
=== Color console configuration ===
<pre>
7 bit 0
---- ----
sc.. ..vv
|| ||
|| ++- Volume level
|+-------- Contrast (WSC): 0 = Low, 1 = High
+--------- Custom splash animation enabled
</pre>
== Hardware notes ==
EEPROM command bits are shifted out starting from the ''most'' significant bit of the port.
<pre>
+----> EEPROM Serial Data
|
[0] <= [0000 0001 ooaa aaaa]
EEPROM Command Port
</pre>
While the M93LCx6 family supports byte organization, the WonderSwan always uses word organization. As such, this implementation detail is omitted in this documentation.
== Errata ==
=== Non-word access on ASWAN ===
On the ASWAN SoC, accessing the internal EEPROM command ports as bytes only works correctly for even addresses. For odd addresses, these accesses return open bus; this means that unaligned word accesses also don't work, as they are converted to one odd and one even byte access internally.
It is recommended to only use aligned word port accesses to talk to the internal EEPROM.
This issue is not present on the SPHINX and newer SoCs, including in "mono" emulation mode, as well as the cartridge bus (which is always forced to be accessed per byte).
== Links ==
* [https://www.st.com/resource/en/datasheet/m93c46-w.pdf STMicroelectronics M93LCx6 datasheet]
ee90a6c1e840eabd13de13c07b81a3abd072167e
284
282
2024-05-28T14:09:30Z
Asie
351
/* Internal EEPROM Control ($BE, $BF write) */
wikitext
text/x-wiki
The WonderSwan utilizes M93LCx6-compatible EEPROMs:
* in the SoC:
** 1 Kbit internal EEPROM (M93LC46-compatible) on the WonderSwan,
** 16 Kbit internal EEPROM (M93LC86-compatible) on the WonderSwan Color,
* on cartridges:
** 1 Kbit cartridge EEPROM (M93LC46-compatible)
** 8 Kbit cartridge EEPROM (M93LC76-compatible)
** 16 Kbit cartridge EEPROM (M93LC86-compatible)
Additional variants exists which were not seen on any production cartridge:
* 256 bit EEPROM (M93LC06-compatible)
* 2 Kbit EEPROM (M93LC56-compatible)
* 4 Kbit EEPROM (M93LC66-compatible)
== Commands ==
=== READ - Read Word ===
The READ command takes an address of a word (address 0 => bytes 0, 1; address 1 => bytes 2, 3; ...) and returns the word at that address.
=== WRITE - Write Word ===
The WRITE command takes an address of a word (address 0 => bytes 0, 1; address 1 => bytes 2, 3; ...) and the word to write to it, then writes the word.
=== ERASE - Erase Word ===
The ERASE command takes an address of a word (address 0 => bytes 0, 1; address 1 => bytes 2, 3; ...) and erases the word at that address, setting it to 0xFFFF.
=== WDS - Write Disable ===
TODO
=== WRAL - Write All ===
This command is not guaranteed to be present on all EEPROMs.
TODO
=== ERAL - Erase All ===
This command is not guaranteed to be present on all EEPROMs.
TODO
=== WEN - Write Enable ===
TODO
== I/O ports ==
The I/O ports listed refer to the internal EEPROM; for the cartridge EEPROM port numbers, refer to the [[Bandai 2001|mapper documentation]].
It is recommended to only access the data and command ports with aligned word reads/writes; see the ''Errata'' section for more information.
{{Anchor|Internal EEPROM Data}}
=== Internal EEPROM Data ($BA, $BB) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
dddd dddd dddd dddd
|||| |||| |||| ||||
++++-++++--++++-++++- Data read from/written to the EEPROM.
</pre>
This port functions as a shared buffer for both "read" and "write" modes. (TODO: Verify)
{{Anchor|Internal EEPROM Command}}
=== Internal EEPROM Command ($BC, $BD) ===
<pre>
Command Pattern 1
15 bit 8 7 bit 0
---- ---- ---- ----
0000 0001 ooaa aaaa (¼, 1 Kbit - M93LC06/46)
0000 01oo aaaa aaaa (2, 4 Kbit - M93LC56/66)
0001 ooaa aaaa aaaa (8, 16 Kbit - M93LC76/86)
|||| |||| ||||
||++--++++-++++- Address (MSb .. LSb)
++-------------- Opcode:
01 - WRITE
10 - READ
11 - ERASE
</pre>
<pre>
Command Pattern 2
15 bit 8 7 bit 0
---- ---- ---- ----
0000 0001 00ss .... (¼, 1 Kbit - M93LC06/46)
0000 0100 ss.. .... (2, 4 Kbit - M93LC56/66)
0001 00ss .... .... (8, 16 Kbit - M93LC76/86)
||
++------------ Sub-Opcode:
00 - WDS
01 - WRAL
01 - ERAL
11 - WEN
</pre>
The value written to this port can be read back; it is not affected by ''EEPROM Control''.
{{Anchor|Internal EEPROM Control}}
=== Internal EEPROM Control ($BE, $BF write) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
.... .... PSWR ....
||||
|||+------ Read mode: 1 for READ command, 0 otherwise
||+------- Write mode: 1 for WRITE and WRAL command, 0 otherwise
|+-------- Short mode: 1 for ERASE, WDS, ERAL and WEN command, 0 otherwise
+--------- 1 to enable internal EEPROM write protection.
Cannot be cleared once set.
</pre>
The ''mode'' flags control the behaviour of the EEPROM interface:
* Read mode: Sends 16 bits from Command, then reads 16 bits to Data.
* Write mode: Sends 16 bits from Command, then 16 bits from Data. De-asserts Microwire chip select, then re-asserts it and waits for the EEPROM to confirm command completion.
* Short mode: Sends 16 bits from Command, de-asserts Microwire chip select.
If more than one of the Read, Write, Short bits are set, the command is treated as invalid (all three bits are cleared and no EEPROM operation is performed).
Also note that nothing inside the SoC or 2001 checks that the contents of the command register matches the bit set in this register.
{{Anchor|Internal EEPROM Status}}
=== Internal EEPROM Status ($BE, $BF read) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
.... .... P... ..rd
| ||
| |+- 0 after a Read command is initiated,
| | 1 once a Read command is completed.
| | Unaffected by Write/Erase commands.
| +-- 0 if the EEPROM is busy,
| 1 if a command can be accepted (idle).
+--------- Internal EEPROM write protection:
0 = disabled, 1 = enabled
</pre>
== Internal EEPROM Layout ==
{| class="wikitable"
|-
! Offset !! Length !! Contents
|-
| $00 || 96 || Program data. Can be written by programs even if write protection has been enabled.
|-
| $60 || 16 || Owner name, custom character set.
|-
| $70 || 1 || Owner birthday year, BCD, first/higher two digits
|-
| $71 || 1 || Owner birthday year, BCD, last/lower two digits
|-
| $72 || 1 || Owner birthday month, BCD
|-
| $73 || 1 || Owner birthday day, BCD
|-
| $74 || 1 || Owner gender:<br/>
0 - ?<br/>
1 - Male<br/>
2 - Female
|-
| $75 || 1 || Owner blood type:<br/>
0 - ?<br/>
1 - A<br/>
2 - B<br/>
3 - AB<br/>
4 - 0
|-
| $76 || 1 || Last booted cartridge developer/publisher ID
|-
| $77 || 1 || Last booted cartridge game ID
|-
| $78 || 1 || Last booted cartridge game version
|-
| $7C || 1 || Stored cartridge ID/version change counter
|-
| $7D || 1 || Owner name change counter
|-
| $7E || 2 || System startup counter
|-
| $83 || 1 || Color console configuration
|-
| $84 || ? || [[Splash animation|Custom splash animation]], if present
|}
=== Owner name character set ===
{| class="wikitable"
|-
!
! <code>.0</code>
! <code>.1</code>
! <code>.2</code>
! <code>.3</code>
! <code>.4</code>
! <code>.5</code>
! <code>.6</code>
! <code>.7</code>
! <code>.8</code>
! <code>.9</code>
! <code>.A</code>
! <code>.B</code>
! <code>.C</code>
! <code>.D</code>
! <code>.E</code>
! <code>.F</code>
|-
! <code>0.</code>
| || 0 || 1 || 2 || 3 || 4 || 5 || 6 || 7 || 8 || 9 || A || B || C || D || E
|-
! <code>1.</code>
| F || G || H || I || J || K || L || M || N || O || P || Q || R || S || T || U
|-
! <code>2.</code>
| V || W || X || Y || Z || ♥ || ♪ || + || - || ? || .
!
!
!
!
!
|}
=== Color console configuration ===
<pre>
7 bit 0
---- ----
sc.. ..vv
|| ||
|| ++- Volume level
|+-------- Contrast (WSC): 0 = Low, 1 = High
+--------- Custom splash animation enabled
</pre>
== Hardware notes ==
EEPROM command bits are shifted out starting from the ''most'' significant bit of the port.
<pre>
+----> EEPROM Serial Data
|
[0] <= [0000 0001 ooaa aaaa]
EEPROM Command Port
</pre>
While the M93LCx6 family supports byte organization, the WonderSwan always uses word organization. As such, this implementation detail is omitted in this documentation.
== Errata ==
=== Non-word access on ASWAN ===
On the ASWAN SoC, accessing the internal EEPROM command ports as bytes only works correctly for even addresses. For odd addresses, these accesses return open bus; this means that unaligned word accesses also don't work, as they are converted to one odd and one even byte access internally.
It is recommended to only use aligned word port accesses to talk to the internal EEPROM.
This issue is not present on the SPHINX and newer SoCs, including in "mono" emulation mode, as well as the cartridge bus (which is always forced to be accessed per byte).
== Links ==
* [https://www.st.com/resource/en/datasheet/m93c46-w.pdf STMicroelectronics M93LCx6 datasheet]
74a120ec36518094a940030e31155acd46b9c5f9
285
284
2024-05-28T14:10:22Z
Asie
351
/* Internal EEPROM Command ($BC, $BD) */
wikitext
text/x-wiki
The WonderSwan utilizes M93LCx6-compatible EEPROMs:
* in the SoC:
** 1 Kbit internal EEPROM (M93LC46-compatible) on the WonderSwan,
** 16 Kbit internal EEPROM (M93LC86-compatible) on the WonderSwan Color,
* on cartridges:
** 1 Kbit cartridge EEPROM (M93LC46-compatible)
** 8 Kbit cartridge EEPROM (M93LC76-compatible)
** 16 Kbit cartridge EEPROM (M93LC86-compatible)
Additional variants exists which were not seen on any production cartridge:
* 256 bit EEPROM (M93LC06-compatible)
* 2 Kbit EEPROM (M93LC56-compatible)
* 4 Kbit EEPROM (M93LC66-compatible)
== Commands ==
=== READ - Read Word ===
The READ command takes an address of a word (address 0 => bytes 0, 1; address 1 => bytes 2, 3; ...) and returns the word at that address.
=== WRITE - Write Word ===
The WRITE command takes an address of a word (address 0 => bytes 0, 1; address 1 => bytes 2, 3; ...) and the word to write to it, then writes the word.
=== ERASE - Erase Word ===
The ERASE command takes an address of a word (address 0 => bytes 0, 1; address 1 => bytes 2, 3; ...) and erases the word at that address, setting it to 0xFFFF.
=== WDS - Write Disable ===
TODO
=== WRAL - Write All ===
This command is not guaranteed to be present on all EEPROMs.
TODO
=== ERAL - Erase All ===
This command is not guaranteed to be present on all EEPROMs.
TODO
=== WEN - Write Enable ===
TODO
== I/O ports ==
The I/O ports listed refer to the internal EEPROM; for the cartridge EEPROM port numbers, refer to the [[Bandai 2001|mapper documentation]].
It is recommended to only access the data and command ports with aligned word reads/writes; see the ''Errata'' section for more information.
{{Anchor|Internal EEPROM Data}}
=== Internal EEPROM Data ($BA, $BB) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
dddd dddd dddd dddd
|||| |||| |||| ||||
++++-++++--++++-++++- Data read from/written to the EEPROM.
</pre>
This port functions as a shared buffer for both "read" and "write" modes. (TODO: Verify)
{{Anchor|Internal EEPROM Command}}
=== Internal EEPROM Command ($BC, $BD) ===
<pre>
Command Pattern 1
15 bit 8 7 bit 0
---- ---- ---- ----
0000 0001 ooaa aaaa (¼, 1 Kbit - M93LC06/46)
0000 01oo aaaa aaaa (2, 4 Kbit - M93LC56/66)
0001 ooaa aaaa aaaa (8, 16 Kbit - M93LC76/86)
|||| |||| ||||
||++--++++-++++- Address (MSb .. LSb)
++-------------- Opcode:
01 - WRITE
10 - READ
11 - ERASE
</pre>
<pre>
Command Pattern 2
15 bit 8 7 bit 0
---- ---- ---- ----
0000 0001 00ss .... (¼, 1 Kbit - M93LC06/46)
0000 0100 ss.. .... (2, 4 Kbit - M93LC56/66)
0001 00ss .... .... (8, 16 Kbit - M93LC76/86)
||||
||++------------ Sub-Opcode:
|| 00 - WDS
|| 01 - WRAL
|| 01 - ERAL
|| 11 - WEN
++-------------- Opcode:
00
</pre>
The value written to this port can be read back; it is not affected by ''EEPROM Control''.
{{Anchor|Internal EEPROM Control}}
=== Internal EEPROM Control ($BE, $BF write) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
.... .... PSWR ....
||||
|||+------ Read mode: 1 for READ command, 0 otherwise
||+------- Write mode: 1 for WRITE and WRAL command, 0 otherwise
|+-------- Short mode: 1 for ERASE, WDS, ERAL and WEN command, 0 otherwise
+--------- 1 to enable internal EEPROM write protection.
Cannot be cleared once set.
</pre>
The ''mode'' flags control the behaviour of the EEPROM interface:
* Read mode: Sends 16 bits from Command, then reads 16 bits to Data.
* Write mode: Sends 16 bits from Command, then 16 bits from Data. De-asserts Microwire chip select, then re-asserts it and waits for the EEPROM to confirm command completion.
* Short mode: Sends 16 bits from Command, de-asserts Microwire chip select.
If more than one of the Read, Write, Short bits are set, the command is treated as invalid (all three bits are cleared and no EEPROM operation is performed).
Also note that nothing inside the SoC or 2001 checks that the contents of the command register matches the bit set in this register.
{{Anchor|Internal EEPROM Status}}
=== Internal EEPROM Status ($BE, $BF read) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
.... .... P... ..rd
| ||
| |+- 0 after a Read command is initiated,
| | 1 once a Read command is completed.
| | Unaffected by Write/Erase commands.
| +-- 0 if the EEPROM is busy,
| 1 if a command can be accepted (idle).
+--------- Internal EEPROM write protection:
0 = disabled, 1 = enabled
</pre>
== Internal EEPROM Layout ==
{| class="wikitable"
|-
! Offset !! Length !! Contents
|-
| $00 || 96 || Program data. Can be written by programs even if write protection has been enabled.
|-
| $60 || 16 || Owner name, custom character set.
|-
| $70 || 1 || Owner birthday year, BCD, first/higher two digits
|-
| $71 || 1 || Owner birthday year, BCD, last/lower two digits
|-
| $72 || 1 || Owner birthday month, BCD
|-
| $73 || 1 || Owner birthday day, BCD
|-
| $74 || 1 || Owner gender:<br/>
0 - ?<br/>
1 - Male<br/>
2 - Female
|-
| $75 || 1 || Owner blood type:<br/>
0 - ?<br/>
1 - A<br/>
2 - B<br/>
3 - AB<br/>
4 - 0
|-
| $76 || 1 || Last booted cartridge developer/publisher ID
|-
| $77 || 1 || Last booted cartridge game ID
|-
| $78 || 1 || Last booted cartridge game version
|-
| $7C || 1 || Stored cartridge ID/version change counter
|-
| $7D || 1 || Owner name change counter
|-
| $7E || 2 || System startup counter
|-
| $83 || 1 || Color console configuration
|-
| $84 || ? || [[Splash animation|Custom splash animation]], if present
|}
=== Owner name character set ===
{| class="wikitable"
|-
!
! <code>.0</code>
! <code>.1</code>
! <code>.2</code>
! <code>.3</code>
! <code>.4</code>
! <code>.5</code>
! <code>.6</code>
! <code>.7</code>
! <code>.8</code>
! <code>.9</code>
! <code>.A</code>
! <code>.B</code>
! <code>.C</code>
! <code>.D</code>
! <code>.E</code>
! <code>.F</code>
|-
! <code>0.</code>
| || 0 || 1 || 2 || 3 || 4 || 5 || 6 || 7 || 8 || 9 || A || B || C || D || E
|-
! <code>1.</code>
| F || G || H || I || J || K || L || M || N || O || P || Q || R || S || T || U
|-
! <code>2.</code>
| V || W || X || Y || Z || ♥ || ♪ || + || - || ? || .
!
!
!
!
!
|}
=== Color console configuration ===
<pre>
7 bit 0
---- ----
sc.. ..vv
|| ||
|| ++- Volume level
|+-------- Contrast (WSC): 0 = Low, 1 = High
+--------- Custom splash animation enabled
</pre>
== Hardware notes ==
EEPROM command bits are shifted out starting from the ''most'' significant bit of the port.
<pre>
+----> EEPROM Serial Data
|
[0] <= [0000 0001 ooaa aaaa]
EEPROM Command Port
</pre>
While the M93LCx6 family supports byte organization, the WonderSwan always uses word organization. As such, this implementation detail is omitted in this documentation.
== Errata ==
=== Non-word access on ASWAN ===
On the ASWAN SoC, accessing the internal EEPROM command ports as bytes only works correctly for even addresses. For odd addresses, these accesses return open bus; this means that unaligned word accesses also don't work, as they are converted to one odd and one even byte access internally.
It is recommended to only use aligned word port accesses to talk to the internal EEPROM.
This issue is not present on the SPHINX and newer SoCs, including in "mono" emulation mode, as well as the cartridge bus (which is always forced to be accessed per byte).
== Links ==
* [https://www.st.com/resource/en/datasheet/m93c46-w.pdf STMicroelectronics M93LCx6 datasheet]
541c3daeab8f723debf3e545d4ab0c03308f31f0
286
285
2024-05-28T14:14:45Z
Asie
351
/* Internal EEPROM Data ($BA, $BB) */
wikitext
text/x-wiki
The WonderSwan utilizes M93LCx6-compatible EEPROMs:
* in the SoC:
** 1 Kbit internal EEPROM (M93LC46-compatible) on the WonderSwan,
** 16 Kbit internal EEPROM (M93LC86-compatible) on the WonderSwan Color,
* on cartridges:
** 1 Kbit cartridge EEPROM (M93LC46-compatible)
** 8 Kbit cartridge EEPROM (M93LC76-compatible)
** 16 Kbit cartridge EEPROM (M93LC86-compatible)
Additional variants exists which were not seen on any production cartridge:
* 256 bit EEPROM (M93LC06-compatible)
* 2 Kbit EEPROM (M93LC56-compatible)
* 4 Kbit EEPROM (M93LC66-compatible)
== Commands ==
=== READ - Read Word ===
The READ command takes an address of a word (address 0 => bytes 0, 1; address 1 => bytes 2, 3; ...) and returns the word at that address.
=== WRITE - Write Word ===
The WRITE command takes an address of a word (address 0 => bytes 0, 1; address 1 => bytes 2, 3; ...) and the word to write to it, then writes the word.
=== ERASE - Erase Word ===
The ERASE command takes an address of a word (address 0 => bytes 0, 1; address 1 => bytes 2, 3; ...) and erases the word at that address, setting it to 0xFFFF.
=== WDS - Write Disable ===
TODO
=== WRAL - Write All ===
This command is not guaranteed to be present on all EEPROMs.
TODO
=== ERAL - Erase All ===
This command is not guaranteed to be present on all EEPROMs.
TODO
=== WEN - Write Enable ===
TODO
== I/O ports ==
The I/O ports listed refer to the internal EEPROM; for the cartridge EEPROM port numbers, refer to the [[Bandai 2001|mapper documentation]].
It is recommended to only access the data and command ports with aligned word reads/writes; see the ''Errata'' section for more information.
{{Anchor|Internal EEPROM Data}}
=== Internal EEPROM Data ($BA, $BB read) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
dddd dddd dddd dddd
|||| |||| |||| ||||
++++-++++--++++-++++- Data read from the EEPROM.
</pre>
=== Internal EEPROM Data ($BA, $BB write) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
dddd dddd dddd dddd
|||| |||| |||| ||||
++++-++++--++++-++++- Data to write to the EEPROM.
</pre>
The two EEPROM data buffers are not shared; neither writes to the write buffer nor the execution of non-read commands affect the contents of the read buffer.
{{Anchor|Internal EEPROM Command}}
=== Internal EEPROM Command ($BC, $BD) ===
<pre>
Command Pattern 1
15 bit 8 7 bit 0
---- ---- ---- ----
0000 0001 ooaa aaaa (¼, 1 Kbit - M93LC06/46)
0000 01oo aaaa aaaa (2, 4 Kbit - M93LC56/66)
0001 ooaa aaaa aaaa (8, 16 Kbit - M93LC76/86)
|||| |||| ||||
||++--++++-++++- Address (MSb .. LSb)
++-------------- Opcode:
01 - WRITE
10 - READ
11 - ERASE
</pre>
<pre>
Command Pattern 2
15 bit 8 7 bit 0
---- ---- ---- ----
0000 0001 00ss .... (¼, 1 Kbit - M93LC06/46)
0000 0100 ss.. .... (2, 4 Kbit - M93LC56/66)
0001 00ss .... .... (8, 16 Kbit - M93LC76/86)
||||
||++------------ Sub-Opcode:
|| 00 - WDS
|| 01 - WRAL
|| 01 - ERAL
|| 11 - WEN
++-------------- Opcode:
00
</pre>
The value written to this port can be read back; it is not affected by ''EEPROM Control''.
{{Anchor|Internal EEPROM Control}}
=== Internal EEPROM Control ($BE, $BF write) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
.... .... PSWR ....
||||
|||+------ Read mode: 1 for READ command, 0 otherwise
||+------- Write mode: 1 for WRITE and WRAL command, 0 otherwise
|+-------- Short mode: 1 for ERASE, WDS, ERAL and WEN command, 0 otherwise
+--------- 1 to enable internal EEPROM write protection.
Cannot be cleared once set.
</pre>
The ''mode'' flags control the behaviour of the EEPROM interface:
* Read mode: Sends 16 bits from Command, then reads 16 bits to Data.
* Write mode: Sends 16 bits from Command, then 16 bits from Data. De-asserts Microwire chip select, then re-asserts it and waits for the EEPROM to confirm command completion.
* Short mode: Sends 16 bits from Command, de-asserts Microwire chip select.
If more than one of the Read, Write, Short bits are set, the command is treated as invalid (all three bits are cleared and no EEPROM operation is performed).
Also note that nothing inside the SoC or 2001 checks that the contents of the command register matches the bit set in this register.
{{Anchor|Internal EEPROM Status}}
=== Internal EEPROM Status ($BE, $BF read) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
.... .... P... ..rd
| ||
| |+- 0 after a Read command is initiated,
| | 1 once a Read command is completed.
| | Unaffected by Write/Erase commands.
| +-- 0 if the EEPROM is busy,
| 1 if a command can be accepted (idle).
+--------- Internal EEPROM write protection:
0 = disabled, 1 = enabled
</pre>
== Internal EEPROM Layout ==
{| class="wikitable"
|-
! Offset !! Length !! Contents
|-
| $00 || 96 || Program data. Can be written by programs even if write protection has been enabled.
|-
| $60 || 16 || Owner name, custom character set.
|-
| $70 || 1 || Owner birthday year, BCD, first/higher two digits
|-
| $71 || 1 || Owner birthday year, BCD, last/lower two digits
|-
| $72 || 1 || Owner birthday month, BCD
|-
| $73 || 1 || Owner birthday day, BCD
|-
| $74 || 1 || Owner gender:<br/>
0 - ?<br/>
1 - Male<br/>
2 - Female
|-
| $75 || 1 || Owner blood type:<br/>
0 - ?<br/>
1 - A<br/>
2 - B<br/>
3 - AB<br/>
4 - 0
|-
| $76 || 1 || Last booted cartridge developer/publisher ID
|-
| $77 || 1 || Last booted cartridge game ID
|-
| $78 || 1 || Last booted cartridge game version
|-
| $7C || 1 || Stored cartridge ID/version change counter
|-
| $7D || 1 || Owner name change counter
|-
| $7E || 2 || System startup counter
|-
| $83 || 1 || Color console configuration
|-
| $84 || ? || [[Splash animation|Custom splash animation]], if present
|}
=== Owner name character set ===
{| class="wikitable"
|-
!
! <code>.0</code>
! <code>.1</code>
! <code>.2</code>
! <code>.3</code>
! <code>.4</code>
! <code>.5</code>
! <code>.6</code>
! <code>.7</code>
! <code>.8</code>
! <code>.9</code>
! <code>.A</code>
! <code>.B</code>
! <code>.C</code>
! <code>.D</code>
! <code>.E</code>
! <code>.F</code>
|-
! <code>0.</code>
| || 0 || 1 || 2 || 3 || 4 || 5 || 6 || 7 || 8 || 9 || A || B || C || D || E
|-
! <code>1.</code>
| F || G || H || I || J || K || L || M || N || O || P || Q || R || S || T || U
|-
! <code>2.</code>
| V || W || X || Y || Z || ♥ || ♪ || + || - || ? || .
!
!
!
!
!
|}
=== Color console configuration ===
<pre>
7 bit 0
---- ----
sc.. ..vv
|| ||
|| ++- Volume level
|+-------- Contrast (WSC): 0 = Low, 1 = High
+--------- Custom splash animation enabled
</pre>
== Hardware notes ==
EEPROM command bits are shifted out starting from the ''most'' significant bit of the port.
<pre>
+----> EEPROM Serial Data
|
[0] <= [0000 0001 ooaa aaaa]
EEPROM Command Port
</pre>
While the M93LCx6 family supports byte organization, the WonderSwan always uses word organization. As such, this implementation detail is omitted in this documentation.
== Errata ==
=== Non-word access on ASWAN ===
On the ASWAN SoC, accessing the internal EEPROM command ports as bytes only works correctly for even addresses. For odd addresses, these accesses return open bus; this means that unaligned word accesses also don't work, as they are converted to one odd and one even byte access internally.
It is recommended to only use aligned word port accesses to talk to the internal EEPROM.
This issue is not present on the SPHINX and newer SoCs, including in "mono" emulation mode, as well as the cartridge bus (which is always forced to be accessed per byte).
== Links ==
* [https://www.st.com/resource/en/datasheet/m93c46-w.pdf STMicroelectronics M93LCx6 datasheet]
29b1f0df6e448075bbab41ea9f274b1dd89e675f
287
286
2024-05-28T14:23:55Z
Asie
351
/* Internal EEPROM Data ($BA, $BB write) */
wikitext
text/x-wiki
The WonderSwan utilizes M93LCx6-compatible EEPROMs:
* in the SoC:
** 1 Kbit internal EEPROM (M93LC46-compatible) on the WonderSwan,
** 16 Kbit internal EEPROM (M93LC86-compatible) on the WonderSwan Color,
* on cartridges:
** 1 Kbit cartridge EEPROM (M93LC46-compatible)
** 8 Kbit cartridge EEPROM (M93LC76-compatible)
** 16 Kbit cartridge EEPROM (M93LC86-compatible)
Additional variants exists which were not seen on any production cartridge:
* 256 bit EEPROM (M93LC06-compatible)
* 2 Kbit EEPROM (M93LC56-compatible)
* 4 Kbit EEPROM (M93LC66-compatible)
== Commands ==
=== READ - Read Word ===
The READ command takes an address of a word (address 0 => bytes 0, 1; address 1 => bytes 2, 3; ...) and returns the word at that address.
=== WRITE - Write Word ===
The WRITE command takes an address of a word (address 0 => bytes 0, 1; address 1 => bytes 2, 3; ...) and the word to write to it, then writes the word.
=== ERASE - Erase Word ===
The ERASE command takes an address of a word (address 0 => bytes 0, 1; address 1 => bytes 2, 3; ...) and erases the word at that address, setting it to 0xFFFF.
=== WDS - Write Disable ===
TODO
=== WRAL - Write All ===
This command is not guaranteed to be present on all EEPROMs.
TODO
=== ERAL - Erase All ===
This command is not guaranteed to be present on all EEPROMs.
TODO
=== WEN - Write Enable ===
TODO
== I/O ports ==
The I/O ports listed refer to the internal EEPROM; for the cartridge EEPROM port numbers, refer to the [[Bandai 2001|mapper documentation]].
It is recommended to only access the data and command ports with aligned word reads/writes; see the ''Errata'' section for more information.
{{Anchor|Internal EEPROM Data}}
=== Internal EEPROM Data ($BA, $BB read) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
dddd dddd dddd dddd
|||| |||| |||| ||||
++++-++++--++++-++++- Data read from the EEPROM.
</pre>
=== Internal EEPROM Data ($BA, $BB write) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
dddd dddd dddd dddd
|||| |||| |||| ||||
++++-++++--++++-++++- Data to write to the EEPROM.
</pre>
The write buffer is latched when a Write command is initiated; further writes to it do not affect the value written by that specific command.
The two EEPROM data buffers are not shared; neither writes to the write buffer nor the execution of non-read commands affect the contents of the read buffer.
{{Anchor|Internal EEPROM Command}}
=== Internal EEPROM Command ($BC, $BD) ===
<pre>
Command Pattern 1
15 bit 8 7 bit 0
---- ---- ---- ----
0000 0001 ooaa aaaa (¼, 1 Kbit - M93LC06/46)
0000 01oo aaaa aaaa (2, 4 Kbit - M93LC56/66)
0001 ooaa aaaa aaaa (8, 16 Kbit - M93LC76/86)
|||| |||| ||||
||++--++++-++++- Address (MSb .. LSb)
++-------------- Opcode:
01 - WRITE
10 - READ
11 - ERASE
</pre>
<pre>
Command Pattern 2
15 bit 8 7 bit 0
---- ---- ---- ----
0000 0001 00ss .... (¼, 1 Kbit - M93LC06/46)
0000 0100 ss.. .... (2, 4 Kbit - M93LC56/66)
0001 00ss .... .... (8, 16 Kbit - M93LC76/86)
||||
||++------------ Sub-Opcode:
|| 00 - WDS
|| 01 - WRAL
|| 01 - ERAL
|| 11 - WEN
++-------------- Opcode:
00
</pre>
The value written to this port can be read back; it is not affected by ''EEPROM Control''.
{{Anchor|Internal EEPROM Control}}
=== Internal EEPROM Control ($BE, $BF write) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
.... .... PSWR ....
||||
|||+------ Read mode: 1 for READ command, 0 otherwise
||+------- Write mode: 1 for WRITE and WRAL command, 0 otherwise
|+-------- Short mode: 1 for ERASE, WDS, ERAL and WEN command, 0 otherwise
+--------- 1 to enable internal EEPROM write protection.
Cannot be cleared once set.
</pre>
The ''mode'' flags control the behaviour of the EEPROM interface:
* Read mode: Sends 16 bits from Command, then reads 16 bits to Data.
* Write mode: Sends 16 bits from Command, then 16 bits from Data. De-asserts Microwire chip select, then re-asserts it and waits for the EEPROM to confirm command completion.
* Short mode: Sends 16 bits from Command, de-asserts Microwire chip select.
If more than one of the Read, Write, Short bits are set, the command is treated as invalid (all three bits are cleared and no EEPROM operation is performed).
Also note that nothing inside the SoC or 2001 checks that the contents of the command register matches the bit set in this register.
{{Anchor|Internal EEPROM Status}}
=== Internal EEPROM Status ($BE, $BF read) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
.... .... P... ..rd
| ||
| |+- 0 after a Read command is initiated,
| | 1 once a Read command is completed.
| | Unaffected by Write/Erase commands.
| +-- 0 if the EEPROM is busy,
| 1 if a command can be accepted (idle).
+--------- Internal EEPROM write protection:
0 = disabled, 1 = enabled
</pre>
== Internal EEPROM Layout ==
{| class="wikitable"
|-
! Offset !! Length !! Contents
|-
| $00 || 96 || Program data. Can be written by programs even if write protection has been enabled.
|-
| $60 || 16 || Owner name, custom character set.
|-
| $70 || 1 || Owner birthday year, BCD, first/higher two digits
|-
| $71 || 1 || Owner birthday year, BCD, last/lower two digits
|-
| $72 || 1 || Owner birthday month, BCD
|-
| $73 || 1 || Owner birthday day, BCD
|-
| $74 || 1 || Owner gender:<br/>
0 - ?<br/>
1 - Male<br/>
2 - Female
|-
| $75 || 1 || Owner blood type:<br/>
0 - ?<br/>
1 - A<br/>
2 - B<br/>
3 - AB<br/>
4 - 0
|-
| $76 || 1 || Last booted cartridge developer/publisher ID
|-
| $77 || 1 || Last booted cartridge game ID
|-
| $78 || 1 || Last booted cartridge game version
|-
| $7C || 1 || Stored cartridge ID/version change counter
|-
| $7D || 1 || Owner name change counter
|-
| $7E || 2 || System startup counter
|-
| $83 || 1 || Color console configuration
|-
| $84 || ? || [[Splash animation|Custom splash animation]], if present
|}
=== Owner name character set ===
{| class="wikitable"
|-
!
! <code>.0</code>
! <code>.1</code>
! <code>.2</code>
! <code>.3</code>
! <code>.4</code>
! <code>.5</code>
! <code>.6</code>
! <code>.7</code>
! <code>.8</code>
! <code>.9</code>
! <code>.A</code>
! <code>.B</code>
! <code>.C</code>
! <code>.D</code>
! <code>.E</code>
! <code>.F</code>
|-
! <code>0.</code>
| || 0 || 1 || 2 || 3 || 4 || 5 || 6 || 7 || 8 || 9 || A || B || C || D || E
|-
! <code>1.</code>
| F || G || H || I || J || K || L || M || N || O || P || Q || R || S || T || U
|-
! <code>2.</code>
| V || W || X || Y || Z || ♥ || ♪ || + || - || ? || .
!
!
!
!
!
|}
=== Color console configuration ===
<pre>
7 bit 0
---- ----
sc.. ..vv
|| ||
|| ++- Volume level
|+-------- Contrast (WSC): 0 = Low, 1 = High
+--------- Custom splash animation enabled
</pre>
== Hardware notes ==
EEPROM command bits are shifted out starting from the ''most'' significant bit of the port.
<pre>
+----> EEPROM Serial Data
|
[0] <= [0000 0001 ooaa aaaa]
EEPROM Command Port
</pre>
While the M93LCx6 family supports byte organization, the WonderSwan always uses word organization. As such, this implementation detail is omitted in this documentation.
== Errata ==
=== Non-word access on ASWAN ===
On the ASWAN SoC, accessing the internal EEPROM command ports as bytes only works correctly for even addresses. For odd addresses, these accesses return open bus; this means that unaligned word accesses also don't work, as they are converted to one odd and one even byte access internally.
It is recommended to only use aligned word port accesses to talk to the internal EEPROM.
This issue is not present on the SPHINX and newer SoCs, including in "mono" emulation mode, as well as the cartridge bus (which is always forced to be accessed per byte).
== Links ==
* [https://www.st.com/resource/en/datasheet/m93c46-w.pdf STMicroelectronics M93LCx6 datasheet]
da0976b4d7017e9433da446e9a339e839cd4c7f7
288
287
2024-05-28T14:24:20Z
Asie
351
/* Internal EEPROM Data ($BA, $BB read) */
wikitext
text/x-wiki
The WonderSwan utilizes M93LCx6-compatible EEPROMs:
* in the SoC:
** 1 Kbit internal EEPROM (M93LC46-compatible) on the WonderSwan,
** 16 Kbit internal EEPROM (M93LC86-compatible) on the WonderSwan Color,
* on cartridges:
** 1 Kbit cartridge EEPROM (M93LC46-compatible)
** 8 Kbit cartridge EEPROM (M93LC76-compatible)
** 16 Kbit cartridge EEPROM (M93LC86-compatible)
Additional variants exists which were not seen on any production cartridge:
* 256 bit EEPROM (M93LC06-compatible)
* 2 Kbit EEPROM (M93LC56-compatible)
* 4 Kbit EEPROM (M93LC66-compatible)
== Commands ==
=== READ - Read Word ===
The READ command takes an address of a word (address 0 => bytes 0, 1; address 1 => bytes 2, 3; ...) and returns the word at that address.
=== WRITE - Write Word ===
The WRITE command takes an address of a word (address 0 => bytes 0, 1; address 1 => bytes 2, 3; ...) and the word to write to it, then writes the word.
=== ERASE - Erase Word ===
The ERASE command takes an address of a word (address 0 => bytes 0, 1; address 1 => bytes 2, 3; ...) and erases the word at that address, setting it to 0xFFFF.
=== WDS - Write Disable ===
TODO
=== WRAL - Write All ===
This command is not guaranteed to be present on all EEPROMs.
TODO
=== ERAL - Erase All ===
This command is not guaranteed to be present on all EEPROMs.
TODO
=== WEN - Write Enable ===
TODO
== I/O ports ==
The I/O ports listed refer to the internal EEPROM; for the cartridge EEPROM port numbers, refer to the [[Bandai 2001|mapper documentation]].
It is recommended to only access the data and command ports with aligned word reads/writes; see the ''Errata'' section for more information.
{{Anchor|Internal EEPROM Data}}
=== Internal EEPROM Data ($BA, $BB read) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
dddd dddd dddd dddd
|||| |||| |||| ||||
++++-++++--++++-++++- Data read from the EEPROM.
</pre>
The read buffer's value changes only once the Read command is completed.
=== Internal EEPROM Data ($BA, $BB write) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
dddd dddd dddd dddd
|||| |||| |||| ||||
++++-++++--++++-++++- Data to write to the EEPROM.
</pre>
The write buffer is latched when a Write command is initiated; further writes to it do not affect the value written by that specific command.
The two EEPROM data buffers are not shared; neither writes to the write buffer nor the execution of non-read commands affect the contents of the read buffer.
{{Anchor|Internal EEPROM Command}}
=== Internal EEPROM Command ($BC, $BD) ===
<pre>
Command Pattern 1
15 bit 8 7 bit 0
---- ---- ---- ----
0000 0001 ooaa aaaa (¼, 1 Kbit - M93LC06/46)
0000 01oo aaaa aaaa (2, 4 Kbit - M93LC56/66)
0001 ooaa aaaa aaaa (8, 16 Kbit - M93LC76/86)
|||| |||| ||||
||++--++++-++++- Address (MSb .. LSb)
++-------------- Opcode:
01 - WRITE
10 - READ
11 - ERASE
</pre>
<pre>
Command Pattern 2
15 bit 8 7 bit 0
---- ---- ---- ----
0000 0001 00ss .... (¼, 1 Kbit - M93LC06/46)
0000 0100 ss.. .... (2, 4 Kbit - M93LC56/66)
0001 00ss .... .... (8, 16 Kbit - M93LC76/86)
||||
||++------------ Sub-Opcode:
|| 00 - WDS
|| 01 - WRAL
|| 01 - ERAL
|| 11 - WEN
++-------------- Opcode:
00
</pre>
The value written to this port can be read back; it is not affected by ''EEPROM Control''.
{{Anchor|Internal EEPROM Control}}
=== Internal EEPROM Control ($BE, $BF write) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
.... .... PSWR ....
||||
|||+------ Read mode: 1 for READ command, 0 otherwise
||+------- Write mode: 1 for WRITE and WRAL command, 0 otherwise
|+-------- Short mode: 1 for ERASE, WDS, ERAL and WEN command, 0 otherwise
+--------- 1 to enable internal EEPROM write protection.
Cannot be cleared once set.
</pre>
The ''mode'' flags control the behaviour of the EEPROM interface:
* Read mode: Sends 16 bits from Command, then reads 16 bits to Data.
* Write mode: Sends 16 bits from Command, then 16 bits from Data. De-asserts Microwire chip select, then re-asserts it and waits for the EEPROM to confirm command completion.
* Short mode: Sends 16 bits from Command, de-asserts Microwire chip select.
If more than one of the Read, Write, Short bits are set, the command is treated as invalid (all three bits are cleared and no EEPROM operation is performed).
Also note that nothing inside the SoC or 2001 checks that the contents of the command register matches the bit set in this register.
{{Anchor|Internal EEPROM Status}}
=== Internal EEPROM Status ($BE, $BF read) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
.... .... P... ..rd
| ||
| |+- 0 after a Read command is initiated,
| | 1 once a Read command is completed.
| | Unaffected by Write/Erase commands.
| +-- 0 if the EEPROM is busy,
| 1 if a command can be accepted (idle).
+--------- Internal EEPROM write protection:
0 = disabled, 1 = enabled
</pre>
== Internal EEPROM Layout ==
{| class="wikitable"
|-
! Offset !! Length !! Contents
|-
| $00 || 96 || Program data. Can be written by programs even if write protection has been enabled.
|-
| $60 || 16 || Owner name, custom character set.
|-
| $70 || 1 || Owner birthday year, BCD, first/higher two digits
|-
| $71 || 1 || Owner birthday year, BCD, last/lower two digits
|-
| $72 || 1 || Owner birthday month, BCD
|-
| $73 || 1 || Owner birthday day, BCD
|-
| $74 || 1 || Owner gender:<br/>
0 - ?<br/>
1 - Male<br/>
2 - Female
|-
| $75 || 1 || Owner blood type:<br/>
0 - ?<br/>
1 - A<br/>
2 - B<br/>
3 - AB<br/>
4 - 0
|-
| $76 || 1 || Last booted cartridge developer/publisher ID
|-
| $77 || 1 || Last booted cartridge game ID
|-
| $78 || 1 || Last booted cartridge game version
|-
| $7C || 1 || Stored cartridge ID/version change counter
|-
| $7D || 1 || Owner name change counter
|-
| $7E || 2 || System startup counter
|-
| $83 || 1 || Color console configuration
|-
| $84 || ? || [[Splash animation|Custom splash animation]], if present
|}
=== Owner name character set ===
{| class="wikitable"
|-
!
! <code>.0</code>
! <code>.1</code>
! <code>.2</code>
! <code>.3</code>
! <code>.4</code>
! <code>.5</code>
! <code>.6</code>
! <code>.7</code>
! <code>.8</code>
! <code>.9</code>
! <code>.A</code>
! <code>.B</code>
! <code>.C</code>
! <code>.D</code>
! <code>.E</code>
! <code>.F</code>
|-
! <code>0.</code>
| || 0 || 1 || 2 || 3 || 4 || 5 || 6 || 7 || 8 || 9 || A || B || C || D || E
|-
! <code>1.</code>
| F || G || H || I || J || K || L || M || N || O || P || Q || R || S || T || U
|-
! <code>2.</code>
| V || W || X || Y || Z || ♥ || ♪ || + || - || ? || .
!
!
!
!
!
|}
=== Color console configuration ===
<pre>
7 bit 0
---- ----
sc.. ..vv
|| ||
|| ++- Volume level
|+-------- Contrast (WSC): 0 = Low, 1 = High
+--------- Custom splash animation enabled
</pre>
== Hardware notes ==
EEPROM command bits are shifted out starting from the ''most'' significant bit of the port.
<pre>
+----> EEPROM Serial Data
|
[0] <= [0000 0001 ooaa aaaa]
EEPROM Command Port
</pre>
While the M93LCx6 family supports byte organization, the WonderSwan always uses word organization. As such, this implementation detail is omitted in this documentation.
== Errata ==
=== Non-word access on ASWAN ===
On the ASWAN SoC, accessing the internal EEPROM command ports as bytes only works correctly for even addresses. For odd addresses, these accesses return open bus; this means that unaligned word accesses also don't work, as they are converted to one odd and one even byte access internally.
It is recommended to only use aligned word port accesses to talk to the internal EEPROM.
This issue is not present on the SPHINX and newer SoCs, including in "mono" emulation mode, as well as the cartridge bus (which is always forced to be accessed per byte).
== Links ==
* [https://www.st.com/resource/en/datasheet/m93c46-w.pdf STMicroelectronics M93LCx6 datasheet]
d7bb0773281c752048287abf5c75f3fa938dc8f6
289
288
2024-05-28T19:45:32Z
Asie
351
/* Internal EEPROM Control ($BE, $BF write) */
wikitext
text/x-wiki
The WonderSwan utilizes M93LCx6-compatible EEPROMs:
* in the SoC:
** 1 Kbit internal EEPROM (M93LC46-compatible) on the WonderSwan,
** 16 Kbit internal EEPROM (M93LC86-compatible) on the WonderSwan Color,
* on cartridges:
** 1 Kbit cartridge EEPROM (M93LC46-compatible)
** 8 Kbit cartridge EEPROM (M93LC76-compatible)
** 16 Kbit cartridge EEPROM (M93LC86-compatible)
Additional variants exists which were not seen on any production cartridge:
* 256 bit EEPROM (M93LC06-compatible)
* 2 Kbit EEPROM (M93LC56-compatible)
* 4 Kbit EEPROM (M93LC66-compatible)
== Commands ==
=== READ - Read Word ===
The READ command takes an address of a word (address 0 => bytes 0, 1; address 1 => bytes 2, 3; ...) and returns the word at that address.
=== WRITE - Write Word ===
The WRITE command takes an address of a word (address 0 => bytes 0, 1; address 1 => bytes 2, 3; ...) and the word to write to it, then writes the word.
=== ERASE - Erase Word ===
The ERASE command takes an address of a word (address 0 => bytes 0, 1; address 1 => bytes 2, 3; ...) and erases the word at that address, setting it to 0xFFFF.
=== WDS - Write Disable ===
TODO
=== WRAL - Write All ===
This command is not guaranteed to be present on all EEPROMs.
TODO
=== ERAL - Erase All ===
This command is not guaranteed to be present on all EEPROMs.
TODO
=== WEN - Write Enable ===
TODO
== I/O ports ==
The I/O ports listed refer to the internal EEPROM; for the cartridge EEPROM port numbers, refer to the [[Bandai 2001|mapper documentation]].
It is recommended to only access the data and command ports with aligned word reads/writes; see the ''Errata'' section for more information.
{{Anchor|Internal EEPROM Data}}
=== Internal EEPROM Data ($BA, $BB read) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
dddd dddd dddd dddd
|||| |||| |||| ||||
++++-++++--++++-++++- Data read from the EEPROM.
</pre>
The read buffer's value changes only once the Read command is completed.
=== Internal EEPROM Data ($BA, $BB write) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
dddd dddd dddd dddd
|||| |||| |||| ||||
++++-++++--++++-++++- Data to write to the EEPROM.
</pre>
The write buffer is latched when a Write command is initiated; further writes to it do not affect the value written by that specific command.
The two EEPROM data buffers are not shared; neither writes to the write buffer nor the execution of non-read commands affect the contents of the read buffer.
{{Anchor|Internal EEPROM Command}}
=== Internal EEPROM Command ($BC, $BD) ===
<pre>
Command Pattern 1
15 bit 8 7 bit 0
---- ---- ---- ----
0000 0001 ooaa aaaa (¼, 1 Kbit - M93LC06/46)
0000 01oo aaaa aaaa (2, 4 Kbit - M93LC56/66)
0001 ooaa aaaa aaaa (8, 16 Kbit - M93LC76/86)
|||| |||| ||||
||++--++++-++++- Address (MSb .. LSb)
++-------------- Opcode:
01 - WRITE
10 - READ
11 - ERASE
</pre>
<pre>
Command Pattern 2
15 bit 8 7 bit 0
---- ---- ---- ----
0000 0001 00ss .... (¼, 1 Kbit - M93LC06/46)
0000 0100 ss.. .... (2, 4 Kbit - M93LC56/66)
0001 00ss .... .... (8, 16 Kbit - M93LC76/86)
||||
||++------------ Sub-Opcode:
|| 00 - WDS
|| 01 - WRAL
|| 01 - ERAL
|| 11 - WEN
++-------------- Opcode:
00
</pre>
The value written to this port can be read back; it is not affected by ''EEPROM Control''.
{{Anchor|Internal EEPROM Control}}
=== Internal EEPROM Control ($BE, $BF write) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
.... .... PSWR ....
||||
|||+------ Read command: 1 for READ command, 0 otherwise
||+------- Write command: 1 for WRITE and WRAL command, 0 otherwise
|+-------- Short command: 1 for ERASE, WDS, ERAL and WEN command, 0 otherwise
+--------- Protection: 1 to enable internal EEPROM write protection.
Cannot be cleared once set.
</pre>
* Read command Sends 16 bits from Command, then reads 16 bits to Data.
* Write command: Sends 16 bits from Command, then 16 bits from Data. De-asserts Microwire chip select, then re-asserts it and waits for the EEPROM to confirm command completion.
* Short command: Sends 16 bits from Command, de-asserts Microwire chip select.
* Protection: Enables internal EEPROM write protection (addresses >= 0x30, or anything after the first 96 bytes, can no longer be written to).
If more than one of the Read, Write, Short, Protect bits are set, the command is treated as invalid (operation bits are cleared and no EEPROM operation is performed). Notably, this means that writing 0x90 does not protect the internal EEPROM if it wasn't already protected, but writing 0x80 does.
The command requested here should match the command sent to the EEPROM in port ''$BC''.
{{Anchor|Internal EEPROM Status}}
=== Internal EEPROM Status ($BE, $BF read) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
.... .... P... ..rd
| ||
| |+- 0 after a Read command is initiated,
| | 1 once a Read command is completed.
| | Unaffected by Write/Erase commands.
| +-- 0 if the EEPROM is busy,
| 1 if a command can be accepted (idle).
+--------- Internal EEPROM write protection:
0 = disabled, 1 = enabled
</pre>
== Internal EEPROM Layout ==
{| class="wikitable"
|-
! Offset !! Length !! Contents
|-
| $00 || 96 || Program data. Can be written by programs even if write protection has been enabled.
|-
| $60 || 16 || Owner name, custom character set.
|-
| $70 || 1 || Owner birthday year, BCD, first/higher two digits
|-
| $71 || 1 || Owner birthday year, BCD, last/lower two digits
|-
| $72 || 1 || Owner birthday month, BCD
|-
| $73 || 1 || Owner birthday day, BCD
|-
| $74 || 1 || Owner gender:<br/>
0 - ?<br/>
1 - Male<br/>
2 - Female
|-
| $75 || 1 || Owner blood type:<br/>
0 - ?<br/>
1 - A<br/>
2 - B<br/>
3 - AB<br/>
4 - 0
|-
| $76 || 1 || Last booted cartridge developer/publisher ID
|-
| $77 || 1 || Last booted cartridge game ID
|-
| $78 || 1 || Last booted cartridge game version
|-
| $7C || 1 || Stored cartridge ID/version change counter
|-
| $7D || 1 || Owner name change counter
|-
| $7E || 2 || System startup counter
|-
| $83 || 1 || Color console configuration
|-
| $84 || ? || [[Splash animation|Custom splash animation]], if present
|}
=== Owner name character set ===
{| class="wikitable"
|-
!
! <code>.0</code>
! <code>.1</code>
! <code>.2</code>
! <code>.3</code>
! <code>.4</code>
! <code>.5</code>
! <code>.6</code>
! <code>.7</code>
! <code>.8</code>
! <code>.9</code>
! <code>.A</code>
! <code>.B</code>
! <code>.C</code>
! <code>.D</code>
! <code>.E</code>
! <code>.F</code>
|-
! <code>0.</code>
| || 0 || 1 || 2 || 3 || 4 || 5 || 6 || 7 || 8 || 9 || A || B || C || D || E
|-
! <code>1.</code>
| F || G || H || I || J || K || L || M || N || O || P || Q || R || S || T || U
|-
! <code>2.</code>
| V || W || X || Y || Z || ♥ || ♪ || + || - || ? || .
!
!
!
!
!
|}
=== Color console configuration ===
<pre>
7 bit 0
---- ----
sc.. ..vv
|| ||
|| ++- Volume level
|+-------- Contrast (WSC): 0 = Low, 1 = High
+--------- Custom splash animation enabled
</pre>
== Hardware notes ==
EEPROM command bits are shifted out starting from the ''most'' significant bit of the port.
<pre>
+----> EEPROM Serial Data
|
[0] <= [0000 0001 ooaa aaaa]
EEPROM Command Port
</pre>
While the M93LCx6 family supports byte organization, the WonderSwan always uses word organization. As such, this implementation detail is omitted in this documentation.
== Errata ==
=== Non-word access on ASWAN ===
On the ASWAN SoC, accessing the internal EEPROM command ports as bytes only works correctly for even addresses. For odd addresses, these accesses return open bus; this means that unaligned word accesses also don't work, as they are converted to one odd and one even byte access internally.
It is recommended to only use aligned word port accesses to talk to the internal EEPROM.
This issue is not present on the SPHINX and newer SoCs, including in "mono" emulation mode, as well as the cartridge bus (which is always forced to be accessed per byte).
== Links ==
* [https://www.st.com/resource/en/datasheet/m93c46-w.pdf STMicroelectronics M93LCx6 datasheet]
5768ed5d90a0a3af19360de67457cc5a1cabf728
290
289
2024-05-28T19:51:39Z
Asie
351
/* WDS - Write Disable */
wikitext
text/x-wiki
The WonderSwan utilizes M93LCx6-compatible EEPROMs:
* in the SoC:
** 1 Kbit internal EEPROM (M93LC46-compatible) on the WonderSwan,
** 16 Kbit internal EEPROM (M93LC86-compatible) on the WonderSwan Color,
* on cartridges:
** 1 Kbit cartridge EEPROM (M93LC46-compatible)
** 8 Kbit cartridge EEPROM (M93LC76-compatible)
** 16 Kbit cartridge EEPROM (M93LC86-compatible)
Additional variants exists which were not seen on any production cartridge:
* 256 bit EEPROM (M93LC06-compatible)
* 2 Kbit EEPROM (M93LC56-compatible)
* 4 Kbit EEPROM (M93LC66-compatible)
== Commands ==
=== READ - Read Word ===
The READ command takes an address of a word (address 0 => bytes 0, 1; address 1 => bytes 2, 3; ...) and returns the word at that address.
=== WRITE - Write Word ===
The WRITE command takes an address of a word (address 0 => bytes 0, 1; address 1 => bytes 2, 3; ...) and the word to write to it, then writes the word.
=== ERASE - Erase Word ===
The ERASE command takes an address of a word (address 0 => bytes 0, 1; address 1 => bytes 2, 3; ...) and erases the word at that address, setting it to 0xFFFF.
=== WDS - Write Disable ===
The WDS command prevents issued write and erase commands from having an effect on the EEPROM.
=== WRAL - Write All ===
This command is not guaranteed to be present on all EEPROMs.
TODO
=== ERAL - Erase All ===
This command is not guaranteed to be present on all EEPROMs.
TODO
=== WEN - Write Enable ===
TODO
== I/O ports ==
The I/O ports listed refer to the internal EEPROM; for the cartridge EEPROM port numbers, refer to the [[Bandai 2001|mapper documentation]].
It is recommended to only access the data and command ports with aligned word reads/writes; see the ''Errata'' section for more information.
{{Anchor|Internal EEPROM Data}}
=== Internal EEPROM Data ($BA, $BB read) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
dddd dddd dddd dddd
|||| |||| |||| ||||
++++-++++--++++-++++- Data read from the EEPROM.
</pre>
The read buffer's value changes only once the Read command is completed.
=== Internal EEPROM Data ($BA, $BB write) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
dddd dddd dddd dddd
|||| |||| |||| ||||
++++-++++--++++-++++- Data to write to the EEPROM.
</pre>
The write buffer is latched when a Write command is initiated; further writes to it do not affect the value written by that specific command.
The two EEPROM data buffers are not shared; neither writes to the write buffer nor the execution of non-read commands affect the contents of the read buffer.
{{Anchor|Internal EEPROM Command}}
=== Internal EEPROM Command ($BC, $BD) ===
<pre>
Command Pattern 1
15 bit 8 7 bit 0
---- ---- ---- ----
0000 0001 ooaa aaaa (¼, 1 Kbit - M93LC06/46)
0000 01oo aaaa aaaa (2, 4 Kbit - M93LC56/66)
0001 ooaa aaaa aaaa (8, 16 Kbit - M93LC76/86)
|||| |||| ||||
||++--++++-++++- Address (MSb .. LSb)
++-------------- Opcode:
01 - WRITE
10 - READ
11 - ERASE
</pre>
<pre>
Command Pattern 2
15 bit 8 7 bit 0
---- ---- ---- ----
0000 0001 00ss .... (¼, 1 Kbit - M93LC06/46)
0000 0100 ss.. .... (2, 4 Kbit - M93LC56/66)
0001 00ss .... .... (8, 16 Kbit - M93LC76/86)
||||
||++------------ Sub-Opcode:
|| 00 - WDS
|| 01 - WRAL
|| 01 - ERAL
|| 11 - WEN
++-------------- Opcode:
00
</pre>
The value written to this port can be read back; it is not affected by ''EEPROM Control''.
{{Anchor|Internal EEPROM Control}}
=== Internal EEPROM Control ($BE, $BF write) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
.... .... PSWR ....
||||
|||+------ Read command: 1 for READ command, 0 otherwise
||+------- Write command: 1 for WRITE and WRAL command, 0 otherwise
|+-------- Short command: 1 for ERASE, WDS, ERAL and WEN command, 0 otherwise
+--------- Protection: 1 to enable internal EEPROM write protection.
Cannot be cleared once set.
</pre>
* Read command Sends 16 bits from Command, then reads 16 bits to Data.
* Write command: Sends 16 bits from Command, then 16 bits from Data. De-asserts Microwire chip select, then re-asserts it and waits for the EEPROM to confirm command completion.
* Short command: Sends 16 bits from Command, de-asserts Microwire chip select.
* Protection: Enables internal EEPROM write protection (addresses >= 0x30, or anything after the first 96 bytes, can no longer be written to).
If more than one of the Read, Write, Short, Protect bits are set, the command is treated as invalid (operation bits are cleared and no EEPROM operation is performed). Notably, this means that writing 0x90 does not protect the internal EEPROM if it wasn't already protected, but writing 0x80 does.
The command requested here should match the command sent to the EEPROM in port ''$BC''.
{{Anchor|Internal EEPROM Status}}
=== Internal EEPROM Status ($BE, $BF read) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
.... .... P... ..rd
| ||
| |+- 0 after a Read command is initiated,
| | 1 once a Read command is completed.
| | Unaffected by Write/Erase commands.
| +-- 0 if the EEPROM is busy,
| 1 if a command can be accepted (idle).
+--------- Internal EEPROM write protection:
0 = disabled, 1 = enabled
</pre>
== Internal EEPROM Layout ==
{| class="wikitable"
|-
! Offset !! Length !! Contents
|-
| $00 || 96 || Program data. Can be written by programs even if write protection has been enabled.
|-
| $60 || 16 || Owner name, custom character set.
|-
| $70 || 1 || Owner birthday year, BCD, first/higher two digits
|-
| $71 || 1 || Owner birthday year, BCD, last/lower two digits
|-
| $72 || 1 || Owner birthday month, BCD
|-
| $73 || 1 || Owner birthday day, BCD
|-
| $74 || 1 || Owner gender:<br/>
0 - ?<br/>
1 - Male<br/>
2 - Female
|-
| $75 || 1 || Owner blood type:<br/>
0 - ?<br/>
1 - A<br/>
2 - B<br/>
3 - AB<br/>
4 - 0
|-
| $76 || 1 || Last booted cartridge developer/publisher ID
|-
| $77 || 1 || Last booted cartridge game ID
|-
| $78 || 1 || Last booted cartridge game version
|-
| $7C || 1 || Stored cartridge ID/version change counter
|-
| $7D || 1 || Owner name change counter
|-
| $7E || 2 || System startup counter
|-
| $83 || 1 || Color console configuration
|-
| $84 || ? || [[Splash animation|Custom splash animation]], if present
|}
=== Owner name character set ===
{| class="wikitable"
|-
!
! <code>.0</code>
! <code>.1</code>
! <code>.2</code>
! <code>.3</code>
! <code>.4</code>
! <code>.5</code>
! <code>.6</code>
! <code>.7</code>
! <code>.8</code>
! <code>.9</code>
! <code>.A</code>
! <code>.B</code>
! <code>.C</code>
! <code>.D</code>
! <code>.E</code>
! <code>.F</code>
|-
! <code>0.</code>
| || 0 || 1 || 2 || 3 || 4 || 5 || 6 || 7 || 8 || 9 || A || B || C || D || E
|-
! <code>1.</code>
| F || G || H || I || J || K || L || M || N || O || P || Q || R || S || T || U
|-
! <code>2.</code>
| V || W || X || Y || Z || ♥ || ♪ || + || - || ? || .
!
!
!
!
!
|}
=== Color console configuration ===
<pre>
7 bit 0
---- ----
sc.. ..vv
|| ||
|| ++- Volume level
|+-------- Contrast (WSC): 0 = Low, 1 = High
+--------- Custom splash animation enabled
</pre>
== Hardware notes ==
EEPROM command bits are shifted out starting from the ''most'' significant bit of the port.
<pre>
+----> EEPROM Serial Data
|
[0] <= [0000 0001 ooaa aaaa]
EEPROM Command Port
</pre>
While the M93LCx6 family supports byte organization, the WonderSwan always uses word organization. As such, this implementation detail is omitted in this documentation.
== Errata ==
=== Non-word access on ASWAN ===
On the ASWAN SoC, accessing the internal EEPROM command ports as bytes only works correctly for even addresses. For odd addresses, these accesses return open bus; this means that unaligned word accesses also don't work, as they are converted to one odd and one even byte access internally.
It is recommended to only use aligned word port accesses to talk to the internal EEPROM.
This issue is not present on the SPHINX and newer SoCs, including in "mono" emulation mode, as well as the cartridge bus (which is always forced to be accessed per byte).
== Links ==
* [https://www.st.com/resource/en/datasheet/m93c46-w.pdf STMicroelectronics M93LCx6 datasheet]
f123cb1ff2044a1cf6bd97c12bda646fb4380080
291
290
2024-05-28T19:51:55Z
Asie
351
/* WEN - Write Enable */
wikitext
text/x-wiki
The WonderSwan utilizes M93LCx6-compatible EEPROMs:
* in the SoC:
** 1 Kbit internal EEPROM (M93LC46-compatible) on the WonderSwan,
** 16 Kbit internal EEPROM (M93LC86-compatible) on the WonderSwan Color,
* on cartridges:
** 1 Kbit cartridge EEPROM (M93LC46-compatible)
** 8 Kbit cartridge EEPROM (M93LC76-compatible)
** 16 Kbit cartridge EEPROM (M93LC86-compatible)
Additional variants exists which were not seen on any production cartridge:
* 256 bit EEPROM (M93LC06-compatible)
* 2 Kbit EEPROM (M93LC56-compatible)
* 4 Kbit EEPROM (M93LC66-compatible)
== Commands ==
=== READ - Read Word ===
The READ command takes an address of a word (address 0 => bytes 0, 1; address 1 => bytes 2, 3; ...) and returns the word at that address.
=== WRITE - Write Word ===
The WRITE command takes an address of a word (address 0 => bytes 0, 1; address 1 => bytes 2, 3; ...) and the word to write to it, then writes the word.
=== ERASE - Erase Word ===
The ERASE command takes an address of a word (address 0 => bytes 0, 1; address 1 => bytes 2, 3; ...) and erases the word at that address, setting it to 0xFFFF.
=== WDS - Write Disable ===
The WDS command prevents issued write and erase commands from having an effect on the EEPROM.
=== WRAL - Write All ===
This command is not guaranteed to be present on all EEPROMs.
TODO
=== ERAL - Erase All ===
This command is not guaranteed to be present on all EEPROMs.
TODO
=== WEN - Write Enable ===
The WEN command restores the effect of issued write and erase commands on the EEPROM disabled using WDS.
== I/O ports ==
The I/O ports listed refer to the internal EEPROM; for the cartridge EEPROM port numbers, refer to the [[Bandai 2001|mapper documentation]].
It is recommended to only access the data and command ports with aligned word reads/writes; see the ''Errata'' section for more information.
{{Anchor|Internal EEPROM Data}}
=== Internal EEPROM Data ($BA, $BB read) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
dddd dddd dddd dddd
|||| |||| |||| ||||
++++-++++--++++-++++- Data read from the EEPROM.
</pre>
The read buffer's value changes only once the Read command is completed.
=== Internal EEPROM Data ($BA, $BB write) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
dddd dddd dddd dddd
|||| |||| |||| ||||
++++-++++--++++-++++- Data to write to the EEPROM.
</pre>
The write buffer is latched when a Write command is initiated; further writes to it do not affect the value written by that specific command.
The two EEPROM data buffers are not shared; neither writes to the write buffer nor the execution of non-read commands affect the contents of the read buffer.
{{Anchor|Internal EEPROM Command}}
=== Internal EEPROM Command ($BC, $BD) ===
<pre>
Command Pattern 1
15 bit 8 7 bit 0
---- ---- ---- ----
0000 0001 ooaa aaaa (¼, 1 Kbit - M93LC06/46)
0000 01oo aaaa aaaa (2, 4 Kbit - M93LC56/66)
0001 ooaa aaaa aaaa (8, 16 Kbit - M93LC76/86)
|||| |||| ||||
||++--++++-++++- Address (MSb .. LSb)
++-------------- Opcode:
01 - WRITE
10 - READ
11 - ERASE
</pre>
<pre>
Command Pattern 2
15 bit 8 7 bit 0
---- ---- ---- ----
0000 0001 00ss .... (¼, 1 Kbit - M93LC06/46)
0000 0100 ss.. .... (2, 4 Kbit - M93LC56/66)
0001 00ss .... .... (8, 16 Kbit - M93LC76/86)
||||
||++------------ Sub-Opcode:
|| 00 - WDS
|| 01 - WRAL
|| 01 - ERAL
|| 11 - WEN
++-------------- Opcode:
00
</pre>
The value written to this port can be read back; it is not affected by ''EEPROM Control''.
{{Anchor|Internal EEPROM Control}}
=== Internal EEPROM Control ($BE, $BF write) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
.... .... PSWR ....
||||
|||+------ Read command: 1 for READ command, 0 otherwise
||+------- Write command: 1 for WRITE and WRAL command, 0 otherwise
|+-------- Short command: 1 for ERASE, WDS, ERAL and WEN command, 0 otherwise
+--------- Protection: 1 to enable internal EEPROM write protection.
Cannot be cleared once set.
</pre>
* Read command Sends 16 bits from Command, then reads 16 bits to Data.
* Write command: Sends 16 bits from Command, then 16 bits from Data. De-asserts Microwire chip select, then re-asserts it and waits for the EEPROM to confirm command completion.
* Short command: Sends 16 bits from Command, de-asserts Microwire chip select.
* Protection: Enables internal EEPROM write protection (addresses >= 0x30, or anything after the first 96 bytes, can no longer be written to).
If more than one of the Read, Write, Short, Protect bits are set, the command is treated as invalid (operation bits are cleared and no EEPROM operation is performed). Notably, this means that writing 0x90 does not protect the internal EEPROM if it wasn't already protected, but writing 0x80 does.
The command requested here should match the command sent to the EEPROM in port ''$BC''.
{{Anchor|Internal EEPROM Status}}
=== Internal EEPROM Status ($BE, $BF read) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
.... .... P... ..rd
| ||
| |+- 0 after a Read command is initiated,
| | 1 once a Read command is completed.
| | Unaffected by Write/Erase commands.
| +-- 0 if the EEPROM is busy,
| 1 if a command can be accepted (idle).
+--------- Internal EEPROM write protection:
0 = disabled, 1 = enabled
</pre>
== Internal EEPROM Layout ==
{| class="wikitable"
|-
! Offset !! Length !! Contents
|-
| $00 || 96 || Program data. Can be written by programs even if write protection has been enabled.
|-
| $60 || 16 || Owner name, custom character set.
|-
| $70 || 1 || Owner birthday year, BCD, first/higher two digits
|-
| $71 || 1 || Owner birthday year, BCD, last/lower two digits
|-
| $72 || 1 || Owner birthday month, BCD
|-
| $73 || 1 || Owner birthday day, BCD
|-
| $74 || 1 || Owner gender:<br/>
0 - ?<br/>
1 - Male<br/>
2 - Female
|-
| $75 || 1 || Owner blood type:<br/>
0 - ?<br/>
1 - A<br/>
2 - B<br/>
3 - AB<br/>
4 - 0
|-
| $76 || 1 || Last booted cartridge developer/publisher ID
|-
| $77 || 1 || Last booted cartridge game ID
|-
| $78 || 1 || Last booted cartridge game version
|-
| $7C || 1 || Stored cartridge ID/version change counter
|-
| $7D || 1 || Owner name change counter
|-
| $7E || 2 || System startup counter
|-
| $83 || 1 || Color console configuration
|-
| $84 || ? || [[Splash animation|Custom splash animation]], if present
|}
=== Owner name character set ===
{| class="wikitable"
|-
!
! <code>.0</code>
! <code>.1</code>
! <code>.2</code>
! <code>.3</code>
! <code>.4</code>
! <code>.5</code>
! <code>.6</code>
! <code>.7</code>
! <code>.8</code>
! <code>.9</code>
! <code>.A</code>
! <code>.B</code>
! <code>.C</code>
! <code>.D</code>
! <code>.E</code>
! <code>.F</code>
|-
! <code>0.</code>
| || 0 || 1 || 2 || 3 || 4 || 5 || 6 || 7 || 8 || 9 || A || B || C || D || E
|-
! <code>1.</code>
| F || G || H || I || J || K || L || M || N || O || P || Q || R || S || T || U
|-
! <code>2.</code>
| V || W || X || Y || Z || ♥ || ♪ || + || - || ? || .
!
!
!
!
!
|}
=== Color console configuration ===
<pre>
7 bit 0
---- ----
sc.. ..vv
|| ||
|| ++- Volume level
|+-------- Contrast (WSC): 0 = Low, 1 = High
+--------- Custom splash animation enabled
</pre>
== Hardware notes ==
EEPROM command bits are shifted out starting from the ''most'' significant bit of the port.
<pre>
+----> EEPROM Serial Data
|
[0] <= [0000 0001 ooaa aaaa]
EEPROM Command Port
</pre>
While the M93LCx6 family supports byte organization, the WonderSwan always uses word organization. As such, this implementation detail is omitted in this documentation.
== Errata ==
=== Non-word access on ASWAN ===
On the ASWAN SoC, accessing the internal EEPROM command ports as bytes only works correctly for even addresses. For odd addresses, these accesses return open bus; this means that unaligned word accesses also don't work, as they are converted to one odd and one even byte access internally.
It is recommended to only use aligned word port accesses to talk to the internal EEPROM.
This issue is not present on the SPHINX and newer SoCs, including in "mono" emulation mode, as well as the cartridge bus (which is always forced to be accessed per byte).
== Links ==
* [https://www.st.com/resource/en/datasheet/m93c46-w.pdf STMicroelectronics M93LCx6 datasheet]
9e417101ebdb7f034ec7fa531371ba653d96c9fe
292
291
2024-05-30T08:42:19Z
Asie
351
/* Hardware notes */
wikitext
text/x-wiki
The WonderSwan utilizes M93LCx6-compatible EEPROMs:
* in the SoC:
** 1 Kbit internal EEPROM (M93LC46-compatible) on the WonderSwan,
** 16 Kbit internal EEPROM (M93LC86-compatible) on the WonderSwan Color,
* on cartridges:
** 1 Kbit cartridge EEPROM (M93LC46-compatible)
** 8 Kbit cartridge EEPROM (M93LC76-compatible)
** 16 Kbit cartridge EEPROM (M93LC86-compatible)
Additional variants exists which were not seen on any production cartridge:
* 256 bit EEPROM (M93LC06-compatible)
* 2 Kbit EEPROM (M93LC56-compatible)
* 4 Kbit EEPROM (M93LC66-compatible)
== Commands ==
=== READ - Read Word ===
The READ command takes an address of a word (address 0 => bytes 0, 1; address 1 => bytes 2, 3; ...) and returns the word at that address.
=== WRITE - Write Word ===
The WRITE command takes an address of a word (address 0 => bytes 0, 1; address 1 => bytes 2, 3; ...) and the word to write to it, then writes the word.
=== ERASE - Erase Word ===
The ERASE command takes an address of a word (address 0 => bytes 0, 1; address 1 => bytes 2, 3; ...) and erases the word at that address, setting it to 0xFFFF.
=== WDS - Write Disable ===
The WDS command prevents issued write and erase commands from having an effect on the EEPROM.
=== WRAL - Write All ===
This command is not guaranteed to be present on all EEPROMs.
TODO
=== ERAL - Erase All ===
This command is not guaranteed to be present on all EEPROMs.
TODO
=== WEN - Write Enable ===
The WEN command restores the effect of issued write and erase commands on the EEPROM disabled using WDS.
== I/O ports ==
The I/O ports listed refer to the internal EEPROM; for the cartridge EEPROM port numbers, refer to the [[Bandai 2001|mapper documentation]].
It is recommended to only access the data and command ports with aligned word reads/writes; see the ''Errata'' section for more information.
{{Anchor|Internal EEPROM Data}}
=== Internal EEPROM Data ($BA, $BB read) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
dddd dddd dddd dddd
|||| |||| |||| ||||
++++-++++--++++-++++- Data read from the EEPROM.
</pre>
The read buffer's value changes only once the Read command is completed.
=== Internal EEPROM Data ($BA, $BB write) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
dddd dddd dddd dddd
|||| |||| |||| ||||
++++-++++--++++-++++- Data to write to the EEPROM.
</pre>
The write buffer is latched when a Write command is initiated; further writes to it do not affect the value written by that specific command.
The two EEPROM data buffers are not shared; neither writes to the write buffer nor the execution of non-read commands affect the contents of the read buffer.
{{Anchor|Internal EEPROM Command}}
=== Internal EEPROM Command ($BC, $BD) ===
<pre>
Command Pattern 1
15 bit 8 7 bit 0
---- ---- ---- ----
0000 0001 ooaa aaaa (¼, 1 Kbit - M93LC06/46)
0000 01oo aaaa aaaa (2, 4 Kbit - M93LC56/66)
0001 ooaa aaaa aaaa (8, 16 Kbit - M93LC76/86)
|||| |||| ||||
||++--++++-++++- Address (MSb .. LSb)
++-------------- Opcode:
01 - WRITE
10 - READ
11 - ERASE
</pre>
<pre>
Command Pattern 2
15 bit 8 7 bit 0
---- ---- ---- ----
0000 0001 00ss .... (¼, 1 Kbit - M93LC06/46)
0000 0100 ss.. .... (2, 4 Kbit - M93LC56/66)
0001 00ss .... .... (8, 16 Kbit - M93LC76/86)
||||
||++------------ Sub-Opcode:
|| 00 - WDS
|| 01 - WRAL
|| 01 - ERAL
|| 11 - WEN
++-------------- Opcode:
00
</pre>
The value written to this port can be read back; it is not affected by ''EEPROM Control''.
{{Anchor|Internal EEPROM Control}}
=== Internal EEPROM Control ($BE, $BF write) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
.... .... PSWR ....
||||
|||+------ Read command: 1 for READ command, 0 otherwise
||+------- Write command: 1 for WRITE and WRAL command, 0 otherwise
|+-------- Short command: 1 for ERASE, WDS, ERAL and WEN command, 0 otherwise
+--------- Protection: 1 to enable internal EEPROM write protection.
Cannot be cleared once set.
</pre>
* Read command Sends 16 bits from Command, then reads 16 bits to Data.
* Write command: Sends 16 bits from Command, then 16 bits from Data. De-asserts Microwire chip select, then re-asserts it and waits for the EEPROM to confirm command completion.
* Short command: Sends 16 bits from Command, de-asserts Microwire chip select.
* Protection: Enables internal EEPROM write protection (addresses >= 0x30, or anything after the first 96 bytes, can no longer be written to).
If more than one of the Read, Write, Short, Protect bits are set, the command is treated as invalid (operation bits are cleared and no EEPROM operation is performed). Notably, this means that writing 0x90 does not protect the internal EEPROM if it wasn't already protected, but writing 0x80 does.
The command requested here should match the command sent to the EEPROM in port ''$BC''.
{{Anchor|Internal EEPROM Status}}
=== Internal EEPROM Status ($BE, $BF read) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
.... .... P... ..rd
| ||
| |+- 0 after a Read command is initiated,
| | 1 once a Read command is completed.
| | Unaffected by Write/Erase commands.
| +-- 0 if the EEPROM is busy,
| 1 if a command can be accepted (idle).
+--------- Internal EEPROM write protection:
0 = disabled, 1 = enabled
</pre>
== Internal EEPROM Layout ==
{| class="wikitable"
|-
! Offset !! Length !! Contents
|-
| $00 || 96 || Program data. Can be written by programs even if write protection has been enabled.
|-
| $60 || 16 || Owner name, custom character set.
|-
| $70 || 1 || Owner birthday year, BCD, first/higher two digits
|-
| $71 || 1 || Owner birthday year, BCD, last/lower two digits
|-
| $72 || 1 || Owner birthday month, BCD
|-
| $73 || 1 || Owner birthday day, BCD
|-
| $74 || 1 || Owner gender:<br/>
0 - ?<br/>
1 - Male<br/>
2 - Female
|-
| $75 || 1 || Owner blood type:<br/>
0 - ?<br/>
1 - A<br/>
2 - B<br/>
3 - AB<br/>
4 - 0
|-
| $76 || 1 || Last booted cartridge developer/publisher ID
|-
| $77 || 1 || Last booted cartridge game ID
|-
| $78 || 1 || Last booted cartridge game version
|-
| $7C || 1 || Stored cartridge ID/version change counter
|-
| $7D || 1 || Owner name change counter
|-
| $7E || 2 || System startup counter
|-
| $83 || 1 || Color console configuration
|-
| $84 || ? || [[Splash animation|Custom splash animation]], if present
|}
=== Owner name character set ===
{| class="wikitable"
|-
!
! <code>.0</code>
! <code>.1</code>
! <code>.2</code>
! <code>.3</code>
! <code>.4</code>
! <code>.5</code>
! <code>.6</code>
! <code>.7</code>
! <code>.8</code>
! <code>.9</code>
! <code>.A</code>
! <code>.B</code>
! <code>.C</code>
! <code>.D</code>
! <code>.E</code>
! <code>.F</code>
|-
! <code>0.</code>
| || 0 || 1 || 2 || 3 || 4 || 5 || 6 || 7 || 8 || 9 || A || B || C || D || E
|-
! <code>1.</code>
| F || G || H || I || J || K || L || M || N || O || P || Q || R || S || T || U
|-
! <code>2.</code>
| V || W || X || Y || Z || ♥ || ♪ || + || - || ? || .
!
!
!
!
!
|}
=== Color console configuration ===
<pre>
7 bit 0
---- ----
sc.. ..vv
|| ||
|| ++- Volume level
|+-------- Contrast (WSC): 0 = Low, 1 = High
+--------- Custom splash animation enabled
</pre>
== Hardware notes ==
EEPROM command bits are shifted out starting from the ''most'' significant bit of the port.
<pre>
+----> EEPROM Serial Data
|
[0] <= [0000 0001 ooaa aaaa]
EEPROM Command Port
</pre>
While the M93LCx6 family supports byte organization, the WonderSwan always uses word organization. As such, this implementation detail is omitted in this documentation.
The SPHINX SoC family emulates a 93C46 in ASWAN compatibility mode by manipulating the shifted out command value when sending it to the EEPROM (TODO: How exactly?).
== Errata ==
=== Non-word access on ASWAN ===
On the ASWAN SoC, accessing the internal EEPROM command ports as bytes only works correctly for even addresses. For odd addresses, these accesses return open bus; this means that unaligned word accesses also don't work, as they are converted to one odd and one even byte access internally.
It is recommended to only use aligned word port accesses to talk to the internal EEPROM.
This issue is not present on the SPHINX and newer SoCs, including in "mono" emulation mode, as well as the cartridge bus (which is always forced to be accessed per byte).
== Links ==
* [https://www.st.com/resource/en/datasheet/m93c46-w.pdf STMicroelectronics M93LCx6 datasheet]
67cca32e7da669aea2366afaeb74cbcf686524d0
293
292
2024-05-30T17:28:55Z
Asie
351
/* Internal EEPROM Command ($BC, $BD) */ Fix ERAL typo
wikitext
text/x-wiki
The WonderSwan utilizes M93LCx6-compatible EEPROMs:
* in the SoC:
** 1 Kbit internal EEPROM (M93LC46-compatible) on the WonderSwan,
** 16 Kbit internal EEPROM (M93LC86-compatible) on the WonderSwan Color,
* on cartridges:
** 1 Kbit cartridge EEPROM (M93LC46-compatible)
** 8 Kbit cartridge EEPROM (M93LC76-compatible)
** 16 Kbit cartridge EEPROM (M93LC86-compatible)
Additional variants exists which were not seen on any production cartridge:
* 256 bit EEPROM (M93LC06-compatible)
* 2 Kbit EEPROM (M93LC56-compatible)
* 4 Kbit EEPROM (M93LC66-compatible)
== Commands ==
=== READ - Read Word ===
The READ command takes an address of a word (address 0 => bytes 0, 1; address 1 => bytes 2, 3; ...) and returns the word at that address.
=== WRITE - Write Word ===
The WRITE command takes an address of a word (address 0 => bytes 0, 1; address 1 => bytes 2, 3; ...) and the word to write to it, then writes the word.
=== ERASE - Erase Word ===
The ERASE command takes an address of a word (address 0 => bytes 0, 1; address 1 => bytes 2, 3; ...) and erases the word at that address, setting it to 0xFFFF.
=== WDS - Write Disable ===
The WDS command prevents issued write and erase commands from having an effect on the EEPROM.
=== WRAL - Write All ===
This command is not guaranteed to be present on all EEPROMs.
TODO
=== ERAL - Erase All ===
This command is not guaranteed to be present on all EEPROMs.
TODO
=== WEN - Write Enable ===
The WEN command restores the effect of issued write and erase commands on the EEPROM disabled using WDS.
== I/O ports ==
The I/O ports listed refer to the internal EEPROM; for the cartridge EEPROM port numbers, refer to the [[Bandai 2001|mapper documentation]].
It is recommended to only access the data and command ports with aligned word reads/writes; see the ''Errata'' section for more information.
{{Anchor|Internal EEPROM Data}}
=== Internal EEPROM Data ($BA, $BB read) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
dddd dddd dddd dddd
|||| |||| |||| ||||
++++-++++--++++-++++- Data read from the EEPROM.
</pre>
The read buffer's value changes only once the Read command is completed.
=== Internal EEPROM Data ($BA, $BB write) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
dddd dddd dddd dddd
|||| |||| |||| ||||
++++-++++--++++-++++- Data to write to the EEPROM.
</pre>
The write buffer is latched when a Write command is initiated; further writes to it do not affect the value written by that specific command.
The two EEPROM data buffers are not shared; neither writes to the write buffer nor the execution of non-read commands affect the contents of the read buffer.
{{Anchor|Internal EEPROM Command}}
=== Internal EEPROM Command ($BC, $BD) ===
<pre>
Command Pattern 1
15 bit 8 7 bit 0
---- ---- ---- ----
0000 0001 ooaa aaaa (¼, 1 Kbit - M93LC06/46)
0000 01oo aaaa aaaa (2, 4 Kbit - M93LC56/66)
0001 ooaa aaaa aaaa (8, 16 Kbit - M93LC76/86)
|||| |||| ||||
||++--++++-++++- Address (MSb .. LSb)
++-------------- Opcode:
01 - WRITE
10 - READ
11 - ERASE
</pre>
<pre>
Command Pattern 2
15 bit 8 7 bit 0
---- ---- ---- ----
0000 0001 00ss .... (¼, 1 Kbit - M93LC06/46)
0000 0100 ss.. .... (2, 4 Kbit - M93LC56/66)
0001 00ss .... .... (8, 16 Kbit - M93LC76/86)
||||
||++------------ Sub-Opcode:
|| 00 - WDS
|| 01 - WRAL
|| 10 - ERAL
|| 11 - WEN
++-------------- Opcode:
00
</pre>
The value written to this port can be read back; it is not affected by ''EEPROM Control''.
{{Anchor|Internal EEPROM Control}}
=== Internal EEPROM Control ($BE, $BF write) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
.... .... PSWR ....
||||
|||+------ Read command: 1 for READ command, 0 otherwise
||+------- Write command: 1 for WRITE and WRAL command, 0 otherwise
|+-------- Short command: 1 for ERASE, WDS, ERAL and WEN command, 0 otherwise
+--------- Protection: 1 to enable internal EEPROM write protection.
Cannot be cleared once set.
</pre>
* Read command Sends 16 bits from Command, then reads 16 bits to Data.
* Write command: Sends 16 bits from Command, then 16 bits from Data. De-asserts Microwire chip select, then re-asserts it and waits for the EEPROM to confirm command completion.
* Short command: Sends 16 bits from Command, de-asserts Microwire chip select.
* Protection: Enables internal EEPROM write protection (addresses >= 0x30, or anything after the first 96 bytes, can no longer be written to).
If more than one of the Read, Write, Short, Protect bits are set, the command is treated as invalid (operation bits are cleared and no EEPROM operation is performed). Notably, this means that writing 0x90 does not protect the internal EEPROM if it wasn't already protected, but writing 0x80 does.
The command requested here should match the command sent to the EEPROM in port ''$BC''.
{{Anchor|Internal EEPROM Status}}
=== Internal EEPROM Status ($BE, $BF read) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
.... .... P... ..rd
| ||
| |+- 0 after a Read command is initiated,
| | 1 once a Read command is completed.
| | Unaffected by Write/Erase commands.
| +-- 0 if the EEPROM is busy,
| 1 if a command can be accepted (idle).
+--------- Internal EEPROM write protection:
0 = disabled, 1 = enabled
</pre>
== Internal EEPROM Layout ==
{| class="wikitable"
|-
! Offset !! Length !! Contents
|-
| $00 || 96 || Program data. Can be written by programs even if write protection has been enabled.
|-
| $60 || 16 || Owner name, custom character set.
|-
| $70 || 1 || Owner birthday year, BCD, first/higher two digits
|-
| $71 || 1 || Owner birthday year, BCD, last/lower two digits
|-
| $72 || 1 || Owner birthday month, BCD
|-
| $73 || 1 || Owner birthday day, BCD
|-
| $74 || 1 || Owner gender:<br/>
0 - ?<br/>
1 - Male<br/>
2 - Female
|-
| $75 || 1 || Owner blood type:<br/>
0 - ?<br/>
1 - A<br/>
2 - B<br/>
3 - AB<br/>
4 - 0
|-
| $76 || 1 || Last booted cartridge developer/publisher ID
|-
| $77 || 1 || Last booted cartridge game ID
|-
| $78 || 1 || Last booted cartridge game version
|-
| $7C || 1 || Stored cartridge ID/version change counter
|-
| $7D || 1 || Owner name change counter
|-
| $7E || 2 || System startup counter
|-
| $83 || 1 || Color console configuration
|-
| $84 || ? || [[Splash animation|Custom splash animation]], if present
|}
=== Owner name character set ===
{| class="wikitable"
|-
!
! <code>.0</code>
! <code>.1</code>
! <code>.2</code>
! <code>.3</code>
! <code>.4</code>
! <code>.5</code>
! <code>.6</code>
! <code>.7</code>
! <code>.8</code>
! <code>.9</code>
! <code>.A</code>
! <code>.B</code>
! <code>.C</code>
! <code>.D</code>
! <code>.E</code>
! <code>.F</code>
|-
! <code>0.</code>
| || 0 || 1 || 2 || 3 || 4 || 5 || 6 || 7 || 8 || 9 || A || B || C || D || E
|-
! <code>1.</code>
| F || G || H || I || J || K || L || M || N || O || P || Q || R || S || T || U
|-
! <code>2.</code>
| V || W || X || Y || Z || ♥ || ♪ || + || - || ? || .
!
!
!
!
!
|}
=== Color console configuration ===
<pre>
7 bit 0
---- ----
sc.. ..vv
|| ||
|| ++- Volume level
|+-------- Contrast (WSC): 0 = Low, 1 = High
+--------- Custom splash animation enabled
</pre>
== Hardware notes ==
EEPROM command bits are shifted out starting from the ''most'' significant bit of the port.
<pre>
+----> EEPROM Serial Data
|
[0] <= [0000 0001 ooaa aaaa]
EEPROM Command Port
</pre>
While the M93LCx6 family supports byte organization, the WonderSwan always uses word organization. As such, this implementation detail is omitted in this documentation.
The SPHINX SoC family emulates a 93C46 in ASWAN compatibility mode by manipulating the shifted out command value when sending it to the EEPROM (TODO: How exactly?).
== Errata ==
=== Non-word access on ASWAN ===
On the ASWAN SoC, accessing the internal EEPROM command ports as bytes only works correctly for even addresses. For odd addresses, these accesses return open bus; this means that unaligned word accesses also don't work, as they are converted to one odd and one even byte access internally.
It is recommended to only use aligned word port accesses to talk to the internal EEPROM.
This issue is not present on the SPHINX and newer SoCs, including in "mono" emulation mode, as well as the cartridge bus (which is always forced to be accessed per byte).
== Links ==
* [https://www.st.com/resource/en/datasheet/m93c46-w.pdf STMicroelectronics M93LCx6 datasheet]
a1ad0181aaac7bb8f9cd43ffb328c882dce2f600
294
293
2024-05-30T17:33:53Z
Asie
351
/* Internal EEPROM Control ($BE, $BF write) */
wikitext
text/x-wiki
The WonderSwan utilizes M93LCx6-compatible EEPROMs:
* in the SoC:
** 1 Kbit internal EEPROM (M93LC46-compatible) on the WonderSwan,
** 16 Kbit internal EEPROM (M93LC86-compatible) on the WonderSwan Color,
* on cartridges:
** 1 Kbit cartridge EEPROM (M93LC46-compatible)
** 8 Kbit cartridge EEPROM (M93LC76-compatible)
** 16 Kbit cartridge EEPROM (M93LC86-compatible)
Additional variants exists which were not seen on any production cartridge:
* 256 bit EEPROM (M93LC06-compatible)
* 2 Kbit EEPROM (M93LC56-compatible)
* 4 Kbit EEPROM (M93LC66-compatible)
== Commands ==
=== READ - Read Word ===
The READ command takes an address of a word (address 0 => bytes 0, 1; address 1 => bytes 2, 3; ...) and returns the word at that address.
=== WRITE - Write Word ===
The WRITE command takes an address of a word (address 0 => bytes 0, 1; address 1 => bytes 2, 3; ...) and the word to write to it, then writes the word.
=== ERASE - Erase Word ===
The ERASE command takes an address of a word (address 0 => bytes 0, 1; address 1 => bytes 2, 3; ...) and erases the word at that address, setting it to 0xFFFF.
=== WDS - Write Disable ===
The WDS command prevents issued write and erase commands from having an effect on the EEPROM.
=== WRAL - Write All ===
This command is not guaranteed to be present on all EEPROMs.
TODO
=== ERAL - Erase All ===
This command is not guaranteed to be present on all EEPROMs.
TODO
=== WEN - Write Enable ===
The WEN command restores the effect of issued write and erase commands on the EEPROM disabled using WDS.
== I/O ports ==
The I/O ports listed refer to the internal EEPROM; for the cartridge EEPROM port numbers, refer to the [[Bandai 2001|mapper documentation]].
It is recommended to only access the data and command ports with aligned word reads/writes; see the ''Errata'' section for more information.
{{Anchor|Internal EEPROM Data}}
=== Internal EEPROM Data ($BA, $BB read) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
dddd dddd dddd dddd
|||| |||| |||| ||||
++++-++++--++++-++++- Data read from the EEPROM.
</pre>
The read buffer's value changes only once the Read command is completed.
=== Internal EEPROM Data ($BA, $BB write) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
dddd dddd dddd dddd
|||| |||| |||| ||||
++++-++++--++++-++++- Data to write to the EEPROM.
</pre>
The write buffer is latched when a Write command is initiated; further writes to it do not affect the value written by that specific command.
The two EEPROM data buffers are not shared; neither writes to the write buffer nor the execution of non-read commands affect the contents of the read buffer.
{{Anchor|Internal EEPROM Command}}
=== Internal EEPROM Command ($BC, $BD) ===
<pre>
Command Pattern 1
15 bit 8 7 bit 0
---- ---- ---- ----
0000 0001 ooaa aaaa (¼, 1 Kbit - M93LC06/46)
0000 01oo aaaa aaaa (2, 4 Kbit - M93LC56/66)
0001 ooaa aaaa aaaa (8, 16 Kbit - M93LC76/86)
|||| |||| ||||
||++--++++-++++- Address (MSb .. LSb)
++-------------- Opcode:
01 - WRITE
10 - READ
11 - ERASE
</pre>
<pre>
Command Pattern 2
15 bit 8 7 bit 0
---- ---- ---- ----
0000 0001 00ss .... (¼, 1 Kbit - M93LC06/46)
0000 0100 ss.. .... (2, 4 Kbit - M93LC56/66)
0001 00ss .... .... (8, 16 Kbit - M93LC76/86)
||||
||++------------ Sub-Opcode:
|| 00 - WDS
|| 01 - WRAL
|| 10 - ERAL
|| 11 - WEN
++-------------- Opcode:
00
</pre>
The value written to this port can be read back; it is not affected by ''EEPROM Control''.
{{Anchor|Internal EEPROM Control}}
=== Internal EEPROM Control ($BE, $BF write) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
.... .... PSWR ....
||||
|||+------ Read operation: 1 for READ command, 0 otherwise
||+------- Write operation: 1 for WRITE and WRAL command, 0 otherwise
|+-------- Short operation: 1 for ERASE, WDS, ERAL and WEN command, 0 otherwise
+--------- Protection: 1 to enable internal EEPROM write protection.
Cannot be cleared once set.
</pre>
* Read operation: Sends 16 bits from Command, then reads 16 bits to Data.
* Write operation: Sends 16 bits from Command, then 16 bits from Data. De-asserts Microwire chip select, then re-asserts it and waits for the EEPROM to confirm command completion.
* Short operation: Sends 16 bits from Command, de-asserts Microwire chip select.
* Protection: Enables internal EEPROM write protection (addresses >= 0x30, or anything after the first 96 bytes, can no longer be written to).
If more than one of the Read, Write, Short, Protect bits are set, the operation is treated as invalid (all four operation bits are cleared and no communication is done with the EEPROM). Notably, this means that writing, for example, 0x90 does not protect the internal EEPROM if it wasn't already protected, but writing 0x80 does.
The command requested here should match the command sent to the EEPROM in port ''$BC''.
{{Anchor|Internal EEPROM Status}}
=== Internal EEPROM Status ($BE, $BF read) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
.... .... P... ..rd
| ||
| |+- 0 after a Read command is initiated,
| | 1 once a Read command is completed.
| | Unaffected by Write/Erase commands.
| +-- 0 if the EEPROM is busy,
| 1 if a command can be accepted (idle).
+--------- Internal EEPROM write protection:
0 = disabled, 1 = enabled
</pre>
== Internal EEPROM Layout ==
{| class="wikitable"
|-
! Offset !! Length !! Contents
|-
| $00 || 96 || Program data. Can be written by programs even if write protection has been enabled.
|-
| $60 || 16 || Owner name, custom character set.
|-
| $70 || 1 || Owner birthday year, BCD, first/higher two digits
|-
| $71 || 1 || Owner birthday year, BCD, last/lower two digits
|-
| $72 || 1 || Owner birthday month, BCD
|-
| $73 || 1 || Owner birthday day, BCD
|-
| $74 || 1 || Owner gender:<br/>
0 - ?<br/>
1 - Male<br/>
2 - Female
|-
| $75 || 1 || Owner blood type:<br/>
0 - ?<br/>
1 - A<br/>
2 - B<br/>
3 - AB<br/>
4 - 0
|-
| $76 || 1 || Last booted cartridge developer/publisher ID
|-
| $77 || 1 || Last booted cartridge game ID
|-
| $78 || 1 || Last booted cartridge game version
|-
| $7C || 1 || Stored cartridge ID/version change counter
|-
| $7D || 1 || Owner name change counter
|-
| $7E || 2 || System startup counter
|-
| $83 || 1 || Color console configuration
|-
| $84 || ? || [[Splash animation|Custom splash animation]], if present
|}
=== Owner name character set ===
{| class="wikitable"
|-
!
! <code>.0</code>
! <code>.1</code>
! <code>.2</code>
! <code>.3</code>
! <code>.4</code>
! <code>.5</code>
! <code>.6</code>
! <code>.7</code>
! <code>.8</code>
! <code>.9</code>
! <code>.A</code>
! <code>.B</code>
! <code>.C</code>
! <code>.D</code>
! <code>.E</code>
! <code>.F</code>
|-
! <code>0.</code>
| || 0 || 1 || 2 || 3 || 4 || 5 || 6 || 7 || 8 || 9 || A || B || C || D || E
|-
! <code>1.</code>
| F || G || H || I || J || K || L || M || N || O || P || Q || R || S || T || U
|-
! <code>2.</code>
| V || W || X || Y || Z || ♥ || ♪ || + || - || ? || .
!
!
!
!
!
|}
=== Color console configuration ===
<pre>
7 bit 0
---- ----
sc.. ..vv
|| ||
|| ++- Volume level
|+-------- Contrast (WSC): 0 = Low, 1 = High
+--------- Custom splash animation enabled
</pre>
== Hardware notes ==
EEPROM command bits are shifted out starting from the ''most'' significant bit of the port.
<pre>
+----> EEPROM Serial Data
|
[0] <= [0000 0001 ooaa aaaa]
EEPROM Command Port
</pre>
While the M93LCx6 family supports byte organization, the WonderSwan always uses word organization. As such, this implementation detail is omitted in this documentation.
The SPHINX SoC family emulates a 93C46 in ASWAN compatibility mode by manipulating the shifted out command value when sending it to the EEPROM (TODO: How exactly?).
== Errata ==
=== Non-word access on ASWAN ===
On the ASWAN SoC, accessing the internal EEPROM command ports as bytes only works correctly for even addresses. For odd addresses, these accesses return open bus; this means that unaligned word accesses also don't work, as they are converted to one odd and one even byte access internally.
It is recommended to only use aligned word port accesses to talk to the internal EEPROM.
This issue is not present on the SPHINX and newer SoCs, including in "mono" emulation mode, as well as the cartridge bus (which is always forced to be accessed per byte).
== Links ==
* [https://www.st.com/resource/en/datasheet/m93c46-w.pdf STMicroelectronics M93LCx6 datasheet]
df6868271b7c8e9144edb52651325fa9afb2b9ad
Bandai 2001
0
12
283
169
2024-05-28T14:08:58Z
Asie
351
wikitext
text/x-wiki
The Bandai 2001 (LUXSOR) is one of the two mappers used in WonderSwan cartridges.
In addition to the normal [[Mapper]] banking interface, Bandai's 2001 adds three registers for interacting with a Microwire EEPROM:
{| class="wikitable"
! Category
! Port
! Description
! Bits
! Type
! Notes
|-
! rowspan="4" | External EEPROM
! $C4
| External EEPROM Data
| style="text-align: right" | <tt style="white-space: nowrap">dddd dddd dddd dddd</tt>
| RW16
| Data (d)
|-
! $C6
| External EEPROM Command
| style="text-align: right" | <tt style="white-space: nowrap">0001 CCaa aaaa aaaa</tt><br/>or <tt style="white-space: nowrap">0000 01CC aaaa aaaa</tt><br/> or <tt style="white-space: nowrap">0000 0001 CCaa aaaa</tt>
| RW16
| Command and address
|-
! rowspan=2|$C8
| External EEPROM Command
| style="text-align: right" | <tt style="white-space: nowrap">ASWR ....</tt>
| W8
| Abort (A), Short (S), Write (W), Read (R)
|-
| External EEPROM Status
| style="text-align: right" | <tt style="white-space: nowrap">.... ..rd</tt>
| R8
| Ready (r), Done (d)
|-
|}
== EEPROM ==
The 2001's EEPROM interface is similar to the internal EEPROM interface, as documented on [[EEPROM#I/O_ports|the EEPROM page]]. Differences include:
* Instead of the internal EEPROM interface's P(rotect) bit, the A(bort) bit is provided. When the A bit is set, the transaction immediately stops.
* The EEPROM "done" bit is buggy and doesn't have useful information. It's set when a Read completes, but is only cleared when a Command or Write is started. (To be useful it would need to also be cleared when a Read is started).
(Upload logic analyzer traces here)
5df749ce5d5b4bb4d38e49b87c8ac06d687b702d
2001 Mapper pinout
0
10
295
63
2024-06-27T07:37:38Z
Lidnariq
7
ROM A23 (h/t happysoul on the discord)
wikitext
text/x-wiki
_____
/ \
D4 <> / 1 48 \ <> D5
D3 <> / 2 O 47 \ <> D6
D2 <> / 3 46 \ <> D7
D1 <> / 4 45 \ -> SRAM /CS
D0 <> / 5 44 \ -- Vcc
Gnd -- / 6 43 \ -> ROM /CS
A0 -> / 7 42 \ -> ROM A18
A1 -> / 8 41 \ -> ROM A19
Vcc -- / 9 40 \ -- Gnd
A2 -> / 10 39 \ -> ROM A21
A3 -> / 11 38 \ -> ROM A20 Orientation:
CPU A19 -> / 12 37 \ -> ROM A16 ----------------
/ BANDAI 2001 \ 36 25
\ Package TQFP-48 / | |
CPU A18 -> \ 13 0.5mm pitch 36 / -> ROM A17 .--------.
CPU A17 -> \ 14 35 / -> ROM A22 37-|BANDAI O|-24
CPU A16 -> \ 15 34 / -> ROM A23 |2001 |
Vcc -- \ 16 33 / -> Microwire CS 48-|O 914XC|-13
/Reset ?> \ 17 32 / -> Microwire DI \--------'
/MBC <- \ 18 31 / <- Microwire DO | |
M/IO -> \ 19 30 / -- Vcc 01 12
/RD -> \ 20 29 / -> Microwire SK
/WR -> \ 21 28 / ?? Gnd Legend:
/SEL -> \ 22 27 / ?? Gnd ------------------------------------------
CLK -> \ 23 O 26 / ?? Gnd --[2001]-- Power, n/a
Gnd -- \ 24 25 / ?? Gnd ->[2001]<- 2001 input
\ / <-[2001]-> 2001 output
\ / <>[2001]<> Bidirectional
\ / ??[2001]?? Unknown
V ?>[2001]<? Input, unknown if bidirectional
(Note that the corner indicator for pin 1 is subtle
compared to the other corners as well as other QFPs.)
b9796006e3ea7db428f31382a76ae2a67aadb7f6
Display
0
26
301
300
2024-07-12T19:39:17Z
Asie
351
/* Color */
wikitext
text/x-wiki
The WonderSwan's display functionality generally consists of:
* a 224x144 display clocked at ~75.47 Hz by default, capable of displaying:
** up to sixteen distinct shades of gray
** 12-bit RGB444 color<sup>(color)</sup>
* two 32x32 background layers ("screens"), capable of displaying up to 512 (1024<sup>(color)</sup>) distinct tiles,
* a sprite layer, capable of displaying up to 128 8x8 sprites (up to 32 per line),
* six LCD icons to the bottom or right of the display, usable as additional indicators.
== Components ==
=== Tiles ===
The WonderSwan can display up to 512 distinct tiles at a time, with two bits of palette index information for every pixel.
The WonderSwan Color expands this to 1024 distinct tiles for background (with 512 remaining the limit for sprites), while also introducing modes with four bits of palette index information for every pixel.
==== 2 bits per pixel, planar ====
The tiles are stored in an interleaved planar format, with two bits total for every pixel. Odd bytes store the first plane (bit 0 of each pixel), while even bytes store the second plane (bit 1 of each pixel).
<pre>
tile data (16 bytes)
01 7C 01 FC 00 C0 18 D8 18 D8 00 C0 00 00 C0 00
||
\/
plane 0 plane 1
7 bit 0 7 bit 0 full tile
---- ---- ---- ----
.... ...1 = 01 .222 22.. = 7C .22222.1
.... ...1 = 01 2222 22.. = FC 222222.1
.... .... = 00 22.. .... = C0 22......
...1 1... = 18 22.2 2... = D8 --\ 22.33...
...1 1... = 18 22.2 2... = D8 --/ 22.33...
.... .... = 00 22.. .... = C0 22......
.... .... = 00 .... .... = 00 ........
11.. .... = C0 .... .... = 00 11......
</pre>
This matches the format used by the Game Boy.
==== 4 bits per pixel, planar ====
This mode is stored in a manner similar to the 2 bits per pixel mode, but with an additional two planes for bit 2 and bit 3 of each pixel's palette index, expanding the tile data to 32 bytes.
<pre>
tile data (32 bytes)
54 32 01 00 54 32 F1 00 54 32 01 F0 54 32 F1 F0 04 02 01 00 F8 04 02 01 00 F8 04 02 00 00 F8 04
||
\/
plane 0 plane 1 plane 2 plane 3
7 bit 0 7 bit 0 7 bit 0 7 bit 0 full tile
---- ---- ---- ---- ---- ---- ---- ----
.1.1 .1.. = 54 ..22 ..2. = 32 .... ...4 = 01 .... .... = 00 .123.124
.1.1 .1.. = 54 ..22 ..2. = 32 4444 ...4 = F1 .... .... = 00 4567.124
.1.1 .1.. = 54 ..22 ..2. = 32 .... ...4 = 01 8888 .... = F0 89AB.124
.1.1 .1.. = 54 ..22 ..2. = 32 4444 ...4 = F1 8888 .... = F0 --\ CDEF.124
.... .1.. = 04 .... ..2. = 02 .... ...4 = 01 .... .... = 00 --/ .....124
1111 1... = F8 .... .2.. = 04 .... ..4. = 02 .... ...8 = 01 11111248
.... .... = 00 2222 2... = F8 .... .4.. = 04 .... ..8. = 02 2222248.
.... .... = 00 .... .... = 00 4444 4... = F8 .... .8.. = 04 444448..
</pre>
This format matches the one used by the Sega Master System and Game Gear family of consoles.
==== 4 bits per pixel, packed ====
Unlike the previous two formats, in the packed format each byte stores the complete palette index of two pixels - the high four bits store the left pixel, while the low four bits store the right pixel. Four such bytes make up a row of eight pixels from left to right.
<pre>
tile data (32 bytes)
01 23 01 24 45 67 01 24 89 AB 01 24 CD EF 01 24 00 00 01 24 11 11 12 48 22 22 24 80 44 44 48 00
||
\/
byte 0 1 2 3
bits 7-4 3-0 7-4 3-0 7-4 3-0 7-4 3-0
pixel 0 1 2 3 4 5 6 7 full tile
--- --- --- --- --- --- --- ---
. 1 = 01 2 3 = 23 . 1 = 01 2 4 = 24 .123.124 = 01 23 01 24
4 5 = 45 6 7 = 67 . 1 = 01 2 4 = 24 4567.124 = 45 67 01 24
8 9 = 89 A B = AB . 1 = 01 2 4 = 24 89AB.124 = 89 AB 01 24
C D = CD E F = EF . 1 = 01 2 4 = 24 --\ CDEF.124 = CD EF 01 24
. . = 00 . . = 00 . 1 = 01 2 4 = 24 --/ .....124 = 00 00 01 24
1 1 = 11 1 1 = 11 1 2 = 12 4 8 = 48 11111248 = 11 11 12 48
2 2 = 22 2 2 = 22 2 4 = 24 8 . = 80 2222248. = 22 22 24 80
4 4 = 44 4 4 = 44 4 8 = 48 . . = 00 444448.. = 44 44 48 00
</pre>
This format matches the one used by the Mega Drive console.
=== Palettes ===
The WonderSwan provides sixteen different palettes. Palettes 0-7 can be used for the two screens only, while palettes 8-15 can be used for both screens and sprites.
==== Mono ====
In ''mono'' modes, palettes are stored in I/O ports 0x20 through 0x3F. Each palette contains four three-bit entries, which are pointers into a global, four-bit shade lookup table:
<pre>
Palette Global shade LUT
1 ===========> 2 ==========================> 5
^ (0, 2, 4, 6) ^ (1, 3, 5, 7, 9, 11, 13, 15) ^
| | |
Palette index Value Displayed shade
</pre>
The shade value corresponds to the darkness of the pixel: shade 0 is the brightest, while shade 15 is the darkest.
==== Color ====
In ''color'' modes, palettes are stored as 16-bit words in memory addresses 0xFE00 through 0xFFFF, without additional lookup tables:
<pre>
Address
15 bit 8 7 bit 0
---- ---- ---- ----
1111 111p pppi iii.
| |||| |||
| |||+-+++-- Index in palette (0-15)
+--+++------- Palette number (0-15)
Data
15 bit 8 7 bit 0
---- ---- ---- ----
.... rrrr gggg bbbb
|||| |||| ||||
|||| |||| ++++- Blue (0-15)
|||| ++++------ Green (0-15)
++++------------ Red (0-15)
</pre>
In 2 bits per pixel color modes, palette entries 4 through 15 are not used.
==== Transparency ====
In two bit per pixel modes:
- Palettes 0-3 and 8-11 are ''opaque''. For these, index zero is treated as opaque.
- Palettes 4-7 and 12-15 are ''translucent''. For these, index zero is treated as transparent. This means that the color/shade value set to it is ignored, and only three distinct colors/shades can be used for tiles.
In four bit per pixel modes, all palettes are ''translucent''. Index zero is always treated as transparent, and fifteen different colors/shades can be used for tiles.
=== Background color ===
The background color is displayed if no ''opaque'' pixel from screens or sprites is drawn. This color is set in I/O port ''0x01'':
- In mono modes, it is set to an entry in the shade lookup table (0-7),
- In color modes, it is set to an entry in the color palette (0-255). Note that this allows you to use the first color (color zero) of any palette, which is normally ignored and assumed to be ''transparent''.
=== Screens ===
The WonderSwan can display up to two distinct 32x32 screens. These consist of 1024 two-byte cells:
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
vhbp pppt tttt tttt
|||| |||| |||| ||||
|||| |||+--++++-++++- Tile index (0-511)
|||+-+++------------- Palette (0-15)
||+------------------ Tile bank (0-1) - color only
|+------------------- Horizontal flip
+-------------------- Vertical flip
</pre>
=== Sprites ===
The WonderSwan can display up to 128 sprites at once. These are stored in a sprite table in RAM, which consists of up to 128 four-byte entries:
<pre>
(Byte 1) (Byte 0)
15 bit 8 7 bit 0
---- ---- ---- ----
vhPi pppt tttt tttt
|||| |||| |||| ||||
|||| |||+--++++-++++- Tile index (0-511) - only bank 0
|||| +++------------- Palette (0-7) - mapped to screen palettes 8-15
|||+----------------- Window location - 0 = inside, 1 = outside
||+------------------ Priority - 0 = behind Screen 2, 1 = in front of Screen 2
|+------------------- Horizontal flip
+-------------------- Vertical flip
(Byte 2)
7 bit 0
---- ----
yyyy yyyy
|||| ||||
++++-++++- Y coordinate
(Byte 3)
7 bit 0
---- ----
xxxx xxxx
|||| ||||
++++-++++- X coordinate
</pre>
For each row, the first 32 sprites for that row will be drawn - including sprites obscured by windows or outside of the visible range; only the Y coordinate determines this. The earlier among those sprites will be on top of the later ones.
=== Visibility priority ===
For display components, the visibility priority is as follows:
* Sprite 0, high priority
* Sprite 127, high priority
* Screen 2
* Sprite 0, low priority
* Sprite 127, low priority
* Screen 1
* Background color
=== Windows ===
Screen 2 and the sprite layer can optionally be restricted to a specific window.
In addition, one can control if a given element is rendered inside or outside that window. For Screen 2, this is controlled globally; for sprites, this is controlled per-sprite.
=== Icons ===
The WonderSwan features six LCD segment icons which are displayed to the right<sup>(color)</sup> or below<sup>(mono)</sup> the main display. These are, as follows:
* Aux 3 - large circle,
* Aux 2 - medium circle,
* Aux 1 - small circle,
* Horizontal orientation,
* Vertical orientation,
* Sleep.
== Interrupts ==
The display circuit generates two interrupts of its own:
* Display Interrupt Line Match - when <code>Display Current Line</code> == <code>Display Interrupt Line</code>, at the beginning of said line.
* Display Vertical Blank - when <code>Display Current Line</code> == <code>144</code>, at the beginning of said line.
It also provides a timing source for the two Horizontal and Vertical Blank [[Timers]], which provide their own respective interrupts.
== I/O ports ==
{{Anchor|Display Control}}
=== Display Control ($00) ===
<pre>
7 bit 0
---- ----
..ow Ws21
|| ||||
|| |||+- Enable Screen 1 layer
|| ||+-- Enable Screen 2 layer
|| |+--- Enable Sprite layer
|| +---- Enable Sprite window
|+------ Enable Screen 2 window
+------- Screen 2 window location:
0 = inside, 1 = outside
</pre>
{{Anchor|Display Background}}
=== Display Background Color ($01) ===
<pre>
(mono) (color)
7 bit 0 7 bit 0
---- ---- ---- ----
.... .sss pppp iiii
||| |||| ||||
+++- Value |||| ++++- Index in palette (0-15)
(0-7) ++++------ Color palette (0-15)
</pre>
{{Anchor|Display Current Line}}
=== Display Current Line ($02 read) ===
The current line being drawn by the display.
Note that lines are sent to the display with a one-line delay. This matters for color palette or shade LUT manipulation; changing these values when <code>current line == 1</code> will actually affect line 0.
{{Anchor|Display Interrupt Line}}
=== Display Interrupt Line ($03) ===
The line to emit an interrupt on.
{{Anchor|Sprite Table Address}}
=== Sprite Table Address ($04) ===
<pre>
7 bit 0
---- ----
..Aa aaaa
|| ||||
|+-++++- Address (bits 9-13)
+------- Address (bit 14) - color only
</pre>
{{Anchor|Sprite Table First}}
=== Sprite Table First ($05) ===
<pre>
7 bit 0
---- ----
.iii iiii
||| ||||
+++-++++- Index of first sprite entry to draw (0-127)
</pre>
{{Anchor|Sprite Table Count}}
=== Sprite Table Count ($06) ===
<pre>
7 bit 0
---- ----
cccc cccc
|||| ||||
++++-++++- Count of sprite entries to draw (1-128)
</pre>
{{Anchor|Screen Address}}
=== Screen Address ($07) ===
<pre>
7 bit 0
---- ----
2222 1111
|||| ||||
|||| |+++- Screen 1 address (bits 11-13)
|||| +---- Screen 1 address (bit 14) - color only
|+++------ Screen 2 address (bits 11-13)
+--------- Screen 2 address (bit 14) - color only
</pre>
{{Anchor|Screen 2 Window}}
=== Screen 2 Window Left ($08) ===
=== Screen 2 Window Top ($09) ===
=== Screen 2 Window Right ($0A) ===
=== Screen 2 Window Bottom ($0B) ===
{{Anchor|Sprite Window}}
=== Sprite Window Left ($0C) ===
=== Sprite Window Top ($0D) ===
=== Sprite Window Right ($0E) ===
=== Sprite Window Bottom ($0F) ===
{{Anchor|Screen Scroll}}
=== Screen 1 Scroll X ($10) ===
=== Screen 1 Scroll Y ($11) ===
=== Screen 2 Scroll X ($12) ===
=== Screen 2 Scroll Y ($13) ===
{{Anchor|LCD Control}}
=== LCD Control ($14) ===
<pre>
7 bit 0
---- ----
.... ..Ce
||
|+- LCD Enable: 0 = sleep, 1 = enabled
+-- Contrast (WSC): 0 = low, 1 = high
</pre>
{{Anchor|LCD Icon Control}}
=== LCD Icon Control ($15) ===
<pre>
7 bit 0
---- ----
..32 1hvs
|| ||||
|| |||+- Sleep
|| ||+-- Vertical orientation
|| |+--- Horizontal orientation
|| +---- Aux 1
|+------ Aux 2
+------- Aux 3
</pre>
{{Anchor|LCD Mono Shade LUT}}
=== LCD Mono Shade LUT ($1C-$1F) ===
<pre>
$1C $1D $1E $1F
7 bit 0 7 bit 0 7 bit 0 7 bit 0
---- ---- ---- ---- ---- ---- ---- ----
1111 0000 3333 2222 5555 4444 7777 6666
</pre>
{{Anchor|LCD Mono Palette}}
=== LCD Mono Palette 0..15 ($20, $21 .. $3E, $3F) ===
The monochrome palette is laid out as sixteen words:
<pre>
N+1 N
15 bit 8 7 bit 0
---- ---- ---- ----
.333 .222 .111 .000
||| ||| ||| |||
||| ||| ||| +++- Shade LUT index for color 0
||| ||| +++------ Shade LUT index for color 1
||| +++------------ Shade LUT index for color 2
+++----------------- Shade LUT index for color 3
</pre>
== Internal I/O ports ==
These I/O ports are said to be internal and not intended for use by commercial games.
{{Anchor|LCD Final Line}}
=== LCD Final Line ($16) ===
The final line preceding line counter restart and the beginning of active display. By default, this is set to 158, which equals 159 total lines per frame.
It is said setting this register to an odd value on SwanCrystal has an adverse effect to the LCD panel<ref>[http://daifukkat.su/docs/wsman/#REG_LCD_VTOTAL REG_LCD_VTOTAL - WSMan]</ref>, but the exact mechanism is unknown.
{{Anchor|LCD Back Porch Line}}
=== LCD Back Porch Line ($17, WSC only) ===
This port is available on the WonderSwan Color only - not the SwanCrystal!
The final line preceding the vertical back porch; by default, this should be set to 155.
The vertical back porch of the LCD is assumed to be 4 lines by some hardware, including IPS mods, as well as the official "TV Swan" capture device. Given that the first visible line is sent to the LCD on the display's line 1, this should be generally set to <code>LCD Final Line - 3</code>.
Conversely, it is said moving this value closer to vertical blank improves LCD visibility<ref>[http://daifukkat.su/docs/wsman/#REG_LCD_VSYNC REG_LCD_VSYNC - WSMan]</ref>, but the exact mechanism is unknown.
{{Anchor|LCD Status}}
=== LCD Status ($1A) ===
<pre>
7 bit 0
---- ----
...v vv.s
| || |
| || +- LCD sleep: 0 = no, 1 = sleep
| ||
| || Volume segments:
| |+--- Volume B (medium, high)
| +---- Volume A (low, high)
+------ Speaker
</pre>
=== TFT LCD Configuration ($70, $71, $72, $73, $74, $75, $76, $77 SwanCrystal only) ===
These eight bytes are read from internal EEPROM and configure unknown aspects of the console's TFT LCD panel.
They are only writable while the [[Boot ROM]] is unlocked - locking has the side effect of making them read-only.
== Notes ==
<references />
429c593599d64eab3d9eaa8e30bc3e46d20ef30e
302
301
2024-07-12T19:41:20Z
Asie
351
/* Palettes */
wikitext
text/x-wiki
The WonderSwan's display functionality generally consists of:
* a 224x144 display clocked at ~75.47 Hz by default, capable of displaying:
** up to sixteen distinct shades of gray
** 12-bit RGB444 color<sup>(color)</sup>
* two 32x32 background layers ("screens"), capable of displaying up to 512 (1024<sup>(color)</sup>) distinct tiles,
* a sprite layer, capable of displaying up to 128 8x8 sprites (up to 32 per line),
* six LCD icons to the bottom or right of the display, usable as additional indicators.
== Components ==
=== Tiles ===
The WonderSwan can display up to 512 distinct tiles at a time, with two bits of palette index information for every pixel.
The WonderSwan Color expands this to 1024 distinct tiles for background (with 512 remaining the limit for sprites), while also introducing modes with four bits of palette index information for every pixel.
==== 2 bits per pixel, planar ====
The tiles are stored in an interleaved planar format, with two bits total for every pixel. Odd bytes store the first plane (bit 0 of each pixel), while even bytes store the second plane (bit 1 of each pixel).
<pre>
tile data (16 bytes)
01 7C 01 FC 00 C0 18 D8 18 D8 00 C0 00 00 C0 00
||
\/
plane 0 plane 1
7 bit 0 7 bit 0 full tile
---- ---- ---- ----
.... ...1 = 01 .222 22.. = 7C .22222.1
.... ...1 = 01 2222 22.. = FC 222222.1
.... .... = 00 22.. .... = C0 22......
...1 1... = 18 22.2 2... = D8 --\ 22.33...
...1 1... = 18 22.2 2... = D8 --/ 22.33...
.... .... = 00 22.. .... = C0 22......
.... .... = 00 .... .... = 00 ........
11.. .... = C0 .... .... = 00 11......
</pre>
This matches the format used by the Game Boy.
==== 4 bits per pixel, planar ====
This mode is stored in a manner similar to the 2 bits per pixel mode, but with an additional two planes for bit 2 and bit 3 of each pixel's palette index, expanding the tile data to 32 bytes.
<pre>
tile data (32 bytes)
54 32 01 00 54 32 F1 00 54 32 01 F0 54 32 F1 F0 04 02 01 00 F8 04 02 01 00 F8 04 02 00 00 F8 04
||
\/
plane 0 plane 1 plane 2 plane 3
7 bit 0 7 bit 0 7 bit 0 7 bit 0 full tile
---- ---- ---- ---- ---- ---- ---- ----
.1.1 .1.. = 54 ..22 ..2. = 32 .... ...4 = 01 .... .... = 00 .123.124
.1.1 .1.. = 54 ..22 ..2. = 32 4444 ...4 = F1 .... .... = 00 4567.124
.1.1 .1.. = 54 ..22 ..2. = 32 .... ...4 = 01 8888 .... = F0 89AB.124
.1.1 .1.. = 54 ..22 ..2. = 32 4444 ...4 = F1 8888 .... = F0 --\ CDEF.124
.... .1.. = 04 .... ..2. = 02 .... ...4 = 01 .... .... = 00 --/ .....124
1111 1... = F8 .... .2.. = 04 .... ..4. = 02 .... ...8 = 01 11111248
.... .... = 00 2222 2... = F8 .... .4.. = 04 .... ..8. = 02 2222248.
.... .... = 00 .... .... = 00 4444 4... = F8 .... .8.. = 04 444448..
</pre>
This format matches the one used by the Sega Master System and Game Gear family of consoles.
==== 4 bits per pixel, packed ====
Unlike the previous two formats, in the packed format each byte stores the complete palette index of two pixels - the high four bits store the left pixel, while the low four bits store the right pixel. Four such bytes make up a row of eight pixels from left to right.
<pre>
tile data (32 bytes)
01 23 01 24 45 67 01 24 89 AB 01 24 CD EF 01 24 00 00 01 24 11 11 12 48 22 22 24 80 44 44 48 00
||
\/
byte 0 1 2 3
bits 7-4 3-0 7-4 3-0 7-4 3-0 7-4 3-0
pixel 0 1 2 3 4 5 6 7 full tile
--- --- --- --- --- --- --- ---
. 1 = 01 2 3 = 23 . 1 = 01 2 4 = 24 .123.124 = 01 23 01 24
4 5 = 45 6 7 = 67 . 1 = 01 2 4 = 24 4567.124 = 45 67 01 24
8 9 = 89 A B = AB . 1 = 01 2 4 = 24 89AB.124 = 89 AB 01 24
C D = CD E F = EF . 1 = 01 2 4 = 24 --\ CDEF.124 = CD EF 01 24
. . = 00 . . = 00 . 1 = 01 2 4 = 24 --/ .....124 = 00 00 01 24
1 1 = 11 1 1 = 11 1 2 = 12 4 8 = 48 11111248 = 11 11 12 48
2 2 = 22 2 2 = 22 2 4 = 24 8 . = 80 2222248. = 22 22 24 80
4 4 = 44 4 4 = 44 4 8 = 48 . . = 00 444448.. = 44 44 48 00
</pre>
This format matches the one used by the Mega Drive console.
=== Palettes ===
The display system provides sixteen different palettes that can be used to color or shade tiles.
- Palettes 0-7 can be used for the two screens only;
- Palettes 8-15 can be used for both screens and sprites.
==== Mono ====
In ''mono'' modes, palettes are stored in I/O ports 0x20 through 0x3F. Each palette contains four three-bit entries, which are pointers into a global, four-bit shade lookup table:
<pre>
Palette Global shade LUT
1 ===========> 2 ==========================> 5
^ (0, 2, 4, 6) ^ (1, 3, 5, 7, 9, 11, 13, 15) ^
| | |
Palette index Value Displayed shade
</pre>
The shade value corresponds to the darkness of the pixel: shade 0 is the brightest, while shade 15 is the darkest.
==== Color ====
In ''color'' modes, palettes are stored as 16-bit words in memory addresses 0xFE00 through 0xFFFF, without additional lookup tables:
<pre>
Address
15 bit 8 7 bit 0
---- ---- ---- ----
1111 111p pppi iii.
| |||| |||
| |||+-+++-- Index in palette (0-15)
+--+++------- Palette number (0-15)
Data
15 bit 8 7 bit 0
---- ---- ---- ----
.... rrrr gggg bbbb
|||| |||| ||||
|||| |||| ++++- Blue (0-15)
|||| ++++------ Green (0-15)
++++------------ Red (0-15)
</pre>
In 2 bits per pixel color modes, palette entries 4 through 15 are not used.
==== Transparency ====
In two bit per pixel modes:
- Palettes 0-3 and 8-11 are ''opaque''. For these, index zero is treated as opaque.
- Palettes 4-7 and 12-15 are ''translucent''. For these, index zero is treated as transparent. This means that the color/shade value set to it is ignored, and only three distinct colors/shades can be used for tiles.
In four bit per pixel modes, all palettes are ''translucent''. Index zero is always treated as transparent, and fifteen different colors/shades can be used for tiles.
=== Background color ===
The background color is displayed if no ''opaque'' pixel from screens or sprites is drawn. This color is set in I/O port ''0x01'':
- In mono modes, it is set to an entry in the shade lookup table (0-7),
- In color modes, it is set to an entry in the color palette (0-255). Note that this allows you to use the first color (color zero) of any palette, which is normally ignored and assumed to be ''transparent''.
=== Screens ===
The WonderSwan can display up to two distinct 32x32 screens. These consist of 1024 two-byte cells:
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
vhbp pppt tttt tttt
|||| |||| |||| ||||
|||| |||+--++++-++++- Tile index (0-511)
|||+-+++------------- Palette (0-15)
||+------------------ Tile bank (0-1) - color only
|+------------------- Horizontal flip
+-------------------- Vertical flip
</pre>
=== Sprites ===
The WonderSwan can display up to 128 sprites at once. These are stored in a sprite table in RAM, which consists of up to 128 four-byte entries:
<pre>
(Byte 1) (Byte 0)
15 bit 8 7 bit 0
---- ---- ---- ----
vhPi pppt tttt tttt
|||| |||| |||| ||||
|||| |||+--++++-++++- Tile index (0-511) - only bank 0
|||| +++------------- Palette (0-7) - mapped to screen palettes 8-15
|||+----------------- Window location - 0 = inside, 1 = outside
||+------------------ Priority - 0 = behind Screen 2, 1 = in front of Screen 2
|+------------------- Horizontal flip
+-------------------- Vertical flip
(Byte 2)
7 bit 0
---- ----
yyyy yyyy
|||| ||||
++++-++++- Y coordinate
(Byte 3)
7 bit 0
---- ----
xxxx xxxx
|||| ||||
++++-++++- X coordinate
</pre>
For each row, the first 32 sprites for that row will be drawn - including sprites obscured by windows or outside of the visible range; only the Y coordinate determines this. The earlier among those sprites will be on top of the later ones.
=== Visibility priority ===
For display components, the visibility priority is as follows:
* Sprite 0, high priority
* Sprite 127, high priority
* Screen 2
* Sprite 0, low priority
* Sprite 127, low priority
* Screen 1
* Background color
=== Windows ===
Screen 2 and the sprite layer can optionally be restricted to a specific window.
In addition, one can control if a given element is rendered inside or outside that window. For Screen 2, this is controlled globally; for sprites, this is controlled per-sprite.
=== Icons ===
The WonderSwan features six LCD segment icons which are displayed to the right<sup>(color)</sup> or below<sup>(mono)</sup> the main display. These are, as follows:
* Aux 3 - large circle,
* Aux 2 - medium circle,
* Aux 1 - small circle,
* Horizontal orientation,
* Vertical orientation,
* Sleep.
== Interrupts ==
The display circuit generates two interrupts of its own:
* Display Interrupt Line Match - when <code>Display Current Line</code> == <code>Display Interrupt Line</code>, at the beginning of said line.
* Display Vertical Blank - when <code>Display Current Line</code> == <code>144</code>, at the beginning of said line.
It also provides a timing source for the two Horizontal and Vertical Blank [[Timers]], which provide their own respective interrupts.
== I/O ports ==
{{Anchor|Display Control}}
=== Display Control ($00) ===
<pre>
7 bit 0
---- ----
..ow Ws21
|| ||||
|| |||+- Enable Screen 1 layer
|| ||+-- Enable Screen 2 layer
|| |+--- Enable Sprite layer
|| +---- Enable Sprite window
|+------ Enable Screen 2 window
+------- Screen 2 window location:
0 = inside, 1 = outside
</pre>
{{Anchor|Display Background}}
=== Display Background Color ($01) ===
<pre>
(mono) (color)
7 bit 0 7 bit 0
---- ---- ---- ----
.... .sss pppp iiii
||| |||| ||||
+++- Value |||| ++++- Index in palette (0-15)
(0-7) ++++------ Color palette (0-15)
</pre>
{{Anchor|Display Current Line}}
=== Display Current Line ($02 read) ===
The current line being drawn by the display.
Note that lines are sent to the display with a one-line delay. This matters for color palette or shade LUT manipulation; changing these values when <code>current line == 1</code> will actually affect line 0.
{{Anchor|Display Interrupt Line}}
=== Display Interrupt Line ($03) ===
The line to emit an interrupt on.
{{Anchor|Sprite Table Address}}
=== Sprite Table Address ($04) ===
<pre>
7 bit 0
---- ----
..Aa aaaa
|| ||||
|+-++++- Address (bits 9-13)
+------- Address (bit 14) - color only
</pre>
{{Anchor|Sprite Table First}}
=== Sprite Table First ($05) ===
<pre>
7 bit 0
---- ----
.iii iiii
||| ||||
+++-++++- Index of first sprite entry to draw (0-127)
</pre>
{{Anchor|Sprite Table Count}}
=== Sprite Table Count ($06) ===
<pre>
7 bit 0
---- ----
cccc cccc
|||| ||||
++++-++++- Count of sprite entries to draw (1-128)
</pre>
{{Anchor|Screen Address}}
=== Screen Address ($07) ===
<pre>
7 bit 0
---- ----
2222 1111
|||| ||||
|||| |+++- Screen 1 address (bits 11-13)
|||| +---- Screen 1 address (bit 14) - color only
|+++------ Screen 2 address (bits 11-13)
+--------- Screen 2 address (bit 14) - color only
</pre>
{{Anchor|Screen 2 Window}}
=== Screen 2 Window Left ($08) ===
=== Screen 2 Window Top ($09) ===
=== Screen 2 Window Right ($0A) ===
=== Screen 2 Window Bottom ($0B) ===
{{Anchor|Sprite Window}}
=== Sprite Window Left ($0C) ===
=== Sprite Window Top ($0D) ===
=== Sprite Window Right ($0E) ===
=== Sprite Window Bottom ($0F) ===
{{Anchor|Screen Scroll}}
=== Screen 1 Scroll X ($10) ===
=== Screen 1 Scroll Y ($11) ===
=== Screen 2 Scroll X ($12) ===
=== Screen 2 Scroll Y ($13) ===
{{Anchor|LCD Control}}
=== LCD Control ($14) ===
<pre>
7 bit 0
---- ----
.... ..Ce
||
|+- LCD Enable: 0 = sleep, 1 = enabled
+-- Contrast (WSC): 0 = low, 1 = high
</pre>
{{Anchor|LCD Icon Control}}
=== LCD Icon Control ($15) ===
<pre>
7 bit 0
---- ----
..32 1hvs
|| ||||
|| |||+- Sleep
|| ||+-- Vertical orientation
|| |+--- Horizontal orientation
|| +---- Aux 1
|+------ Aux 2
+------- Aux 3
</pre>
{{Anchor|LCD Mono Shade LUT}}
=== LCD Mono Shade LUT ($1C-$1F) ===
<pre>
$1C $1D $1E $1F
7 bit 0 7 bit 0 7 bit 0 7 bit 0
---- ---- ---- ---- ---- ---- ---- ----
1111 0000 3333 2222 5555 4444 7777 6666
</pre>
{{Anchor|LCD Mono Palette}}
=== LCD Mono Palette 0..15 ($20, $21 .. $3E, $3F) ===
The monochrome palette is laid out as sixteen words:
<pre>
N+1 N
15 bit 8 7 bit 0
---- ---- ---- ----
.333 .222 .111 .000
||| ||| ||| |||
||| ||| ||| +++- Shade LUT index for color 0
||| ||| +++------ Shade LUT index for color 1
||| +++------------ Shade LUT index for color 2
+++----------------- Shade LUT index for color 3
</pre>
== Internal I/O ports ==
These I/O ports are said to be internal and not intended for use by commercial games.
{{Anchor|LCD Final Line}}
=== LCD Final Line ($16) ===
The final line preceding line counter restart and the beginning of active display. By default, this is set to 158, which equals 159 total lines per frame.
It is said setting this register to an odd value on SwanCrystal has an adverse effect to the LCD panel<ref>[http://daifukkat.su/docs/wsman/#REG_LCD_VTOTAL REG_LCD_VTOTAL - WSMan]</ref>, but the exact mechanism is unknown.
{{Anchor|LCD Back Porch Line}}
=== LCD Back Porch Line ($17, WSC only) ===
This port is available on the WonderSwan Color only - not the SwanCrystal!
The final line preceding the vertical back porch; by default, this should be set to 155.
The vertical back porch of the LCD is assumed to be 4 lines by some hardware, including IPS mods, as well as the official "TV Swan" capture device. Given that the first visible line is sent to the LCD on the display's line 1, this should be generally set to <code>LCD Final Line - 3</code>.
Conversely, it is said moving this value closer to vertical blank improves LCD visibility<ref>[http://daifukkat.su/docs/wsman/#REG_LCD_VSYNC REG_LCD_VSYNC - WSMan]</ref>, but the exact mechanism is unknown.
{{Anchor|LCD Status}}
=== LCD Status ($1A) ===
<pre>
7 bit 0
---- ----
...v vv.s
| || |
| || +- LCD sleep: 0 = no, 1 = sleep
| ||
| || Volume segments:
| |+--- Volume B (medium, high)
| +---- Volume A (low, high)
+------ Speaker
</pre>
=== TFT LCD Configuration ($70, $71, $72, $73, $74, $75, $76, $77 SwanCrystal only) ===
These eight bytes are read from internal EEPROM and configure unknown aspects of the console's TFT LCD panel.
They are only writable while the [[Boot ROM]] is unlocked - locking has the side effect of making them read-only.
== Notes ==
<references />
259f2365f4a68d463033294931a5cd834ecb742d
303
302
2024-07-12T19:41:42Z
Asie
351
/* Palettes */
wikitext
text/x-wiki
The WonderSwan's display functionality generally consists of:
* a 224x144 display clocked at ~75.47 Hz by default, capable of displaying:
** up to sixteen distinct shades of gray
** 12-bit RGB444 color<sup>(color)</sup>
* two 32x32 background layers ("screens"), capable of displaying up to 512 (1024<sup>(color)</sup>) distinct tiles,
* a sprite layer, capable of displaying up to 128 8x8 sprites (up to 32 per line),
* six LCD icons to the bottom or right of the display, usable as additional indicators.
== Components ==
=== Tiles ===
The WonderSwan can display up to 512 distinct tiles at a time, with two bits of palette index information for every pixel.
The WonderSwan Color expands this to 1024 distinct tiles for background (with 512 remaining the limit for sprites), while also introducing modes with four bits of palette index information for every pixel.
==== 2 bits per pixel, planar ====
The tiles are stored in an interleaved planar format, with two bits total for every pixel. Odd bytes store the first plane (bit 0 of each pixel), while even bytes store the second plane (bit 1 of each pixel).
<pre>
tile data (16 bytes)
01 7C 01 FC 00 C0 18 D8 18 D8 00 C0 00 00 C0 00
||
\/
plane 0 plane 1
7 bit 0 7 bit 0 full tile
---- ---- ---- ----
.... ...1 = 01 .222 22.. = 7C .22222.1
.... ...1 = 01 2222 22.. = FC 222222.1
.... .... = 00 22.. .... = C0 22......
...1 1... = 18 22.2 2... = D8 --\ 22.33...
...1 1... = 18 22.2 2... = D8 --/ 22.33...
.... .... = 00 22.. .... = C0 22......
.... .... = 00 .... .... = 00 ........
11.. .... = C0 .... .... = 00 11......
</pre>
This matches the format used by the Game Boy.
==== 4 bits per pixel, planar ====
This mode is stored in a manner similar to the 2 bits per pixel mode, but with an additional two planes for bit 2 and bit 3 of each pixel's palette index, expanding the tile data to 32 bytes.
<pre>
tile data (32 bytes)
54 32 01 00 54 32 F1 00 54 32 01 F0 54 32 F1 F0 04 02 01 00 F8 04 02 01 00 F8 04 02 00 00 F8 04
||
\/
plane 0 plane 1 plane 2 plane 3
7 bit 0 7 bit 0 7 bit 0 7 bit 0 full tile
---- ---- ---- ---- ---- ---- ---- ----
.1.1 .1.. = 54 ..22 ..2. = 32 .... ...4 = 01 .... .... = 00 .123.124
.1.1 .1.. = 54 ..22 ..2. = 32 4444 ...4 = F1 .... .... = 00 4567.124
.1.1 .1.. = 54 ..22 ..2. = 32 .... ...4 = 01 8888 .... = F0 89AB.124
.1.1 .1.. = 54 ..22 ..2. = 32 4444 ...4 = F1 8888 .... = F0 --\ CDEF.124
.... .1.. = 04 .... ..2. = 02 .... ...4 = 01 .... .... = 00 --/ .....124
1111 1... = F8 .... .2.. = 04 .... ..4. = 02 .... ...8 = 01 11111248
.... .... = 00 2222 2... = F8 .... .4.. = 04 .... ..8. = 02 2222248.
.... .... = 00 .... .... = 00 4444 4... = F8 .... .8.. = 04 444448..
</pre>
This format matches the one used by the Sega Master System and Game Gear family of consoles.
==== 4 bits per pixel, packed ====
Unlike the previous two formats, in the packed format each byte stores the complete palette index of two pixels - the high four bits store the left pixel, while the low four bits store the right pixel. Four such bytes make up a row of eight pixels from left to right.
<pre>
tile data (32 bytes)
01 23 01 24 45 67 01 24 89 AB 01 24 CD EF 01 24 00 00 01 24 11 11 12 48 22 22 24 80 44 44 48 00
||
\/
byte 0 1 2 3
bits 7-4 3-0 7-4 3-0 7-4 3-0 7-4 3-0
pixel 0 1 2 3 4 5 6 7 full tile
--- --- --- --- --- --- --- ---
. 1 = 01 2 3 = 23 . 1 = 01 2 4 = 24 .123.124 = 01 23 01 24
4 5 = 45 6 7 = 67 . 1 = 01 2 4 = 24 4567.124 = 45 67 01 24
8 9 = 89 A B = AB . 1 = 01 2 4 = 24 89AB.124 = 89 AB 01 24
C D = CD E F = EF . 1 = 01 2 4 = 24 --\ CDEF.124 = CD EF 01 24
. . = 00 . . = 00 . 1 = 01 2 4 = 24 --/ .....124 = 00 00 01 24
1 1 = 11 1 1 = 11 1 2 = 12 4 8 = 48 11111248 = 11 11 12 48
2 2 = 22 2 2 = 22 2 4 = 24 8 . = 80 2222248. = 22 22 24 80
4 4 = 44 4 4 = 44 4 8 = 48 . . = 00 444448.. = 44 44 48 00
</pre>
This format matches the one used by the Mega Drive console.
=== Palettes ===
The display system provides sixteen different palettes that can be used to color or shade tiles.
* Palettes 0-7 can be used for the two screens only;
* Palettes 8-15 can be used for both screens and sprites.
==== Mono ====
In ''mono'' modes, palettes are stored in I/O ports 0x20 through 0x3F. Each palette contains four three-bit entries, which are pointers into a global, four-bit shade lookup table:
<pre>
Palette Global shade LUT
1 ===========> 2 ==========================> 5
^ (0, 2, 4, 6) ^ (1, 3, 5, 7, 9, 11, 13, 15) ^
| | |
Palette index Value Displayed shade
</pre>
The shade value corresponds to the darkness of the pixel: shade 0 is the brightest, while shade 15 is the darkest.
==== Color ====
In ''color'' modes, palettes are stored as 16-bit words in memory addresses 0xFE00 through 0xFFFF, without additional lookup tables:
<pre>
Address
15 bit 8 7 bit 0
---- ---- ---- ----
1111 111p pppi iii.
| |||| |||
| |||+-+++-- Index in palette (0-15)
+--+++------- Palette number (0-15)
Data
15 bit 8 7 bit 0
---- ---- ---- ----
.... rrrr gggg bbbb
|||| |||| ||||
|||| |||| ++++- Blue (0-15)
|||| ++++------ Green (0-15)
++++------------ Red (0-15)
</pre>
In 2 bits per pixel color modes, palette entries 4 through 15 are not used.
==== Transparency ====
In two bit per pixel modes:
- Palettes 0-3 and 8-11 are ''opaque''. For these, index zero is treated as opaque.
- Palettes 4-7 and 12-15 are ''translucent''. For these, index zero is treated as transparent. This means that the color/shade value set to it is ignored, and only three distinct colors/shades can be used for tiles.
In four bit per pixel modes, all palettes are ''translucent''. Index zero is always treated as transparent, and fifteen different colors/shades can be used for tiles.
=== Background color ===
The background color is displayed if no ''opaque'' pixel from screens or sprites is drawn. This color is set in I/O port ''0x01'':
- In mono modes, it is set to an entry in the shade lookup table (0-7),
- In color modes, it is set to an entry in the color palette (0-255). Note that this allows you to use the first color (color zero) of any palette, which is normally ignored and assumed to be ''transparent''.
=== Screens ===
The WonderSwan can display up to two distinct 32x32 screens. These consist of 1024 two-byte cells:
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
vhbp pppt tttt tttt
|||| |||| |||| ||||
|||| |||+--++++-++++- Tile index (0-511)
|||+-+++------------- Palette (0-15)
||+------------------ Tile bank (0-1) - color only
|+------------------- Horizontal flip
+-------------------- Vertical flip
</pre>
=== Sprites ===
The WonderSwan can display up to 128 sprites at once. These are stored in a sprite table in RAM, which consists of up to 128 four-byte entries:
<pre>
(Byte 1) (Byte 0)
15 bit 8 7 bit 0
---- ---- ---- ----
vhPi pppt tttt tttt
|||| |||| |||| ||||
|||| |||+--++++-++++- Tile index (0-511) - only bank 0
|||| +++------------- Palette (0-7) - mapped to screen palettes 8-15
|||+----------------- Window location - 0 = inside, 1 = outside
||+------------------ Priority - 0 = behind Screen 2, 1 = in front of Screen 2
|+------------------- Horizontal flip
+-------------------- Vertical flip
(Byte 2)
7 bit 0
---- ----
yyyy yyyy
|||| ||||
++++-++++- Y coordinate
(Byte 3)
7 bit 0
---- ----
xxxx xxxx
|||| ||||
++++-++++- X coordinate
</pre>
For each row, the first 32 sprites for that row will be drawn - including sprites obscured by windows or outside of the visible range; only the Y coordinate determines this. The earlier among those sprites will be on top of the later ones.
=== Visibility priority ===
For display components, the visibility priority is as follows:
* Sprite 0, high priority
* Sprite 127, high priority
* Screen 2
* Sprite 0, low priority
* Sprite 127, low priority
* Screen 1
* Background color
=== Windows ===
Screen 2 and the sprite layer can optionally be restricted to a specific window.
In addition, one can control if a given element is rendered inside or outside that window. For Screen 2, this is controlled globally; for sprites, this is controlled per-sprite.
=== Icons ===
The WonderSwan features six LCD segment icons which are displayed to the right<sup>(color)</sup> or below<sup>(mono)</sup> the main display. These are, as follows:
* Aux 3 - large circle,
* Aux 2 - medium circle,
* Aux 1 - small circle,
* Horizontal orientation,
* Vertical orientation,
* Sleep.
== Interrupts ==
The display circuit generates two interrupts of its own:
* Display Interrupt Line Match - when <code>Display Current Line</code> == <code>Display Interrupt Line</code>, at the beginning of said line.
* Display Vertical Blank - when <code>Display Current Line</code> == <code>144</code>, at the beginning of said line.
It also provides a timing source for the two Horizontal and Vertical Blank [[Timers]], which provide their own respective interrupts.
== I/O ports ==
{{Anchor|Display Control}}
=== Display Control ($00) ===
<pre>
7 bit 0
---- ----
..ow Ws21
|| ||||
|| |||+- Enable Screen 1 layer
|| ||+-- Enable Screen 2 layer
|| |+--- Enable Sprite layer
|| +---- Enable Sprite window
|+------ Enable Screen 2 window
+------- Screen 2 window location:
0 = inside, 1 = outside
</pre>
{{Anchor|Display Background}}
=== Display Background Color ($01) ===
<pre>
(mono) (color)
7 bit 0 7 bit 0
---- ---- ---- ----
.... .sss pppp iiii
||| |||| ||||
+++- Value |||| ++++- Index in palette (0-15)
(0-7) ++++------ Color palette (0-15)
</pre>
{{Anchor|Display Current Line}}
=== Display Current Line ($02 read) ===
The current line being drawn by the display.
Note that lines are sent to the display with a one-line delay. This matters for color palette or shade LUT manipulation; changing these values when <code>current line == 1</code> will actually affect line 0.
{{Anchor|Display Interrupt Line}}
=== Display Interrupt Line ($03) ===
The line to emit an interrupt on.
{{Anchor|Sprite Table Address}}
=== Sprite Table Address ($04) ===
<pre>
7 bit 0
---- ----
..Aa aaaa
|| ||||
|+-++++- Address (bits 9-13)
+------- Address (bit 14) - color only
</pre>
{{Anchor|Sprite Table First}}
=== Sprite Table First ($05) ===
<pre>
7 bit 0
---- ----
.iii iiii
||| ||||
+++-++++- Index of first sprite entry to draw (0-127)
</pre>
{{Anchor|Sprite Table Count}}
=== Sprite Table Count ($06) ===
<pre>
7 bit 0
---- ----
cccc cccc
|||| ||||
++++-++++- Count of sprite entries to draw (1-128)
</pre>
{{Anchor|Screen Address}}
=== Screen Address ($07) ===
<pre>
7 bit 0
---- ----
2222 1111
|||| ||||
|||| |+++- Screen 1 address (bits 11-13)
|||| +---- Screen 1 address (bit 14) - color only
|+++------ Screen 2 address (bits 11-13)
+--------- Screen 2 address (bit 14) - color only
</pre>
{{Anchor|Screen 2 Window}}
=== Screen 2 Window Left ($08) ===
=== Screen 2 Window Top ($09) ===
=== Screen 2 Window Right ($0A) ===
=== Screen 2 Window Bottom ($0B) ===
{{Anchor|Sprite Window}}
=== Sprite Window Left ($0C) ===
=== Sprite Window Top ($0D) ===
=== Sprite Window Right ($0E) ===
=== Sprite Window Bottom ($0F) ===
{{Anchor|Screen Scroll}}
=== Screen 1 Scroll X ($10) ===
=== Screen 1 Scroll Y ($11) ===
=== Screen 2 Scroll X ($12) ===
=== Screen 2 Scroll Y ($13) ===
{{Anchor|LCD Control}}
=== LCD Control ($14) ===
<pre>
7 bit 0
---- ----
.... ..Ce
||
|+- LCD Enable: 0 = sleep, 1 = enabled
+-- Contrast (WSC): 0 = low, 1 = high
</pre>
{{Anchor|LCD Icon Control}}
=== LCD Icon Control ($15) ===
<pre>
7 bit 0
---- ----
..32 1hvs
|| ||||
|| |||+- Sleep
|| ||+-- Vertical orientation
|| |+--- Horizontal orientation
|| +---- Aux 1
|+------ Aux 2
+------- Aux 3
</pre>
{{Anchor|LCD Mono Shade LUT}}
=== LCD Mono Shade LUT ($1C-$1F) ===
<pre>
$1C $1D $1E $1F
7 bit 0 7 bit 0 7 bit 0 7 bit 0
---- ---- ---- ---- ---- ---- ---- ----
1111 0000 3333 2222 5555 4444 7777 6666
</pre>
{{Anchor|LCD Mono Palette}}
=== LCD Mono Palette 0..15 ($20, $21 .. $3E, $3F) ===
The monochrome palette is laid out as sixteen words:
<pre>
N+1 N
15 bit 8 7 bit 0
---- ---- ---- ----
.333 .222 .111 .000
||| ||| ||| |||
||| ||| ||| +++- Shade LUT index for color 0
||| ||| +++------ Shade LUT index for color 1
||| +++------------ Shade LUT index for color 2
+++----------------- Shade LUT index for color 3
</pre>
== Internal I/O ports ==
These I/O ports are said to be internal and not intended for use by commercial games.
{{Anchor|LCD Final Line}}
=== LCD Final Line ($16) ===
The final line preceding line counter restart and the beginning of active display. By default, this is set to 158, which equals 159 total lines per frame.
It is said setting this register to an odd value on SwanCrystal has an adverse effect to the LCD panel<ref>[http://daifukkat.su/docs/wsman/#REG_LCD_VTOTAL REG_LCD_VTOTAL - WSMan]</ref>, but the exact mechanism is unknown.
{{Anchor|LCD Back Porch Line}}
=== LCD Back Porch Line ($17, WSC only) ===
This port is available on the WonderSwan Color only - not the SwanCrystal!
The final line preceding the vertical back porch; by default, this should be set to 155.
The vertical back porch of the LCD is assumed to be 4 lines by some hardware, including IPS mods, as well as the official "TV Swan" capture device. Given that the first visible line is sent to the LCD on the display's line 1, this should be generally set to <code>LCD Final Line - 3</code>.
Conversely, it is said moving this value closer to vertical blank improves LCD visibility<ref>[http://daifukkat.su/docs/wsman/#REG_LCD_VSYNC REG_LCD_VSYNC - WSMan]</ref>, but the exact mechanism is unknown.
{{Anchor|LCD Status}}
=== LCD Status ($1A) ===
<pre>
7 bit 0
---- ----
...v vv.s
| || |
| || +- LCD sleep: 0 = no, 1 = sleep
| ||
| || Volume segments:
| |+--- Volume B (medium, high)
| +---- Volume A (low, high)
+------ Speaker
</pre>
=== TFT LCD Configuration ($70, $71, $72, $73, $74, $75, $76, $77 SwanCrystal only) ===
These eight bytes are read from internal EEPROM and configure unknown aspects of the console's TFT LCD panel.
They are only writable while the [[Boot ROM]] is unlocked - locking has the side effect of making them read-only.
== Notes ==
<references />
eb556e3eff32371927eeaf6ee6e21da5ee4a17ed
304
303
2024-07-12T19:41:49Z
Asie
351
/* Transparency */
wikitext
text/x-wiki
The WonderSwan's display functionality generally consists of:
* a 224x144 display clocked at ~75.47 Hz by default, capable of displaying:
** up to sixteen distinct shades of gray
** 12-bit RGB444 color<sup>(color)</sup>
* two 32x32 background layers ("screens"), capable of displaying up to 512 (1024<sup>(color)</sup>) distinct tiles,
* a sprite layer, capable of displaying up to 128 8x8 sprites (up to 32 per line),
* six LCD icons to the bottom or right of the display, usable as additional indicators.
== Components ==
=== Tiles ===
The WonderSwan can display up to 512 distinct tiles at a time, with two bits of palette index information for every pixel.
The WonderSwan Color expands this to 1024 distinct tiles for background (with 512 remaining the limit for sprites), while also introducing modes with four bits of palette index information for every pixel.
==== 2 bits per pixel, planar ====
The tiles are stored in an interleaved planar format, with two bits total for every pixel. Odd bytes store the first plane (bit 0 of each pixel), while even bytes store the second plane (bit 1 of each pixel).
<pre>
tile data (16 bytes)
01 7C 01 FC 00 C0 18 D8 18 D8 00 C0 00 00 C0 00
||
\/
plane 0 plane 1
7 bit 0 7 bit 0 full tile
---- ---- ---- ----
.... ...1 = 01 .222 22.. = 7C .22222.1
.... ...1 = 01 2222 22.. = FC 222222.1
.... .... = 00 22.. .... = C0 22......
...1 1... = 18 22.2 2... = D8 --\ 22.33...
...1 1... = 18 22.2 2... = D8 --/ 22.33...
.... .... = 00 22.. .... = C0 22......
.... .... = 00 .... .... = 00 ........
11.. .... = C0 .... .... = 00 11......
</pre>
This matches the format used by the Game Boy.
==== 4 bits per pixel, planar ====
This mode is stored in a manner similar to the 2 bits per pixel mode, but with an additional two planes for bit 2 and bit 3 of each pixel's palette index, expanding the tile data to 32 bytes.
<pre>
tile data (32 bytes)
54 32 01 00 54 32 F1 00 54 32 01 F0 54 32 F1 F0 04 02 01 00 F8 04 02 01 00 F8 04 02 00 00 F8 04
||
\/
plane 0 plane 1 plane 2 plane 3
7 bit 0 7 bit 0 7 bit 0 7 bit 0 full tile
---- ---- ---- ---- ---- ---- ---- ----
.1.1 .1.. = 54 ..22 ..2. = 32 .... ...4 = 01 .... .... = 00 .123.124
.1.1 .1.. = 54 ..22 ..2. = 32 4444 ...4 = F1 .... .... = 00 4567.124
.1.1 .1.. = 54 ..22 ..2. = 32 .... ...4 = 01 8888 .... = F0 89AB.124
.1.1 .1.. = 54 ..22 ..2. = 32 4444 ...4 = F1 8888 .... = F0 --\ CDEF.124
.... .1.. = 04 .... ..2. = 02 .... ...4 = 01 .... .... = 00 --/ .....124
1111 1... = F8 .... .2.. = 04 .... ..4. = 02 .... ...8 = 01 11111248
.... .... = 00 2222 2... = F8 .... .4.. = 04 .... ..8. = 02 2222248.
.... .... = 00 .... .... = 00 4444 4... = F8 .... .8.. = 04 444448..
</pre>
This format matches the one used by the Sega Master System and Game Gear family of consoles.
==== 4 bits per pixel, packed ====
Unlike the previous two formats, in the packed format each byte stores the complete palette index of two pixels - the high four bits store the left pixel, while the low four bits store the right pixel. Four such bytes make up a row of eight pixels from left to right.
<pre>
tile data (32 bytes)
01 23 01 24 45 67 01 24 89 AB 01 24 CD EF 01 24 00 00 01 24 11 11 12 48 22 22 24 80 44 44 48 00
||
\/
byte 0 1 2 3
bits 7-4 3-0 7-4 3-0 7-4 3-0 7-4 3-0
pixel 0 1 2 3 4 5 6 7 full tile
--- --- --- --- --- --- --- ---
. 1 = 01 2 3 = 23 . 1 = 01 2 4 = 24 .123.124 = 01 23 01 24
4 5 = 45 6 7 = 67 . 1 = 01 2 4 = 24 4567.124 = 45 67 01 24
8 9 = 89 A B = AB . 1 = 01 2 4 = 24 89AB.124 = 89 AB 01 24
C D = CD E F = EF . 1 = 01 2 4 = 24 --\ CDEF.124 = CD EF 01 24
. . = 00 . . = 00 . 1 = 01 2 4 = 24 --/ .....124 = 00 00 01 24
1 1 = 11 1 1 = 11 1 2 = 12 4 8 = 48 11111248 = 11 11 12 48
2 2 = 22 2 2 = 22 2 4 = 24 8 . = 80 2222248. = 22 22 24 80
4 4 = 44 4 4 = 44 4 8 = 48 . . = 00 444448.. = 44 44 48 00
</pre>
This format matches the one used by the Mega Drive console.
=== Palettes ===
The display system provides sixteen different palettes that can be used to color or shade tiles.
* Palettes 0-7 can be used for the two screens only;
* Palettes 8-15 can be used for both screens and sprites.
==== Mono ====
In ''mono'' modes, palettes are stored in I/O ports 0x20 through 0x3F. Each palette contains four three-bit entries, which are pointers into a global, four-bit shade lookup table:
<pre>
Palette Global shade LUT
1 ===========> 2 ==========================> 5
^ (0, 2, 4, 6) ^ (1, 3, 5, 7, 9, 11, 13, 15) ^
| | |
Palette index Value Displayed shade
</pre>
The shade value corresponds to the darkness of the pixel: shade 0 is the brightest, while shade 15 is the darkest.
==== Color ====
In ''color'' modes, palettes are stored as 16-bit words in memory addresses 0xFE00 through 0xFFFF, without additional lookup tables:
<pre>
Address
15 bit 8 7 bit 0
---- ---- ---- ----
1111 111p pppi iii.
| |||| |||
| |||+-+++-- Index in palette (0-15)
+--+++------- Palette number (0-15)
Data
15 bit 8 7 bit 0
---- ---- ---- ----
.... rrrr gggg bbbb
|||| |||| ||||
|||| |||| ++++- Blue (0-15)
|||| ++++------ Green (0-15)
++++------------ Red (0-15)
</pre>
In 2 bits per pixel color modes, palette entries 4 through 15 are not used.
==== Transparency ====
In two bit per pixel modes:
* Palettes 0-3 and 8-11 are ''opaque''. For these, index zero is treated as opaque.
* Palettes 4-7 and 12-15 are ''translucent''. For these, index zero is treated as transparent. This means that the color/shade value set to it is ignored, and only three distinct colors/shades can be used for tiles.
In four bit per pixel modes, all palettes are ''translucent''. Index zero is always treated as transparent, and fifteen different colors/shades can be used for tiles.
=== Background color ===
The background color is displayed if no ''opaque'' pixel from screens or sprites is drawn. This color is set in I/O port ''0x01'':
- In mono modes, it is set to an entry in the shade lookup table (0-7),
- In color modes, it is set to an entry in the color palette (0-255). Note that this allows you to use the first color (color zero) of any palette, which is normally ignored and assumed to be ''transparent''.
=== Screens ===
The WonderSwan can display up to two distinct 32x32 screens. These consist of 1024 two-byte cells:
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
vhbp pppt tttt tttt
|||| |||| |||| ||||
|||| |||+--++++-++++- Tile index (0-511)
|||+-+++------------- Palette (0-15)
||+------------------ Tile bank (0-1) - color only
|+------------------- Horizontal flip
+-------------------- Vertical flip
</pre>
=== Sprites ===
The WonderSwan can display up to 128 sprites at once. These are stored in a sprite table in RAM, which consists of up to 128 four-byte entries:
<pre>
(Byte 1) (Byte 0)
15 bit 8 7 bit 0
---- ---- ---- ----
vhPi pppt tttt tttt
|||| |||| |||| ||||
|||| |||+--++++-++++- Tile index (0-511) - only bank 0
|||| +++------------- Palette (0-7) - mapped to screen palettes 8-15
|||+----------------- Window location - 0 = inside, 1 = outside
||+------------------ Priority - 0 = behind Screen 2, 1 = in front of Screen 2
|+------------------- Horizontal flip
+-------------------- Vertical flip
(Byte 2)
7 bit 0
---- ----
yyyy yyyy
|||| ||||
++++-++++- Y coordinate
(Byte 3)
7 bit 0
---- ----
xxxx xxxx
|||| ||||
++++-++++- X coordinate
</pre>
For each row, the first 32 sprites for that row will be drawn - including sprites obscured by windows or outside of the visible range; only the Y coordinate determines this. The earlier among those sprites will be on top of the later ones.
=== Visibility priority ===
For display components, the visibility priority is as follows:
* Sprite 0, high priority
* Sprite 127, high priority
* Screen 2
* Sprite 0, low priority
* Sprite 127, low priority
* Screen 1
* Background color
=== Windows ===
Screen 2 and the sprite layer can optionally be restricted to a specific window.
In addition, one can control if a given element is rendered inside or outside that window. For Screen 2, this is controlled globally; for sprites, this is controlled per-sprite.
=== Icons ===
The WonderSwan features six LCD segment icons which are displayed to the right<sup>(color)</sup> or below<sup>(mono)</sup> the main display. These are, as follows:
* Aux 3 - large circle,
* Aux 2 - medium circle,
* Aux 1 - small circle,
* Horizontal orientation,
* Vertical orientation,
* Sleep.
== Interrupts ==
The display circuit generates two interrupts of its own:
* Display Interrupt Line Match - when <code>Display Current Line</code> == <code>Display Interrupt Line</code>, at the beginning of said line.
* Display Vertical Blank - when <code>Display Current Line</code> == <code>144</code>, at the beginning of said line.
It also provides a timing source for the two Horizontal and Vertical Blank [[Timers]], which provide their own respective interrupts.
== I/O ports ==
{{Anchor|Display Control}}
=== Display Control ($00) ===
<pre>
7 bit 0
---- ----
..ow Ws21
|| ||||
|| |||+- Enable Screen 1 layer
|| ||+-- Enable Screen 2 layer
|| |+--- Enable Sprite layer
|| +---- Enable Sprite window
|+------ Enable Screen 2 window
+------- Screen 2 window location:
0 = inside, 1 = outside
</pre>
{{Anchor|Display Background}}
=== Display Background Color ($01) ===
<pre>
(mono) (color)
7 bit 0 7 bit 0
---- ---- ---- ----
.... .sss pppp iiii
||| |||| ||||
+++- Value |||| ++++- Index in palette (0-15)
(0-7) ++++------ Color palette (0-15)
</pre>
{{Anchor|Display Current Line}}
=== Display Current Line ($02 read) ===
The current line being drawn by the display.
Note that lines are sent to the display with a one-line delay. This matters for color palette or shade LUT manipulation; changing these values when <code>current line == 1</code> will actually affect line 0.
{{Anchor|Display Interrupt Line}}
=== Display Interrupt Line ($03) ===
The line to emit an interrupt on.
{{Anchor|Sprite Table Address}}
=== Sprite Table Address ($04) ===
<pre>
7 bit 0
---- ----
..Aa aaaa
|| ||||
|+-++++- Address (bits 9-13)
+------- Address (bit 14) - color only
</pre>
{{Anchor|Sprite Table First}}
=== Sprite Table First ($05) ===
<pre>
7 bit 0
---- ----
.iii iiii
||| ||||
+++-++++- Index of first sprite entry to draw (0-127)
</pre>
{{Anchor|Sprite Table Count}}
=== Sprite Table Count ($06) ===
<pre>
7 bit 0
---- ----
cccc cccc
|||| ||||
++++-++++- Count of sprite entries to draw (1-128)
</pre>
{{Anchor|Screen Address}}
=== Screen Address ($07) ===
<pre>
7 bit 0
---- ----
2222 1111
|||| ||||
|||| |+++- Screen 1 address (bits 11-13)
|||| +---- Screen 1 address (bit 14) - color only
|+++------ Screen 2 address (bits 11-13)
+--------- Screen 2 address (bit 14) - color only
</pre>
{{Anchor|Screen 2 Window}}
=== Screen 2 Window Left ($08) ===
=== Screen 2 Window Top ($09) ===
=== Screen 2 Window Right ($0A) ===
=== Screen 2 Window Bottom ($0B) ===
{{Anchor|Sprite Window}}
=== Sprite Window Left ($0C) ===
=== Sprite Window Top ($0D) ===
=== Sprite Window Right ($0E) ===
=== Sprite Window Bottom ($0F) ===
{{Anchor|Screen Scroll}}
=== Screen 1 Scroll X ($10) ===
=== Screen 1 Scroll Y ($11) ===
=== Screen 2 Scroll X ($12) ===
=== Screen 2 Scroll Y ($13) ===
{{Anchor|LCD Control}}
=== LCD Control ($14) ===
<pre>
7 bit 0
---- ----
.... ..Ce
||
|+- LCD Enable: 0 = sleep, 1 = enabled
+-- Contrast (WSC): 0 = low, 1 = high
</pre>
{{Anchor|LCD Icon Control}}
=== LCD Icon Control ($15) ===
<pre>
7 bit 0
---- ----
..32 1hvs
|| ||||
|| |||+- Sleep
|| ||+-- Vertical orientation
|| |+--- Horizontal orientation
|| +---- Aux 1
|+------ Aux 2
+------- Aux 3
</pre>
{{Anchor|LCD Mono Shade LUT}}
=== LCD Mono Shade LUT ($1C-$1F) ===
<pre>
$1C $1D $1E $1F
7 bit 0 7 bit 0 7 bit 0 7 bit 0
---- ---- ---- ---- ---- ---- ---- ----
1111 0000 3333 2222 5555 4444 7777 6666
</pre>
{{Anchor|LCD Mono Palette}}
=== LCD Mono Palette 0..15 ($20, $21 .. $3E, $3F) ===
The monochrome palette is laid out as sixteen words:
<pre>
N+1 N
15 bit 8 7 bit 0
---- ---- ---- ----
.333 .222 .111 .000
||| ||| ||| |||
||| ||| ||| +++- Shade LUT index for color 0
||| ||| +++------ Shade LUT index for color 1
||| +++------------ Shade LUT index for color 2
+++----------------- Shade LUT index for color 3
</pre>
== Internal I/O ports ==
These I/O ports are said to be internal and not intended for use by commercial games.
{{Anchor|LCD Final Line}}
=== LCD Final Line ($16) ===
The final line preceding line counter restart and the beginning of active display. By default, this is set to 158, which equals 159 total lines per frame.
It is said setting this register to an odd value on SwanCrystal has an adverse effect to the LCD panel<ref>[http://daifukkat.su/docs/wsman/#REG_LCD_VTOTAL REG_LCD_VTOTAL - WSMan]</ref>, but the exact mechanism is unknown.
{{Anchor|LCD Back Porch Line}}
=== LCD Back Porch Line ($17, WSC only) ===
This port is available on the WonderSwan Color only - not the SwanCrystal!
The final line preceding the vertical back porch; by default, this should be set to 155.
The vertical back porch of the LCD is assumed to be 4 lines by some hardware, including IPS mods, as well as the official "TV Swan" capture device. Given that the first visible line is sent to the LCD on the display's line 1, this should be generally set to <code>LCD Final Line - 3</code>.
Conversely, it is said moving this value closer to vertical blank improves LCD visibility<ref>[http://daifukkat.su/docs/wsman/#REG_LCD_VSYNC REG_LCD_VSYNC - WSMan]</ref>, but the exact mechanism is unknown.
{{Anchor|LCD Status}}
=== LCD Status ($1A) ===
<pre>
7 bit 0
---- ----
...v vv.s
| || |
| || +- LCD sleep: 0 = no, 1 = sleep
| ||
| || Volume segments:
| |+--- Volume B (medium, high)
| +---- Volume A (low, high)
+------ Speaker
</pre>
=== TFT LCD Configuration ($70, $71, $72, $73, $74, $75, $76, $77 SwanCrystal only) ===
These eight bytes are read from internal EEPROM and configure unknown aspects of the console's TFT LCD panel.
They are only writable while the [[Boot ROM]] is unlocked - locking has the side effect of making them read-only.
== Notes ==
<references />
a8edd709692a7a18c9ae9e67519f2de5c65a3e6c
305
304
2024-07-12T19:41:59Z
Asie
351
/* Background color */
wikitext
text/x-wiki
The WonderSwan's display functionality generally consists of:
* a 224x144 display clocked at ~75.47 Hz by default, capable of displaying:
** up to sixteen distinct shades of gray
** 12-bit RGB444 color<sup>(color)</sup>
* two 32x32 background layers ("screens"), capable of displaying up to 512 (1024<sup>(color)</sup>) distinct tiles,
* a sprite layer, capable of displaying up to 128 8x8 sprites (up to 32 per line),
* six LCD icons to the bottom or right of the display, usable as additional indicators.
== Components ==
=== Tiles ===
The WonderSwan can display up to 512 distinct tiles at a time, with two bits of palette index information for every pixel.
The WonderSwan Color expands this to 1024 distinct tiles for background (with 512 remaining the limit for sprites), while also introducing modes with four bits of palette index information for every pixel.
==== 2 bits per pixel, planar ====
The tiles are stored in an interleaved planar format, with two bits total for every pixel. Odd bytes store the first plane (bit 0 of each pixel), while even bytes store the second plane (bit 1 of each pixel).
<pre>
tile data (16 bytes)
01 7C 01 FC 00 C0 18 D8 18 D8 00 C0 00 00 C0 00
||
\/
plane 0 plane 1
7 bit 0 7 bit 0 full tile
---- ---- ---- ----
.... ...1 = 01 .222 22.. = 7C .22222.1
.... ...1 = 01 2222 22.. = FC 222222.1
.... .... = 00 22.. .... = C0 22......
...1 1... = 18 22.2 2... = D8 --\ 22.33...
...1 1... = 18 22.2 2... = D8 --/ 22.33...
.... .... = 00 22.. .... = C0 22......
.... .... = 00 .... .... = 00 ........
11.. .... = C0 .... .... = 00 11......
</pre>
This matches the format used by the Game Boy.
==== 4 bits per pixel, planar ====
This mode is stored in a manner similar to the 2 bits per pixel mode, but with an additional two planes for bit 2 and bit 3 of each pixel's palette index, expanding the tile data to 32 bytes.
<pre>
tile data (32 bytes)
54 32 01 00 54 32 F1 00 54 32 01 F0 54 32 F1 F0 04 02 01 00 F8 04 02 01 00 F8 04 02 00 00 F8 04
||
\/
plane 0 plane 1 plane 2 plane 3
7 bit 0 7 bit 0 7 bit 0 7 bit 0 full tile
---- ---- ---- ---- ---- ---- ---- ----
.1.1 .1.. = 54 ..22 ..2. = 32 .... ...4 = 01 .... .... = 00 .123.124
.1.1 .1.. = 54 ..22 ..2. = 32 4444 ...4 = F1 .... .... = 00 4567.124
.1.1 .1.. = 54 ..22 ..2. = 32 .... ...4 = 01 8888 .... = F0 89AB.124
.1.1 .1.. = 54 ..22 ..2. = 32 4444 ...4 = F1 8888 .... = F0 --\ CDEF.124
.... .1.. = 04 .... ..2. = 02 .... ...4 = 01 .... .... = 00 --/ .....124
1111 1... = F8 .... .2.. = 04 .... ..4. = 02 .... ...8 = 01 11111248
.... .... = 00 2222 2... = F8 .... .4.. = 04 .... ..8. = 02 2222248.
.... .... = 00 .... .... = 00 4444 4... = F8 .... .8.. = 04 444448..
</pre>
This format matches the one used by the Sega Master System and Game Gear family of consoles.
==== 4 bits per pixel, packed ====
Unlike the previous two formats, in the packed format each byte stores the complete palette index of two pixels - the high four bits store the left pixel, while the low four bits store the right pixel. Four such bytes make up a row of eight pixels from left to right.
<pre>
tile data (32 bytes)
01 23 01 24 45 67 01 24 89 AB 01 24 CD EF 01 24 00 00 01 24 11 11 12 48 22 22 24 80 44 44 48 00
||
\/
byte 0 1 2 3
bits 7-4 3-0 7-4 3-0 7-4 3-0 7-4 3-0
pixel 0 1 2 3 4 5 6 7 full tile
--- --- --- --- --- --- --- ---
. 1 = 01 2 3 = 23 . 1 = 01 2 4 = 24 .123.124 = 01 23 01 24
4 5 = 45 6 7 = 67 . 1 = 01 2 4 = 24 4567.124 = 45 67 01 24
8 9 = 89 A B = AB . 1 = 01 2 4 = 24 89AB.124 = 89 AB 01 24
C D = CD E F = EF . 1 = 01 2 4 = 24 --\ CDEF.124 = CD EF 01 24
. . = 00 . . = 00 . 1 = 01 2 4 = 24 --/ .....124 = 00 00 01 24
1 1 = 11 1 1 = 11 1 2 = 12 4 8 = 48 11111248 = 11 11 12 48
2 2 = 22 2 2 = 22 2 4 = 24 8 . = 80 2222248. = 22 22 24 80
4 4 = 44 4 4 = 44 4 8 = 48 . . = 00 444448.. = 44 44 48 00
</pre>
This format matches the one used by the Mega Drive console.
=== Palettes ===
The display system provides sixteen different palettes that can be used to color or shade tiles.
* Palettes 0-7 can be used for the two screens only;
* Palettes 8-15 can be used for both screens and sprites.
==== Mono ====
In ''mono'' modes, palettes are stored in I/O ports 0x20 through 0x3F. Each palette contains four three-bit entries, which are pointers into a global, four-bit shade lookup table:
<pre>
Palette Global shade LUT
1 ===========> 2 ==========================> 5
^ (0, 2, 4, 6) ^ (1, 3, 5, 7, 9, 11, 13, 15) ^
| | |
Palette index Value Displayed shade
</pre>
The shade value corresponds to the darkness of the pixel: shade 0 is the brightest, while shade 15 is the darkest.
==== Color ====
In ''color'' modes, palettes are stored as 16-bit words in memory addresses 0xFE00 through 0xFFFF, without additional lookup tables:
<pre>
Address
15 bit 8 7 bit 0
---- ---- ---- ----
1111 111p pppi iii.
| |||| |||
| |||+-+++-- Index in palette (0-15)
+--+++------- Palette number (0-15)
Data
15 bit 8 7 bit 0
---- ---- ---- ----
.... rrrr gggg bbbb
|||| |||| ||||
|||| |||| ++++- Blue (0-15)
|||| ++++------ Green (0-15)
++++------------ Red (0-15)
</pre>
In 2 bits per pixel color modes, palette entries 4 through 15 are not used.
==== Transparency ====
In two bit per pixel modes:
* Palettes 0-3 and 8-11 are ''opaque''. For these, index zero is treated as opaque.
* Palettes 4-7 and 12-15 are ''translucent''. For these, index zero is treated as transparent. This means that the color/shade value set to it is ignored, and only three distinct colors/shades can be used for tiles.
In four bit per pixel modes, all palettes are ''translucent''. Index zero is always treated as transparent, and fifteen different colors/shades can be used for tiles.
=== Background color ===
The background color is displayed if no ''opaque'' pixel from screens or sprites is drawn. This color is set in I/O port ''0x01'':
* In mono modes, it is set to an entry in the shade lookup table (0-7),
* In color modes, it is set to an entry in the color palette (0-255). Note that this allows you to use the first color (color zero) of any palette, which is normally ignored and assumed to be ''transparent''.
=== Screens ===
The WonderSwan can display up to two distinct 32x32 screens. These consist of 1024 two-byte cells:
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
vhbp pppt tttt tttt
|||| |||| |||| ||||
|||| |||+--++++-++++- Tile index (0-511)
|||+-+++------------- Palette (0-15)
||+------------------ Tile bank (0-1) - color only
|+------------------- Horizontal flip
+-------------------- Vertical flip
</pre>
=== Sprites ===
The WonderSwan can display up to 128 sprites at once. These are stored in a sprite table in RAM, which consists of up to 128 four-byte entries:
<pre>
(Byte 1) (Byte 0)
15 bit 8 7 bit 0
---- ---- ---- ----
vhPi pppt tttt tttt
|||| |||| |||| ||||
|||| |||+--++++-++++- Tile index (0-511) - only bank 0
|||| +++------------- Palette (0-7) - mapped to screen palettes 8-15
|||+----------------- Window location - 0 = inside, 1 = outside
||+------------------ Priority - 0 = behind Screen 2, 1 = in front of Screen 2
|+------------------- Horizontal flip
+-------------------- Vertical flip
(Byte 2)
7 bit 0
---- ----
yyyy yyyy
|||| ||||
++++-++++- Y coordinate
(Byte 3)
7 bit 0
---- ----
xxxx xxxx
|||| ||||
++++-++++- X coordinate
</pre>
For each row, the first 32 sprites for that row will be drawn - including sprites obscured by windows or outside of the visible range; only the Y coordinate determines this. The earlier among those sprites will be on top of the later ones.
=== Visibility priority ===
For display components, the visibility priority is as follows:
* Sprite 0, high priority
* Sprite 127, high priority
* Screen 2
* Sprite 0, low priority
* Sprite 127, low priority
* Screen 1
* Background color
=== Windows ===
Screen 2 and the sprite layer can optionally be restricted to a specific window.
In addition, one can control if a given element is rendered inside or outside that window. For Screen 2, this is controlled globally; for sprites, this is controlled per-sprite.
=== Icons ===
The WonderSwan features six LCD segment icons which are displayed to the right<sup>(color)</sup> or below<sup>(mono)</sup> the main display. These are, as follows:
* Aux 3 - large circle,
* Aux 2 - medium circle,
* Aux 1 - small circle,
* Horizontal orientation,
* Vertical orientation,
* Sleep.
== Interrupts ==
The display circuit generates two interrupts of its own:
* Display Interrupt Line Match - when <code>Display Current Line</code> == <code>Display Interrupt Line</code>, at the beginning of said line.
* Display Vertical Blank - when <code>Display Current Line</code> == <code>144</code>, at the beginning of said line.
It also provides a timing source for the two Horizontal and Vertical Blank [[Timers]], which provide their own respective interrupts.
== I/O ports ==
{{Anchor|Display Control}}
=== Display Control ($00) ===
<pre>
7 bit 0
---- ----
..ow Ws21
|| ||||
|| |||+- Enable Screen 1 layer
|| ||+-- Enable Screen 2 layer
|| |+--- Enable Sprite layer
|| +---- Enable Sprite window
|+------ Enable Screen 2 window
+------- Screen 2 window location:
0 = inside, 1 = outside
</pre>
{{Anchor|Display Background}}
=== Display Background Color ($01) ===
<pre>
(mono) (color)
7 bit 0 7 bit 0
---- ---- ---- ----
.... .sss pppp iiii
||| |||| ||||
+++- Value |||| ++++- Index in palette (0-15)
(0-7) ++++------ Color palette (0-15)
</pre>
{{Anchor|Display Current Line}}
=== Display Current Line ($02 read) ===
The current line being drawn by the display.
Note that lines are sent to the display with a one-line delay. This matters for color palette or shade LUT manipulation; changing these values when <code>current line == 1</code> will actually affect line 0.
{{Anchor|Display Interrupt Line}}
=== Display Interrupt Line ($03) ===
The line to emit an interrupt on.
{{Anchor|Sprite Table Address}}
=== Sprite Table Address ($04) ===
<pre>
7 bit 0
---- ----
..Aa aaaa
|| ||||
|+-++++- Address (bits 9-13)
+------- Address (bit 14) - color only
</pre>
{{Anchor|Sprite Table First}}
=== Sprite Table First ($05) ===
<pre>
7 bit 0
---- ----
.iii iiii
||| ||||
+++-++++- Index of first sprite entry to draw (0-127)
</pre>
{{Anchor|Sprite Table Count}}
=== Sprite Table Count ($06) ===
<pre>
7 bit 0
---- ----
cccc cccc
|||| ||||
++++-++++- Count of sprite entries to draw (1-128)
</pre>
{{Anchor|Screen Address}}
=== Screen Address ($07) ===
<pre>
7 bit 0
---- ----
2222 1111
|||| ||||
|||| |+++- Screen 1 address (bits 11-13)
|||| +---- Screen 1 address (bit 14) - color only
|+++------ Screen 2 address (bits 11-13)
+--------- Screen 2 address (bit 14) - color only
</pre>
{{Anchor|Screen 2 Window}}
=== Screen 2 Window Left ($08) ===
=== Screen 2 Window Top ($09) ===
=== Screen 2 Window Right ($0A) ===
=== Screen 2 Window Bottom ($0B) ===
{{Anchor|Sprite Window}}
=== Sprite Window Left ($0C) ===
=== Sprite Window Top ($0D) ===
=== Sprite Window Right ($0E) ===
=== Sprite Window Bottom ($0F) ===
{{Anchor|Screen Scroll}}
=== Screen 1 Scroll X ($10) ===
=== Screen 1 Scroll Y ($11) ===
=== Screen 2 Scroll X ($12) ===
=== Screen 2 Scroll Y ($13) ===
{{Anchor|LCD Control}}
=== LCD Control ($14) ===
<pre>
7 bit 0
---- ----
.... ..Ce
||
|+- LCD Enable: 0 = sleep, 1 = enabled
+-- Contrast (WSC): 0 = low, 1 = high
</pre>
{{Anchor|LCD Icon Control}}
=== LCD Icon Control ($15) ===
<pre>
7 bit 0
---- ----
..32 1hvs
|| ||||
|| |||+- Sleep
|| ||+-- Vertical orientation
|| |+--- Horizontal orientation
|| +---- Aux 1
|+------ Aux 2
+------- Aux 3
</pre>
{{Anchor|LCD Mono Shade LUT}}
=== LCD Mono Shade LUT ($1C-$1F) ===
<pre>
$1C $1D $1E $1F
7 bit 0 7 bit 0 7 bit 0 7 bit 0
---- ---- ---- ---- ---- ---- ---- ----
1111 0000 3333 2222 5555 4444 7777 6666
</pre>
{{Anchor|LCD Mono Palette}}
=== LCD Mono Palette 0..15 ($20, $21 .. $3E, $3F) ===
The monochrome palette is laid out as sixteen words:
<pre>
N+1 N
15 bit 8 7 bit 0
---- ---- ---- ----
.333 .222 .111 .000
||| ||| ||| |||
||| ||| ||| +++- Shade LUT index for color 0
||| ||| +++------ Shade LUT index for color 1
||| +++------------ Shade LUT index for color 2
+++----------------- Shade LUT index for color 3
</pre>
== Internal I/O ports ==
These I/O ports are said to be internal and not intended for use by commercial games.
{{Anchor|LCD Final Line}}
=== LCD Final Line ($16) ===
The final line preceding line counter restart and the beginning of active display. By default, this is set to 158, which equals 159 total lines per frame.
It is said setting this register to an odd value on SwanCrystal has an adverse effect to the LCD panel<ref>[http://daifukkat.su/docs/wsman/#REG_LCD_VTOTAL REG_LCD_VTOTAL - WSMan]</ref>, but the exact mechanism is unknown.
{{Anchor|LCD Back Porch Line}}
=== LCD Back Porch Line ($17, WSC only) ===
This port is available on the WonderSwan Color only - not the SwanCrystal!
The final line preceding the vertical back porch; by default, this should be set to 155.
The vertical back porch of the LCD is assumed to be 4 lines by some hardware, including IPS mods, as well as the official "TV Swan" capture device. Given that the first visible line is sent to the LCD on the display's line 1, this should be generally set to <code>LCD Final Line - 3</code>.
Conversely, it is said moving this value closer to vertical blank improves LCD visibility<ref>[http://daifukkat.su/docs/wsman/#REG_LCD_VSYNC REG_LCD_VSYNC - WSMan]</ref>, but the exact mechanism is unknown.
{{Anchor|LCD Status}}
=== LCD Status ($1A) ===
<pre>
7 bit 0
---- ----
...v vv.s
| || |
| || +- LCD sleep: 0 = no, 1 = sleep
| ||
| || Volume segments:
| |+--- Volume B (medium, high)
| +---- Volume A (low, high)
+------ Speaker
</pre>
=== TFT LCD Configuration ($70, $71, $72, $73, $74, $75, $76, $77 SwanCrystal only) ===
These eight bytes are read from internal EEPROM and configure unknown aspects of the console's TFT LCD panel.
They are only writable while the [[Boot ROM]] is unlocked - locking has the side effect of making them read-only.
== Notes ==
<references />
c70a54cfc6327215de923f43be020fdd93d15ebd
306
305
2024-07-12T19:47:01Z
Asie
351
/* Screens */
wikitext
text/x-wiki
The WonderSwan's display functionality generally consists of:
* a 224x144 display clocked at ~75.47 Hz by default, capable of displaying:
** up to sixteen distinct shades of gray
** 12-bit RGB444 color<sup>(color)</sup>
* two 32x32 background layers ("screens"), capable of displaying up to 512 (1024<sup>(color)</sup>) distinct tiles,
* a sprite layer, capable of displaying up to 128 8x8 sprites (up to 32 per line),
* six LCD icons to the bottom or right of the display, usable as additional indicators.
== Components ==
=== Tiles ===
The WonderSwan can display up to 512 distinct tiles at a time, with two bits of palette index information for every pixel.
The WonderSwan Color expands this to 1024 distinct tiles for background (with 512 remaining the limit for sprites), while also introducing modes with four bits of palette index information for every pixel.
==== 2 bits per pixel, planar ====
The tiles are stored in an interleaved planar format, with two bits total for every pixel. Odd bytes store the first plane (bit 0 of each pixel), while even bytes store the second plane (bit 1 of each pixel).
<pre>
tile data (16 bytes)
01 7C 01 FC 00 C0 18 D8 18 D8 00 C0 00 00 C0 00
||
\/
plane 0 plane 1
7 bit 0 7 bit 0 full tile
---- ---- ---- ----
.... ...1 = 01 .222 22.. = 7C .22222.1
.... ...1 = 01 2222 22.. = FC 222222.1
.... .... = 00 22.. .... = C0 22......
...1 1... = 18 22.2 2... = D8 --\ 22.33...
...1 1... = 18 22.2 2... = D8 --/ 22.33...
.... .... = 00 22.. .... = C0 22......
.... .... = 00 .... .... = 00 ........
11.. .... = C0 .... .... = 00 11......
</pre>
This matches the format used by the Game Boy.
==== 4 bits per pixel, planar ====
This mode is stored in a manner similar to the 2 bits per pixel mode, but with an additional two planes for bit 2 and bit 3 of each pixel's palette index, expanding the tile data to 32 bytes.
<pre>
tile data (32 bytes)
54 32 01 00 54 32 F1 00 54 32 01 F0 54 32 F1 F0 04 02 01 00 F8 04 02 01 00 F8 04 02 00 00 F8 04
||
\/
plane 0 plane 1 plane 2 plane 3
7 bit 0 7 bit 0 7 bit 0 7 bit 0 full tile
---- ---- ---- ---- ---- ---- ---- ----
.1.1 .1.. = 54 ..22 ..2. = 32 .... ...4 = 01 .... .... = 00 .123.124
.1.1 .1.. = 54 ..22 ..2. = 32 4444 ...4 = F1 .... .... = 00 4567.124
.1.1 .1.. = 54 ..22 ..2. = 32 .... ...4 = 01 8888 .... = F0 89AB.124
.1.1 .1.. = 54 ..22 ..2. = 32 4444 ...4 = F1 8888 .... = F0 --\ CDEF.124
.... .1.. = 04 .... ..2. = 02 .... ...4 = 01 .... .... = 00 --/ .....124
1111 1... = F8 .... .2.. = 04 .... ..4. = 02 .... ...8 = 01 11111248
.... .... = 00 2222 2... = F8 .... .4.. = 04 .... ..8. = 02 2222248.
.... .... = 00 .... .... = 00 4444 4... = F8 .... .8.. = 04 444448..
</pre>
This format matches the one used by the Sega Master System and Game Gear family of consoles.
==== 4 bits per pixel, packed ====
Unlike the previous two formats, in the packed format each byte stores the complete palette index of two pixels - the high four bits store the left pixel, while the low four bits store the right pixel. Four such bytes make up a row of eight pixels from left to right.
<pre>
tile data (32 bytes)
01 23 01 24 45 67 01 24 89 AB 01 24 CD EF 01 24 00 00 01 24 11 11 12 48 22 22 24 80 44 44 48 00
||
\/
byte 0 1 2 3
bits 7-4 3-0 7-4 3-0 7-4 3-0 7-4 3-0
pixel 0 1 2 3 4 5 6 7 full tile
--- --- --- --- --- --- --- ---
. 1 = 01 2 3 = 23 . 1 = 01 2 4 = 24 .123.124 = 01 23 01 24
4 5 = 45 6 7 = 67 . 1 = 01 2 4 = 24 4567.124 = 45 67 01 24
8 9 = 89 A B = AB . 1 = 01 2 4 = 24 89AB.124 = 89 AB 01 24
C D = CD E F = EF . 1 = 01 2 4 = 24 --\ CDEF.124 = CD EF 01 24
. . = 00 . . = 00 . 1 = 01 2 4 = 24 --/ .....124 = 00 00 01 24
1 1 = 11 1 1 = 11 1 2 = 12 4 8 = 48 11111248 = 11 11 12 48
2 2 = 22 2 2 = 22 2 4 = 24 8 . = 80 2222248. = 22 22 24 80
4 4 = 44 4 4 = 44 4 8 = 48 . . = 00 444448.. = 44 44 48 00
</pre>
This format matches the one used by the Mega Drive console.
=== Palettes ===
The display system provides sixteen different palettes that can be used to color or shade tiles.
* Palettes 0-7 can be used for the two screens only;
* Palettes 8-15 can be used for both screens and sprites.
==== Mono ====
In ''mono'' modes, palettes are stored in I/O ports 0x20 through 0x3F. Each palette contains four three-bit entries, which are pointers into a global, four-bit shade lookup table:
<pre>
Palette Global shade LUT
1 ===========> 2 ==========================> 5
^ (0, 2, 4, 6) ^ (1, 3, 5, 7, 9, 11, 13, 15) ^
| | |
Palette index Value Displayed shade
</pre>
The shade value corresponds to the darkness of the pixel: shade 0 is the brightest, while shade 15 is the darkest.
==== Color ====
In ''color'' modes, palettes are stored as 16-bit words in memory addresses 0xFE00 through 0xFFFF, without additional lookup tables:
<pre>
Address
15 bit 8 7 bit 0
---- ---- ---- ----
1111 111p pppi iii.
| |||| |||
| |||+-+++-- Index in palette (0-15)
+--+++------- Palette number (0-15)
Data
15 bit 8 7 bit 0
---- ---- ---- ----
.... rrrr gggg bbbb
|||| |||| ||||
|||| |||| ++++- Blue (0-15)
|||| ++++------ Green (0-15)
++++------------ Red (0-15)
</pre>
In 2 bits per pixel color modes, palette entries 4 through 15 are not used.
==== Transparency ====
In two bit per pixel modes:
* Palettes 0-3 and 8-11 are ''opaque''. For these, index zero is treated as opaque.
* Palettes 4-7 and 12-15 are ''translucent''. For these, index zero is treated as transparent. This means that the color/shade value set to it is ignored, and only three distinct colors/shades can be used for tiles.
In four bit per pixel modes, all palettes are ''translucent''. Index zero is always treated as transparent, and fifteen different colors/shades can be used for tiles.
=== Background color ===
The background color is displayed if no ''opaque'' pixel from screens or sprites is drawn. This color is set in I/O port ''0x01'':
* In mono modes, it is set to an entry in the shade lookup table (0-7),
* In color modes, it is set to an entry in the color palette (0-255). Note that this allows you to use the first color (color zero) of any palette, which is normally ignored and assumed to be ''transparent''.
=== Screens ===
A screen is a layout of tiles. Each cell in a screen controls one 8x8 tile.
The display system can show two distinct screens simultaneously. It also supports hardware flipping of tiles, both horizontally and vertically.
The size of each screen is fixed at 32x32 cells or 256x256 pixels, while each cell is stored as a two-byte word:
<pre>
Address
15 bit 8 7 bit 0
---- ---- ---- ----
0bbb byyy yyxx xxx.
||| |||| |||| |||
||| |||| ||++-+++-- X coordinate (0-31)
||| |+++--++-------- Y coordinate (0-31)
+++-+--------------- Base address (from I/O port)
Data
15 bit 8 7 bit 0
---- ---- ---- ----
vhbp pppt tttt tttt
|||| |||| |||| ||||
|||| |||+--++++-++++- Tile index (0-511)
|||+-+++------------- Palette (0-15)
||+------------------ Tile bank (0-1) - color only
|+------------------- Horizontal flip
+-------------------- Vertical flip
</pre>
=== Sprites ===
The WonderSwan can display up to 128 sprites at once. These are stored in a sprite table in RAM, which consists of up to 128 four-byte entries:
<pre>
(Byte 1) (Byte 0)
15 bit 8 7 bit 0
---- ---- ---- ----
vhPi pppt tttt tttt
|||| |||| |||| ||||
|||| |||+--++++-++++- Tile index (0-511) - only bank 0
|||| +++------------- Palette (0-7) - mapped to screen palettes 8-15
|||+----------------- Window location - 0 = inside, 1 = outside
||+------------------ Priority - 0 = behind Screen 2, 1 = in front of Screen 2
|+------------------- Horizontal flip
+-------------------- Vertical flip
(Byte 2)
7 bit 0
---- ----
yyyy yyyy
|||| ||||
++++-++++- Y coordinate
(Byte 3)
7 bit 0
---- ----
xxxx xxxx
|||| ||||
++++-++++- X coordinate
</pre>
For each row, the first 32 sprites for that row will be drawn - including sprites obscured by windows or outside of the visible range; only the Y coordinate determines this. The earlier among those sprites will be on top of the later ones.
=== Visibility priority ===
For display components, the visibility priority is as follows:
* Sprite 0, high priority
* Sprite 127, high priority
* Screen 2
* Sprite 0, low priority
* Sprite 127, low priority
* Screen 1
* Background color
=== Windows ===
Screen 2 and the sprite layer can optionally be restricted to a specific window.
In addition, one can control if a given element is rendered inside or outside that window. For Screen 2, this is controlled globally; for sprites, this is controlled per-sprite.
=== Icons ===
The WonderSwan features six LCD segment icons which are displayed to the right<sup>(color)</sup> or below<sup>(mono)</sup> the main display. These are, as follows:
* Aux 3 - large circle,
* Aux 2 - medium circle,
* Aux 1 - small circle,
* Horizontal orientation,
* Vertical orientation,
* Sleep.
== Interrupts ==
The display circuit generates two interrupts of its own:
* Display Interrupt Line Match - when <code>Display Current Line</code> == <code>Display Interrupt Line</code>, at the beginning of said line.
* Display Vertical Blank - when <code>Display Current Line</code> == <code>144</code>, at the beginning of said line.
It also provides a timing source for the two Horizontal and Vertical Blank [[Timers]], which provide their own respective interrupts.
== I/O ports ==
{{Anchor|Display Control}}
=== Display Control ($00) ===
<pre>
7 bit 0
---- ----
..ow Ws21
|| ||||
|| |||+- Enable Screen 1 layer
|| ||+-- Enable Screen 2 layer
|| |+--- Enable Sprite layer
|| +---- Enable Sprite window
|+------ Enable Screen 2 window
+------- Screen 2 window location:
0 = inside, 1 = outside
</pre>
{{Anchor|Display Background}}
=== Display Background Color ($01) ===
<pre>
(mono) (color)
7 bit 0 7 bit 0
---- ---- ---- ----
.... .sss pppp iiii
||| |||| ||||
+++- Value |||| ++++- Index in palette (0-15)
(0-7) ++++------ Color palette (0-15)
</pre>
{{Anchor|Display Current Line}}
=== Display Current Line ($02 read) ===
The current line being drawn by the display.
Note that lines are sent to the display with a one-line delay. This matters for color palette or shade LUT manipulation; changing these values when <code>current line == 1</code> will actually affect line 0.
{{Anchor|Display Interrupt Line}}
=== Display Interrupt Line ($03) ===
The line to emit an interrupt on.
{{Anchor|Sprite Table Address}}
=== Sprite Table Address ($04) ===
<pre>
7 bit 0
---- ----
..Aa aaaa
|| ||||
|+-++++- Address (bits 9-13)
+------- Address (bit 14) - color only
</pre>
{{Anchor|Sprite Table First}}
=== Sprite Table First ($05) ===
<pre>
7 bit 0
---- ----
.iii iiii
||| ||||
+++-++++- Index of first sprite entry to draw (0-127)
</pre>
{{Anchor|Sprite Table Count}}
=== Sprite Table Count ($06) ===
<pre>
7 bit 0
---- ----
cccc cccc
|||| ||||
++++-++++- Count of sprite entries to draw (1-128)
</pre>
{{Anchor|Screen Address}}
=== Screen Address ($07) ===
<pre>
7 bit 0
---- ----
2222 1111
|||| ||||
|||| |+++- Screen 1 address (bits 11-13)
|||| +---- Screen 1 address (bit 14) - color only
|+++------ Screen 2 address (bits 11-13)
+--------- Screen 2 address (bit 14) - color only
</pre>
{{Anchor|Screen 2 Window}}
=== Screen 2 Window Left ($08) ===
=== Screen 2 Window Top ($09) ===
=== Screen 2 Window Right ($0A) ===
=== Screen 2 Window Bottom ($0B) ===
{{Anchor|Sprite Window}}
=== Sprite Window Left ($0C) ===
=== Sprite Window Top ($0D) ===
=== Sprite Window Right ($0E) ===
=== Sprite Window Bottom ($0F) ===
{{Anchor|Screen Scroll}}
=== Screen 1 Scroll X ($10) ===
=== Screen 1 Scroll Y ($11) ===
=== Screen 2 Scroll X ($12) ===
=== Screen 2 Scroll Y ($13) ===
{{Anchor|LCD Control}}
=== LCD Control ($14) ===
<pre>
7 bit 0
---- ----
.... ..Ce
||
|+- LCD Enable: 0 = sleep, 1 = enabled
+-- Contrast (WSC): 0 = low, 1 = high
</pre>
{{Anchor|LCD Icon Control}}
=== LCD Icon Control ($15) ===
<pre>
7 bit 0
---- ----
..32 1hvs
|| ||||
|| |||+- Sleep
|| ||+-- Vertical orientation
|| |+--- Horizontal orientation
|| +---- Aux 1
|+------ Aux 2
+------- Aux 3
</pre>
{{Anchor|LCD Mono Shade LUT}}
=== LCD Mono Shade LUT ($1C-$1F) ===
<pre>
$1C $1D $1E $1F
7 bit 0 7 bit 0 7 bit 0 7 bit 0
---- ---- ---- ---- ---- ---- ---- ----
1111 0000 3333 2222 5555 4444 7777 6666
</pre>
{{Anchor|LCD Mono Palette}}
=== LCD Mono Palette 0..15 ($20, $21 .. $3E, $3F) ===
The monochrome palette is laid out as sixteen words:
<pre>
N+1 N
15 bit 8 7 bit 0
---- ---- ---- ----
.333 .222 .111 .000
||| ||| ||| |||
||| ||| ||| +++- Shade LUT index for color 0
||| ||| +++------ Shade LUT index for color 1
||| +++------------ Shade LUT index for color 2
+++----------------- Shade LUT index for color 3
</pre>
== Internal I/O ports ==
These I/O ports are said to be internal and not intended for use by commercial games.
{{Anchor|LCD Final Line}}
=== LCD Final Line ($16) ===
The final line preceding line counter restart and the beginning of active display. By default, this is set to 158, which equals 159 total lines per frame.
It is said setting this register to an odd value on SwanCrystal has an adverse effect to the LCD panel<ref>[http://daifukkat.su/docs/wsman/#REG_LCD_VTOTAL REG_LCD_VTOTAL - WSMan]</ref>, but the exact mechanism is unknown.
{{Anchor|LCD Back Porch Line}}
=== LCD Back Porch Line ($17, WSC only) ===
This port is available on the WonderSwan Color only - not the SwanCrystal!
The final line preceding the vertical back porch; by default, this should be set to 155.
The vertical back porch of the LCD is assumed to be 4 lines by some hardware, including IPS mods, as well as the official "TV Swan" capture device. Given that the first visible line is sent to the LCD on the display's line 1, this should be generally set to <code>LCD Final Line - 3</code>.
Conversely, it is said moving this value closer to vertical blank improves LCD visibility<ref>[http://daifukkat.su/docs/wsman/#REG_LCD_VSYNC REG_LCD_VSYNC - WSMan]</ref>, but the exact mechanism is unknown.
{{Anchor|LCD Status}}
=== LCD Status ($1A) ===
<pre>
7 bit 0
---- ----
...v vv.s
| || |
| || +- LCD sleep: 0 = no, 1 = sleep
| ||
| || Volume segments:
| |+--- Volume B (medium, high)
| +---- Volume A (low, high)
+------ Speaker
</pre>
=== TFT LCD Configuration ($70, $71, $72, $73, $74, $75, $76, $77 SwanCrystal only) ===
These eight bytes are read from internal EEPROM and configure unknown aspects of the console's TFT LCD panel.
They are only writable while the [[Boot ROM]] is unlocked - locking has the side effect of making them read-only.
== Notes ==
<references />
982b3960b58e1e64d8882404f7335c487af5b79f
307
306
2024-07-12T19:47:38Z
Asie
351
/* Screens */
wikitext
text/x-wiki
The WonderSwan's display functionality generally consists of:
* a 224x144 display clocked at ~75.47 Hz by default, capable of displaying:
** up to sixteen distinct shades of gray
** 12-bit RGB444 color<sup>(color)</sup>
* two 32x32 background layers ("screens"), capable of displaying up to 512 (1024<sup>(color)</sup>) distinct tiles,
* a sprite layer, capable of displaying up to 128 8x8 sprites (up to 32 per line),
* six LCD icons to the bottom or right of the display, usable as additional indicators.
== Components ==
=== Tiles ===
The WonderSwan can display up to 512 distinct tiles at a time, with two bits of palette index information for every pixel.
The WonderSwan Color expands this to 1024 distinct tiles for background (with 512 remaining the limit for sprites), while also introducing modes with four bits of palette index information for every pixel.
==== 2 bits per pixel, planar ====
The tiles are stored in an interleaved planar format, with two bits total for every pixel. Odd bytes store the first plane (bit 0 of each pixel), while even bytes store the second plane (bit 1 of each pixel).
<pre>
tile data (16 bytes)
01 7C 01 FC 00 C0 18 D8 18 D8 00 C0 00 00 C0 00
||
\/
plane 0 plane 1
7 bit 0 7 bit 0 full tile
---- ---- ---- ----
.... ...1 = 01 .222 22.. = 7C .22222.1
.... ...1 = 01 2222 22.. = FC 222222.1
.... .... = 00 22.. .... = C0 22......
...1 1... = 18 22.2 2... = D8 --\ 22.33...
...1 1... = 18 22.2 2... = D8 --/ 22.33...
.... .... = 00 22.. .... = C0 22......
.... .... = 00 .... .... = 00 ........
11.. .... = C0 .... .... = 00 11......
</pre>
This matches the format used by the Game Boy.
==== 4 bits per pixel, planar ====
This mode is stored in a manner similar to the 2 bits per pixel mode, but with an additional two planes for bit 2 and bit 3 of each pixel's palette index, expanding the tile data to 32 bytes.
<pre>
tile data (32 bytes)
54 32 01 00 54 32 F1 00 54 32 01 F0 54 32 F1 F0 04 02 01 00 F8 04 02 01 00 F8 04 02 00 00 F8 04
||
\/
plane 0 plane 1 plane 2 plane 3
7 bit 0 7 bit 0 7 bit 0 7 bit 0 full tile
---- ---- ---- ---- ---- ---- ---- ----
.1.1 .1.. = 54 ..22 ..2. = 32 .... ...4 = 01 .... .... = 00 .123.124
.1.1 .1.. = 54 ..22 ..2. = 32 4444 ...4 = F1 .... .... = 00 4567.124
.1.1 .1.. = 54 ..22 ..2. = 32 .... ...4 = 01 8888 .... = F0 89AB.124
.1.1 .1.. = 54 ..22 ..2. = 32 4444 ...4 = F1 8888 .... = F0 --\ CDEF.124
.... .1.. = 04 .... ..2. = 02 .... ...4 = 01 .... .... = 00 --/ .....124
1111 1... = F8 .... .2.. = 04 .... ..4. = 02 .... ...8 = 01 11111248
.... .... = 00 2222 2... = F8 .... .4.. = 04 .... ..8. = 02 2222248.
.... .... = 00 .... .... = 00 4444 4... = F8 .... .8.. = 04 444448..
</pre>
This format matches the one used by the Sega Master System and Game Gear family of consoles.
==== 4 bits per pixel, packed ====
Unlike the previous two formats, in the packed format each byte stores the complete palette index of two pixels - the high four bits store the left pixel, while the low four bits store the right pixel. Four such bytes make up a row of eight pixels from left to right.
<pre>
tile data (32 bytes)
01 23 01 24 45 67 01 24 89 AB 01 24 CD EF 01 24 00 00 01 24 11 11 12 48 22 22 24 80 44 44 48 00
||
\/
byte 0 1 2 3
bits 7-4 3-0 7-4 3-0 7-4 3-0 7-4 3-0
pixel 0 1 2 3 4 5 6 7 full tile
--- --- --- --- --- --- --- ---
. 1 = 01 2 3 = 23 . 1 = 01 2 4 = 24 .123.124 = 01 23 01 24
4 5 = 45 6 7 = 67 . 1 = 01 2 4 = 24 4567.124 = 45 67 01 24
8 9 = 89 A B = AB . 1 = 01 2 4 = 24 89AB.124 = 89 AB 01 24
C D = CD E F = EF . 1 = 01 2 4 = 24 --\ CDEF.124 = CD EF 01 24
. . = 00 . . = 00 . 1 = 01 2 4 = 24 --/ .....124 = 00 00 01 24
1 1 = 11 1 1 = 11 1 2 = 12 4 8 = 48 11111248 = 11 11 12 48
2 2 = 22 2 2 = 22 2 4 = 24 8 . = 80 2222248. = 22 22 24 80
4 4 = 44 4 4 = 44 4 8 = 48 . . = 00 444448.. = 44 44 48 00
</pre>
This format matches the one used by the Mega Drive console.
=== Palettes ===
The display system provides sixteen different palettes that can be used to color or shade tiles.
* Palettes 0-7 can be used for the two screens only;
* Palettes 8-15 can be used for both screens and sprites.
==== Mono ====
In ''mono'' modes, palettes are stored in I/O ports 0x20 through 0x3F. Each palette contains four three-bit entries, which are pointers into a global, four-bit shade lookup table:
<pre>
Palette Global shade LUT
1 ===========> 2 ==========================> 5
^ (0, 2, 4, 6) ^ (1, 3, 5, 7, 9, 11, 13, 15) ^
| | |
Palette index Value Displayed shade
</pre>
The shade value corresponds to the darkness of the pixel: shade 0 is the brightest, while shade 15 is the darkest.
==== Color ====
In ''color'' modes, palettes are stored as 16-bit words in memory addresses 0xFE00 through 0xFFFF, without additional lookup tables:
<pre>
Address
15 bit 8 7 bit 0
---- ---- ---- ----
1111 111p pppi iii.
| |||| |||
| |||+-+++-- Index in palette (0-15)
+--+++------- Palette number (0-15)
Data
15 bit 8 7 bit 0
---- ---- ---- ----
.... rrrr gggg bbbb
|||| |||| ||||
|||| |||| ++++- Blue (0-15)
|||| ++++------ Green (0-15)
++++------------ Red (0-15)
</pre>
In 2 bits per pixel color modes, palette entries 4 through 15 are not used.
==== Transparency ====
In two bit per pixel modes:
* Palettes 0-3 and 8-11 are ''opaque''. For these, index zero is treated as opaque.
* Palettes 4-7 and 12-15 are ''translucent''. For these, index zero is treated as transparent. This means that the color/shade value set to it is ignored, and only three distinct colors/shades can be used for tiles.
In four bit per pixel modes, all palettes are ''translucent''. Index zero is always treated as transparent, and fifteen different colors/shades can be used for tiles.
=== Background color ===
The background color is displayed if no ''opaque'' pixel from screens or sprites is drawn. This color is set in I/O port ''0x01'':
* In mono modes, it is set to an entry in the shade lookup table (0-7),
* In color modes, it is set to an entry in the color palette (0-255). Note that this allows you to use the first color (color zero) of any palette, which is normally ignored and assumed to be ''transparent''.
=== Screens ===
A screen is a layout of tiles. Each cell in a screen controls one 8x8 tile.
The display system can show two distinct screens simultaneously. It also supports hardware flipping of tiles, both horizontally and vertically.
The size of each screen is fixed at 32x32 cells or 256x256 pixels, while each cell is stored as a two-byte word:
<pre>
Address
15 bit 8 7 bit 0
---- ---- ---- ----
0bbb byyy yyxx xxx.
||| |||| |||| |||
||| |||| ||++-+++-- X coordinate (0-31)
||| |+++--++-------- Y coordinate (0-31)
+++-+--------------- Base address (from I/O port)
Data
15 bit 8 7 bit 0
---- ---- ---- ----
vhbp pppt tttt tttt
|||| |||| |||| ||||
|||| |||+--++++-++++- Tile index (0-511)
|||+-+++------------- Palette (0-15)
||+------------------ Tile bank (0-1) - color only
|+------------------- Horizontal flip
+-------------------- Vertical flip
</pre>
In ''color'' modes, the tile bank selects between tiles 0-511 and 512-1023.
=== Sprites ===
The WonderSwan can display up to 128 sprites at once. These are stored in a sprite table in RAM, which consists of up to 128 four-byte entries:
<pre>
(Byte 1) (Byte 0)
15 bit 8 7 bit 0
---- ---- ---- ----
vhPi pppt tttt tttt
|||| |||| |||| ||||
|||| |||+--++++-++++- Tile index (0-511) - only bank 0
|||| +++------------- Palette (0-7) - mapped to screen palettes 8-15
|||+----------------- Window location - 0 = inside, 1 = outside
||+------------------ Priority - 0 = behind Screen 2, 1 = in front of Screen 2
|+------------------- Horizontal flip
+-------------------- Vertical flip
(Byte 2)
7 bit 0
---- ----
yyyy yyyy
|||| ||||
++++-++++- Y coordinate
(Byte 3)
7 bit 0
---- ----
xxxx xxxx
|||| ||||
++++-++++- X coordinate
</pre>
For each row, the first 32 sprites for that row will be drawn - including sprites obscured by windows or outside of the visible range; only the Y coordinate determines this. The earlier among those sprites will be on top of the later ones.
=== Visibility priority ===
For display components, the visibility priority is as follows:
* Sprite 0, high priority
* Sprite 127, high priority
* Screen 2
* Sprite 0, low priority
* Sprite 127, low priority
* Screen 1
* Background color
=== Windows ===
Screen 2 and the sprite layer can optionally be restricted to a specific window.
In addition, one can control if a given element is rendered inside or outside that window. For Screen 2, this is controlled globally; for sprites, this is controlled per-sprite.
=== Icons ===
The WonderSwan features six LCD segment icons which are displayed to the right<sup>(color)</sup> or below<sup>(mono)</sup> the main display. These are, as follows:
* Aux 3 - large circle,
* Aux 2 - medium circle,
* Aux 1 - small circle,
* Horizontal orientation,
* Vertical orientation,
* Sleep.
== Interrupts ==
The display circuit generates two interrupts of its own:
* Display Interrupt Line Match - when <code>Display Current Line</code> == <code>Display Interrupt Line</code>, at the beginning of said line.
* Display Vertical Blank - when <code>Display Current Line</code> == <code>144</code>, at the beginning of said line.
It also provides a timing source for the two Horizontal and Vertical Blank [[Timers]], which provide their own respective interrupts.
== I/O ports ==
{{Anchor|Display Control}}
=== Display Control ($00) ===
<pre>
7 bit 0
---- ----
..ow Ws21
|| ||||
|| |||+- Enable Screen 1 layer
|| ||+-- Enable Screen 2 layer
|| |+--- Enable Sprite layer
|| +---- Enable Sprite window
|+------ Enable Screen 2 window
+------- Screen 2 window location:
0 = inside, 1 = outside
</pre>
{{Anchor|Display Background}}
=== Display Background Color ($01) ===
<pre>
(mono) (color)
7 bit 0 7 bit 0
---- ---- ---- ----
.... .sss pppp iiii
||| |||| ||||
+++- Value |||| ++++- Index in palette (0-15)
(0-7) ++++------ Color palette (0-15)
</pre>
{{Anchor|Display Current Line}}
=== Display Current Line ($02 read) ===
The current line being drawn by the display.
Note that lines are sent to the display with a one-line delay. This matters for color palette or shade LUT manipulation; changing these values when <code>current line == 1</code> will actually affect line 0.
{{Anchor|Display Interrupt Line}}
=== Display Interrupt Line ($03) ===
The line to emit an interrupt on.
{{Anchor|Sprite Table Address}}
=== Sprite Table Address ($04) ===
<pre>
7 bit 0
---- ----
..Aa aaaa
|| ||||
|+-++++- Address (bits 9-13)
+------- Address (bit 14) - color only
</pre>
{{Anchor|Sprite Table First}}
=== Sprite Table First ($05) ===
<pre>
7 bit 0
---- ----
.iii iiii
||| ||||
+++-++++- Index of first sprite entry to draw (0-127)
</pre>
{{Anchor|Sprite Table Count}}
=== Sprite Table Count ($06) ===
<pre>
7 bit 0
---- ----
cccc cccc
|||| ||||
++++-++++- Count of sprite entries to draw (1-128)
</pre>
{{Anchor|Screen Address}}
=== Screen Address ($07) ===
<pre>
7 bit 0
---- ----
2222 1111
|||| ||||
|||| |+++- Screen 1 address (bits 11-13)
|||| +---- Screen 1 address (bit 14) - color only
|+++------ Screen 2 address (bits 11-13)
+--------- Screen 2 address (bit 14) - color only
</pre>
{{Anchor|Screen 2 Window}}
=== Screen 2 Window Left ($08) ===
=== Screen 2 Window Top ($09) ===
=== Screen 2 Window Right ($0A) ===
=== Screen 2 Window Bottom ($0B) ===
{{Anchor|Sprite Window}}
=== Sprite Window Left ($0C) ===
=== Sprite Window Top ($0D) ===
=== Sprite Window Right ($0E) ===
=== Sprite Window Bottom ($0F) ===
{{Anchor|Screen Scroll}}
=== Screen 1 Scroll X ($10) ===
=== Screen 1 Scroll Y ($11) ===
=== Screen 2 Scroll X ($12) ===
=== Screen 2 Scroll Y ($13) ===
{{Anchor|LCD Control}}
=== LCD Control ($14) ===
<pre>
7 bit 0
---- ----
.... ..Ce
||
|+- LCD Enable: 0 = sleep, 1 = enabled
+-- Contrast (WSC): 0 = low, 1 = high
</pre>
{{Anchor|LCD Icon Control}}
=== LCD Icon Control ($15) ===
<pre>
7 bit 0
---- ----
..32 1hvs
|| ||||
|| |||+- Sleep
|| ||+-- Vertical orientation
|| |+--- Horizontal orientation
|| +---- Aux 1
|+------ Aux 2
+------- Aux 3
</pre>
{{Anchor|LCD Mono Shade LUT}}
=== LCD Mono Shade LUT ($1C-$1F) ===
<pre>
$1C $1D $1E $1F
7 bit 0 7 bit 0 7 bit 0 7 bit 0
---- ---- ---- ---- ---- ---- ---- ----
1111 0000 3333 2222 5555 4444 7777 6666
</pre>
{{Anchor|LCD Mono Palette}}
=== LCD Mono Palette 0..15 ($20, $21 .. $3E, $3F) ===
The monochrome palette is laid out as sixteen words:
<pre>
N+1 N
15 bit 8 7 bit 0
---- ---- ---- ----
.333 .222 .111 .000
||| ||| ||| |||
||| ||| ||| +++- Shade LUT index for color 0
||| ||| +++------ Shade LUT index for color 1
||| +++------------ Shade LUT index for color 2
+++----------------- Shade LUT index for color 3
</pre>
== Internal I/O ports ==
These I/O ports are said to be internal and not intended for use by commercial games.
{{Anchor|LCD Final Line}}
=== LCD Final Line ($16) ===
The final line preceding line counter restart and the beginning of active display. By default, this is set to 158, which equals 159 total lines per frame.
It is said setting this register to an odd value on SwanCrystal has an adverse effect to the LCD panel<ref>[http://daifukkat.su/docs/wsman/#REG_LCD_VTOTAL REG_LCD_VTOTAL - WSMan]</ref>, but the exact mechanism is unknown.
{{Anchor|LCD Back Porch Line}}
=== LCD Back Porch Line ($17, WSC only) ===
This port is available on the WonderSwan Color only - not the SwanCrystal!
The final line preceding the vertical back porch; by default, this should be set to 155.
The vertical back porch of the LCD is assumed to be 4 lines by some hardware, including IPS mods, as well as the official "TV Swan" capture device. Given that the first visible line is sent to the LCD on the display's line 1, this should be generally set to <code>LCD Final Line - 3</code>.
Conversely, it is said moving this value closer to vertical blank improves LCD visibility<ref>[http://daifukkat.su/docs/wsman/#REG_LCD_VSYNC REG_LCD_VSYNC - WSMan]</ref>, but the exact mechanism is unknown.
{{Anchor|LCD Status}}
=== LCD Status ($1A) ===
<pre>
7 bit 0
---- ----
...v vv.s
| || |
| || +- LCD sleep: 0 = no, 1 = sleep
| ||
| || Volume segments:
| |+--- Volume B (medium, high)
| +---- Volume A (low, high)
+------ Speaker
</pre>
=== TFT LCD Configuration ($70, $71, $72, $73, $74, $75, $76, $77 SwanCrystal only) ===
These eight bytes are read from internal EEPROM and configure unknown aspects of the console's TFT LCD panel.
They are only writable while the [[Boot ROM]] is unlocked - locking has the side effect of making them read-only.
== Notes ==
<references />
784266dd1a97d80c731f9bd9f916b9aa98fecd5c
308
307
2024-07-12T19:49:50Z
Asie
351
/* Sprites */
wikitext
text/x-wiki
The WonderSwan's display functionality generally consists of:
* a 224x144 display clocked at ~75.47 Hz by default, capable of displaying:
** up to sixteen distinct shades of gray
** 12-bit RGB444 color<sup>(color)</sup>
* two 32x32 background layers ("screens"), capable of displaying up to 512 (1024<sup>(color)</sup>) distinct tiles,
* a sprite layer, capable of displaying up to 128 8x8 sprites (up to 32 per line),
* six LCD icons to the bottom or right of the display, usable as additional indicators.
== Components ==
=== Tiles ===
The WonderSwan can display up to 512 distinct tiles at a time, with two bits of palette index information for every pixel.
The WonderSwan Color expands this to 1024 distinct tiles for background (with 512 remaining the limit for sprites), while also introducing modes with four bits of palette index information for every pixel.
==== 2 bits per pixel, planar ====
The tiles are stored in an interleaved planar format, with two bits total for every pixel. Odd bytes store the first plane (bit 0 of each pixel), while even bytes store the second plane (bit 1 of each pixel).
<pre>
tile data (16 bytes)
01 7C 01 FC 00 C0 18 D8 18 D8 00 C0 00 00 C0 00
||
\/
plane 0 plane 1
7 bit 0 7 bit 0 full tile
---- ---- ---- ----
.... ...1 = 01 .222 22.. = 7C .22222.1
.... ...1 = 01 2222 22.. = FC 222222.1
.... .... = 00 22.. .... = C0 22......
...1 1... = 18 22.2 2... = D8 --\ 22.33...
...1 1... = 18 22.2 2... = D8 --/ 22.33...
.... .... = 00 22.. .... = C0 22......
.... .... = 00 .... .... = 00 ........
11.. .... = C0 .... .... = 00 11......
</pre>
This matches the format used by the Game Boy.
==== 4 bits per pixel, planar ====
This mode is stored in a manner similar to the 2 bits per pixel mode, but with an additional two planes for bit 2 and bit 3 of each pixel's palette index, expanding the tile data to 32 bytes.
<pre>
tile data (32 bytes)
54 32 01 00 54 32 F1 00 54 32 01 F0 54 32 F1 F0 04 02 01 00 F8 04 02 01 00 F8 04 02 00 00 F8 04
||
\/
plane 0 plane 1 plane 2 plane 3
7 bit 0 7 bit 0 7 bit 0 7 bit 0 full tile
---- ---- ---- ---- ---- ---- ---- ----
.1.1 .1.. = 54 ..22 ..2. = 32 .... ...4 = 01 .... .... = 00 .123.124
.1.1 .1.. = 54 ..22 ..2. = 32 4444 ...4 = F1 .... .... = 00 4567.124
.1.1 .1.. = 54 ..22 ..2. = 32 .... ...4 = 01 8888 .... = F0 89AB.124
.1.1 .1.. = 54 ..22 ..2. = 32 4444 ...4 = F1 8888 .... = F0 --\ CDEF.124
.... .1.. = 04 .... ..2. = 02 .... ...4 = 01 .... .... = 00 --/ .....124
1111 1... = F8 .... .2.. = 04 .... ..4. = 02 .... ...8 = 01 11111248
.... .... = 00 2222 2... = F8 .... .4.. = 04 .... ..8. = 02 2222248.
.... .... = 00 .... .... = 00 4444 4... = F8 .... .8.. = 04 444448..
</pre>
This format matches the one used by the Sega Master System and Game Gear family of consoles.
==== 4 bits per pixel, packed ====
Unlike the previous two formats, in the packed format each byte stores the complete palette index of two pixels - the high four bits store the left pixel, while the low four bits store the right pixel. Four such bytes make up a row of eight pixels from left to right.
<pre>
tile data (32 bytes)
01 23 01 24 45 67 01 24 89 AB 01 24 CD EF 01 24 00 00 01 24 11 11 12 48 22 22 24 80 44 44 48 00
||
\/
byte 0 1 2 3
bits 7-4 3-0 7-4 3-0 7-4 3-0 7-4 3-0
pixel 0 1 2 3 4 5 6 7 full tile
--- --- --- --- --- --- --- ---
. 1 = 01 2 3 = 23 . 1 = 01 2 4 = 24 .123.124 = 01 23 01 24
4 5 = 45 6 7 = 67 . 1 = 01 2 4 = 24 4567.124 = 45 67 01 24
8 9 = 89 A B = AB . 1 = 01 2 4 = 24 89AB.124 = 89 AB 01 24
C D = CD E F = EF . 1 = 01 2 4 = 24 --\ CDEF.124 = CD EF 01 24
. . = 00 . . = 00 . 1 = 01 2 4 = 24 --/ .....124 = 00 00 01 24
1 1 = 11 1 1 = 11 1 2 = 12 4 8 = 48 11111248 = 11 11 12 48
2 2 = 22 2 2 = 22 2 4 = 24 8 . = 80 2222248. = 22 22 24 80
4 4 = 44 4 4 = 44 4 8 = 48 . . = 00 444448.. = 44 44 48 00
</pre>
This format matches the one used by the Mega Drive console.
=== Palettes ===
The display system provides sixteen different palettes that can be used to color or shade tiles.
* Palettes 0-7 can be used for the two screens only;
* Palettes 8-15 can be used for both screens and sprites.
==== Mono ====
In ''mono'' modes, palettes are stored in I/O ports 0x20 through 0x3F. Each palette contains four three-bit entries, which are pointers into a global, four-bit shade lookup table:
<pre>
Palette Global shade LUT
1 ===========> 2 ==========================> 5
^ (0, 2, 4, 6) ^ (1, 3, 5, 7, 9, 11, 13, 15) ^
| | |
Palette index Value Displayed shade
</pre>
The shade value corresponds to the darkness of the pixel: shade 0 is the brightest, while shade 15 is the darkest.
==== Color ====
In ''color'' modes, palettes are stored as 16-bit words in memory addresses 0xFE00 through 0xFFFF, without additional lookup tables:
<pre>
Address
15 bit 8 7 bit 0
---- ---- ---- ----
1111 111p pppi iii.
| |||| |||
| |||+-+++-- Index in palette (0-15)
+--+++------- Palette number (0-15)
Data
15 bit 8 7 bit 0
---- ---- ---- ----
.... rrrr gggg bbbb
|||| |||| ||||
|||| |||| ++++- Blue (0-15)
|||| ++++------ Green (0-15)
++++------------ Red (0-15)
</pre>
In 2 bits per pixel color modes, palette entries 4 through 15 are not used.
==== Transparency ====
In two bit per pixel modes:
* Palettes 0-3 and 8-11 are ''opaque''. For these, index zero is treated as opaque.
* Palettes 4-7 and 12-15 are ''translucent''. For these, index zero is treated as transparent. This means that the color/shade value set to it is ignored, and only three distinct colors/shades can be used for tiles.
In four bit per pixel modes, all palettes are ''translucent''. Index zero is always treated as transparent, and fifteen different colors/shades can be used for tiles.
=== Background color ===
The background color is displayed if no ''opaque'' pixel from screens or sprites is drawn. This color is set in I/O port ''0x01'':
* In mono modes, it is set to an entry in the shade lookup table (0-7),
* In color modes, it is set to an entry in the color palette (0-255). Note that this allows you to use the first color (color zero) of any palette, which is normally ignored and assumed to be ''transparent''.
=== Screens ===
A screen is a layout of tiles. Each cell in a screen controls one 8x8 tile.
The display system can show two distinct screens simultaneously. It also supports hardware flipping of tiles, both horizontally and vertically.
The size of each screen is fixed at 32x32 cells or 256x256 pixels, while each cell is stored as a two-byte word:
<pre>
Address
15 bit 8 7 bit 0
---- ---- ---- ----
0bbb byyy yyxx xxx.
||| |||| |||| |||
||| |||| ||++-+++-- X coordinate (0-31)
||| |+++--++-------- Y coordinate (0-31)
+++-+--------------- Base address (from I/O port)
Data
15 bit 8 7 bit 0
---- ---- ---- ----
vhbp pppt tttt tttt
|||| |||| |||| ||||
|||| |||+--++++-++++- Tile index (0-511)
|||+-+++------------- Palette (0-15)
||+------------------ Tile bank (0-1) - color only
|+------------------- Horizontal flip
+-------------------- Vertical flip
</pre>
In ''color'' modes, the tile bank selects between tiles 0-511 and 512-1023.
=== Sprites ===
The display system can show up to 128 sprites at once.
Sprites are always drawn in front of Screen 1, but they can be drawn in front of or behind Screen 2.
Sprites are stored in a sprite table in the console's internal RAM. It consists of up to 128 four-byte entries, of which any sequential slice can be displayed:
<pre>
(Byte 1) (Byte 0)
15 bit 8 7 bit 0
---- ---- ---- ----
vhPi pppt tttt tttt
|||| |||| |||| ||||
|||| |||+--++++-++++- Tile index (0-511) - only tile bank 0
|||| +++------------- Palette (0-7) - mapped to screen palettes 8-15
|||+----------------- Window location - 0 = inside, 1 = outside
||+------------------ Priority - 0 = behind Screen 2, 1 = in front of Screen 2
|+------------------- Horizontal flip
+-------------------- Vertical flip
(Byte 2)
7 bit 0
---- ----
yyyy yyyy
|||| ||||
++++-++++- Y coordinate
(Byte 3)
7 bit 0
---- ----
xxxx xxxx
|||| ||||
++++-++++- X coordinate
</pre>
There is a sprite limit of 32 per scanline. This means that for each scanline, only the first 32 sprites will be drawn.
Note that this includes sprites obscured by windows or outside of visible X coordinates; this list is determined solely by the Y coordinate.
Between sprites themselves, earlier sprites in the list are always drawn on top of later sprites in the list.
=== Visibility priority ===
For display components, the visibility priority is as follows:
* Sprite 0, high priority
* Sprite 127, high priority
* Screen 2
* Sprite 0, low priority
* Sprite 127, low priority
* Screen 1
* Background color
=== Windows ===
Screen 2 and the sprite layer can optionally be restricted to a specific window.
In addition, one can control if a given element is rendered inside or outside that window. For Screen 2, this is controlled globally; for sprites, this is controlled per-sprite.
=== Icons ===
The WonderSwan features six LCD segment icons which are displayed to the right<sup>(color)</sup> or below<sup>(mono)</sup> the main display. These are, as follows:
* Aux 3 - large circle,
* Aux 2 - medium circle,
* Aux 1 - small circle,
* Horizontal orientation,
* Vertical orientation,
* Sleep.
== Interrupts ==
The display circuit generates two interrupts of its own:
* Display Interrupt Line Match - when <code>Display Current Line</code> == <code>Display Interrupt Line</code>, at the beginning of said line.
* Display Vertical Blank - when <code>Display Current Line</code> == <code>144</code>, at the beginning of said line.
It also provides a timing source for the two Horizontal and Vertical Blank [[Timers]], which provide their own respective interrupts.
== I/O ports ==
{{Anchor|Display Control}}
=== Display Control ($00) ===
<pre>
7 bit 0
---- ----
..ow Ws21
|| ||||
|| |||+- Enable Screen 1 layer
|| ||+-- Enable Screen 2 layer
|| |+--- Enable Sprite layer
|| +---- Enable Sprite window
|+------ Enable Screen 2 window
+------- Screen 2 window location:
0 = inside, 1 = outside
</pre>
{{Anchor|Display Background}}
=== Display Background Color ($01) ===
<pre>
(mono) (color)
7 bit 0 7 bit 0
---- ---- ---- ----
.... .sss pppp iiii
||| |||| ||||
+++- Value |||| ++++- Index in palette (0-15)
(0-7) ++++------ Color palette (0-15)
</pre>
{{Anchor|Display Current Line}}
=== Display Current Line ($02 read) ===
The current line being drawn by the display.
Note that lines are sent to the display with a one-line delay. This matters for color palette or shade LUT manipulation; changing these values when <code>current line == 1</code> will actually affect line 0.
{{Anchor|Display Interrupt Line}}
=== Display Interrupt Line ($03) ===
The line to emit an interrupt on.
{{Anchor|Sprite Table Address}}
=== Sprite Table Address ($04) ===
<pre>
7 bit 0
---- ----
..Aa aaaa
|| ||||
|+-++++- Address (bits 9-13)
+------- Address (bit 14) - color only
</pre>
{{Anchor|Sprite Table First}}
=== Sprite Table First ($05) ===
<pre>
7 bit 0
---- ----
.iii iiii
||| ||||
+++-++++- Index of first sprite entry to draw (0-127)
</pre>
{{Anchor|Sprite Table Count}}
=== Sprite Table Count ($06) ===
<pre>
7 bit 0
---- ----
cccc cccc
|||| ||||
++++-++++- Count of sprite entries to draw (1-128)
</pre>
{{Anchor|Screen Address}}
=== Screen Address ($07) ===
<pre>
7 bit 0
---- ----
2222 1111
|||| ||||
|||| |+++- Screen 1 address (bits 11-13)
|||| +---- Screen 1 address (bit 14) - color only
|+++------ Screen 2 address (bits 11-13)
+--------- Screen 2 address (bit 14) - color only
</pre>
{{Anchor|Screen 2 Window}}
=== Screen 2 Window Left ($08) ===
=== Screen 2 Window Top ($09) ===
=== Screen 2 Window Right ($0A) ===
=== Screen 2 Window Bottom ($0B) ===
{{Anchor|Sprite Window}}
=== Sprite Window Left ($0C) ===
=== Sprite Window Top ($0D) ===
=== Sprite Window Right ($0E) ===
=== Sprite Window Bottom ($0F) ===
{{Anchor|Screen Scroll}}
=== Screen 1 Scroll X ($10) ===
=== Screen 1 Scroll Y ($11) ===
=== Screen 2 Scroll X ($12) ===
=== Screen 2 Scroll Y ($13) ===
{{Anchor|LCD Control}}
=== LCD Control ($14) ===
<pre>
7 bit 0
---- ----
.... ..Ce
||
|+- LCD Enable: 0 = sleep, 1 = enabled
+-- Contrast (WSC): 0 = low, 1 = high
</pre>
{{Anchor|LCD Icon Control}}
=== LCD Icon Control ($15) ===
<pre>
7 bit 0
---- ----
..32 1hvs
|| ||||
|| |||+- Sleep
|| ||+-- Vertical orientation
|| |+--- Horizontal orientation
|| +---- Aux 1
|+------ Aux 2
+------- Aux 3
</pre>
{{Anchor|LCD Mono Shade LUT}}
=== LCD Mono Shade LUT ($1C-$1F) ===
<pre>
$1C $1D $1E $1F
7 bit 0 7 bit 0 7 bit 0 7 bit 0
---- ---- ---- ---- ---- ---- ---- ----
1111 0000 3333 2222 5555 4444 7777 6666
</pre>
{{Anchor|LCD Mono Palette}}
=== LCD Mono Palette 0..15 ($20, $21 .. $3E, $3F) ===
The monochrome palette is laid out as sixteen words:
<pre>
N+1 N
15 bit 8 7 bit 0
---- ---- ---- ----
.333 .222 .111 .000
||| ||| ||| |||
||| ||| ||| +++- Shade LUT index for color 0
||| ||| +++------ Shade LUT index for color 1
||| +++------------ Shade LUT index for color 2
+++----------------- Shade LUT index for color 3
</pre>
== Internal I/O ports ==
These I/O ports are said to be internal and not intended for use by commercial games.
{{Anchor|LCD Final Line}}
=== LCD Final Line ($16) ===
The final line preceding line counter restart and the beginning of active display. By default, this is set to 158, which equals 159 total lines per frame.
It is said setting this register to an odd value on SwanCrystal has an adverse effect to the LCD panel<ref>[http://daifukkat.su/docs/wsman/#REG_LCD_VTOTAL REG_LCD_VTOTAL - WSMan]</ref>, but the exact mechanism is unknown.
{{Anchor|LCD Back Porch Line}}
=== LCD Back Porch Line ($17, WSC only) ===
This port is available on the WonderSwan Color only - not the SwanCrystal!
The final line preceding the vertical back porch; by default, this should be set to 155.
The vertical back porch of the LCD is assumed to be 4 lines by some hardware, including IPS mods, as well as the official "TV Swan" capture device. Given that the first visible line is sent to the LCD on the display's line 1, this should be generally set to <code>LCD Final Line - 3</code>.
Conversely, it is said moving this value closer to vertical blank improves LCD visibility<ref>[http://daifukkat.su/docs/wsman/#REG_LCD_VSYNC REG_LCD_VSYNC - WSMan]</ref>, but the exact mechanism is unknown.
{{Anchor|LCD Status}}
=== LCD Status ($1A) ===
<pre>
7 bit 0
---- ----
...v vv.s
| || |
| || +- LCD sleep: 0 = no, 1 = sleep
| ||
| || Volume segments:
| |+--- Volume B (medium, high)
| +---- Volume A (low, high)
+------ Speaker
</pre>
=== TFT LCD Configuration ($70, $71, $72, $73, $74, $75, $76, $77 SwanCrystal only) ===
These eight bytes are read from internal EEPROM and configure unknown aspects of the console's TFT LCD panel.
They are only writable while the [[Boot ROM]] is unlocked - locking has the side effect of making them read-only.
== Notes ==
<references />
dda21e0aa6d7fb262f302883ae808691822c8f36
309
308
2024-07-12T19:51:38Z
Asie
351
/* Windows */
wikitext
text/x-wiki
The WonderSwan's display functionality generally consists of:
* a 224x144 display clocked at ~75.47 Hz by default, capable of displaying:
** up to sixteen distinct shades of gray
** 12-bit RGB444 color<sup>(color)</sup>
* two 32x32 background layers ("screens"), capable of displaying up to 512 (1024<sup>(color)</sup>) distinct tiles,
* a sprite layer, capable of displaying up to 128 8x8 sprites (up to 32 per line),
* six LCD icons to the bottom or right of the display, usable as additional indicators.
== Components ==
=== Tiles ===
The WonderSwan can display up to 512 distinct tiles at a time, with two bits of palette index information for every pixel.
The WonderSwan Color expands this to 1024 distinct tiles for background (with 512 remaining the limit for sprites), while also introducing modes with four bits of palette index information for every pixel.
==== 2 bits per pixel, planar ====
The tiles are stored in an interleaved planar format, with two bits total for every pixel. Odd bytes store the first plane (bit 0 of each pixel), while even bytes store the second plane (bit 1 of each pixel).
<pre>
tile data (16 bytes)
01 7C 01 FC 00 C0 18 D8 18 D8 00 C0 00 00 C0 00
||
\/
plane 0 plane 1
7 bit 0 7 bit 0 full tile
---- ---- ---- ----
.... ...1 = 01 .222 22.. = 7C .22222.1
.... ...1 = 01 2222 22.. = FC 222222.1
.... .... = 00 22.. .... = C0 22......
...1 1... = 18 22.2 2... = D8 --\ 22.33...
...1 1... = 18 22.2 2... = D8 --/ 22.33...
.... .... = 00 22.. .... = C0 22......
.... .... = 00 .... .... = 00 ........
11.. .... = C0 .... .... = 00 11......
</pre>
This matches the format used by the Game Boy.
==== 4 bits per pixel, planar ====
This mode is stored in a manner similar to the 2 bits per pixel mode, but with an additional two planes for bit 2 and bit 3 of each pixel's palette index, expanding the tile data to 32 bytes.
<pre>
tile data (32 bytes)
54 32 01 00 54 32 F1 00 54 32 01 F0 54 32 F1 F0 04 02 01 00 F8 04 02 01 00 F8 04 02 00 00 F8 04
||
\/
plane 0 plane 1 plane 2 plane 3
7 bit 0 7 bit 0 7 bit 0 7 bit 0 full tile
---- ---- ---- ---- ---- ---- ---- ----
.1.1 .1.. = 54 ..22 ..2. = 32 .... ...4 = 01 .... .... = 00 .123.124
.1.1 .1.. = 54 ..22 ..2. = 32 4444 ...4 = F1 .... .... = 00 4567.124
.1.1 .1.. = 54 ..22 ..2. = 32 .... ...4 = 01 8888 .... = F0 89AB.124
.1.1 .1.. = 54 ..22 ..2. = 32 4444 ...4 = F1 8888 .... = F0 --\ CDEF.124
.... .1.. = 04 .... ..2. = 02 .... ...4 = 01 .... .... = 00 --/ .....124
1111 1... = F8 .... .2.. = 04 .... ..4. = 02 .... ...8 = 01 11111248
.... .... = 00 2222 2... = F8 .... .4.. = 04 .... ..8. = 02 2222248.
.... .... = 00 .... .... = 00 4444 4... = F8 .... .8.. = 04 444448..
</pre>
This format matches the one used by the Sega Master System and Game Gear family of consoles.
==== 4 bits per pixel, packed ====
Unlike the previous two formats, in the packed format each byte stores the complete palette index of two pixels - the high four bits store the left pixel, while the low four bits store the right pixel. Four such bytes make up a row of eight pixels from left to right.
<pre>
tile data (32 bytes)
01 23 01 24 45 67 01 24 89 AB 01 24 CD EF 01 24 00 00 01 24 11 11 12 48 22 22 24 80 44 44 48 00
||
\/
byte 0 1 2 3
bits 7-4 3-0 7-4 3-0 7-4 3-0 7-4 3-0
pixel 0 1 2 3 4 5 6 7 full tile
--- --- --- --- --- --- --- ---
. 1 = 01 2 3 = 23 . 1 = 01 2 4 = 24 .123.124 = 01 23 01 24
4 5 = 45 6 7 = 67 . 1 = 01 2 4 = 24 4567.124 = 45 67 01 24
8 9 = 89 A B = AB . 1 = 01 2 4 = 24 89AB.124 = 89 AB 01 24
C D = CD E F = EF . 1 = 01 2 4 = 24 --\ CDEF.124 = CD EF 01 24
. . = 00 . . = 00 . 1 = 01 2 4 = 24 --/ .....124 = 00 00 01 24
1 1 = 11 1 1 = 11 1 2 = 12 4 8 = 48 11111248 = 11 11 12 48
2 2 = 22 2 2 = 22 2 4 = 24 8 . = 80 2222248. = 22 22 24 80
4 4 = 44 4 4 = 44 4 8 = 48 . . = 00 444448.. = 44 44 48 00
</pre>
This format matches the one used by the Mega Drive console.
=== Palettes ===
The display system provides sixteen different palettes that can be used to color or shade tiles.
* Palettes 0-7 can be used for the two screens only;
* Palettes 8-15 can be used for both screens and sprites.
==== Mono ====
In ''mono'' modes, palettes are stored in I/O ports 0x20 through 0x3F. Each palette contains four three-bit entries, which are pointers into a global, four-bit shade lookup table:
<pre>
Palette Global shade LUT
1 ===========> 2 ==========================> 5
^ (0, 2, 4, 6) ^ (1, 3, 5, 7, 9, 11, 13, 15) ^
| | |
Palette index Value Displayed shade
</pre>
The shade value corresponds to the darkness of the pixel: shade 0 is the brightest, while shade 15 is the darkest.
==== Color ====
In ''color'' modes, palettes are stored as 16-bit words in memory addresses 0xFE00 through 0xFFFF, without additional lookup tables:
<pre>
Address
15 bit 8 7 bit 0
---- ---- ---- ----
1111 111p pppi iii.
| |||| |||
| |||+-+++-- Index in palette (0-15)
+--+++------- Palette number (0-15)
Data
15 bit 8 7 bit 0
---- ---- ---- ----
.... rrrr gggg bbbb
|||| |||| ||||
|||| |||| ++++- Blue (0-15)
|||| ++++------ Green (0-15)
++++------------ Red (0-15)
</pre>
In 2 bits per pixel color modes, palette entries 4 through 15 are not used.
==== Transparency ====
In two bit per pixel modes:
* Palettes 0-3 and 8-11 are ''opaque''. For these, index zero is treated as opaque.
* Palettes 4-7 and 12-15 are ''translucent''. For these, index zero is treated as transparent. This means that the color/shade value set to it is ignored, and only three distinct colors/shades can be used for tiles.
In four bit per pixel modes, all palettes are ''translucent''. Index zero is always treated as transparent, and fifteen different colors/shades can be used for tiles.
=== Background color ===
The background color is displayed if no ''opaque'' pixel from screens or sprites is drawn. This color is set in I/O port ''0x01'':
* In mono modes, it is set to an entry in the shade lookup table (0-7),
* In color modes, it is set to an entry in the color palette (0-255). Note that this allows you to use the first color (color zero) of any palette, which is normally ignored and assumed to be ''transparent''.
=== Screens ===
A screen is a layout of tiles. Each cell in a screen controls one 8x8 tile.
The display system can show two distinct screens simultaneously. It also supports hardware flipping of tiles, both horizontally and vertically.
The size of each screen is fixed at 32x32 cells or 256x256 pixels, while each cell is stored as a two-byte word:
<pre>
Address
15 bit 8 7 bit 0
---- ---- ---- ----
0bbb byyy yyxx xxx.
||| |||| |||| |||
||| |||| ||++-+++-- X coordinate (0-31)
||| |+++--++-------- Y coordinate (0-31)
+++-+--------------- Base address (from I/O port)
Data
15 bit 8 7 bit 0
---- ---- ---- ----
vhbp pppt tttt tttt
|||| |||| |||| ||||
|||| |||+--++++-++++- Tile index (0-511)
|||+-+++------------- Palette (0-15)
||+------------------ Tile bank (0-1) - color only
|+------------------- Horizontal flip
+-------------------- Vertical flip
</pre>
In ''color'' modes, the tile bank selects between tiles 0-511 and 512-1023.
=== Sprites ===
The display system can show up to 128 sprites at once.
Sprites are always drawn in front of Screen 1, but they can be drawn in front of or behind Screen 2.
Sprites are stored in a sprite table in the console's internal RAM. It consists of up to 128 four-byte entries, of which any sequential slice can be displayed:
<pre>
(Byte 1) (Byte 0)
15 bit 8 7 bit 0
---- ---- ---- ----
vhPi pppt tttt tttt
|||| |||| |||| ||||
|||| |||+--++++-++++- Tile index (0-511) - only tile bank 0
|||| +++------------- Palette (0-7) - mapped to screen palettes 8-15
|||+----------------- Window location - 0 = inside, 1 = outside
||+------------------ Priority - 0 = behind Screen 2, 1 = in front of Screen 2
|+------------------- Horizontal flip
+-------------------- Vertical flip
(Byte 2)
7 bit 0
---- ----
yyyy yyyy
|||| ||||
++++-++++- Y coordinate
(Byte 3)
7 bit 0
---- ----
xxxx xxxx
|||| ||||
++++-++++- X coordinate
</pre>
There is a sprite limit of 32 per scanline. This means that for each scanline, only the first 32 sprites will be drawn.
Note that this includes sprites obscured by windows or outside of visible X coordinates; this list is determined solely by the Y coordinate.
Between sprites themselves, earlier sprites in the list are always drawn on top of later sprites in the list.
=== Visibility priority ===
For display components, the visibility priority is as follows:
* Sprite 0, high priority
* Sprite 127, high priority
* Screen 2
* Sprite 0, low priority
* Sprite 127, low priority
* Screen 1
* Background color
=== Windows ===
Screen 2 and sprites can optionally have their drawing restricted within or outside of their specific rectangular windows.
Note that for sprites, the window is enabled globally (for all sprites), but each sprite can individually decide if it's rendered inside or outside of it.
=== Icons ===
The WonderSwan features six LCD segment icons which are displayed to the right<sup>(color)</sup> or below<sup>(mono)</sup> the main display. These are, as follows:
* Aux 3 - large circle,
* Aux 2 - medium circle,
* Aux 1 - small circle,
* Horizontal orientation,
* Vertical orientation,
* Sleep.
== Interrupts ==
The display circuit generates two interrupts of its own:
* Display Interrupt Line Match - when <code>Display Current Line</code> == <code>Display Interrupt Line</code>, at the beginning of said line.
* Display Vertical Blank - when <code>Display Current Line</code> == <code>144</code>, at the beginning of said line.
It also provides a timing source for the two Horizontal and Vertical Blank [[Timers]], which provide their own respective interrupts.
== I/O ports ==
{{Anchor|Display Control}}
=== Display Control ($00) ===
<pre>
7 bit 0
---- ----
..ow Ws21
|| ||||
|| |||+- Enable Screen 1 layer
|| ||+-- Enable Screen 2 layer
|| |+--- Enable Sprite layer
|| +---- Enable Sprite window
|+------ Enable Screen 2 window
+------- Screen 2 window location:
0 = inside, 1 = outside
</pre>
{{Anchor|Display Background}}
=== Display Background Color ($01) ===
<pre>
(mono) (color)
7 bit 0 7 bit 0
---- ---- ---- ----
.... .sss pppp iiii
||| |||| ||||
+++- Value |||| ++++- Index in palette (0-15)
(0-7) ++++------ Color palette (0-15)
</pre>
{{Anchor|Display Current Line}}
=== Display Current Line ($02 read) ===
The current line being drawn by the display.
Note that lines are sent to the display with a one-line delay. This matters for color palette or shade LUT manipulation; changing these values when <code>current line == 1</code> will actually affect line 0.
{{Anchor|Display Interrupt Line}}
=== Display Interrupt Line ($03) ===
The line to emit an interrupt on.
{{Anchor|Sprite Table Address}}
=== Sprite Table Address ($04) ===
<pre>
7 bit 0
---- ----
..Aa aaaa
|| ||||
|+-++++- Address (bits 9-13)
+------- Address (bit 14) - color only
</pre>
{{Anchor|Sprite Table First}}
=== Sprite Table First ($05) ===
<pre>
7 bit 0
---- ----
.iii iiii
||| ||||
+++-++++- Index of first sprite entry to draw (0-127)
</pre>
{{Anchor|Sprite Table Count}}
=== Sprite Table Count ($06) ===
<pre>
7 bit 0
---- ----
cccc cccc
|||| ||||
++++-++++- Count of sprite entries to draw (1-128)
</pre>
{{Anchor|Screen Address}}
=== Screen Address ($07) ===
<pre>
7 bit 0
---- ----
2222 1111
|||| ||||
|||| |+++- Screen 1 address (bits 11-13)
|||| +---- Screen 1 address (bit 14) - color only
|+++------ Screen 2 address (bits 11-13)
+--------- Screen 2 address (bit 14) - color only
</pre>
{{Anchor|Screen 2 Window}}
=== Screen 2 Window Left ($08) ===
=== Screen 2 Window Top ($09) ===
=== Screen 2 Window Right ($0A) ===
=== Screen 2 Window Bottom ($0B) ===
{{Anchor|Sprite Window}}
=== Sprite Window Left ($0C) ===
=== Sprite Window Top ($0D) ===
=== Sprite Window Right ($0E) ===
=== Sprite Window Bottom ($0F) ===
{{Anchor|Screen Scroll}}
=== Screen 1 Scroll X ($10) ===
=== Screen 1 Scroll Y ($11) ===
=== Screen 2 Scroll X ($12) ===
=== Screen 2 Scroll Y ($13) ===
{{Anchor|LCD Control}}
=== LCD Control ($14) ===
<pre>
7 bit 0
---- ----
.... ..Ce
||
|+- LCD Enable: 0 = sleep, 1 = enabled
+-- Contrast (WSC): 0 = low, 1 = high
</pre>
{{Anchor|LCD Icon Control}}
=== LCD Icon Control ($15) ===
<pre>
7 bit 0
---- ----
..32 1hvs
|| ||||
|| |||+- Sleep
|| ||+-- Vertical orientation
|| |+--- Horizontal orientation
|| +---- Aux 1
|+------ Aux 2
+------- Aux 3
</pre>
{{Anchor|LCD Mono Shade LUT}}
=== LCD Mono Shade LUT ($1C-$1F) ===
<pre>
$1C $1D $1E $1F
7 bit 0 7 bit 0 7 bit 0 7 bit 0
---- ---- ---- ---- ---- ---- ---- ----
1111 0000 3333 2222 5555 4444 7777 6666
</pre>
{{Anchor|LCD Mono Palette}}
=== LCD Mono Palette 0..15 ($20, $21 .. $3E, $3F) ===
The monochrome palette is laid out as sixteen words:
<pre>
N+1 N
15 bit 8 7 bit 0
---- ---- ---- ----
.333 .222 .111 .000
||| ||| ||| |||
||| ||| ||| +++- Shade LUT index for color 0
||| ||| +++------ Shade LUT index for color 1
||| +++------------ Shade LUT index for color 2
+++----------------- Shade LUT index for color 3
</pre>
== Internal I/O ports ==
These I/O ports are said to be internal and not intended for use by commercial games.
{{Anchor|LCD Final Line}}
=== LCD Final Line ($16) ===
The final line preceding line counter restart and the beginning of active display. By default, this is set to 158, which equals 159 total lines per frame.
It is said setting this register to an odd value on SwanCrystal has an adverse effect to the LCD panel<ref>[http://daifukkat.su/docs/wsman/#REG_LCD_VTOTAL REG_LCD_VTOTAL - WSMan]</ref>, but the exact mechanism is unknown.
{{Anchor|LCD Back Porch Line}}
=== LCD Back Porch Line ($17, WSC only) ===
This port is available on the WonderSwan Color only - not the SwanCrystal!
The final line preceding the vertical back porch; by default, this should be set to 155.
The vertical back porch of the LCD is assumed to be 4 lines by some hardware, including IPS mods, as well as the official "TV Swan" capture device. Given that the first visible line is sent to the LCD on the display's line 1, this should be generally set to <code>LCD Final Line - 3</code>.
Conversely, it is said moving this value closer to vertical blank improves LCD visibility<ref>[http://daifukkat.su/docs/wsman/#REG_LCD_VSYNC REG_LCD_VSYNC - WSMan]</ref>, but the exact mechanism is unknown.
{{Anchor|LCD Status}}
=== LCD Status ($1A) ===
<pre>
7 bit 0
---- ----
...v vv.s
| || |
| || +- LCD sleep: 0 = no, 1 = sleep
| ||
| || Volume segments:
| |+--- Volume B (medium, high)
| +---- Volume A (low, high)
+------ Speaker
</pre>
=== TFT LCD Configuration ($70, $71, $72, $73, $74, $75, $76, $77 SwanCrystal only) ===
These eight bytes are read from internal EEPROM and configure unknown aspects of the console's TFT LCD panel.
They are only writable while the [[Boot ROM]] is unlocked - locking has the side effect of making them read-only.
== Notes ==
<references />
95c85ad18760137af4a3417887d850f70549a1d5
311
309
2024-07-13T06:23:58Z
Asie
351
/* Display Control ($00) */
wikitext
text/x-wiki
The WonderSwan's display functionality generally consists of:
* a 224x144 display clocked at ~75.47 Hz by default, capable of displaying:
** up to sixteen distinct shades of gray
** 12-bit RGB444 color<sup>(color)</sup>
* two 32x32 background layers ("screens"), capable of displaying up to 512 (1024<sup>(color)</sup>) distinct tiles,
* a sprite layer, capable of displaying up to 128 8x8 sprites (up to 32 per line),
* six LCD icons to the bottom or right of the display, usable as additional indicators.
== Components ==
=== Tiles ===
The WonderSwan can display up to 512 distinct tiles at a time, with two bits of palette index information for every pixel.
The WonderSwan Color expands this to 1024 distinct tiles for background (with 512 remaining the limit for sprites), while also introducing modes with four bits of palette index information for every pixel.
==== 2 bits per pixel, planar ====
The tiles are stored in an interleaved planar format, with two bits total for every pixel. Odd bytes store the first plane (bit 0 of each pixel), while even bytes store the second plane (bit 1 of each pixel).
<pre>
tile data (16 bytes)
01 7C 01 FC 00 C0 18 D8 18 D8 00 C0 00 00 C0 00
||
\/
plane 0 plane 1
7 bit 0 7 bit 0 full tile
---- ---- ---- ----
.... ...1 = 01 .222 22.. = 7C .22222.1
.... ...1 = 01 2222 22.. = FC 222222.1
.... .... = 00 22.. .... = C0 22......
...1 1... = 18 22.2 2... = D8 --\ 22.33...
...1 1... = 18 22.2 2... = D8 --/ 22.33...
.... .... = 00 22.. .... = C0 22......
.... .... = 00 .... .... = 00 ........
11.. .... = C0 .... .... = 00 11......
</pre>
This matches the format used by the Game Boy.
==== 4 bits per pixel, planar ====
This mode is stored in a manner similar to the 2 bits per pixel mode, but with an additional two planes for bit 2 and bit 3 of each pixel's palette index, expanding the tile data to 32 bytes.
<pre>
tile data (32 bytes)
54 32 01 00 54 32 F1 00 54 32 01 F0 54 32 F1 F0 04 02 01 00 F8 04 02 01 00 F8 04 02 00 00 F8 04
||
\/
plane 0 plane 1 plane 2 plane 3
7 bit 0 7 bit 0 7 bit 0 7 bit 0 full tile
---- ---- ---- ---- ---- ---- ---- ----
.1.1 .1.. = 54 ..22 ..2. = 32 .... ...4 = 01 .... .... = 00 .123.124
.1.1 .1.. = 54 ..22 ..2. = 32 4444 ...4 = F1 .... .... = 00 4567.124
.1.1 .1.. = 54 ..22 ..2. = 32 .... ...4 = 01 8888 .... = F0 89AB.124
.1.1 .1.. = 54 ..22 ..2. = 32 4444 ...4 = F1 8888 .... = F0 --\ CDEF.124
.... .1.. = 04 .... ..2. = 02 .... ...4 = 01 .... .... = 00 --/ .....124
1111 1... = F8 .... .2.. = 04 .... ..4. = 02 .... ...8 = 01 11111248
.... .... = 00 2222 2... = F8 .... .4.. = 04 .... ..8. = 02 2222248.
.... .... = 00 .... .... = 00 4444 4... = F8 .... .8.. = 04 444448..
</pre>
This format matches the one used by the Sega Master System and Game Gear family of consoles.
==== 4 bits per pixel, packed ====
Unlike the previous two formats, in the packed format each byte stores the complete palette index of two pixels - the high four bits store the left pixel, while the low four bits store the right pixel. Four such bytes make up a row of eight pixels from left to right.
<pre>
tile data (32 bytes)
01 23 01 24 45 67 01 24 89 AB 01 24 CD EF 01 24 00 00 01 24 11 11 12 48 22 22 24 80 44 44 48 00
||
\/
byte 0 1 2 3
bits 7-4 3-0 7-4 3-0 7-4 3-0 7-4 3-0
pixel 0 1 2 3 4 5 6 7 full tile
--- --- --- --- --- --- --- ---
. 1 = 01 2 3 = 23 . 1 = 01 2 4 = 24 .123.124 = 01 23 01 24
4 5 = 45 6 7 = 67 . 1 = 01 2 4 = 24 4567.124 = 45 67 01 24
8 9 = 89 A B = AB . 1 = 01 2 4 = 24 89AB.124 = 89 AB 01 24
C D = CD E F = EF . 1 = 01 2 4 = 24 --\ CDEF.124 = CD EF 01 24
. . = 00 . . = 00 . 1 = 01 2 4 = 24 --/ .....124 = 00 00 01 24
1 1 = 11 1 1 = 11 1 2 = 12 4 8 = 48 11111248 = 11 11 12 48
2 2 = 22 2 2 = 22 2 4 = 24 8 . = 80 2222248. = 22 22 24 80
4 4 = 44 4 4 = 44 4 8 = 48 . . = 00 444448.. = 44 44 48 00
</pre>
This format matches the one used by the Mega Drive console.
=== Palettes ===
The display system provides sixteen different palettes that can be used to color or shade tiles.
* Palettes 0-7 can be used for the two screens only;
* Palettes 8-15 can be used for both screens and sprites.
==== Mono ====
In ''mono'' modes, palettes are stored in I/O ports 0x20 through 0x3F. Each palette contains four three-bit entries, which are pointers into a global, four-bit shade lookup table:
<pre>
Palette Global shade LUT
1 ===========> 2 ==========================> 5
^ (0, 2, 4, 6) ^ (1, 3, 5, 7, 9, 11, 13, 15) ^
| | |
Palette index Value Displayed shade
</pre>
The shade value corresponds to the darkness of the pixel: shade 0 is the brightest, while shade 15 is the darkest.
==== Color ====
In ''color'' modes, palettes are stored as 16-bit words in memory addresses 0xFE00 through 0xFFFF, without additional lookup tables:
<pre>
Address
15 bit 8 7 bit 0
---- ---- ---- ----
1111 111p pppi iii.
| |||| |||
| |||+-+++-- Index in palette (0-15)
+--+++------- Palette number (0-15)
Data
15 bit 8 7 bit 0
---- ---- ---- ----
.... rrrr gggg bbbb
|||| |||| ||||
|||| |||| ++++- Blue (0-15)
|||| ++++------ Green (0-15)
++++------------ Red (0-15)
</pre>
In 2 bits per pixel color modes, palette entries 4 through 15 are not used.
==== Transparency ====
In two bit per pixel modes:
* Palettes 0-3 and 8-11 are ''opaque''. For these, index zero is treated as opaque.
* Palettes 4-7 and 12-15 are ''translucent''. For these, index zero is treated as transparent. This means that the color/shade value set to it is ignored, and only three distinct colors/shades can be used for tiles.
In four bit per pixel modes, all palettes are ''translucent''. Index zero is always treated as transparent, and fifteen different colors/shades can be used for tiles.
=== Background color ===
The background color is displayed if no ''opaque'' pixel from screens or sprites is drawn. This color is set in I/O port ''0x01'':
* In mono modes, it is set to an entry in the shade lookup table (0-7),
* In color modes, it is set to an entry in the color palette (0-255). Note that this allows you to use the first color (color zero) of any palette, which is normally ignored and assumed to be ''transparent''.
=== Screens ===
A screen is a layout of tiles. Each cell in a screen controls one 8x8 tile.
The display system can show two distinct screens simultaneously. It also supports hardware flipping of tiles, both horizontally and vertically.
The size of each screen is fixed at 32x32 cells or 256x256 pixels, while each cell is stored as a two-byte word:
<pre>
Address
15 bit 8 7 bit 0
---- ---- ---- ----
0bbb byyy yyxx xxx.
||| |||| |||| |||
||| |||| ||++-+++-- X coordinate (0-31)
||| |+++--++-------- Y coordinate (0-31)
+++-+--------------- Base address (from I/O port)
Data
15 bit 8 7 bit 0
---- ---- ---- ----
vhbp pppt tttt tttt
|||| |||| |||| ||||
|||| |||+--++++-++++- Tile index (0-511)
|||+-+++------------- Palette (0-15)
||+------------------ Tile bank (0-1) - color only
|+------------------- Horizontal flip
+-------------------- Vertical flip
</pre>
In ''color'' modes, the tile bank selects between tiles 0-511 and 512-1023.
=== Sprites ===
The display system can show up to 128 sprites at once.
Sprites are always drawn in front of Screen 1, but they can be drawn in front of or behind Screen 2.
Sprites are stored in a sprite table in the console's internal RAM. It consists of up to 128 four-byte entries, of which any sequential slice can be displayed:
<pre>
(Byte 1) (Byte 0)
15 bit 8 7 bit 0
---- ---- ---- ----
vhPi pppt tttt tttt
|||| |||| |||| ||||
|||| |||+--++++-++++- Tile index (0-511) - only tile bank 0
|||| +++------------- Palette (0-7) - mapped to screen palettes 8-15
|||+----------------- Window location - 0 = inside, 1 = outside
||+------------------ Priority - 0 = behind Screen 2, 1 = in front of Screen 2
|+------------------- Horizontal flip
+-------------------- Vertical flip
(Byte 2)
7 bit 0
---- ----
yyyy yyyy
|||| ||||
++++-++++- Y coordinate
(Byte 3)
7 bit 0
---- ----
xxxx xxxx
|||| ||||
++++-++++- X coordinate
</pre>
There is a sprite limit of 32 per scanline. This means that for each scanline, only the first 32 sprites will be drawn.
Note that this includes sprites obscured by windows or outside of visible X coordinates; this list is determined solely by the Y coordinate.
Between sprites themselves, earlier sprites in the list are always drawn on top of later sprites in the list.
=== Visibility priority ===
For display components, the visibility priority is as follows:
* Sprite 0, high priority
* Sprite 127, high priority
* Screen 2
* Sprite 0, low priority
* Sprite 127, low priority
* Screen 1
* Background color
=== Windows ===
Screen 2 and sprites can optionally have their drawing restricted within or outside of their specific rectangular windows.
Note that for sprites, the window is enabled globally (for all sprites), but each sprite can individually decide if it's rendered inside or outside of it.
=== Icons ===
The WonderSwan features six LCD segment icons which are displayed to the right<sup>(color)</sup> or below<sup>(mono)</sup> the main display. These are, as follows:
* Aux 3 - large circle,
* Aux 2 - medium circle,
* Aux 1 - small circle,
* Horizontal orientation,
* Vertical orientation,
* Sleep.
== Interrupts ==
The display circuit generates two interrupts of its own:
* Display Interrupt Line Match - when <code>Display Current Line</code> == <code>Display Interrupt Line</code>, at the beginning of said line.
* Display Vertical Blank - when <code>Display Current Line</code> == <code>144</code>, at the beginning of said line.
It also provides a timing source for the two Horizontal and Vertical Blank [[Timers]], which provide their own respective interrupts.
== I/O ports ==
{{Anchor|Display Control}}
=== Display Control ($00) ===
<pre>
7 bit 0
---- ----
..ow Ws21
|| ||||
|| |||+- Enable Screen 1 layer
|| ||+-- Enable Screen 2 layer
|| |+--- Enable Sprite layer
|| +---- Enable Sprite window
|+------ Enable Screen 2 window
+------- Screen 2 tiles are drawn (if window enabled):
0 = inside window,
1 = outside window.
</pre>
{{Anchor|Display Background}}
=== Display Background Color ($01) ===
<pre>
(mono) (color)
7 bit 0 7 bit 0
---- ---- ---- ----
.... .sss pppp iiii
||| |||| ||||
+++- Value |||| ++++- Index in palette (0-15)
(0-7) ++++------ Color palette (0-15)
</pre>
{{Anchor|Display Current Line}}
=== Display Current Line ($02 read) ===
The current line being drawn by the display.
Note that lines are sent to the display with a one-line delay. This matters for color palette or shade LUT manipulation; changing these values when <code>current line == 1</code> will actually affect line 0.
{{Anchor|Display Interrupt Line}}
=== Display Interrupt Line ($03) ===
The line to emit an interrupt on.
{{Anchor|Sprite Table Address}}
=== Sprite Table Address ($04) ===
<pre>
7 bit 0
---- ----
..Aa aaaa
|| ||||
|+-++++- Address (bits 9-13)
+------- Address (bit 14) - color only
</pre>
{{Anchor|Sprite Table First}}
=== Sprite Table First ($05) ===
<pre>
7 bit 0
---- ----
.iii iiii
||| ||||
+++-++++- Index of first sprite entry to draw (0-127)
</pre>
{{Anchor|Sprite Table Count}}
=== Sprite Table Count ($06) ===
<pre>
7 bit 0
---- ----
cccc cccc
|||| ||||
++++-++++- Count of sprite entries to draw (1-128)
</pre>
{{Anchor|Screen Address}}
=== Screen Address ($07) ===
<pre>
7 bit 0
---- ----
2222 1111
|||| ||||
|||| |+++- Screen 1 address (bits 11-13)
|||| +---- Screen 1 address (bit 14) - color only
|+++------ Screen 2 address (bits 11-13)
+--------- Screen 2 address (bit 14) - color only
</pre>
{{Anchor|Screen 2 Window}}
=== Screen 2 Window Left ($08) ===
=== Screen 2 Window Top ($09) ===
=== Screen 2 Window Right ($0A) ===
=== Screen 2 Window Bottom ($0B) ===
{{Anchor|Sprite Window}}
=== Sprite Window Left ($0C) ===
=== Sprite Window Top ($0D) ===
=== Sprite Window Right ($0E) ===
=== Sprite Window Bottom ($0F) ===
{{Anchor|Screen Scroll}}
=== Screen 1 Scroll X ($10) ===
=== Screen 1 Scroll Y ($11) ===
=== Screen 2 Scroll X ($12) ===
=== Screen 2 Scroll Y ($13) ===
{{Anchor|LCD Control}}
=== LCD Control ($14) ===
<pre>
7 bit 0
---- ----
.... ..Ce
||
|+- LCD Enable: 0 = sleep, 1 = enabled
+-- Contrast (WSC): 0 = low, 1 = high
</pre>
{{Anchor|LCD Icon Control}}
=== LCD Icon Control ($15) ===
<pre>
7 bit 0
---- ----
..32 1hvs
|| ||||
|| |||+- Sleep
|| ||+-- Vertical orientation
|| |+--- Horizontal orientation
|| +---- Aux 1
|+------ Aux 2
+------- Aux 3
</pre>
{{Anchor|LCD Mono Shade LUT}}
=== LCD Mono Shade LUT ($1C-$1F) ===
<pre>
$1C $1D $1E $1F
7 bit 0 7 bit 0 7 bit 0 7 bit 0
---- ---- ---- ---- ---- ---- ---- ----
1111 0000 3333 2222 5555 4444 7777 6666
</pre>
{{Anchor|LCD Mono Palette}}
=== LCD Mono Palette 0..15 ($20, $21 .. $3E, $3F) ===
The monochrome palette is laid out as sixteen words:
<pre>
N+1 N
15 bit 8 7 bit 0
---- ---- ---- ----
.333 .222 .111 .000
||| ||| ||| |||
||| ||| ||| +++- Shade LUT index for color 0
||| ||| +++------ Shade LUT index for color 1
||| +++------------ Shade LUT index for color 2
+++----------------- Shade LUT index for color 3
</pre>
== Internal I/O ports ==
These I/O ports are said to be internal and not intended for use by commercial games.
{{Anchor|LCD Final Line}}
=== LCD Final Line ($16) ===
The final line preceding line counter restart and the beginning of active display. By default, this is set to 158, which equals 159 total lines per frame.
It is said setting this register to an odd value on SwanCrystal has an adverse effect to the LCD panel<ref>[http://daifukkat.su/docs/wsman/#REG_LCD_VTOTAL REG_LCD_VTOTAL - WSMan]</ref>, but the exact mechanism is unknown.
{{Anchor|LCD Back Porch Line}}
=== LCD Back Porch Line ($17, WSC only) ===
This port is available on the WonderSwan Color only - not the SwanCrystal!
The final line preceding the vertical back porch; by default, this should be set to 155.
The vertical back porch of the LCD is assumed to be 4 lines by some hardware, including IPS mods, as well as the official "TV Swan" capture device. Given that the first visible line is sent to the LCD on the display's line 1, this should be generally set to <code>LCD Final Line - 3</code>.
Conversely, it is said moving this value closer to vertical blank improves LCD visibility<ref>[http://daifukkat.su/docs/wsman/#REG_LCD_VSYNC REG_LCD_VSYNC - WSMan]</ref>, but the exact mechanism is unknown.
{{Anchor|LCD Status}}
=== LCD Status ($1A) ===
<pre>
7 bit 0
---- ----
...v vv.s
| || |
| || +- LCD sleep: 0 = no, 1 = sleep
| ||
| || Volume segments:
| |+--- Volume B (medium, high)
| +---- Volume A (low, high)
+------ Speaker
</pre>
=== TFT LCD Configuration ($70, $71, $72, $73, $74, $75, $76, $77 SwanCrystal only) ===
These eight bytes are read from internal EEPROM and configure unknown aspects of the console's TFT LCD panel.
They are only writable while the [[Boot ROM]] is unlocked - locking has the side effect of making them read-only.
== Notes ==
<references />
eb26e56888a5a992a8ecce1eea68ed8cc4bb46b1
312
311
2024-07-13T06:25:26Z
Asie
351
/* Screen 2 Window Bottom ($0B) */ clarify
wikitext
text/x-wiki
The WonderSwan's display functionality generally consists of:
* a 224x144 display clocked at ~75.47 Hz by default, capable of displaying:
** up to sixteen distinct shades of gray
** 12-bit RGB444 color<sup>(color)</sup>
* two 32x32 background layers ("screens"), capable of displaying up to 512 (1024<sup>(color)</sup>) distinct tiles,
* a sprite layer, capable of displaying up to 128 8x8 sprites (up to 32 per line),
* six LCD icons to the bottom or right of the display, usable as additional indicators.
== Components ==
=== Tiles ===
The WonderSwan can display up to 512 distinct tiles at a time, with two bits of palette index information for every pixel.
The WonderSwan Color expands this to 1024 distinct tiles for background (with 512 remaining the limit for sprites), while also introducing modes with four bits of palette index information for every pixel.
==== 2 bits per pixel, planar ====
The tiles are stored in an interleaved planar format, with two bits total for every pixel. Odd bytes store the first plane (bit 0 of each pixel), while even bytes store the second plane (bit 1 of each pixel).
<pre>
tile data (16 bytes)
01 7C 01 FC 00 C0 18 D8 18 D8 00 C0 00 00 C0 00
||
\/
plane 0 plane 1
7 bit 0 7 bit 0 full tile
---- ---- ---- ----
.... ...1 = 01 .222 22.. = 7C .22222.1
.... ...1 = 01 2222 22.. = FC 222222.1
.... .... = 00 22.. .... = C0 22......
...1 1... = 18 22.2 2... = D8 --\ 22.33...
...1 1... = 18 22.2 2... = D8 --/ 22.33...
.... .... = 00 22.. .... = C0 22......
.... .... = 00 .... .... = 00 ........
11.. .... = C0 .... .... = 00 11......
</pre>
This matches the format used by the Game Boy.
==== 4 bits per pixel, planar ====
This mode is stored in a manner similar to the 2 bits per pixel mode, but with an additional two planes for bit 2 and bit 3 of each pixel's palette index, expanding the tile data to 32 bytes.
<pre>
tile data (32 bytes)
54 32 01 00 54 32 F1 00 54 32 01 F0 54 32 F1 F0 04 02 01 00 F8 04 02 01 00 F8 04 02 00 00 F8 04
||
\/
plane 0 plane 1 plane 2 plane 3
7 bit 0 7 bit 0 7 bit 0 7 bit 0 full tile
---- ---- ---- ---- ---- ---- ---- ----
.1.1 .1.. = 54 ..22 ..2. = 32 .... ...4 = 01 .... .... = 00 .123.124
.1.1 .1.. = 54 ..22 ..2. = 32 4444 ...4 = F1 .... .... = 00 4567.124
.1.1 .1.. = 54 ..22 ..2. = 32 .... ...4 = 01 8888 .... = F0 89AB.124
.1.1 .1.. = 54 ..22 ..2. = 32 4444 ...4 = F1 8888 .... = F0 --\ CDEF.124
.... .1.. = 04 .... ..2. = 02 .... ...4 = 01 .... .... = 00 --/ .....124
1111 1... = F8 .... .2.. = 04 .... ..4. = 02 .... ...8 = 01 11111248
.... .... = 00 2222 2... = F8 .... .4.. = 04 .... ..8. = 02 2222248.
.... .... = 00 .... .... = 00 4444 4... = F8 .... .8.. = 04 444448..
</pre>
This format matches the one used by the Sega Master System and Game Gear family of consoles.
==== 4 bits per pixel, packed ====
Unlike the previous two formats, in the packed format each byte stores the complete palette index of two pixels - the high four bits store the left pixel, while the low four bits store the right pixel. Four such bytes make up a row of eight pixels from left to right.
<pre>
tile data (32 bytes)
01 23 01 24 45 67 01 24 89 AB 01 24 CD EF 01 24 00 00 01 24 11 11 12 48 22 22 24 80 44 44 48 00
||
\/
byte 0 1 2 3
bits 7-4 3-0 7-4 3-0 7-4 3-0 7-4 3-0
pixel 0 1 2 3 4 5 6 7 full tile
--- --- --- --- --- --- --- ---
. 1 = 01 2 3 = 23 . 1 = 01 2 4 = 24 .123.124 = 01 23 01 24
4 5 = 45 6 7 = 67 . 1 = 01 2 4 = 24 4567.124 = 45 67 01 24
8 9 = 89 A B = AB . 1 = 01 2 4 = 24 89AB.124 = 89 AB 01 24
C D = CD E F = EF . 1 = 01 2 4 = 24 --\ CDEF.124 = CD EF 01 24
. . = 00 . . = 00 . 1 = 01 2 4 = 24 --/ .....124 = 00 00 01 24
1 1 = 11 1 1 = 11 1 2 = 12 4 8 = 48 11111248 = 11 11 12 48
2 2 = 22 2 2 = 22 2 4 = 24 8 . = 80 2222248. = 22 22 24 80
4 4 = 44 4 4 = 44 4 8 = 48 . . = 00 444448.. = 44 44 48 00
</pre>
This format matches the one used by the Mega Drive console.
=== Palettes ===
The display system provides sixteen different palettes that can be used to color or shade tiles.
* Palettes 0-7 can be used for the two screens only;
* Palettes 8-15 can be used for both screens and sprites.
==== Mono ====
In ''mono'' modes, palettes are stored in I/O ports 0x20 through 0x3F. Each palette contains four three-bit entries, which are pointers into a global, four-bit shade lookup table:
<pre>
Palette Global shade LUT
1 ===========> 2 ==========================> 5
^ (0, 2, 4, 6) ^ (1, 3, 5, 7, 9, 11, 13, 15) ^
| | |
Palette index Value Displayed shade
</pre>
The shade value corresponds to the darkness of the pixel: shade 0 is the brightest, while shade 15 is the darkest.
==== Color ====
In ''color'' modes, palettes are stored as 16-bit words in memory addresses 0xFE00 through 0xFFFF, without additional lookup tables:
<pre>
Address
15 bit 8 7 bit 0
---- ---- ---- ----
1111 111p pppi iii.
| |||| |||
| |||+-+++-- Index in palette (0-15)
+--+++------- Palette number (0-15)
Data
15 bit 8 7 bit 0
---- ---- ---- ----
.... rrrr gggg bbbb
|||| |||| ||||
|||| |||| ++++- Blue (0-15)
|||| ++++------ Green (0-15)
++++------------ Red (0-15)
</pre>
In 2 bits per pixel color modes, palette entries 4 through 15 are not used.
==== Transparency ====
In two bit per pixel modes:
* Palettes 0-3 and 8-11 are ''opaque''. For these, index zero is treated as opaque.
* Palettes 4-7 and 12-15 are ''translucent''. For these, index zero is treated as transparent. This means that the color/shade value set to it is ignored, and only three distinct colors/shades can be used for tiles.
In four bit per pixel modes, all palettes are ''translucent''. Index zero is always treated as transparent, and fifteen different colors/shades can be used for tiles.
=== Background color ===
The background color is displayed if no ''opaque'' pixel from screens or sprites is drawn. This color is set in I/O port ''0x01'':
* In mono modes, it is set to an entry in the shade lookup table (0-7),
* In color modes, it is set to an entry in the color palette (0-255). Note that this allows you to use the first color (color zero) of any palette, which is normally ignored and assumed to be ''transparent''.
=== Screens ===
A screen is a layout of tiles. Each cell in a screen controls one 8x8 tile.
The display system can show two distinct screens simultaneously. It also supports hardware flipping of tiles, both horizontally and vertically.
The size of each screen is fixed at 32x32 cells or 256x256 pixels, while each cell is stored as a two-byte word:
<pre>
Address
15 bit 8 7 bit 0
---- ---- ---- ----
0bbb byyy yyxx xxx.
||| |||| |||| |||
||| |||| ||++-+++-- X coordinate (0-31)
||| |+++--++-------- Y coordinate (0-31)
+++-+--------------- Base address (from I/O port)
Data
15 bit 8 7 bit 0
---- ---- ---- ----
vhbp pppt tttt tttt
|||| |||| |||| ||||
|||| |||+--++++-++++- Tile index (0-511)
|||+-+++------------- Palette (0-15)
||+------------------ Tile bank (0-1) - color only
|+------------------- Horizontal flip
+-------------------- Vertical flip
</pre>
In ''color'' modes, the tile bank selects between tiles 0-511 and 512-1023.
=== Sprites ===
The display system can show up to 128 sprites at once.
Sprites are always drawn in front of Screen 1, but they can be drawn in front of or behind Screen 2.
Sprites are stored in a sprite table in the console's internal RAM. It consists of up to 128 four-byte entries, of which any sequential slice can be displayed:
<pre>
(Byte 1) (Byte 0)
15 bit 8 7 bit 0
---- ---- ---- ----
vhPi pppt tttt tttt
|||| |||| |||| ||||
|||| |||+--++++-++++- Tile index (0-511) - only tile bank 0
|||| +++------------- Palette (0-7) - mapped to screen palettes 8-15
|||+----------------- Window location - 0 = inside, 1 = outside
||+------------------ Priority - 0 = behind Screen 2, 1 = in front of Screen 2
|+------------------- Horizontal flip
+-------------------- Vertical flip
(Byte 2)
7 bit 0
---- ----
yyyy yyyy
|||| ||||
++++-++++- Y coordinate
(Byte 3)
7 bit 0
---- ----
xxxx xxxx
|||| ||||
++++-++++- X coordinate
</pre>
There is a sprite limit of 32 per scanline. This means that for each scanline, only the first 32 sprites will be drawn.
Note that this includes sprites obscured by windows or outside of visible X coordinates; this list is determined solely by the Y coordinate.
Between sprites themselves, earlier sprites in the list are always drawn on top of later sprites in the list.
=== Visibility priority ===
For display components, the visibility priority is as follows:
* Sprite 0, high priority
* Sprite 127, high priority
* Screen 2
* Sprite 0, low priority
* Sprite 127, low priority
* Screen 1
* Background color
=== Windows ===
Screen 2 and sprites can optionally have their drawing restricted within or outside of their specific rectangular windows.
Note that for sprites, the window is enabled globally (for all sprites), but each sprite can individually decide if it's rendered inside or outside of it.
=== Icons ===
The WonderSwan features six LCD segment icons which are displayed to the right<sup>(color)</sup> or below<sup>(mono)</sup> the main display. These are, as follows:
* Aux 3 - large circle,
* Aux 2 - medium circle,
* Aux 1 - small circle,
* Horizontal orientation,
* Vertical orientation,
* Sleep.
== Interrupts ==
The display circuit generates two interrupts of its own:
* Display Interrupt Line Match - when <code>Display Current Line</code> == <code>Display Interrupt Line</code>, at the beginning of said line.
* Display Vertical Blank - when <code>Display Current Line</code> == <code>144</code>, at the beginning of said line.
It also provides a timing source for the two Horizontal and Vertical Blank [[Timers]], which provide their own respective interrupts.
== I/O ports ==
{{Anchor|Display Control}}
=== Display Control ($00) ===
<pre>
7 bit 0
---- ----
..ow Ws21
|| ||||
|| |||+- Enable Screen 1 layer
|| ||+-- Enable Screen 2 layer
|| |+--- Enable Sprite layer
|| +---- Enable Sprite window
|+------ Enable Screen 2 window
+------- Screen 2 tiles are drawn (if window enabled):
0 = inside window,
1 = outside window.
</pre>
{{Anchor|Display Background}}
=== Display Background Color ($01) ===
<pre>
(mono) (color)
7 bit 0 7 bit 0
---- ---- ---- ----
.... .sss pppp iiii
||| |||| ||||
+++- Value |||| ++++- Index in palette (0-15)
(0-7) ++++------ Color palette (0-15)
</pre>
{{Anchor|Display Current Line}}
=== Display Current Line ($02 read) ===
The current line being drawn by the display.
Note that lines are sent to the display with a one-line delay. This matters for color palette or shade LUT manipulation; changing these values when <code>current line == 1</code> will actually affect line 0.
{{Anchor|Display Interrupt Line}}
=== Display Interrupt Line ($03) ===
The line to emit an interrupt on.
{{Anchor|Sprite Table Address}}
=== Sprite Table Address ($04) ===
<pre>
7 bit 0
---- ----
..Aa aaaa
|| ||||
|+-++++- Address (bits 9-13)
+------- Address (bit 14) - color only
</pre>
{{Anchor|Sprite Table First}}
=== Sprite Table First ($05) ===
<pre>
7 bit 0
---- ----
.iii iiii
||| ||||
+++-++++- Index of first sprite entry to draw (0-127)
</pre>
{{Anchor|Sprite Table Count}}
=== Sprite Table Count ($06) ===
<pre>
7 bit 0
---- ----
cccc cccc
|||| ||||
++++-++++- Count of sprite entries to draw (1-128)
</pre>
{{Anchor|Screen Address}}
=== Screen Address ($07) ===
<pre>
7 bit 0
---- ----
2222 1111
|||| ||||
|||| |+++- Screen 1 address (bits 11-13)
|||| +---- Screen 1 address (bit 14) - color only
|+++------ Screen 2 address (bits 11-13)
+--------- Screen 2 address (bit 14) - color only
</pre>
{{Anchor|Screen 2 Window}}
=== Screen 2 Window Left ($08) ===
=== Screen 2 Window Top ($09) ===
=== Screen 2 Window Right ($0A) ===
=== Screen 2 Window Bottom ($0B) ===
The X and Y coordinates of the Screen 2 window.
Note that all coordinates are inclusive; for example, for a 200x100 window in the top-left corner, the values should be set as follows:
* Left - 0,
* Top - 0,
* Right - 199,
* Bottom - 99.
{{Anchor|Sprite Window}}
=== Sprite Window Left ($0C) ===
=== Sprite Window Top ($0D) ===
=== Sprite Window Right ($0E) ===
=== Sprite Window Bottom ($0F) ===
{{Anchor|Screen Scroll}}
=== Screen 1 Scroll X ($10) ===
=== Screen 1 Scroll Y ($11) ===
=== Screen 2 Scroll X ($12) ===
=== Screen 2 Scroll Y ($13) ===
{{Anchor|LCD Control}}
=== LCD Control ($14) ===
<pre>
7 bit 0
---- ----
.... ..Ce
||
|+- LCD Enable: 0 = sleep, 1 = enabled
+-- Contrast (WSC): 0 = low, 1 = high
</pre>
{{Anchor|LCD Icon Control}}
=== LCD Icon Control ($15) ===
<pre>
7 bit 0
---- ----
..32 1hvs
|| ||||
|| |||+- Sleep
|| ||+-- Vertical orientation
|| |+--- Horizontal orientation
|| +---- Aux 1
|+------ Aux 2
+------- Aux 3
</pre>
{{Anchor|LCD Mono Shade LUT}}
=== LCD Mono Shade LUT ($1C-$1F) ===
<pre>
$1C $1D $1E $1F
7 bit 0 7 bit 0 7 bit 0 7 bit 0
---- ---- ---- ---- ---- ---- ---- ----
1111 0000 3333 2222 5555 4444 7777 6666
</pre>
{{Anchor|LCD Mono Palette}}
=== LCD Mono Palette 0..15 ($20, $21 .. $3E, $3F) ===
The monochrome palette is laid out as sixteen words:
<pre>
N+1 N
15 bit 8 7 bit 0
---- ---- ---- ----
.333 .222 .111 .000
||| ||| ||| |||
||| ||| ||| +++- Shade LUT index for color 0
||| ||| +++------ Shade LUT index for color 1
||| +++------------ Shade LUT index for color 2
+++----------------- Shade LUT index for color 3
</pre>
== Internal I/O ports ==
These I/O ports are said to be internal and not intended for use by commercial games.
{{Anchor|LCD Final Line}}
=== LCD Final Line ($16) ===
The final line preceding line counter restart and the beginning of active display. By default, this is set to 158, which equals 159 total lines per frame.
It is said setting this register to an odd value on SwanCrystal has an adverse effect to the LCD panel<ref>[http://daifukkat.su/docs/wsman/#REG_LCD_VTOTAL REG_LCD_VTOTAL - WSMan]</ref>, but the exact mechanism is unknown.
{{Anchor|LCD Back Porch Line}}
=== LCD Back Porch Line ($17, WSC only) ===
This port is available on the WonderSwan Color only - not the SwanCrystal!
The final line preceding the vertical back porch; by default, this should be set to 155.
The vertical back porch of the LCD is assumed to be 4 lines by some hardware, including IPS mods, as well as the official "TV Swan" capture device. Given that the first visible line is sent to the LCD on the display's line 1, this should be generally set to <code>LCD Final Line - 3</code>.
Conversely, it is said moving this value closer to vertical blank improves LCD visibility<ref>[http://daifukkat.su/docs/wsman/#REG_LCD_VSYNC REG_LCD_VSYNC - WSMan]</ref>, but the exact mechanism is unknown.
{{Anchor|LCD Status}}
=== LCD Status ($1A) ===
<pre>
7 bit 0
---- ----
...v vv.s
| || |
| || +- LCD sleep: 0 = no, 1 = sleep
| ||
| || Volume segments:
| |+--- Volume B (medium, high)
| +---- Volume A (low, high)
+------ Speaker
</pre>
=== TFT LCD Configuration ($70, $71, $72, $73, $74, $75, $76, $77 SwanCrystal only) ===
These eight bytes are read from internal EEPROM and configure unknown aspects of the console's TFT LCD panel.
They are only writable while the [[Boot ROM]] is unlocked - locking has the side effect of making them read-only.
== Notes ==
<references />
3200fa3b81e1c72640f0fcb3ddc13dfc621c8761
313
312
2024-07-13T06:25:40Z
Asie
351
/* Sprite Window Bottom ($0F) */ clarify
wikitext
text/x-wiki
The WonderSwan's display functionality generally consists of:
* a 224x144 display clocked at ~75.47 Hz by default, capable of displaying:
** up to sixteen distinct shades of gray
** 12-bit RGB444 color<sup>(color)</sup>
* two 32x32 background layers ("screens"), capable of displaying up to 512 (1024<sup>(color)</sup>) distinct tiles,
* a sprite layer, capable of displaying up to 128 8x8 sprites (up to 32 per line),
* six LCD icons to the bottom or right of the display, usable as additional indicators.
== Components ==
=== Tiles ===
The WonderSwan can display up to 512 distinct tiles at a time, with two bits of palette index information for every pixel.
The WonderSwan Color expands this to 1024 distinct tiles for background (with 512 remaining the limit for sprites), while also introducing modes with four bits of palette index information for every pixel.
==== 2 bits per pixel, planar ====
The tiles are stored in an interleaved planar format, with two bits total for every pixel. Odd bytes store the first plane (bit 0 of each pixel), while even bytes store the second plane (bit 1 of each pixel).
<pre>
tile data (16 bytes)
01 7C 01 FC 00 C0 18 D8 18 D8 00 C0 00 00 C0 00
||
\/
plane 0 plane 1
7 bit 0 7 bit 0 full tile
---- ---- ---- ----
.... ...1 = 01 .222 22.. = 7C .22222.1
.... ...1 = 01 2222 22.. = FC 222222.1
.... .... = 00 22.. .... = C0 22......
...1 1... = 18 22.2 2... = D8 --\ 22.33...
...1 1... = 18 22.2 2... = D8 --/ 22.33...
.... .... = 00 22.. .... = C0 22......
.... .... = 00 .... .... = 00 ........
11.. .... = C0 .... .... = 00 11......
</pre>
This matches the format used by the Game Boy.
==== 4 bits per pixel, planar ====
This mode is stored in a manner similar to the 2 bits per pixel mode, but with an additional two planes for bit 2 and bit 3 of each pixel's palette index, expanding the tile data to 32 bytes.
<pre>
tile data (32 bytes)
54 32 01 00 54 32 F1 00 54 32 01 F0 54 32 F1 F0 04 02 01 00 F8 04 02 01 00 F8 04 02 00 00 F8 04
||
\/
plane 0 plane 1 plane 2 plane 3
7 bit 0 7 bit 0 7 bit 0 7 bit 0 full tile
---- ---- ---- ---- ---- ---- ---- ----
.1.1 .1.. = 54 ..22 ..2. = 32 .... ...4 = 01 .... .... = 00 .123.124
.1.1 .1.. = 54 ..22 ..2. = 32 4444 ...4 = F1 .... .... = 00 4567.124
.1.1 .1.. = 54 ..22 ..2. = 32 .... ...4 = 01 8888 .... = F0 89AB.124
.1.1 .1.. = 54 ..22 ..2. = 32 4444 ...4 = F1 8888 .... = F0 --\ CDEF.124
.... .1.. = 04 .... ..2. = 02 .... ...4 = 01 .... .... = 00 --/ .....124
1111 1... = F8 .... .2.. = 04 .... ..4. = 02 .... ...8 = 01 11111248
.... .... = 00 2222 2... = F8 .... .4.. = 04 .... ..8. = 02 2222248.
.... .... = 00 .... .... = 00 4444 4... = F8 .... .8.. = 04 444448..
</pre>
This format matches the one used by the Sega Master System and Game Gear family of consoles.
==== 4 bits per pixel, packed ====
Unlike the previous two formats, in the packed format each byte stores the complete palette index of two pixels - the high four bits store the left pixel, while the low four bits store the right pixel. Four such bytes make up a row of eight pixels from left to right.
<pre>
tile data (32 bytes)
01 23 01 24 45 67 01 24 89 AB 01 24 CD EF 01 24 00 00 01 24 11 11 12 48 22 22 24 80 44 44 48 00
||
\/
byte 0 1 2 3
bits 7-4 3-0 7-4 3-0 7-4 3-0 7-4 3-0
pixel 0 1 2 3 4 5 6 7 full tile
--- --- --- --- --- --- --- ---
. 1 = 01 2 3 = 23 . 1 = 01 2 4 = 24 .123.124 = 01 23 01 24
4 5 = 45 6 7 = 67 . 1 = 01 2 4 = 24 4567.124 = 45 67 01 24
8 9 = 89 A B = AB . 1 = 01 2 4 = 24 89AB.124 = 89 AB 01 24
C D = CD E F = EF . 1 = 01 2 4 = 24 --\ CDEF.124 = CD EF 01 24
. . = 00 . . = 00 . 1 = 01 2 4 = 24 --/ .....124 = 00 00 01 24
1 1 = 11 1 1 = 11 1 2 = 12 4 8 = 48 11111248 = 11 11 12 48
2 2 = 22 2 2 = 22 2 4 = 24 8 . = 80 2222248. = 22 22 24 80
4 4 = 44 4 4 = 44 4 8 = 48 . . = 00 444448.. = 44 44 48 00
</pre>
This format matches the one used by the Mega Drive console.
=== Palettes ===
The display system provides sixteen different palettes that can be used to color or shade tiles.
* Palettes 0-7 can be used for the two screens only;
* Palettes 8-15 can be used for both screens and sprites.
==== Mono ====
In ''mono'' modes, palettes are stored in I/O ports 0x20 through 0x3F. Each palette contains four three-bit entries, which are pointers into a global, four-bit shade lookup table:
<pre>
Palette Global shade LUT
1 ===========> 2 ==========================> 5
^ (0, 2, 4, 6) ^ (1, 3, 5, 7, 9, 11, 13, 15) ^
| | |
Palette index Value Displayed shade
</pre>
The shade value corresponds to the darkness of the pixel: shade 0 is the brightest, while shade 15 is the darkest.
==== Color ====
In ''color'' modes, palettes are stored as 16-bit words in memory addresses 0xFE00 through 0xFFFF, without additional lookup tables:
<pre>
Address
15 bit 8 7 bit 0
---- ---- ---- ----
1111 111p pppi iii.
| |||| |||
| |||+-+++-- Index in palette (0-15)
+--+++------- Palette number (0-15)
Data
15 bit 8 7 bit 0
---- ---- ---- ----
.... rrrr gggg bbbb
|||| |||| ||||
|||| |||| ++++- Blue (0-15)
|||| ++++------ Green (0-15)
++++------------ Red (0-15)
</pre>
In 2 bits per pixel color modes, palette entries 4 through 15 are not used.
==== Transparency ====
In two bit per pixel modes:
* Palettes 0-3 and 8-11 are ''opaque''. For these, index zero is treated as opaque.
* Palettes 4-7 and 12-15 are ''translucent''. For these, index zero is treated as transparent. This means that the color/shade value set to it is ignored, and only three distinct colors/shades can be used for tiles.
In four bit per pixel modes, all palettes are ''translucent''. Index zero is always treated as transparent, and fifteen different colors/shades can be used for tiles.
=== Background color ===
The background color is displayed if no ''opaque'' pixel from screens or sprites is drawn. This color is set in I/O port ''0x01'':
* In mono modes, it is set to an entry in the shade lookup table (0-7),
* In color modes, it is set to an entry in the color palette (0-255). Note that this allows you to use the first color (color zero) of any palette, which is normally ignored and assumed to be ''transparent''.
=== Screens ===
A screen is a layout of tiles. Each cell in a screen controls one 8x8 tile.
The display system can show two distinct screens simultaneously. It also supports hardware flipping of tiles, both horizontally and vertically.
The size of each screen is fixed at 32x32 cells or 256x256 pixels, while each cell is stored as a two-byte word:
<pre>
Address
15 bit 8 7 bit 0
---- ---- ---- ----
0bbb byyy yyxx xxx.
||| |||| |||| |||
||| |||| ||++-+++-- X coordinate (0-31)
||| |+++--++-------- Y coordinate (0-31)
+++-+--------------- Base address (from I/O port)
Data
15 bit 8 7 bit 0
---- ---- ---- ----
vhbp pppt tttt tttt
|||| |||| |||| ||||
|||| |||+--++++-++++- Tile index (0-511)
|||+-+++------------- Palette (0-15)
||+------------------ Tile bank (0-1) - color only
|+------------------- Horizontal flip
+-------------------- Vertical flip
</pre>
In ''color'' modes, the tile bank selects between tiles 0-511 and 512-1023.
=== Sprites ===
The display system can show up to 128 sprites at once.
Sprites are always drawn in front of Screen 1, but they can be drawn in front of or behind Screen 2.
Sprites are stored in a sprite table in the console's internal RAM. It consists of up to 128 four-byte entries, of which any sequential slice can be displayed:
<pre>
(Byte 1) (Byte 0)
15 bit 8 7 bit 0
---- ---- ---- ----
vhPi pppt tttt tttt
|||| |||| |||| ||||
|||| |||+--++++-++++- Tile index (0-511) - only tile bank 0
|||| +++------------- Palette (0-7) - mapped to screen palettes 8-15
|||+----------------- Window location - 0 = inside, 1 = outside
||+------------------ Priority - 0 = behind Screen 2, 1 = in front of Screen 2
|+------------------- Horizontal flip
+-------------------- Vertical flip
(Byte 2)
7 bit 0
---- ----
yyyy yyyy
|||| ||||
++++-++++- Y coordinate
(Byte 3)
7 bit 0
---- ----
xxxx xxxx
|||| ||||
++++-++++- X coordinate
</pre>
There is a sprite limit of 32 per scanline. This means that for each scanline, only the first 32 sprites will be drawn.
Note that this includes sprites obscured by windows or outside of visible X coordinates; this list is determined solely by the Y coordinate.
Between sprites themselves, earlier sprites in the list are always drawn on top of later sprites in the list.
=== Visibility priority ===
For display components, the visibility priority is as follows:
* Sprite 0, high priority
* Sprite 127, high priority
* Screen 2
* Sprite 0, low priority
* Sprite 127, low priority
* Screen 1
* Background color
=== Windows ===
Screen 2 and sprites can optionally have their drawing restricted within or outside of their specific rectangular windows.
Note that for sprites, the window is enabled globally (for all sprites), but each sprite can individually decide if it's rendered inside or outside of it.
=== Icons ===
The WonderSwan features six LCD segment icons which are displayed to the right<sup>(color)</sup> or below<sup>(mono)</sup> the main display. These are, as follows:
* Aux 3 - large circle,
* Aux 2 - medium circle,
* Aux 1 - small circle,
* Horizontal orientation,
* Vertical orientation,
* Sleep.
== Interrupts ==
The display circuit generates two interrupts of its own:
* Display Interrupt Line Match - when <code>Display Current Line</code> == <code>Display Interrupt Line</code>, at the beginning of said line.
* Display Vertical Blank - when <code>Display Current Line</code> == <code>144</code>, at the beginning of said line.
It also provides a timing source for the two Horizontal and Vertical Blank [[Timers]], which provide their own respective interrupts.
== I/O ports ==
{{Anchor|Display Control}}
=== Display Control ($00) ===
<pre>
7 bit 0
---- ----
..ow Ws21
|| ||||
|| |||+- Enable Screen 1 layer
|| ||+-- Enable Screen 2 layer
|| |+--- Enable Sprite layer
|| +---- Enable Sprite window
|+------ Enable Screen 2 window
+------- Screen 2 tiles are drawn (if window enabled):
0 = inside window,
1 = outside window.
</pre>
{{Anchor|Display Background}}
=== Display Background Color ($01) ===
<pre>
(mono) (color)
7 bit 0 7 bit 0
---- ---- ---- ----
.... .sss pppp iiii
||| |||| ||||
+++- Value |||| ++++- Index in palette (0-15)
(0-7) ++++------ Color palette (0-15)
</pre>
{{Anchor|Display Current Line}}
=== Display Current Line ($02 read) ===
The current line being drawn by the display.
Note that lines are sent to the display with a one-line delay. This matters for color palette or shade LUT manipulation; changing these values when <code>current line == 1</code> will actually affect line 0.
{{Anchor|Display Interrupt Line}}
=== Display Interrupt Line ($03) ===
The line to emit an interrupt on.
{{Anchor|Sprite Table Address}}
=== Sprite Table Address ($04) ===
<pre>
7 bit 0
---- ----
..Aa aaaa
|| ||||
|+-++++- Address (bits 9-13)
+------- Address (bit 14) - color only
</pre>
{{Anchor|Sprite Table First}}
=== Sprite Table First ($05) ===
<pre>
7 bit 0
---- ----
.iii iiii
||| ||||
+++-++++- Index of first sprite entry to draw (0-127)
</pre>
{{Anchor|Sprite Table Count}}
=== Sprite Table Count ($06) ===
<pre>
7 bit 0
---- ----
cccc cccc
|||| ||||
++++-++++- Count of sprite entries to draw (1-128)
</pre>
{{Anchor|Screen Address}}
=== Screen Address ($07) ===
<pre>
7 bit 0
---- ----
2222 1111
|||| ||||
|||| |+++- Screen 1 address (bits 11-13)
|||| +---- Screen 1 address (bit 14) - color only
|+++------ Screen 2 address (bits 11-13)
+--------- Screen 2 address (bit 14) - color only
</pre>
{{Anchor|Screen 2 Window}}
=== Screen 2 Window Left ($08) ===
=== Screen 2 Window Top ($09) ===
=== Screen 2 Window Right ($0A) ===
=== Screen 2 Window Bottom ($0B) ===
The X and Y coordinates of the Screen 2 window.
Note that all coordinates are inclusive; for example, for a 200x100 window in the top-left corner, the values should be set as follows:
* Left - 0,
* Top - 0,
* Right - 199,
* Bottom - 99.
{{Anchor|Sprite Window}}
=== Sprite Window Left ($0C) ===
=== Sprite Window Top ($0D) ===
=== Sprite Window Right ($0E) ===
=== Sprite Window Bottom ($0F) ===
The X and Y coordinates of the Sprite window.
Note that all coordinates are inclusive.
{{Anchor|Screen Scroll}}
=== Screen 1 Scroll X ($10) ===
=== Screen 1 Scroll Y ($11) ===
=== Screen 2 Scroll X ($12) ===
=== Screen 2 Scroll Y ($13) ===
{{Anchor|LCD Control}}
=== LCD Control ($14) ===
<pre>
7 bit 0
---- ----
.... ..Ce
||
|+- LCD Enable: 0 = sleep, 1 = enabled
+-- Contrast (WSC): 0 = low, 1 = high
</pre>
{{Anchor|LCD Icon Control}}
=== LCD Icon Control ($15) ===
<pre>
7 bit 0
---- ----
..32 1hvs
|| ||||
|| |||+- Sleep
|| ||+-- Vertical orientation
|| |+--- Horizontal orientation
|| +---- Aux 1
|+------ Aux 2
+------- Aux 3
</pre>
{{Anchor|LCD Mono Shade LUT}}
=== LCD Mono Shade LUT ($1C-$1F) ===
<pre>
$1C $1D $1E $1F
7 bit 0 7 bit 0 7 bit 0 7 bit 0
---- ---- ---- ---- ---- ---- ---- ----
1111 0000 3333 2222 5555 4444 7777 6666
</pre>
{{Anchor|LCD Mono Palette}}
=== LCD Mono Palette 0..15 ($20, $21 .. $3E, $3F) ===
The monochrome palette is laid out as sixteen words:
<pre>
N+1 N
15 bit 8 7 bit 0
---- ---- ---- ----
.333 .222 .111 .000
||| ||| ||| |||
||| ||| ||| +++- Shade LUT index for color 0
||| ||| +++------ Shade LUT index for color 1
||| +++------------ Shade LUT index for color 2
+++----------------- Shade LUT index for color 3
</pre>
== Internal I/O ports ==
These I/O ports are said to be internal and not intended for use by commercial games.
{{Anchor|LCD Final Line}}
=== LCD Final Line ($16) ===
The final line preceding line counter restart and the beginning of active display. By default, this is set to 158, which equals 159 total lines per frame.
It is said setting this register to an odd value on SwanCrystal has an adverse effect to the LCD panel<ref>[http://daifukkat.su/docs/wsman/#REG_LCD_VTOTAL REG_LCD_VTOTAL - WSMan]</ref>, but the exact mechanism is unknown.
{{Anchor|LCD Back Porch Line}}
=== LCD Back Porch Line ($17, WSC only) ===
This port is available on the WonderSwan Color only - not the SwanCrystal!
The final line preceding the vertical back porch; by default, this should be set to 155.
The vertical back porch of the LCD is assumed to be 4 lines by some hardware, including IPS mods, as well as the official "TV Swan" capture device. Given that the first visible line is sent to the LCD on the display's line 1, this should be generally set to <code>LCD Final Line - 3</code>.
Conversely, it is said moving this value closer to vertical blank improves LCD visibility<ref>[http://daifukkat.su/docs/wsman/#REG_LCD_VSYNC REG_LCD_VSYNC - WSMan]</ref>, but the exact mechanism is unknown.
{{Anchor|LCD Status}}
=== LCD Status ($1A) ===
<pre>
7 bit 0
---- ----
...v vv.s
| || |
| || +- LCD sleep: 0 = no, 1 = sleep
| ||
| || Volume segments:
| |+--- Volume B (medium, high)
| +---- Volume A (low, high)
+------ Speaker
</pre>
=== TFT LCD Configuration ($70, $71, $72, $73, $74, $75, $76, $77 SwanCrystal only) ===
These eight bytes are read from internal EEPROM and configure unknown aspects of the console's TFT LCD panel.
They are only writable while the [[Boot ROM]] is unlocked - locking has the side effect of making them read-only.
== Notes ==
<references />
47e0a45fd4bfc6907c6d40ae7361ed01d82187c5
314
313
2024-07-13T06:26:39Z
Asie
351
/* Screen 1 Scroll Y ($11) */ clarify
wikitext
text/x-wiki
The WonderSwan's display functionality generally consists of:
* a 224x144 display clocked at ~75.47 Hz by default, capable of displaying:
** up to sixteen distinct shades of gray
** 12-bit RGB444 color<sup>(color)</sup>
* two 32x32 background layers ("screens"), capable of displaying up to 512 (1024<sup>(color)</sup>) distinct tiles,
* a sprite layer, capable of displaying up to 128 8x8 sprites (up to 32 per line),
* six LCD icons to the bottom or right of the display, usable as additional indicators.
== Components ==
=== Tiles ===
The WonderSwan can display up to 512 distinct tiles at a time, with two bits of palette index information for every pixel.
The WonderSwan Color expands this to 1024 distinct tiles for background (with 512 remaining the limit for sprites), while also introducing modes with four bits of palette index information for every pixel.
==== 2 bits per pixel, planar ====
The tiles are stored in an interleaved planar format, with two bits total for every pixel. Odd bytes store the first plane (bit 0 of each pixel), while even bytes store the second plane (bit 1 of each pixel).
<pre>
tile data (16 bytes)
01 7C 01 FC 00 C0 18 D8 18 D8 00 C0 00 00 C0 00
||
\/
plane 0 plane 1
7 bit 0 7 bit 0 full tile
---- ---- ---- ----
.... ...1 = 01 .222 22.. = 7C .22222.1
.... ...1 = 01 2222 22.. = FC 222222.1
.... .... = 00 22.. .... = C0 22......
...1 1... = 18 22.2 2... = D8 --\ 22.33...
...1 1... = 18 22.2 2... = D8 --/ 22.33...
.... .... = 00 22.. .... = C0 22......
.... .... = 00 .... .... = 00 ........
11.. .... = C0 .... .... = 00 11......
</pre>
This matches the format used by the Game Boy.
==== 4 bits per pixel, planar ====
This mode is stored in a manner similar to the 2 bits per pixel mode, but with an additional two planes for bit 2 and bit 3 of each pixel's palette index, expanding the tile data to 32 bytes.
<pre>
tile data (32 bytes)
54 32 01 00 54 32 F1 00 54 32 01 F0 54 32 F1 F0 04 02 01 00 F8 04 02 01 00 F8 04 02 00 00 F8 04
||
\/
plane 0 plane 1 plane 2 plane 3
7 bit 0 7 bit 0 7 bit 0 7 bit 0 full tile
---- ---- ---- ---- ---- ---- ---- ----
.1.1 .1.. = 54 ..22 ..2. = 32 .... ...4 = 01 .... .... = 00 .123.124
.1.1 .1.. = 54 ..22 ..2. = 32 4444 ...4 = F1 .... .... = 00 4567.124
.1.1 .1.. = 54 ..22 ..2. = 32 .... ...4 = 01 8888 .... = F0 89AB.124
.1.1 .1.. = 54 ..22 ..2. = 32 4444 ...4 = F1 8888 .... = F0 --\ CDEF.124
.... .1.. = 04 .... ..2. = 02 .... ...4 = 01 .... .... = 00 --/ .....124
1111 1... = F8 .... .2.. = 04 .... ..4. = 02 .... ...8 = 01 11111248
.... .... = 00 2222 2... = F8 .... .4.. = 04 .... ..8. = 02 2222248.
.... .... = 00 .... .... = 00 4444 4... = F8 .... .8.. = 04 444448..
</pre>
This format matches the one used by the Sega Master System and Game Gear family of consoles.
==== 4 bits per pixel, packed ====
Unlike the previous two formats, in the packed format each byte stores the complete palette index of two pixels - the high four bits store the left pixel, while the low four bits store the right pixel. Four such bytes make up a row of eight pixels from left to right.
<pre>
tile data (32 bytes)
01 23 01 24 45 67 01 24 89 AB 01 24 CD EF 01 24 00 00 01 24 11 11 12 48 22 22 24 80 44 44 48 00
||
\/
byte 0 1 2 3
bits 7-4 3-0 7-4 3-0 7-4 3-0 7-4 3-0
pixel 0 1 2 3 4 5 6 7 full tile
--- --- --- --- --- --- --- ---
. 1 = 01 2 3 = 23 . 1 = 01 2 4 = 24 .123.124 = 01 23 01 24
4 5 = 45 6 7 = 67 . 1 = 01 2 4 = 24 4567.124 = 45 67 01 24
8 9 = 89 A B = AB . 1 = 01 2 4 = 24 89AB.124 = 89 AB 01 24
C D = CD E F = EF . 1 = 01 2 4 = 24 --\ CDEF.124 = CD EF 01 24
. . = 00 . . = 00 . 1 = 01 2 4 = 24 --/ .....124 = 00 00 01 24
1 1 = 11 1 1 = 11 1 2 = 12 4 8 = 48 11111248 = 11 11 12 48
2 2 = 22 2 2 = 22 2 4 = 24 8 . = 80 2222248. = 22 22 24 80
4 4 = 44 4 4 = 44 4 8 = 48 . . = 00 444448.. = 44 44 48 00
</pre>
This format matches the one used by the Mega Drive console.
=== Palettes ===
The display system provides sixteen different palettes that can be used to color or shade tiles.
* Palettes 0-7 can be used for the two screens only;
* Palettes 8-15 can be used for both screens and sprites.
==== Mono ====
In ''mono'' modes, palettes are stored in I/O ports 0x20 through 0x3F. Each palette contains four three-bit entries, which are pointers into a global, four-bit shade lookup table:
<pre>
Palette Global shade LUT
1 ===========> 2 ==========================> 5
^ (0, 2, 4, 6) ^ (1, 3, 5, 7, 9, 11, 13, 15) ^
| | |
Palette index Value Displayed shade
</pre>
The shade value corresponds to the darkness of the pixel: shade 0 is the brightest, while shade 15 is the darkest.
==== Color ====
In ''color'' modes, palettes are stored as 16-bit words in memory addresses 0xFE00 through 0xFFFF, without additional lookup tables:
<pre>
Address
15 bit 8 7 bit 0
---- ---- ---- ----
1111 111p pppi iii.
| |||| |||
| |||+-+++-- Index in palette (0-15)
+--+++------- Palette number (0-15)
Data
15 bit 8 7 bit 0
---- ---- ---- ----
.... rrrr gggg bbbb
|||| |||| ||||
|||| |||| ++++- Blue (0-15)
|||| ++++------ Green (0-15)
++++------------ Red (0-15)
</pre>
In 2 bits per pixel color modes, palette entries 4 through 15 are not used.
==== Transparency ====
In two bit per pixel modes:
* Palettes 0-3 and 8-11 are ''opaque''. For these, index zero is treated as opaque.
* Palettes 4-7 and 12-15 are ''translucent''. For these, index zero is treated as transparent. This means that the color/shade value set to it is ignored, and only three distinct colors/shades can be used for tiles.
In four bit per pixel modes, all palettes are ''translucent''. Index zero is always treated as transparent, and fifteen different colors/shades can be used for tiles.
=== Background color ===
The background color is displayed if no ''opaque'' pixel from screens or sprites is drawn. This color is set in I/O port ''0x01'':
* In mono modes, it is set to an entry in the shade lookup table (0-7),
* In color modes, it is set to an entry in the color palette (0-255). Note that this allows you to use the first color (color zero) of any palette, which is normally ignored and assumed to be ''transparent''.
=== Screens ===
A screen is a layout of tiles. Each cell in a screen controls one 8x8 tile.
The display system can show two distinct screens simultaneously. It also supports hardware flipping of tiles, both horizontally and vertically.
The size of each screen is fixed at 32x32 cells or 256x256 pixels, while each cell is stored as a two-byte word:
<pre>
Address
15 bit 8 7 bit 0
---- ---- ---- ----
0bbb byyy yyxx xxx.
||| |||| |||| |||
||| |||| ||++-+++-- X coordinate (0-31)
||| |+++--++-------- Y coordinate (0-31)
+++-+--------------- Base address (from I/O port)
Data
15 bit 8 7 bit 0
---- ---- ---- ----
vhbp pppt tttt tttt
|||| |||| |||| ||||
|||| |||+--++++-++++- Tile index (0-511)
|||+-+++------------- Palette (0-15)
||+------------------ Tile bank (0-1) - color only
|+------------------- Horizontal flip
+-------------------- Vertical flip
</pre>
In ''color'' modes, the tile bank selects between tiles 0-511 and 512-1023.
=== Sprites ===
The display system can show up to 128 sprites at once.
Sprites are always drawn in front of Screen 1, but they can be drawn in front of or behind Screen 2.
Sprites are stored in a sprite table in the console's internal RAM. It consists of up to 128 four-byte entries, of which any sequential slice can be displayed:
<pre>
(Byte 1) (Byte 0)
15 bit 8 7 bit 0
---- ---- ---- ----
vhPi pppt tttt tttt
|||| |||| |||| ||||
|||| |||+--++++-++++- Tile index (0-511) - only tile bank 0
|||| +++------------- Palette (0-7) - mapped to screen palettes 8-15
|||+----------------- Window location - 0 = inside, 1 = outside
||+------------------ Priority - 0 = behind Screen 2, 1 = in front of Screen 2
|+------------------- Horizontal flip
+-------------------- Vertical flip
(Byte 2)
7 bit 0
---- ----
yyyy yyyy
|||| ||||
++++-++++- Y coordinate
(Byte 3)
7 bit 0
---- ----
xxxx xxxx
|||| ||||
++++-++++- X coordinate
</pre>
There is a sprite limit of 32 per scanline. This means that for each scanline, only the first 32 sprites will be drawn.
Note that this includes sprites obscured by windows or outside of visible X coordinates; this list is determined solely by the Y coordinate.
Between sprites themselves, earlier sprites in the list are always drawn on top of later sprites in the list.
=== Visibility priority ===
For display components, the visibility priority is as follows:
* Sprite 0, high priority
* Sprite 127, high priority
* Screen 2
* Sprite 0, low priority
* Sprite 127, low priority
* Screen 1
* Background color
=== Windows ===
Screen 2 and sprites can optionally have their drawing restricted within or outside of their specific rectangular windows.
Note that for sprites, the window is enabled globally (for all sprites), but each sprite can individually decide if it's rendered inside or outside of it.
=== Icons ===
The WonderSwan features six LCD segment icons which are displayed to the right<sup>(color)</sup> or below<sup>(mono)</sup> the main display. These are, as follows:
* Aux 3 - large circle,
* Aux 2 - medium circle,
* Aux 1 - small circle,
* Horizontal orientation,
* Vertical orientation,
* Sleep.
== Interrupts ==
The display circuit generates two interrupts of its own:
* Display Interrupt Line Match - when <code>Display Current Line</code> == <code>Display Interrupt Line</code>, at the beginning of said line.
* Display Vertical Blank - when <code>Display Current Line</code> == <code>144</code>, at the beginning of said line.
It also provides a timing source for the two Horizontal and Vertical Blank [[Timers]], which provide their own respective interrupts.
== I/O ports ==
{{Anchor|Display Control}}
=== Display Control ($00) ===
<pre>
7 bit 0
---- ----
..ow Ws21
|| ||||
|| |||+- Enable Screen 1 layer
|| ||+-- Enable Screen 2 layer
|| |+--- Enable Sprite layer
|| +---- Enable Sprite window
|+------ Enable Screen 2 window
+------- Screen 2 tiles are drawn (if window enabled):
0 = inside window,
1 = outside window.
</pre>
{{Anchor|Display Background}}
=== Display Background Color ($01) ===
<pre>
(mono) (color)
7 bit 0 7 bit 0
---- ---- ---- ----
.... .sss pppp iiii
||| |||| ||||
+++- Value |||| ++++- Index in palette (0-15)
(0-7) ++++------ Color palette (0-15)
</pre>
{{Anchor|Display Current Line}}
=== Display Current Line ($02 read) ===
The current line being drawn by the display.
Note that lines are sent to the display with a one-line delay. This matters for color palette or shade LUT manipulation; changing these values when <code>current line == 1</code> will actually affect line 0.
{{Anchor|Display Interrupt Line}}
=== Display Interrupt Line ($03) ===
The line to emit an interrupt on.
{{Anchor|Sprite Table Address}}
=== Sprite Table Address ($04) ===
<pre>
7 bit 0
---- ----
..Aa aaaa
|| ||||
|+-++++- Address (bits 9-13)
+------- Address (bit 14) - color only
</pre>
{{Anchor|Sprite Table First}}
=== Sprite Table First ($05) ===
<pre>
7 bit 0
---- ----
.iii iiii
||| ||||
+++-++++- Index of first sprite entry to draw (0-127)
</pre>
{{Anchor|Sprite Table Count}}
=== Sprite Table Count ($06) ===
<pre>
7 bit 0
---- ----
cccc cccc
|||| ||||
++++-++++- Count of sprite entries to draw (1-128)
</pre>
{{Anchor|Screen Address}}
=== Screen Address ($07) ===
<pre>
7 bit 0
---- ----
2222 1111
|||| ||||
|||| |+++- Screen 1 address (bits 11-13)
|||| +---- Screen 1 address (bit 14) - color only
|+++------ Screen 2 address (bits 11-13)
+--------- Screen 2 address (bit 14) - color only
</pre>
{{Anchor|Screen 2 Window}}
=== Screen 2 Window Left ($08) ===
=== Screen 2 Window Top ($09) ===
=== Screen 2 Window Right ($0A) ===
=== Screen 2 Window Bottom ($0B) ===
The X and Y coordinates of the Screen 2 window.
Note that all coordinates are inclusive; for example, for a 200x100 window in the top-left corner, the values should be set as follows:
* Left - 0,
* Top - 0,
* Right - 199,
* Bottom - 99.
{{Anchor|Sprite Window}}
=== Sprite Window Left ($0C) ===
=== Sprite Window Top ($0D) ===
=== Sprite Window Right ($0E) ===
=== Sprite Window Bottom ($0F) ===
The X and Y coordinates of the Sprite window.
Note that all coordinates are inclusive.
{{Anchor|Screen Scroll}}
=== Screen 1 Scroll X ($10) ===
=== Screen 1 Scroll Y ($11) ===
The X and Y coordinates that Screen 1 is scrolled by.
For example, setting Scroll X to 24 and Scroll Y to 8 will omit, in 8x8 tile units, the first three rows and the first two columns of the 32x32 screen.
=== Screen 2 Scroll X ($12) ===
=== Screen 2 Scroll Y ($13) ===
{{Anchor|LCD Control}}
=== LCD Control ($14) ===
<pre>
7 bit 0
---- ----
.... ..Ce
||
|+- LCD Enable: 0 = sleep, 1 = enabled
+-- Contrast (WSC): 0 = low, 1 = high
</pre>
{{Anchor|LCD Icon Control}}
=== LCD Icon Control ($15) ===
<pre>
7 bit 0
---- ----
..32 1hvs
|| ||||
|| |||+- Sleep
|| ||+-- Vertical orientation
|| |+--- Horizontal orientation
|| +---- Aux 1
|+------ Aux 2
+------- Aux 3
</pre>
{{Anchor|LCD Mono Shade LUT}}
=== LCD Mono Shade LUT ($1C-$1F) ===
<pre>
$1C $1D $1E $1F
7 bit 0 7 bit 0 7 bit 0 7 bit 0
---- ---- ---- ---- ---- ---- ---- ----
1111 0000 3333 2222 5555 4444 7777 6666
</pre>
{{Anchor|LCD Mono Palette}}
=== LCD Mono Palette 0..15 ($20, $21 .. $3E, $3F) ===
The monochrome palette is laid out as sixteen words:
<pre>
N+1 N
15 bit 8 7 bit 0
---- ---- ---- ----
.333 .222 .111 .000
||| ||| ||| |||
||| ||| ||| +++- Shade LUT index for color 0
||| ||| +++------ Shade LUT index for color 1
||| +++------------ Shade LUT index for color 2
+++----------------- Shade LUT index for color 3
</pre>
== Internal I/O ports ==
These I/O ports are said to be internal and not intended for use by commercial games.
{{Anchor|LCD Final Line}}
=== LCD Final Line ($16) ===
The final line preceding line counter restart and the beginning of active display. By default, this is set to 158, which equals 159 total lines per frame.
It is said setting this register to an odd value on SwanCrystal has an adverse effect to the LCD panel<ref>[http://daifukkat.su/docs/wsman/#REG_LCD_VTOTAL REG_LCD_VTOTAL - WSMan]</ref>, but the exact mechanism is unknown.
{{Anchor|LCD Back Porch Line}}
=== LCD Back Porch Line ($17, WSC only) ===
This port is available on the WonderSwan Color only - not the SwanCrystal!
The final line preceding the vertical back porch; by default, this should be set to 155.
The vertical back porch of the LCD is assumed to be 4 lines by some hardware, including IPS mods, as well as the official "TV Swan" capture device. Given that the first visible line is sent to the LCD on the display's line 1, this should be generally set to <code>LCD Final Line - 3</code>.
Conversely, it is said moving this value closer to vertical blank improves LCD visibility<ref>[http://daifukkat.su/docs/wsman/#REG_LCD_VSYNC REG_LCD_VSYNC - WSMan]</ref>, but the exact mechanism is unknown.
{{Anchor|LCD Status}}
=== LCD Status ($1A) ===
<pre>
7 bit 0
---- ----
...v vv.s
| || |
| || +- LCD sleep: 0 = no, 1 = sleep
| ||
| || Volume segments:
| |+--- Volume B (medium, high)
| +---- Volume A (low, high)
+------ Speaker
</pre>
=== TFT LCD Configuration ($70, $71, $72, $73, $74, $75, $76, $77 SwanCrystal only) ===
These eight bytes are read from internal EEPROM and configure unknown aspects of the console's TFT LCD panel.
They are only writable while the [[Boot ROM]] is unlocked - locking has the side effect of making them read-only.
== Notes ==
<references />
0b94516aedc37802b99bd1edeb10556ed57454ff
315
314
2024-07-13T06:26:47Z
Asie
351
/* Screen 2 Scroll Y ($13) */ clarify
wikitext
text/x-wiki
The WonderSwan's display functionality generally consists of:
* a 224x144 display clocked at ~75.47 Hz by default, capable of displaying:
** up to sixteen distinct shades of gray
** 12-bit RGB444 color<sup>(color)</sup>
* two 32x32 background layers ("screens"), capable of displaying up to 512 (1024<sup>(color)</sup>) distinct tiles,
* a sprite layer, capable of displaying up to 128 8x8 sprites (up to 32 per line),
* six LCD icons to the bottom or right of the display, usable as additional indicators.
== Components ==
=== Tiles ===
The WonderSwan can display up to 512 distinct tiles at a time, with two bits of palette index information for every pixel.
The WonderSwan Color expands this to 1024 distinct tiles for background (with 512 remaining the limit for sprites), while also introducing modes with four bits of palette index information for every pixel.
==== 2 bits per pixel, planar ====
The tiles are stored in an interleaved planar format, with two bits total for every pixel. Odd bytes store the first plane (bit 0 of each pixel), while even bytes store the second plane (bit 1 of each pixel).
<pre>
tile data (16 bytes)
01 7C 01 FC 00 C0 18 D8 18 D8 00 C0 00 00 C0 00
||
\/
plane 0 plane 1
7 bit 0 7 bit 0 full tile
---- ---- ---- ----
.... ...1 = 01 .222 22.. = 7C .22222.1
.... ...1 = 01 2222 22.. = FC 222222.1
.... .... = 00 22.. .... = C0 22......
...1 1... = 18 22.2 2... = D8 --\ 22.33...
...1 1... = 18 22.2 2... = D8 --/ 22.33...
.... .... = 00 22.. .... = C0 22......
.... .... = 00 .... .... = 00 ........
11.. .... = C0 .... .... = 00 11......
</pre>
This matches the format used by the Game Boy.
==== 4 bits per pixel, planar ====
This mode is stored in a manner similar to the 2 bits per pixel mode, but with an additional two planes for bit 2 and bit 3 of each pixel's palette index, expanding the tile data to 32 bytes.
<pre>
tile data (32 bytes)
54 32 01 00 54 32 F1 00 54 32 01 F0 54 32 F1 F0 04 02 01 00 F8 04 02 01 00 F8 04 02 00 00 F8 04
||
\/
plane 0 plane 1 plane 2 plane 3
7 bit 0 7 bit 0 7 bit 0 7 bit 0 full tile
---- ---- ---- ---- ---- ---- ---- ----
.1.1 .1.. = 54 ..22 ..2. = 32 .... ...4 = 01 .... .... = 00 .123.124
.1.1 .1.. = 54 ..22 ..2. = 32 4444 ...4 = F1 .... .... = 00 4567.124
.1.1 .1.. = 54 ..22 ..2. = 32 .... ...4 = 01 8888 .... = F0 89AB.124
.1.1 .1.. = 54 ..22 ..2. = 32 4444 ...4 = F1 8888 .... = F0 --\ CDEF.124
.... .1.. = 04 .... ..2. = 02 .... ...4 = 01 .... .... = 00 --/ .....124
1111 1... = F8 .... .2.. = 04 .... ..4. = 02 .... ...8 = 01 11111248
.... .... = 00 2222 2... = F8 .... .4.. = 04 .... ..8. = 02 2222248.
.... .... = 00 .... .... = 00 4444 4... = F8 .... .8.. = 04 444448..
</pre>
This format matches the one used by the Sega Master System and Game Gear family of consoles.
==== 4 bits per pixel, packed ====
Unlike the previous two formats, in the packed format each byte stores the complete palette index of two pixels - the high four bits store the left pixel, while the low four bits store the right pixel. Four such bytes make up a row of eight pixels from left to right.
<pre>
tile data (32 bytes)
01 23 01 24 45 67 01 24 89 AB 01 24 CD EF 01 24 00 00 01 24 11 11 12 48 22 22 24 80 44 44 48 00
||
\/
byte 0 1 2 3
bits 7-4 3-0 7-4 3-0 7-4 3-0 7-4 3-0
pixel 0 1 2 3 4 5 6 7 full tile
--- --- --- --- --- --- --- ---
. 1 = 01 2 3 = 23 . 1 = 01 2 4 = 24 .123.124 = 01 23 01 24
4 5 = 45 6 7 = 67 . 1 = 01 2 4 = 24 4567.124 = 45 67 01 24
8 9 = 89 A B = AB . 1 = 01 2 4 = 24 89AB.124 = 89 AB 01 24
C D = CD E F = EF . 1 = 01 2 4 = 24 --\ CDEF.124 = CD EF 01 24
. . = 00 . . = 00 . 1 = 01 2 4 = 24 --/ .....124 = 00 00 01 24
1 1 = 11 1 1 = 11 1 2 = 12 4 8 = 48 11111248 = 11 11 12 48
2 2 = 22 2 2 = 22 2 4 = 24 8 . = 80 2222248. = 22 22 24 80
4 4 = 44 4 4 = 44 4 8 = 48 . . = 00 444448.. = 44 44 48 00
</pre>
This format matches the one used by the Mega Drive console.
=== Palettes ===
The display system provides sixteen different palettes that can be used to color or shade tiles.
* Palettes 0-7 can be used for the two screens only;
* Palettes 8-15 can be used for both screens and sprites.
==== Mono ====
In ''mono'' modes, palettes are stored in I/O ports 0x20 through 0x3F. Each palette contains four three-bit entries, which are pointers into a global, four-bit shade lookup table:
<pre>
Palette Global shade LUT
1 ===========> 2 ==========================> 5
^ (0, 2, 4, 6) ^ (1, 3, 5, 7, 9, 11, 13, 15) ^
| | |
Palette index Value Displayed shade
</pre>
The shade value corresponds to the darkness of the pixel: shade 0 is the brightest, while shade 15 is the darkest.
==== Color ====
In ''color'' modes, palettes are stored as 16-bit words in memory addresses 0xFE00 through 0xFFFF, without additional lookup tables:
<pre>
Address
15 bit 8 7 bit 0
---- ---- ---- ----
1111 111p pppi iii.
| |||| |||
| |||+-+++-- Index in palette (0-15)
+--+++------- Palette number (0-15)
Data
15 bit 8 7 bit 0
---- ---- ---- ----
.... rrrr gggg bbbb
|||| |||| ||||
|||| |||| ++++- Blue (0-15)
|||| ++++------ Green (0-15)
++++------------ Red (0-15)
</pre>
In 2 bits per pixel color modes, palette entries 4 through 15 are not used.
==== Transparency ====
In two bit per pixel modes:
* Palettes 0-3 and 8-11 are ''opaque''. For these, index zero is treated as opaque.
* Palettes 4-7 and 12-15 are ''translucent''. For these, index zero is treated as transparent. This means that the color/shade value set to it is ignored, and only three distinct colors/shades can be used for tiles.
In four bit per pixel modes, all palettes are ''translucent''. Index zero is always treated as transparent, and fifteen different colors/shades can be used for tiles.
=== Background color ===
The background color is displayed if no ''opaque'' pixel from screens or sprites is drawn. This color is set in I/O port ''0x01'':
* In mono modes, it is set to an entry in the shade lookup table (0-7),
* In color modes, it is set to an entry in the color palette (0-255). Note that this allows you to use the first color (color zero) of any palette, which is normally ignored and assumed to be ''transparent''.
=== Screens ===
A screen is a layout of tiles. Each cell in a screen controls one 8x8 tile.
The display system can show two distinct screens simultaneously. It also supports hardware flipping of tiles, both horizontally and vertically.
The size of each screen is fixed at 32x32 cells or 256x256 pixels, while each cell is stored as a two-byte word:
<pre>
Address
15 bit 8 7 bit 0
---- ---- ---- ----
0bbb byyy yyxx xxx.
||| |||| |||| |||
||| |||| ||++-+++-- X coordinate (0-31)
||| |+++--++-------- Y coordinate (0-31)
+++-+--------------- Base address (from I/O port)
Data
15 bit 8 7 bit 0
---- ---- ---- ----
vhbp pppt tttt tttt
|||| |||| |||| ||||
|||| |||+--++++-++++- Tile index (0-511)
|||+-+++------------- Palette (0-15)
||+------------------ Tile bank (0-1) - color only
|+------------------- Horizontal flip
+-------------------- Vertical flip
</pre>
In ''color'' modes, the tile bank selects between tiles 0-511 and 512-1023.
=== Sprites ===
The display system can show up to 128 sprites at once.
Sprites are always drawn in front of Screen 1, but they can be drawn in front of or behind Screen 2.
Sprites are stored in a sprite table in the console's internal RAM. It consists of up to 128 four-byte entries, of which any sequential slice can be displayed:
<pre>
(Byte 1) (Byte 0)
15 bit 8 7 bit 0
---- ---- ---- ----
vhPi pppt tttt tttt
|||| |||| |||| ||||
|||| |||+--++++-++++- Tile index (0-511) - only tile bank 0
|||| +++------------- Palette (0-7) - mapped to screen palettes 8-15
|||+----------------- Window location - 0 = inside, 1 = outside
||+------------------ Priority - 0 = behind Screen 2, 1 = in front of Screen 2
|+------------------- Horizontal flip
+-------------------- Vertical flip
(Byte 2)
7 bit 0
---- ----
yyyy yyyy
|||| ||||
++++-++++- Y coordinate
(Byte 3)
7 bit 0
---- ----
xxxx xxxx
|||| ||||
++++-++++- X coordinate
</pre>
There is a sprite limit of 32 per scanline. This means that for each scanline, only the first 32 sprites will be drawn.
Note that this includes sprites obscured by windows or outside of visible X coordinates; this list is determined solely by the Y coordinate.
Between sprites themselves, earlier sprites in the list are always drawn on top of later sprites in the list.
=== Visibility priority ===
For display components, the visibility priority is as follows:
* Sprite 0, high priority
* Sprite 127, high priority
* Screen 2
* Sprite 0, low priority
* Sprite 127, low priority
* Screen 1
* Background color
=== Windows ===
Screen 2 and sprites can optionally have their drawing restricted within or outside of their specific rectangular windows.
Note that for sprites, the window is enabled globally (for all sprites), but each sprite can individually decide if it's rendered inside or outside of it.
=== Icons ===
The WonderSwan features six LCD segment icons which are displayed to the right<sup>(color)</sup> or below<sup>(mono)</sup> the main display. These are, as follows:
* Aux 3 - large circle,
* Aux 2 - medium circle,
* Aux 1 - small circle,
* Horizontal orientation,
* Vertical orientation,
* Sleep.
== Interrupts ==
The display circuit generates two interrupts of its own:
* Display Interrupt Line Match - when <code>Display Current Line</code> == <code>Display Interrupt Line</code>, at the beginning of said line.
* Display Vertical Blank - when <code>Display Current Line</code> == <code>144</code>, at the beginning of said line.
It also provides a timing source for the two Horizontal and Vertical Blank [[Timers]], which provide their own respective interrupts.
== I/O ports ==
{{Anchor|Display Control}}
=== Display Control ($00) ===
<pre>
7 bit 0
---- ----
..ow Ws21
|| ||||
|| |||+- Enable Screen 1 layer
|| ||+-- Enable Screen 2 layer
|| |+--- Enable Sprite layer
|| +---- Enable Sprite window
|+------ Enable Screen 2 window
+------- Screen 2 tiles are drawn (if window enabled):
0 = inside window,
1 = outside window.
</pre>
{{Anchor|Display Background}}
=== Display Background Color ($01) ===
<pre>
(mono) (color)
7 bit 0 7 bit 0
---- ---- ---- ----
.... .sss pppp iiii
||| |||| ||||
+++- Value |||| ++++- Index in palette (0-15)
(0-7) ++++------ Color palette (0-15)
</pre>
{{Anchor|Display Current Line}}
=== Display Current Line ($02 read) ===
The current line being drawn by the display.
Note that lines are sent to the display with a one-line delay. This matters for color palette or shade LUT manipulation; changing these values when <code>current line == 1</code> will actually affect line 0.
{{Anchor|Display Interrupt Line}}
=== Display Interrupt Line ($03) ===
The line to emit an interrupt on.
{{Anchor|Sprite Table Address}}
=== Sprite Table Address ($04) ===
<pre>
7 bit 0
---- ----
..Aa aaaa
|| ||||
|+-++++- Address (bits 9-13)
+------- Address (bit 14) - color only
</pre>
{{Anchor|Sprite Table First}}
=== Sprite Table First ($05) ===
<pre>
7 bit 0
---- ----
.iii iiii
||| ||||
+++-++++- Index of first sprite entry to draw (0-127)
</pre>
{{Anchor|Sprite Table Count}}
=== Sprite Table Count ($06) ===
<pre>
7 bit 0
---- ----
cccc cccc
|||| ||||
++++-++++- Count of sprite entries to draw (1-128)
</pre>
{{Anchor|Screen Address}}
=== Screen Address ($07) ===
<pre>
7 bit 0
---- ----
2222 1111
|||| ||||
|||| |+++- Screen 1 address (bits 11-13)
|||| +---- Screen 1 address (bit 14) - color only
|+++------ Screen 2 address (bits 11-13)
+--------- Screen 2 address (bit 14) - color only
</pre>
{{Anchor|Screen 2 Window}}
=== Screen 2 Window Left ($08) ===
=== Screen 2 Window Top ($09) ===
=== Screen 2 Window Right ($0A) ===
=== Screen 2 Window Bottom ($0B) ===
The X and Y coordinates of the Screen 2 window.
Note that all coordinates are inclusive; for example, for a 200x100 window in the top-left corner, the values should be set as follows:
* Left - 0,
* Top - 0,
* Right - 199,
* Bottom - 99.
{{Anchor|Sprite Window}}
=== Sprite Window Left ($0C) ===
=== Sprite Window Top ($0D) ===
=== Sprite Window Right ($0E) ===
=== Sprite Window Bottom ($0F) ===
The X and Y coordinates of the Sprite window.
Note that all coordinates are inclusive.
{{Anchor|Screen Scroll}}
=== Screen 1 Scroll X ($10) ===
=== Screen 1 Scroll Y ($11) ===
The X and Y coordinates that Screen 1 is scrolled by.
For example, setting Scroll X to 24 and Scroll Y to 8 will omit, in 8x8 tile units, the first three rows and the first two columns of the 32x32 screen.
=== Screen 2 Scroll X ($12) ===
=== Screen 2 Scroll Y ($13) ===
The X and Y coordinates that Screen 2 is scrolled by.
{{Anchor|LCD Control}}
=== LCD Control ($14) ===
<pre>
7 bit 0
---- ----
.... ..Ce
||
|+- LCD Enable: 0 = sleep, 1 = enabled
+-- Contrast (WSC): 0 = low, 1 = high
</pre>
{{Anchor|LCD Icon Control}}
=== LCD Icon Control ($15) ===
<pre>
7 bit 0
---- ----
..32 1hvs
|| ||||
|| |||+- Sleep
|| ||+-- Vertical orientation
|| |+--- Horizontal orientation
|| +---- Aux 1
|+------ Aux 2
+------- Aux 3
</pre>
{{Anchor|LCD Mono Shade LUT}}
=== LCD Mono Shade LUT ($1C-$1F) ===
<pre>
$1C $1D $1E $1F
7 bit 0 7 bit 0 7 bit 0 7 bit 0
---- ---- ---- ---- ---- ---- ---- ----
1111 0000 3333 2222 5555 4444 7777 6666
</pre>
{{Anchor|LCD Mono Palette}}
=== LCD Mono Palette 0..15 ($20, $21 .. $3E, $3F) ===
The monochrome palette is laid out as sixteen words:
<pre>
N+1 N
15 bit 8 7 bit 0
---- ---- ---- ----
.333 .222 .111 .000
||| ||| ||| |||
||| ||| ||| +++- Shade LUT index for color 0
||| ||| +++------ Shade LUT index for color 1
||| +++------------ Shade LUT index for color 2
+++----------------- Shade LUT index for color 3
</pre>
== Internal I/O ports ==
These I/O ports are said to be internal and not intended for use by commercial games.
{{Anchor|LCD Final Line}}
=== LCD Final Line ($16) ===
The final line preceding line counter restart and the beginning of active display. By default, this is set to 158, which equals 159 total lines per frame.
It is said setting this register to an odd value on SwanCrystal has an adverse effect to the LCD panel<ref>[http://daifukkat.su/docs/wsman/#REG_LCD_VTOTAL REG_LCD_VTOTAL - WSMan]</ref>, but the exact mechanism is unknown.
{{Anchor|LCD Back Porch Line}}
=== LCD Back Porch Line ($17, WSC only) ===
This port is available on the WonderSwan Color only - not the SwanCrystal!
The final line preceding the vertical back porch; by default, this should be set to 155.
The vertical back porch of the LCD is assumed to be 4 lines by some hardware, including IPS mods, as well as the official "TV Swan" capture device. Given that the first visible line is sent to the LCD on the display's line 1, this should be generally set to <code>LCD Final Line - 3</code>.
Conversely, it is said moving this value closer to vertical blank improves LCD visibility<ref>[http://daifukkat.su/docs/wsman/#REG_LCD_VSYNC REG_LCD_VSYNC - WSMan]</ref>, but the exact mechanism is unknown.
{{Anchor|LCD Status}}
=== LCD Status ($1A) ===
<pre>
7 bit 0
---- ----
...v vv.s
| || |
| || +- LCD sleep: 0 = no, 1 = sleep
| ||
| || Volume segments:
| |+--- Volume B (medium, high)
| +---- Volume A (low, high)
+------ Speaker
</pre>
=== TFT LCD Configuration ($70, $71, $72, $73, $74, $75, $76, $77 SwanCrystal only) ===
These eight bytes are read from internal EEPROM and configure unknown aspects of the console's TFT LCD panel.
They are only writable while the [[Boot ROM]] is unlocked - locking has the side effect of making them read-only.
== Notes ==
<references />
3f6667b0f88686ce4e6f9d89827520440716ebd7
348
315
2024-08-15T08:01:26Z
Asie
351
/* Display Control ($00) */ fix bit order
wikitext
text/x-wiki
The WonderSwan's display functionality generally consists of:
* a 224x144 display clocked at ~75.47 Hz by default, capable of displaying:
** up to sixteen distinct shades of gray
** 12-bit RGB444 color<sup>(color)</sup>
* two 32x32 background layers ("screens"), capable of displaying up to 512 (1024<sup>(color)</sup>) distinct tiles,
* a sprite layer, capable of displaying up to 128 8x8 sprites (up to 32 per line),
* six LCD icons to the bottom or right of the display, usable as additional indicators.
== Components ==
=== Tiles ===
The WonderSwan can display up to 512 distinct tiles at a time, with two bits of palette index information for every pixel.
The WonderSwan Color expands this to 1024 distinct tiles for background (with 512 remaining the limit for sprites), while also introducing modes with four bits of palette index information for every pixel.
==== 2 bits per pixel, planar ====
The tiles are stored in an interleaved planar format, with two bits total for every pixel. Odd bytes store the first plane (bit 0 of each pixel), while even bytes store the second plane (bit 1 of each pixel).
<pre>
tile data (16 bytes)
01 7C 01 FC 00 C0 18 D8 18 D8 00 C0 00 00 C0 00
||
\/
plane 0 plane 1
7 bit 0 7 bit 0 full tile
---- ---- ---- ----
.... ...1 = 01 .222 22.. = 7C .22222.1
.... ...1 = 01 2222 22.. = FC 222222.1
.... .... = 00 22.. .... = C0 22......
...1 1... = 18 22.2 2... = D8 --\ 22.33...
...1 1... = 18 22.2 2... = D8 --/ 22.33...
.... .... = 00 22.. .... = C0 22......
.... .... = 00 .... .... = 00 ........
11.. .... = C0 .... .... = 00 11......
</pre>
This matches the format used by the Game Boy.
==== 4 bits per pixel, planar ====
This mode is stored in a manner similar to the 2 bits per pixel mode, but with an additional two planes for bit 2 and bit 3 of each pixel's palette index, expanding the tile data to 32 bytes.
<pre>
tile data (32 bytes)
54 32 01 00 54 32 F1 00 54 32 01 F0 54 32 F1 F0 04 02 01 00 F8 04 02 01 00 F8 04 02 00 00 F8 04
||
\/
plane 0 plane 1 plane 2 plane 3
7 bit 0 7 bit 0 7 bit 0 7 bit 0 full tile
---- ---- ---- ---- ---- ---- ---- ----
.1.1 .1.. = 54 ..22 ..2. = 32 .... ...4 = 01 .... .... = 00 .123.124
.1.1 .1.. = 54 ..22 ..2. = 32 4444 ...4 = F1 .... .... = 00 4567.124
.1.1 .1.. = 54 ..22 ..2. = 32 .... ...4 = 01 8888 .... = F0 89AB.124
.1.1 .1.. = 54 ..22 ..2. = 32 4444 ...4 = F1 8888 .... = F0 --\ CDEF.124
.... .1.. = 04 .... ..2. = 02 .... ...4 = 01 .... .... = 00 --/ .....124
1111 1... = F8 .... .2.. = 04 .... ..4. = 02 .... ...8 = 01 11111248
.... .... = 00 2222 2... = F8 .... .4.. = 04 .... ..8. = 02 2222248.
.... .... = 00 .... .... = 00 4444 4... = F8 .... .8.. = 04 444448..
</pre>
This format matches the one used by the Sega Master System and Game Gear family of consoles.
==== 4 bits per pixel, packed ====
Unlike the previous two formats, in the packed format each byte stores the complete palette index of two pixels - the high four bits store the left pixel, while the low four bits store the right pixel. Four such bytes make up a row of eight pixels from left to right.
<pre>
tile data (32 bytes)
01 23 01 24 45 67 01 24 89 AB 01 24 CD EF 01 24 00 00 01 24 11 11 12 48 22 22 24 80 44 44 48 00
||
\/
byte 0 1 2 3
bits 7-4 3-0 7-4 3-0 7-4 3-0 7-4 3-0
pixel 0 1 2 3 4 5 6 7 full tile
--- --- --- --- --- --- --- ---
. 1 = 01 2 3 = 23 . 1 = 01 2 4 = 24 .123.124 = 01 23 01 24
4 5 = 45 6 7 = 67 . 1 = 01 2 4 = 24 4567.124 = 45 67 01 24
8 9 = 89 A B = AB . 1 = 01 2 4 = 24 89AB.124 = 89 AB 01 24
C D = CD E F = EF . 1 = 01 2 4 = 24 --\ CDEF.124 = CD EF 01 24
. . = 00 . . = 00 . 1 = 01 2 4 = 24 --/ .....124 = 00 00 01 24
1 1 = 11 1 1 = 11 1 2 = 12 4 8 = 48 11111248 = 11 11 12 48
2 2 = 22 2 2 = 22 2 4 = 24 8 . = 80 2222248. = 22 22 24 80
4 4 = 44 4 4 = 44 4 8 = 48 . . = 00 444448.. = 44 44 48 00
</pre>
This format matches the one used by the Mega Drive console.
=== Palettes ===
The display system provides sixteen different palettes that can be used to color or shade tiles.
* Palettes 0-7 can be used for the two screens only;
* Palettes 8-15 can be used for both screens and sprites.
==== Mono ====
In ''mono'' modes, palettes are stored in I/O ports 0x20 through 0x3F. Each palette contains four three-bit entries, which are pointers into a global, four-bit shade lookup table:
<pre>
Palette Global shade LUT
1 ===========> 2 ==========================> 5
^ (0, 2, 4, 6) ^ (1, 3, 5, 7, 9, 11, 13, 15) ^
| | |
Palette index Value Displayed shade
</pre>
The shade value corresponds to the darkness of the pixel: shade 0 is the brightest, while shade 15 is the darkest.
==== Color ====
In ''color'' modes, palettes are stored as 16-bit words in memory addresses 0xFE00 through 0xFFFF, without additional lookup tables:
<pre>
Address
15 bit 8 7 bit 0
---- ---- ---- ----
1111 111p pppi iii.
| |||| |||
| |||+-+++-- Index in palette (0-15)
+--+++------- Palette number (0-15)
Data
15 bit 8 7 bit 0
---- ---- ---- ----
.... rrrr gggg bbbb
|||| |||| ||||
|||| |||| ++++- Blue (0-15)
|||| ++++------ Green (0-15)
++++------------ Red (0-15)
</pre>
In 2 bits per pixel color modes, palette entries 4 through 15 are not used.
==== Transparency ====
In two bit per pixel modes:
* Palettes 0-3 and 8-11 are ''opaque''. For these, index zero is treated as opaque.
* Palettes 4-7 and 12-15 are ''translucent''. For these, index zero is treated as transparent. This means that the color/shade value set to it is ignored, and only three distinct colors/shades can be used for tiles.
In four bit per pixel modes, all palettes are ''translucent''. Index zero is always treated as transparent, and fifteen different colors/shades can be used for tiles.
=== Background color ===
The background color is displayed if no ''opaque'' pixel from screens or sprites is drawn. This color is set in I/O port ''0x01'':
* In mono modes, it is set to an entry in the shade lookup table (0-7),
* In color modes, it is set to an entry in the color palette (0-255). Note that this allows you to use the first color (color zero) of any palette, which is normally ignored and assumed to be ''transparent''.
=== Screens ===
A screen is a layout of tiles. Each cell in a screen controls one 8x8 tile.
The display system can show two distinct screens simultaneously. It also supports hardware flipping of tiles, both horizontally and vertically.
The size of each screen is fixed at 32x32 cells or 256x256 pixels, while each cell is stored as a two-byte word:
<pre>
Address
15 bit 8 7 bit 0
---- ---- ---- ----
0bbb byyy yyxx xxx.
||| |||| |||| |||
||| |||| ||++-+++-- X coordinate (0-31)
||| |+++--++-------- Y coordinate (0-31)
+++-+--------------- Base address (from I/O port)
Data
15 bit 8 7 bit 0
---- ---- ---- ----
vhbp pppt tttt tttt
|||| |||| |||| ||||
|||| |||+--++++-++++- Tile index (0-511)
|||+-+++------------- Palette (0-15)
||+------------------ Tile bank (0-1) - color only
|+------------------- Horizontal flip
+-------------------- Vertical flip
</pre>
In ''color'' modes, the tile bank selects between tiles 0-511 and 512-1023.
=== Sprites ===
The display system can show up to 128 sprites at once.
Sprites are always drawn in front of Screen 1, but they can be drawn in front of or behind Screen 2.
Sprites are stored in a sprite table in the console's internal RAM. It consists of up to 128 four-byte entries, of which any sequential slice can be displayed:
<pre>
(Byte 1) (Byte 0)
15 bit 8 7 bit 0
---- ---- ---- ----
vhPi pppt tttt tttt
|||| |||| |||| ||||
|||| |||+--++++-++++- Tile index (0-511) - only tile bank 0
|||| +++------------- Palette (0-7) - mapped to screen palettes 8-15
|||+----------------- Window location - 0 = inside, 1 = outside
||+------------------ Priority - 0 = behind Screen 2, 1 = in front of Screen 2
|+------------------- Horizontal flip
+-------------------- Vertical flip
(Byte 2)
7 bit 0
---- ----
yyyy yyyy
|||| ||||
++++-++++- Y coordinate
(Byte 3)
7 bit 0
---- ----
xxxx xxxx
|||| ||||
++++-++++- X coordinate
</pre>
There is a sprite limit of 32 per scanline. This means that for each scanline, only the first 32 sprites will be drawn.
Note that this includes sprites obscured by windows or outside of visible X coordinates; this list is determined solely by the Y coordinate.
Between sprites themselves, earlier sprites in the list are always drawn on top of later sprites in the list.
=== Visibility priority ===
For display components, the visibility priority is as follows:
* Sprite 0, high priority
* Sprite 127, high priority
* Screen 2
* Sprite 0, low priority
* Sprite 127, low priority
* Screen 1
* Background color
=== Windows ===
Screen 2 and sprites can optionally have their drawing restricted within or outside of their specific rectangular windows.
Note that for sprites, the window is enabled globally (for all sprites), but each sprite can individually decide if it's rendered inside or outside of it.
=== Icons ===
The WonderSwan features six LCD segment icons which are displayed to the right<sup>(color)</sup> or below<sup>(mono)</sup> the main display. These are, as follows:
* Aux 3 - large circle,
* Aux 2 - medium circle,
* Aux 1 - small circle,
* Horizontal orientation,
* Vertical orientation,
* Sleep.
== Interrupts ==
The display circuit generates two interrupts of its own:
* Display Interrupt Line Match - when <code>Display Current Line</code> == <code>Display Interrupt Line</code>, at the beginning of said line.
* Display Vertical Blank - when <code>Display Current Line</code> == <code>144</code>, at the beginning of said line.
It also provides a timing source for the two Horizontal and Vertical Blank [[Timers]], which provide their own respective interrupts.
== I/O ports ==
{{Anchor|Display Control}}
=== Display Control ($00) ===
<pre>
7 bit 0
---- ----
..w0 Ws21
|| ||||
|| |||+- Enable Screen 1 layer
|| ||+-- Enable Screen 2 layer
|| |+--- Enable Sprite layer
|| +---- Enable Sprite window
|+------ Screen 2 tiles are drawn (if window enabled):
| 0 = inside window,
| 1 = outside window.
+------- Enable Screen 2 window
</pre>
{{Anchor|Display Background}}
=== Display Background Color ($01) ===
<pre>
(mono) (color)
7 bit 0 7 bit 0
---- ---- ---- ----
.... .sss pppp iiii
||| |||| ||||
+++- Value |||| ++++- Index in palette (0-15)
(0-7) ++++------ Color palette (0-15)
</pre>
{{Anchor|Display Current Line}}
=== Display Current Line ($02 read) ===
The current line being drawn by the display.
Note that lines are sent to the display with a one-line delay. This matters for color palette or shade LUT manipulation; changing these values when <code>current line == 1</code> will actually affect line 0.
{{Anchor|Display Interrupt Line}}
=== Display Interrupt Line ($03) ===
The line to emit an interrupt on.
{{Anchor|Sprite Table Address}}
=== Sprite Table Address ($04) ===
<pre>
7 bit 0
---- ----
..Aa aaaa
|| ||||
|+-++++- Address (bits 9-13)
+------- Address (bit 14) - color only
</pre>
{{Anchor|Sprite Table First}}
=== Sprite Table First ($05) ===
<pre>
7 bit 0
---- ----
.iii iiii
||| ||||
+++-++++- Index of first sprite entry to draw (0-127)
</pre>
{{Anchor|Sprite Table Count}}
=== Sprite Table Count ($06) ===
<pre>
7 bit 0
---- ----
cccc cccc
|||| ||||
++++-++++- Count of sprite entries to draw (1-128)
</pre>
{{Anchor|Screen Address}}
=== Screen Address ($07) ===
<pre>
7 bit 0
---- ----
2222 1111
|||| ||||
|||| |+++- Screen 1 address (bits 11-13)
|||| +---- Screen 1 address (bit 14) - color only
|+++------ Screen 2 address (bits 11-13)
+--------- Screen 2 address (bit 14) - color only
</pre>
{{Anchor|Screen 2 Window}}
=== Screen 2 Window Left ($08) ===
=== Screen 2 Window Top ($09) ===
=== Screen 2 Window Right ($0A) ===
=== Screen 2 Window Bottom ($0B) ===
The X and Y coordinates of the Screen 2 window.
Note that all coordinates are inclusive; for example, for a 200x100 window in the top-left corner, the values should be set as follows:
* Left - 0,
* Top - 0,
* Right - 199,
* Bottom - 99.
{{Anchor|Sprite Window}}
=== Sprite Window Left ($0C) ===
=== Sprite Window Top ($0D) ===
=== Sprite Window Right ($0E) ===
=== Sprite Window Bottom ($0F) ===
The X and Y coordinates of the Sprite window.
Note that all coordinates are inclusive.
{{Anchor|Screen Scroll}}
=== Screen 1 Scroll X ($10) ===
=== Screen 1 Scroll Y ($11) ===
The X and Y coordinates that Screen 1 is scrolled by.
For example, setting Scroll X to 24 and Scroll Y to 8 will omit, in 8x8 tile units, the first three rows and the first two columns of the 32x32 screen.
=== Screen 2 Scroll X ($12) ===
=== Screen 2 Scroll Y ($13) ===
The X and Y coordinates that Screen 2 is scrolled by.
{{Anchor|LCD Control}}
=== LCD Control ($14) ===
<pre>
7 bit 0
---- ----
.... ..Ce
||
|+- LCD Enable: 0 = sleep, 1 = enabled
+-- Contrast (WSC): 0 = low, 1 = high
</pre>
{{Anchor|LCD Icon Control}}
=== LCD Icon Control ($15) ===
<pre>
7 bit 0
---- ----
..32 1hvs
|| ||||
|| |||+- Sleep
|| ||+-- Vertical orientation
|| |+--- Horizontal orientation
|| +---- Aux 1
|+------ Aux 2
+------- Aux 3
</pre>
{{Anchor|LCD Mono Shade LUT}}
=== LCD Mono Shade LUT ($1C-$1F) ===
<pre>
$1C $1D $1E $1F
7 bit 0 7 bit 0 7 bit 0 7 bit 0
---- ---- ---- ---- ---- ---- ---- ----
1111 0000 3333 2222 5555 4444 7777 6666
</pre>
{{Anchor|LCD Mono Palette}}
=== LCD Mono Palette 0..15 ($20, $21 .. $3E, $3F) ===
The monochrome palette is laid out as sixteen words:
<pre>
N+1 N
15 bit 8 7 bit 0
---- ---- ---- ----
.333 .222 .111 .000
||| ||| ||| |||
||| ||| ||| +++- Shade LUT index for color 0
||| ||| +++------ Shade LUT index for color 1
||| +++------------ Shade LUT index for color 2
+++----------------- Shade LUT index for color 3
</pre>
== Internal I/O ports ==
These I/O ports are said to be internal and not intended for use by commercial games.
{{Anchor|LCD Final Line}}
=== LCD Final Line ($16) ===
The final line preceding line counter restart and the beginning of active display. By default, this is set to 158, which equals 159 total lines per frame.
It is said setting this register to an odd value on SwanCrystal has an adverse effect to the LCD panel<ref>[http://daifukkat.su/docs/wsman/#REG_LCD_VTOTAL REG_LCD_VTOTAL - WSMan]</ref>, but the exact mechanism is unknown.
{{Anchor|LCD Back Porch Line}}
=== LCD Back Porch Line ($17, WSC only) ===
This port is available on the WonderSwan Color only - not the SwanCrystal!
The final line preceding the vertical back porch; by default, this should be set to 155.
The vertical back porch of the LCD is assumed to be 4 lines by some hardware, including IPS mods, as well as the official "TV Swan" capture device. Given that the first visible line is sent to the LCD on the display's line 1, this should be generally set to <code>LCD Final Line - 3</code>.
Conversely, it is said moving this value closer to vertical blank improves LCD visibility<ref>[http://daifukkat.su/docs/wsman/#REG_LCD_VSYNC REG_LCD_VSYNC - WSMan]</ref>, but the exact mechanism is unknown.
{{Anchor|LCD Status}}
=== LCD Status ($1A) ===
<pre>
7 bit 0
---- ----
...v vv.s
| || |
| || +- LCD sleep: 0 = no, 1 = sleep
| ||
| || Volume segments:
| |+--- Volume B (medium, high)
| +---- Volume A (low, high)
+------ Speaker
</pre>
=== TFT LCD Configuration ($70, $71, $72, $73, $74, $75, $76, $77 SwanCrystal only) ===
These eight bytes are read from internal EEPROM and configure unknown aspects of the console's TFT LCD panel.
They are only writable while the [[Boot ROM]] is unlocked - locking has the side effect of making them read-only.
== Notes ==
<references />
7d55bd8c45a4dac8094c433fdc0fc9e67388c631
349
348
2024-08-15T08:01:35Z
Asie
351
/* Display Control ($00) */
wikitext
text/x-wiki
The WonderSwan's display functionality generally consists of:
* a 224x144 display clocked at ~75.47 Hz by default, capable of displaying:
** up to sixteen distinct shades of gray
** 12-bit RGB444 color<sup>(color)</sup>
* two 32x32 background layers ("screens"), capable of displaying up to 512 (1024<sup>(color)</sup>) distinct tiles,
* a sprite layer, capable of displaying up to 128 8x8 sprites (up to 32 per line),
* six LCD icons to the bottom or right of the display, usable as additional indicators.
== Components ==
=== Tiles ===
The WonderSwan can display up to 512 distinct tiles at a time, with two bits of palette index information for every pixel.
The WonderSwan Color expands this to 1024 distinct tiles for background (with 512 remaining the limit for sprites), while also introducing modes with four bits of palette index information for every pixel.
==== 2 bits per pixel, planar ====
The tiles are stored in an interleaved planar format, with two bits total for every pixel. Odd bytes store the first plane (bit 0 of each pixel), while even bytes store the second plane (bit 1 of each pixel).
<pre>
tile data (16 bytes)
01 7C 01 FC 00 C0 18 D8 18 D8 00 C0 00 00 C0 00
||
\/
plane 0 plane 1
7 bit 0 7 bit 0 full tile
---- ---- ---- ----
.... ...1 = 01 .222 22.. = 7C .22222.1
.... ...1 = 01 2222 22.. = FC 222222.1
.... .... = 00 22.. .... = C0 22......
...1 1... = 18 22.2 2... = D8 --\ 22.33...
...1 1... = 18 22.2 2... = D8 --/ 22.33...
.... .... = 00 22.. .... = C0 22......
.... .... = 00 .... .... = 00 ........
11.. .... = C0 .... .... = 00 11......
</pre>
This matches the format used by the Game Boy.
==== 4 bits per pixel, planar ====
This mode is stored in a manner similar to the 2 bits per pixel mode, but with an additional two planes for bit 2 and bit 3 of each pixel's palette index, expanding the tile data to 32 bytes.
<pre>
tile data (32 bytes)
54 32 01 00 54 32 F1 00 54 32 01 F0 54 32 F1 F0 04 02 01 00 F8 04 02 01 00 F8 04 02 00 00 F8 04
||
\/
plane 0 plane 1 plane 2 plane 3
7 bit 0 7 bit 0 7 bit 0 7 bit 0 full tile
---- ---- ---- ---- ---- ---- ---- ----
.1.1 .1.. = 54 ..22 ..2. = 32 .... ...4 = 01 .... .... = 00 .123.124
.1.1 .1.. = 54 ..22 ..2. = 32 4444 ...4 = F1 .... .... = 00 4567.124
.1.1 .1.. = 54 ..22 ..2. = 32 .... ...4 = 01 8888 .... = F0 89AB.124
.1.1 .1.. = 54 ..22 ..2. = 32 4444 ...4 = F1 8888 .... = F0 --\ CDEF.124
.... .1.. = 04 .... ..2. = 02 .... ...4 = 01 .... .... = 00 --/ .....124
1111 1... = F8 .... .2.. = 04 .... ..4. = 02 .... ...8 = 01 11111248
.... .... = 00 2222 2... = F8 .... .4.. = 04 .... ..8. = 02 2222248.
.... .... = 00 .... .... = 00 4444 4... = F8 .... .8.. = 04 444448..
</pre>
This format matches the one used by the Sega Master System and Game Gear family of consoles.
==== 4 bits per pixel, packed ====
Unlike the previous two formats, in the packed format each byte stores the complete palette index of two pixels - the high four bits store the left pixel, while the low four bits store the right pixel. Four such bytes make up a row of eight pixels from left to right.
<pre>
tile data (32 bytes)
01 23 01 24 45 67 01 24 89 AB 01 24 CD EF 01 24 00 00 01 24 11 11 12 48 22 22 24 80 44 44 48 00
||
\/
byte 0 1 2 3
bits 7-4 3-0 7-4 3-0 7-4 3-0 7-4 3-0
pixel 0 1 2 3 4 5 6 7 full tile
--- --- --- --- --- --- --- ---
. 1 = 01 2 3 = 23 . 1 = 01 2 4 = 24 .123.124 = 01 23 01 24
4 5 = 45 6 7 = 67 . 1 = 01 2 4 = 24 4567.124 = 45 67 01 24
8 9 = 89 A B = AB . 1 = 01 2 4 = 24 89AB.124 = 89 AB 01 24
C D = CD E F = EF . 1 = 01 2 4 = 24 --\ CDEF.124 = CD EF 01 24
. . = 00 . . = 00 . 1 = 01 2 4 = 24 --/ .....124 = 00 00 01 24
1 1 = 11 1 1 = 11 1 2 = 12 4 8 = 48 11111248 = 11 11 12 48
2 2 = 22 2 2 = 22 2 4 = 24 8 . = 80 2222248. = 22 22 24 80
4 4 = 44 4 4 = 44 4 8 = 48 . . = 00 444448.. = 44 44 48 00
</pre>
This format matches the one used by the Mega Drive console.
=== Palettes ===
The display system provides sixteen different palettes that can be used to color or shade tiles.
* Palettes 0-7 can be used for the two screens only;
* Palettes 8-15 can be used for both screens and sprites.
==== Mono ====
In ''mono'' modes, palettes are stored in I/O ports 0x20 through 0x3F. Each palette contains four three-bit entries, which are pointers into a global, four-bit shade lookup table:
<pre>
Palette Global shade LUT
1 ===========> 2 ==========================> 5
^ (0, 2, 4, 6) ^ (1, 3, 5, 7, 9, 11, 13, 15) ^
| | |
Palette index Value Displayed shade
</pre>
The shade value corresponds to the darkness of the pixel: shade 0 is the brightest, while shade 15 is the darkest.
==== Color ====
In ''color'' modes, palettes are stored as 16-bit words in memory addresses 0xFE00 through 0xFFFF, without additional lookup tables:
<pre>
Address
15 bit 8 7 bit 0
---- ---- ---- ----
1111 111p pppi iii.
| |||| |||
| |||+-+++-- Index in palette (0-15)
+--+++------- Palette number (0-15)
Data
15 bit 8 7 bit 0
---- ---- ---- ----
.... rrrr gggg bbbb
|||| |||| ||||
|||| |||| ++++- Blue (0-15)
|||| ++++------ Green (0-15)
++++------------ Red (0-15)
</pre>
In 2 bits per pixel color modes, palette entries 4 through 15 are not used.
==== Transparency ====
In two bit per pixel modes:
* Palettes 0-3 and 8-11 are ''opaque''. For these, index zero is treated as opaque.
* Palettes 4-7 and 12-15 are ''translucent''. For these, index zero is treated as transparent. This means that the color/shade value set to it is ignored, and only three distinct colors/shades can be used for tiles.
In four bit per pixel modes, all palettes are ''translucent''. Index zero is always treated as transparent, and fifteen different colors/shades can be used for tiles.
=== Background color ===
The background color is displayed if no ''opaque'' pixel from screens or sprites is drawn. This color is set in I/O port ''0x01'':
* In mono modes, it is set to an entry in the shade lookup table (0-7),
* In color modes, it is set to an entry in the color palette (0-255). Note that this allows you to use the first color (color zero) of any palette, which is normally ignored and assumed to be ''transparent''.
=== Screens ===
A screen is a layout of tiles. Each cell in a screen controls one 8x8 tile.
The display system can show two distinct screens simultaneously. It also supports hardware flipping of tiles, both horizontally and vertically.
The size of each screen is fixed at 32x32 cells or 256x256 pixels, while each cell is stored as a two-byte word:
<pre>
Address
15 bit 8 7 bit 0
---- ---- ---- ----
0bbb byyy yyxx xxx.
||| |||| |||| |||
||| |||| ||++-+++-- X coordinate (0-31)
||| |+++--++-------- Y coordinate (0-31)
+++-+--------------- Base address (from I/O port)
Data
15 bit 8 7 bit 0
---- ---- ---- ----
vhbp pppt tttt tttt
|||| |||| |||| ||||
|||| |||+--++++-++++- Tile index (0-511)
|||+-+++------------- Palette (0-15)
||+------------------ Tile bank (0-1) - color only
|+------------------- Horizontal flip
+-------------------- Vertical flip
</pre>
In ''color'' modes, the tile bank selects between tiles 0-511 and 512-1023.
=== Sprites ===
The display system can show up to 128 sprites at once.
Sprites are always drawn in front of Screen 1, but they can be drawn in front of or behind Screen 2.
Sprites are stored in a sprite table in the console's internal RAM. It consists of up to 128 four-byte entries, of which any sequential slice can be displayed:
<pre>
(Byte 1) (Byte 0)
15 bit 8 7 bit 0
---- ---- ---- ----
vhPi pppt tttt tttt
|||| |||| |||| ||||
|||| |||+--++++-++++- Tile index (0-511) - only tile bank 0
|||| +++------------- Palette (0-7) - mapped to screen palettes 8-15
|||+----------------- Window location - 0 = inside, 1 = outside
||+------------------ Priority - 0 = behind Screen 2, 1 = in front of Screen 2
|+------------------- Horizontal flip
+-------------------- Vertical flip
(Byte 2)
7 bit 0
---- ----
yyyy yyyy
|||| ||||
++++-++++- Y coordinate
(Byte 3)
7 bit 0
---- ----
xxxx xxxx
|||| ||||
++++-++++- X coordinate
</pre>
There is a sprite limit of 32 per scanline. This means that for each scanline, only the first 32 sprites will be drawn.
Note that this includes sprites obscured by windows or outside of visible X coordinates; this list is determined solely by the Y coordinate.
Between sprites themselves, earlier sprites in the list are always drawn on top of later sprites in the list.
=== Visibility priority ===
For display components, the visibility priority is as follows:
* Sprite 0, high priority
* Sprite 127, high priority
* Screen 2
* Sprite 0, low priority
* Sprite 127, low priority
* Screen 1
* Background color
=== Windows ===
Screen 2 and sprites can optionally have their drawing restricted within or outside of their specific rectangular windows.
Note that for sprites, the window is enabled globally (for all sprites), but each sprite can individually decide if it's rendered inside or outside of it.
=== Icons ===
The WonderSwan features six LCD segment icons which are displayed to the right<sup>(color)</sup> or below<sup>(mono)</sup> the main display. These are, as follows:
* Aux 3 - large circle,
* Aux 2 - medium circle,
* Aux 1 - small circle,
* Horizontal orientation,
* Vertical orientation,
* Sleep.
== Interrupts ==
The display circuit generates two interrupts of its own:
* Display Interrupt Line Match - when <code>Display Current Line</code> == <code>Display Interrupt Line</code>, at the beginning of said line.
* Display Vertical Blank - when <code>Display Current Line</code> == <code>144</code>, at the beginning of said line.
It also provides a timing source for the two Horizontal and Vertical Blank [[Timers]], which provide their own respective interrupts.
== I/O ports ==
{{Anchor|Display Control}}
=== Display Control ($00) ===
<pre>
7 bit 0
---- ----
..wo Ws21
|| ||||
|| |||+- Enable Screen 1 layer
|| ||+-- Enable Screen 2 layer
|| |+--- Enable Sprite layer
|| +---- Enable Sprite window
|+------ Screen 2 tiles are drawn (if window enabled):
| 0 = inside window,
| 1 = outside window.
+------- Enable Screen 2 window
</pre>
{{Anchor|Display Background}}
=== Display Background Color ($01) ===
<pre>
(mono) (color)
7 bit 0 7 bit 0
---- ---- ---- ----
.... .sss pppp iiii
||| |||| ||||
+++- Value |||| ++++- Index in palette (0-15)
(0-7) ++++------ Color palette (0-15)
</pre>
{{Anchor|Display Current Line}}
=== Display Current Line ($02 read) ===
The current line being drawn by the display.
Note that lines are sent to the display with a one-line delay. This matters for color palette or shade LUT manipulation; changing these values when <code>current line == 1</code> will actually affect line 0.
{{Anchor|Display Interrupt Line}}
=== Display Interrupt Line ($03) ===
The line to emit an interrupt on.
{{Anchor|Sprite Table Address}}
=== Sprite Table Address ($04) ===
<pre>
7 bit 0
---- ----
..Aa aaaa
|| ||||
|+-++++- Address (bits 9-13)
+------- Address (bit 14) - color only
</pre>
{{Anchor|Sprite Table First}}
=== Sprite Table First ($05) ===
<pre>
7 bit 0
---- ----
.iii iiii
||| ||||
+++-++++- Index of first sprite entry to draw (0-127)
</pre>
{{Anchor|Sprite Table Count}}
=== Sprite Table Count ($06) ===
<pre>
7 bit 0
---- ----
cccc cccc
|||| ||||
++++-++++- Count of sprite entries to draw (1-128)
</pre>
{{Anchor|Screen Address}}
=== Screen Address ($07) ===
<pre>
7 bit 0
---- ----
2222 1111
|||| ||||
|||| |+++- Screen 1 address (bits 11-13)
|||| +---- Screen 1 address (bit 14) - color only
|+++------ Screen 2 address (bits 11-13)
+--------- Screen 2 address (bit 14) - color only
</pre>
{{Anchor|Screen 2 Window}}
=== Screen 2 Window Left ($08) ===
=== Screen 2 Window Top ($09) ===
=== Screen 2 Window Right ($0A) ===
=== Screen 2 Window Bottom ($0B) ===
The X and Y coordinates of the Screen 2 window.
Note that all coordinates are inclusive; for example, for a 200x100 window in the top-left corner, the values should be set as follows:
* Left - 0,
* Top - 0,
* Right - 199,
* Bottom - 99.
{{Anchor|Sprite Window}}
=== Sprite Window Left ($0C) ===
=== Sprite Window Top ($0D) ===
=== Sprite Window Right ($0E) ===
=== Sprite Window Bottom ($0F) ===
The X and Y coordinates of the Sprite window.
Note that all coordinates are inclusive.
{{Anchor|Screen Scroll}}
=== Screen 1 Scroll X ($10) ===
=== Screen 1 Scroll Y ($11) ===
The X and Y coordinates that Screen 1 is scrolled by.
For example, setting Scroll X to 24 and Scroll Y to 8 will omit, in 8x8 tile units, the first three rows and the first two columns of the 32x32 screen.
=== Screen 2 Scroll X ($12) ===
=== Screen 2 Scroll Y ($13) ===
The X and Y coordinates that Screen 2 is scrolled by.
{{Anchor|LCD Control}}
=== LCD Control ($14) ===
<pre>
7 bit 0
---- ----
.... ..Ce
||
|+- LCD Enable: 0 = sleep, 1 = enabled
+-- Contrast (WSC): 0 = low, 1 = high
</pre>
{{Anchor|LCD Icon Control}}
=== LCD Icon Control ($15) ===
<pre>
7 bit 0
---- ----
..32 1hvs
|| ||||
|| |||+- Sleep
|| ||+-- Vertical orientation
|| |+--- Horizontal orientation
|| +---- Aux 1
|+------ Aux 2
+------- Aux 3
</pre>
{{Anchor|LCD Mono Shade LUT}}
=== LCD Mono Shade LUT ($1C-$1F) ===
<pre>
$1C $1D $1E $1F
7 bit 0 7 bit 0 7 bit 0 7 bit 0
---- ---- ---- ---- ---- ---- ---- ----
1111 0000 3333 2222 5555 4444 7777 6666
</pre>
{{Anchor|LCD Mono Palette}}
=== LCD Mono Palette 0..15 ($20, $21 .. $3E, $3F) ===
The monochrome palette is laid out as sixteen words:
<pre>
N+1 N
15 bit 8 7 bit 0
---- ---- ---- ----
.333 .222 .111 .000
||| ||| ||| |||
||| ||| ||| +++- Shade LUT index for color 0
||| ||| +++------ Shade LUT index for color 1
||| +++------------ Shade LUT index for color 2
+++----------------- Shade LUT index for color 3
</pre>
== Internal I/O ports ==
These I/O ports are said to be internal and not intended for use by commercial games.
{{Anchor|LCD Final Line}}
=== LCD Final Line ($16) ===
The final line preceding line counter restart and the beginning of active display. By default, this is set to 158, which equals 159 total lines per frame.
It is said setting this register to an odd value on SwanCrystal has an adverse effect to the LCD panel<ref>[http://daifukkat.su/docs/wsman/#REG_LCD_VTOTAL REG_LCD_VTOTAL - WSMan]</ref>, but the exact mechanism is unknown.
{{Anchor|LCD Back Porch Line}}
=== LCD Back Porch Line ($17, WSC only) ===
This port is available on the WonderSwan Color only - not the SwanCrystal!
The final line preceding the vertical back porch; by default, this should be set to 155.
The vertical back porch of the LCD is assumed to be 4 lines by some hardware, including IPS mods, as well as the official "TV Swan" capture device. Given that the first visible line is sent to the LCD on the display's line 1, this should be generally set to <code>LCD Final Line - 3</code>.
Conversely, it is said moving this value closer to vertical blank improves LCD visibility<ref>[http://daifukkat.su/docs/wsman/#REG_LCD_VSYNC REG_LCD_VSYNC - WSMan]</ref>, but the exact mechanism is unknown.
{{Anchor|LCD Status}}
=== LCD Status ($1A) ===
<pre>
7 bit 0
---- ----
...v vv.s
| || |
| || +- LCD sleep: 0 = no, 1 = sleep
| ||
| || Volume segments:
| |+--- Volume B (medium, high)
| +---- Volume A (low, high)
+------ Speaker
</pre>
=== TFT LCD Configuration ($70, $71, $72, $73, $74, $75, $76, $77 SwanCrystal only) ===
These eight bytes are read from internal EEPROM and configure unknown aspects of the console's TFT LCD panel.
They are only writable while the [[Boot ROM]] is unlocked - locking has the side effect of making them read-only.
== Notes ==
<references />
f90e70bb05f83c2401223250868ac4b149b0a163
350
349
2024-08-21T14:17:57Z
Asie
351
/* Sprites */
wikitext
text/x-wiki
The WonderSwan's display functionality generally consists of:
* a 224x144 display clocked at ~75.47 Hz by default, capable of displaying:
** up to sixteen distinct shades of gray
** 12-bit RGB444 color<sup>(color)</sup>
* two 32x32 background layers ("screens"), capable of displaying up to 512 (1024<sup>(color)</sup>) distinct tiles,
* a sprite layer, capable of displaying up to 128 8x8 sprites (up to 32 per line),
* six LCD icons to the bottom or right of the display, usable as additional indicators.
== Components ==
=== Tiles ===
The WonderSwan can display up to 512 distinct tiles at a time, with two bits of palette index information for every pixel.
The WonderSwan Color expands this to 1024 distinct tiles for background (with 512 remaining the limit for sprites), while also introducing modes with four bits of palette index information for every pixel.
==== 2 bits per pixel, planar ====
The tiles are stored in an interleaved planar format, with two bits total for every pixel. Odd bytes store the first plane (bit 0 of each pixel), while even bytes store the second plane (bit 1 of each pixel).
<pre>
tile data (16 bytes)
01 7C 01 FC 00 C0 18 D8 18 D8 00 C0 00 00 C0 00
||
\/
plane 0 plane 1
7 bit 0 7 bit 0 full tile
---- ---- ---- ----
.... ...1 = 01 .222 22.. = 7C .22222.1
.... ...1 = 01 2222 22.. = FC 222222.1
.... .... = 00 22.. .... = C0 22......
...1 1... = 18 22.2 2... = D8 --\ 22.33...
...1 1... = 18 22.2 2... = D8 --/ 22.33...
.... .... = 00 22.. .... = C0 22......
.... .... = 00 .... .... = 00 ........
11.. .... = C0 .... .... = 00 11......
</pre>
This matches the format used by the Game Boy.
==== 4 bits per pixel, planar ====
This mode is stored in a manner similar to the 2 bits per pixel mode, but with an additional two planes for bit 2 and bit 3 of each pixel's palette index, expanding the tile data to 32 bytes.
<pre>
tile data (32 bytes)
54 32 01 00 54 32 F1 00 54 32 01 F0 54 32 F1 F0 04 02 01 00 F8 04 02 01 00 F8 04 02 00 00 F8 04
||
\/
plane 0 plane 1 plane 2 plane 3
7 bit 0 7 bit 0 7 bit 0 7 bit 0 full tile
---- ---- ---- ---- ---- ---- ---- ----
.1.1 .1.. = 54 ..22 ..2. = 32 .... ...4 = 01 .... .... = 00 .123.124
.1.1 .1.. = 54 ..22 ..2. = 32 4444 ...4 = F1 .... .... = 00 4567.124
.1.1 .1.. = 54 ..22 ..2. = 32 .... ...4 = 01 8888 .... = F0 89AB.124
.1.1 .1.. = 54 ..22 ..2. = 32 4444 ...4 = F1 8888 .... = F0 --\ CDEF.124
.... .1.. = 04 .... ..2. = 02 .... ...4 = 01 .... .... = 00 --/ .....124
1111 1... = F8 .... .2.. = 04 .... ..4. = 02 .... ...8 = 01 11111248
.... .... = 00 2222 2... = F8 .... .4.. = 04 .... ..8. = 02 2222248.
.... .... = 00 .... .... = 00 4444 4... = F8 .... .8.. = 04 444448..
</pre>
This format matches the one used by the Sega Master System and Game Gear family of consoles.
==== 4 bits per pixel, packed ====
Unlike the previous two formats, in the packed format each byte stores the complete palette index of two pixels - the high four bits store the left pixel, while the low four bits store the right pixel. Four such bytes make up a row of eight pixels from left to right.
<pre>
tile data (32 bytes)
01 23 01 24 45 67 01 24 89 AB 01 24 CD EF 01 24 00 00 01 24 11 11 12 48 22 22 24 80 44 44 48 00
||
\/
byte 0 1 2 3
bits 7-4 3-0 7-4 3-0 7-4 3-0 7-4 3-0
pixel 0 1 2 3 4 5 6 7 full tile
--- --- --- --- --- --- --- ---
. 1 = 01 2 3 = 23 . 1 = 01 2 4 = 24 .123.124 = 01 23 01 24
4 5 = 45 6 7 = 67 . 1 = 01 2 4 = 24 4567.124 = 45 67 01 24
8 9 = 89 A B = AB . 1 = 01 2 4 = 24 89AB.124 = 89 AB 01 24
C D = CD E F = EF . 1 = 01 2 4 = 24 --\ CDEF.124 = CD EF 01 24
. . = 00 . . = 00 . 1 = 01 2 4 = 24 --/ .....124 = 00 00 01 24
1 1 = 11 1 1 = 11 1 2 = 12 4 8 = 48 11111248 = 11 11 12 48
2 2 = 22 2 2 = 22 2 4 = 24 8 . = 80 2222248. = 22 22 24 80
4 4 = 44 4 4 = 44 4 8 = 48 . . = 00 444448.. = 44 44 48 00
</pre>
This format matches the one used by the Mega Drive console.
=== Palettes ===
The display system provides sixteen different palettes that can be used to color or shade tiles.
* Palettes 0-7 can be used for the two screens only;
* Palettes 8-15 can be used for both screens and sprites.
==== Mono ====
In ''mono'' modes, palettes are stored in I/O ports 0x20 through 0x3F. Each palette contains four three-bit entries, which are pointers into a global, four-bit shade lookup table:
<pre>
Palette Global shade LUT
1 ===========> 2 ==========================> 5
^ (0, 2, 4, 6) ^ (1, 3, 5, 7, 9, 11, 13, 15) ^
| | |
Palette index Value Displayed shade
</pre>
The shade value corresponds to the darkness of the pixel: shade 0 is the brightest, while shade 15 is the darkest.
==== Color ====
In ''color'' modes, palettes are stored as 16-bit words in memory addresses 0xFE00 through 0xFFFF, without additional lookup tables:
<pre>
Address
15 bit 8 7 bit 0
---- ---- ---- ----
1111 111p pppi iii.
| |||| |||
| |||+-+++-- Index in palette (0-15)
+--+++------- Palette number (0-15)
Data
15 bit 8 7 bit 0
---- ---- ---- ----
.... rrrr gggg bbbb
|||| |||| ||||
|||| |||| ++++- Blue (0-15)
|||| ++++------ Green (0-15)
++++------------ Red (0-15)
</pre>
In 2 bits per pixel color modes, palette entries 4 through 15 are not used.
==== Transparency ====
In two bit per pixel modes:
* Palettes 0-3 and 8-11 are ''opaque''. For these, index zero is treated as opaque.
* Palettes 4-7 and 12-15 are ''translucent''. For these, index zero is treated as transparent. This means that the color/shade value set to it is ignored, and only three distinct colors/shades can be used for tiles.
In four bit per pixel modes, all palettes are ''translucent''. Index zero is always treated as transparent, and fifteen different colors/shades can be used for tiles.
=== Background color ===
The background color is displayed if no ''opaque'' pixel from screens or sprites is drawn. This color is set in I/O port ''0x01'':
* In mono modes, it is set to an entry in the shade lookup table (0-7),
* In color modes, it is set to an entry in the color palette (0-255). Note that this allows you to use the first color (color zero) of any palette, which is normally ignored and assumed to be ''transparent''.
=== Screens ===
A screen is a layout of tiles. Each cell in a screen controls one 8x8 tile.
The display system can show two distinct screens simultaneously. It also supports hardware flipping of tiles, both horizontally and vertically.
The size of each screen is fixed at 32x32 cells or 256x256 pixels, while each cell is stored as a two-byte word:
<pre>
Address
15 bit 8 7 bit 0
---- ---- ---- ----
0bbb byyy yyxx xxx.
||| |||| |||| |||
||| |||| ||++-+++-- X coordinate (0-31)
||| |+++--++-------- Y coordinate (0-31)
+++-+--------------- Base address (from I/O port)
Data
15 bit 8 7 bit 0
---- ---- ---- ----
vhbp pppt tttt tttt
|||| |||| |||| ||||
|||| |||+--++++-++++- Tile index (0-511)
|||+-+++------------- Palette (0-15)
||+------------------ Tile bank (0-1) - color only
|+------------------- Horizontal flip
+-------------------- Vertical flip
</pre>
In ''color'' modes, the tile bank selects between tiles 0-511 and 512-1023.
=== Sprites ===
The display system can show up to 128 sprites at once.
Sprites are always drawn in front of Screen 1, but they can be drawn in front of or behind Screen 2.
Sprites are stored in a sprite table in the console's internal RAM. It consists of up to 128 four-byte entries, of which any sequential slice can be displayed:
<pre>
(Byte 1) (Byte 0)
15 bit 8 7 bit 0
---- ---- ---- ----
vhPi pppt tttt tttt
|||| |||| |||| ||||
|||| |||+--++++-++++- Tile index (0-511) - only tile bank 0
|||| +++------------- Palette (0-7) - mapped to screen palettes 8-15
|||+----------------- Window location - 0 = inside, 1 = outside
||+------------------ Priority - 0 = behind Screen 2, 1 = in front of Screen 2
|+------------------- Horizontal flip
+-------------------- Vertical flip
(Byte 2)
7 bit 0
---- ----
yyyy yyyy
|||| ||||
++++-++++- Y coordinate
(Byte 3)
7 bit 0
---- ----
xxxx xxxx
|||| ||||
++++-++++- X coordinate
</pre>
There is a sprite limit of 32 per scanline. This means that for each scanline, only the first 32 sprites will be drawn. Note that this includes sprites obscured by windows or outside of visible X coordinates; this list is determined solely by the Y coordinate. Between sprites themselves, earlier sprites in the list are always drawn on top of later sprites in the list.
The sprite table is copied from the console's RAM to a SoC-internal buffer every frame on line <tt>144</tt>; one word for every clock of the line, totaling 256 words (512 bytes) for 256 clocks. This internal buffer is then used for reading sprite data on the next frame.
=== Visibility priority ===
For display components, the visibility priority is as follows:
* Sprite 0, high priority
* Sprite 127, high priority
* Screen 2
* Sprite 0, low priority
* Sprite 127, low priority
* Screen 1
* Background color
=== Windows ===
Screen 2 and sprites can optionally have their drawing restricted within or outside of their specific rectangular windows.
Note that for sprites, the window is enabled globally (for all sprites), but each sprite can individually decide if it's rendered inside or outside of it.
=== Icons ===
The WonderSwan features six LCD segment icons which are displayed to the right<sup>(color)</sup> or below<sup>(mono)</sup> the main display. These are, as follows:
* Aux 3 - large circle,
* Aux 2 - medium circle,
* Aux 1 - small circle,
* Horizontal orientation,
* Vertical orientation,
* Sleep.
== Interrupts ==
The display circuit generates two interrupts of its own:
* Display Interrupt Line Match - when <code>Display Current Line</code> == <code>Display Interrupt Line</code>, at the beginning of said line.
* Display Vertical Blank - when <code>Display Current Line</code> == <code>144</code>, at the beginning of said line.
It also provides a timing source for the two Horizontal and Vertical Blank [[Timers]], which provide their own respective interrupts.
== I/O ports ==
{{Anchor|Display Control}}
=== Display Control ($00) ===
<pre>
7 bit 0
---- ----
..wo Ws21
|| ||||
|| |||+- Enable Screen 1 layer
|| ||+-- Enable Screen 2 layer
|| |+--- Enable Sprite layer
|| +---- Enable Sprite window
|+------ Screen 2 tiles are drawn (if window enabled):
| 0 = inside window,
| 1 = outside window.
+------- Enable Screen 2 window
</pre>
{{Anchor|Display Background}}
=== Display Background Color ($01) ===
<pre>
(mono) (color)
7 bit 0 7 bit 0
---- ---- ---- ----
.... .sss pppp iiii
||| |||| ||||
+++- Value |||| ++++- Index in palette (0-15)
(0-7) ++++------ Color palette (0-15)
</pre>
{{Anchor|Display Current Line}}
=== Display Current Line ($02 read) ===
The current line being drawn by the display.
Note that lines are sent to the display with a one-line delay. This matters for color palette or shade LUT manipulation; changing these values when <code>current line == 1</code> will actually affect line 0.
{{Anchor|Display Interrupt Line}}
=== Display Interrupt Line ($03) ===
The line to emit an interrupt on.
{{Anchor|Sprite Table Address}}
=== Sprite Table Address ($04) ===
<pre>
7 bit 0
---- ----
..Aa aaaa
|| ||||
|+-++++- Address (bits 9-13)
+------- Address (bit 14) - color only
</pre>
{{Anchor|Sprite Table First}}
=== Sprite Table First ($05) ===
<pre>
7 bit 0
---- ----
.iii iiii
||| ||||
+++-++++- Index of first sprite entry to draw (0-127)
</pre>
{{Anchor|Sprite Table Count}}
=== Sprite Table Count ($06) ===
<pre>
7 bit 0
---- ----
cccc cccc
|||| ||||
++++-++++- Count of sprite entries to draw (1-128)
</pre>
{{Anchor|Screen Address}}
=== Screen Address ($07) ===
<pre>
7 bit 0
---- ----
2222 1111
|||| ||||
|||| |+++- Screen 1 address (bits 11-13)
|||| +---- Screen 1 address (bit 14) - color only
|+++------ Screen 2 address (bits 11-13)
+--------- Screen 2 address (bit 14) - color only
</pre>
{{Anchor|Screen 2 Window}}
=== Screen 2 Window Left ($08) ===
=== Screen 2 Window Top ($09) ===
=== Screen 2 Window Right ($0A) ===
=== Screen 2 Window Bottom ($0B) ===
The X and Y coordinates of the Screen 2 window.
Note that all coordinates are inclusive; for example, for a 200x100 window in the top-left corner, the values should be set as follows:
* Left - 0,
* Top - 0,
* Right - 199,
* Bottom - 99.
{{Anchor|Sprite Window}}
=== Sprite Window Left ($0C) ===
=== Sprite Window Top ($0D) ===
=== Sprite Window Right ($0E) ===
=== Sprite Window Bottom ($0F) ===
The X and Y coordinates of the Sprite window.
Note that all coordinates are inclusive.
{{Anchor|Screen Scroll}}
=== Screen 1 Scroll X ($10) ===
=== Screen 1 Scroll Y ($11) ===
The X and Y coordinates that Screen 1 is scrolled by.
For example, setting Scroll X to 24 and Scroll Y to 8 will omit, in 8x8 tile units, the first three rows and the first two columns of the 32x32 screen.
=== Screen 2 Scroll X ($12) ===
=== Screen 2 Scroll Y ($13) ===
The X and Y coordinates that Screen 2 is scrolled by.
{{Anchor|LCD Control}}
=== LCD Control ($14) ===
<pre>
7 bit 0
---- ----
.... ..Ce
||
|+- LCD Enable: 0 = sleep, 1 = enabled
+-- Contrast (WSC): 0 = low, 1 = high
</pre>
{{Anchor|LCD Icon Control}}
=== LCD Icon Control ($15) ===
<pre>
7 bit 0
---- ----
..32 1hvs
|| ||||
|| |||+- Sleep
|| ||+-- Vertical orientation
|| |+--- Horizontal orientation
|| +---- Aux 1
|+------ Aux 2
+------- Aux 3
</pre>
{{Anchor|LCD Mono Shade LUT}}
=== LCD Mono Shade LUT ($1C-$1F) ===
<pre>
$1C $1D $1E $1F
7 bit 0 7 bit 0 7 bit 0 7 bit 0
---- ---- ---- ---- ---- ---- ---- ----
1111 0000 3333 2222 5555 4444 7777 6666
</pre>
{{Anchor|LCD Mono Palette}}
=== LCD Mono Palette 0..15 ($20, $21 .. $3E, $3F) ===
The monochrome palette is laid out as sixteen words:
<pre>
N+1 N
15 bit 8 7 bit 0
---- ---- ---- ----
.333 .222 .111 .000
||| ||| ||| |||
||| ||| ||| +++- Shade LUT index for color 0
||| ||| +++------ Shade LUT index for color 1
||| +++------------ Shade LUT index for color 2
+++----------------- Shade LUT index for color 3
</pre>
== Internal I/O ports ==
These I/O ports are said to be internal and not intended for use by commercial games.
{{Anchor|LCD Final Line}}
=== LCD Final Line ($16) ===
The final line preceding line counter restart and the beginning of active display. By default, this is set to 158, which equals 159 total lines per frame.
It is said setting this register to an odd value on SwanCrystal has an adverse effect to the LCD panel<ref>[http://daifukkat.su/docs/wsman/#REG_LCD_VTOTAL REG_LCD_VTOTAL - WSMan]</ref>, but the exact mechanism is unknown.
{{Anchor|LCD Back Porch Line}}
=== LCD Back Porch Line ($17, WSC only) ===
This port is available on the WonderSwan Color only - not the SwanCrystal!
The final line preceding the vertical back porch; by default, this should be set to 155.
The vertical back porch of the LCD is assumed to be 4 lines by some hardware, including IPS mods, as well as the official "TV Swan" capture device. Given that the first visible line is sent to the LCD on the display's line 1, this should be generally set to <code>LCD Final Line - 3</code>.
Conversely, it is said moving this value closer to vertical blank improves LCD visibility<ref>[http://daifukkat.su/docs/wsman/#REG_LCD_VSYNC REG_LCD_VSYNC - WSMan]</ref>, but the exact mechanism is unknown.
{{Anchor|LCD Status}}
=== LCD Status ($1A) ===
<pre>
7 bit 0
---- ----
...v vv.s
| || |
| || +- LCD sleep: 0 = no, 1 = sleep
| ||
| || Volume segments:
| |+--- Volume B (medium, high)
| +---- Volume A (low, high)
+------ Speaker
</pre>
=== TFT LCD Configuration ($70, $71, $72, $73, $74, $75, $76, $77 SwanCrystal only) ===
These eight bytes are read from internal EEPROM and configure unknown aspects of the console's TFT LCD panel.
They are only writable while the [[Boot ROM]] is unlocked - locking has the side effect of making them read-only.
== Notes ==
<references />
8666cc7840ebeb9f8806f09823fde519d7ee19b4
WSdev Wiki
0
1
310
250
2024-07-12T20:29:25Z
Asie
351
/* Links */ might as well add Wonderful
wikitext
text/x-wiki
'''WonderSwan Development Wiki'''
== Reference ==
=== General ===
* [[Memory map]]
* [[I/O port map]]
* [[ROM header]]
* [[NEC V30MZ]] - the WonderSwan CPU (80186-compatible)
* [[Timing]]
=== Console components ===
* [[SoC]]
** [[Display]]
** [[Sound]]
*** [[Hyper Voice]]<sup>(color)</sup>
** [[Keypad]]
** [[Timers]]
** [[Interrupts]]
** [[UART]]
** [[DMA]]<sup>(color)</sup>
* [[Boot ROM]]
* [[EEPROM|Internal EEPROM]]
** [[Splash animation]]<sup>(color)</sup>
=== Cartridge components ===
* [[Cartridge connector]]
* [[Mapper]]
** [[Bandai 2001]]
** [[Bandai 2003]]
** [[KARNAK]]
* [[EEPROM]] (2001)
* [[Real-Time Clock]] (2003)
=== Pinouts ===
* [[Cartridge connector#Pinout|Cartridge pinout]]
* [[Accessory port pinout]]
* [[2001 Mapper pinout]]
* [[2003 Mapper pinout]]
* [[KARNAK pinout]]
* [[GIZA pinout]]
* [[S-3511A pinout]]
=== Accessories ===
* [[WonderBeat 9480]] headphone adapter
* [[WonderBorg]] robot
* [[WonderGate]] mobile adapter
* [[WonderWave]] infrared adapter
=== WonderWitch ===
* [[WonderWitch]]
** [[WonderWitch/FreyaBIOS|FreyaBIOS]]
** [[WonderWitch/FreyaOS|FreyaOS]]
** [[WonderWitch .fx files|.fx file format]]
== Links ==
* [https://wonderful.asie.pl/wiki/doku.php?id=wswan:index#guides Wonderful Toolchain Wiki] - gcc-ia16-based homebrew toolchain guides and documentation
* [https://github.com/WonderfulToolchain/awesome-wsdev awesome-wsdev] - curated documentation/tools/source code link list
== MediaWiki ==
* [https://www.mediawiki.org/wiki/Special:MyLanguage/Help:Contents User's Guide]
* [https://www.mediawiki.org/wiki/Special:MyLanguage/Manual:FAQ MediaWiki FAQ]
* [[:Category:Deletion requests|Deletion requests]]
9d984a27cfd7ceb10c7870a0983867b33f7fe111
WonderWitch/FreyaBIOS/Sound
0
50
316
2024-07-20T08:18:39Z
Asie
351
Created page with "The Sound interrupt provides an abstraction layer for the WonderSwan's [[Sound|sound hardware]]. == Interrupts == === INT 15/AH=00h - sound_init === * AH = 00h === INT 15/AH=01h - sound_set_channel === * AH = 01h * BL = [[Sound#Sound Channel Control|Channel Control]] value === INT 15/AH=02h - sound_get_channel === * AH = 02h Return: * AL = [[Sound#Sound Channel Control|Channel Control]] value === INT 15/AH=03h - sound_set_output === * AH = 03h * BL = Sound#S..."
wikitext
text/x-wiki
The Sound interrupt provides an abstraction layer for the WonderSwan's [[Sound|sound hardware]].
== Interrupts ==
=== INT 15/AH=00h - sound_init ===
* AH = 00h
=== INT 15/AH=01h - sound_set_channel ===
* AH = 01h
* BL = [[Sound#Sound Channel Control|Channel Control]] value
=== INT 15/AH=02h - sound_get_channel ===
* AH = 02h
Return:
* AL = [[Sound#Sound Channel Control|Channel Control]] value
=== INT 15/AH=03h - sound_set_output ===
* AH = 03h
* BL = [[Sound#Sound Output Control|Output Control]] value
=== INT 15/AH=04h - sound_get_output ===
* AH = 04h
Return:
* AL = [[Sound#Sound Output Control|Output Control]] value
=== INT 15/AH=05h - sound_set_wave ===
* AH = 05h
* AL = Channel (0, 1, 2, 3)
* DS:DX = Pointer to waveform data (16 bytes)
=== INT 15/AH=06h - sound_set_pitch ===
* AH = 06h
* AL = Channel (0, 1, 2, 3)
* BX = Frequency divider (0 - 2047)
=== INT 15/AH=07h - sound_get_pitch ===
* AH = 07h
* AL = Channel (0, 1, 2, 3)
Return:
* AX = Frequency divider (0 - 2047)
=== INT 15/AH=08h - sound_set_volume ===
* AH = 08h
* AL = Channel (0, 1, 2, 3)
* BL = [[Sound#Sound Channel Volume|Channel Volume]] value
=== INT 15/AH=09h - sound_get_volume ===
* AH = 09h
* AL = Channel (0, 1, 2, 3)
Return:
* AL = [[Sound#Sound Channel Volume|Channel Volume]] value
=== INT 15/AH=0Ah - sound_set_sweep ===
* AH = 0Ah
* BL = [[Sound#Sound Channel 3 Sweep Amount|Sweep Amount]]
* CL = [[Sound#Sound Channel 3 Sweep Ticks|Sweep Ticks]]
=== INT 15/AH=0Bh - sound_get_sweep ===
* AH = 0Bh
Return:
* AL = [[Sound#Sound Channel 3 Sweep Amount|Sweep Amount]]
* AH = [[Sound#Sound Channel 3 Sweep Ticks|Sweep Ticks]]
=== INT 15/AH=0Ch - sound_set_noise ===
* AH = 0Ch
* BL = [[Sound#Sound Channel 4 Noise Control|Channel 4 Noise Control]] value
=== INT 15/AH=0Dh - sound_get_noise ===
* AH = 0Dh
Return:
* AL = [[Sound#Sound Channel 4 Noise Control|Channel 4 Noise Control]] value
=== INT 15/AH=0Eh - sound_get_random ===
* AH = 0Eh
Return:
* AX = [[Sound#Sound Channel 4 LFSR Register|Channel 4 LFSR Register]] value
9e4b7048f4dfc23900fa9a2c6e8903df415bb79f
317
316
2024-07-20T08:20:31Z
Asie
351
wikitext
text/x-wiki
The Sound interrupt provides an abstraction layer for the WonderSwan's [[Sound|sound hardware]].
== Interrupts ==
=== INT $15/AH=$00 - sound_init ===
* AH = $00
=== INT $15/AH=$01 - sound_set_channel ===
* AH = $01
* BL = [[Sound#Sound Channel Control|Channel Control]] value
=== INT $15/AH=$02 - sound_get_channel ===
* AH = $02
Return:
* AL = [[Sound#Sound Channel Control|Channel Control]] value
=== INT $15/AH=$03 - sound_set_output ===
* AH = $03
* BL = [[Sound#Sound Output Control|Output Control]] value
=== INT $15/AH=$04 - sound_get_output ===
* AH = $04
Return:
* AL = [[Sound#Sound Output Control|Output Control]] value
=== INT $15/AH=$05 - sound_set_wave ===
* AH = $05
* AL = Channel (0, 1, 2, 3)
* DS:DX = Pointer to waveform data (16 bytes)
=== INT $15/AH=$06 - sound_set_pitch ===
* AH = $06
* AL = Channel (0, 1, 2, 3)
* BX = Frequency divider (0 - 2047)
=== INT $15/AH=$07 - sound_get_pitch ===
* AH = $07
* AL = Channel (0, 1, 2, 3)
Return:
* AX = Frequency divider (0 - 2047)
=== INT $15/AH=$08 - sound_set_volume ===
* AH = $08
* AL = Channel (0, 1, 2, 3)
* BL = [[Sound#Sound Channel Volume|Channel Volume]] value
=== INT $15/AH=$09 - sound_get_volume ===
* AH = $09
* AL = Channel (0, 1, 2, 3)
Return:
* AL = [[Sound#Sound Channel Volume|Channel Volume]] value
=== INT $15/AH=$0A - sound_set_sweep ===
* AH = $0A
* BL = [[Sound#Sound Channel 3 Sweep Amount|Sweep Amount]]
* CL = [[Sound#Sound Channel 3 Sweep Ticks|Sweep Ticks]]
=== INT $15/AH=$0B - sound_get_sweep ===
* AH = $0B
Return:
* AL = [[Sound#Sound Channel 3 Sweep Amount|Sweep Amount]]
* AH = [[Sound#Sound Channel 3 Sweep Ticks|Sweep Ticks]]
=== INT $15/AH=$0C - sound_set_noise ===
* AH = $0C
* BL = [[Sound#Sound Channel 4 Noise Control|Channel 4 Noise Control]] value
=== INT $15/AH=$0D - sound_get_noise ===
* AH = $0D
Return:
* AL = [[Sound#Sound Channel 4 Noise Control|Channel 4 Noise Control]] value
=== INT $15/AH=$0E - sound_get_random ===
* AH = $0E
Return:
* AX = [[Sound#Sound Channel 4 LFSR Register|Channel 4 LFSR Register]] value
544f959160185f4723f5954ae5568c73de718c31
WonderWitch
0
41
318
261
2024-07-23T20:05:52Z
Asie
351
wikitext
text/x-wiki
The WonderWitch is an official homebrew development kit released by Qute Corporation on July 18th, 2000.
== Hardware ==
The WonderWitch cartridge is based on the [[Bandai 2003]] mapper. It provides an RTC, as well as NOR self-flashing functionality using the Fujitsu MBM29DL400TC chip.
There were three means of acquiring WonderWitch cartridges:
* '''WonderWitch''', a software development kit containing a reflashable cartridge, a WonderSwan<->RS-232 adapter, a development manual and a development tool CD;
* '''WonderWitch Player''', a priced-down user-only version omitting the development manual and tooling;
* The VAR program, allowing independent creators to buy reflashable cartridges in bulk, in units of 20 or 100.
== Software ==
The WonderWitch provides an abstraction layer and helper libraries, split into two modules:
* [[WonderWitch/FreyaBIOS|FreyaBIOS]] - providing a hardware abstraction layer and some utility functions,
* [[WonderWitch/FreyaOS|FreyaOS]] - providing helper libraries and higher-level concepts, such as processes and files.
== Memory map ==
=== Internal RAM (0x00000 - 0x0FFFF) ===
{| class="wikitable"
! From
! To
! Description
|-
| 0x00000
| 0x00???
| Interrupt vectors
|-
| 0x00???
| 0x00???
| ???
|-
| 0x00E00
| 0x03FFF
| Space used by user programs (sprite, screen, tile data)
|-
| 0x04000
| 0x0BFFF
| Space used by user programs (color tile data)
|-
| 0x0C000
| 0x0FDFF
| ???
|-
| 0x0FE00
| 0x0FFFF
| Space used by user programs (color palette data)
|-
|}
=== Cartridge SRAM (0x10000 - 0x1FFFF) ===
=== Cartridge flash (0x80000 - 0xFFFFF) ===
The 512KB of NOR flash memory is mapped and partitioned as follows:
{| class="wikitable"
! Linear address
! Size
! Description
|-
| 0x8nnnn
| rowspan="6" | 384 KB
| rowspan="6" | [[WonderWitch/File system|File system]]
|-
| 0x9nnnn
|-
| 0xAnnnn
|-
| 0xBnnnn
|-
| 0xCnnnn
|-
| 0xDnnnn
|-
| 0xEnnnn
| 64 KB
| [[WonderWitch/FreyaOS|FreyaOS]]
|-
| 0xFnnnn
| 64 KB
| [[WonderWitch/FreyaBIOS|FreyaBIOS]]
|}
=== Interrupt vectors ===
{| class="wikitable"
! Start
! End
! Description
|-
| 0x00
| 0x07
| CPU interrupts
|-
| 0x08
| 0x0F
|
|-
| 0x10
| 0x18
| [[WonderWitch/FreyaBIOS|FreyaBIOS]] interrupts
|}
Internal console RAM is generally managed by [[WonderWitch/FreyaBIOS|FreyaBIOS]], while SRAM is managed by [[WonderWitch/FreyaOS|FreyaOS]].
== Development tools ==
TODO
== Links ==
* [https://github.com/up-n-atom/WonderWitch/blob/main/Datasheets/MBM29DL400BC-12PFTN_to_MBM29DL400TC-90PFTN.pdf Fujitsu MBM29DL400TC datasheet]
068f2917f6aa2fcff10dfda8536101737c9ededb
WonderWitch/FreyaBIOS/Display
0
51
319
2024-07-23T20:27:28Z
Asie
351
Created page with "The Display interrupt provides an abstraction layer and helpers for the WonderSwan's [[Display|display hardware]]. Note that features specific to the WonderSwan Color are implemented using [[WonderWitch/Libwwc|libwwc]], which is linked statically with the user program and thus not part of the BIOS call surface. == Interrupts == === INT $12/AH=$00 - display_control === * AH = $00 * BX = [[Display#Display Control|Display Control]] value === INT $12/AH=$01 - display_st..."
wikitext
text/x-wiki
The Display interrupt provides an abstraction layer and helpers for the WonderSwan's [[Display|display hardware]].
Note that features specific to the WonderSwan Color are implemented using [[WonderWitch/Libwwc|libwwc]], which is linked statically with the user program and thus not part of the BIOS call surface.
== Interrupts ==
=== INT $12/AH=$00 - display_control ===
* AH = $00
* BX = [[Display#Display Control|Display Control]] value
=== INT $12/AH=$01 - display_status ===
* AH = $01
Return:
* AX = [[Display#Display Control|Display Control]] value
=== INT $12/AH=$02 - font_set_monodata ===
* AH = $02
* BX = Starting tile
* CX = Tile count
* DS:DX = Input data buffer (<code>8 x Tile count</code> bytes)
Stores 1 bit-per-pixel tile data, which is expanded to 2 bits-per-pixel using the configured color.
=== INT $12/AH=$03 - font_set_colordata ===
* AH = $03
* BX = Starting tile
* CX = Tile count
* DS:DX = Input data buffer (<code>16 x Tile count</code> bytes)
Stores 2 bit-per-pixel tile data.
=== INT $12/AH=$04 - font_get_data ===
* AH = $04
* BX = Starting tile
* CX = Tile count
* DS:DX = Output data buffer (<code>16 x Tile count</code> bytes)
Retrieves 2 bit-per-pixel tile data.
=== INT $12/AH=$05 - font_set_color ===
* AH = $05
* BX = Color
<code>
15 bit 8 7 bit 0
---- ---- ---- ----
.... .... .... bbff
||||
||++- Foreground color (0-3)
++--- Background color (0-3)
</code>
Used by <code>font_set_monodata</code>.
=== INT $12/AH=$06 - font_get_color ===
* AH = $05
Return:
* AX = Color
=== INT $12/AH=$07 - screen_set_char ===
* AH = $07
* AL = Screen (0, 1)
* BL = Top-left tile X coordinate
* BH = Top-left tile Y coordinate
* CL = Width, in tiles
* CH = Height, in tiles
* DS:DX = Input tilemap buffer (<code>2 x Width x Height</code> bytes)
Places a rectangular tilemap on the specified screen.
=== INT $12/AH=$08 - screen_get_char ===
* AH = $07
* AL = Screen (0, 1)
* BL = Top-left tile X coordinate
* BH = Top-left tile Y coordinate
* CL = Width, in tiles
* CH = Height, in tiles
* DS:DX = Output tilemap buffer (<code>2 x Width x Height</code> bytes)
Retrieves a rectangular tilemap from the specified screen.
Special case: If CL/CH are equal to 0, <code>DS:DX</code> is ignored and instead <code>AX</code> is set to the tile at coordinates <code>(BL, BH)</code>.
=== INT $12/AH=$09 - screen_fill_char ===
* AH = $07
* AL = Screen (0, 1)
* BL = Top-left tile X coordinate
* BH = Top-left tile Y coordinate
* CL = Width, in tiles
* CH = Height, in tiles
* DX = Tile attribute
Fills a rectangular area with the specified tile attribute.
=== INT $12/AH=$0A - screen_fill_attr ===
* AH = $07
* AL = Screen (0, 1)
* BL = Top-left tile X coordinate
* BH = Top-left tile Y coordinate
* CL = Width, in tiles
* CH = Height, in tiles
* DX = Tile data
* SI = Tile mask
Modifies each tile in the specified rectangular area as follows: <code>tile = ((tile & SI) | DX)</code>.
=== INT $12/AH=$0B - sprite_set_range ===
* AH = $0B
* BX = [[Display#Sprite Table First|Sprite Table First]]
* CX = [[Display#Sprite Table Count|Sprite Table Count]]
=== INT $12/AH=$0C - sprite_set_char ===
* AH = $0C
* BX = Sprite ID in table (0 - 127)
* CX = Sprite attribute
=== INT $12/AH=$0D - sprite_get_char ===
* AH = $0D
* BX = Sprite ID in table (0 - 127)
Return:
* AX = Sprite attribute
=== INT $12/AH=$0E - sprite_set_location ===
* AH = $0E
* BX = Sprite ID in table (0 - 127)
* DL = X coordinate
* DH = Y coordinate
Note that DL/DH are swapped relative to the order in which the sprite coordinate bytes are stored in memory.
=== INT $12/AH=$0F - sprite_get_location ===
* AH = $0F
* BX = Sprite ID in table (0 - 127)
Return:
* AL = X coordinate
* AH = Y coordinate
=== INT $12/AH=$10 - sprite_set_char_location ===
* AH = $10
* BX = Sprite ID in table (0 - 127)
* CX = Sprite attribute
* DL = X coordinate
* DH = Y coordinate
=== INT $12/AH=$11 - sprite_get_char_location ===
* AH = $11
* BX = Sprite ID in table (0 - 127)
Return:
* AX = Sprite attribute
* DL = X coordinate
* DH = Y coordinate
=== INT $12/AH=$12 - sprite_set_data ===
* AH = $12
* BX = Initial sprite ID in table (0 - 127)
* CX = Sprite count
* DS:DX = Input data buffer (<code>4 x Sprite count</code> bytes)
=== INT $12/AH=$13 - screen_set_scroll ===
* AH = $13
* AL = Screen (0, 1)
* BL = [[Display#Screen Scroll|Screen Scroll X]] value
* BH = [[Display#Screen Scroll|Screen Scroll Y]] value
=== INT $12/AH=$14 - screen_get_scroll ===
* AH = $14
* AL = Screen (0, 1)
Return:
* AL = [[Display#Screen Scroll|Screen Scroll X]] value
* AH = [[Display#Screen Scroll|Screen Scroll Y]] value
=== INT $12/AH=$15 - screen2_set_window ===
* AH = $15
* BL = [[Display#Screen 2 Window|Screen 2 Window Left]] value
* BH = [[Display#Screen 2 Window|Screen 2 Window Top]] value
* CL = Window width
* CH = Window height
=== INT $12/AH=$16 - screen2_get_window ===
* AH = $15
Return:
* AL = [[Display#Screen 2 Window|Screen 2 Window Left]] value
* AH = [[Display#Screen 2 Window|Screen 2 Window Top]] value
* DL = Window width
* DH = Window height
=== INT $12/AH=$17 - sprite_set_window ===
* AH = $17
* BL = [[Display#Sprite Window|Sprite Window Left]] value
* BH = [[Display#Sprite Window|Sprite Window Top]] value
* CL = Window width
* CH = Window height
=== INT $12/AH=$18 - sprite_get_window ===
* AH = $18
Return:
* AL = [[Display#Sprite Window|Sprite Window Left]] value
* AH = [[Display#Sprite Window|Sprite Window Top]] value
* DL = Window width
* DH = Window height
=== INT $12/AH=$19 - palette_set_color ===
* AH = $19
* BX = Palette index (0 - 15)
* CX = [[Display#LCD Mono Palette|LCD Mono Palette]] value
=== INT $12/AH=$1A - palette_get_color ===
* AH = $1A
* BX = Palette index (0 - 15)
Return:
* AX = [[Display#LCD Mono Palette|LCD Mono Palette]] value
=== INT $12/AH=$1B - lcd_set_color ===
* AH = $1B
* CX:BX = [[Display#LCD Mono Shade LUT|LCD Mono Shade LUT]] value
=== INT $12/AH=$1C - lcd_get_color ===
* AH = $1C
Return:
* DX:AX = [[Display#LCD Mono Shade LUT|LCD Mono Shade LUT]] value
=== INT $12/AH=$1D - lcd_set_segments ===
* AH = $1D
* BX = [[Display#LCD Icon Control|LCD Icon Control]] value
=== INT $12/AH=$1E - lcd_get_segments ===
* AH = $1E
Return:
* AX = [[Display#LCD Icon Control|LCD Icon Control]] value
=== INT $12/AH=$1F - lcd_set_sleep ===
=== INT $12/AH=$20 - lcd_get_sleep ===
=== INT $12/AH=$21 - screen_set_vram ===
* AH = $21
* AL = Screen (0, 1)
* BL = Internal RAM address, shifted right by 11
Note: This function is undocumented.
=== INT $12/AH=$22 - sprite_set_vram ===
* AH = $21
* BL = Internal RAM address, shifted right by 9
Note: This function is undocumented.
c69966ee5c10d7cebd25da8115702154d4ea75f1
320
319
2024-07-23T20:28:02Z
Asie
351
wikitext
text/x-wiki
The Display interrupt provides an abstraction layer and helpers for the WonderSwan's [[Display|display hardware]].
Note that features specific to the WonderSwan Color are implemented using [[WonderWitch/Libwwc|libwwc]], which is linked statically with the user program and thus not part of the BIOS call surface.
== Interrupts ==
=== INT $12/AH=$00 - display_control ===
* AH = $00
* BX = [[Display#Display Control|Display Control]] value
=== INT $12/AH=$01 - display_status ===
* AH = $01
Return:
* AX = [[Display#Display Control|Display Control]] value
=== INT $12/AH=$02 - font_set_monodata ===
* AH = $02
* BX = Starting tile
* CX = Tile count
* DS:DX = Input data buffer (<code>8 x Tile count</code> bytes)
Stores 1 bit-per-pixel tile data, which is expanded to 2 bits-per-pixel using the configured color.
=== INT $12/AH=$03 - font_set_colordata ===
* AH = $03
* BX = Starting tile
* CX = Tile count
* DS:DX = Input data buffer (<code>16 x Tile count</code> bytes)
Stores 2 bit-per-pixel tile data.
=== INT $12/AH=$04 - font_get_data ===
* AH = $04
* BX = Starting tile
* CX = Tile count
* DS:DX = Output data buffer (<code>16 x Tile count</code> bytes)
Retrieves 2 bit-per-pixel tile data.
=== INT $12/AH=$05 - font_set_color ===
* AH = $05
* BX = Color
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
.... .... .... bbff
||||
||++- Foreground color (0-3)
++--- Background color (0-3)
</pre>
Used by <code>font_set_monodata</code>.
=== INT $12/AH=$06 - font_get_color ===
* AH = $05
Return:
* AX = Color
=== INT $12/AH=$07 - screen_set_char ===
* AH = $07
* AL = Screen (0, 1)
* BL = Top-left tile X coordinate
* BH = Top-left tile Y coordinate
* CL = Width, in tiles
* CH = Height, in tiles
* DS:DX = Input tilemap buffer (<code>2 x Width x Height</code> bytes)
Places a rectangular tilemap on the specified screen.
=== INT $12/AH=$08 - screen_get_char ===
* AH = $07
* AL = Screen (0, 1)
* BL = Top-left tile X coordinate
* BH = Top-left tile Y coordinate
* CL = Width, in tiles
* CH = Height, in tiles
* DS:DX = Output tilemap buffer (<code>2 x Width x Height</code> bytes)
Retrieves a rectangular tilemap from the specified screen.
Special case: If CL/CH are equal to 0, <code>DS:DX</code> is ignored and instead <code>AX</code> is set to the tile at coordinates <code>(BL, BH)</code>.
=== INT $12/AH=$09 - screen_fill_char ===
* AH = $07
* AL = Screen (0, 1)
* BL = Top-left tile X coordinate
* BH = Top-left tile Y coordinate
* CL = Width, in tiles
* CH = Height, in tiles
* DX = Tile attribute
Fills a rectangular area with the specified tile attribute.
=== INT $12/AH=$0A - screen_fill_attr ===
* AH = $07
* AL = Screen (0, 1)
* BL = Top-left tile X coordinate
* BH = Top-left tile Y coordinate
* CL = Width, in tiles
* CH = Height, in tiles
* DX = Tile data
* SI = Tile mask
Modifies each tile in the specified rectangular area as follows: <code>tile = ((tile & SI) | DX)</code>.
=== INT $12/AH=$0B - sprite_set_range ===
* AH = $0B
* BX = [[Display#Sprite Table First|Sprite Table First]]
* CX = [[Display#Sprite Table Count|Sprite Table Count]]
=== INT $12/AH=$0C - sprite_set_char ===
* AH = $0C
* BX = Sprite ID in table (0 - 127)
* CX = Sprite attribute
=== INT $12/AH=$0D - sprite_get_char ===
* AH = $0D
* BX = Sprite ID in table (0 - 127)
Return:
* AX = Sprite attribute
=== INT $12/AH=$0E - sprite_set_location ===
* AH = $0E
* BX = Sprite ID in table (0 - 127)
* DL = X coordinate
* DH = Y coordinate
Note that DL/DH are swapped relative to the order in which the sprite coordinate bytes are stored in memory.
=== INT $12/AH=$0F - sprite_get_location ===
* AH = $0F
* BX = Sprite ID in table (0 - 127)
Return:
* AL = X coordinate
* AH = Y coordinate
=== INT $12/AH=$10 - sprite_set_char_location ===
* AH = $10
* BX = Sprite ID in table (0 - 127)
* CX = Sprite attribute
* DL = X coordinate
* DH = Y coordinate
=== INT $12/AH=$11 - sprite_get_char_location ===
* AH = $11
* BX = Sprite ID in table (0 - 127)
Return:
* AX = Sprite attribute
* DL = X coordinate
* DH = Y coordinate
=== INT $12/AH=$12 - sprite_set_data ===
* AH = $12
* BX = Initial sprite ID in table (0 - 127)
* CX = Sprite count
* DS:DX = Input data buffer (<code>4 x Sprite count</code> bytes)
=== INT $12/AH=$13 - screen_set_scroll ===
* AH = $13
* AL = Screen (0, 1)
* BL = [[Display#Screen Scroll|Screen Scroll X]] value
* BH = [[Display#Screen Scroll|Screen Scroll Y]] value
=== INT $12/AH=$14 - screen_get_scroll ===
* AH = $14
* AL = Screen (0, 1)
Return:
* AL = [[Display#Screen Scroll|Screen Scroll X]] value
* AH = [[Display#Screen Scroll|Screen Scroll Y]] value
=== INT $12/AH=$15 - screen2_set_window ===
* AH = $15
* BL = [[Display#Screen 2 Window|Screen 2 Window Left]] value
* BH = [[Display#Screen 2 Window|Screen 2 Window Top]] value
* CL = Window width
* CH = Window height
=== INT $12/AH=$16 - screen2_get_window ===
* AH = $15
Return:
* AL = [[Display#Screen 2 Window|Screen 2 Window Left]] value
* AH = [[Display#Screen 2 Window|Screen 2 Window Top]] value
* DL = Window width
* DH = Window height
=== INT $12/AH=$17 - sprite_set_window ===
* AH = $17
* BL = [[Display#Sprite Window|Sprite Window Left]] value
* BH = [[Display#Sprite Window|Sprite Window Top]] value
* CL = Window width
* CH = Window height
=== INT $12/AH=$18 - sprite_get_window ===
* AH = $18
Return:
* AL = [[Display#Sprite Window|Sprite Window Left]] value
* AH = [[Display#Sprite Window|Sprite Window Top]] value
* DL = Window width
* DH = Window height
=== INT $12/AH=$19 - palette_set_color ===
* AH = $19
* BX = Palette index (0 - 15)
* CX = [[Display#LCD Mono Palette|LCD Mono Palette]] value
=== INT $12/AH=$1A - palette_get_color ===
* AH = $1A
* BX = Palette index (0 - 15)
Return:
* AX = [[Display#LCD Mono Palette|LCD Mono Palette]] value
=== INT $12/AH=$1B - lcd_set_color ===
* AH = $1B
* CX:BX = [[Display#LCD Mono Shade LUT|LCD Mono Shade LUT]] value
=== INT $12/AH=$1C - lcd_get_color ===
* AH = $1C
Return:
* DX:AX = [[Display#LCD Mono Shade LUT|LCD Mono Shade LUT]] value
=== INT $12/AH=$1D - lcd_set_segments ===
* AH = $1D
* BX = [[Display#LCD Icon Control|LCD Icon Control]] value
=== INT $12/AH=$1E - lcd_get_segments ===
* AH = $1E
Return:
* AX = [[Display#LCD Icon Control|LCD Icon Control]] value
=== INT $12/AH=$1F - lcd_set_sleep ===
=== INT $12/AH=$20 - lcd_get_sleep ===
=== INT $12/AH=$21 - screen_set_vram ===
* AH = $21
* AL = Screen (0, 1)
* BL = Internal RAM address, shifted right by 11
Note: This function is undocumented.
=== INT $12/AH=$22 - sprite_set_vram ===
* AH = $21
* BL = Internal RAM address, shifted right by 9
Note: This function is undocumented.
09f156ea0981ccf62c248ea00b08453466271d03
325
320
2024-07-27T13:39:47Z
Asie
351
fix AH values
wikitext
text/x-wiki
The Display interrupt provides an abstraction layer and helpers for the WonderSwan's [[Display|display hardware]].
Note that features specific to the WonderSwan Color are implemented using [[WonderWitch/Libwwc|libwwc]], which is linked statically with the user program and thus not part of the BIOS call surface.
== Interrupts ==
=== INT $12/AH=$00 - display_control ===
* AH = $00
* BX = [[Display#Display Control|Display Control]] value
=== INT $12/AH=$01 - display_status ===
* AH = $01
Return:
* AX = [[Display#Display Control|Display Control]] value
=== INT $12/AH=$02 - font_set_monodata ===
* AH = $02
* BX = Starting tile
* CX = Tile count
* DS:DX = Input data buffer (<code>8 x Tile count</code> bytes)
Stores 1 bit-per-pixel tile data, which is expanded to 2 bits-per-pixel using the configured color.
=== INT $12/AH=$03 - font_set_colordata ===
* AH = $03
* BX = Starting tile
* CX = Tile count
* DS:DX = Input data buffer (<code>16 x Tile count</code> bytes)
Stores 2 bit-per-pixel tile data.
=== INT $12/AH=$04 - font_get_data ===
* AH = $04
* BX = Starting tile
* CX = Tile count
* DS:DX = Output data buffer (<code>16 x Tile count</code> bytes)
Retrieves 2 bit-per-pixel tile data.
=== INT $12/AH=$05 - font_set_color ===
* AH = $05
* BX = Color
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
.... .... .... bbff
||||
||++- Foreground color (0-3)
++--- Background color (0-3)
</pre>
Used by <code>font_set_monodata</code>.
=== INT $12/AH=$06 - font_get_color ===
* AH = $06
Return:
* AX = Color
=== INT $12/AH=$07 - screen_set_char ===
* AH = $07
* AL = Screen (0, 1)
* BL = Top-left tile X coordinate
* BH = Top-left tile Y coordinate
* CL = Width, in tiles
* CH = Height, in tiles
* DS:DX = Input tilemap buffer (<code>2 x Width x Height</code> bytes)
Places a rectangular tilemap on the specified screen.
=== INT $12/AH=$08 - screen_get_char ===
* AH = $08
* AL = Screen (0, 1)
* BL = Top-left tile X coordinate
* BH = Top-left tile Y coordinate
* CL = Width, in tiles
* CH = Height, in tiles
* DS:DX = Output tilemap buffer (<code>2 x Width x Height</code> bytes)
Retrieves a rectangular tilemap from the specified screen.
Special case: If CL/CH are equal to 0, <code>DS:DX</code> is ignored and instead <code>AX</code> is set to the tile at coordinates <code>(BL, BH)</code>.
=== INT $12/AH=$09 - screen_fill_char ===
* AH = $09
* AL = Screen (0, 1)
* BL = Top-left tile X coordinate
* BH = Top-left tile Y coordinate
* CL = Width, in tiles
* CH = Height, in tiles
* DX = Tile attribute
Fills a rectangular area with the specified tile attribute.
=== INT $12/AH=$0A - screen_fill_attr ===
* AH = $0A
* AL = Screen (0, 1)
* BL = Top-left tile X coordinate
* BH = Top-left tile Y coordinate
* CL = Width, in tiles
* CH = Height, in tiles
* DX = Tile data
* SI = Tile mask
Modifies each tile in the specified rectangular area as follows: <code>tile = ((tile & SI) | DX)</code>.
=== INT $12/AH=$0B - sprite_set_range ===
* AH = $0B
* BX = [[Display#Sprite Table First|Sprite Table First]]
* CX = [[Display#Sprite Table Count|Sprite Table Count]]
=== INT $12/AH=$0C - sprite_set_char ===
* AH = $0C
* BX = Sprite ID in table (0 - 127)
* CX = Sprite attribute
=== INT $12/AH=$0D - sprite_get_char ===
* AH = $0D
* BX = Sprite ID in table (0 - 127)
Return:
* AX = Sprite attribute
=== INT $12/AH=$0E - sprite_set_location ===
* AH = $0E
* BX = Sprite ID in table (0 - 127)
* DL = X coordinate
* DH = Y coordinate
Note that DL/DH are swapped relative to the order in which the sprite coordinate bytes are stored in memory.
=== INT $12/AH=$0F - sprite_get_location ===
* AH = $0F
* BX = Sprite ID in table (0 - 127)
Return:
* AL = X coordinate
* AH = Y coordinate
=== INT $12/AH=$10 - sprite_set_char_location ===
* AH = $10
* BX = Sprite ID in table (0 - 127)
* CX = Sprite attribute
* DL = X coordinate
* DH = Y coordinate
=== INT $12/AH=$11 - sprite_get_char_location ===
* AH = $11
* BX = Sprite ID in table (0 - 127)
Return:
* AX = Sprite attribute
* DL = X coordinate
* DH = Y coordinate
=== INT $12/AH=$12 - sprite_set_data ===
* AH = $12
* BX = Initial sprite ID in table (0 - 127)
* CX = Sprite count
* DS:DX = Input data buffer (<code>4 x Sprite count</code> bytes)
=== INT $12/AH=$13 - screen_set_scroll ===
* AH = $13
* AL = Screen (0, 1)
* BL = [[Display#Screen Scroll|Screen Scroll X]] value
* BH = [[Display#Screen Scroll|Screen Scroll Y]] value
=== INT $12/AH=$14 - screen_get_scroll ===
* AH = $14
* AL = Screen (0, 1)
Return:
* AL = [[Display#Screen Scroll|Screen Scroll X]] value
* AH = [[Display#Screen Scroll|Screen Scroll Y]] value
=== INT $12/AH=$15 - screen2_set_window ===
* AH = $15
* BL = [[Display#Screen 2 Window|Screen 2 Window Left]] value
* BH = [[Display#Screen 2 Window|Screen 2 Window Top]] value
* CL = Window width
* CH = Window height
=== INT $12/AH=$16 - screen2_get_window ===
* AH = $16
Return:
* AL = [[Display#Screen 2 Window|Screen 2 Window Left]] value
* AH = [[Display#Screen 2 Window|Screen 2 Window Top]] value
* DL = Window width
* DH = Window height
=== INT $12/AH=$17 - sprite_set_window ===
* AH = $17
* BL = [[Display#Sprite Window|Sprite Window Left]] value
* BH = [[Display#Sprite Window|Sprite Window Top]] value
* CL = Window width
* CH = Window height
=== INT $12/AH=$18 - sprite_get_window ===
* AH = $18
Return:
* AL = [[Display#Sprite Window|Sprite Window Left]] value
* AH = [[Display#Sprite Window|Sprite Window Top]] value
* DL = Window width
* DH = Window height
=== INT $12/AH=$19 - palette_set_color ===
* AH = $19
* BX = Palette index (0 - 15)
* CX = [[Display#LCD Mono Palette|LCD Mono Palette]] value
=== INT $12/AH=$1A - palette_get_color ===
* AH = $1A
* BX = Palette index (0 - 15)
Return:
* AX = [[Display#LCD Mono Palette|LCD Mono Palette]] value
=== INT $12/AH=$1B - lcd_set_color ===
* AH = $1B
* CX:BX = [[Display#LCD Mono Shade LUT|LCD Mono Shade LUT]] value
=== INT $12/AH=$1C - lcd_get_color ===
* AH = $1C
Return:
* DX:AX = [[Display#LCD Mono Shade LUT|LCD Mono Shade LUT]] value
=== INT $12/AH=$1D - lcd_set_segments ===
* AH = $1D
* BX = [[Display#LCD Icon Control|LCD Icon Control]] value
=== INT $12/AH=$1E - lcd_get_segments ===
* AH = $1E
Return:
* AX = [[Display#LCD Icon Control|LCD Icon Control]] value
=== INT $12/AH=$1F - lcd_set_sleep ===
=== INT $12/AH=$20 - lcd_get_sleep ===
=== INT $12/AH=$21 - screen_set_vram ===
* AH = $21
* AL = Screen (0, 1)
* BL = Internal RAM address, shifted right by 11
Note: This function is undocumented.
=== INT $12/AH=$22 - sprite_set_vram ===
* AH = $22
* BL = Internal RAM address, shifted right by 9
Note: This function is undocumented.
01db17da6d32922280e4539772322e9f1572d283
WonderWitch/FreyaBIOS/Key
0
52
321
2024-07-24T16:08:07Z
Asie
351
Created page with "The Display interrupt provides helper functions for accessing the WonderSwan's [[Keypad|keypad]]. == Interrupts == === INT $11/AH=$00 - key_press_check === * AH = $00 Return: * AX = A bitmask containing the currently held keys. <pre> 15 bit 8 7 bit 0 ---- ---- ---- ---- .... 4321 4321 bas. |||| |||| ||| |||| |||| ||+- Start |||| |||| |+-- A |||| |||| +--- B |||| ++++----- X1/X2/X3/X4 ++++----------- Y1/Y2/Y3/Y4 </pr..."
wikitext
text/x-wiki
The Display interrupt provides helper functions for accessing the WonderSwan's [[Keypad|keypad]].
== Interrupts ==
=== INT $11/AH=$00 - key_press_check ===
* AH = $00
Return:
* AX = A bitmask containing the currently held keys.
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
.... 4321 4321 bas.
|||| |||| |||
|||| |||| ||+- Start
|||| |||| |+-- A
|||| |||| +--- B
|||| ++++----- X1/X2/X3/X4
++++----------- Y1/Y2/Y3/Y4
</pre>
=== INT $12/AH=$01 - key_hit_check ===
* AH = $01
Return:
* AX = A bitmask containing the newly pressed keys, if any.
=== INT $11/AH=$02 - key_wait ===
* AH = $01
Return:
* AX = A bitmask containing the newly pressed keys.
This call blocks until a key is pressed.
=== INT $11/AH=$03 - key_set_repeat ===
* AH = $03
* BL = Key repeat delay, in frames
* BH = Key repeat rate, in frames
=== INT $11/AH=$04 - key_get_repeat ===
* AH = $04
Return:
* AL = Key repeat delay, in frames
* AH = Key repeat rate, in frames
=== INT $11/AH=$05 - key_hit_check_with_repeat ===
* AH = $01
Return:
* AX = A bitmask containing the newly pressed keys, if any.
For this call, the repeat delay/rate configuration is taken into account.
71b1ae6b80c1893035256b8d04af38c1f79f0780
322
321
2024-07-24T16:08:16Z
Asie
351
wikitext
text/x-wiki
The Display interrupt provides helper functions for accessing the WonderSwan's [[Keypad|keypad]].
== Interrupts ==
=== INT $11/AH=$00 - key_press_check ===
* AH = $00
Return:
* AX = A bitmask containing the currently held keys.
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
.... 4321 4321 bas.
|||| |||| |||
|||| |||| ||+- Start
|||| |||| |+-- A
|||| |||| +--- B
|||| ++++----- X1/X2/X3/X4
++++----------- Y1/Y2/Y3/Y4
</pre>
=== INT $12/AH=$01 - key_hit_check ===
* AH = $01
Return:
* AX = A bitmask containing the newly pressed keys, if any.
=== INT $11/AH=$02 - key_wait ===
* AH = $02
Return:
* AX = A bitmask containing the newly pressed keys.
This call blocks until a key is pressed.
=== INT $11/AH=$03 - key_set_repeat ===
* AH = $03
* BL = Key repeat delay, in frames
* BH = Key repeat rate, in frames
=== INT $11/AH=$04 - key_get_repeat ===
* AH = $04
Return:
* AL = Key repeat delay, in frames
* AH = Key repeat rate, in frames
=== INT $11/AH=$05 - key_hit_check_with_repeat ===
* AH = $05
Return:
* AX = A bitmask containing the newly pressed keys, if any.
For this call, the repeat delay/rate configuration is taken into account.
698ef440972143953bf68ce5297a7c4944367436
EEPROM
0
35
323
294
2024-07-25T17:58:17Z
Asie
351
/* Internal EEPROM Layout */ fix blood type order
wikitext
text/x-wiki
The WonderSwan utilizes M93LCx6-compatible EEPROMs:
* in the SoC:
** 1 Kbit internal EEPROM (M93LC46-compatible) on the WonderSwan,
** 16 Kbit internal EEPROM (M93LC86-compatible) on the WonderSwan Color,
* on cartridges:
** 1 Kbit cartridge EEPROM (M93LC46-compatible)
** 8 Kbit cartridge EEPROM (M93LC76-compatible)
** 16 Kbit cartridge EEPROM (M93LC86-compatible)
Additional variants exists which were not seen on any production cartridge:
* 256 bit EEPROM (M93LC06-compatible)
* 2 Kbit EEPROM (M93LC56-compatible)
* 4 Kbit EEPROM (M93LC66-compatible)
== Commands ==
=== READ - Read Word ===
The READ command takes an address of a word (address 0 => bytes 0, 1; address 1 => bytes 2, 3; ...) and returns the word at that address.
=== WRITE - Write Word ===
The WRITE command takes an address of a word (address 0 => bytes 0, 1; address 1 => bytes 2, 3; ...) and the word to write to it, then writes the word.
=== ERASE - Erase Word ===
The ERASE command takes an address of a word (address 0 => bytes 0, 1; address 1 => bytes 2, 3; ...) and erases the word at that address, setting it to 0xFFFF.
=== WDS - Write Disable ===
The WDS command prevents issued write and erase commands from having an effect on the EEPROM.
=== WRAL - Write All ===
This command is not guaranteed to be present on all EEPROMs.
TODO
=== ERAL - Erase All ===
This command is not guaranteed to be present on all EEPROMs.
TODO
=== WEN - Write Enable ===
The WEN command restores the effect of issued write and erase commands on the EEPROM disabled using WDS.
== I/O ports ==
The I/O ports listed refer to the internal EEPROM; for the cartridge EEPROM port numbers, refer to the [[Bandai 2001|mapper documentation]].
It is recommended to only access the data and command ports with aligned word reads/writes; see the ''Errata'' section for more information.
{{Anchor|Internal EEPROM Data}}
=== Internal EEPROM Data ($BA, $BB read) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
dddd dddd dddd dddd
|||| |||| |||| ||||
++++-++++--++++-++++- Data read from the EEPROM.
</pre>
The read buffer's value changes only once the Read command is completed.
=== Internal EEPROM Data ($BA, $BB write) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
dddd dddd dddd dddd
|||| |||| |||| ||||
++++-++++--++++-++++- Data to write to the EEPROM.
</pre>
The write buffer is latched when a Write command is initiated; further writes to it do not affect the value written by that specific command.
The two EEPROM data buffers are not shared; neither writes to the write buffer nor the execution of non-read commands affect the contents of the read buffer.
{{Anchor|Internal EEPROM Command}}
=== Internal EEPROM Command ($BC, $BD) ===
<pre>
Command Pattern 1
15 bit 8 7 bit 0
---- ---- ---- ----
0000 0001 ooaa aaaa (¼, 1 Kbit - M93LC06/46)
0000 01oo aaaa aaaa (2, 4 Kbit - M93LC56/66)
0001 ooaa aaaa aaaa (8, 16 Kbit - M93LC76/86)
|||| |||| ||||
||++--++++-++++- Address (MSb .. LSb)
++-------------- Opcode:
01 - WRITE
10 - READ
11 - ERASE
</pre>
<pre>
Command Pattern 2
15 bit 8 7 bit 0
---- ---- ---- ----
0000 0001 00ss .... (¼, 1 Kbit - M93LC06/46)
0000 0100 ss.. .... (2, 4 Kbit - M93LC56/66)
0001 00ss .... .... (8, 16 Kbit - M93LC76/86)
||||
||++------------ Sub-Opcode:
|| 00 - WDS
|| 01 - WRAL
|| 10 - ERAL
|| 11 - WEN
++-------------- Opcode:
00
</pre>
The value written to this port can be read back; it is not affected by ''EEPROM Control''.
{{Anchor|Internal EEPROM Control}}
=== Internal EEPROM Control ($BE, $BF write) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
.... .... PSWR ....
||||
|||+------ Read operation: 1 for READ command, 0 otherwise
||+------- Write operation: 1 for WRITE and WRAL command, 0 otherwise
|+-------- Short operation: 1 for ERASE, WDS, ERAL and WEN command, 0 otherwise
+--------- Protection: 1 to enable internal EEPROM write protection.
Cannot be cleared once set.
</pre>
* Read operation: Sends 16 bits from Command, then reads 16 bits to Data.
* Write operation: Sends 16 bits from Command, then 16 bits from Data. De-asserts Microwire chip select, then re-asserts it and waits for the EEPROM to confirm command completion.
* Short operation: Sends 16 bits from Command, de-asserts Microwire chip select.
* Protection: Enables internal EEPROM write protection (addresses >= 0x30, or anything after the first 96 bytes, can no longer be written to).
If more than one of the Read, Write, Short, Protect bits are set, the operation is treated as invalid (all four operation bits are cleared and no communication is done with the EEPROM). Notably, this means that writing, for example, 0x90 does not protect the internal EEPROM if it wasn't already protected, but writing 0x80 does.
The command requested here should match the command sent to the EEPROM in port ''$BC''.
{{Anchor|Internal EEPROM Status}}
=== Internal EEPROM Status ($BE, $BF read) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
.... .... P... ..rd
| ||
| |+- 0 after a Read command is initiated,
| | 1 once a Read command is completed.
| | Unaffected by Write/Erase commands.
| +-- 0 if the EEPROM is busy,
| 1 if a command can be accepted (idle).
+--------- Internal EEPROM write protection:
0 = disabled, 1 = enabled
</pre>
== Internal EEPROM Layout ==
{| class="wikitable"
|-
! Offset !! Length !! Contents
|-
| $00 || 96 || Program data. Can be written by programs even if write protection has been enabled.
|-
| $60 || 16 || Owner name, custom character set.
|-
| $70 || 1 || Owner birthday year, BCD, first/higher two digits
|-
| $71 || 1 || Owner birthday year, BCD, last/lower two digits
|-
| $72 || 1 || Owner birthday month, BCD
|-
| $73 || 1 || Owner birthday day, BCD
|-
| $74 || 1 || Owner gender:<br/>
0 - ?<br/>
1 - Male<br/>
2 - Female
|-
| $75 || 1 || Owner blood type:<br/>
0 - ?<br/>
1 - A<br/>
2 - B<br/>
3 - 0<br/>
4 - AB
|-
| $76 || 1 || Last booted cartridge developer/publisher ID
|-
| $77 || 1 || Last booted cartridge game ID
|-
| $78 || 1 || Last booted cartridge game version
|-
| $7C || 1 || Stored cartridge ID/version change counter
|-
| $7D || 1 || Owner name change counter
|-
| $7E || 2 || System startup counter
|-
| $83 || 1 || Color console configuration
|-
| $84 || ? || [[Splash animation|Custom splash animation]], if present
|}
=== Owner name character set ===
{| class="wikitable"
|-
!
! <code>.0</code>
! <code>.1</code>
! <code>.2</code>
! <code>.3</code>
! <code>.4</code>
! <code>.5</code>
! <code>.6</code>
! <code>.7</code>
! <code>.8</code>
! <code>.9</code>
! <code>.A</code>
! <code>.B</code>
! <code>.C</code>
! <code>.D</code>
! <code>.E</code>
! <code>.F</code>
|-
! <code>0.</code>
| || 0 || 1 || 2 || 3 || 4 || 5 || 6 || 7 || 8 || 9 || A || B || C || D || E
|-
! <code>1.</code>
| F || G || H || I || J || K || L || M || N || O || P || Q || R || S || T || U
|-
! <code>2.</code>
| V || W || X || Y || Z || ♥ || ♪ || + || - || ? || .
!
!
!
!
!
|}
=== Color console configuration ===
<pre>
7 bit 0
---- ----
sc.. ..vv
|| ||
|| ++- Volume level
|+-------- Contrast (WSC): 0 = Low, 1 = High
+--------- Custom splash animation enabled
</pre>
== Hardware notes ==
EEPROM command bits are shifted out starting from the ''most'' significant bit of the port.
<pre>
+----> EEPROM Serial Data
|
[0] <= [0000 0001 ooaa aaaa]
EEPROM Command Port
</pre>
While the M93LCx6 family supports byte organization, the WonderSwan always uses word organization. As such, this implementation detail is omitted in this documentation.
The SPHINX SoC family emulates a 93C46 in ASWAN compatibility mode by manipulating the shifted out command value when sending it to the EEPROM (TODO: How exactly?).
== Errata ==
=== Non-word access on ASWAN ===
On the ASWAN SoC, accessing the internal EEPROM command ports as bytes only works correctly for even addresses. For odd addresses, these accesses return open bus; this means that unaligned word accesses also don't work, as they are converted to one odd and one even byte access internally.
It is recommended to only use aligned word port accesses to talk to the internal EEPROM.
This issue is not present on the SPHINX and newer SoCs, including in "mono" emulation mode, as well as the cartridge bus (which is always forced to be accessed per byte).
== Links ==
* [https://www.st.com/resource/en/datasheet/m93c46-w.pdf STMicroelectronics M93LCx6 datasheet]
6059d59f66ce07b6bb8224bf1f803253bb0d12ea
340
323
2024-08-05T08:49:26Z
Asie
351
fix error in internal EEPROM data layout
wikitext
text/x-wiki
The WonderSwan utilizes M93LCx6-compatible EEPROMs:
* in the SoC:
** 1 Kbit internal EEPROM (M93LC46-compatible) on the WonderSwan,
** 16 Kbit internal EEPROM (M93LC86-compatible) on the WonderSwan Color,
* on cartridges:
** 1 Kbit cartridge EEPROM (M93LC46-compatible)
** 8 Kbit cartridge EEPROM (M93LC76-compatible)
** 16 Kbit cartridge EEPROM (M93LC86-compatible)
Additional variants exists which were not seen on any production cartridge:
* 256 bit EEPROM (M93LC06-compatible)
* 2 Kbit EEPROM (M93LC56-compatible)
* 4 Kbit EEPROM (M93LC66-compatible)
== Commands ==
=== READ - Read Word ===
The READ command takes an address of a word (address 0 => bytes 0, 1; address 1 => bytes 2, 3; ...) and returns the word at that address.
=== WRITE - Write Word ===
The WRITE command takes an address of a word (address 0 => bytes 0, 1; address 1 => bytes 2, 3; ...) and the word to write to it, then writes the word.
=== ERASE - Erase Word ===
The ERASE command takes an address of a word (address 0 => bytes 0, 1; address 1 => bytes 2, 3; ...) and erases the word at that address, setting it to 0xFFFF.
=== WDS - Write Disable ===
The WDS command prevents issued write and erase commands from having an effect on the EEPROM.
=== WRAL - Write All ===
This command is not guaranteed to be present on all EEPROMs.
TODO
=== ERAL - Erase All ===
This command is not guaranteed to be present on all EEPROMs.
TODO
=== WEN - Write Enable ===
The WEN command restores the effect of issued write and erase commands on the EEPROM disabled using WDS.
== I/O ports ==
The I/O ports listed refer to the internal EEPROM; for the cartridge EEPROM port numbers, refer to the [[Bandai 2001|mapper documentation]].
It is recommended to only access the data and command ports with aligned word reads/writes; see the ''Errata'' section for more information.
{{Anchor|Internal EEPROM Data}}
=== Internal EEPROM Data ($BA, $BB read) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
dddd dddd dddd dddd
|||| |||| |||| ||||
++++-++++--++++-++++- Data read from the EEPROM.
</pre>
The read buffer's value changes only once the Read command is completed.
=== Internal EEPROM Data ($BA, $BB write) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
dddd dddd dddd dddd
|||| |||| |||| ||||
++++-++++--++++-++++- Data to write to the EEPROM.
</pre>
The write buffer is latched when a Write command is initiated; further writes to it do not affect the value written by that specific command.
The two EEPROM data buffers are not shared; neither writes to the write buffer nor the execution of non-read commands affect the contents of the read buffer.
{{Anchor|Internal EEPROM Command}}
=== Internal EEPROM Command ($BC, $BD) ===
<pre>
Command Pattern 1
15 bit 8 7 bit 0
---- ---- ---- ----
0000 0001 ooaa aaaa (¼, 1 Kbit - M93LC06/46)
0000 01oo aaaa aaaa (2, 4 Kbit - M93LC56/66)
0001 ooaa aaaa aaaa (8, 16 Kbit - M93LC76/86)
|||| |||| ||||
||++--++++-++++- Address (MSb .. LSb)
++-------------- Opcode:
01 - WRITE
10 - READ
11 - ERASE
</pre>
<pre>
Command Pattern 2
15 bit 8 7 bit 0
---- ---- ---- ----
0000 0001 00ss .... (¼, 1 Kbit - M93LC06/46)
0000 0100 ss.. .... (2, 4 Kbit - M93LC56/66)
0001 00ss .... .... (8, 16 Kbit - M93LC76/86)
||||
||++------------ Sub-Opcode:
|| 00 - WDS
|| 01 - WRAL
|| 10 - ERAL
|| 11 - WEN
++-------------- Opcode:
00
</pre>
The value written to this port can be read back; it is not affected by ''EEPROM Control''.
{{Anchor|Internal EEPROM Control}}
=== Internal EEPROM Control ($BE, $BF write) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
.... .... PSWR ....
||||
|||+------ Read operation: 1 for READ command, 0 otherwise
||+------- Write operation: 1 for WRITE and WRAL command, 0 otherwise
|+-------- Short operation: 1 for ERASE, WDS, ERAL and WEN command, 0 otherwise
+--------- Protection: 1 to enable internal EEPROM write protection.
Cannot be cleared once set.
</pre>
* Read operation: Sends 16 bits from Command, then reads 16 bits to Data.
* Write operation: Sends 16 bits from Command, then 16 bits from Data. De-asserts Microwire chip select, then re-asserts it and waits for the EEPROM to confirm command completion.
* Short operation: Sends 16 bits from Command, de-asserts Microwire chip select.
* Protection: Enables internal EEPROM write protection (addresses >= 0x30, or anything after the first 96 bytes, can no longer be written to).
If more than one of the Read, Write, Short, Protect bits are set, the operation is treated as invalid (all four operation bits are cleared and no communication is done with the EEPROM). Notably, this means that writing, for example, 0x90 does not protect the internal EEPROM if it wasn't already protected, but writing 0x80 does.
The command requested here should match the command sent to the EEPROM in port ''$BC''.
{{Anchor|Internal EEPROM Status}}
=== Internal EEPROM Status ($BE, $BF read) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
.... .... P... ..rd
| ||
| |+- 0 after a Read command is initiated,
| | 1 once a Read command is completed.
| | Unaffected by Write/Erase commands.
| +-- 0 if the EEPROM is busy,
| 1 if a command can be accepted (idle).
+--------- Internal EEPROM write protection:
0 = disabled, 1 = enabled
</pre>
== Internal EEPROM Layout ==
{| class="wikitable"
|-
! Offset !! Length !! Contents
|-
| $00 || 96 || Program data. Can be written by programs even if write protection has been enabled.
|-
| $60 || 16 || Owner name, custom character set.
|-
| $70 || 1 || Owner birthday year, BCD, first/higher two digits
|-
| $71 || 1 || Owner birthday year, BCD, last/lower two digits
|-
| $72 || 1 || Owner birthday month, BCD
|-
| $73 || 1 || Owner birthday day, BCD
|-
| $74 || 1 || Owner gender:<br/>
0 - ?<br/>
1 - Male<br/>
2 - Female
|-
| $75 || 1 || Owner blood type:<br/>
0 - ?<br/>
1 - A<br/>
2 - B<br/>
3 - 0<br/>
4 - AB
|-
| $76 || 1 || Last booted [[ROM header]] byte 6 (developer/publisher ID)
|-
| $77 || 1 || Last booted [[ROM header]] byte 7 (color)
|-
| $78 || 1 || Last booted [[ROM header]] byte 8 (game ID)
|-
| $7C || 1 || Stored cartridge ID/version change counter
|-
| $7D || 1 || Owner name change counter
|-
| $7E || 2 || System startup counter
|-
| $83 || 1 || Color console configuration
|-
| $84 || ? || [[Splash animation|Custom splash animation]], if present
|}
=== Owner name character set ===
{| class="wikitable"
|-
!
! <code>.0</code>
! <code>.1</code>
! <code>.2</code>
! <code>.3</code>
! <code>.4</code>
! <code>.5</code>
! <code>.6</code>
! <code>.7</code>
! <code>.8</code>
! <code>.9</code>
! <code>.A</code>
! <code>.B</code>
! <code>.C</code>
! <code>.D</code>
! <code>.E</code>
! <code>.F</code>
|-
! <code>0.</code>
| || 0 || 1 || 2 || 3 || 4 || 5 || 6 || 7 || 8 || 9 || A || B || C || D || E
|-
! <code>1.</code>
| F || G || H || I || J || K || L || M || N || O || P || Q || R || S || T || U
|-
! <code>2.</code>
| V || W || X || Y || Z || ♥ || ♪ || + || - || ? || .
!
!
!
!
!
|}
=== Color console configuration ===
<pre>
7 bit 0
---- ----
sc.. ..vv
|| ||
|| ++- Volume level
|+-------- Contrast (WSC): 0 = Low, 1 = High
+--------- Custom splash animation enabled
</pre>
== Hardware notes ==
EEPROM command bits are shifted out starting from the ''most'' significant bit of the port.
<pre>
+----> EEPROM Serial Data
|
[0] <= [0000 0001 ooaa aaaa]
EEPROM Command Port
</pre>
While the M93LCx6 family supports byte organization, the WonderSwan always uses word organization. As such, this implementation detail is omitted in this documentation.
The SPHINX SoC family emulates a 93C46 in ASWAN compatibility mode by manipulating the shifted out command value when sending it to the EEPROM (TODO: How exactly?).
== Errata ==
=== Non-word access on ASWAN ===
On the ASWAN SoC, accessing the internal EEPROM command ports as bytes only works correctly for even addresses. For odd addresses, these accesses return open bus; this means that unaligned word accesses also don't work, as they are converted to one odd and one even byte access internally.
It is recommended to only use aligned word port accesses to talk to the internal EEPROM.
This issue is not present on the SPHINX and newer SoCs, including in "mono" emulation mode, as well as the cartridge bus (which is always forced to be accessed per byte).
== Links ==
* [https://www.st.com/resource/en/datasheet/m93c46-w.pdf STMicroelectronics M93LCx6 datasheet]
0ac74b4fd203412f92d97b982022ab5e23f662da
341
340
2024-08-05T09:27:34Z
Asie
351
/* Internal EEPROM Layout */ figure out bytes 0x80, 0x81, 0x82
wikitext
text/x-wiki
The WonderSwan utilizes M93LCx6-compatible EEPROMs:
* in the SoC:
** 1 Kbit internal EEPROM (M93LC46-compatible) on the WonderSwan,
** 16 Kbit internal EEPROM (M93LC86-compatible) on the WonderSwan Color,
* on cartridges:
** 1 Kbit cartridge EEPROM (M93LC46-compatible)
** 8 Kbit cartridge EEPROM (M93LC76-compatible)
** 16 Kbit cartridge EEPROM (M93LC86-compatible)
Additional variants exists which were not seen on any production cartridge:
* 256 bit EEPROM (M93LC06-compatible)
* 2 Kbit EEPROM (M93LC56-compatible)
* 4 Kbit EEPROM (M93LC66-compatible)
== Commands ==
=== READ - Read Word ===
The READ command takes an address of a word (address 0 => bytes 0, 1; address 1 => bytes 2, 3; ...) and returns the word at that address.
=== WRITE - Write Word ===
The WRITE command takes an address of a word (address 0 => bytes 0, 1; address 1 => bytes 2, 3; ...) and the word to write to it, then writes the word.
=== ERASE - Erase Word ===
The ERASE command takes an address of a word (address 0 => bytes 0, 1; address 1 => bytes 2, 3; ...) and erases the word at that address, setting it to 0xFFFF.
=== WDS - Write Disable ===
The WDS command prevents issued write and erase commands from having an effect on the EEPROM.
=== WRAL - Write All ===
This command is not guaranteed to be present on all EEPROMs.
TODO
=== ERAL - Erase All ===
This command is not guaranteed to be present on all EEPROMs.
TODO
=== WEN - Write Enable ===
The WEN command restores the effect of issued write and erase commands on the EEPROM disabled using WDS.
== I/O ports ==
The I/O ports listed refer to the internal EEPROM; for the cartridge EEPROM port numbers, refer to the [[Bandai 2001|mapper documentation]].
It is recommended to only access the data and command ports with aligned word reads/writes; see the ''Errata'' section for more information.
{{Anchor|Internal EEPROM Data}}
=== Internal EEPROM Data ($BA, $BB read) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
dddd dddd dddd dddd
|||| |||| |||| ||||
++++-++++--++++-++++- Data read from the EEPROM.
</pre>
The read buffer's value changes only once the Read command is completed.
=== Internal EEPROM Data ($BA, $BB write) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
dddd dddd dddd dddd
|||| |||| |||| ||||
++++-++++--++++-++++- Data to write to the EEPROM.
</pre>
The write buffer is latched when a Write command is initiated; further writes to it do not affect the value written by that specific command.
The two EEPROM data buffers are not shared; neither writes to the write buffer nor the execution of non-read commands affect the contents of the read buffer.
{{Anchor|Internal EEPROM Command}}
=== Internal EEPROM Command ($BC, $BD) ===
<pre>
Command Pattern 1
15 bit 8 7 bit 0
---- ---- ---- ----
0000 0001 ooaa aaaa (¼, 1 Kbit - M93LC06/46)
0000 01oo aaaa aaaa (2, 4 Kbit - M93LC56/66)
0001 ooaa aaaa aaaa (8, 16 Kbit - M93LC76/86)
|||| |||| ||||
||++--++++-++++- Address (MSb .. LSb)
++-------------- Opcode:
01 - WRITE
10 - READ
11 - ERASE
</pre>
<pre>
Command Pattern 2
15 bit 8 7 bit 0
---- ---- ---- ----
0000 0001 00ss .... (¼, 1 Kbit - M93LC06/46)
0000 0100 ss.. .... (2, 4 Kbit - M93LC56/66)
0001 00ss .... .... (8, 16 Kbit - M93LC76/86)
||||
||++------------ Sub-Opcode:
|| 00 - WDS
|| 01 - WRAL
|| 10 - ERAL
|| 11 - WEN
++-------------- Opcode:
00
</pre>
The value written to this port can be read back; it is not affected by ''EEPROM Control''.
{{Anchor|Internal EEPROM Control}}
=== Internal EEPROM Control ($BE, $BF write) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
.... .... PSWR ....
||||
|||+------ Read operation: 1 for READ command, 0 otherwise
||+------- Write operation: 1 for WRITE and WRAL command, 0 otherwise
|+-------- Short operation: 1 for ERASE, WDS, ERAL and WEN command, 0 otherwise
+--------- Protection: 1 to enable internal EEPROM write protection.
Cannot be cleared once set.
</pre>
* Read operation: Sends 16 bits from Command, then reads 16 bits to Data.
* Write operation: Sends 16 bits from Command, then 16 bits from Data. De-asserts Microwire chip select, then re-asserts it and waits for the EEPROM to confirm command completion.
* Short operation: Sends 16 bits from Command, de-asserts Microwire chip select.
* Protection: Enables internal EEPROM write protection (addresses >= 0x30, or anything after the first 96 bytes, can no longer be written to).
If more than one of the Read, Write, Short, Protect bits are set, the operation is treated as invalid (all four operation bits are cleared and no communication is done with the EEPROM). Notably, this means that writing, for example, 0x90 does not protect the internal EEPROM if it wasn't already protected, but writing 0x80 does.
The command requested here should match the command sent to the EEPROM in port ''$BC''.
{{Anchor|Internal EEPROM Status}}
=== Internal EEPROM Status ($BE, $BF read) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
.... .... P... ..rd
| ||
| |+- 0 after a Read command is initiated,
| | 1 once a Read command is completed.
| | Unaffected by Write/Erase commands.
| +-- 0 if the EEPROM is busy,
| 1 if a command can be accepted (idle).
+--------- Internal EEPROM write protection:
0 = disabled, 1 = enabled
</pre>
== Internal EEPROM Layout ==
{| class="wikitable"
|-
! Offset !! Length !! Contents
|-
| $00 || 96 || Program data. Can be written by programs even if write protection has been enabled.
|-
| $60 || 16 || Owner name, custom character set.
|-
| $70 || 1 || Owner birthday year, BCD, first/higher two digits
|-
| $71 || 1 || Owner birthday year, BCD, last/lower two digits
|-
| $72 || 1 || Owner birthday month, BCD
|-
| $73 || 1 || Owner birthday day, BCD
|-
| $74 || 1 || Owner gender:<br/>
0 - ?<br/>
1 - Male<br/>
2 - Female
|-
| $75 || 1 || Owner blood type:<br/>
0 - ?<br/>
1 - A<br/>
2 - B<br/>
3 - 0<br/>
4 - AB
|-
| $76 || 1 || Last booted [[ROM header]] byte 6 (developer/publisher ID)
|-
| $77 || 1 || Last booted [[ROM header]] byte 7 (color)
|-
| $78 || 1 || Last booted [[ROM header]] byte 8 (game ID)
|-
| $7C || 1 || Stored cartridge ID/version change counter
|-
| $7D || 1 || Owner name change counter
|-
| $7E || 2 || System startup counter
|-
| $80 || 1 || Last booted [[ROM header]] byte 6 (developer/publisher ID) - only changed if byte 7 (color) != 0
|-
| $81 || 1 || Last booted [[ROM header]] byte 7 (color) - only changed if byte 7 (color) != 0
|-
| $82 || 1 || Last booted [[ROM header]] byte 8 (game ID) - only changed if byte 7 (color) != 0
|-
| $83 || 1 || Color console configuration
|-
| $84 || ? || [[Splash animation|Custom splash animation]], if present
|}
=== Owner name character set ===
{| class="wikitable"
|-
!
! <code>.0</code>
! <code>.1</code>
! <code>.2</code>
! <code>.3</code>
! <code>.4</code>
! <code>.5</code>
! <code>.6</code>
! <code>.7</code>
! <code>.8</code>
! <code>.9</code>
! <code>.A</code>
! <code>.B</code>
! <code>.C</code>
! <code>.D</code>
! <code>.E</code>
! <code>.F</code>
|-
! <code>0.</code>
| || 0 || 1 || 2 || 3 || 4 || 5 || 6 || 7 || 8 || 9 || A || B || C || D || E
|-
! <code>1.</code>
| F || G || H || I || J || K || L || M || N || O || P || Q || R || S || T || U
|-
! <code>2.</code>
| V || W || X || Y || Z || ♥ || ♪ || + || - || ? || .
!
!
!
!
!
|}
=== Color console configuration ===
<pre>
7 bit 0
---- ----
sc.. ..vv
|| ||
|| ++- Volume level
|+-------- Contrast (WSC): 0 = Low, 1 = High
+--------- Custom splash animation enabled
</pre>
== Hardware notes ==
EEPROM command bits are shifted out starting from the ''most'' significant bit of the port.
<pre>
+----> EEPROM Serial Data
|
[0] <= [0000 0001 ooaa aaaa]
EEPROM Command Port
</pre>
While the M93LCx6 family supports byte organization, the WonderSwan always uses word organization. As such, this implementation detail is omitted in this documentation.
The SPHINX SoC family emulates a 93C46 in ASWAN compatibility mode by manipulating the shifted out command value when sending it to the EEPROM (TODO: How exactly?).
== Errata ==
=== Non-word access on ASWAN ===
On the ASWAN SoC, accessing the internal EEPROM command ports as bytes only works correctly for even addresses. For odd addresses, these accesses return open bus; this means that unaligned word accesses also don't work, as they are converted to one odd and one even byte access internally.
It is recommended to only use aligned word port accesses to talk to the internal EEPROM.
This issue is not present on the SPHINX and newer SoCs, including in "mono" emulation mode, as well as the cartridge bus (which is always forced to be accessed per byte).
== Links ==
* [https://www.st.com/resource/en/datasheet/m93c46-w.pdf STMicroelectronics M93LCx6 datasheet]
9601ce270576101747ed8157ad6713c9ea92c3b0
WonderWitch/FreyaBIOS/Text
0
53
324
2024-07-27T08:34:30Z
Asie
351
Created page with "The Text interrupt provides a text output display using one of the WonderSwan's screens. == Interrupts == === INT $13/AH=$00 - text_screen_init === * AH = $00 Initializes a text window (see INT $13/AH=$01) with the following default settings: * X, Y = 0, 0 * width, height = 28, 18 * starting tile = 512 - font tile count (in ASCII mode) * starting tile = 512 - (width x height) (in Shift-JIS and mixed modes) === INT $13/AH=$01 - text_window_init === * AH = $01 * BL..."
wikitext
text/x-wiki
The Text interrupt provides a text output display using one of the WonderSwan's screens.
== Interrupts ==
=== INT $13/AH=$00 - text_screen_init ===
* AH = $00
Initializes a text window (see INT $13/AH=$01) with the following default settings:
* X, Y = 0, 0
* width, height = 28, 18
* starting tile = 512 - font tile count (in ASCII mode)
* starting tile = 512 - (width x height) (in Shift-JIS and mixed modes)
=== INT $13/AH=$01 - text_window_init ===
* AH = $01
* BL = X position on screen, in tiles
* BH = Y position on screen, in tiles
* CL = width, in tiles
* CH = height, in tiles
* DX = starting tile
Initializes a text window starting at <code>(BL, BH)</code> with a size of <code>CL x CH</code> tiles on the configured screen.
This requires the following number of tiles, starting at <code>DX</code>:
* font tile count (in ASCII mode)
* width x height (in Shift-JIS and mixed modes)
=== INT $13/AH=$02 - text_set_mode ===
* AH = $02
* BX = Text mode
Available modes:
* 0 = ASCII mode
* 1 = mixed (ASCII and Shift-JIS) mode
* 2 = Shift-JIS mode
=== INT $13/AH=$03 - text_get_mode ===
* AH = $03
Return:
* BX = Text mode
=== INT $13/AH=$04 - text_put_char ===
* AH = $04
* BL = X position in text window
* BH = Y position in text window
* CX = Character code
=== INT $13/AH=$05 - text_put_string ===
* AH = $05
* BL = X position in text window
* BH = Y position in text window
* DS:DX = String to print
=== INT $13/AH=$06 - text_put_substring ===
* AH = $06
* BL = X position in text window
* BH = Y position in text window
* CX = Maximum length of string to print
* DS:DX = String to print
=== INT $13/AH=$07 - text_put_numeric ===
* AH = $07
* BL = X position in text window
* BH = Y position in text window
* CL = Width of area to write number in
* CH = Flags
* DX = Number
* DS:SI = Output buffer (optional, see flags)
Numeric output flags:
<pre>
7 bit 0
---- ----
o... slzx
| ||||
| |||+- 0 = output in decimal
| ||| 1 = output in hexadecimal
| ||+---- 0 = pad with spaces
| || 1 = pad with zeroes
| |+------- 0 = align to right
| | 1 = align to left
| +---------- 0 = number is unsigned
| 1 = number is signed
+----------------- 0 = output to text window (at BL, BH)
1 = output to buffer (DS:SI)
</pre>
=== INT $13/AH=$08 - text_fill_char ===
* AH = $08
* BL = X position in text window
* BH = Y position in text window
* CX = Length
* DX = Character code
Repeat the specified character code <code>CX</code> times.
=== INT $13/AH=$09 - text_set_palette ===
* AH = $09
* BX = Palette color (0-15).
Set the palette used by printed text.
=== INT $13/AH=$0A - text_get_palette ===
* AH = $0A
Return:
* AX = Palette color (0-15).
Retrieve the palette used by printed text.
=== INT $13/AH=$0B - text_set_ank_font ===
* AH = $0B
* BL = Starting character code.
* BH = Bit depth; 0 = 1bpp, 1 = 2bpp.
* CX = Number of tiles.
* DS:DX = Input buffer containing font data.
=== INT $13/AH=$0C - text_set_sjis_font ===
TODO
=== INT $13/AH=$0D - text_get_fontdata ===
* AH = $0D
* CX = Character code.
* DS:DX = Output buffer for the character's tile data.
=== INT $13/AH=$0E - text_set_screen ===
* AH = $0E
* AL = Screen ID (0, 1).
=== INT $13/AH=$0F - text_get_screen ===
* AH = $0F
Return:
* AL = Screen ID (0, 1).
=== INT $13/AH=$10 - cursor_display ===
* AH = $10
* AL = Cursor status (0 = disabled, 1 = enabled).
Controls the visibility of a blinking cursor on the text screen.
=== INT $13/AH=$11 - cursor_status ===
* AH = $11
Return:
* AX = Cursor status.
<pre>
7 bit 0
---- ----
.... ..ve
||
|+- 0 = disabled, 1 = enabled
+-- 0 = currently not visible, 1 = visible
</pre>
=== INT $13/AH=$12 - cursor_set_location ===
* AH = $12
* BL = X position
* BH = Y position
* CL = Width, in tiles
* CH = Height, in tiles
=== INT $13/AH=$13 - cursor_get_location ===
* AH = $13
Return:
* AL = X position
* AH = Y position
* DL = Width, in tiles
* DH = Height, in tiles
=== INT $13/AH=$14 - cursor_set_type ===
* AH = $14
* BL = Palette (0-15) used by cursor area when visible
* CL = Blinking rate, in frames (0 = always visible)
The defaults are as follows:
* Palette = 1
* Blinking rate = 30
=== INT $13/AH=$15 - cursor_set_type ===
* AH = $15
Return:
* AL = Palette (0-15) used by cursor area when visible
* AH = Blinking rate, in frames (0 = always visible)
3efd8c7df3af914fafa3c83c1eab97fec5d99072
WonderWitch/FreyaBIOS/Communication
0
54
326
2024-07-27T13:42:18Z
Asie
351
Created page with "The Communication (comm) interrupt provides an abstraction layer and helpers for the WonderSwan's [[UART|serial port]]. == Interrupts == === INT $14/AH=$00 - comm_open === * AH = $00 Opens the serial port. Note that the baud rate must be set before calling <code>comm_open</code>. === INT $14/AH=$01 - comm_close === * AH = $01 Closes the serial port. === INT $14/AH=$02 - comm_send_char === * AH = $02 * BL = Character (byte) to send. Return: * AX = Return code...."
wikitext
text/x-wiki
The Communication (comm) interrupt provides an abstraction layer and helpers for the WonderSwan's [[UART|serial port]].
== Interrupts ==
=== INT $14/AH=$00 - comm_open ===
* AH = $00
Opens the serial port. Note that the baud rate must be set before calling <code>comm_open</code>.
=== INT $14/AH=$01 - comm_close ===
* AH = $01
Closes the serial port.
=== INT $14/AH=$02 - comm_send_char ===
* AH = $02
* BL = Character (byte) to send.
Return:
* AX = Return code.
Return codes:
* 0x0000 - Success
* 0x8101 - Transfer timeout
* 0x8102 - Transfer RX overrun
* 0x8103 - Transfer cancelled
=== INT $14/AH=$03 - comm_receive_char ===
* AH = $03
Return:
* AX = Character (byte) read (0x0000 - 0xFFFF) or error return code.
=== INT $14/AH=$04 - comm_receive_with_timeout ===
* AH = $03
* CX = Timeout, in frames (as in <code>comm_set_timeout</code>).
Return:
* AX = Character (byte) read (0x0000 - 0xFFFF) or error return code.
Unlike <code>comm_receive_char</code>, this function uses an user-provided timeout.
=== INT $14/AH=$05 - comm_send_string ===
* AH = $05
* DS:DX = Input string to send.
Return:
* AX = Return code.
=== INT $14/AH=$06 - comm_send_block ===
* AH = $06
* CX = Buffer size, in bytes.
* DS:DX = Input buffer to send.
Return:
* AX = Return code.
=== INT $14/AH=$07 - comm_receive_block ===
* AH = $07
* CX = Buffer size, in bytes.
* DS:DX = Buffer to receive bytes to.
Return:
* AX = Return code.
* DX = Number of bytes successfully received.
=== INT $14/AH=$08 - comm_set_timeout ===
* AH = $08
* BX = Receive timeout (in frames; 0xFFFF - wait forever)
* CX = Send timeout (in frames; 0xFFFF - wait forever)
=== INT $14/AH=$09 - comm_set_baudrate ===
* AH = $09
* BX = Baud rate (0 = 9600 bps, 1 = 38400 bps).
Only affects newly opened serial port connections.
=== INT $14/AH=$0A - comm_get_baudrate ===
* AH = $0A
Return:
* AX = Baud rate (0 = 9600 bps, 1 = 38400 bps).
=== INT $14/AH=$0B - comm_set_cancel_key ===
* AH = $0B
* BX = Cancel key combination.
=== INT $14/AH=$0C - comm_get_cancel_key ===
* AH = $0C
Return:
* AX = Cancel key combination.
=== INT $14/AH=$0D - comm_xmodem ===
TODO
10a086c1ac789043ffab65c993e2b15106cc59e1
WonderWitch/FreyaBIOS
0
42
327
239
2024-07-27T13:44:38Z
Asie
351
fix missing ending parenthesis
wikitext
text/x-wiki
FreyaBIOS is a boot program and hardware abstraction layer for [[WonderWitch]], present in the top-most (last) 64 KB of any WonderWitch cartridge.
It provides the following functionality:
* bring-up code,
* interrupt-based hardware abstraction layer, providing a more user-friendly (and less direct) interface to the WonderSwan hardware,
* 8x8 ASCII and kanji fonts,
* a monitor program, allowing FreyaOS recovery and updates via XMODEM.
Other functionality (like file system access) is instead included as part of [[WonderWitch/FreyaOS|FreyaOS]]' system libraries; some other functionality (like [[WonderWitch/libwwc|WonderSwan Color support]]) is implemented as part of the development tooling.
== Revisions ==
TODO
== Fonts ==
As part of its ROM image, FreyaBIOS provides two fonts:
* an 8x8 ASCII font,
* an 8x8 Shift-JIS kanji font - [http://hp.vector.co.jp/authors/VA002310/original.html ELISA FONT].
== Interrupts ==
* [[WonderWitch/FreyaBIOS/Exit|Exit]] (INT $10)
* [[WonderWitch/FreyaBIOS/Key|Key]] (INT $11)
* [[WonderWitch/FreyaBIOS/Display|Display]] (INT $12)
* [[WonderWitch/FreyaBIOS/Text|Text]] (INT $13)
* [[WonderWitch/FreyaBIOS/Communication|Communication]] (INT $14)
* [[WonderWitch/FreyaBIOS/Sound|Sound]] (INT $15)
* [[WonderWitch/FreyaBIOS/Timer|Timer]] (INT $16)
* [[WonderWitch/FreyaBIOS/System|System]] (INT $17)
* [[WonderWitch/FreyaBIOS/Bank|Bank]] (INT $18)
== Freya Monitor ==
TODO
153973464cb7393762185299b48d5ff375b3906a
SoC
0
46
328
244
2024-07-28T11:58:02Z
Asie
351
wikitext
text/x-wiki
The WonderSwan SoC is a single-chip solution powering the entirety of the system's hardware - containing the CPU, most peripheral logic, as well as the internal RAM.
There exist three variants of the SoC:
* ASWAN, used in the WonderSwan,
* SPHINX, used in the WonderSwan Color,
* SPHINX2, used in the SwanCrystal.
A fourth variant, CAIRO, was planned<ref>[https://web.archive.org/web/20071023111112/http://www.koto.co.jp/products/mono_sp.html CAIRO グラフィックス機能内蔵ローコストSoC - Wayback Machine]</ref>. It was designed as an ASWAN with a doubled clock speed and a built-in ADPCM decoder, but is not known to have been licensed for any commercial product.
== I/O ports ==
{{Anchor|System Control}}
=== System Control ($A0) ===
<pre>
7 bit 0
---- ----
t??? swcl
| ||||
| |||+- Boot ROM lockout: 0 = off, 1 = on
| ||+-- Color model: 0 = no, 1 = yes
| |+--- Cartridge ROM width: 0 = 8-bit, 1 = 16-bit
| +---- Cartridge ROM wait state: 0 = +0 cycles, 1 = +1
+--------- MBC authentication successful?
</pre>
{{Anchor|System Control 2}}
=== System Control 2 ($60, color) ===
<pre>
7 bit 0
---- ----
c4C. i?sl
||| | ||
||| | |+- Cartridge clock speed?
||| | +-- Cartridge SRAM wait state: 0 = +0 cycles, 1 = +1
||| +---- Cartridge I/O wait state: 0 = +0 cycles, 1 = +1
||+------- 1 = 4bpp "chunky"; requires all previous
|+-------- 1 = 4bpp; requires all previous
+--------- 0 = mono, 1 = color; also controls access
to WSC-specific features (extra RAM, DMA, etc.)
</pre>
{{Anchor|System Control 3}}
=== System Control 3 ($62, color) ===
<pre>
7 bit 0
---- ----
S... ...p
| |
| +- 1 = Power off system
+--------- 0 = WonderSwan Color (SPHINX)
1 = SwanCrystal (SPHINX2)
</pre>
== Notes ==
<references />
05ce8088d42a27e52327ddc9c7c114c325ed9c9d
WonderWitch/FreyaBIOS/Bank
0
55
329
2024-07-30T20:37:45Z
Asie
351
Created page with "The Bank interrupt provides an abstraction layer for accessing the WonderWitch cartridge's flash and RAM. == Interrupts == === INT $18/AH=$00 - bank_set_map === * AH = $00 * BX = Bank region * CX = Number of bank to map to region Bank regions: * 0 = SRAM (1000:xxxx) * 1 = ROM0 (2000:xxxx) * 2 = ROM1 (3000:xxxx) === INT $18/AH=$01 - bank_get_map === * AH = $01 * BX = Bank region Return: * AX = Number of bank mapped to region === INT $18/AH=$02 - bank_read_byte =..."
wikitext
text/x-wiki
The Bank interrupt provides an abstraction layer for accessing the WonderWitch cartridge's flash and RAM.
== Interrupts ==
=== INT $18/AH=$00 - bank_set_map ===
* AH = $00
* BX = Bank region
* CX = Number of bank to map to region
Bank regions:
* 0 = SRAM (1000:xxxx)
* 1 = ROM0 (2000:xxxx)
* 2 = ROM1 (3000:xxxx)
=== INT $18/AH=$01 - bank_get_map ===
* AH = $01
* BX = Bank region
Return:
* AX = Number of bank mapped to region
=== INT $18/AH=$02 - bank_read_byte ===
* AH = $02
* BX = Bank ID
* DX = Offset within bank
Return:
* AL = Byte read
Bank ID format:
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
tiii iiii iiii iiii
|||| |||| |||| ||||
|+++-++++--++++-++++- Number of bank
+-------------------- 0 = SRAM, 1 = Flash
</pre>
=== INT $18/AH=$03 - bank_write_byte ===
* AH = $03
* BX = Bank ID
* CL = Byte to write
* DX = Offset within bank
=== INT $18/AH=$04 - bank_read_word ===
* AH = $04
* BX = Bank ID
* DX = Offset within bank
Return:
* AX = Word read
=== INT $18/AH=$05 - bank_write_word ===
* AH = $05
* BX = Bank ID
* CX = Word to write
* DX = Offset within bank
=== INT $18/AH=$06 - bank_read_block ===
* AH = $06
* BX = Bank ID
* CX = Number of bytes to read
* DX = Offset within bank
* DS:SI = Output buffer, of size <code>CX</code>
=== INT $18/AH=$07 - bank_write_block ===
* AH = $07
* BX = Bank ID
* CX = Number of bytes to write
* DX = Offset within bank
* DS:SI = Input buffer, of size <code>CX</code>
=== INT $18/AH=$08 - bank_fill_block ===
* AH = $08
* AL = Fill value
* BX = Bank ID
* CX = Number of bytes to write
* DX = Offset within bank
Sets <code>CX</code> bytes in bank <code>BX</code> to value <code>AL</code> starting at offset <code>DX</code>.
=== INT $18/AH=$09 - bank_erase_flash ===
* AH = $09
* BX = Bank ID
70fb3919087d5ebc2e6f19266f63109c745d073c
Memory map
0
25
330
225
2024-08-02T16:57:40Z
Asie
351
wikitext
text/x-wiki
The WonderSwan's SoC uses a 20-bit physical memory map, split into three regions with distinct bus widths, timings, and access permissions;
{| class="wikitable"
|+ WonderSwan physical memory map
! Bus
! colspan="2" | Address range
! Access width
! Access speed
! Read/Write
|-
| Internal
| colspan="2" style="text-align: center;" | 0x00000<br/>0x0FFFF
| 16-bit
| 1 cycle
| RW
|-
| rowspan="2" | Cartridge
| rowspan="2" style="text-align: center;" | 0x10000<br/>0xFFFFF
| style="text-align: center;" | 0x10000<br/>0x1FFFF
| 8-bit
| 1<sup>(color)</sup>/2 cycles (configurable)
| RW
|-
| style="text-align: center;" | 0x20000<br/>0xFFFFF
| 8/16-bit (configurable)
| 1/2 cycles (configurable)
| R
|}
== Internal ==
The WonderSwan SoC features an unified memory architecture. The CPU, [[Display]] and [[Sound]] components make use of data stored in a shared RAM in distinct segments of the 12.288 MHz SoC clock. This is in contrast to many other platforms which feature, for example, separate video memory. This allows the CPU to modify video and audio data without worrying about wait states or video timing; however, the video and audio components have location and alignment restrictions for data:
{| class="wikitable"
|+ WonderSwan SoC internal memory map
! Address
! WonderSwan
! WonderSwan Color (2BPP mode)
! WonderSwan Color (4BPP mode)
|-
| style="text-align: center;" | 0x0000
| colspan="3" style="text-align: center;" | '''Interrupt vectors''' (256 x 4 bytes - far addresses)
|-
| style="text-align: center;" | 0x0400
| colspan="3" style="text-align: center;" | Free RAM
|-
| style="text-align: center;" | 0x2000
| colspan="2" style="text-align: center;" | '''Tile data (bank 0)'''
| style="text-align: center;" | Free RAM
|-
| style="text-align: center;" | 0x4000
! rowspan="6" style="text-align: center;" |
| style="text-align: center;" | '''Tile data (bank 1)'''
| rowspan="2" style="text-align: center;" | '''Tile data (bank 0)'''
|-
| style="text-align: center;" | 0x6000
| rowspan="2" style="text-align: center;" | Free RAM
|-
| style="text-align: center;" | 0x8000
| style="text-align: center;" | '''Tile data (bank 1)'''
|-
| style="text-align: center;" | 0xC000
| colspan="2" style="text-align: center;" | Free RAM
|-
| style="text-align: center;" | 0xFE00
| rowspan="2" colspan="2" style="text-align: center;" | '''Color palette'''
|-
| style="text-align: center;" | 0xFFFF
|}
In addition, some elements can be placed at configurable locations in RAM, but with restrictions:
{| class="wikitable"
|+ WonderSwan SoC internal memory layout limitations
! Type
! Lowest address
! Highest address
! Alignment
|-
| Screen
| style="text-align: center;" | 0x0000
| style="text-align: center;" | 0x3800<br/>0x7800<sup>(color)</sup>
| 0x800 (2048) bytes
|-
| Sprite table
| style="text-align: center;" | 0x0000
| style="text-align: center;" | 0x3E00<br/>0x7E00<sup>(color)</sup>
| 0x200 (512) bytes
|-
| Sound wave table
| style="text-align: center;" | 0x0000
| style="text-align: center;" | 0x3FC0
| 0x40 (64) bytes
|}
Note that an element being present on this map does not mean that the space cannot be utilized for other data. For example, it is common for a WonderSwan game to only reserve sixteen out of the 256 interrupt vectors, reusing the remaining 240 as general RAM space.
== Cartridge ==
The cartridge part of the memory map is fully controlled by the cartridge bus; this is usually subdivided further by a [[Mapper]]. There exists a standard layout common to all official mappers:
{| class="wikitable"
|+ Standard mapper physical memory map
! Address range
! Bank
|-
| style="text-align: center;" | 0x10000<br/>0x1FFFF
| SRAM (or flashable ROM)
|-
| style="text-align: center;" | 0x20000<br/>0x2FFFF
| ROM bank 0
|-
| style="text-align: center;" | 0x30000<br/>0x3FFFF
| ROM bank 1
|-
| style="text-align: center;" | 0x40000<br/>0xFFFFF
| ROM linear (EX) bank
|}
0c3d38ba1af6c2d52a78fb0025a5f56afabe0561
Cartridge
0
45
331
192
2024-08-02T16:58:30Z
Asie
351
wikitext
text/x-wiki
== Cartridge bus ==
The SoC forwards some memory and I/O accesses to the cartridge bus:
* memory: physical addresses 0x10000 - 0xFFFFF,
* I/O: ports 0xC0 - 0xFF.
To facilitate this, the Memory/IO pin is used:
* When Memory/IO is asserted '''high''', all bus address pins specify the 20-bit linear memory address.
* When Memory/IO is asserted '''low''', bus address pins 0-7 specify the port address bits 0-7, bus address pins 8-15 are low, bus address pins 16-19 specify the port address bits 4-7.
== Interrupts ==
The cartridge bus provides an /IRQ pin which can be used by the cartridge to assert an interrupt.
d9c0df007e166cb5bc29cd90cbc5f2445bcef556
Cartridge connector
0
44
332
254
2024-08-02T16:58:50Z
Asie
351
/* Signal descriptions */ linear -> physical
wikitext
text/x-wiki
== Memory access ==
Both the ROM and the SRAM chip use a standard asynchronous memory interface.
It is presumed that:
* the CPU sets the address lines before each memory access while '''/OE''' or '''/WE''' respectively are still high,
* for writes the CPU sets the data lines with the falling edge of '''/WE''' (TODO: only confirmed for I/O writes),
* for reads the CPU latches the data lines on the subsequent rising edge of '''/OE'''.
Memory may be accessed in 8-bit or 16-bit mode. SRAM reads/writes always happen in 8-bit mode, while ROM reads/writes can happen in 8-bit or 16-bit mode depending on [[ROM header|header]] configuration.
Note that in 16-bit mode, the output on address line '''A0''' is undetermined and should be ignored.
== Pinout ==
<pre>
Cartridge Console
(label side) (back)
____________
|====|
____ |--01| -- GND
... \ | -02| <- CPU A15
... | | -03| <- CPU A10
... | | -04| <- CPU A11
... | | -05| <- CPU A9
... | | -06| <- CPU A8
... | | -07| <- CPU A13
... | | -08| <- CPU A14
... | | -09| <- CPU A12
... | | -10| <- CPU A7
... | | -11| <- CPU A6
... | | -12| <- CPU A5
... | | -13| <- CPU A4
... | | -14| <> D15
... | | -15| <> D14
... | | -16| <> D7
... | | -17| <> D6
... | | -18| <> D5
... | | -19| <> D4
... | | -20| <> D3
... | | -21| <> D2
... | | -22| <> D1
... | | -23| <> D0
... | |--24| -- +3.3V
... | |--25| -- +3.3V
... | | -26| <- CPU A0
... | | -27| <- CPU A1
... | | -28| <- CPU A2
... | | -29| <- CPU A3
... | | -30| <- CPU A19
... | | -31| <- CPU A18
... | | -32| <- CPU A17
... | | -33| <- CPU A16
... | | -34| <> D8
... | | -35| <> D9
... | | -36| <> D10
... | | -37| <> D11
... | | -38| <> D12
... | | -39| <> D13
... | | -40| <- /RESET
... | | -41| -> /MBC
... | | -42| <- M/IO (Memory/IO)
... | | -43| <- /RD (Read enable)
... | | -44| <- /WR (Write enable)
... | | -45| <- /SEL (Cartridge select)
... | | -46| -> /IRQ (Interrupt request)
____/ | -47| <- CLK
|--48| -- GND
_______|====|
Cartridge Console
(label side) (back)
</pre>
== Mechanical details ==
{| class="wikitable"
|-
! Distance !! Length (in mm)
|-
| Distance pad to pad || 1.25
|-
| Left edge to first pad || 0.7
|-
| Last pad to right edge || 0.95
|-
| Bottom edge to longer pads (GND, Vcc) || 0.5
|-
| Bottom edge to shorter pads || 1
|}
== Signal descriptions ==
* '''/RESET''': Reset signal output from the console. On a mono WonderSwan, it stays low for about 18 milliseconds after power-up.
* '''/MBC''': Authentication handshake signal. A cartridge is required to communicate over this pin shortly after reset.
* '''M/IO''': Memory/IO bus selection. The cartridge bus allows both memory access (to physical addresses 0x10000-0xFFFFF) and I/O access (to ports 0xC0-0xFF):
** When Memory/IO is '''high''', pins A0-A19 specify the 20-bit linear memory address.
** When Memory/IO is '''low''', pins A0-A7 specify the 8-bit I/O port address, pins A8-A15 are low, pins A16-A19 are a copy of the I/O port address bits 4-7.
* '''/IRQ''': Cartridge interrupt. When this pin is pulled low, the console will trigger a maskable cartridge interrupt.
* '''CLK''': A clock provided by the console. This pin outputs a frequency of 384 KHz, derived from the 12.288 MHz system clock; on the WonderSwan Color, it can optionally be configured by software to provide a 6.144 MHz frequency instead.
== Timing requirements ==
The '''/OE''' or '''/WE''' signal appear to have a frequency of about 3.072 MHz, derived from the 12.288 MHz system clock. This leaves half this period, so about 162 ns, to handle one memory access.
TODO: Verify how using ROM/SRAM wait states affects this.
== Authentication handshake ==
Shortly after '''/RESET''' goes high, a handshake between the SoC and the cartridge is performed, in order:
* '''/MBC''' is held high. '''A0'''-'''A3''' are set to 0xA and '''A16'''-'''A19''' are set to 0x5.
* On a rising edge of '''CLK''', '''A0'''-'''A3''' are set to 0x5 and '''A16'''-'''A19''' are set to 0xA.
* The cartridge continues to hold '''/MBC''' high for three additional '''CLK''' rising edges. Note that the SoC appears to allow some variance in this number of cycles.
* For each subsequent rising edge of '''CLK''', the cartridge is expected to output the following binary sequence through its '''/MBC''' pin: <code>1000101000101000000111</code>.
* After this is finished, '''/MBC''' is expected to stay high indefinitely.
On a successful handshake, the [[SoC]] sets bit 7 of the System Control I/O port. The boot ROM will refuse to boot the cartridge if this bit is not set; on the WonderSwan Color, it will refuse to start the system at all.
An example public domain (CC0) VHDL implementation by trap15 is available [https://bitbucket.org/trap15/mbc-unlock here].
6b704156ce7a63d14325374a6756e91f8113adfe
NEC V30MZ
0
39
333
207
2024-08-02T18:18:29Z
Asie
351
add architecture, sketch instruction set
wikitext
text/x-wiki
The NEC V30MZ is the CPU component of the WonderSwan SoC.
Unlike the NEC V20/V30 CPU family, the V30MZ is fully compatible with the Intel 80186's documented behaviour, as well as some of its undocumented behaviour (such as the SALC opcode); it also omits the V20/V30's opcode extensions.
The NEC V30MZ datasheet uses distinct names for opcodes and registers (''NEC names''); as all homebrew compilers and assemblers for the platform utilize Intel's official naming (''Intel names''), the latter is what the wiki - and most community tooling - has standardized on.
== Architecture ==
For this section, elements of the architecture which have distinct NEC names are provided in the following format: Intel<sup>NEC</sup>.
=== Registers ===
* Four 16-bit general-purpose registers, with their (low, high) components accessible as individual 8-bit sub-registers:
** '''AX'''<sup>AW</sup> ('''AL''', '''AH''')
** '''BX'''<sup>BW</sup> ('''BL''', '''BH''')
** '''CX'''<sup>CW</sup> ('''CL''', '''CH''')
** '''DX'''<sup>DW</sup> ('''DL''', '''DH''')
* Four additional 16-bit registers:
** '''SI'''<sup>IX</sup>
** '''DI'''<sup>IY</sup>
** '''SP'''
** '''BP'''
* Four segment registers:
** '''CS'''<sup>PS</sup> - code segment,
** '''DS'''<sup>DS0</sup> - data segment,
** '''ES'''<sup>DS1</sup> - additional data segment,
** '''SS''' - stack segment.
* '''IP'''<sup>PC</sup> - instruction pointer; instructions are always addressed in the code segment (so as <code>CS:IP</code> far addresses),
* '''FLAGS'''<sup>PSW</sup> - 16-bit processor flag register.
=== Flags ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
m111 odit sz0a 0p1c
| |||| || | | |
| |||| || | | +- Carry (CF<sup>CY</sup>)
| |||| || | +--- Parity (PF<sup>P</sup>)
| |||| || +------ Auxillary Carry (AF<sup>AC</sup>)
| |||| |+-------- Zero (Z)
| |||| +--------- Sign (S)
| |||+------------ Single Step<sup>Break</sup> (TF<sup>BRK</sup>)
| ||+------------- Interrupt Enable (IF<sup>IE</sup>)
| |+-------------- Direction (DF<sup>DIR</sup>)
| +--------------- Overflow (OF<sup>V</sup>)
+-------------------- Mode (MD)
</pre>
<!--
== Instruction set ==
{| class="wikitable sortable"
|+ V30MZ Instruction Set
|-
! Instruction
! Opcode (hex)
! Opcode (bin)
! Bytes
! Cycles
! Flags
! NEC mnemonic
! Notes
|-
| <tt>ADD AL, imm8</tt>
| <tt>04</tt>
| <tt>00000100</tt>
| 2
| 1
| <tt>O...SZAPC</tt>
| <tt>ADD AL, imm8</tt>
|
|-
| <tt>ADD AX, imm16</tt>
| <tt>05</tt>
| <tt>00000101</tt>
| 3
| 1
| <tt>O...SZAPC</tt>
| <tt>ADD AW, imm16</tt>
|
|-
| <tt>ADD mem8, imm8</tt>
| <tt>80 rm</tt> / <tt>82 rm</tt>
| <tt>100000.0 oo000mm</tt>
| 3-5
| 3
| <tt>O...SZAPC</tt>
| <tt>ADD mem8, imm8</tt>
|
|-
|}
-->
== Links ==
* [https://www.ardent-tool.com/CPU/docs/NEC/V20-V30/v30mz.pdf NEC V30MZ datasheet]
* [http://perfectkiosk.net/stsws.html#cpu STSWS - CPU - V30MZ/V Series Microprocessor]
2b50de1198a5ebd24957830d232dd07c077488a1
334
333
2024-08-02T18:30:26Z
Asie
351
/* Registers */
wikitext
text/x-wiki
The NEC V30MZ is the CPU component of the WonderSwan SoC.
Unlike the NEC V20/V30 CPU family, the V30MZ is fully compatible with the Intel 80186's documented behaviour, as well as some of its undocumented behaviour (such as the SALC opcode); it also omits the V20/V30's opcode extensions.
The NEC V30MZ datasheet uses distinct names for opcodes and registers (''NEC names''); as all homebrew compilers and assemblers for the platform utilize Intel's official naming (''Intel names''), the latter is what the wiki - and most community tooling - has standardized on.
== Architecture ==
For this section, elements of the architecture which have distinct NEC names are provided in the following format: Intel<sup>NEC</sup>.
=== Registers ===
* Four 16-bit general-purpose registers, with their (low, high) components accessible as individual 8-bit sub-registers:
** '''AX'''<sup>AW</sup> ('''AL''', '''AH''')
** '''BX'''<sup>BW</sup> ('''BL''', '''BH''')
** '''CX'''<sup>CW</sup> ('''CL''', '''CH''')
** '''DX'''<sup>DW</sup> ('''DL''', '''DH''')
* Four additional 16-bit registers:
** '''SI'''<sup>IX</sup>
** '''DI'''<sup>IY</sup>
** '''SP''' - stack pointer; the stack is always addressed in the stack segment (so as <code>SS:SP</code> far addresses).
** '''BP'''
* Four segment registers:
** '''CS'''<sup>PS</sup> - code segment,
** '''DS'''<sup>DS0</sup> - data segment,
** '''ES'''<sup>DS1</sup> - additional data segment,
** '''SS''' - stack segment.
* '''IP'''<sup>PC</sup> - instruction pointer; instructions are always addressed in the code segment (so as <code>CS:IP</code> far addresses),
* '''FLAGS'''<sup>PSW</sup> - 16-bit processor flag register.
While the eight registers can be used in a general-purpose manner, some opcodes are constrained to only using certain registers:
* '''AX''' benefits from more compact encoding for certain instructions; it's also used as an output and input register in multiplication/division, port access, BCD conversions, and (as AL) in the XCHG opcode.
* '''CX''' is used for loop and repeat instructions as a counter.
* '''DX''' can be used used as the address register for port access, it is also used as an output register for word multiplication/division.
* '''BX''', '''SI''', and '''DI''' can be used as indices for accessing data in tables in the DS segment (or other segments when overridden).
** '''SI''' and '''DI''' are, in addition, used as source and destination pointers by string instructions.
* Similarly, '''BP''' can be used as an index for accessing stack data; this makes it particularly useful as a frame pointer.
=== Flags ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
m111 odit sz0a 0p1c
| |||| || | | |
| |||| || | | +- Carry (CF<sup>CY</sup>)
| |||| || | +--- Parity (PF<sup>P</sup>)
| |||| || +------ Auxillary Carry (AF<sup>AC</sup>)
| |||| |+-------- Zero (Z)
| |||| +--------- Sign (S)
| |||+------------ Single Step<sup>Break</sup> (TF<sup>BRK</sup>)
| ||+------------- Interrupt Enable (IF<sup>IE</sup>)
| |+-------------- Direction (DF<sup>DIR</sup>)
| +--------------- Overflow (OF<sup>V</sup>)
+-------------------- Mode (MD)
</pre>
<!--
== Instruction set ==
{| class="wikitable sortable"
|+ V30MZ Instruction Set
|-
! Instruction
! Opcode (hex)
! Opcode (bin)
! Bytes
! Cycles
! Flags
! NEC mnemonic
! Notes
|-
| <tt>ADD AL, imm8</tt>
| <tt>04</tt>
| <tt>00000100</tt>
| 2
| 1
| <tt>O...SZAPC</tt>
| <tt>ADD AL, imm8</tt>
|
|-
| <tt>ADD AX, imm16</tt>
| <tt>05</tt>
| <tt>00000101</tt>
| 3
| 1
| <tt>O...SZAPC</tt>
| <tt>ADD AW, imm16</tt>
|
|-
| <tt>ADD mem8, imm8</tt>
| <tt>80 rm</tt> / <tt>82 rm</tt>
| <tt>100000.0 oo000mm</tt>
| 3-5
| 3
| <tt>O...SZAPC</tt>
| <tt>ADD mem8, imm8</tt>
|
|-
|}
-->
== Links ==
* [https://www.ardent-tool.com/CPU/docs/NEC/V20-V30/v30mz.pdf NEC V30MZ datasheet]
* [http://perfectkiosk.net/stsws.html#cpu STSWS - CPU - V30MZ/V Series Microprocessor]
d60a3e82636ac390ed1beb66e9c3a76a6f88b4a9
335
334
2024-08-02T19:01:50Z
Asie
351
fix formatting
wikitext
text/x-wiki
The NEC V30MZ is the CPU component of the WonderSwan SoC.
Unlike the NEC V20/V30 CPU family, the V30MZ is fully compatible with the Intel 80186's documented behaviour, as well as some of its undocumented behaviour (such as the SALC opcode); it also omits the V20/V30's opcode extensions.
The NEC V30MZ datasheet uses distinct names for opcodes and registers (''NEC names''); as all homebrew compilers and assemblers for the platform utilize Intel's official naming (''Intel names''), the latter is what the wiki - and most community tooling - has standardized on.
== Architecture ==
For this section, elements of the architecture which have distinct NEC names are provided in the following format: Intel<sup>NEC</sup>.
=== Registers ===
* Four 16-bit general-purpose registers, with their (low, high) components accessible as individual 8-bit sub-registers:
** '''AX'''<sup>AW</sup> ('''AL''', '''AH''')
** '''BX'''<sup>BW</sup> ('''BL''', '''BH''')
** '''CX'''<sup>CW</sup> ('''CL''', '''CH''')
** '''DX'''<sup>DW</sup> ('''DL''', '''DH''')
* Four additional 16-bit registers:
** '''SI'''<sup>IX</sup>
** '''DI'''<sup>IY</sup>
** '''SP''' - stack pointer; the stack is always addressed in the stack segment (so as <code>SS:SP</code> far addresses).
** '''BP'''
* Four segment registers:
** '''CS'''<sup>PS</sup> - code segment,
** '''DS'''<sup>DS0</sup> - data segment,
** '''ES'''<sup>DS1</sup> - additional data segment,
** '''SS''' - stack segment.
* '''IP'''<sup>PC</sup> - instruction pointer; instructions are always addressed in the code segment (so as <code>CS:IP</code> far addresses),
* '''FLAGS'''<sup>PSW</sup> - 16-bit processor flag register.
While the eight registers can be used in a general-purpose manner, some opcodes are constrained to only using certain registers:
* '''AX''' benefits from more compact encoding for certain instructions; it's also used as an output and input register in multiplication/division, port access, BCD conversions, and (as AL) in the XCHG opcode.
* '''CX''' is used for loop and repeat instructions as a counter.
* '''DX''' can be used used as the address register for port access, it is also used as an output register for word multiplication/division.
* '''BX''', '''SI''', and '''DI''' can be used as indices for accessing data in tables in the DS segment (or other segments when overridden).
** '''SI''' and '''DI''' are, in addition, used as source and destination pointers by string instructions.
* Similarly, '''BP''' can be used as an index for accessing stack data; this makes it particularly useful as a frame pointer.
=== Flags ===
15 bit 8 7 bit 0
---- ---- ---- ----
m111 odit sz0a 0p1c
| |||| || | | |
| |||| || | | +- Carry (CF<sup>CY</sup>)
| |||| || | +--- Parity (PF<sup>P</sup>)
| |||| || +------ Auxillary Carry (AF<sup>AC</sup>)
| |||| |+-------- Zero (Z)
| |||| +--------- Sign (S)
| |||+------------ Single Step<sup>Break</sup> (TF<sup>BRK</sup>)
| ||+------------- Interrupt Enable (IF<sup>IE</sup>)
| |+-------------- Direction (DF<sup>DIR</sup>)
| +--------------- Overflow (OF<sup>V</sup>)
+-------------------- Mode (MD)
== Instruction set ==
{| class="wikitable sortable"
|+ V30MZ Instruction Set
|-
! Instruction
! Opcode (hex)
! Opcode (bin)
! Bytes
! Cycles
! Flags
! NEC mnemonic
! Notes
|-
| <tt>ADD AL, imm8</tt>
| <tt>04</tt>
| <tt>00000100</tt>
| 2
| 1
| <tt>O...SZAPC</tt>
| <tt>ADD AL, imm8</tt>
|
|-
| <tt>ADD AX, imm16</tt>
| <tt>05</tt>
| <tt>00000101</tt>
| 3
| 1
| <tt>O...SZAPC</tt>
| <tt>ADD AW, imm16</tt>
|
|-
| <tt>ADD mem8, imm8</tt>
| <tt>80 rm</tt> / <tt>82 rm</tt>
| <tt>100000.0 oo000mm</tt>
| 3-5
| 3
| <tt>O...SZAPC</tt>
| <tt>ADD mem8, imm8</tt>
|
|-
|}
== Links ==
* [https://www.ardent-tool.com/CPU/docs/NEC/V20-V30/v30mz.pdf NEC V30MZ datasheet]
* [http://perfectkiosk.net/stsws.html#cpu STSWS - CPU - V30MZ/V Series Microprocessor]
a59bed3dd6d5f5b6cb069f0873a41e063b487d15
336
335
2024-08-03T07:27:14Z
Asie
351
/* Flags */ elaborate
wikitext
text/x-wiki
The NEC V30MZ is the CPU component of the WonderSwan SoC.
Unlike the NEC V20/V30 CPU family, the V30MZ is fully compatible with the Intel 80186's documented behaviour, as well as some of its undocumented behaviour (such as the SALC opcode); it also omits the V20/V30's opcode extensions.
The NEC V30MZ datasheet uses distinct names for opcodes and registers (''NEC names''); as all homebrew compilers and assemblers for the platform utilize Intel's official naming (''Intel names''), the latter is what the wiki - and most community tooling - has standardized on.
== Architecture ==
For this section, elements of the architecture which have distinct NEC names are provided in the following format: Intel<sup>NEC</sup>.
=== Registers ===
* Four 16-bit general-purpose registers, with their (low, high) components accessible as individual 8-bit sub-registers:
** '''AX'''<sup>AW</sup> ('''AL''', '''AH''')
** '''BX'''<sup>BW</sup> ('''BL''', '''BH''')
** '''CX'''<sup>CW</sup> ('''CL''', '''CH''')
** '''DX'''<sup>DW</sup> ('''DL''', '''DH''')
* Four additional 16-bit registers:
** '''SI'''<sup>IX</sup>
** '''DI'''<sup>IY</sup>
** '''SP''' - stack pointer; the stack is always addressed in the stack segment (so as <code>SS:SP</code> far addresses).
** '''BP'''
* Four segment registers:
** '''CS'''<sup>PS</sup> - code segment,
** '''DS'''<sup>DS0</sup> - data segment,
** '''ES'''<sup>DS1</sup> - additional data segment,
** '''SS''' - stack segment.
* '''IP'''<sup>PC</sup> - instruction pointer; instructions are always addressed in the code segment (so as <code>CS:IP</code> far addresses),
* '''FLAGS'''<sup>PSW</sup> - 16-bit processor flag register.
While the eight registers can be used in a general-purpose manner, some opcodes are constrained to only using certain registers:
* '''AX''' benefits from more compact encoding for certain instructions; it's also used as an output and input register in multiplication/division, port access, BCD conversions, and (as AL) in the XCHG opcode.
* '''CX''' is used for loop and repeat instructions as a counter.
* '''DX''' can be used used as the address register for port access, it is also used as an output register for word multiplication/division.
* '''BX''', '''SI''', and '''DI''' can be used as indices for accessing data in tables in the DS segment (or other segments when overridden).
** '''SI''' and '''DI''' are, in addition, used as source and destination pointers by string instructions.
* Similarly, '''BP''' can be used as an index for accessing stack data; this makes it particularly useful as a frame pointer.
=== Flags ===
The V30MZ features the following flags:
15 bit 8 7 bit 0
---- ---- ---- ----
m111 odit sz0a 0p1c
| |||| || | | |
| |||| || | | +- Carry (CF<sup>CY</sup>)
| |||| || | +--- Parity (PF<sup>P</sup>)
| |||| || +------ Auxillary Carry (AF<sup>AC</sup>)
| |||| |+-------- Zero (Z)
| |||| +--------- Sign (S)
| |||+------------ Single Step<sup>Break</sup> (TF<sup>BRK</sup>)
| ||+------------- Interrupt Enable (IF<sup>IE</sup>)
| |+-------------- Direction (DF<sup>DIR</sup>)
| +--------------- Overflow (OF<sup>V</sup>)
+-------------------- Mode (MD)
In general, they are set by operations as follows:
* '''Carry''' - stores the carry/borrow state of the last arithmetic operation, or the bit shifted to it for shift/rotate operations.
* '''Parity''' - set to <tt>1</tt> if, after arithmetic and logical operations, the lower 8 bits of the result are even.
* '''Auxillary Carry''' - stores the carry state from the lower 4-bit nibble (bits 0-3) to the higher 4-bit nibble (bits 4-7), or the borrow state from the higher nibble to the lower nibble.
* '''Zero''' - set to <tt>1</tt> if, after arithmetic and logical operations, the result is equal to zero.
* '''Sign''' - set to <tt>1</tt> if, after arithmetic and logical operations, the highest bit of the result is set.
* '''Overflow''' - set to <tt>1</tt> if an overflow occured as part of the arithmetic operation.
There are also programmer-controlled control flags:
* '''Single Step''' - if set to <tt>1</tt>, after every instruction, a software interrupt (vector 1) is generated.
* '''Interrupt Enable''' - if set to <tt>1</tt>, enables maskable interrupt handling via the interrupt vector table; cleared to <tt>0</tt> as part of interrupt handling and restored by the <tt>IRET</tt> opcode.
* '''Direction''' - if set to <tt>1</tt>, string instructions decrement pointers as part of their operation; if set to <tt>0</tt>, the pointers are to be incremented.
* '''Mode''' - used for 8080 emulation mode in other V20/V30-family chips, does nothing on V30MZ
== Instruction set ==
{| class="wikitable sortable"
|+ V30MZ Instruction Set
|-
! Instruction
! Opcode (hex)
! Opcode (bin)
! Bytes
! Cycles
! Flags
! NEC mnemonic
! Notes
|-
| <tt>ADD AL, imm8</tt>
| <tt>04</tt>
| <tt>00000100</tt>
| 2
| 1
| <tt>O...SZAPC</tt>
| <tt>ADD AL, imm8</tt>
|
|-
| <tt>ADD AX, imm16</tt>
| <tt>05</tt>
| <tt>00000101</tt>
| 3
| 1
| <tt>O...SZAPC</tt>
| <tt>ADD AW, imm16</tt>
|
|-
| <tt>ADD mem8, imm8</tt>
| <tt>80 rm</tt> / <tt>82 rm</tt>
| <tt>100000.0 oo000mm</tt>
| 3-5
| 3
| <tt>O...SZAPC</tt>
| <tt>ADD mem8, imm8</tt>
|
|-
|}
== Links ==
* [https://www.ardent-tool.com/CPU/docs/NEC/V20-V30/v30mz.pdf NEC V30MZ datasheet]
* [http://perfectkiosk.net/stsws.html#cpu STSWS - CPU - V30MZ/V Series Microprocessor]
cae55ac0b8861310ddc8e0fef2be17fbe59ee2ef
337
336
2024-08-03T09:01:56Z
Asie
351
/* Registers */ add register names
wikitext
text/x-wiki
The NEC V30MZ is the CPU component of the WonderSwan SoC.
Unlike the NEC V20/V30 CPU family, the V30MZ is fully compatible with the Intel 80186's documented behaviour, as well as some of its undocumented behaviour (such as the SALC opcode); it also omits the V20/V30's opcode extensions.
The NEC V30MZ datasheet uses distinct names for opcodes and registers (''NEC names''); as all homebrew compilers and assemblers for the platform utilize Intel's official naming (''Intel names''), the latter is what the wiki - and most community tooling - has standardized on.
== Architecture ==
For this section, elements of the architecture which have distinct NEC names are provided in the following format: Intel<sup>NEC</sup>.
=== Registers ===
* Four 16-bit general-purpose registers, with their (low, high) components accessible as individual 8-bit sub-registers:
** '''AX'''<sup>AW</sup> ('''AL''', '''AH''') - the ''accumulator'' register,
** '''BX'''<sup>BW</sup> ('''BL''', '''BH''') - the ''base'' register,
** '''CX'''<sup>CW</sup> ('''CL''', '''CH''') - the ''count'' register,
** '''DX'''<sup>DW</sup> ('''DL''', '''DH''') - the ''data'' register,
* Four additional 16-bit registers:
** '''SI'''<sup>IX</sup> - the ''source index'' register,
** '''DI'''<sup>IY</sup> - the ''destination index'' register,
** '''SP''' - the ''stack pointer''; the stack is always addressed in the stack segment (so as <code>SS:SP</code> far addresses),
** '''BP''' - the ''base pointer'.
* Four segment registers:
** '''CS'''<sup>PS</sup> - code segment,
** '''DS'''<sup>DS0</sup> - data segment,
** '''ES'''<sup>DS1</sup> - additional data segment,
** '''SS''' - stack segment.
* '''IP'''<sup>PC</sup> - instruction pointer; instructions are always addressed in the code segment (so as <code>CS:IP</code> far addresses),
* '''FLAGS'''<sup>PSW</sup> - 16-bit processor flag register.
While the eight registers can be used in a general-purpose manner, some opcodes are constrained to only using certain registers:
* '''AX''' benefits from more compact encoding for certain instructions; it's also used as an output and input register in multiplication/division, port access, BCD conversions, and (as AL) in the XCHG opcode.
* '''CX''' is used for loop and repeat instructions as a counter.
* '''DX''' can be used used as the address register for port access, it is also used as an output register for word multiplication/division.
* '''BX''', '''SI''', and '''DI''' can be used as indices for accessing data in tables in the DS segment (or other segments when overridden).
** '''SI''' and '''DI''' are, in addition, used as source and destination pointers by string instructions.
* Similarly, '''BP''' can be used as an index for accessing stack data; this makes it particularly useful as a frame pointer.
=== Flags ===
The V30MZ features the following flags:
15 bit 8 7 bit 0
---- ---- ---- ----
m111 odit sz0a 0p1c
| |||| || | | |
| |||| || | | +- Carry (CF<sup>CY</sup>)
| |||| || | +--- Parity (PF<sup>P</sup>)
| |||| || +------ Auxillary Carry (AF<sup>AC</sup>)
| |||| |+-------- Zero (Z)
| |||| +--------- Sign (S)
| |||+------------ Single Step<sup>Break</sup> (TF<sup>BRK</sup>)
| ||+------------- Interrupt Enable (IF<sup>IE</sup>)
| |+-------------- Direction (DF<sup>DIR</sup>)
| +--------------- Overflow (OF<sup>V</sup>)
+-------------------- Mode (MD)
In general, they are set by operations as follows:
* '''Carry''' - stores the carry/borrow state of the last arithmetic operation, or the bit shifted to it for shift/rotate operations.
* '''Parity''' - set to <tt>1</tt> if, after arithmetic and logical operations, the lower 8 bits of the result are even.
* '''Auxillary Carry''' - stores the carry state from the lower 4-bit nibble (bits 0-3) to the higher 4-bit nibble (bits 4-7), or the borrow state from the higher nibble to the lower nibble.
* '''Zero''' - set to <tt>1</tt> if, after arithmetic and logical operations, the result is equal to zero.
* '''Sign''' - set to <tt>1</tt> if, after arithmetic and logical operations, the highest bit of the result is set.
* '''Overflow''' - set to <tt>1</tt> if an overflow occured as part of the arithmetic operation.
There are also programmer-controlled control flags:
* '''Single Step''' - if set to <tt>1</tt>, after every instruction, a software interrupt (vector 1) is generated.
* '''Interrupt Enable''' - if set to <tt>1</tt>, enables maskable interrupt handling via the interrupt vector table; cleared to <tt>0</tt> as part of interrupt handling and restored by the <tt>IRET</tt> opcode.
* '''Direction''' - if set to <tt>1</tt>, string instructions decrement pointers as part of their operation; if set to <tt>0</tt>, the pointers are to be incremented.
* '''Mode''' - used for 8080 emulation mode in other V20/V30-family chips, does nothing on V30MZ
== Instruction set ==
{| class="wikitable sortable"
|+ V30MZ Instruction Set
|-
! Instruction
! Opcode (hex)
! Opcode (bin)
! Bytes
! Cycles
! Flags
! NEC mnemonic
! Notes
|-
| <tt>ADD AL, imm8</tt>
| <tt>04</tt>
| <tt>00000100</tt>
| 2
| 1
| <tt>O...SZAPC</tt>
| <tt>ADD AL, imm8</tt>
|
|-
| <tt>ADD AX, imm16</tt>
| <tt>05</tt>
| <tt>00000101</tt>
| 3
| 1
| <tt>O...SZAPC</tt>
| <tt>ADD AW, imm16</tt>
|
|-
| <tt>ADD mem8, imm8</tt>
| <tt>80 rm</tt> / <tt>82 rm</tt>
| <tt>100000.0 oo000mm</tt>
| 3-5
| 3
| <tt>O...SZAPC</tt>
| <tt>ADD mem8, imm8</tt>
|
|-
|}
== Links ==
* [https://www.ardent-tool.com/CPU/docs/NEC/V20-V30/v30mz.pdf NEC V30MZ datasheet]
* [http://perfectkiosk.net/stsws.html#cpu STSWS - CPU - V30MZ/V Series Microprocessor]
31db6ebc3e6f963f4ab634aa37b5aa1dc8f25715
338
337
2024-08-03T09:02:35Z
Asie
351
/* Architecture */
wikitext
text/x-wiki
The NEC V30MZ is the CPU component of the WonderSwan SoC.
Unlike the NEC V20/V30 CPU family, the V30MZ is fully compatible with the Intel 80186's documented behaviour, as well as some of its undocumented behaviour (such as the SALC opcode); it also omits the V20/V30's opcode extensions.
The NEC V30MZ datasheet uses distinct names for opcodes and registers (''NEC names''); as all homebrew compilers and assemblers for the platform utilize Intel's official naming (''Intel names''), the latter is what the wiki - and most community tooling - has standardized on.
== Architecture ==
For this section, elements of the architecture which have distinct NEC names are provided in the following format: Intel<sup>NEC</sup>.
=== Registers ===
* Four 16-bit general-purpose registers, with their (low, high) components accessible as individual 8-bit sub-registers:
** '''AX'''<sup>AW</sup> ('''AL''', '''AH''') - the ''accumulator'' register,
** '''BX'''<sup>BW</sup> ('''BL''', '''BH''') - the ''base'' register,
** '''CX'''<sup>CW</sup> ('''CL''', '''CH''') - the ''count'' register,
** '''DX'''<sup>DW</sup> ('''DL''', '''DH''') - the ''data'' register,
* Four additional 16-bit registers:
** '''SI'''<sup>IX</sup> - the ''source index'' register,
** '''DI'''<sup>IY</sup> - the ''destination index'' register,
** '''SP''' - the ''stack pointer''; the stack is always addressed in the stack segment (so as <code>SS:SP</code> far addresses),
** '''BP''' - the ''base pointer''.
* Four segment registers:
** '''CS'''<sup>PS</sup> - the ''code segment'',
** '''DS'''<sup>DS0</sup> - the ''data segment'',
** '''ES'''<sup>DS1</sup> - the ''extra segment''; an additional data segment,
** '''SS''' - the ''stack segment''.
* '''IP'''<sup>PC</sup> - the ''instruction pointer''; instructions are always addressed in the code segment (so as <code>CS:IP</code> far addresses),
* '''FLAGS'''<sup>PSW</sup> - the 16-bit processor flag register.
While the eight registers can be used in a general-purpose manner, some opcodes are constrained to only using certain registers:
* '''AX''' benefits from more compact encoding for certain instructions; it's also used as an output and input register in multiplication/division, port access, BCD conversions, and (as AL) in the XCHG opcode.
* '''CX''' is used for loop and repeat instructions as a counter.
* '''DX''' can be used used as the address register for port access, it is also used as an output register for word multiplication/division.
* '''BX''', '''SI''', and '''DI''' can be used as indices for accessing data in tables in the DS segment (or other segments when overridden).
** '''SI''' and '''DI''' are, in addition, used as source and destination pointers by string instructions.
* Similarly, '''BP''' can be used as an index for accessing stack data; this makes it particularly useful as a frame pointer.
=== Flags ===
The V30MZ features the following flags:
15 bit 8 7 bit 0
---- ---- ---- ----
m111 odit sz0a 0p1c
| |||| || | | |
| |||| || | | +- Carry (CF<sup>CY</sup>)
| |||| || | +--- Parity (PF<sup>P</sup>)
| |||| || +------ Auxillary Carry (AF<sup>AC</sup>)
| |||| |+-------- Zero (Z)
| |||| +--------- Sign (S)
| |||+------------ Single Step<sup>Break</sup> (TF<sup>BRK</sup>)
| ||+------------- Interrupt Enable (IF<sup>IE</sup>)
| |+-------------- Direction (DF<sup>DIR</sup>)
| +--------------- Overflow (OF<sup>V</sup>)
+-------------------- Mode (MD)
In general, they are set by operations as follows:
* '''Carry''' - stores the carry/borrow state of the last arithmetic operation, or the bit shifted to it for shift/rotate operations.
* '''Parity''' - set to <tt>1</tt> if, after arithmetic and logical operations, the lower 8 bits of the result are even.
* '''Auxillary Carry''' - stores the carry state from the lower 4-bit nibble (bits 0-3) to the higher 4-bit nibble (bits 4-7), or the borrow state from the higher nibble to the lower nibble.
* '''Zero''' - set to <tt>1</tt> if, after arithmetic and logical operations, the result is equal to zero.
* '''Sign''' - set to <tt>1</tt> if, after arithmetic and logical operations, the highest bit of the result is set.
* '''Overflow''' - set to <tt>1</tt> if an overflow occured as part of the arithmetic operation.
There are also programmer-controlled control flags:
* '''Single Step''' - if set to <tt>1</tt>, after every instruction, a software interrupt (vector 1) is generated.
* '''Interrupt Enable''' - if set to <tt>1</tt>, enables maskable interrupt handling via the interrupt vector table; cleared to <tt>0</tt> as part of interrupt handling and restored by the <tt>IRET</tt> opcode.
* '''Direction''' - if set to <tt>1</tt>, string instructions decrement pointers as part of their operation; if set to <tt>0</tt>, the pointers are to be incremented.
* '''Mode''' - used for 8080 emulation mode in other V20/V30-family chips, does nothing on V30MZ
== Instruction set ==
{| class="wikitable sortable"
|+ V30MZ Instruction Set
|-
! Instruction
! Opcode (hex)
! Opcode (bin)
! Bytes
! Cycles
! Flags
! NEC mnemonic
! Notes
|-
| <tt>ADD AL, imm8</tt>
| <tt>04</tt>
| <tt>00000100</tt>
| 2
| 1
| <tt>O...SZAPC</tt>
| <tt>ADD AL, imm8</tt>
|
|-
| <tt>ADD AX, imm16</tt>
| <tt>05</tt>
| <tt>00000101</tt>
| 3
| 1
| <tt>O...SZAPC</tt>
| <tt>ADD AW, imm16</tt>
|
|-
| <tt>ADD mem8, imm8</tt>
| <tt>80 rm</tt> / <tt>82 rm</tt>
| <tt>100000.0 oo000mm</tt>
| 3-5
| 3
| <tt>O...SZAPC</tt>
| <tt>ADD mem8, imm8</tt>
|
|-
|}
== Links ==
* [https://www.ardent-tool.com/CPU/docs/NEC/V20-V30/v30mz.pdf NEC V30MZ datasheet]
* [http://perfectkiosk.net/stsws.html#cpu STSWS - CPU - V30MZ/V Series Microprocessor]
73e26fa0ecac64527386574f601440bcd9d4bdfe
339
338
2024-08-03T09:02:55Z
Asie
351
wikitext
text/x-wiki
The NEC V30MZ is the CPU component of the WonderSwan SoC.
Unlike the NEC V20/V30 CPU family, the V30MZ is fully compatible with the Intel 80186's documented behaviour, as well as some of its undocumented behaviour (such as the SALC opcode); it also omits the V20/V30's opcode extensions.
The NEC V30MZ datasheet uses distinct names for opcodes and registers (''NEC names''); as all homebrew compilers and assemblers for the platform utilize Intel's official naming (''Intel names''), the latter is what the wiki - and most community tooling - has standardized on.
== Architecture ==
For this section, elements of the architecture which have distinct NEC names are provided in the following format: Intel<sup>NEC</sup>.
=== Registers ===
* Four 16-bit general-purpose registers, with their (low, high) components accessible as individual 8-bit sub-registers:
** '''AX'''<sup>AW</sup> ('''AL''', '''AH''') - the ''accumulator'' register,
** '''BX'''<sup>BW</sup> ('''BL''', '''BH''') - the ''base'' register,
** '''CX'''<sup>CW</sup> ('''CL''', '''CH''') - the ''count'' register,
** '''DX'''<sup>DW</sup> ('''DL''', '''DH''') - the ''data'' register,
* Four additional 16-bit registers:
** '''SI'''<sup>IX</sup> - the ''source index'' register,
** '''DI'''<sup>IY</sup> - the ''destination index'' register,
** '''SP''' - the ''stack pointer''; the stack is always addressed in the stack segment (so as <code>SS:SP</code> far addresses),
** '''BP''' - the ''base pointer''.
* Four segment registers:
** '''CS'''<sup>PS</sup> - the ''code segment'',
** '''DS'''<sup>DS0</sup> - the ''data segment'',
** '''ES'''<sup>DS1</sup> - the ''extra segment''; an additional data segment,
** '''SS''' - the ''stack segment''.
* '''IP'''<sup>PC</sup> - the ''instruction pointer''; instructions are always addressed in the code segment (so as <code>CS:IP</code> far addresses),
* '''FLAGS'''<sup>PSW</sup> - the 16-bit processor flag register.
While the eight registers can be used in a general-purpose manner, some opcodes are constrained to only using certain registers:
* '''AX''' benefits from more compact encoding for certain instructions; it's also used as an output and input register in multiplication/division, port access, BCD conversions, and (as AL) in the XCHG opcode.
* '''CX''' is used for loop and repeat instructions as a counter.
* '''DX''' can be used used as the address register for port access, it is also used as an output register for word multiplication/division.
* '''BX''', '''SI''', and '''DI''' can be used as indices for accessing data in tables in the DS segment (or other segments when overridden).
** '''SI''' and '''DI''' are, in addition, used as source and destination pointers by string instructions.
* Similarly, '''BP''' can be used as an index for accessing stack data; this makes it particularly useful as a frame pointer.
=== Flags ===
The V30MZ features the following flags:
15 bit 8 7 bit 0
---- ---- ---- ----
m111 odit sz0a 0p1c
| |||| || | | |
| |||| || | | +- Carry (CF<sup>CY</sup>)
| |||| || | +--- Parity (PF<sup>P</sup>)
| |||| || +------ Auxillary Carry (AF<sup>AC</sup>)
| |||| |+-------- Zero (Z)
| |||| +--------- Sign (S)
| |||+------------ Single Step<sup>Break</sup> (TF<sup>BRK</sup>)
| ||+------------- Interrupt Enable (IF<sup>IE</sup>)
| |+-------------- Direction (DF<sup>DIR</sup>)
| +--------------- Overflow (OF<sup>V</sup>)
+-------------------- Mode (MD)
In general, they are set by operations as follows:
* '''Carry''' - stores the carry/borrow state of the last arithmetic operation, or the bit shifted to it for shift/rotate operations.
* '''Parity''' - set to <tt>1</tt> if, after arithmetic and logical operations, the lower 8 bits of the result are even.
* '''Auxillary Carry''' - stores the carry state from the lower 4-bit nibble (bits 0-3) to the higher 4-bit nibble (bits 4-7), or the borrow state from the higher nibble to the lower nibble.
* '''Zero''' - set to <tt>1</tt> if, after arithmetic and logical operations, the result is equal to zero.
* '''Sign''' - set to <tt>1</tt> if, after arithmetic and logical operations, the highest bit of the result is set.
* '''Overflow''' - set to <tt>1</tt> if an overflow occured as part of the arithmetic operation.
There are also programmer-controlled control flags:
* '''Single Step''' - if set to <tt>1</tt>, after every instruction, a software interrupt (vector 1) is generated.
* '''Interrupt Enable''' - if set to <tt>1</tt>, enables maskable interrupt handling via the interrupt vector table; cleared to <tt>0</tt> as part of interrupt handling and restored by the <tt>IRET</tt> opcode.
* '''Direction''' - if set to <tt>1</tt>, string instructions decrement pointers as part of their operation; if set to <tt>0</tt>, the pointers are to be incremented.
* '''Mode''' - used for 8080 emulation mode in other V20/V30-family chips, does nothing on V30MZ
<!--
== Instruction set ==
{| class="wikitable sortable"
|+ V30MZ Instruction Set
|-
! Instruction
! Opcode (hex)
! Opcode (bin)
! Bytes
! Cycles
! Flags
! NEC mnemonic
! Notes
|-
| <tt>ADD AL, imm8</tt>
| <tt>04</tt>
| <tt>00000100</tt>
| 2
| 1
| <tt>O...SZAPC</tt>
| <tt>ADD AL, imm8</tt>
|
|-
| <tt>ADD AX, imm16</tt>
| <tt>05</tt>
| <tt>00000101</tt>
| 3
| 1
| <tt>O...SZAPC</tt>
| <tt>ADD AW, imm16</tt>
|
|-
| <tt>ADD mem8, imm8</tt>
| <tt>80 rm</tt> / <tt>82 rm</tt>
| <tt>100000.0 oo000mm</tt>
| 3-5
| 3
| <tt>O...SZAPC</tt>
| <tt>ADD mem8, imm8</tt>
|
|-
|}
-->
== Links ==
* [https://www.ardent-tool.com/CPU/docs/NEC/V20-V30/v30mz.pdf NEC V30MZ datasheet]
* [http://perfectkiosk.net/stsws.html#cpu STSWS - CPU - V30MZ/V Series Microprocessor]
f82197109e5fbcbde83f031ad84200c841eee3be
345
339
2024-08-05T09:38:15Z
Asie
351
move sections out to sub-pages
wikitext
text/x-wiki
The NEC V30MZ is the CPU component of the WonderSwan SoC.
Unlike the NEC V20/V30 CPU family, the V30MZ is fully compatible with the Intel 80186's documented behaviour, as well as some of its undocumented behaviour (such as the SALC opcode); it also omits the V20/V30's opcode extensions.
== Format ==
The NEC V30MZ datasheet provides distinct names for opcodes, flags and registers, which the wiki refers to as ''NEC names''. As all homebrew compilers and assemblers for the platform utilize Intel's official naming (''Intel names''), the latter is what is used throughout. For registers and flags, distinct NEC names are presented in the following format: Intel<sup>NEC</sup>.
== Sections ==
* [[NEC V30MZ registers]]
* [[NEC V30MZ flags]]
* [[NEC V30MZ instruction set]]
* [[NEC V30MZ interrupts]]
== Links ==
* [https://www.ardent-tool.com/CPU/docs/NEC/V20-V30/v30mz.pdf NEC V30MZ datasheet]
* [http://perfectkiosk.net/stsws.html#cpu STSWS - CPU - V30MZ/V Series Microprocessor]
00280da54f31086332da25ec5f2da091d2b94c8a
NEC V30MZ flags
0
56
342
2024-08-05T09:36:06Z
Asie
351
Created page with " = NEC V30MZ flags = == Layout == The V30MZ processor features a 16-bit flag register: 15 bit 8 7 bit 0 ---- ---- ---- ---- m111 odit sz0a 0p1c | |||| || | | | | |||| || | | +- Carry (CF<sup>CY</sup>) | |||| || | +--- Parity (PF<sup>P</sup>) | |||| || +------ Auxillary Carry (AF<sup>AC</sup>) | |||| |+-------- Zero (Z) | |||| +--------- Sign (S) | |||+------------ Single Step<sup>Break</sup> (TF<sup>BRK</sup>)..."
wikitext
text/x-wiki
= NEC V30MZ flags =
== Layout ==
The V30MZ processor features a 16-bit flag register:
15 bit 8 7 bit 0
---- ---- ---- ----
m111 odit sz0a 0p1c
| |||| || | | |
| |||| || | | +- Carry (CF<sup>CY</sup>)
| |||| || | +--- Parity (PF<sup>P</sup>)
| |||| || +------ Auxillary Carry (AF<sup>AC</sup>)
| |||| |+-------- Zero (Z)
| |||| +--------- Sign (S)
| |||+------------ Single Step<sup>Break</sup> (TF<sup>BRK</sup>)
| ||+------------- Interrupt Enable (IF<sup>IE</sup>)
| |+-------------- Direction (DF<sup>DIR</sup>)
| +--------------- Overflow (OF<sup>V</sup>)
+-------------------- Mode (MD)
== Status flags ==
The following flags are typically modified by instructions:
=== Carry ===
Stores the carry/borrow state of the last arithmetic operation, or the bit shifted to it for shift/rotate operations.
=== Parity ===
Set to <tt>1</tt> if, after arithmetic and logical operations, the lower 8 bits of the result are even.
=== Auxillary Carry ===
Stores the carry state from the lower 4-bit nibble (bits 0-3) to the higher 4-bit nibble (bits 4-7), or the borrow state from the higher nibble to the lower nibble.
=== Zero ===
Set to <tt>1</tt> if, after arithmetic and logical operations, the result is equal to zero.
=== Sign ===
Set to <tt>1</tt> if, after arithmetic and logical operations, the highest bit of the result is set.
=== Overflow ===
Set to <tt>1</tt> if an overflow occured as part of the arithmetic operation.
== Control flags ==
The following flags are typically modified by the developer:
=== Single step ===
If set to <tt>1</tt>, after every instruction, a software interrupt (vector 1) is generated.
Alternatively referred to as the ''trap flag''.
=== Interrupt enable ===
If set to <tt>1</tt>, enables maskable interrupt handling via the interrupt vector table; cleared to <tt>0</tt> as part of interrupt handling and restored by the <tt>IRET</tt> opcode.
=== Direction ===
If set to <tt>1</tt>, string instructions decrement pointers as part of their operation; if set to <tt>0</tt>, the pointers are to be incremented.
=== Mode ===
This flag does nothing on the NEC V30MZ. It was used to implement 8080 emulation mode in other V20/V30-family chips, but this functionality has been removed in the V30MZ.
782b8b6670b1602b18252ac04eec7b6a98eb2291
NEC V30MZ registers
0
57
343
2024-08-05T09:36:29Z
Asie
351
Created page with "= NEC V30MZ registers = * Four 16-bit general-purpose registers, with their (low, high) components accessible as individual 8-bit sub-registers: ** '''AX'''<sup>AW</sup> ('''AL''', '''AH''') - the ''accumulator'' register, ** '''BX'''<sup>BW</sup> ('''BL''', '''BH''') - the ''base'' register, ** '''CX'''<sup>CW</sup> ('''CL''', '''CH''') - the ''count'' register, ** '''DX'''<sup>DW</sup> ('''DL''', '''DH''') - the ''data'' register, * Four additional 16-bit registers: *..."
wikitext
text/x-wiki
= NEC V30MZ registers =
* Four 16-bit general-purpose registers, with their (low, high) components accessible as individual 8-bit sub-registers:
** '''AX'''<sup>AW</sup> ('''AL''', '''AH''') - the ''accumulator'' register,
** '''BX'''<sup>BW</sup> ('''BL''', '''BH''') - the ''base'' register,
** '''CX'''<sup>CW</sup> ('''CL''', '''CH''') - the ''count'' register,
** '''DX'''<sup>DW</sup> ('''DL''', '''DH''') - the ''data'' register,
* Four additional 16-bit registers:
** '''SI'''<sup>IX</sup> - the ''source index'' register,
** '''DI'''<sup>IY</sup> - the ''destination index'' register,
** '''SP''' - the ''stack pointer''; the stack is always addressed in the stack segment (so as <code>SS:SP</code> far addresses),
** '''BP''' - the ''base pointer''.
* Four segment registers:
** '''CS'''<sup>PS</sup> - the ''code segment'',
** '''DS'''<sup>DS0</sup> - the ''data segment'',
** '''ES'''<sup>DS1</sup> - the ''extra segment''; an additional data segment,
** '''SS''' - the ''stack segment''.
* '''IP'''<sup>PC</sup> - the ''instruction pointer''; instructions are always addressed in the code segment (so as <code>CS:IP</code> far addresses),
* '''FLAGS'''<sup>PSW</sup> - the 16-bit processor flag register.
While the eight registers can be used in a general-purpose manner, some opcodes are constrained to only using certain registers:
* '''AX''' benefits from more compact encoding for certain instructions; it's also used as an output and input register in multiplication/division, port access, BCD conversions, and (as AL) in the XCHG opcode.
* '''CX''' is used for loop and repeat instructions as a counter.
* '''DX''' can be used used as the address register for port access, it is also used as an output register for word multiplication/division.
* '''BX''', '''SI''', and '''DI''' can be used as indices for accessing data in tables in the DS segment (or other segments when overridden).
** '''SI''' and '''DI''' are, in addition, used as source and destination pointers by string instructions.
* Similarly, '''BP''' can be used as an index for accessing stack data; this makes it particularly useful as a frame pointer.
2ce279edfcfeb2b4a666622327d29533cff68a23
344
343
2024-08-05T09:36:35Z
Asie
351
/* NEC V30MZ registers */
wikitext
text/x-wiki
* Four 16-bit general-purpose registers, with their (low, high) components accessible as individual 8-bit sub-registers:
** '''AX'''<sup>AW</sup> ('''AL''', '''AH''') - the ''accumulator'' register,
** '''BX'''<sup>BW</sup> ('''BL''', '''BH''') - the ''base'' register,
** '''CX'''<sup>CW</sup> ('''CL''', '''CH''') - the ''count'' register,
** '''DX'''<sup>DW</sup> ('''DL''', '''DH''') - the ''data'' register,
* Four additional 16-bit registers:
** '''SI'''<sup>IX</sup> - the ''source index'' register,
** '''DI'''<sup>IY</sup> - the ''destination index'' register,
** '''SP''' - the ''stack pointer''; the stack is always addressed in the stack segment (so as <code>SS:SP</code> far addresses),
** '''BP''' - the ''base pointer''.
* Four segment registers:
** '''CS'''<sup>PS</sup> - the ''code segment'',
** '''DS'''<sup>DS0</sup> - the ''data segment'',
** '''ES'''<sup>DS1</sup> - the ''extra segment''; an additional data segment,
** '''SS''' - the ''stack segment''.
* '''IP'''<sup>PC</sup> - the ''instruction pointer''; instructions are always addressed in the code segment (so as <code>CS:IP</code> far addresses),
* '''FLAGS'''<sup>PSW</sup> - the 16-bit processor flag register.
While the eight registers can be used in a general-purpose manner, some opcodes are constrained to only using certain registers:
* '''AX''' benefits from more compact encoding for certain instructions; it's also used as an output and input register in multiplication/division, port access, BCD conversions, and (as AL) in the XCHG opcode.
* '''CX''' is used for loop and repeat instructions as a counter.
* '''DX''' can be used used as the address register for port access, it is also used as an output register for word multiplication/division.
* '''BX''', '''SI''', and '''DI''' can be used as indices for accessing data in tables in the DS segment (or other segments when overridden).
** '''SI''' and '''DI''' are, in addition, used as source and destination pointers by string instructions.
* Similarly, '''BP''' can be used as an index for accessing stack data; this makes it particularly useful as a frame pointer.
d23b0a14c3dd2100a4a9a09988e9f83ec4098858
NEC V30MZ interrupts
0
58
346
2024-08-15T07:57:45Z
Asie
351
Created page with "The NEC V30MZ provides six of the eight interrupts provided by the 80186. == Interrupts == === INT 0 - Divide Error === This interrupt is emitted as the result of a DIV<sup>IDIV</sup> or DIVU<sup>DIV</sup> instruction. === INT 1 - Single Step/Break === This interrupt is emitted if the single step flag is set after executing an instruction. (The instruction which changed the single step flag is ignored.) The single step flag is cleared for the duration of the interru..."
wikitext
text/x-wiki
The NEC V30MZ provides six of the eight interrupts provided by the 80186.
== Interrupts ==
=== INT 0 - Divide Error ===
This interrupt is emitted as the result of a DIV<sup>IDIV</sup> or DIVU<sup>DIV</sup> instruction.
=== INT 1 - Single Step/Break ===
This interrupt is emitted if the single step flag is set after executing an instruction. (The instruction which changed the single step flag is ignored.) The single step flag is cleared for the duration of the interrupt, allowing the user to store state and perform debug activities; it is then restored when returning from the interrupt, by restoring the original processor flags stored on the stack.
=== INT 2 - Non-Maskable interrupt (NMI) ===
This interrupt is emitted when the SoC requests a non-maskable interrupt. On the WonderSwan, the condtions for emitting an NMI are configured by the relevant I/O port.
=== INT 3 - Breakpoint ===
This interrupt is emitted by the INT 3<sup>BRK</sup> instruction. Unlike other unconditional interrupt instructions, it is encoded with only one byte.
=== INT 4 - Overflow ===
This interrupt is emitted by the INTO<sup>BRKV</sup> instruction, if the overflow flag is set while it is being executed.
=== INT 5 - Array Bounds ===
This interrupt is emitted only by the BOUND<sup>CHKIND</sup> instruction.
== Timing ==
TODO
== Notes ==
* The following 80186 interrupts are not implemented:
** INT 6 - Unused Opcode - the V30MZ treats most unimplemented instructions as NOPs.
** INT 7 - ESC Opcode - the V30MZ, likewise, treats these instructions as NOPs.
49f83ef1fa03973b988cf3d8ee6fc36dd4a1a957
I/O port map
0
8
347
268
2024-08-15T08:01:11Z
Asie
351
/* I/O port map */ fix $00 bit order
wikitext
text/x-wiki
The WonderSwan SoC has three general blocks of I/O port accesses:
{| class="wikitable"
! From !! To !! Holder !! Width !! Speed
|-
| $00 || $B7 || WonderSwan SoC || 16-bit || 1 cycle
|-
| $B8 || $BF || Internal EEPROM control || 16-bit || 1 cycle
|-
| $C0 || $FF || Cartridge bus || 8-bit || 1<sup>(color)</sup>/2 cycles (configurable)
|}
With the exception of internal EEPROM on the ASWAN, all unaligned 16-bit accesses can be converted to two 8-bit accesses with a 1-cycle penalty.
== I/O port map ==
* Superscripts are used to mark ports specific to a given mode or platform:
** Color mode: <sup>(color)</sup>. Such ports are only accessible when color mode is enabled through port <code>$60</code>.
** WS/WSC/SC console: <sup>(WS)</sup>, <sup>(WSC)</sup>, <sup>(SC)</sup>.
* If two Bits rows are provided, the second one refers to the "Color" mode.
* The Type can be: R - readable, W - writable, L - writable before boot ROM lockout, 8/16 - width (byte/word).
{| class="wikitable"
! Category
! Port
! Description
! Bits
! Type
! Notes
|-
! rowspan="45" | [[Display]]
! $00
| [[Display#Display Control|Display Control]]
| style="text-align: right" | <tt style="white-space: nowrap">..wo Ws21</tt>
| RW8
|
|-
! $01
| [[Display#Display Background|Display Background]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .sss</tt>
<tt style="white-space: nowrap">pppp iiii</tt>
| RW8
| Shade (s)
Palette (p), Index (i)
|-
! $02
| [[Display#Current Line|Display Current Line]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll</tt>
| R8
| Line (l)
|-
! $03
| [[Display#Interrupt Line|Display Interrupt Line]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll</tt>
| RW8
| Line (l)
|-
! $04
| [[Display#Sprite Table Address|Sprite Table Address]]
| style="text-align: right" | <tt style="white-space: nowrap">...a aaaa</tt>
<tt style="white-space: nowrap">..aa aaaa</tt>
| RW8
| Address >> 9 (a)
|-
! $05
| [[Display#Sprite Table First|Sprite Table First]]
| style="text-align: right" | <tt style="white-space: nowrap">.iii iiii</tt>
| RW8
| Index (i)
|-
! $06
| [[Display#Sprite Table Count|Sprite Table Count]]
| style="text-align: right" | <tt style="white-space: nowrap">cccc cccc</tt>
| RW8
| Count (c)
|-
! $07
| [[Display#Screen Address|Screen Address]]
| style="text-align: right" | <tt style="white-space: nowrap">.222 .111</tt>
<tt style="white-space: nowrap">2222 1111</tt>
| RW8
| Screen 1 address >> 11 (1)
Screen 2 address >> 11 (2)
|-
! $08
| [[Display#Screen 2 Window|Screen 2 Window Left]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $09
| [[Display#Screen 2 Window|Screen 2 Window Top]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $0A
| [[Display#Screen 2 Window|Screen 2 Window Right]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $0B
| [[Display#Screen 2 Window|Screen 2 Window Bottom]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $0B
| [[Display#Sprite Window|Sprite Window Left]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $0C
| [[Display#Sprite Window|Sprite Window Top]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $0E
| [[Display#Sprite Window|Sprite Window Right]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $0F
| [[Display#Sprite Window|Sprite Window Bottom]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $10
| [[Display#Screen Scroll|Screen 1 Scroll X]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $11
| [[Display#Screen Scroll|Screen 1 Scroll Y]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $12
| [[Display#Screen Scroll|Screen 2 Scroll X]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $13
| [[Display#Screen Scroll|Screen 2 Scroll Y]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $14
| [[Display#LCD Control|LCD Control]]
| style="text-align: right" | <tt style="white-space: nowrap">.... ..Ce</tt>
| RW8
| Contrast (C)<sup>(WSC)</sup>, Enable (e)
|-
! $15
| [[Display#LCD Icon Control|LCD Icon Control]]
| style="text-align: right" | <tt style="white-space: nowrap">..32 1hvs</tt>
| RW8
| Auxillary 3 (3), Auxillary 2 (2), Auxillary 1 (1),
Horizontal (h), Vertical (v), Sleep (s)
|-
! $16
| [[Display#LCD Final Line|LCD Final Line]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll</tt>
| RW8
| Line (l)
|-
! $17
| [[Display#LCD Back Porch Line|LCD Back Porch Line]]<sup>(WSC)</sup>
| style="text-align: right" | <tt style="white-space: nowrap">llll llll</tt>
| RW8
| Line (l)
|-
! $1A
| [[Display#LCD Status|LCD Status]]
| style="text-align: right" | <tt style="white-space: nowrap">...v vv.s</tt>
| RW8
| Volume segment status (v), Sleep (s)
|-
! $1C
| [[Display#LCD Mono Shade LUT|LCD Mono Shade LUT 0/1]]
| style="text-align: right" | <tt style="white-space: nowrap">1111 0000</tt>
| RW8
| Shade index
|-
! $1D
| [[Display#LCD Mono Shade LUT|LCD Mono Shade LUT 2/3]]
| style="text-align: right" | <tt style="white-space: nowrap">3333 2222</tt>
| RW8
| Shade index
|-
! $1E
| [[Display#LCD Mono Shade LUT|LCD Mono Shade LUT 4/5]]
| style="text-align: right" | <tt style="white-space: nowrap">5555 4444</tt>
| RW8
| Shade index
|-
! $1F
| [[Display#LCD Mono Shade LUT|LCD Mono Shade LUT 6/7]]
| style="text-align: right" | <tt style="white-space: nowrap">7777 6666</tt>
| RW8
| Shade index
|-
! $20
| [[Display#LCD Mono Palette|LCD Mono Palette 0]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $22
| [[Display#LCD Mono Palette|LCD Mono Palette 1]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $24
| [[Display#LCD Mono Palette|LCD Mono Palette 2]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $26
| [[Display#LCD Mono Palette|LCD Mono Palette 3]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $28
| [[Display#LCD Mono Palette|LCD Mono Palette 4]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $2A
| [[Display#LCD Mono Palette|LCD Mono Palette 5]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $2C
| [[Display#LCD Mono Palette|LCD Mono Palette 6]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $2E
| [[Display#LCD Mono Palette|LCD Mono Palette 7]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $30
| [[Display#LCD Mono Palette|LCD Mono Palette 8]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $32
| [[Display#LCD Mono Palette|LCD Mono Palette 9]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $34
| [[Display#LCD Mono Palette|LCD Mono Palette 10]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $36
| [[Display#LCD Mono Palette|LCD Mono Palette 11]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $38
| [[Display#LCD Mono Palette|LCD Mono Palette 12]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $3A
| [[Display#LCD Mono Palette|LCD Mono Palette 13]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $3C
| [[Display#LCD Mono Palette|LCD Mono Palette 14]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $3E
| [[Display#LCD Mono Palette|LCD Mono Palette 15]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! rowspan="10" | [[DMA]]<sup>(color)</sup>
! $40
| [[DMA#General DMA|GDMA Source Address Low]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll llll lll.</tt>
| RW16
| Linear address, low 16 bits (l)
|-
! $42
| [[DMA#General DMA|GDMA Source Address High]]
| style="text-align: right" | <tt style="white-space: nowrap">.... hhhh</tt>
| RW8
| Linear address, high 4 bits (h)
|-
! $44
| [[DMA#General DMA|GDMA Destination Address]]
| style="text-align: right" | <tt style="white-space: nowrap">aaaa aaaa aaaa aaa.</tt>
| RW16
| IRAM address (a)
|-
! $46
| [[DMA#General DMA|GDMA Length]]
| style="text-align: right" | <tt style="white-space: nowrap">bbbb bbbb bbbb bbb.</tt>
| RW16
| Bytes (b)
|-
! $48
| [[DMA#General DMA|GDMA Control]]
| style="text-align: right" | <tt style="white-space: nowrap">ed.. ....</tt>
| RW8
| Enable (e), Decrement (d)
|-
! $4A
| [[DMA#Sound DMA|SDMA Source Address Low]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll llll llll</tt>
| RW16
| Linear address, low 16 bits (l)
|-
! $4C
| [[DMA#Sound DMA|SDMA Source Address High]]
| style="text-align: right" | <tt style="white-space: nowrap">.... hhhh</tt>
| RW8
| Linear address, high 4 bits (h)
|-
! $4E
| [[DMA#Sound DMA|SDMA Length Low]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll llll llll</tt>
| RW16
| Length, low 16 bits (l)
|-
! $50
| [[DMA#Sound DMA|SDMA Length High]]
| style="text-align: right" | <tt style="white-space: nowrap">.... hhhh</tt>
| RW8
| Length, high 4 bits (h)
|-
! $52
| [[DMA#Sound DMA|SDMA Control]]
| style="text-align: right" | <tt style="white-space: nowrap">ed.t rhff</tt>
| RW8
| Enable (e), Decrement (d), Target (t),
Repeat (r), Hold (h), Frequency (f)
|-
! rowspan="2" | [[SoC]]<sup>(color)</sup>
! $60
| [[SoC#System Control 2|System Control 2]]
| style="text-align: right" | <tt style="white-space: nowrap">c4C. i?sl</tt>
| RW8
| Color (c), 4BPP (4), Chunky (C),<br/>
Cart I/O wait state (i), SRAM wait state (s),<br/>
Cart clock speed (l).
|-
! $62
| [[SoC#System Control 3|System Control 3]]
| style="text-align: right" | <tt style="white-space: nowrap">S... ...p</tt>
| RW8
| SwanCrystal (S), Power off (p)
|-
! rowspan="4" | [[Hyper Voice]]<sup>(color)</sup>
! $64
| [[Hyper Voice#Hyper Voice Output|Hyper Voice Left Output]]
| style="text-align: right" | <tt style="white-space: nowrap">ssss ssss ssss ssss</tt>
| W16
| Raw sample (s)
|-
! $66
| [[Hyper Voice#Hyper Voice Output|Hyper Voice Right Output]]
| style="text-align: right" | <tt style="white-space: nowrap">ssss ssss ssss ssss</tt>
| W16
| Raw sample (s)
|-
! $69
| [[Hyper Voice#Hyper Voice Input|Hyper Voice Right Input]]
| style="text-align: right" | <tt style="white-space: nowrap">ssss ssss</tt>
| W8
| Sample (s)
|-
! $6A
| [[Hyper Voice#Hyper Voice Control|Hyper Voice Control]]
| style="text-align: right" | <tt style="white-space: nowrap">.mmc ???? errr ffss</tt>
| RW16
| Mask (m), Channel reset (c), Enable (e),
Rate (r), Format (f), Shift (s)
|-
! rowspan="8" | [[Display]]<sup>(SC)</sup>
! $70
| LCD Timing Configuration 1?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $71
| LCD Timing Configuration 2?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $72
| LCD Timing Configuration 3?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $73
| LCD Timing Configuration 4?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $74
| LCD Timing Configuration 5?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $75
| LCD Timing Configuration 6?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $76
| LCD Timing Configuration 7?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $77
| LCD Timing Configuration 8?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! rowspan="22" | [[Sound]]
! $80
| [[Sound#Sound Channel Frequency|Sound Channel 1 Frequency]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .ddd dddd dddd</tt>
| RW16
| Divider (d)
|-
! $82
| [[Sound#Sound Channel Frequency|Sound Channel 2 Frequency]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .ddd dddd dddd</tt>
| RW16
| Divider (d)
|-
! $84
| [[Sound#Sound Channel Frequency|Sound Channel 3 Frequency]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .ddd dddd dddd</tt>
| RW16
| Divider (d)
|-
! $86
| [[Sound#Sound Channel Frequency|Sound Channel 4 Frequency]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .ddd dddd dddd</tt>
| RW16
| Divider (d)
|-
! $88
| [[Sound#Sound Channel Volume|Sound Channel 1 Volume]]
| style="text-align: right" | <tt style="white-space: nowrap">llll rrrr</tt>
| RW8
| Left (l), Right (r)
|-
! rowspan="2" | $89
| [[Sound#Sound Channel Volume|Sound Channel 2 Volume]]
| style="text-align: right" | <tt style="white-space: nowrap">llll rrrr</tt>
| RW8
| Left (l), Right (r)
|-
| [[Sound#Sound Channel 2 Voice Sample|Sound Channel 2 Voice Sample]]
| style="text-align: right" | <tt style="white-space: nowrap">ssss ssss</tt>
| RW8
| Sample (s)
|-
! $8A
| [[Sound#Sound Channel Volume|Sound Channel 3 Volume]]
| style="text-align: right" | <tt style="white-space: nowrap">llll rrrr</tt>
| RW8
| Left (l), Right (r)
|-
! $8B
| [[Sound#Sound Channel Volume|Sound Channel 4 Volume]]
| style="text-align: right" | <tt style="white-space: nowrap">llll rrrr</tt>
| RW8
| Left (l), Right (r)
|-
! $8C
| [[Sound#Sound Channel 3 Sweep Amount|Sound Channel 3 Sweep Amount]]
| style="text-align: right" | <tt style="white-space: nowrap">vvvv vvvv</tt>
| RW8
| Value (v)
|-
! $8D
| [[Sound#Sound Channel 3 Sweep Ticks|Sound Channel 3 Sweep Ticks]]
| style="text-align: right" | <tt style="white-space: nowrap">...t tttt</tt>
| RW8
| Ticks (t)
|-
! $8E
| [[Sound#Sound Channel 4 Noise Control|Sound Channel 4 Noise Control]]
| style="text-align: right" | <tt style="white-space: nowrap">...e rttt</tt>
| RW8
| Enable (e), Reset (r), Tap (t)
|-
! $8F
| [[Sound#Sound Wavetable Address|Sound Wavetable Address]]
| style="text-align: right" | <tt style="white-space: nowrap">wwww wwww</tt>
| RW8
| Address >> 6 (w)
|-
! $90
| [[Sound#Sound Channel Control|Sound Channel Control]]
| style="text-align: right" | <tt style="white-space: nowrap">nsv. 4321</tt>
| RW8
| Channel enable (1234)
Noise (n), Sweep (s), Voice (v)
|-
! $91
| [[Sound#Sound Output Control|Sound Output Control]]
| style="text-align: right" | <tt style="white-space: nowrap">H... hrrs</tt>
| RW8
| Headphones connected (H)
Headphone output (h)
Speaker output (s), range (r)
|-
! $92
| [[Sound#Sound Channel 4 LFSR Register|Sound Channel 4 LFSR Register]]
| style="text-align: right" | <tt style="white-space: nowrap">.rrr rrrr rrrr rrrr</tt>
| R16
| PRNG state (r)
|-
! $94
| [[Sound#Sound Channel 2 Voice Volume|Sound Channel 2 Voice Volume]]
| style="text-align: right" | <tt style="white-space: nowrap">.... lLrR</tt>
| RW8
| Left Half (l), Full (L)
Right Half (r), Full (R)
|-
! $95
| [[Sound#Sound Test|Sound Test]]
| style="text-align: right" | <tt style="white-space: nowrap">425? ???h</tt>
| RW8
|
|-
! $96
| Sound Channel Output Right
| style="text-align: right" | <tt style="white-space: nowrap">.... ..ss ssss ssss</tt>
| R16
| Sample (s)
|-
! $98
| Sound Channel Output Left
| style="text-align: right" | <tt style="white-space: nowrap">.... ..ss ssss ssss</tt>
| R16
| Sample (s)
|-
! $9A
| Sound Channel Output Sum
| style="text-align: right" | <tt style="white-space: nowrap">.... .sss ssss ssss</tt>
| R16
| Sample (s)
|-
! $9E
| Sound Speaker Main Volume<sup>(color)</sup>
| style="text-align: right" | <tt style="white-space: nowrap">.... ..vv</tt>
| RW8
| Main volume (v)
|-
! [[SoC]]
! $A0
| [[SoC#System Control|System Control]]
| style="text-align: right" | <tt style="white-space: nowrap">t??? swcl</tt>
| RW8
| Test OK (t), ROM wait state (s), ROM width (w),
Color system (c), Boot ROM lockout (l)
|-
! rowspan="5" | [[Timers]]
! $A2
| [[Timers#Timer Control|Timer Control]]
| style="text-align: right" | <tt style="white-space: nowrap">.... VvHh</tt>
| RW8
| Horizontal enable (h), auto reload (H)
Vertical enable (v), auto reload (V)
|-
! $A4
| [[Timers#Timer Reload|Horizontal Blank Timer Reload]]
| style="text-align: right" | <tt style="white-space: nowrap">tttt tttt tttt tttt</tt>
| RW16
| Ticks (t)
|-
! $A6
| [[Timers#Timer Reload|Vertical Blank Timer Reload]]
| style="text-align: right" | <tt style="white-space: nowrap">tttt tttt tttt tttt</tt>
| RW16
| Ticks (t)
|-
! $A8
| [[Timers#Timer Counter|Horizontal Blank Timer Counter]]
| style="text-align: right" | <tt style="white-space: nowrap">tttt tttt tttt tttt</tt>
| R16
| Ticks (t)
|-
! $AA
| [[Timers#Timer Counter|Vertical Blank Timer Counter]]
| style="text-align: right" | <tt style="white-space: nowrap">tttt tttt tttt tttt</tt>
| R16
| Ticks (t)
|-
! ?
! $AC
| ?
| style="text-align: right" | <tt style="white-space: nowrap">.... ...p</tt>
| W8?
| Power off (p)
|-
! rowspan="2" | [[Interrupts]]
! rowspan="2" | $B0
| [[Interrupts#Interrupt Vector Offset|Interrupt Vector Offset]]
| style="text-align: right" | <tt style="white-space: nowrap">VVVV V...</tt>
| W8
| Vector offset (V)
|-
| [[Interrupts#Interrupt Vector Request|Interrupt Vector Request]]
| style="text-align: right" | <tt style="white-space: nowrap">vvvv vvvv</tt>
| R8
| Requested vector offset (v)
|-
! rowspan="2" | [[UART]]
! $B1
| [[UART#Serial Receive Data|Serial Receive Data]]
| style="text-align: right" | <tt style="white-space: nowrap">dddd dddd</tt>
| R8
| Receive buffer data (d)
|-
! $B1
| [[UART#Serial Transmit Data|Serial Transmit Data]]
| style="text-align: right" | <tt style="white-space: nowrap">dddd dddd</tt>
| W8
| Transmit buffer data (d)
|-
! [[Interrupts]]
! $B2
| [[Interrupts#Interrupt Enable|Interrupt Enable]]
| style="text-align: right" | <tt style="white-space: nowrap">iiii iiii</tt>
| RW8
| Interrupt index (i)
|-
! rowspan="2" | [[UART]]
! $B3
| [[UART#Serial Status|Serial Status]]
| style="text-align: right" | <tt style="white-space: nowrap">eb.. .tor</tt>
| R8
| Enable (e), Baud rate (b),
Transfer ready (t), Overrun (o), Receive ready (r)
|-
! $B3
| [[UART#Serial Control|Serial Control]]
| style="text-align: right" | <tt style="white-space: nowrap">ebO. ....</tt>
| W8
| Enable (e), Baud rate (b), Reset Overrun (O)
|-
! [[Interrupts]]
! $B4
| [[Interrupts#Interrupt Status|Interrupt Status]]
| style="text-align: right" | <tt style="white-space: nowrap">iiii iiii</tt>
| R8
| Interrupt index (i)
|-
! [[Keypad]]
! $B5
| [[Keypad|Keypad Scan]]
| style="text-align: right" | <tt style="white-space: nowrap">.iii oooo</tt>
| RW8
| Input row (i), Output column (o)
|-
! rowspan="2" | [[Interrupts]]
! $B6
| [[Interrupts#Interrupt Acknowledge|Interrupt Acknowledge]]
| style="text-align: right" | <tt style="white-space: nowrap">iiii iiii</tt>
| W8
| Interrupt index (i)
|-
! $B7
| [[Interrupts#Interrupt NMI Control|Interrupt NMI Control]]
| style="text-align: right" | <tt style="white-space: nowrap">...b ....</tt>
| RW8
| Low battery (b)
|-
! rowspan="4" | [[EEPROM|Internal EEPROM]]
! $BA
| [[EEPROM#Internal EEPROM Data|Internal EEPROM Data]]
| style="text-align: right" | <tt style="white-space: nowrap">dddd dddd dddd dddd</tt>
| RW16
| Data (d)
|-
! $BC
| [[EEPROM#Internal EEPROM Command|Internal EEPROM Command]]
|
| RW16
|
|-
! rowspan="2" | $BE
| [[EEPROM#Internal EEPROM Status|Internal EEPROM Status]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .... p... ..RD</tt>
| R16
| Protected (p), Ready (R), Done (D)
|-
| [[EEPROM#Internal EEPROM Control|Internal EEPROM Control]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .... pewr ....</tt>
| W16
| Protect (p), Erase (e), Write (w), Read (r)
|-
! [[Mapper|Cartridge]]
! $C0<br />...<br />
$FF
| Cartridge I/O
|
| RW8
| Forwarded by the SoC
|}
== I/O port routing ==
The [[NEC V30MZ]] supports 16-bit I/O port addresses. The WonderSwan SoC routes them using the following algorithm:
* If an address is between <code>$00B8</code> and <code>$00BF</code> inclusive, it is routed to the internal EEPROM control block.
* If an address is between <code>$00C0</code> and <code>$00FF</code> inclusive, it is routed to the cartride bus.
* If an address's bits <code>0</code> through <code>8</code> inclusive are between <code>$000</code> and <code>$0B7</code> inclusive, they are routed to the SoC block.
* If none of these conditions are reached, open bus is read.
On the monochrome models, as well as color models in mono emulation, open bus is always <code>0x90</code>.
1af50f35debc3be260a61519a0ac04f1c13df7af
Interrupts
0
22
351
247
2024-08-22T13:10:01Z
Asie
351
/* Interrupts */
wikitext
text/x-wiki
== Interrupts ==
The WonderSwan features fourteen different interrupts:
* CPU interrupts - six provided by the V30MZ CPU ($00-$05),
* Hardware interrupts - eight provided by the SoC's hardware ($00-$07, or $08-$0F, or $10-$1F, or ... $F8-$FF - controlled by an offset <code>V</code>):
** Level - will be constantly requested while enabled and the prerequisite condition is true,
** Edge - will only be requested while enabled the moment the prerequisite condition ''becomes'' true.
Level interrupts will be immediately retriggered upon acknowledging unless they are disabled, or their prerequisite condition is cleared (for example, a byte is read from the UART). Edge interrupts are only triggered the moment they happen; acknowledging them is sufficient until the next time one is issued (for example, until the next vertical blank).
The user can additionally make use of all 256 available interrupt vectors in their own code.
{| class="wikitable"
|+ List of WonderSwan interrupts
! Source
! Type
! Index
! Description
|-
! rowspan="6" | CPU
| rowspan="6" | N/A
| $00
| DIV or IDIV instruction divide error<br/>
(division by zero or result overflow)
|-
| $01
| Single-step (T flag)
|-
| $02
| NMI (non-maskable interrupt)
|-
| $03
| INT 3 opcode
|-
| $04
| INTO opcode (if V = 1)
|-
| $05
| BOUND opcode (if index out of bounds)
|-
! rowspan="8" | Hardware
| Level
| V + 0
| [[UART|UART Send Ready]]
|-
| Edge
| V + 1
| [[Keypad|Key Pressed]]
|-
| rowspan="2" | Level
| V + 2
| [[Cartridge|Cartridge IRQ]]
|-
| V + 3
| [[UART|UART Receive Ready]]
|-
| rowspan="4" | Edge
| V + 4
| [[Display|Display Interrupt Line Match]]
|-
| V + 5
| [[Timers|Vertical Blank Timer]]
|-
| V + 6
| [[Display|Display Vertical Blank]]
|-
| V + 7
| [[Timers|Horizontal Blank Timer]]
|}
== I/O ports ==
{{Anchor|Interrupt Vector Offset}}
=== Interrupt Vector Offset ($B0 write) ===
<pre>
7 bit 0
---- ----
VVVV V...
|||| |
++++-+---- Interrupt vector offset
</pre>
{{Anchor|Interrupt Vector Request}}
=== Interrupt Vector Request ($B0 read) ===
<pre>
7 bit 0
---- ----
vvvv vvvv
|||| ||||
++++-++++- Interrupt vector requested
from the CPU.
</pre>
* Bits <code>7 .. 3</code> of this will always equal the user-provided vector offset.
* Bits <code>2 .. 0</code> of this will always equal the highest set bit index of Interrupt Status; if all bits in Interrupt Status are clear, they will equal <code>0</code>.
{{Anchor|Interrupt Enable}}
=== Interrupt Enable ($B2) ===
<pre>
7 bit 0
---- ----
iiii iiii
|||| ||||
++++-++++- Hardware interrupt to enable
(acts as a mask)
</pre>
{{Anchor|Interrupt Status}}
=== Interrupt Status ($B4 read)===
<pre>
7 bit 0
---- ----
iiii iiii
|||| ||||
++++-++++- 1 if interrupt requested
</pre>
{{Anchor|Interrupt Acknowledge}}
=== Interrupt Acknowledge ($B6 write)===
<pre>
7 bit 0
---- ----
iiii iiii
|||| ||||
++++-++++- Write 1 to clear interrupt request
</pre>
{{Anchor|Interrupt NMI Control}}
=== Interrupt NMI Control ($B7)===
<pre>
7 bit 0
---- ----
...b ....
|
+----- Enable NMI on low battery detection
</pre>
6c9ecc187c0ea6526f8280b58b1ca326baec455e
352
351
2024-08-22T13:11:03Z
Asie
351
/* Interrupt Enable ($B2) */
wikitext
text/x-wiki
== Interrupts ==
The WonderSwan features fourteen different interrupts:
* CPU interrupts - six provided by the V30MZ CPU ($00-$05),
* Hardware interrupts - eight provided by the SoC's hardware ($00-$07, or $08-$0F, or $10-$1F, or ... $F8-$FF - controlled by an offset <code>V</code>):
** Level - will be constantly requested while enabled and the prerequisite condition is true,
** Edge - will only be requested while enabled the moment the prerequisite condition ''becomes'' true.
Level interrupts will be immediately retriggered upon acknowledging unless they are disabled, or their prerequisite condition is cleared (for example, a byte is read from the UART). Edge interrupts are only triggered the moment they happen; acknowledging them is sufficient until the next time one is issued (for example, until the next vertical blank).
The user can additionally make use of all 256 available interrupt vectors in their own code.
{| class="wikitable"
|+ List of WonderSwan interrupts
! Source
! Type
! Index
! Description
|-
! rowspan="6" | CPU
| rowspan="6" | N/A
| $00
| DIV or IDIV instruction divide error<br/>
(division by zero or result overflow)
|-
| $01
| Single-step (T flag)
|-
| $02
| NMI (non-maskable interrupt)
|-
| $03
| INT 3 opcode
|-
| $04
| INTO opcode (if V = 1)
|-
| $05
| BOUND opcode (if index out of bounds)
|-
! rowspan="8" | Hardware
| Level
| V + 0
| [[UART|UART Send Ready]]
|-
| Edge
| V + 1
| [[Keypad|Key Pressed]]
|-
| rowspan="2" | Level
| V + 2
| [[Cartridge|Cartridge IRQ]]
|-
| V + 3
| [[UART|UART Receive Ready]]
|-
| rowspan="4" | Edge
| V + 4
| [[Display|Display Interrupt Line Match]]
|-
| V + 5
| [[Timers|Vertical Blank Timer]]
|-
| V + 6
| [[Display|Display Vertical Blank]]
|-
| V + 7
| [[Timers|Horizontal Blank Timer]]
|}
== I/O ports ==
{{Anchor|Interrupt Vector Offset}}
=== Interrupt Vector Offset ($B0 write) ===
<pre>
7 bit 0
---- ----
VVVV V...
|||| |
++++-+---- Interrupt vector offset
</pre>
{{Anchor|Interrupt Vector Request}}
=== Interrupt Vector Request ($B0 read) ===
<pre>
7 bit 0
---- ----
vvvv vvvv
|||| ||||
++++-++++- Interrupt vector requested
from the CPU.
</pre>
* Bits <code>7 .. 3</code> of this will always equal the user-provided vector offset.
* Bits <code>2 .. 0</code> of this will always equal the highest set bit index of Interrupt Status; if all bits in Interrupt Status are clear, they will equal <code>0</code>.
{{Anchor|Interrupt Enable}}
=== Interrupt Enable ($B2) ===
<pre>
7 bit 0
---- ----
iiii iiii
|||| ||||
++++-++++- Hardware interrupt to enable
(acts as a mask)
</pre>
Contrary to other systems, this also controls whether interrupts set the relevant bit in Interrupt Status.
{{Anchor|Interrupt Status}}
=== Interrupt Status ($B4 read)===
<pre>
7 bit 0
---- ----
iiii iiii
|||| ||||
++++-++++- 1 if interrupt requested
</pre>
{{Anchor|Interrupt Acknowledge}}
=== Interrupt Acknowledge ($B6 write)===
<pre>
7 bit 0
---- ----
iiii iiii
|||| ||||
++++-++++- Write 1 to clear interrupt request
</pre>
{{Anchor|Interrupt NMI Control}}
=== Interrupt NMI Control ($B7)===
<pre>
7 bit 0
---- ----
...b ....
|
+----- Enable NMI on low battery detection
</pre>
9adaf00049c8ce0ec2a7e506e67d871114dba16d
Sound
0
27
353
276
2024-08-25T10:26:46Z
Asie
351
/* Sound Channel 4 Noise Control ($8E) */
wikitext
text/x-wiki
The WonderSwan features the following sound hardware:
* Four audio channels:
** channel 1 - wavetable (32 x 4-bit samples),
** channel 2 - wavetable or 8-bit unsigned PCM sample,
** channel 3 - wavetable with optional hardware sweep,
** channel 4 - wavetable or LFSR noise,
* [[Hyper Voice]]<sup>(color)</sup> - headphone output exclusive 16-bit stereo PCM output,
* 24000 Hz output:
** internal speaker - 8-bit, mono,
** headphone output - 16-bit, stereo.
[[Hyper Voice]] functionality is documented on its own sub-page.
== Mixing diagram ==
The sound is mixed as follows:
<pre>
Ch1 Ch2 Ch3 Ch4 Glossary: L = left, R = right, M = mono
| | | | Mnn = nn-bit mono
8 8 8 8 port $98 port $nn = value port
| | | | /
_V___V___V___V_ / _____ _____
| |--L10------+----->| | | |
| + | | | + |--M11-->| >>r |--M8--> Speaker output
|_______________|--R10------|-+--->|_____| / |_____|
/ _|_|_ / (r=0...3)
/ | | / \
port $96 | <<5 | port $9A \
|_____| \
| | port $91
| |
port $68 port $64 | |
/ _______________ \ __V_V__ _____
L8-->| (Color only) |--L16-->| |----------L16-->| |
| Hyper Voice | | + + | | I2S |------> Headphone output
R8-->|_______________|--R16-->|_______|----------R16-->|_____|
\ /
port $69 port $66
</pre>
== I/O Ports ==
{{Anchor|Sound Channel Frequency}}
=== Sound Channel Frequency ($80, $81; $82, $83; $84, $85; $86, $87) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
.... .ddd dddd dddd
||| |||| ||||
+++--++++-++++- Frequency divisor
</pre>
This frequency is used for wavetable output. It is calculated as follows: <code>sample rate = 3072000 Hz / (2048 - divisor)</code>.
Note that this refers to the sample rate of the ''wavetable'', and needs to be scaled accordingly for a given waveform when performing music playback.
{{Anchor|Sound Channel Volume}}
=== Sound Channel Volume ($88; $89; $8A; $8B) ===
<pre>
7 bit 0
---------
llll rrrr
|||| ||||
|||| ++++- Right channel volume (0-15)
++++------ Left channel volume (0-15)
</pre>
This volume is used for wavetable output.
The calculation to get an unsigned 8-bit sample out of a 4-bit wavetable sample / 4-bit volume pair is simple: <code>out_sample = sample * volume</code>. This means that the maximum sample in wavetable output mode is <code>15 * 15 = 225</code>.
{{Anchor|Sound Channel 2 Voice Sample}}
=== Sound Channel 2 Voice Sample ($89) ===
<pre>
7 bit 0
---- ----
ssss ssss
|||| ||||
++++-++++- Unsigned 8-bit PCM sample (0-255)
</pre>
This sample is used for voice output.
{{Anchor|Sound Channel 3 Sweep Amount}}
=== Sound Channel 3 Sweep Amount ($8C) ===
<pre>
7 bit 0
---- ----
vvvv vvvv
|||| ||||
++++-++++- Value; 8-bit, signed.
</pre>
This port is used for wavetable output with sweep enabled.
The signed value in this port will be added to the frequency divider for channel 3 every sweep step (as determined by the Sweep Ticks port). Wraparound is present - adding 1 to a frequency divider value of 2047 will cause it to roll over back to 0.
{{Anchor|Sound Channel 3 Sweep Ticks}}
=== Sound Channel 3 Sweep Ticks ($8D) ===
<pre>
7 bit 0
---- ----
...t tttt
| ||||
+-++++- Ticks per step - 1
</pre>
This port is used for wavetable output with sweep enabled.
Every <code>ttttt + 1</code> ticks, clocked at 375 Hz, the value in the Sweep Amount port will be added to the frequency divider for channel 3.
{{Anchor|Sound Channel 4 Noise Control}}
=== Sound Channel 4 Noise Control ($8E) ===
<pre>
7 bit 0
---- ----
...e rttt
| ||||
| |+++- LFSR tap mode
| +---- LFSR reset: 1 = reset shift register
+------ LFSR enabled: 0 = off, 1 = on
</pre>
This port is used for noise output.
{| class="wikitable"
|+ List of LFSR tap modes
! Tap mode
! Tap bit
! Sequence length
|-
| 0
| 14
| 32767
|-
| 1
| 10
| 1953
|-
| 2
| 13
| 254
|-
| 3
| 4
| 217
|-
| 4
| 8
| 73
|-
| 5
| 6
| 63
|-
| 6
| 9
| 42
|-
| 7
| 11
| 28
|}
Noise output works using the following algorithm, performed once per sample generated:
# Create a new bit by inverting the XOR of bit 7 with the tap bit.
# Shift the LFSR register one bit to the left.
# Write the new bit as bit 0.
# Use the new bit as if it were a wavetable sample: 0 = 0, 1 = 15.
{{Anchor|Sound Wavetable Address}}
=== Sound Wavetable Address ($8F) ===
<pre>
7 bit 0
---- ----
wwww wwww
|||| ||||
++++-++++- Wavetable address (bits 6-13)
</pre>
The wavetable is 4 x 16 bytes long; each 16-byte block contains 32 4-bit samples for the relevant channel:
<pre>
Address $00 $01 $02 $03 $04 $05 $06 $07 $08 $09 $0A $0B $0C $0D $0E $0F
98 CB ED FF FF EF BD 8A 57 24 01 00 00 21 43 76
Sample
15 .. .. .. ## ## #. .. .. .. .. .. .. .. .. .. ..
14 .. .. .# || || |# .. .. .. .. .. .. .. .. .. ..
13 .. .. #| || || || #. .. .. .. .. .. .. .. .. ..
12 .. .# || || || || |. .. .. .. .. .. .. .. .. ..
11 .. #| || || || || |# .. .. .. .. .. .. .. .. ..
10 .. || || || || || || #. .. .. .. .. .. .. .. ..
9 .# || || || || || || |. .. .. .. .. .. .. .. ..
8 #| || || || || || || |# .. .. .. .. .. .. .. ..
7 || || || || || || || || #. .. .. .. .. .. .. .#
6 || || || || || || || || |. .. .. .. .. .. .. #|
5 || || || || || || || || |# .. .. .. .. .. .. ||
4 || || || || || || || || || #. .. .. .. .. .# ||
3 || || || || || || || || || |. .. .. .. .. #| ||
2 || || || || || || || || || |# .. .. .. .# || ||
1 || || || || || || || || || || #. .. .. #| || ||
0 || || || || || || || || || || |# ## ## || || ||
</pre>
Note that the ''higher'' bits - the first hexadecimal number - specify the ''later'' samples; that is to say, the nybbles of each sample are swapped relative to the wave drawing.
{{Anchor|Sound Channel Control}}
=== Sound Channel Control ($90) ===
<pre>
7 bit 0
---- ----
nsv. 4321
||| ||||
||| |||+- Channel 1 enable
||| ||+-- Channel 2 enable
||| |+--- Channel 3 enable
||| +---- Channel 4 enable
||+------- Channel 2 mode: 0 = wavetable, 1 = voice
|+-------- Channel 3 sweep: 0 = disable, 1 = enable
+--------- Channel 4 mode: 0 = wavetable, 1 = noise
</pre>
{{Anchor|Sound Output Control}}
=== Sound Output Control ($91) ===
<pre>
7 bit 0
---- ----
H... hrrs
| ||||
| |||+- Internal speaker output enable
| |++-- Internal speaker shift/volume:
| | 0 = 100% 1 = 50%
| | 2 = 25% 3 = 12.5%
| +---- Headphone output enable
+--------- Headphones connected, 1 if true
</pre>
For correct playback on the internal speaker, it is important to set the shift/volume correctly, to match the peak summed output of the first four channels. If the value is too low, music using multiple loud channels will wrap, causing audible distortion. If the value is too high, single-channel PCM sample playback will be very quiet.
{{Anchor|Sound Channel 4 LFSR Register}}
=== Sound Channel 4 LFSR Register ($92, $93 read) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
.rrr rrrr rrrr rrrr
||| |||| |||| ||||
+++-++++--++++-++++- Shift register value
</pre>
{{Anchor|Sound Channel 2 Voice Volume}}
=== Sound Channel 2 Voice Volume ($94) ===
<pre>
7 bit 0
---- ----
.... lLrR
||||
|||+- Right channel 100% volume
||+-- Right channel 50% volume
|+--- Left channel 100% volume
+---- Left channel 50% volume
</pre>
This port is used for voice output.
The <code>50% volume</code> have no effect if their respective <code>100% volume</code> bits are set.
{{Anchor|Sound Test}}
=== Sound Test ($95) ===
<pre>
7 bit 0
---- ----
425? llsh
||| ||||
||| |||+- Hold Ch1-4 output updates
||| ||+-- Use 3072000 Hz CPU clock for sweep
||| ++--- Hold noise LFSR output
||| (Differences between bit 2/3
||| behavior are unknown)
||+------- Force L10/R10 outputs to 0x55
|+-------- Force Ch1-4 outputs to 0x02
+--------- Force Ch1-4 outputs to 0x04
</pre>
{{Anchor|Sound Channel Output Right}}
=== Sound Channel Output Right ($96, $97 read) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
.... ..ss ssss ssss
|| |||| ||||
++--++++-++++- Unsigned 10-bit sample
</pre>
{{Anchor|Sound Channel Output Left}}
=== Sound Channel Output Left ($98, $99 read) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
.... ..ss ssss ssss
|| |||| ||||
++--++++-++++- Unsigned 10-bit sample
</pre>
{{Anchor|Sound Channel Output Sum}}
=== Sound Channel Output Sum ($9A, $9B read) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
.... .sss ssss ssss
||| |||| ||||
+++--++++-++++- Unsigned 11-bit sample
</pre>
74d00fdcd31ce56be4e7ee420cbd85b5637ed91b
356
353
2024-09-10T19:40:34Z
Asie
351
/* Sound Test ($95) */
wikitext
text/x-wiki
The WonderSwan features the following sound hardware:
* Four audio channels:
** channel 1 - wavetable (32 x 4-bit samples),
** channel 2 - wavetable or 8-bit unsigned PCM sample,
** channel 3 - wavetable with optional hardware sweep,
** channel 4 - wavetable or LFSR noise,
* [[Hyper Voice]]<sup>(color)</sup> - headphone output exclusive 16-bit stereo PCM output,
* 24000 Hz output:
** internal speaker - 8-bit, mono,
** headphone output - 16-bit, stereo.
[[Hyper Voice]] functionality is documented on its own sub-page.
== Mixing diagram ==
The sound is mixed as follows:
<pre>
Ch1 Ch2 Ch3 Ch4 Glossary: L = left, R = right, M = mono
| | | | Mnn = nn-bit mono
8 8 8 8 port $98 port $nn = value port
| | | | /
_V___V___V___V_ / _____ _____
| |--L10------+----->| | | |
| + | | | + |--M11-->| >>r |--M8--> Speaker output
|_______________|--R10------|-+--->|_____| / |_____|
/ _|_|_ / (r=0...3)
/ | | / \
port $96 | <<5 | port $9A \
|_____| \
| | port $91
| |
port $68 port $64 | |
/ _______________ \ __V_V__ _____
L8-->| (Color only) |--L16-->| |----------L16-->| |
| Hyper Voice | | + + | | I2S |------> Headphone output
R8-->|_______________|--R16-->|_______|----------R16-->|_____|
\ /
port $69 port $66
</pre>
== I/O Ports ==
{{Anchor|Sound Channel Frequency}}
=== Sound Channel Frequency ($80, $81; $82, $83; $84, $85; $86, $87) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
.... .ddd dddd dddd
||| |||| ||||
+++--++++-++++- Frequency divisor
</pre>
This frequency is used for wavetable output. It is calculated as follows: <code>sample rate = 3072000 Hz / (2048 - divisor)</code>.
Note that this refers to the sample rate of the ''wavetable'', and needs to be scaled accordingly for a given waveform when performing music playback.
{{Anchor|Sound Channel Volume}}
=== Sound Channel Volume ($88; $89; $8A; $8B) ===
<pre>
7 bit 0
---------
llll rrrr
|||| ||||
|||| ++++- Right channel volume (0-15)
++++------ Left channel volume (0-15)
</pre>
This volume is used for wavetable output.
The calculation to get an unsigned 8-bit sample out of a 4-bit wavetable sample / 4-bit volume pair is simple: <code>out_sample = sample * volume</code>. This means that the maximum sample in wavetable output mode is <code>15 * 15 = 225</code>.
{{Anchor|Sound Channel 2 Voice Sample}}
=== Sound Channel 2 Voice Sample ($89) ===
<pre>
7 bit 0
---- ----
ssss ssss
|||| ||||
++++-++++- Unsigned 8-bit PCM sample (0-255)
</pre>
This sample is used for voice output.
{{Anchor|Sound Channel 3 Sweep Amount}}
=== Sound Channel 3 Sweep Amount ($8C) ===
<pre>
7 bit 0
---- ----
vvvv vvvv
|||| ||||
++++-++++- Value; 8-bit, signed.
</pre>
This port is used for wavetable output with sweep enabled.
The signed value in this port will be added to the frequency divider for channel 3 every sweep step (as determined by the Sweep Ticks port). Wraparound is present - adding 1 to a frequency divider value of 2047 will cause it to roll over back to 0.
{{Anchor|Sound Channel 3 Sweep Ticks}}
=== Sound Channel 3 Sweep Ticks ($8D) ===
<pre>
7 bit 0
---- ----
...t tttt
| ||||
+-++++- Ticks per step - 1
</pre>
This port is used for wavetable output with sweep enabled.
Every <code>ttttt + 1</code> ticks, clocked at 375 Hz, the value in the Sweep Amount port will be added to the frequency divider for channel 3.
{{Anchor|Sound Channel 4 Noise Control}}
=== Sound Channel 4 Noise Control ($8E) ===
<pre>
7 bit 0
---- ----
...e rttt
| ||||
| |+++- LFSR tap mode
| +---- LFSR reset: 1 = reset shift register
+------ LFSR enabled: 0 = off, 1 = on
</pre>
This port is used for noise output.
{| class="wikitable"
|+ List of LFSR tap modes
! Tap mode
! Tap bit
! Sequence length
|-
| 0
| 14
| 32767
|-
| 1
| 10
| 1953
|-
| 2
| 13
| 254
|-
| 3
| 4
| 217
|-
| 4
| 8
| 73
|-
| 5
| 6
| 63
|-
| 6
| 9
| 42
|-
| 7
| 11
| 28
|}
Noise output works using the following algorithm, performed once per sample generated:
# Create a new bit by inverting the XOR of bit 7 with the tap bit.
# Shift the LFSR register one bit to the left.
# Write the new bit as bit 0.
# Use the new bit as if it were a wavetable sample: 0 = 0, 1 = 15.
{{Anchor|Sound Wavetable Address}}
=== Sound Wavetable Address ($8F) ===
<pre>
7 bit 0
---- ----
wwww wwww
|||| ||||
++++-++++- Wavetable address (bits 6-13)
</pre>
The wavetable is 4 x 16 bytes long; each 16-byte block contains 32 4-bit samples for the relevant channel:
<pre>
Address $00 $01 $02 $03 $04 $05 $06 $07 $08 $09 $0A $0B $0C $0D $0E $0F
98 CB ED FF FF EF BD 8A 57 24 01 00 00 21 43 76
Sample
15 .. .. .. ## ## #. .. .. .. .. .. .. .. .. .. ..
14 .. .. .# || || |# .. .. .. .. .. .. .. .. .. ..
13 .. .. #| || || || #. .. .. .. .. .. .. .. .. ..
12 .. .# || || || || |. .. .. .. .. .. .. .. .. ..
11 .. #| || || || || |# .. .. .. .. .. .. .. .. ..
10 .. || || || || || || #. .. .. .. .. .. .. .. ..
9 .# || || || || || || |. .. .. .. .. .. .. .. ..
8 #| || || || || || || |# .. .. .. .. .. .. .. ..
7 || || || || || || || || #. .. .. .. .. .. .. .#
6 || || || || || || || || |. .. .. .. .. .. .. #|
5 || || || || || || || || |# .. .. .. .. .. .. ||
4 || || || || || || || || || #. .. .. .. .. .# ||
3 || || || || || || || || || |. .. .. .. .. #| ||
2 || || || || || || || || || |# .. .. .. .# || ||
1 || || || || || || || || || || #. .. .. #| || ||
0 || || || || || || || || || || |# ## ## || || ||
</pre>
Note that the ''higher'' bits - the first hexadecimal number - specify the ''later'' samples; that is to say, the nybbles of each sample are swapped relative to the wave drawing.
{{Anchor|Sound Channel Control}}
=== Sound Channel Control ($90) ===
<pre>
7 bit 0
---- ----
nsv. 4321
||| ||||
||| |||+- Channel 1 enable
||| ||+-- Channel 2 enable
||| |+--- Channel 3 enable
||| +---- Channel 4 enable
||+------- Channel 2 mode: 0 = wavetable, 1 = voice
|+-------- Channel 3 sweep: 0 = disable, 1 = enable
+--------- Channel 4 mode: 0 = wavetable, 1 = noise
</pre>
{{Anchor|Sound Output Control}}
=== Sound Output Control ($91) ===
<pre>
7 bit 0
---- ----
H... hrrs
| ||||
| |||+- Internal speaker output enable
| |++-- Internal speaker shift/volume:
| | 0 = 100% 1 = 50%
| | 2 = 25% 3 = 12.5%
| +---- Headphone output enable
+--------- Headphones connected, 1 if true
</pre>
For correct playback on the internal speaker, it is important to set the shift/volume correctly, to match the peak summed output of the first four channels. If the value is too low, music using multiple loud channels will wrap, causing audible distortion. If the value is too high, single-channel PCM sample playback will be very quiet.
{{Anchor|Sound Channel 4 LFSR Register}}
=== Sound Channel 4 LFSR Register ($92, $93 read) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
.rrr rrrr rrrr rrrr
||| |||| |||| ||||
+++-++++--++++-++++- Shift register value
</pre>
{{Anchor|Sound Channel 2 Voice Volume}}
=== Sound Channel 2 Voice Volume ($94) ===
<pre>
7 bit 0
---- ----
.... lLrR
||||
|||+- Right channel 100% volume
||+-- Right channel 50% volume
|+--- Left channel 100% volume
+---- Left channel 50% volume
</pre>
This port is used for voice output.
The <code>50% volume</code> have no effect if their respective <code>100% volume</code> bits are set.
{{Anchor|Sound Test}}
=== Sound Test ($95) ===
<pre>
7 bit 0
---- ----
??5? llsh
| ||||
| |||+- Hold Ch1-4 output updates
| ||+-- Use 3072000 Hz CPU clock for sweep
| ++--- Hold noise LFSR output
| (Differences between bit 2/3
| behavior are unknown)
+------- Force L10/R10 outputs to (channel 2 voice output * 5) & 0x3FF
</pre>
{{Anchor|Sound Channel Output Right}}
=== Sound Channel Output Right ($96, $97 read) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
.... ..ss ssss ssss
|| |||| ||||
++--++++-++++- Unsigned 10-bit sample
</pre>
{{Anchor|Sound Channel Output Left}}
=== Sound Channel Output Left ($98, $99 read) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
.... ..ss ssss ssss
|| |||| ||||
++--++++-++++- Unsigned 10-bit sample
</pre>
{{Anchor|Sound Channel Output Sum}}
=== Sound Channel Output Sum ($9A, $9B read) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
.... .sss ssss ssss
||| |||| ||||
+++--++++-++++- Unsigned 11-bit sample
</pre>
e65e156f4821136007fb4f92db18c31e83024b30
357
356
2024-09-13T14:17:34Z
Asie
351
wikitext
text/x-wiki
The WonderSwan features the following sound hardware:
* Four audio channels:
** channel 1 - wavetable (32 x 4-bit samples),
** channel 2 - wavetable or 8-bit unsigned PCM sample,
** channel 3 - wavetable with optional hardware sweep,
** channel 4 - wavetable or LFSR noise,
* [[Hyper Voice]]<sup>(color)</sup> - headphone output exclusive 16-bit stereo PCM output,
* 24000 Hz output:
** internal speaker - 8-bit, mono,
** headphone output - 16-bit, stereo.
[[Hyper Voice]] functionality is documented on its own sub-page.
== Mixing diagram ==
The sound is mixed as follows:
<pre>
Ch1 Ch2 Ch3 Ch4 Glossary: L = left, R = right, M = mono
| | | | Mnn = nn-bit mono
8 8 8 8 port $98 port $nn = value port
| | | | /
_V___V___V___V_ / _____ _____
| |--L10------+----->| | | |
| + | | | + |--M11-->| >>r |--M8--> Speaker output
|_______________|--R10------|-+--->|_____| / |_____|
/ _|_|_ / (r=0...3)
/ | | / \
port $96 | <<5 | port $9A \
|_____| \
| | port $91
| |
port $68 port $64 | |
/ _______________ \ __V_V__ _____
L8-->| (Color only) |--L16-->| |----------L16-->| |
| Hyper Voice | | + + | | I2S |------> Headphone output
R8-->|_______________|--R16-->|_______|----------R16-->|_____|
\ /
port $69 port $66
</pre>
== I/O Ports ==
{{Anchor|Sound Channel Frequency}}
=== Sound Channel Frequency ($80, $81; $82, $83; $84, $85; $86, $87) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
.... .ddd dddd dddd
||| |||| ||||
+++--++++-++++- Frequency divisor
</pre>
This frequency is used for wavetable output. It is calculated as follows: <code>sample rate = 3072000 Hz / (2048 - divisor)</code>.
Note that this refers to the sample rate of the ''wavetable'', and needs to be scaled accordingly for a given waveform when performing music playback.
{{Anchor|Sound Channel Volume}}
=== Sound Channel Volume ($88; $89; $8A; $8B) ===
<pre>
7 bit 0
---------
llll rrrr
|||| ||||
|||| ++++- Right channel volume (0-15)
++++------ Left channel volume (0-15)
</pre>
This volume is used for wavetable output.
The calculation to get an unsigned 8-bit sample out of a 4-bit wavetable sample / 4-bit volume pair is simple: <code>out_sample = sample * volume</code>. This means that the maximum sample in wavetable output mode is <code>15 * 15 = 225</code>.
{{Anchor|Sound Channel 2 Voice Sample}}
=== Sound Channel 2 Voice Sample ($89) ===
<pre>
7 bit 0
---- ----
ssss ssss
|||| ||||
++++-++++- Unsigned 8-bit PCM sample (0-255)
</pre>
This sample is used for voice output.
{{Anchor|Sound Channel 3 Sweep Amount}}
=== Sound Channel 3 Sweep Amount ($8C) ===
<pre>
7 bit 0
---- ----
vvvv vvvv
|||| ||||
++++-++++- Value; 8-bit, signed.
</pre>
This port is used for wavetable output with sweep enabled.
The signed value in this port will be added to the frequency divider for channel 3 every sweep step (as determined by the Sweep Ticks port). Wraparound is present - adding 1 to a frequency divider value of 2047 will cause it to roll over back to 0.
{{Anchor|Sound Channel 3 Sweep Ticks}}
=== Sound Channel 3 Sweep Ticks ($8D) ===
<pre>
7 bit 0
---- ----
...t tttt
| ||||
+-++++- Ticks per step - 1
</pre>
This port is used for wavetable output with sweep enabled.
Every <code>ttttt + 1</code> ticks, clocked at 375 Hz, the value in the Sweep Amount port will be added to the frequency divider for channel 3.
{{Anchor|Sound Channel 4 Noise Control}}
=== Sound Channel 4 Noise Control ($8E) ===
<pre>
7 bit 0
---- ----
...e rttt
| ||||
| |+++- LFSR tap mode
| +---- LFSR reset: 1 = reset shift register
+------ LFSR enabled: 0 = off, 1 = on
</pre>
This port is used for noise output.
{| class="wikitable"
|+ List of LFSR tap modes
! Tap mode
! Tap bit
! Sequence length
|-
| 0
| 14
| 32767
|-
| 1
| 10
| 1953
|-
| 2
| 13
| 254
|-
| 3
| 4
| 217
|-
| 4
| 8
| 73
|-
| 5
| 6
| 63
|-
| 6
| 9
| 42
|-
| 7
| 11
| 28
|}
Noise output works using the following algorithm, performed once per sample generated:
# Create a new bit by inverting the XOR of bit 7 with the tap bit.
# Shift the LFSR register one bit to the left.
# Write the new bit as bit 0.
# Use the new bit as if it were a wavetable sample: 0 = 0, 1 = 15.
{{Anchor|Sound Wavetable Address}}
=== Sound Wavetable Address ($8F) ===
<pre>
7 bit 0
---- ----
wwww wwww
|||| ||||
++++-++++- Wavetable address (bits 6-13)
</pre>
The wavetable is 4 x 16 bytes long; each 16-byte block contains 32 4-bit samples for the relevant channel:
<pre>
Address $00 $01 $02 $03 $04 $05 $06 $07 $08 $09 $0A $0B $0C $0D $0E $0F
98 CB ED FF FF EF BD 8A 57 24 01 00 00 21 43 76
Sample
15 .. .. .. ## ## #. .. .. .. .. .. .. .. .. .. ..
14 .. .. .# || || |# .. .. .. .. .. .. .. .. .. ..
13 .. .. #| || || || #. .. .. .. .. .. .. .. .. ..
12 .. .# || || || || |. .. .. .. .. .. .. .. .. ..
11 .. #| || || || || |# .. .. .. .. .. .. .. .. ..
10 .. || || || || || || #. .. .. .. .. .. .. .. ..
9 .# || || || || || || |. .. .. .. .. .. .. .. ..
8 #| || || || || || || |# .. .. .. .. .. .. .. ..
7 || || || || || || || || #. .. .. .. .. .. .. .#
6 || || || || || || || || |. .. .. .. .. .. .. #|
5 || || || || || || || || |# .. .. .. .. .. .. ||
4 || || || || || || || || || #. .. .. .. .. .# ||
3 || || || || || || || || || |. .. .. .. .. #| ||
2 || || || || || || || || || |# .. .. .. .# || ||
1 || || || || || || || || || || #. .. .. #| || ||
0 || || || || || || || || || || |# ## ## || || ||
</pre>
Note that the ''higher'' bits - the first hexadecimal number - specify the ''later'' samples; that is to say, the nybbles of each sample are swapped relative to the wave drawing.
{{Anchor|Sound Channel Control}}
=== Sound Channel Control ($90) ===
<pre>
7 bit 0
---- ----
nsv. 4321
||| ||||
||| |||+- Channel 1 enable
||| ||+-- Channel 2 enable
||| |+--- Channel 3 enable
||| +---- Channel 4 enable
||+------- Channel 2 mode: 0 = wavetable, 1 = voice
|+-------- Channel 3 sweep: 0 = disable, 1 = enable
+--------- Channel 4 mode: 0 = wavetable, 1 = noise
</pre>
{{Anchor|Sound Output Control}}
=== Sound Output Control ($91) ===
<pre>
7 bit 0
---- ----
H... hrrs
| ||||
| |||+- Internal speaker output enable
| |++-- Internal speaker shift/volume:
| | 0 = 100% 1 = 50%
| | 2 = 25% 3 = 12.5%
| +---- Headphone output enable
+--------- Headphones connected, 1 if true
</pre>
For correct playback on the internal speaker, it is important to set the shift/volume correctly, to match the peak summed output of the first four channels. If the value is too low, music using multiple loud channels will wrap, causing audible distortion. If the value is too high, single-channel PCM sample playback will be very quiet.
{{Anchor|Sound Channel 4 LFSR Register}}
=== Sound Channel 4 LFSR Register ($92, $93 read) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
.rrr rrrr rrrr rrrr
||| |||| |||| ||||
+++-++++--++++-++++- Shift register value
</pre>
{{Anchor|Sound Channel 2 Voice Volume}}
=== Sound Channel 2 Voice Volume ($94) ===
<pre>
7 bit 0
---- ----
.... lLrR
||||
|||+- Right channel 100% volume
||+-- Right channel 50% volume
|+--- Left channel 100% volume
+---- Left channel 50% volume
</pre>
This port is used for voice output.
The <code>50% volume</code> have no effect if their respective <code>100% volume</code> bits are set.
{{Anchor|Sound Test}}
=== Sound Test ($95) ===
<pre>
7 bit 0
---- ----
??5? llsh
| ||||
| |||+- Hold Ch1-4 output updates
| ||+-- Use 3072000 Hz CPU clock for sweep
| ++--- Hold noise LFSR output
| (Differences between bit 2/3
| behavior are unknown)
+------- Force L10/R10 outputs to (channel 2 voice output * 5) & 0x3FF
</pre>
{{Anchor|Sound Channel Output Right}}
=== Sound Channel Output Right ($96, $97 read) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
.... ..ss ssss ssss
|| |||| ||||
++--++++-++++- Unsigned 10-bit sample
</pre>
{{Anchor|Sound Channel Output Left}}
=== Sound Channel Output Left ($98, $99 read) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
.... ..ss ssss ssss
|| |||| ||||
++--++++-++++- Unsigned 10-bit sample
</pre>
{{Anchor|Sound Channel Output Sum}}
=== Sound Channel Output Sum ($9A, $9B read) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
.... .sss ssss ssss
||| |||| ||||
+++--++++-++++- Unsigned 11-bit sample
</pre>
{{Anchor|Sound Speaker Main Volume}}
=== Sound Speaker Main Volume ($9E) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
.... .... .... ..vv
||
++- Built-in speaker output volume
</pre>
Writing to this port changes the output volume of the built-in speaker.
While it functions the same way as the SOUND button (and affects the same internal register), pressing the SOUND button does ''not'' update this port's value.
This port does not affect the headphone output in any way, just like the SOUND button.
TODO: The exact volume levels have not been verified; it's probably either 0, 25, 50, 100% or 0, ~33, ~67, 100%.
ebf1cc8d201187a0927a356d6e7b327e247f13ed
359
357
2024-09-13T14:19:49Z
Asie
351
wikitext
text/x-wiki
The WonderSwan features the following sound hardware:
* Four audio channels:
** channel 1 - wavetable (32 x 4-bit samples),
** channel 2 - wavetable or 8-bit unsigned PCM sample,
** channel 3 - wavetable with optional hardware sweep,
** channel 4 - wavetable or LFSR noise,
* [[Hyper Voice]]<sup>(color)</sup> - headphone output exclusive 16-bit stereo PCM output,
* 24000 Hz output:
** internal speaker - 8-bit, mono,
** headphone output - 16-bit, stereo.
[[Hyper Voice]] functionality is documented on its own sub-page.
== Mixing diagram ==
The sound is mixed as follows:
<pre>
Ch1 Ch2 Ch3 Ch4 Glossary: L = left, R = right, M = mono
| | | | Mnn = nn-bit mono
8 8 8 8 port $98 port $nn = value port
| | | | /
_V___V___V___V_ / _____ _____
| |--L10------+----->| | | |
| + | | | + |--M11-->| >>r |--M8--> Speaker output
|_______________|--R10------|-+--->|_____| / |_____|
/ _|_|_ / (r=0...3)
/ | | / \
port $96 | <<5 | port $9A \
|_____| \
| | port $91
| |
port $68 port $64 | |
/ _______________ \ __V_V__ _____
L8-->| (Color only) |--L16-->| |----------L16-->| |
| Hyper Voice | | + + | | I2S |------> Headphone output
R8-->|_______________|--R16-->|_______|----------R16-->|_____|
\ /
port $69 port $66
</pre>
== I/O Ports ==
{{Anchor|Sound Channel Frequency}}
=== Sound Channel Frequency ($80, $81; $82, $83; $84, $85; $86, $87) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
.... .ddd dddd dddd
||| |||| ||||
+++--++++-++++- Frequency divisor
</pre>
This frequency is used for wavetable output. It is calculated as follows: <code>sample rate = 3072000 Hz / (2048 - divisor)</code>.
Note that this refers to the sample rate of the ''wavetable'', and needs to be scaled accordingly for a given waveform when performing music playback.
{{Anchor|Sound Channel Volume}}
=== Sound Channel Volume ($88; $89; $8A; $8B) ===
<pre>
7 bit 0
---------
llll rrrr
|||| ||||
|||| ++++- Right channel volume (0-15)
++++------ Left channel volume (0-15)
</pre>
This volume is used for wavetable output.
The calculation to get an unsigned 8-bit sample out of a 4-bit wavetable sample / 4-bit volume pair is simple: <code>out_sample = sample * volume</code>. This means that the maximum sample in wavetable output mode is <code>15 * 15 = 225</code>.
{{Anchor|Sound Channel 2 Voice Sample}}
=== Sound Channel 2 Voice Sample ($89) ===
<pre>
7 bit 0
---- ----
ssss ssss
|||| ||||
++++-++++- Unsigned 8-bit PCM sample (0-255)
</pre>
This sample is used for voice output.
{{Anchor|Sound Channel 3 Sweep Amount}}
=== Sound Channel 3 Sweep Amount ($8C) ===
<pre>
7 bit 0
---- ----
vvvv vvvv
|||| ||||
++++-++++- Value; 8-bit, signed.
</pre>
This port is used for wavetable output with sweep enabled.
The signed value in this port will be added to the frequency divider for channel 3 every sweep step (as determined by the Sweep Ticks port). Wraparound is present - adding 1 to a frequency divider value of 2047 will cause it to roll over back to 0.
{{Anchor|Sound Channel 3 Sweep Ticks}}
=== Sound Channel 3 Sweep Ticks ($8D) ===
<pre>
7 bit 0
---- ----
...t tttt
| ||||
+-++++- Ticks per step - 1
</pre>
This port is used for wavetable output with sweep enabled.
Every <code>ttttt + 1</code> ticks, clocked at 375 Hz, the value in the Sweep Amount port will be added to the frequency divider for channel 3.
{{Anchor|Sound Channel 4 Noise Control}}
=== Sound Channel 4 Noise Control ($8E) ===
<pre>
7 bit 0
---- ----
...e rttt
| ||||
| |+++- LFSR tap mode
| +---- LFSR reset: 1 = reset shift register
+------ LFSR enabled: 0 = off, 1 = on
</pre>
This port is used for noise output.
{| class="wikitable"
|+ List of LFSR tap modes
! Tap mode
! Tap bit
! Sequence length
|-
| 0
| 14
| 32767
|-
| 1
| 10
| 1953
|-
| 2
| 13
| 254
|-
| 3
| 4
| 217
|-
| 4
| 8
| 73
|-
| 5
| 6
| 63
|-
| 6
| 9
| 42
|-
| 7
| 11
| 28
|}
Noise output works using the following algorithm, performed once per sample generated:
# Create a new bit by inverting the XOR of bit 7 with the tap bit.
# Shift the LFSR register one bit to the left.
# Write the new bit as bit 0.
# Use the new bit as if it were a wavetable sample: 0 = 0, 1 = 15.
{{Anchor|Sound Wavetable Address}}
=== Sound Wavetable Address ($8F) ===
<pre>
7 bit 0
---- ----
wwww wwww
|||| ||||
++++-++++- Wavetable address (bits 6-13)
</pre>
The wavetable is 4 x 16 bytes long; each 16-byte block contains 32 4-bit samples for the relevant channel:
<pre>
Address $00 $01 $02 $03 $04 $05 $06 $07 $08 $09 $0A $0B $0C $0D $0E $0F
98 CB ED FF FF EF BD 8A 57 24 01 00 00 21 43 76
Sample
15 .. .. .. ## ## #. .. .. .. .. .. .. .. .. .. ..
14 .. .. .# || || |# .. .. .. .. .. .. .. .. .. ..
13 .. .. #| || || || #. .. .. .. .. .. .. .. .. ..
12 .. .# || || || || |. .. .. .. .. .. .. .. .. ..
11 .. #| || || || || |# .. .. .. .. .. .. .. .. ..
10 .. || || || || || || #. .. .. .. .. .. .. .. ..
9 .# || || || || || || |. .. .. .. .. .. .. .. ..
8 #| || || || || || || |# .. .. .. .. .. .. .. ..
7 || || || || || || || || #. .. .. .. .. .. .. .#
6 || || || || || || || || |. .. .. .. .. .. .. #|
5 || || || || || || || || |# .. .. .. .. .. .. ||
4 || || || || || || || || || #. .. .. .. .. .# ||
3 || || || || || || || || || |. .. .. .. .. #| ||
2 || || || || || || || || || |# .. .. .. .# || ||
1 || || || || || || || || || || #. .. .. #| || ||
0 || || || || || || || || || || |# ## ## || || ||
</pre>
Note that the ''higher'' bits - the first hexadecimal number - specify the ''later'' samples; that is to say, the nybbles of each sample are swapped relative to the wave drawing.
{{Anchor|Sound Channel Control}}
=== Sound Channel Control ($90) ===
<pre>
7 bit 0
---- ----
nsv. 4321
||| ||||
||| |||+- Channel 1 enable
||| ||+-- Channel 2 enable
||| |+--- Channel 3 enable
||| +---- Channel 4 enable
||+------- Channel 2 mode: 0 = wavetable, 1 = voice
|+-------- Channel 3 sweep: 0 = disable, 1 = enable
+--------- Channel 4 mode: 0 = wavetable, 1 = noise
</pre>
{{Anchor|Sound Output Control}}
=== Sound Output Control ($91) ===
<pre>
7 bit 0
---- ----
H... hrrs
| ||||
| |||+- Internal speaker output enable
| |++-- Internal speaker shift/volume:
| | 0 = 100% 1 = 50%
| | 2 = 25% 3 = 12.5%
| +---- Headphone output enable
+--------- Headphones connected, 1 if true
</pre>
For correct playback on the internal speaker, it is important to set the shift/volume correctly, to match the peak summed output of the first four channels. If the value is too low, music using multiple loud channels will wrap, causing audible distortion. If the value is too high, single-channel PCM sample playback will be very quiet.
{{Anchor|Sound Channel 4 LFSR Register}}
=== Sound Channel 4 LFSR Register ($92, $93 read) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
.rrr rrrr rrrr rrrr
||| |||| |||| ||||
+++-++++--++++-++++- Shift register value
</pre>
{{Anchor|Sound Channel 2 Voice Volume}}
=== Sound Channel 2 Voice Volume ($94) ===
<pre>
7 bit 0
---- ----
.... lLrR
||||
|||+- Right channel 100% volume
||+-- Right channel 50% volume
|+--- Left channel 100% volume
+---- Left channel 50% volume
</pre>
This port is used for voice output.
The <code>50% volume</code> have no effect if their respective <code>100% volume</code> bits are set.
{{Anchor|Sound Test}}
=== Sound Test ($95) ===
<pre>
7 bit 0
---- ----
??5? llsh
| ||||
| |||+- Hold Ch1-4 output updates
| ||+-- Use 3072000 Hz CPU clock for sweep
| ++--- Hold noise LFSR output
| (Differences between bit 2/3
| behavior are unknown)
+------- Force L10/R10 outputs to (channel 2 voice output * 5) & 0x3FF
</pre>
{{Anchor|Sound Channel Output Right}}
=== Sound Channel Output Right ($96, $97 read) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
.... ..ss ssss ssss
|| |||| ||||
++--++++-++++- Unsigned 10-bit sample
</pre>
{{Anchor|Sound Channel Output Left}}
=== Sound Channel Output Left ($98, $99 read) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
.... ..ss ssss ssss
|| |||| ||||
++--++++-++++- Unsigned 10-bit sample
</pre>
{{Anchor|Sound Channel Output Sum}}
=== Sound Channel Output Sum ($9A, $9B read) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
.... .sss ssss ssss
||| |||| ||||
+++--++++-++++- Unsigned 11-bit sample
</pre>
{{Anchor|Sound Speaker Main Volume}}
=== Sound Speaker Main Volume ($9E) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
.... .... .... ..vv
||
++- Built-in speaker output volume
</pre>
Writing to this port changes the output volume of the built-in speaker.
While it functions the same way as the SOUND button (and affects the same internal register), pressing the SOUND button does ''not'' update this port's value. However, manual writes do, and those values can be read out.
This port does not affect the headphone output in any way, just like the SOUND button.
TODO: The exact volume levels have not been verified; it's probably either 0, 25, 50, 100% or 0, ~33, ~67, 100%.
f04ecf5ba67406e88699ca5a27177c17563adfd2
DMA
0
31
354
238
2024-09-09T17:00:00Z
Asie
351
/* General DMA */
wikitext
text/x-wiki
The WonderSwan Color introduced two DMA blocks:
* General DMA (GDMA) - allowing for fast IRAM/ROM -> IRAM transfers,
* Sound DMA (SDMA) - allowing for IRAM/ROM -> sound transfers in a much less CPU-intensive way than an interrupt.
== General DMA ==
The CPU is stalled immediately after General DMA is enabled; the enable bit is cleared after a completed GDMA operation.
General DMA takes <code>(5 + 2 * words)</code> cycles to complete, where <code>words</code> is the number of words (2-bytes) transferred.
General DMA allows source addresses which can be accessed with a 16-bit width and without waitstates; any attempt to access SRAM (8-bit width) or "slow" ROM ($A0 bit 3 set) will cause DMA to immediately return, even if in the middle of processing a transfer. If GDMA is enabled for an address that is already invalid, zero cycles are taken up.
{{Anchor|GDMA Source Address Low}}
{{Anchor|GDMA Source Address High}}
=== GDMA Source Address ($40, $41, $42) ===
<pre>
23 bit 16 15 bit 8 7 bit 0
---- ---- ---- ---- ---- ----
.... hhhh llll llll llll lll.
|||| |||| |||| |||| |||
++++---++++-++++---++++-++++- Linear source address
($00000 - $FFFFE)
</pre>
{{Anchor|GDMA Destination Address}}
=== GDMA Destination Address ($44, $45) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
aaaa aaaa aaaa aaa.
|||| |||| |||| |||
++++-++++--++++-+++-- Destination address in IRAM
</pre>
GDMA allows destination addresses in IRAM.
{{Anchor|GDMA Length}}
=== GDMA Length ($46, $47) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
bbbb bbbb bbbb bbb.
|||| |||| |||| |||
++++-++++--++++-+++-- Transfer length, in words
(if including bit 0: in bytes)
</pre>
{{Anchor|GDMA Control}}
=== GDMA Control ($48) ===
<pre>
7 bit 0
---- ----
ed.. ....
||
|+-------- Direction: 0 = increment, 1 = decrement
+--------- Enable DMA: 0 = off, 1 = on
</pre>
== Sound DMA ==
Sound DMA allows copying sample data to either Channel 2 or Hyper Voice automatically while incurring a much lower cost than that of a CPU interrupt.
Features:
* 4000, 6000, 12000, 24000 Hz sample rates.
* '''Auto-repeat''': If enabled, every time the length counter reaches 0, a shadowed copy of the offset and length as written to the I/O ports will be restored. If disabled, bit 7 will automatically clear on transfer completion, same as with General DMA.
* '''Holding''': If enabled, the offset/length counters will be paused, and $00 will be written on every Sound DMA tick as opposed to the value in memory. This does not impact the timing of Sound DMA.
When playing back sound, the visible ports ($4A-$4C, $4E-$50) are the ones updated live; any edits to them are reflected immediately, as well as written to the shadow copy used for auto-repeat.
The enable/disable bit of Sound DMA does not affect the offset/length counters in any way; for example, if a sample is stopped mid-playthrough, then started again, it will pick up right where it left off.
Unlike General DMA, Sound DMA copies data per byte. This means that SRAM is supported as an input source. Also unlike General DMA, streaming from "slow" (>1 cycle) locations is supported; doing so lengthens the duration of Sound DMA. Due to its need to access the external cartridge bus, Sound DMA must use cycles normally reserved for the CPU; it uses <code>6 + N</code> cycles every 128 cycles, always starting from cycle <code>117 mod 128</code>. <code>N</code> refers to the access time of the area from which audio is being streamed from, and is typically 1 cycle.
{{Anchor|SDMA Source Address Low}}
{{Anchor|SDMA Source Address High}}
=== SDMA Source Address ($4A, $4B, $4C) ===
<pre>
23 bit 16 15 bit 8 7 bit 0
---- ---- ---- ---- ---- ----
.... hhhh llll llll llll llll
|||| |||| |||| |||| ||||
++++---++++-++++---++++-++++- Linear source address
($00000 - $FFFFF)
</pre>
Upon writing to any of the bytes, said byte (and only said byte) is copied to a shadow register, used for restoring the offset/length counter when auto-repeat is enabled.
{{Anchor|SDMA Length}}
=== SDMA Length ($4E, $4F, $50) ===
<pre>
23 bit 16 15 bit 8 7 bit 0
---- ---- ---- ---- ---- ----
.... hhhh llll llll llll llll
|||| |||| |||| |||| ||||
++++---++++-++++---++++-++++- Transfer length, in bytes
</pre>
Upon writing to any of the bytes, said byte (and only said byte) is copied to a shadow register, used for restoring the offset/length counter when auto-repeat is enabled.
{{Anchor|SDMA Control}}
=== SDMA Control ($52) ===
<pre>
7 bit 0
---- ----
ed.t rhff
|| | ||||
|| | ||++- Frequency/Rate:
|| | || 0 = 24000/6 = 4000 Hz
|| | || 1 = 24000/4 = 6000 Hz
|| | || 2 = 24000/2 = 12000 Hz
|| | || 3 = 24000/1 = 24000 Hz
|| | |+--- Hold: 0 = normal playback, 1 = hold
|| | +---- Repeat: 0 = one-shot, 1 = auto-repeat
|| +------ Target:
|| 0 = Channel 2 (port $89)
|| 1 = Hyper Voice
|+-------- Direction: 0 = increment, 1 = decrement
+--------- Enable DMA: 0 = off, 1 = on
</pre>
49d23bdac49092bac1942b81786e4d749067deb4
355
354
2024-09-10T19:15:18Z
Asie
351
/* General DMA */
wikitext
text/x-wiki
The WonderSwan Color introduced two DMA blocks:
* General DMA (GDMA) - allowing for fast IRAM/ROM -> IRAM transfers,
* Sound DMA (SDMA) - allowing for IRAM/ROM -> sound transfers in a much less CPU-intensive way than an interrupt.
== General DMA ==
The CPU is stalled immediately after General DMA is enabled; the enable bit is cleared after a completed GDMA operation.
General DMA takes <code>(5 + 2 * words)</code> cycles to complete, where <code>words</code> is the number of words (2-bytes) transferred.
General DMA allows source addresses which can be accessed with a 16-bit width and without waitstates; any attempt to access SRAM (8-bit width) or "slow" ROM ($A0 bit 3 set) will cause DMA to immediately return, even if in the middle of processing a transfer.
Note that the 5-cycle cost is not spent for DMA requests for invalid addresses or of length zero; such scenarios take up no cycles.
{{Anchor|GDMA Source Address Low}}
{{Anchor|GDMA Source Address High}}
=== GDMA Source Address ($40, $41, $42) ===
<pre>
23 bit 16 15 bit 8 7 bit 0
---- ---- ---- ---- ---- ----
.... hhhh llll llll llll lll.
|||| |||| |||| |||| |||
++++---++++-++++---++++-++++- Linear source address
($00000 - $FFFFE)
</pre>
{{Anchor|GDMA Destination Address}}
=== GDMA Destination Address ($44, $45) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
aaaa aaaa aaaa aaa.
|||| |||| |||| |||
++++-++++--++++-+++-- Destination address in IRAM
</pre>
GDMA allows destination addresses in IRAM.
{{Anchor|GDMA Length}}
=== GDMA Length ($46, $47) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
bbbb bbbb bbbb bbb.
|||| |||| |||| |||
++++-++++--++++-+++-- Transfer length, in words
(if including bit 0: in bytes)
</pre>
{{Anchor|GDMA Control}}
=== GDMA Control ($48) ===
<pre>
7 bit 0
---- ----
ed.. ....
||
|+-------- Direction: 0 = increment, 1 = decrement
+--------- Enable DMA: 0 = off, 1 = on
</pre>
== Sound DMA ==
Sound DMA allows copying sample data to either Channel 2 or Hyper Voice automatically while incurring a much lower cost than that of a CPU interrupt.
Features:
* 4000, 6000, 12000, 24000 Hz sample rates.
* '''Auto-repeat''': If enabled, every time the length counter reaches 0, a shadowed copy of the offset and length as written to the I/O ports will be restored. If disabled, bit 7 will automatically clear on transfer completion, same as with General DMA.
* '''Holding''': If enabled, the offset/length counters will be paused, and $00 will be written on every Sound DMA tick as opposed to the value in memory. This does not impact the timing of Sound DMA.
When playing back sound, the visible ports ($4A-$4C, $4E-$50) are the ones updated live; any edits to them are reflected immediately, as well as written to the shadow copy used for auto-repeat.
The enable/disable bit of Sound DMA does not affect the offset/length counters in any way; for example, if a sample is stopped mid-playthrough, then started again, it will pick up right where it left off.
Unlike General DMA, Sound DMA copies data per byte. This means that SRAM is supported as an input source. Also unlike General DMA, streaming from "slow" (>1 cycle) locations is supported; doing so lengthens the duration of Sound DMA. Due to its need to access the external cartridge bus, Sound DMA must use cycles normally reserved for the CPU; it uses <code>6 + N</code> cycles every 128 cycles, always starting from cycle <code>117 mod 128</code>. <code>N</code> refers to the access time of the area from which audio is being streamed from, and is typically 1 cycle.
{{Anchor|SDMA Source Address Low}}
{{Anchor|SDMA Source Address High}}
=== SDMA Source Address ($4A, $4B, $4C) ===
<pre>
23 bit 16 15 bit 8 7 bit 0
---- ---- ---- ---- ---- ----
.... hhhh llll llll llll llll
|||| |||| |||| |||| ||||
++++---++++-++++---++++-++++- Linear source address
($00000 - $FFFFF)
</pre>
Upon writing to any of the bytes, said byte (and only said byte) is copied to a shadow register, used for restoring the offset/length counter when auto-repeat is enabled.
{{Anchor|SDMA Length}}
=== SDMA Length ($4E, $4F, $50) ===
<pre>
23 bit 16 15 bit 8 7 bit 0
---- ---- ---- ---- ---- ----
.... hhhh llll llll llll llll
|||| |||| |||| |||| ||||
++++---++++-++++---++++-++++- Transfer length, in bytes
</pre>
Upon writing to any of the bytes, said byte (and only said byte) is copied to a shadow register, used for restoring the offset/length counter when auto-repeat is enabled.
{{Anchor|SDMA Control}}
=== SDMA Control ($52) ===
<pre>
7 bit 0
---- ----
ed.t rhff
|| | ||||
|| | ||++- Frequency/Rate:
|| | || 0 = 24000/6 = 4000 Hz
|| | || 1 = 24000/4 = 6000 Hz
|| | || 2 = 24000/2 = 12000 Hz
|| | || 3 = 24000/1 = 24000 Hz
|| | |+--- Hold: 0 = normal playback, 1 = hold
|| | +---- Repeat: 0 = one-shot, 1 = auto-repeat
|| +------ Target:
|| 0 = Channel 2 (port $89)
|| 1 = Hyper Voice
|+-------- Direction: 0 = increment, 1 = decrement
+--------- Enable DMA: 0 = off, 1 = on
</pre>
7ddda5986a9523d2c04e6dd58ad113d9d6625106
I/O port map
0
8
358
347
2024-09-13T14:19:20Z
Asie
351
wikitext
text/x-wiki
The WonderSwan SoC has three general blocks of I/O port accesses:
{| class="wikitable"
! From !! To !! Holder !! Width !! Speed
|-
| $00 || $B7 || WonderSwan SoC || 16-bit || 1 cycle
|-
| $B8 || $BF || Internal EEPROM control || 16-bit || 1 cycle
|-
| $C0 || $FF || Cartridge bus || 8-bit || 1<sup>(color)</sup>/2 cycles (configurable)
|}
With the exception of internal EEPROM on the ASWAN, all unaligned 16-bit accesses can be converted to two 8-bit accesses with a 1-cycle penalty.
== I/O port map ==
* Superscripts are used to mark ports specific to a given mode or platform:
** Color mode: <sup>(color)</sup>. Such ports are only accessible when color mode is enabled through port <code>$60</code>.
** WS/WSC/SC console: <sup>(WS)</sup>, <sup>(WSC)</sup>, <sup>(SC)</sup>.
* If two Bits rows are provided, the second one refers to the "Color" mode.
* The Type can be: R - readable, W - writable, L - writable before boot ROM lockout, 8/16 - width (byte/word).
{| class="wikitable"
! Category
! Port
! Description
! Bits
! Type
! Notes
|-
! rowspan="45" | [[Display]]
! $00
| [[Display#Display Control|Display Control]]
| style="text-align: right" | <tt style="white-space: nowrap">..wo Ws21</tt>
| RW8
|
|-
! $01
| [[Display#Display Background|Display Background]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .sss</tt>
<tt style="white-space: nowrap">pppp iiii</tt>
| RW8
| Shade (s)
Palette (p), Index (i)
|-
! $02
| [[Display#Current Line|Display Current Line]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll</tt>
| R8
| Line (l)
|-
! $03
| [[Display#Interrupt Line|Display Interrupt Line]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll</tt>
| RW8
| Line (l)
|-
! $04
| [[Display#Sprite Table Address|Sprite Table Address]]
| style="text-align: right" | <tt style="white-space: nowrap">...a aaaa</tt>
<tt style="white-space: nowrap">..aa aaaa</tt>
| RW8
| Address >> 9 (a)
|-
! $05
| [[Display#Sprite Table First|Sprite Table First]]
| style="text-align: right" | <tt style="white-space: nowrap">.iii iiii</tt>
| RW8
| Index (i)
|-
! $06
| [[Display#Sprite Table Count|Sprite Table Count]]
| style="text-align: right" | <tt style="white-space: nowrap">cccc cccc</tt>
| RW8
| Count (c)
|-
! $07
| [[Display#Screen Address|Screen Address]]
| style="text-align: right" | <tt style="white-space: nowrap">.222 .111</tt>
<tt style="white-space: nowrap">2222 1111</tt>
| RW8
| Screen 1 address >> 11 (1)
Screen 2 address >> 11 (2)
|-
! $08
| [[Display#Screen 2 Window|Screen 2 Window Left]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $09
| [[Display#Screen 2 Window|Screen 2 Window Top]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $0A
| [[Display#Screen 2 Window|Screen 2 Window Right]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $0B
| [[Display#Screen 2 Window|Screen 2 Window Bottom]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $0B
| [[Display#Sprite Window|Sprite Window Left]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $0C
| [[Display#Sprite Window|Sprite Window Top]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $0E
| [[Display#Sprite Window|Sprite Window Right]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $0F
| [[Display#Sprite Window|Sprite Window Bottom]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $10
| [[Display#Screen Scroll|Screen 1 Scroll X]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $11
| [[Display#Screen Scroll|Screen 1 Scroll Y]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $12
| [[Display#Screen Scroll|Screen 2 Scroll X]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $13
| [[Display#Screen Scroll|Screen 2 Scroll Y]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $14
| [[Display#LCD Control|LCD Control]]
| style="text-align: right" | <tt style="white-space: nowrap">.... ..Ce</tt>
| RW8
| Contrast (C)<sup>(WSC)</sup>, Enable (e)
|-
! $15
| [[Display#LCD Icon Control|LCD Icon Control]]
| style="text-align: right" | <tt style="white-space: nowrap">..32 1hvs</tt>
| RW8
| Auxillary 3 (3), Auxillary 2 (2), Auxillary 1 (1),
Horizontal (h), Vertical (v), Sleep (s)
|-
! $16
| [[Display#LCD Final Line|LCD Final Line]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll</tt>
| RW8
| Line (l)
|-
! $17
| [[Display#LCD Back Porch Line|LCD Back Porch Line]]<sup>(WSC)</sup>
| style="text-align: right" | <tt style="white-space: nowrap">llll llll</tt>
| RW8
| Line (l)
|-
! $1A
| [[Display#LCD Status|LCD Status]]
| style="text-align: right" | <tt style="white-space: nowrap">...v vvhs</tt>
| RW8
| Volume segments (v), Headphone segment (h), Sleep (s)
|-
! $1C
| [[Display#LCD Mono Shade LUT|LCD Mono Shade LUT 0/1]]
| style="text-align: right" | <tt style="white-space: nowrap">1111 0000</tt>
| RW8
| Shade index
|-
! $1D
| [[Display#LCD Mono Shade LUT|LCD Mono Shade LUT 2/3]]
| style="text-align: right" | <tt style="white-space: nowrap">3333 2222</tt>
| RW8
| Shade index
|-
! $1E
| [[Display#LCD Mono Shade LUT|LCD Mono Shade LUT 4/5]]
| style="text-align: right" | <tt style="white-space: nowrap">5555 4444</tt>
| RW8
| Shade index
|-
! $1F
| [[Display#LCD Mono Shade LUT|LCD Mono Shade LUT 6/7]]
| style="text-align: right" | <tt style="white-space: nowrap">7777 6666</tt>
| RW8
| Shade index
|-
! $20
| [[Display#LCD Mono Palette|LCD Mono Palette 0]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $22
| [[Display#LCD Mono Palette|LCD Mono Palette 1]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $24
| [[Display#LCD Mono Palette|LCD Mono Palette 2]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $26
| [[Display#LCD Mono Palette|LCD Mono Palette 3]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $28
| [[Display#LCD Mono Palette|LCD Mono Palette 4]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $2A
| [[Display#LCD Mono Palette|LCD Mono Palette 5]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $2C
| [[Display#LCD Mono Palette|LCD Mono Palette 6]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $2E
| [[Display#LCD Mono Palette|LCD Mono Palette 7]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $30
| [[Display#LCD Mono Palette|LCD Mono Palette 8]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $32
| [[Display#LCD Mono Palette|LCD Mono Palette 9]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $34
| [[Display#LCD Mono Palette|LCD Mono Palette 10]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $36
| [[Display#LCD Mono Palette|LCD Mono Palette 11]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $38
| [[Display#LCD Mono Palette|LCD Mono Palette 12]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $3A
| [[Display#LCD Mono Palette|LCD Mono Palette 13]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $3C
| [[Display#LCD Mono Palette|LCD Mono Palette 14]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $3E
| [[Display#LCD Mono Palette|LCD Mono Palette 15]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! rowspan="10" | [[DMA]]<sup>(color)</sup>
! $40
| [[DMA#General DMA|GDMA Source Address Low]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll llll lll.</tt>
| RW16
| Linear address, low 16 bits (l)
|-
! $42
| [[DMA#General DMA|GDMA Source Address High]]
| style="text-align: right" | <tt style="white-space: nowrap">.... hhhh</tt>
| RW8
| Linear address, high 4 bits (h)
|-
! $44
| [[DMA#General DMA|GDMA Destination Address]]
| style="text-align: right" | <tt style="white-space: nowrap">aaaa aaaa aaaa aaa.</tt>
| RW16
| IRAM address (a)
|-
! $46
| [[DMA#General DMA|GDMA Length]]
| style="text-align: right" | <tt style="white-space: nowrap">bbbb bbbb bbbb bbb.</tt>
| RW16
| Bytes (b)
|-
! $48
| [[DMA#General DMA|GDMA Control]]
| style="text-align: right" | <tt style="white-space: nowrap">ed.. ....</tt>
| RW8
| Enable (e), Decrement (d)
|-
! $4A
| [[DMA#Sound DMA|SDMA Source Address Low]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll llll llll</tt>
| RW16
| Linear address, low 16 bits (l)
|-
! $4C
| [[DMA#Sound DMA|SDMA Source Address High]]
| style="text-align: right" | <tt style="white-space: nowrap">.... hhhh</tt>
| RW8
| Linear address, high 4 bits (h)
|-
! $4E
| [[DMA#Sound DMA|SDMA Length Low]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll llll llll</tt>
| RW16
| Length, low 16 bits (l)
|-
! $50
| [[DMA#Sound DMA|SDMA Length High]]
| style="text-align: right" | <tt style="white-space: nowrap">.... hhhh</tt>
| RW8
| Length, high 4 bits (h)
|-
! $52
| [[DMA#Sound DMA|SDMA Control]]
| style="text-align: right" | <tt style="white-space: nowrap">ed.t rhff</tt>
| RW8
| Enable (e), Decrement (d), Target (t),
Repeat (r), Hold (h), Frequency (f)
|-
! rowspan="2" | [[SoC]]<sup>(color)</sup>
! $60
| [[SoC#System Control 2|System Control 2]]
| style="text-align: right" | <tt style="white-space: nowrap">c4C. i?sl</tt>
| RW8
| Color (c), 4BPP (4), Chunky (C),<br/>
Cart I/O wait state (i), SRAM wait state (s),<br/>
Cart clock speed (l).
|-
! $62
| [[SoC#System Control 3|System Control 3]]
| style="text-align: right" | <tt style="white-space: nowrap">S... ...p</tt>
| RW8
| SwanCrystal (S), Power off (p)
|-
! rowspan="4" | [[Hyper Voice]]<sup>(color)</sup>
! $64
| [[Hyper Voice#Hyper Voice Output|Hyper Voice Left Output]]
| style="text-align: right" | <tt style="white-space: nowrap">ssss ssss ssss ssss</tt>
| W16
| Raw sample (s)
|-
! $66
| [[Hyper Voice#Hyper Voice Output|Hyper Voice Right Output]]
| style="text-align: right" | <tt style="white-space: nowrap">ssss ssss ssss ssss</tt>
| W16
| Raw sample (s)
|-
! $69
| [[Hyper Voice#Hyper Voice Input|Hyper Voice Right Input]]
| style="text-align: right" | <tt style="white-space: nowrap">ssss ssss</tt>
| W8
| Sample (s)
|-
! $6A
| [[Hyper Voice#Hyper Voice Control|Hyper Voice Control]]
| style="text-align: right" | <tt style="white-space: nowrap">.mmc ???? errr ffss</tt>
| RW16
| Mask (m), Channel reset (c), Enable (e),
Rate (r), Format (f), Shift (s)
|-
! rowspan="8" | [[Display]]<sup>(SC)</sup>
! $70
| LCD Timing Configuration 1?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $71
| LCD Timing Configuration 2?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $72
| LCD Timing Configuration 3?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $73
| LCD Timing Configuration 4?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $74
| LCD Timing Configuration 5?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $75
| LCD Timing Configuration 6?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $76
| LCD Timing Configuration 7?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $77
| LCD Timing Configuration 8?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! rowspan="22" | [[Sound]]
! $80
| [[Sound#Sound Channel Frequency|Sound Channel 1 Frequency]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .ddd dddd dddd</tt>
| RW16
| Divider (d)
|-
! $82
| [[Sound#Sound Channel Frequency|Sound Channel 2 Frequency]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .ddd dddd dddd</tt>
| RW16
| Divider (d)
|-
! $84
| [[Sound#Sound Channel Frequency|Sound Channel 3 Frequency]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .ddd dddd dddd</tt>
| RW16
| Divider (d)
|-
! $86
| [[Sound#Sound Channel Frequency|Sound Channel 4 Frequency]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .ddd dddd dddd</tt>
| RW16
| Divider (d)
|-
! $88
| [[Sound#Sound Channel Volume|Sound Channel 1 Volume]]
| style="text-align: right" | <tt style="white-space: nowrap">llll rrrr</tt>
| RW8
| Left (l), Right (r)
|-
! rowspan="2" | $89
| [[Sound#Sound Channel Volume|Sound Channel 2 Volume]]
| style="text-align: right" | <tt style="white-space: nowrap">llll rrrr</tt>
| RW8
| Left (l), Right (r)
|-
| [[Sound#Sound Channel 2 Voice Sample|Sound Channel 2 Voice Sample]]
| style="text-align: right" | <tt style="white-space: nowrap">ssss ssss</tt>
| RW8
| Sample (s)
|-
! $8A
| [[Sound#Sound Channel Volume|Sound Channel 3 Volume]]
| style="text-align: right" | <tt style="white-space: nowrap">llll rrrr</tt>
| RW8
| Left (l), Right (r)
|-
! $8B
| [[Sound#Sound Channel Volume|Sound Channel 4 Volume]]
| style="text-align: right" | <tt style="white-space: nowrap">llll rrrr</tt>
| RW8
| Left (l), Right (r)
|-
! $8C
| [[Sound#Sound Channel 3 Sweep Amount|Sound Channel 3 Sweep Amount]]
| style="text-align: right" | <tt style="white-space: nowrap">vvvv vvvv</tt>
| RW8
| Value (v)
|-
! $8D
| [[Sound#Sound Channel 3 Sweep Ticks|Sound Channel 3 Sweep Ticks]]
| style="text-align: right" | <tt style="white-space: nowrap">...t tttt</tt>
| RW8
| Ticks (t)
|-
! $8E
| [[Sound#Sound Channel 4 Noise Control|Sound Channel 4 Noise Control]]
| style="text-align: right" | <tt style="white-space: nowrap">...e rttt</tt>
| RW8
| Enable (e), Reset (r), Tap (t)
|-
! $8F
| [[Sound#Sound Wavetable Address|Sound Wavetable Address]]
| style="text-align: right" | <tt style="white-space: nowrap">wwww wwww</tt>
| RW8
| Address >> 6 (w)
|-
! $90
| [[Sound#Sound Channel Control|Sound Channel Control]]
| style="text-align: right" | <tt style="white-space: nowrap">nsv. 4321</tt>
| RW8
| Channel enable (1234)
Noise (n), Sweep (s), Voice (v)
|-
! $91
| [[Sound#Sound Output Control|Sound Output Control]]
| style="text-align: right" | <tt style="white-space: nowrap">H... hrrs</tt>
| RW8
| Headphones connected (H)
Headphone output (h)
Speaker output (s), range (r)
|-
! $92
| [[Sound#Sound Channel 4 LFSR Register|Sound Channel 4 LFSR Register]]
| style="text-align: right" | <tt style="white-space: nowrap">.rrr rrrr rrrr rrrr</tt>
| R16
| PRNG state (r)
|-
! $94
| [[Sound#Sound Channel 2 Voice Volume|Sound Channel 2 Voice Volume]]
| style="text-align: right" | <tt style="white-space: nowrap">.... lLrR</tt>
| RW8
| Left Half (l), Full (L)
Right Half (r), Full (R)
|-
! $95
| [[Sound#Sound Test|Sound Test]]
| style="text-align: right" | <tt style="white-space: nowrap">425? ???h</tt>
| RW8
|
|-
! $96
| [[Sound#Sound Channel Output Right|Sound Channel Output Right]]
| style="text-align: right" | <tt style="white-space: nowrap">.... ..ss ssss ssss</tt>
| R16
| Sample (s)
|-
! $98
| [[Sound#Sound Channel Output Left|Sound Channel Output Left]]
| style="text-align: right" | <tt style="white-space: nowrap">.... ..ss ssss ssss</tt>
| R16
| Sample (s)
|-
! $9A
| [[Sound#Sound Channel Output Sum|Sound Channel Output Sum]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .sss ssss ssss</tt>
| R16
| Sample (s)
|-
! $9E
| [[Sound#Sound Speaker Main Volume|Sound Speaker Main Volume]]<sup>(color)</sup>
| style="text-align: right" | <tt style="white-space: nowrap">.... ..vv</tt>
| RW8
| Main volume (v)
|-
! [[SoC]]
! $A0
| [[SoC#System Control|System Control]]
| style="text-align: right" | <tt style="white-space: nowrap">t??? swcl</tt>
| RW8
| Test OK (t), ROM wait state (s), ROM width (w),
Color system (c), Boot ROM lockout (l)
|-
! rowspan="5" | [[Timers]]
! $A2
| [[Timers#Timer Control|Timer Control]]
| style="text-align: right" | <tt style="white-space: nowrap">.... VvHh</tt>
| RW8
| Horizontal enable (h), auto reload (H)
Vertical enable (v), auto reload (V)
|-
! $A4
| [[Timers#Timer Reload|Horizontal Blank Timer Reload]]
| style="text-align: right" | <tt style="white-space: nowrap">tttt tttt tttt tttt</tt>
| RW16
| Ticks (t)
|-
! $A6
| [[Timers#Timer Reload|Vertical Blank Timer Reload]]
| style="text-align: right" | <tt style="white-space: nowrap">tttt tttt tttt tttt</tt>
| RW16
| Ticks (t)
|-
! $A8
| [[Timers#Timer Counter|Horizontal Blank Timer Counter]]
| style="text-align: right" | <tt style="white-space: nowrap">tttt tttt tttt tttt</tt>
| R16
| Ticks (t)
|-
! $AA
| [[Timers#Timer Counter|Vertical Blank Timer Counter]]
| style="text-align: right" | <tt style="white-space: nowrap">tttt tttt tttt tttt</tt>
| R16
| Ticks (t)
|-
! ?
! $AC
| ?
| style="text-align: right" | <tt style="white-space: nowrap">.... ...p</tt>
| W8?
| Power off (p)
|-
! rowspan="2" | [[Interrupts]]
! rowspan="2" | $B0
| [[Interrupts#Interrupt Vector Offset|Interrupt Vector Offset]]
| style="text-align: right" | <tt style="white-space: nowrap">VVVV V...</tt>
| W8
| Vector offset (V)
|-
| [[Interrupts#Interrupt Vector Request|Interrupt Vector Request]]
| style="text-align: right" | <tt style="white-space: nowrap">vvvv vvvv</tt>
| R8
| Requested vector offset (v)
|-
! rowspan="2" | [[UART]]
! $B1
| [[UART#Serial Receive Data|Serial Receive Data]]
| style="text-align: right" | <tt style="white-space: nowrap">dddd dddd</tt>
| R8
| Receive buffer data (d)
|-
! $B1
| [[UART#Serial Transmit Data|Serial Transmit Data]]
| style="text-align: right" | <tt style="white-space: nowrap">dddd dddd</tt>
| W8
| Transmit buffer data (d)
|-
! [[Interrupts]]
! $B2
| [[Interrupts#Interrupt Enable|Interrupt Enable]]
| style="text-align: right" | <tt style="white-space: nowrap">iiii iiii</tt>
| RW8
| Interrupt index (i)
|-
! rowspan="2" | [[UART]]
! $B3
| [[UART#Serial Status|Serial Status]]
| style="text-align: right" | <tt style="white-space: nowrap">eb.. .tor</tt>
| R8
| Enable (e), Baud rate (b),
Transfer ready (t), Overrun (o), Receive ready (r)
|-
! $B3
| [[UART#Serial Control|Serial Control]]
| style="text-align: right" | <tt style="white-space: nowrap">ebO. ....</tt>
| W8
| Enable (e), Baud rate (b), Reset Overrun (O)
|-
! [[Interrupts]]
! $B4
| [[Interrupts#Interrupt Status|Interrupt Status]]
| style="text-align: right" | <tt style="white-space: nowrap">iiii iiii</tt>
| R8
| Interrupt index (i)
|-
! [[Keypad]]
! $B5
| [[Keypad|Keypad Scan]]
| style="text-align: right" | <tt style="white-space: nowrap">.iii oooo</tt>
| RW8
| Input row (i), Output column (o)
|-
! rowspan="2" | [[Interrupts]]
! $B6
| [[Interrupts#Interrupt Acknowledge|Interrupt Acknowledge]]
| style="text-align: right" | <tt style="white-space: nowrap">iiii iiii</tt>
| W8
| Interrupt index (i)
|-
! $B7
| [[Interrupts#Interrupt NMI Control|Interrupt NMI Control]]
| style="text-align: right" | <tt style="white-space: nowrap">...b ....</tt>
| RW8
| Low battery (b)
|-
! rowspan="4" | [[EEPROM|Internal EEPROM]]
! $BA
| [[EEPROM#Internal EEPROM Data|Internal EEPROM Data]]
| style="text-align: right" | <tt style="white-space: nowrap">dddd dddd dddd dddd</tt>
| RW16
| Data (d)
|-
! $BC
| [[EEPROM#Internal EEPROM Command|Internal EEPROM Command]]
|
| RW16
|
|-
! rowspan="2" | $BE
| [[EEPROM#Internal EEPROM Status|Internal EEPROM Status]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .... p... ..RD</tt>
| R16
| Protected (p), Ready (R), Done (D)
|-
| [[EEPROM#Internal EEPROM Control|Internal EEPROM Control]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .... pewr ....</tt>
| W16
| Protect (p), Erase (e), Write (w), Read (r)
|-
! [[Mapper|Cartridge]]
! $C0<br />...<br />
$FF
| Cartridge I/O
|
| RW8
| Forwarded by the SoC
|}
== I/O port routing ==
The [[NEC V30MZ]] supports 16-bit I/O port addresses. The WonderSwan SoC routes them using the following algorithm:
* If an address is between <code>$00B8</code> and <code>$00BF</code> inclusive, it is routed to the internal EEPROM control block.
* If an address is between <code>$00C0</code> and <code>$00FF</code> inclusive, it is routed to the cartride bus.
* If an address's bits <code>0</code> through <code>8</code> inclusive are between <code>$000</code> and <code>$0B7</code> inclusive, they are routed to the SoC block.
* If none of these conditions are reached, open bus is read.
On the monochrome models, as well as color models in mono emulation, open bus is always <code>0x90</code>.
ea04971e51b29e89400f1b2822f4169cf4e74d89
363
358
2024-09-13T14:38:39Z
Asie
351
/* I/O port map */ fix typo
wikitext
text/x-wiki
The WonderSwan SoC has three general blocks of I/O port accesses:
{| class="wikitable"
! From !! To !! Holder !! Width !! Speed
|-
| $00 || $B7 || WonderSwan SoC || 16-bit || 1 cycle
|-
| $B8 || $BF || Internal EEPROM control || 16-bit || 1 cycle
|-
| $C0 || $FF || Cartridge bus || 8-bit || 1<sup>(color)</sup>/2 cycles (configurable)
|}
With the exception of internal EEPROM on the ASWAN, all unaligned 16-bit accesses can be converted to two 8-bit accesses with a 1-cycle penalty.
== I/O port map ==
* Superscripts are used to mark ports specific to a given mode or platform:
** Color mode: <sup>(color)</sup>. Such ports are only accessible when color mode is enabled through port <code>$60</code>.
** WS/WSC/SC console: <sup>(WS)</sup>, <sup>(WSC)</sup>, <sup>(SC)</sup>.
* If two Bits rows are provided, the second one refers to the "Color" mode.
* The Type can be: R - readable, W - writable, L - writable before boot ROM lockout, 8/16 - width (byte/word).
{| class="wikitable"
! Category
! Port
! Description
! Bits
! Type
! Notes
|-
! rowspan="45" | [[Display]]
! $00
| [[Display#Display Control|Display Control]]
| style="text-align: right" | <tt style="white-space: nowrap">..wo Ws21</tt>
| RW8
|
|-
! $01
| [[Display#Display Background|Display Background]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .sss</tt>
<tt style="white-space: nowrap">pppp iiii</tt>
| RW8
| Shade (s)
Palette (p), Index (i)
|-
! $02
| [[Display#Current Line|Display Current Line]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll</tt>
| R8
| Line (l)
|-
! $03
| [[Display#Interrupt Line|Display Interrupt Line]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll</tt>
| RW8
| Line (l)
|-
! $04
| [[Display#Sprite Table Address|Sprite Table Address]]
| style="text-align: right" | <tt style="white-space: nowrap">...a aaaa</tt>
<tt style="white-space: nowrap">..aa aaaa</tt>
| RW8
| Address >> 9 (a)
|-
! $05
| [[Display#Sprite Table First|Sprite Table First]]
| style="text-align: right" | <tt style="white-space: nowrap">.iii iiii</tt>
| RW8
| Index (i)
|-
! $06
| [[Display#Sprite Table Count|Sprite Table Count]]
| style="text-align: right" | <tt style="white-space: nowrap">cccc cccc</tt>
| RW8
| Count (c)
|-
! $07
| [[Display#Screen Address|Screen Address]]
| style="text-align: right" | <tt style="white-space: nowrap">.222 .111</tt>
<tt style="white-space: nowrap">2222 1111</tt>
| RW8
| Screen 1 address >> 11 (1)
Screen 2 address >> 11 (2)
|-
! $08
| [[Display#Screen 2 Window|Screen 2 Window Left]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $09
| [[Display#Screen 2 Window|Screen 2 Window Top]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $0A
| [[Display#Screen 2 Window|Screen 2 Window Right]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $0B
| [[Display#Screen 2 Window|Screen 2 Window Bottom]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $0C
| [[Display#Sprite Window|Sprite Window Left]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $0D
| [[Display#Sprite Window|Sprite Window Top]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $0E
| [[Display#Sprite Window|Sprite Window Right]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $0F
| [[Display#Sprite Window|Sprite Window Bottom]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $10
| [[Display#Screen Scroll|Screen 1 Scroll X]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $11
| [[Display#Screen Scroll|Screen 1 Scroll Y]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $12
| [[Display#Screen Scroll|Screen 2 Scroll X]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $13
| [[Display#Screen Scroll|Screen 2 Scroll Y]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $14
| [[Display#LCD Control|LCD Control]]
| style="text-align: right" | <tt style="white-space: nowrap">.... ..Ce</tt>
| RW8
| Contrast (C)<sup>(WSC)</sup>, Enable (e)
|-
! $15
| [[Display#LCD Icon Control|LCD Icon Control]]
| style="text-align: right" | <tt style="white-space: nowrap">..32 1hvs</tt>
| RW8
| Auxillary 3 (3), Auxillary 2 (2), Auxillary 1 (1),
Horizontal (h), Vertical (v), Sleep (s)
|-
! $16
| [[Display#LCD Final Line|LCD Final Line]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll</tt>
| RW8
| Line (l)
|-
! $17
| [[Display#LCD Back Porch Line|LCD Back Porch Line]]<sup>(WSC)</sup>
| style="text-align: right" | <tt style="white-space: nowrap">llll llll</tt>
| RW8
| Line (l)
|-
! $1A
| [[Display#LCD Status|LCD Status]]
| style="text-align: right" | <tt style="white-space: nowrap">...v vvhs</tt>
| RW8
| Volume segments (v), Headphone segment (h), Sleep (s)
|-
! $1C
| [[Display#LCD Mono Shade LUT|LCD Mono Shade LUT 0/1]]
| style="text-align: right" | <tt style="white-space: nowrap">1111 0000</tt>
| RW8
| Shade index
|-
! $1D
| [[Display#LCD Mono Shade LUT|LCD Mono Shade LUT 2/3]]
| style="text-align: right" | <tt style="white-space: nowrap">3333 2222</tt>
| RW8
| Shade index
|-
! $1E
| [[Display#LCD Mono Shade LUT|LCD Mono Shade LUT 4/5]]
| style="text-align: right" | <tt style="white-space: nowrap">5555 4444</tt>
| RW8
| Shade index
|-
! $1F
| [[Display#LCD Mono Shade LUT|LCD Mono Shade LUT 6/7]]
| style="text-align: right" | <tt style="white-space: nowrap">7777 6666</tt>
| RW8
| Shade index
|-
! $20
| [[Display#LCD Mono Palette|LCD Mono Palette 0]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $22
| [[Display#LCD Mono Palette|LCD Mono Palette 1]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $24
| [[Display#LCD Mono Palette|LCD Mono Palette 2]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $26
| [[Display#LCD Mono Palette|LCD Mono Palette 3]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $28
| [[Display#LCD Mono Palette|LCD Mono Palette 4]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $2A
| [[Display#LCD Mono Palette|LCD Mono Palette 5]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $2C
| [[Display#LCD Mono Palette|LCD Mono Palette 6]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $2E
| [[Display#LCD Mono Palette|LCD Mono Palette 7]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $30
| [[Display#LCD Mono Palette|LCD Mono Palette 8]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $32
| [[Display#LCD Mono Palette|LCD Mono Palette 9]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $34
| [[Display#LCD Mono Palette|LCD Mono Palette 10]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $36
| [[Display#LCD Mono Palette|LCD Mono Palette 11]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $38
| [[Display#LCD Mono Palette|LCD Mono Palette 12]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $3A
| [[Display#LCD Mono Palette|LCD Mono Palette 13]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $3C
| [[Display#LCD Mono Palette|LCD Mono Palette 14]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $3E
| [[Display#LCD Mono Palette|LCD Mono Palette 15]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! rowspan="10" | [[DMA]]<sup>(color)</sup>
! $40
| [[DMA#General DMA|GDMA Source Address Low]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll llll lll.</tt>
| RW16
| Linear address, low 16 bits (l)
|-
! $42
| [[DMA#General DMA|GDMA Source Address High]]
| style="text-align: right" | <tt style="white-space: nowrap">.... hhhh</tt>
| RW8
| Linear address, high 4 bits (h)
|-
! $44
| [[DMA#General DMA|GDMA Destination Address]]
| style="text-align: right" | <tt style="white-space: nowrap">aaaa aaaa aaaa aaa.</tt>
| RW16
| IRAM address (a)
|-
! $46
| [[DMA#General DMA|GDMA Length]]
| style="text-align: right" | <tt style="white-space: nowrap">bbbb bbbb bbbb bbb.</tt>
| RW16
| Bytes (b)
|-
! $48
| [[DMA#General DMA|GDMA Control]]
| style="text-align: right" | <tt style="white-space: nowrap">ed.. ....</tt>
| RW8
| Enable (e), Decrement (d)
|-
! $4A
| [[DMA#Sound DMA|SDMA Source Address Low]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll llll llll</tt>
| RW16
| Linear address, low 16 bits (l)
|-
! $4C
| [[DMA#Sound DMA|SDMA Source Address High]]
| style="text-align: right" | <tt style="white-space: nowrap">.... hhhh</tt>
| RW8
| Linear address, high 4 bits (h)
|-
! $4E
| [[DMA#Sound DMA|SDMA Length Low]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll llll llll</tt>
| RW16
| Length, low 16 bits (l)
|-
! $50
| [[DMA#Sound DMA|SDMA Length High]]
| style="text-align: right" | <tt style="white-space: nowrap">.... hhhh</tt>
| RW8
| Length, high 4 bits (h)
|-
! $52
| [[DMA#Sound DMA|SDMA Control]]
| style="text-align: right" | <tt style="white-space: nowrap">ed.t rhff</tt>
| RW8
| Enable (e), Decrement (d), Target (t),
Repeat (r), Hold (h), Frequency (f)
|-
! rowspan="2" | [[SoC]]<sup>(color)</sup>
! $60
| [[SoC#System Control 2|System Control 2]]
| style="text-align: right" | <tt style="white-space: nowrap">c4C. i?sl</tt>
| RW8
| Color (c), 4BPP (4), Chunky (C),<br/>
Cart I/O wait state (i), SRAM wait state (s),<br/>
Cart clock speed (l).
|-
! $62
| [[SoC#System Control 3|System Control 3]]
| style="text-align: right" | <tt style="white-space: nowrap">S... ...p</tt>
| RW8
| SwanCrystal (S), Power off (p)
|-
! rowspan="4" | [[Hyper Voice]]<sup>(color)</sup>
! $64
| [[Hyper Voice#Hyper Voice Output|Hyper Voice Left Output]]
| style="text-align: right" | <tt style="white-space: nowrap">ssss ssss ssss ssss</tt>
| W16
| Raw sample (s)
|-
! $66
| [[Hyper Voice#Hyper Voice Output|Hyper Voice Right Output]]
| style="text-align: right" | <tt style="white-space: nowrap">ssss ssss ssss ssss</tt>
| W16
| Raw sample (s)
|-
! $69
| [[Hyper Voice#Hyper Voice Input|Hyper Voice Right Input]]
| style="text-align: right" | <tt style="white-space: nowrap">ssss ssss</tt>
| W8
| Sample (s)
|-
! $6A
| [[Hyper Voice#Hyper Voice Control|Hyper Voice Control]]
| style="text-align: right" | <tt style="white-space: nowrap">.mmc ???? errr ffss</tt>
| RW16
| Mask (m), Channel reset (c), Enable (e),
Rate (r), Format (f), Shift (s)
|-
! rowspan="8" | [[Display]]<sup>(SC)</sup>
! $70
| LCD Timing Configuration 1?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $71
| LCD Timing Configuration 2?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $72
| LCD Timing Configuration 3?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $73
| LCD Timing Configuration 4?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $74
| LCD Timing Configuration 5?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $75
| LCD Timing Configuration 6?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $76
| LCD Timing Configuration 7?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $77
| LCD Timing Configuration 8?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! rowspan="22" | [[Sound]]
! $80
| [[Sound#Sound Channel Frequency|Sound Channel 1 Frequency]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .ddd dddd dddd</tt>
| RW16
| Divider (d)
|-
! $82
| [[Sound#Sound Channel Frequency|Sound Channel 2 Frequency]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .ddd dddd dddd</tt>
| RW16
| Divider (d)
|-
! $84
| [[Sound#Sound Channel Frequency|Sound Channel 3 Frequency]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .ddd dddd dddd</tt>
| RW16
| Divider (d)
|-
! $86
| [[Sound#Sound Channel Frequency|Sound Channel 4 Frequency]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .ddd dddd dddd</tt>
| RW16
| Divider (d)
|-
! $88
| [[Sound#Sound Channel Volume|Sound Channel 1 Volume]]
| style="text-align: right" | <tt style="white-space: nowrap">llll rrrr</tt>
| RW8
| Left (l), Right (r)
|-
! rowspan="2" | $89
| [[Sound#Sound Channel Volume|Sound Channel 2 Volume]]
| style="text-align: right" | <tt style="white-space: nowrap">llll rrrr</tt>
| RW8
| Left (l), Right (r)
|-
| [[Sound#Sound Channel 2 Voice Sample|Sound Channel 2 Voice Sample]]
| style="text-align: right" | <tt style="white-space: nowrap">ssss ssss</tt>
| RW8
| Sample (s)
|-
! $8A
| [[Sound#Sound Channel Volume|Sound Channel 3 Volume]]
| style="text-align: right" | <tt style="white-space: nowrap">llll rrrr</tt>
| RW8
| Left (l), Right (r)
|-
! $8B
| [[Sound#Sound Channel Volume|Sound Channel 4 Volume]]
| style="text-align: right" | <tt style="white-space: nowrap">llll rrrr</tt>
| RW8
| Left (l), Right (r)
|-
! $8C
| [[Sound#Sound Channel 3 Sweep Amount|Sound Channel 3 Sweep Amount]]
| style="text-align: right" | <tt style="white-space: nowrap">vvvv vvvv</tt>
| RW8
| Value (v)
|-
! $8D
| [[Sound#Sound Channel 3 Sweep Ticks|Sound Channel 3 Sweep Ticks]]
| style="text-align: right" | <tt style="white-space: nowrap">...t tttt</tt>
| RW8
| Ticks (t)
|-
! $8E
| [[Sound#Sound Channel 4 Noise Control|Sound Channel 4 Noise Control]]
| style="text-align: right" | <tt style="white-space: nowrap">...e rttt</tt>
| RW8
| Enable (e), Reset (r), Tap (t)
|-
! $8F
| [[Sound#Sound Wavetable Address|Sound Wavetable Address]]
| style="text-align: right" | <tt style="white-space: nowrap">wwww wwww</tt>
| RW8
| Address >> 6 (w)
|-
! $90
| [[Sound#Sound Channel Control|Sound Channel Control]]
| style="text-align: right" | <tt style="white-space: nowrap">nsv. 4321</tt>
| RW8
| Channel enable (1234)
Noise (n), Sweep (s), Voice (v)
|-
! $91
| [[Sound#Sound Output Control|Sound Output Control]]
| style="text-align: right" | <tt style="white-space: nowrap">H... hrrs</tt>
| RW8
| Headphones connected (H)
Headphone output (h)
Speaker output (s), range (r)
|-
! $92
| [[Sound#Sound Channel 4 LFSR Register|Sound Channel 4 LFSR Register]]
| style="text-align: right" | <tt style="white-space: nowrap">.rrr rrrr rrrr rrrr</tt>
| R16
| PRNG state (r)
|-
! $94
| [[Sound#Sound Channel 2 Voice Volume|Sound Channel 2 Voice Volume]]
| style="text-align: right" | <tt style="white-space: nowrap">.... lLrR</tt>
| RW8
| Left Half (l), Full (L)
Right Half (r), Full (R)
|-
! $95
| [[Sound#Sound Test|Sound Test]]
| style="text-align: right" | <tt style="white-space: nowrap">425? ???h</tt>
| RW8
|
|-
! $96
| [[Sound#Sound Channel Output Right|Sound Channel Output Right]]
| style="text-align: right" | <tt style="white-space: nowrap">.... ..ss ssss ssss</tt>
| R16
| Sample (s)
|-
! $98
| [[Sound#Sound Channel Output Left|Sound Channel Output Left]]
| style="text-align: right" | <tt style="white-space: nowrap">.... ..ss ssss ssss</tt>
| R16
| Sample (s)
|-
! $9A
| [[Sound#Sound Channel Output Sum|Sound Channel Output Sum]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .sss ssss ssss</tt>
| R16
| Sample (s)
|-
! $9E
| [[Sound#Sound Speaker Main Volume|Sound Speaker Main Volume]]<sup>(color)</sup>
| style="text-align: right" | <tt style="white-space: nowrap">.... ..vv</tt>
| RW8
| Main volume (v)
|-
! [[SoC]]
! $A0
| [[SoC#System Control|System Control]]
| style="text-align: right" | <tt style="white-space: nowrap">t??? swcl</tt>
| RW8
| Test OK (t), ROM wait state (s), ROM width (w),
Color system (c), Boot ROM lockout (l)
|-
! rowspan="5" | [[Timers]]
! $A2
| [[Timers#Timer Control|Timer Control]]
| style="text-align: right" | <tt style="white-space: nowrap">.... VvHh</tt>
| RW8
| Horizontal enable (h), auto reload (H)
Vertical enable (v), auto reload (V)
|-
! $A4
| [[Timers#Timer Reload|Horizontal Blank Timer Reload]]
| style="text-align: right" | <tt style="white-space: nowrap">tttt tttt tttt tttt</tt>
| RW16
| Ticks (t)
|-
! $A6
| [[Timers#Timer Reload|Vertical Blank Timer Reload]]
| style="text-align: right" | <tt style="white-space: nowrap">tttt tttt tttt tttt</tt>
| RW16
| Ticks (t)
|-
! $A8
| [[Timers#Timer Counter|Horizontal Blank Timer Counter]]
| style="text-align: right" | <tt style="white-space: nowrap">tttt tttt tttt tttt</tt>
| R16
| Ticks (t)
|-
! $AA
| [[Timers#Timer Counter|Vertical Blank Timer Counter]]
| style="text-align: right" | <tt style="white-space: nowrap">tttt tttt tttt tttt</tt>
| R16
| Ticks (t)
|-
! ?
! $AC
| ?
| style="text-align: right" | <tt style="white-space: nowrap">.... ...p</tt>
| W8?
| Power off (p)
|-
! rowspan="2" | [[Interrupts]]
! rowspan="2" | $B0
| [[Interrupts#Interrupt Vector Offset|Interrupt Vector Offset]]
| style="text-align: right" | <tt style="white-space: nowrap">VVVV V...</tt>
| W8
| Vector offset (V)
|-
| [[Interrupts#Interrupt Vector Request|Interrupt Vector Request]]
| style="text-align: right" | <tt style="white-space: nowrap">vvvv vvvv</tt>
| R8
| Requested vector offset (v)
|-
! rowspan="2" | [[UART]]
! $B1
| [[UART#Serial Receive Data|Serial Receive Data]]
| style="text-align: right" | <tt style="white-space: nowrap">dddd dddd</tt>
| R8
| Receive buffer data (d)
|-
! $B1
| [[UART#Serial Transmit Data|Serial Transmit Data]]
| style="text-align: right" | <tt style="white-space: nowrap">dddd dddd</tt>
| W8
| Transmit buffer data (d)
|-
! [[Interrupts]]
! $B2
| [[Interrupts#Interrupt Enable|Interrupt Enable]]
| style="text-align: right" | <tt style="white-space: nowrap">iiii iiii</tt>
| RW8
| Interrupt index (i)
|-
! rowspan="2" | [[UART]]
! $B3
| [[UART#Serial Status|Serial Status]]
| style="text-align: right" | <tt style="white-space: nowrap">eb.. .tor</tt>
| R8
| Enable (e), Baud rate (b),
Transfer ready (t), Overrun (o), Receive ready (r)
|-
! $B3
| [[UART#Serial Control|Serial Control]]
| style="text-align: right" | <tt style="white-space: nowrap">ebO. ....</tt>
| W8
| Enable (e), Baud rate (b), Reset Overrun (O)
|-
! [[Interrupts]]
! $B4
| [[Interrupts#Interrupt Status|Interrupt Status]]
| style="text-align: right" | <tt style="white-space: nowrap">iiii iiii</tt>
| R8
| Interrupt index (i)
|-
! [[Keypad]]
! $B5
| [[Keypad|Keypad Scan]]
| style="text-align: right" | <tt style="white-space: nowrap">.iii oooo</tt>
| RW8
| Input row (i), Output column (o)
|-
! rowspan="2" | [[Interrupts]]
! $B6
| [[Interrupts#Interrupt Acknowledge|Interrupt Acknowledge]]
| style="text-align: right" | <tt style="white-space: nowrap">iiii iiii</tt>
| W8
| Interrupt index (i)
|-
! $B7
| [[Interrupts#Interrupt NMI Control|Interrupt NMI Control]]
| style="text-align: right" | <tt style="white-space: nowrap">...b ....</tt>
| RW8
| Low battery (b)
|-
! rowspan="4" | [[EEPROM|Internal EEPROM]]
! $BA
| [[EEPROM#Internal EEPROM Data|Internal EEPROM Data]]
| style="text-align: right" | <tt style="white-space: nowrap">dddd dddd dddd dddd</tt>
| RW16
| Data (d)
|-
! $BC
| [[EEPROM#Internal EEPROM Command|Internal EEPROM Command]]
|
| RW16
|
|-
! rowspan="2" | $BE
| [[EEPROM#Internal EEPROM Status|Internal EEPROM Status]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .... p... ..RD</tt>
| R16
| Protected (p), Ready (R), Done (D)
|-
| [[EEPROM#Internal EEPROM Control|Internal EEPROM Control]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .... pewr ....</tt>
| W16
| Protect (p), Erase (e), Write (w), Read (r)
|-
! [[Mapper|Cartridge]]
! $C0<br />...<br />
$FF
| Cartridge I/O
|
| RW8
| Forwarded by the SoC
|}
== I/O port routing ==
The [[NEC V30MZ]] supports 16-bit I/O port addresses. The WonderSwan SoC routes them using the following algorithm:
* If an address is between <code>$00B8</code> and <code>$00BF</code> inclusive, it is routed to the internal EEPROM control block.
* If an address is between <code>$00C0</code> and <code>$00FF</code> inclusive, it is routed to the cartride bus.
* If an address's bits <code>0</code> through <code>8</code> inclusive are between <code>$000</code> and <code>$0B7</code> inclusive, they are routed to the SoC block.
* If none of these conditions are reached, open bus is read.
On the monochrome models, as well as color models in mono emulation, open bus is always <code>0x90</code>.
53495ea79de8474e1b9b86fbfc23cf4ccb201029
Display
0
26
360
350
2024-09-13T14:26:40Z
Asie
351
/* LCD Status ($1A) */
wikitext
text/x-wiki
The WonderSwan's display functionality generally consists of:
* a 224x144 display clocked at ~75.47 Hz by default, capable of displaying:
** up to sixteen distinct shades of gray
** 12-bit RGB444 color<sup>(color)</sup>
* two 32x32 background layers ("screens"), capable of displaying up to 512 (1024<sup>(color)</sup>) distinct tiles,
* a sprite layer, capable of displaying up to 128 8x8 sprites (up to 32 per line),
* six LCD icons to the bottom or right of the display, usable as additional indicators.
== Components ==
=== Tiles ===
The WonderSwan can display up to 512 distinct tiles at a time, with two bits of palette index information for every pixel.
The WonderSwan Color expands this to 1024 distinct tiles for background (with 512 remaining the limit for sprites), while also introducing modes with four bits of palette index information for every pixel.
==== 2 bits per pixel, planar ====
The tiles are stored in an interleaved planar format, with two bits total for every pixel. Odd bytes store the first plane (bit 0 of each pixel), while even bytes store the second plane (bit 1 of each pixel).
<pre>
tile data (16 bytes)
01 7C 01 FC 00 C0 18 D8 18 D8 00 C0 00 00 C0 00
||
\/
plane 0 plane 1
7 bit 0 7 bit 0 full tile
---- ---- ---- ----
.... ...1 = 01 .222 22.. = 7C .22222.1
.... ...1 = 01 2222 22.. = FC 222222.1
.... .... = 00 22.. .... = C0 22......
...1 1... = 18 22.2 2... = D8 --\ 22.33...
...1 1... = 18 22.2 2... = D8 --/ 22.33...
.... .... = 00 22.. .... = C0 22......
.... .... = 00 .... .... = 00 ........
11.. .... = C0 .... .... = 00 11......
</pre>
This matches the format used by the Game Boy.
==== 4 bits per pixel, planar ====
This mode is stored in a manner similar to the 2 bits per pixel mode, but with an additional two planes for bit 2 and bit 3 of each pixel's palette index, expanding the tile data to 32 bytes.
<pre>
tile data (32 bytes)
54 32 01 00 54 32 F1 00 54 32 01 F0 54 32 F1 F0 04 02 01 00 F8 04 02 01 00 F8 04 02 00 00 F8 04
||
\/
plane 0 plane 1 plane 2 plane 3
7 bit 0 7 bit 0 7 bit 0 7 bit 0 full tile
---- ---- ---- ---- ---- ---- ---- ----
.1.1 .1.. = 54 ..22 ..2. = 32 .... ...4 = 01 .... .... = 00 .123.124
.1.1 .1.. = 54 ..22 ..2. = 32 4444 ...4 = F1 .... .... = 00 4567.124
.1.1 .1.. = 54 ..22 ..2. = 32 .... ...4 = 01 8888 .... = F0 89AB.124
.1.1 .1.. = 54 ..22 ..2. = 32 4444 ...4 = F1 8888 .... = F0 --\ CDEF.124
.... .1.. = 04 .... ..2. = 02 .... ...4 = 01 .... .... = 00 --/ .....124
1111 1... = F8 .... .2.. = 04 .... ..4. = 02 .... ...8 = 01 11111248
.... .... = 00 2222 2... = F8 .... .4.. = 04 .... ..8. = 02 2222248.
.... .... = 00 .... .... = 00 4444 4... = F8 .... .8.. = 04 444448..
</pre>
This format matches the one used by the Sega Master System and Game Gear family of consoles.
==== 4 bits per pixel, packed ====
Unlike the previous two formats, in the packed format each byte stores the complete palette index of two pixels - the high four bits store the left pixel, while the low four bits store the right pixel. Four such bytes make up a row of eight pixels from left to right.
<pre>
tile data (32 bytes)
01 23 01 24 45 67 01 24 89 AB 01 24 CD EF 01 24 00 00 01 24 11 11 12 48 22 22 24 80 44 44 48 00
||
\/
byte 0 1 2 3
bits 7-4 3-0 7-4 3-0 7-4 3-0 7-4 3-0
pixel 0 1 2 3 4 5 6 7 full tile
--- --- --- --- --- --- --- ---
. 1 = 01 2 3 = 23 . 1 = 01 2 4 = 24 .123.124 = 01 23 01 24
4 5 = 45 6 7 = 67 . 1 = 01 2 4 = 24 4567.124 = 45 67 01 24
8 9 = 89 A B = AB . 1 = 01 2 4 = 24 89AB.124 = 89 AB 01 24
C D = CD E F = EF . 1 = 01 2 4 = 24 --\ CDEF.124 = CD EF 01 24
. . = 00 . . = 00 . 1 = 01 2 4 = 24 --/ .....124 = 00 00 01 24
1 1 = 11 1 1 = 11 1 2 = 12 4 8 = 48 11111248 = 11 11 12 48
2 2 = 22 2 2 = 22 2 4 = 24 8 . = 80 2222248. = 22 22 24 80
4 4 = 44 4 4 = 44 4 8 = 48 . . = 00 444448.. = 44 44 48 00
</pre>
This format matches the one used by the Mega Drive console.
=== Palettes ===
The display system provides sixteen different palettes that can be used to color or shade tiles.
* Palettes 0-7 can be used for the two screens only;
* Palettes 8-15 can be used for both screens and sprites.
==== Mono ====
In ''mono'' modes, palettes are stored in I/O ports 0x20 through 0x3F. Each palette contains four three-bit entries, which are pointers into a global, four-bit shade lookup table:
<pre>
Palette Global shade LUT
1 ===========> 2 ==========================> 5
^ (0, 2, 4, 6) ^ (1, 3, 5, 7, 9, 11, 13, 15) ^
| | |
Palette index Value Displayed shade
</pre>
The shade value corresponds to the darkness of the pixel: shade 0 is the brightest, while shade 15 is the darkest.
==== Color ====
In ''color'' modes, palettes are stored as 16-bit words in memory addresses 0xFE00 through 0xFFFF, without additional lookup tables:
<pre>
Address
15 bit 8 7 bit 0
---- ---- ---- ----
1111 111p pppi iii.
| |||| |||
| |||+-+++-- Index in palette (0-15)
+--+++------- Palette number (0-15)
Data
15 bit 8 7 bit 0
---- ---- ---- ----
.... rrrr gggg bbbb
|||| |||| ||||
|||| |||| ++++- Blue (0-15)
|||| ++++------ Green (0-15)
++++------------ Red (0-15)
</pre>
In 2 bits per pixel color modes, palette entries 4 through 15 are not used.
==== Transparency ====
In two bit per pixel modes:
* Palettes 0-3 and 8-11 are ''opaque''. For these, index zero is treated as opaque.
* Palettes 4-7 and 12-15 are ''translucent''. For these, index zero is treated as transparent. This means that the color/shade value set to it is ignored, and only three distinct colors/shades can be used for tiles.
In four bit per pixel modes, all palettes are ''translucent''. Index zero is always treated as transparent, and fifteen different colors/shades can be used for tiles.
=== Background color ===
The background color is displayed if no ''opaque'' pixel from screens or sprites is drawn. This color is set in I/O port ''0x01'':
* In mono modes, it is set to an entry in the shade lookup table (0-7),
* In color modes, it is set to an entry in the color palette (0-255). Note that this allows you to use the first color (color zero) of any palette, which is normally ignored and assumed to be ''transparent''.
=== Screens ===
A screen is a layout of tiles. Each cell in a screen controls one 8x8 tile.
The display system can show two distinct screens simultaneously. It also supports hardware flipping of tiles, both horizontally and vertically.
The size of each screen is fixed at 32x32 cells or 256x256 pixels, while each cell is stored as a two-byte word:
<pre>
Address
15 bit 8 7 bit 0
---- ---- ---- ----
0bbb byyy yyxx xxx.
||| |||| |||| |||
||| |||| ||++-+++-- X coordinate (0-31)
||| |+++--++-------- Y coordinate (0-31)
+++-+--------------- Base address (from I/O port)
Data
15 bit 8 7 bit 0
---- ---- ---- ----
vhbp pppt tttt tttt
|||| |||| |||| ||||
|||| |||+--++++-++++- Tile index (0-511)
|||+-+++------------- Palette (0-15)
||+------------------ Tile bank (0-1) - color only
|+------------------- Horizontal flip
+-------------------- Vertical flip
</pre>
In ''color'' modes, the tile bank selects between tiles 0-511 and 512-1023.
=== Sprites ===
The display system can show up to 128 sprites at once.
Sprites are always drawn in front of Screen 1, but they can be drawn in front of or behind Screen 2.
Sprites are stored in a sprite table in the console's internal RAM. It consists of up to 128 four-byte entries, of which any sequential slice can be displayed:
<pre>
(Byte 1) (Byte 0)
15 bit 8 7 bit 0
---- ---- ---- ----
vhPi pppt tttt tttt
|||| |||| |||| ||||
|||| |||+--++++-++++- Tile index (0-511) - only tile bank 0
|||| +++------------- Palette (0-7) - mapped to screen palettes 8-15
|||+----------------- Window location - 0 = inside, 1 = outside
||+------------------ Priority - 0 = behind Screen 2, 1 = in front of Screen 2
|+------------------- Horizontal flip
+-------------------- Vertical flip
(Byte 2)
7 bit 0
---- ----
yyyy yyyy
|||| ||||
++++-++++- Y coordinate
(Byte 3)
7 bit 0
---- ----
xxxx xxxx
|||| ||||
++++-++++- X coordinate
</pre>
There is a sprite limit of 32 per scanline. This means that for each scanline, only the first 32 sprites will be drawn. Note that this includes sprites obscured by windows or outside of visible X coordinates; this list is determined solely by the Y coordinate. Between sprites themselves, earlier sprites in the list are always drawn on top of later sprites in the list.
The sprite table is copied from the console's RAM to a SoC-internal buffer every frame on line <tt>144</tt>; one word for every clock of the line, totaling 256 words (512 bytes) for 256 clocks. This internal buffer is then used for reading sprite data on the next frame.
=== Visibility priority ===
For display components, the visibility priority is as follows:
* Sprite 0, high priority
* Sprite 127, high priority
* Screen 2
* Sprite 0, low priority
* Sprite 127, low priority
* Screen 1
* Background color
=== Windows ===
Screen 2 and sprites can optionally have their drawing restricted within or outside of their specific rectangular windows.
Note that for sprites, the window is enabled globally (for all sprites), but each sprite can individually decide if it's rendered inside or outside of it.
=== Icons ===
The WonderSwan features six LCD segment icons which are displayed to the right<sup>(color)</sup> or below<sup>(mono)</sup> the main display. These are, as follows:
* Aux 3 - large circle,
* Aux 2 - medium circle,
* Aux 1 - small circle,
* Horizontal orientation,
* Vertical orientation,
* Sleep.
== Interrupts ==
The display circuit generates two interrupts of its own:
* Display Interrupt Line Match - when <code>Display Current Line</code> == <code>Display Interrupt Line</code>, at the beginning of said line.
* Display Vertical Blank - when <code>Display Current Line</code> == <code>144</code>, at the beginning of said line.
It also provides a timing source for the two Horizontal and Vertical Blank [[Timers]], which provide their own respective interrupts.
== I/O ports ==
{{Anchor|Display Control}}
=== Display Control ($00) ===
<pre>
7 bit 0
---- ----
..wo Ws21
|| ||||
|| |||+- Enable Screen 1 layer
|| ||+-- Enable Screen 2 layer
|| |+--- Enable Sprite layer
|| +---- Enable Sprite window
|+------ Screen 2 tiles are drawn (if window enabled):
| 0 = inside window,
| 1 = outside window.
+------- Enable Screen 2 window
</pre>
{{Anchor|Display Background}}
=== Display Background Color ($01) ===
<pre>
(mono) (color)
7 bit 0 7 bit 0
---- ---- ---- ----
.... .sss pppp iiii
||| |||| ||||
+++- Value |||| ++++- Index in palette (0-15)
(0-7) ++++------ Color palette (0-15)
</pre>
{{Anchor|Display Current Line}}
=== Display Current Line ($02 read) ===
The current line being drawn by the display.
Note that lines are sent to the display with a one-line delay. This matters for color palette or shade LUT manipulation; changing these values when <code>current line == 1</code> will actually affect line 0.
{{Anchor|Display Interrupt Line}}
=== Display Interrupt Line ($03) ===
The line to emit an interrupt on.
{{Anchor|Sprite Table Address}}
=== Sprite Table Address ($04) ===
<pre>
7 bit 0
---- ----
..Aa aaaa
|| ||||
|+-++++- Address (bits 9-13)
+------- Address (bit 14) - color only
</pre>
{{Anchor|Sprite Table First}}
=== Sprite Table First ($05) ===
<pre>
7 bit 0
---- ----
.iii iiii
||| ||||
+++-++++- Index of first sprite entry to draw (0-127)
</pre>
{{Anchor|Sprite Table Count}}
=== Sprite Table Count ($06) ===
<pre>
7 bit 0
---- ----
cccc cccc
|||| ||||
++++-++++- Count of sprite entries to draw (1-128)
</pre>
{{Anchor|Screen Address}}
=== Screen Address ($07) ===
<pre>
7 bit 0
---- ----
2222 1111
|||| ||||
|||| |+++- Screen 1 address (bits 11-13)
|||| +---- Screen 1 address (bit 14) - color only
|+++------ Screen 2 address (bits 11-13)
+--------- Screen 2 address (bit 14) - color only
</pre>
{{Anchor|Screen 2 Window}}
=== Screen 2 Window Left ($08) ===
=== Screen 2 Window Top ($09) ===
=== Screen 2 Window Right ($0A) ===
=== Screen 2 Window Bottom ($0B) ===
The X and Y coordinates of the Screen 2 window.
Note that all coordinates are inclusive; for example, for a 200x100 window in the top-left corner, the values should be set as follows:
* Left - 0,
* Top - 0,
* Right - 199,
* Bottom - 99.
{{Anchor|Sprite Window}}
=== Sprite Window Left ($0C) ===
=== Sprite Window Top ($0D) ===
=== Sprite Window Right ($0E) ===
=== Sprite Window Bottom ($0F) ===
The X and Y coordinates of the Sprite window.
Note that all coordinates are inclusive.
{{Anchor|Screen Scroll}}
=== Screen 1 Scroll X ($10) ===
=== Screen 1 Scroll Y ($11) ===
The X and Y coordinates that Screen 1 is scrolled by.
For example, setting Scroll X to 24 and Scroll Y to 8 will omit, in 8x8 tile units, the first three rows and the first two columns of the 32x32 screen.
=== Screen 2 Scroll X ($12) ===
=== Screen 2 Scroll Y ($13) ===
The X and Y coordinates that Screen 2 is scrolled by.
{{Anchor|LCD Control}}
=== LCD Control ($14) ===
<pre>
7 bit 0
---- ----
.... ..Ce
||
|+- LCD Enable: 0 = sleep, 1 = enabled
+-- Contrast (WSC): 0 = low, 1 = high
</pre>
{{Anchor|LCD Icon Control}}
=== LCD Icon Control ($15) ===
<pre>
7 bit 0
---- ----
..32 1hvs
|| ||||
|| |||+- Sleep
|| ||+-- Vertical orientation
|| |+--- Horizontal orientation
|| +---- Aux 1
|+------ Aux 2
+------- Aux 3
</pre>
{{Anchor|LCD Mono Shade LUT}}
=== LCD Mono Shade LUT ($1C-$1F) ===
<pre>
$1C $1D $1E $1F
7 bit 0 7 bit 0 7 bit 0 7 bit 0
---- ---- ---- ---- ---- ---- ---- ----
1111 0000 3333 2222 5555 4444 7777 6666
</pre>
{{Anchor|LCD Mono Palette}}
=== LCD Mono Palette 0..15 ($20, $21 .. $3E, $3F) ===
The monochrome palette is laid out as sixteen words:
<pre>
N+1 N
15 bit 8 7 bit 0
---- ---- ---- ----
.333 .222 .111 .000
||| ||| ||| |||
||| ||| ||| +++- Shade LUT index for color 0
||| ||| +++------ Shade LUT index for color 1
||| +++------------ Shade LUT index for color 2
+++----------------- Shade LUT index for color 3
</pre>
== Internal I/O ports ==
These I/O ports are said to be internal and not intended for use by commercial games.
{{Anchor|LCD Final Line}}
=== LCD Final Line ($16) ===
The final line preceding line counter restart and the beginning of active display. By default, this is set to 158, which equals 159 total lines per frame.
It is said setting this register to an odd value on SwanCrystal has an adverse effect to the LCD panel<ref>[http://daifukkat.su/docs/wsman/#REG_LCD_VTOTAL REG_LCD_VTOTAL - WSMan]</ref>, but the exact mechanism is unknown.
{{Anchor|LCD Back Porch Line}}
=== LCD Back Porch Line ($17, WSC only) ===
This port is available on the WonderSwan Color only - not the SwanCrystal!
The final line preceding the vertical back porch; by default, this should be set to 155.
The vertical back porch of the LCD is assumed to be 4 lines by some hardware, including IPS mods, as well as the official "TV Swan" capture device. Given that the first visible line is sent to the LCD on the display's line 1, this should be generally set to <code>LCD Final Line - 3</code>.
Conversely, it is said moving this value closer to vertical blank improves LCD visibility<ref>[http://daifukkat.su/docs/wsman/#REG_LCD_VSYNC REG_LCD_VSYNC - WSMan]</ref>, but the exact mechanism is unknown.
{{Anchor|LCD Status}}
=== LCD Status ($1A) ===
<pre>
7 bit 0
---- ----
...v vvhs
| ||||
| |||+- LCD sleep: 0 = no, 1 = sleep
| ||+-- Headphone segment
| ||
| || Volume segments:
| |+--- - Volume B (medium, high)
| +---- - Volume A (low, high)
+------ - Speaker
</pre>
The LCD sleep bit is writable. The remaining bits are read-only.
The volume and headphone segments are enabled when pressing the SOUND button, according to this algorithm:
* If headphones are plugged in, enable the Headphone segment.
* If headphones are not plugged in, enable the Speaker segment and the following Volume segments:
** Volume level 0: None
** Volume level 1: A
** Volume level 2: B
** Volume level 3: A, B
* Hide all visible segments after 128 frames.
TODO: This documents the WonderSwan Color. The specifics probably work differently on the mono WonderSwan.
=== TFT LCD Configuration ($70, $71, $72, $73, $74, $75, $76, $77 SwanCrystal only) ===
These eight bytes are read from internal EEPROM and configure unknown aspects of the console's TFT LCD panel.
They are only writable while the [[Boot ROM]] is unlocked - locking has the side effect of making them read-only.
== Notes ==
<references />
f537356c0174f36161e11d0c4a1c3f5ede2db060
361
360
2024-09-13T14:27:42Z
Asie
351
/* LCD Control ($14) */
wikitext
text/x-wiki
The WonderSwan's display functionality generally consists of:
* a 224x144 display clocked at ~75.47 Hz by default, capable of displaying:
** up to sixteen distinct shades of gray
** 12-bit RGB444 color<sup>(color)</sup>
* two 32x32 background layers ("screens"), capable of displaying up to 512 (1024<sup>(color)</sup>) distinct tiles,
* a sprite layer, capable of displaying up to 128 8x8 sprites (up to 32 per line),
* six LCD icons to the bottom or right of the display, usable as additional indicators.
== Components ==
=== Tiles ===
The WonderSwan can display up to 512 distinct tiles at a time, with two bits of palette index information for every pixel.
The WonderSwan Color expands this to 1024 distinct tiles for background (with 512 remaining the limit for sprites), while also introducing modes with four bits of palette index information for every pixel.
==== 2 bits per pixel, planar ====
The tiles are stored in an interleaved planar format, with two bits total for every pixel. Odd bytes store the first plane (bit 0 of each pixel), while even bytes store the second plane (bit 1 of each pixel).
<pre>
tile data (16 bytes)
01 7C 01 FC 00 C0 18 D8 18 D8 00 C0 00 00 C0 00
||
\/
plane 0 plane 1
7 bit 0 7 bit 0 full tile
---- ---- ---- ----
.... ...1 = 01 .222 22.. = 7C .22222.1
.... ...1 = 01 2222 22.. = FC 222222.1
.... .... = 00 22.. .... = C0 22......
...1 1... = 18 22.2 2... = D8 --\ 22.33...
...1 1... = 18 22.2 2... = D8 --/ 22.33...
.... .... = 00 22.. .... = C0 22......
.... .... = 00 .... .... = 00 ........
11.. .... = C0 .... .... = 00 11......
</pre>
This matches the format used by the Game Boy.
==== 4 bits per pixel, planar ====
This mode is stored in a manner similar to the 2 bits per pixel mode, but with an additional two planes for bit 2 and bit 3 of each pixel's palette index, expanding the tile data to 32 bytes.
<pre>
tile data (32 bytes)
54 32 01 00 54 32 F1 00 54 32 01 F0 54 32 F1 F0 04 02 01 00 F8 04 02 01 00 F8 04 02 00 00 F8 04
||
\/
plane 0 plane 1 plane 2 plane 3
7 bit 0 7 bit 0 7 bit 0 7 bit 0 full tile
---- ---- ---- ---- ---- ---- ---- ----
.1.1 .1.. = 54 ..22 ..2. = 32 .... ...4 = 01 .... .... = 00 .123.124
.1.1 .1.. = 54 ..22 ..2. = 32 4444 ...4 = F1 .... .... = 00 4567.124
.1.1 .1.. = 54 ..22 ..2. = 32 .... ...4 = 01 8888 .... = F0 89AB.124
.1.1 .1.. = 54 ..22 ..2. = 32 4444 ...4 = F1 8888 .... = F0 --\ CDEF.124
.... .1.. = 04 .... ..2. = 02 .... ...4 = 01 .... .... = 00 --/ .....124
1111 1... = F8 .... .2.. = 04 .... ..4. = 02 .... ...8 = 01 11111248
.... .... = 00 2222 2... = F8 .... .4.. = 04 .... ..8. = 02 2222248.
.... .... = 00 .... .... = 00 4444 4... = F8 .... .8.. = 04 444448..
</pre>
This format matches the one used by the Sega Master System and Game Gear family of consoles.
==== 4 bits per pixel, packed ====
Unlike the previous two formats, in the packed format each byte stores the complete palette index of two pixels - the high four bits store the left pixel, while the low four bits store the right pixel. Four such bytes make up a row of eight pixels from left to right.
<pre>
tile data (32 bytes)
01 23 01 24 45 67 01 24 89 AB 01 24 CD EF 01 24 00 00 01 24 11 11 12 48 22 22 24 80 44 44 48 00
||
\/
byte 0 1 2 3
bits 7-4 3-0 7-4 3-0 7-4 3-0 7-4 3-0
pixel 0 1 2 3 4 5 6 7 full tile
--- --- --- --- --- --- --- ---
. 1 = 01 2 3 = 23 . 1 = 01 2 4 = 24 .123.124 = 01 23 01 24
4 5 = 45 6 7 = 67 . 1 = 01 2 4 = 24 4567.124 = 45 67 01 24
8 9 = 89 A B = AB . 1 = 01 2 4 = 24 89AB.124 = 89 AB 01 24
C D = CD E F = EF . 1 = 01 2 4 = 24 --\ CDEF.124 = CD EF 01 24
. . = 00 . . = 00 . 1 = 01 2 4 = 24 --/ .....124 = 00 00 01 24
1 1 = 11 1 1 = 11 1 2 = 12 4 8 = 48 11111248 = 11 11 12 48
2 2 = 22 2 2 = 22 2 4 = 24 8 . = 80 2222248. = 22 22 24 80
4 4 = 44 4 4 = 44 4 8 = 48 . . = 00 444448.. = 44 44 48 00
</pre>
This format matches the one used by the Mega Drive console.
=== Palettes ===
The display system provides sixteen different palettes that can be used to color or shade tiles.
* Palettes 0-7 can be used for the two screens only;
* Palettes 8-15 can be used for both screens and sprites.
==== Mono ====
In ''mono'' modes, palettes are stored in I/O ports 0x20 through 0x3F. Each palette contains four three-bit entries, which are pointers into a global, four-bit shade lookup table:
<pre>
Palette Global shade LUT
1 ===========> 2 ==========================> 5
^ (0, 2, 4, 6) ^ (1, 3, 5, 7, 9, 11, 13, 15) ^
| | |
Palette index Value Displayed shade
</pre>
The shade value corresponds to the darkness of the pixel: shade 0 is the brightest, while shade 15 is the darkest.
==== Color ====
In ''color'' modes, palettes are stored as 16-bit words in memory addresses 0xFE00 through 0xFFFF, without additional lookup tables:
<pre>
Address
15 bit 8 7 bit 0
---- ---- ---- ----
1111 111p pppi iii.
| |||| |||
| |||+-+++-- Index in palette (0-15)
+--+++------- Palette number (0-15)
Data
15 bit 8 7 bit 0
---- ---- ---- ----
.... rrrr gggg bbbb
|||| |||| ||||
|||| |||| ++++- Blue (0-15)
|||| ++++------ Green (0-15)
++++------------ Red (0-15)
</pre>
In 2 bits per pixel color modes, palette entries 4 through 15 are not used.
==== Transparency ====
In two bit per pixel modes:
* Palettes 0-3 and 8-11 are ''opaque''. For these, index zero is treated as opaque.
* Palettes 4-7 and 12-15 are ''translucent''. For these, index zero is treated as transparent. This means that the color/shade value set to it is ignored, and only three distinct colors/shades can be used for tiles.
In four bit per pixel modes, all palettes are ''translucent''. Index zero is always treated as transparent, and fifteen different colors/shades can be used for tiles.
=== Background color ===
The background color is displayed if no ''opaque'' pixel from screens or sprites is drawn. This color is set in I/O port ''0x01'':
* In mono modes, it is set to an entry in the shade lookup table (0-7),
* In color modes, it is set to an entry in the color palette (0-255). Note that this allows you to use the first color (color zero) of any palette, which is normally ignored and assumed to be ''transparent''.
=== Screens ===
A screen is a layout of tiles. Each cell in a screen controls one 8x8 tile.
The display system can show two distinct screens simultaneously. It also supports hardware flipping of tiles, both horizontally and vertically.
The size of each screen is fixed at 32x32 cells or 256x256 pixels, while each cell is stored as a two-byte word:
<pre>
Address
15 bit 8 7 bit 0
---- ---- ---- ----
0bbb byyy yyxx xxx.
||| |||| |||| |||
||| |||| ||++-+++-- X coordinate (0-31)
||| |+++--++-------- Y coordinate (0-31)
+++-+--------------- Base address (from I/O port)
Data
15 bit 8 7 bit 0
---- ---- ---- ----
vhbp pppt tttt tttt
|||| |||| |||| ||||
|||| |||+--++++-++++- Tile index (0-511)
|||+-+++------------- Palette (0-15)
||+------------------ Tile bank (0-1) - color only
|+------------------- Horizontal flip
+-------------------- Vertical flip
</pre>
In ''color'' modes, the tile bank selects between tiles 0-511 and 512-1023.
=== Sprites ===
The display system can show up to 128 sprites at once.
Sprites are always drawn in front of Screen 1, but they can be drawn in front of or behind Screen 2.
Sprites are stored in a sprite table in the console's internal RAM. It consists of up to 128 four-byte entries, of which any sequential slice can be displayed:
<pre>
(Byte 1) (Byte 0)
15 bit 8 7 bit 0
---- ---- ---- ----
vhPi pppt tttt tttt
|||| |||| |||| ||||
|||| |||+--++++-++++- Tile index (0-511) - only tile bank 0
|||| +++------------- Palette (0-7) - mapped to screen palettes 8-15
|||+----------------- Window location - 0 = inside, 1 = outside
||+------------------ Priority - 0 = behind Screen 2, 1 = in front of Screen 2
|+------------------- Horizontal flip
+-------------------- Vertical flip
(Byte 2)
7 bit 0
---- ----
yyyy yyyy
|||| ||||
++++-++++- Y coordinate
(Byte 3)
7 bit 0
---- ----
xxxx xxxx
|||| ||||
++++-++++- X coordinate
</pre>
There is a sprite limit of 32 per scanline. This means that for each scanline, only the first 32 sprites will be drawn. Note that this includes sprites obscured by windows or outside of visible X coordinates; this list is determined solely by the Y coordinate. Between sprites themselves, earlier sprites in the list are always drawn on top of later sprites in the list.
The sprite table is copied from the console's RAM to a SoC-internal buffer every frame on line <tt>144</tt>; one word for every clock of the line, totaling 256 words (512 bytes) for 256 clocks. This internal buffer is then used for reading sprite data on the next frame.
=== Visibility priority ===
For display components, the visibility priority is as follows:
* Sprite 0, high priority
* Sprite 127, high priority
* Screen 2
* Sprite 0, low priority
* Sprite 127, low priority
* Screen 1
* Background color
=== Windows ===
Screen 2 and sprites can optionally have their drawing restricted within or outside of their specific rectangular windows.
Note that for sprites, the window is enabled globally (for all sprites), but each sprite can individually decide if it's rendered inside or outside of it.
=== Icons ===
The WonderSwan features six LCD segment icons which are displayed to the right<sup>(color)</sup> or below<sup>(mono)</sup> the main display. These are, as follows:
* Aux 3 - large circle,
* Aux 2 - medium circle,
* Aux 1 - small circle,
* Horizontal orientation,
* Vertical orientation,
* Sleep.
== Interrupts ==
The display circuit generates two interrupts of its own:
* Display Interrupt Line Match - when <code>Display Current Line</code> == <code>Display Interrupt Line</code>, at the beginning of said line.
* Display Vertical Blank - when <code>Display Current Line</code> == <code>144</code>, at the beginning of said line.
It also provides a timing source for the two Horizontal and Vertical Blank [[Timers]], which provide their own respective interrupts.
== I/O ports ==
{{Anchor|Display Control}}
=== Display Control ($00) ===
<pre>
7 bit 0
---- ----
..wo Ws21
|| ||||
|| |||+- Enable Screen 1 layer
|| ||+-- Enable Screen 2 layer
|| |+--- Enable Sprite layer
|| +---- Enable Sprite window
|+------ Screen 2 tiles are drawn (if window enabled):
| 0 = inside window,
| 1 = outside window.
+------- Enable Screen 2 window
</pre>
{{Anchor|Display Background}}
=== Display Background Color ($01) ===
<pre>
(mono) (color)
7 bit 0 7 bit 0
---- ---- ---- ----
.... .sss pppp iiii
||| |||| ||||
+++- Value |||| ++++- Index in palette (0-15)
(0-7) ++++------ Color palette (0-15)
</pre>
{{Anchor|Display Current Line}}
=== Display Current Line ($02 read) ===
The current line being drawn by the display.
Note that lines are sent to the display with a one-line delay. This matters for color palette or shade LUT manipulation; changing these values when <code>current line == 1</code> will actually affect line 0.
{{Anchor|Display Interrupt Line}}
=== Display Interrupt Line ($03) ===
The line to emit an interrupt on.
{{Anchor|Sprite Table Address}}
=== Sprite Table Address ($04) ===
<pre>
7 bit 0
---- ----
..Aa aaaa
|| ||||
|+-++++- Address (bits 9-13)
+------- Address (bit 14) - color only
</pre>
{{Anchor|Sprite Table First}}
=== Sprite Table First ($05) ===
<pre>
7 bit 0
---- ----
.iii iiii
||| ||||
+++-++++- Index of first sprite entry to draw (0-127)
</pre>
{{Anchor|Sprite Table Count}}
=== Sprite Table Count ($06) ===
<pre>
7 bit 0
---- ----
cccc cccc
|||| ||||
++++-++++- Count of sprite entries to draw (1-128)
</pre>
{{Anchor|Screen Address}}
=== Screen Address ($07) ===
<pre>
7 bit 0
---- ----
2222 1111
|||| ||||
|||| |+++- Screen 1 address (bits 11-13)
|||| +---- Screen 1 address (bit 14) - color only
|+++------ Screen 2 address (bits 11-13)
+--------- Screen 2 address (bit 14) - color only
</pre>
{{Anchor|Screen 2 Window}}
=== Screen 2 Window Left ($08) ===
=== Screen 2 Window Top ($09) ===
=== Screen 2 Window Right ($0A) ===
=== Screen 2 Window Bottom ($0B) ===
The X and Y coordinates of the Screen 2 window.
Note that all coordinates are inclusive; for example, for a 200x100 window in the top-left corner, the values should be set as follows:
* Left - 0,
* Top - 0,
* Right - 199,
* Bottom - 99.
{{Anchor|Sprite Window}}
=== Sprite Window Left ($0C) ===
=== Sprite Window Top ($0D) ===
=== Sprite Window Right ($0E) ===
=== Sprite Window Bottom ($0F) ===
The X and Y coordinates of the Sprite window.
Note that all coordinates are inclusive.
{{Anchor|Screen Scroll}}
=== Screen 1 Scroll X ($10) ===
=== Screen 1 Scroll Y ($11) ===
The X and Y coordinates that Screen 1 is scrolled by.
For example, setting Scroll X to 24 and Scroll Y to 8 will omit, in 8x8 tile units, the first three rows and the first two columns of the 32x32 screen.
=== Screen 2 Scroll X ($12) ===
=== Screen 2 Scroll Y ($13) ===
The X and Y coordinates that Screen 2 is scrolled by.
{{Anchor|LCD Control}}
=== LCD Control ($14) ===
<pre>
7 bit 0
---- ----
.... ..Ce
||
|+- LCD enable: 0 = sleep, 1 = enabled
+-- Contrast (WSC): 0 = low, 1 = high
</pre>
The LCD enable bit controls whether or not the LCD screen is displaying graphics; if sleeping, it displays nothing (all white). Note that segments continue displaying regardless of this configuration.
Note that port $1A also provides an LCD sleep bit; the display will be disabled in the same way if any of those bits are set to "sleep".
{{Anchor|LCD Icon Control}}
=== LCD Icon Control ($15) ===
<pre>
7 bit 0
---- ----
..32 1hvs
|| ||||
|| |||+- Sleep
|| ||+-- Vertical orientation
|| |+--- Horizontal orientation
|| +---- Aux 1
|+------ Aux 2
+------- Aux 3
</pre>
{{Anchor|LCD Mono Shade LUT}}
=== LCD Mono Shade LUT ($1C-$1F) ===
<pre>
$1C $1D $1E $1F
7 bit 0 7 bit 0 7 bit 0 7 bit 0
---- ---- ---- ---- ---- ---- ---- ----
1111 0000 3333 2222 5555 4444 7777 6666
</pre>
{{Anchor|LCD Mono Palette}}
=== LCD Mono Palette 0..15 ($20, $21 .. $3E, $3F) ===
The monochrome palette is laid out as sixteen words:
<pre>
N+1 N
15 bit 8 7 bit 0
---- ---- ---- ----
.333 .222 .111 .000
||| ||| ||| |||
||| ||| ||| +++- Shade LUT index for color 0
||| ||| +++------ Shade LUT index for color 1
||| +++------------ Shade LUT index for color 2
+++----------------- Shade LUT index for color 3
</pre>
== Internal I/O ports ==
These I/O ports are said to be internal and not intended for use by commercial games.
{{Anchor|LCD Final Line}}
=== LCD Final Line ($16) ===
The final line preceding line counter restart and the beginning of active display. By default, this is set to 158, which equals 159 total lines per frame.
It is said setting this register to an odd value on SwanCrystal has an adverse effect to the LCD panel<ref>[http://daifukkat.su/docs/wsman/#REG_LCD_VTOTAL REG_LCD_VTOTAL - WSMan]</ref>, but the exact mechanism is unknown.
{{Anchor|LCD Back Porch Line}}
=== LCD Back Porch Line ($17, WSC only) ===
This port is available on the WonderSwan Color only - not the SwanCrystal!
The final line preceding the vertical back porch; by default, this should be set to 155.
The vertical back porch of the LCD is assumed to be 4 lines by some hardware, including IPS mods, as well as the official "TV Swan" capture device. Given that the first visible line is sent to the LCD on the display's line 1, this should be generally set to <code>LCD Final Line - 3</code>.
Conversely, it is said moving this value closer to vertical blank improves LCD visibility<ref>[http://daifukkat.su/docs/wsman/#REG_LCD_VSYNC REG_LCD_VSYNC - WSMan]</ref>, but the exact mechanism is unknown.
{{Anchor|LCD Status}}
=== LCD Status ($1A) ===
<pre>
7 bit 0
---- ----
...v vvhs
| ||||
| |||+- LCD sleep: 0 = no, 1 = sleep
| ||+-- Headphone segment
| ||
| || Volume segments:
| |+--- - Volume B (medium, high)
| +---- - Volume A (low, high)
+------ - Speaker
</pre>
The LCD sleep bit is writable. The remaining bits are read-only.
The volume and headphone segments are enabled when pressing the SOUND button, according to this algorithm:
* If headphones are plugged in, enable the Headphone segment.
* If headphones are not plugged in, enable the Speaker segment and the following Volume segments:
** Volume level 0: None
** Volume level 1: A
** Volume level 2: B
** Volume level 3: A, B
* Hide all visible segments after 128 frames.
TODO: This documents the WonderSwan Color. The specifics probably work differently on the mono WonderSwan.
=== TFT LCD Configuration ($70, $71, $72, $73, $74, $75, $76, $77 SwanCrystal only) ===
These eight bytes are read from internal EEPROM and configure unknown aspects of the console's TFT LCD panel.
They are only writable while the [[Boot ROM]] is unlocked - locking has the side effect of making them read-only.
== Notes ==
<references />
fb84b7419a0fc1d7d5851f69005e552eb64c53a5
362
361
2024-09-13T14:34:25Z
Asie
351
/* LCD Status ($1A) */
wikitext
text/x-wiki
The WonderSwan's display functionality generally consists of:
* a 224x144 display clocked at ~75.47 Hz by default, capable of displaying:
** up to sixteen distinct shades of gray
** 12-bit RGB444 color<sup>(color)</sup>
* two 32x32 background layers ("screens"), capable of displaying up to 512 (1024<sup>(color)</sup>) distinct tiles,
* a sprite layer, capable of displaying up to 128 8x8 sprites (up to 32 per line),
* six LCD icons to the bottom or right of the display, usable as additional indicators.
== Components ==
=== Tiles ===
The WonderSwan can display up to 512 distinct tiles at a time, with two bits of palette index information for every pixel.
The WonderSwan Color expands this to 1024 distinct tiles for background (with 512 remaining the limit for sprites), while also introducing modes with four bits of palette index information for every pixel.
==== 2 bits per pixel, planar ====
The tiles are stored in an interleaved planar format, with two bits total for every pixel. Odd bytes store the first plane (bit 0 of each pixel), while even bytes store the second plane (bit 1 of each pixel).
<pre>
tile data (16 bytes)
01 7C 01 FC 00 C0 18 D8 18 D8 00 C0 00 00 C0 00
||
\/
plane 0 plane 1
7 bit 0 7 bit 0 full tile
---- ---- ---- ----
.... ...1 = 01 .222 22.. = 7C .22222.1
.... ...1 = 01 2222 22.. = FC 222222.1
.... .... = 00 22.. .... = C0 22......
...1 1... = 18 22.2 2... = D8 --\ 22.33...
...1 1... = 18 22.2 2... = D8 --/ 22.33...
.... .... = 00 22.. .... = C0 22......
.... .... = 00 .... .... = 00 ........
11.. .... = C0 .... .... = 00 11......
</pre>
This matches the format used by the Game Boy.
==== 4 bits per pixel, planar ====
This mode is stored in a manner similar to the 2 bits per pixel mode, but with an additional two planes for bit 2 and bit 3 of each pixel's palette index, expanding the tile data to 32 bytes.
<pre>
tile data (32 bytes)
54 32 01 00 54 32 F1 00 54 32 01 F0 54 32 F1 F0 04 02 01 00 F8 04 02 01 00 F8 04 02 00 00 F8 04
||
\/
plane 0 plane 1 plane 2 plane 3
7 bit 0 7 bit 0 7 bit 0 7 bit 0 full tile
---- ---- ---- ---- ---- ---- ---- ----
.1.1 .1.. = 54 ..22 ..2. = 32 .... ...4 = 01 .... .... = 00 .123.124
.1.1 .1.. = 54 ..22 ..2. = 32 4444 ...4 = F1 .... .... = 00 4567.124
.1.1 .1.. = 54 ..22 ..2. = 32 .... ...4 = 01 8888 .... = F0 89AB.124
.1.1 .1.. = 54 ..22 ..2. = 32 4444 ...4 = F1 8888 .... = F0 --\ CDEF.124
.... .1.. = 04 .... ..2. = 02 .... ...4 = 01 .... .... = 00 --/ .....124
1111 1... = F8 .... .2.. = 04 .... ..4. = 02 .... ...8 = 01 11111248
.... .... = 00 2222 2... = F8 .... .4.. = 04 .... ..8. = 02 2222248.
.... .... = 00 .... .... = 00 4444 4... = F8 .... .8.. = 04 444448..
</pre>
This format matches the one used by the Sega Master System and Game Gear family of consoles.
==== 4 bits per pixel, packed ====
Unlike the previous two formats, in the packed format each byte stores the complete palette index of two pixels - the high four bits store the left pixel, while the low four bits store the right pixel. Four such bytes make up a row of eight pixels from left to right.
<pre>
tile data (32 bytes)
01 23 01 24 45 67 01 24 89 AB 01 24 CD EF 01 24 00 00 01 24 11 11 12 48 22 22 24 80 44 44 48 00
||
\/
byte 0 1 2 3
bits 7-4 3-0 7-4 3-0 7-4 3-0 7-4 3-0
pixel 0 1 2 3 4 5 6 7 full tile
--- --- --- --- --- --- --- ---
. 1 = 01 2 3 = 23 . 1 = 01 2 4 = 24 .123.124 = 01 23 01 24
4 5 = 45 6 7 = 67 . 1 = 01 2 4 = 24 4567.124 = 45 67 01 24
8 9 = 89 A B = AB . 1 = 01 2 4 = 24 89AB.124 = 89 AB 01 24
C D = CD E F = EF . 1 = 01 2 4 = 24 --\ CDEF.124 = CD EF 01 24
. . = 00 . . = 00 . 1 = 01 2 4 = 24 --/ .....124 = 00 00 01 24
1 1 = 11 1 1 = 11 1 2 = 12 4 8 = 48 11111248 = 11 11 12 48
2 2 = 22 2 2 = 22 2 4 = 24 8 . = 80 2222248. = 22 22 24 80
4 4 = 44 4 4 = 44 4 8 = 48 . . = 00 444448.. = 44 44 48 00
</pre>
This format matches the one used by the Mega Drive console.
=== Palettes ===
The display system provides sixteen different palettes that can be used to color or shade tiles.
* Palettes 0-7 can be used for the two screens only;
* Palettes 8-15 can be used for both screens and sprites.
==== Mono ====
In ''mono'' modes, palettes are stored in I/O ports 0x20 through 0x3F. Each palette contains four three-bit entries, which are pointers into a global, four-bit shade lookup table:
<pre>
Palette Global shade LUT
1 ===========> 2 ==========================> 5
^ (0, 2, 4, 6) ^ (1, 3, 5, 7, 9, 11, 13, 15) ^
| | |
Palette index Value Displayed shade
</pre>
The shade value corresponds to the darkness of the pixel: shade 0 is the brightest, while shade 15 is the darkest.
==== Color ====
In ''color'' modes, palettes are stored as 16-bit words in memory addresses 0xFE00 through 0xFFFF, without additional lookup tables:
<pre>
Address
15 bit 8 7 bit 0
---- ---- ---- ----
1111 111p pppi iii.
| |||| |||
| |||+-+++-- Index in palette (0-15)
+--+++------- Palette number (0-15)
Data
15 bit 8 7 bit 0
---- ---- ---- ----
.... rrrr gggg bbbb
|||| |||| ||||
|||| |||| ++++- Blue (0-15)
|||| ++++------ Green (0-15)
++++------------ Red (0-15)
</pre>
In 2 bits per pixel color modes, palette entries 4 through 15 are not used.
==== Transparency ====
In two bit per pixel modes:
* Palettes 0-3 and 8-11 are ''opaque''. For these, index zero is treated as opaque.
* Palettes 4-7 and 12-15 are ''translucent''. For these, index zero is treated as transparent. This means that the color/shade value set to it is ignored, and only three distinct colors/shades can be used for tiles.
In four bit per pixel modes, all palettes are ''translucent''. Index zero is always treated as transparent, and fifteen different colors/shades can be used for tiles.
=== Background color ===
The background color is displayed if no ''opaque'' pixel from screens or sprites is drawn. This color is set in I/O port ''0x01'':
* In mono modes, it is set to an entry in the shade lookup table (0-7),
* In color modes, it is set to an entry in the color palette (0-255). Note that this allows you to use the first color (color zero) of any palette, which is normally ignored and assumed to be ''transparent''.
=== Screens ===
A screen is a layout of tiles. Each cell in a screen controls one 8x8 tile.
The display system can show two distinct screens simultaneously. It also supports hardware flipping of tiles, both horizontally and vertically.
The size of each screen is fixed at 32x32 cells or 256x256 pixels, while each cell is stored as a two-byte word:
<pre>
Address
15 bit 8 7 bit 0
---- ---- ---- ----
0bbb byyy yyxx xxx.
||| |||| |||| |||
||| |||| ||++-+++-- X coordinate (0-31)
||| |+++--++-------- Y coordinate (0-31)
+++-+--------------- Base address (from I/O port)
Data
15 bit 8 7 bit 0
---- ---- ---- ----
vhbp pppt tttt tttt
|||| |||| |||| ||||
|||| |||+--++++-++++- Tile index (0-511)
|||+-+++------------- Palette (0-15)
||+------------------ Tile bank (0-1) - color only
|+------------------- Horizontal flip
+-------------------- Vertical flip
</pre>
In ''color'' modes, the tile bank selects between tiles 0-511 and 512-1023.
=== Sprites ===
The display system can show up to 128 sprites at once.
Sprites are always drawn in front of Screen 1, but they can be drawn in front of or behind Screen 2.
Sprites are stored in a sprite table in the console's internal RAM. It consists of up to 128 four-byte entries, of which any sequential slice can be displayed:
<pre>
(Byte 1) (Byte 0)
15 bit 8 7 bit 0
---- ---- ---- ----
vhPi pppt tttt tttt
|||| |||| |||| ||||
|||| |||+--++++-++++- Tile index (0-511) - only tile bank 0
|||| +++------------- Palette (0-7) - mapped to screen palettes 8-15
|||+----------------- Window location - 0 = inside, 1 = outside
||+------------------ Priority - 0 = behind Screen 2, 1 = in front of Screen 2
|+------------------- Horizontal flip
+-------------------- Vertical flip
(Byte 2)
7 bit 0
---- ----
yyyy yyyy
|||| ||||
++++-++++- Y coordinate
(Byte 3)
7 bit 0
---- ----
xxxx xxxx
|||| ||||
++++-++++- X coordinate
</pre>
There is a sprite limit of 32 per scanline. This means that for each scanline, only the first 32 sprites will be drawn. Note that this includes sprites obscured by windows or outside of visible X coordinates; this list is determined solely by the Y coordinate. Between sprites themselves, earlier sprites in the list are always drawn on top of later sprites in the list.
The sprite table is copied from the console's RAM to a SoC-internal buffer every frame on line <tt>144</tt>; one word for every clock of the line, totaling 256 words (512 bytes) for 256 clocks. This internal buffer is then used for reading sprite data on the next frame.
=== Visibility priority ===
For display components, the visibility priority is as follows:
* Sprite 0, high priority
* Sprite 127, high priority
* Screen 2
* Sprite 0, low priority
* Sprite 127, low priority
* Screen 1
* Background color
=== Windows ===
Screen 2 and sprites can optionally have their drawing restricted within or outside of their specific rectangular windows.
Note that for sprites, the window is enabled globally (for all sprites), but each sprite can individually decide if it's rendered inside or outside of it.
=== Icons ===
The WonderSwan features six LCD segment icons which are displayed to the right<sup>(color)</sup> or below<sup>(mono)</sup> the main display. These are, as follows:
* Aux 3 - large circle,
* Aux 2 - medium circle,
* Aux 1 - small circle,
* Horizontal orientation,
* Vertical orientation,
* Sleep.
== Interrupts ==
The display circuit generates two interrupts of its own:
* Display Interrupt Line Match - when <code>Display Current Line</code> == <code>Display Interrupt Line</code>, at the beginning of said line.
* Display Vertical Blank - when <code>Display Current Line</code> == <code>144</code>, at the beginning of said line.
It also provides a timing source for the two Horizontal and Vertical Blank [[Timers]], which provide their own respective interrupts.
== I/O ports ==
{{Anchor|Display Control}}
=== Display Control ($00) ===
<pre>
7 bit 0
---- ----
..wo Ws21
|| ||||
|| |||+- Enable Screen 1 layer
|| ||+-- Enable Screen 2 layer
|| |+--- Enable Sprite layer
|| +---- Enable Sprite window
|+------ Screen 2 tiles are drawn (if window enabled):
| 0 = inside window,
| 1 = outside window.
+------- Enable Screen 2 window
</pre>
{{Anchor|Display Background}}
=== Display Background Color ($01) ===
<pre>
(mono) (color)
7 bit 0 7 bit 0
---- ---- ---- ----
.... .sss pppp iiii
||| |||| ||||
+++- Value |||| ++++- Index in palette (0-15)
(0-7) ++++------ Color palette (0-15)
</pre>
{{Anchor|Display Current Line}}
=== Display Current Line ($02 read) ===
The current line being drawn by the display.
Note that lines are sent to the display with a one-line delay. This matters for color palette or shade LUT manipulation; changing these values when <code>current line == 1</code> will actually affect line 0.
{{Anchor|Display Interrupt Line}}
=== Display Interrupt Line ($03) ===
The line to emit an interrupt on.
{{Anchor|Sprite Table Address}}
=== Sprite Table Address ($04) ===
<pre>
7 bit 0
---- ----
..Aa aaaa
|| ||||
|+-++++- Address (bits 9-13)
+------- Address (bit 14) - color only
</pre>
{{Anchor|Sprite Table First}}
=== Sprite Table First ($05) ===
<pre>
7 bit 0
---- ----
.iii iiii
||| ||||
+++-++++- Index of first sprite entry to draw (0-127)
</pre>
{{Anchor|Sprite Table Count}}
=== Sprite Table Count ($06) ===
<pre>
7 bit 0
---- ----
cccc cccc
|||| ||||
++++-++++- Count of sprite entries to draw (1-128)
</pre>
{{Anchor|Screen Address}}
=== Screen Address ($07) ===
<pre>
7 bit 0
---- ----
2222 1111
|||| ||||
|||| |+++- Screen 1 address (bits 11-13)
|||| +---- Screen 1 address (bit 14) - color only
|+++------ Screen 2 address (bits 11-13)
+--------- Screen 2 address (bit 14) - color only
</pre>
{{Anchor|Screen 2 Window}}
=== Screen 2 Window Left ($08) ===
=== Screen 2 Window Top ($09) ===
=== Screen 2 Window Right ($0A) ===
=== Screen 2 Window Bottom ($0B) ===
The X and Y coordinates of the Screen 2 window.
Note that all coordinates are inclusive; for example, for a 200x100 window in the top-left corner, the values should be set as follows:
* Left - 0,
* Top - 0,
* Right - 199,
* Bottom - 99.
{{Anchor|Sprite Window}}
=== Sprite Window Left ($0C) ===
=== Sprite Window Top ($0D) ===
=== Sprite Window Right ($0E) ===
=== Sprite Window Bottom ($0F) ===
The X and Y coordinates of the Sprite window.
Note that all coordinates are inclusive.
{{Anchor|Screen Scroll}}
=== Screen 1 Scroll X ($10) ===
=== Screen 1 Scroll Y ($11) ===
The X and Y coordinates that Screen 1 is scrolled by.
For example, setting Scroll X to 24 and Scroll Y to 8 will omit, in 8x8 tile units, the first three rows and the first two columns of the 32x32 screen.
=== Screen 2 Scroll X ($12) ===
=== Screen 2 Scroll Y ($13) ===
The X and Y coordinates that Screen 2 is scrolled by.
{{Anchor|LCD Control}}
=== LCD Control ($14) ===
<pre>
7 bit 0
---- ----
.... ..Ce
||
|+- LCD enable: 0 = sleep, 1 = enabled
+-- Contrast (WSC): 0 = low, 1 = high
</pre>
The LCD enable bit controls whether or not the LCD screen is displaying graphics; if sleeping, it displays nothing (all white). Note that segments continue displaying regardless of this configuration.
Note that port $1A also provides an LCD sleep bit; the display will be disabled in the same way if any of those bits are set to "sleep".
{{Anchor|LCD Icon Control}}
=== LCD Icon Control ($15) ===
<pre>
7 bit 0
---- ----
..32 1hvs
|| ||||
|| |||+- Sleep
|| ||+-- Vertical orientation
|| |+--- Horizontal orientation
|| +---- Aux 1
|+------ Aux 2
+------- Aux 3
</pre>
{{Anchor|LCD Mono Shade LUT}}
=== LCD Mono Shade LUT ($1C-$1F) ===
<pre>
$1C $1D $1E $1F
7 bit 0 7 bit 0 7 bit 0 7 bit 0
---- ---- ---- ---- ---- ---- ---- ----
1111 0000 3333 2222 5555 4444 7777 6666
</pre>
{{Anchor|LCD Mono Palette}}
=== LCD Mono Palette 0..15 ($20, $21 .. $3E, $3F) ===
The monochrome palette is laid out as sixteen words:
<pre>
N+1 N
15 bit 8 7 bit 0
---- ---- ---- ----
.333 .222 .111 .000
||| ||| ||| |||
||| ||| ||| +++- Shade LUT index for color 0
||| ||| +++------ Shade LUT index for color 1
||| +++------------ Shade LUT index for color 2
+++----------------- Shade LUT index for color 3
</pre>
== Internal I/O ports ==
These I/O ports are said to be internal and not intended for use by commercial games.
{{Anchor|LCD Final Line}}
=== LCD Final Line ($16) ===
The final line preceding line counter restart and the beginning of active display. By default, this is set to 158, which equals 159 total lines per frame.
It is said setting this register to an odd value on SwanCrystal has an adverse effect to the LCD panel<ref>[http://daifukkat.su/docs/wsman/#REG_LCD_VTOTAL REG_LCD_VTOTAL - WSMan]</ref>, but the exact mechanism is unknown.
{{Anchor|LCD Back Porch Line}}
=== LCD Back Porch Line ($17, WSC only) ===
This port is available on the WonderSwan Color only - not the SwanCrystal!
The final line preceding the vertical back porch; by default, this should be set to 155.
The vertical back porch of the LCD is assumed to be 4 lines by some hardware, including IPS mods, as well as the official "TV Swan" capture device. Given that the first visible line is sent to the LCD on the display's line 1, this should be generally set to <code>LCD Final Line - 3</code>.
Conversely, it is said moving this value closer to vertical blank improves LCD visibility<ref>[http://daifukkat.su/docs/wsman/#REG_LCD_VSYNC REG_LCD_VSYNC - WSMan]</ref>, but the exact mechanism is unknown.
{{Anchor|LCD Status}}
=== LCD Status ($1A) ===
<pre>
7 bit 0
---- ----
...v vvhs
| ||||
| |||+- LCD sleep: 0 = no, 1 = sleep
| ||+-- Headphone segment
| ||
| || Volume segments:
| |+--- - Volume B (medium, high)
| +---- - Volume A (low, high)
+------ - Speaker
</pre>
The LCD sleep bit is writable. The remaining bits are read-only.
The volume and headphone segments are enabled when pressing the SOUND button, according to this algorithm:
* If headphones are plugged in, enable the Headphone segment.
* If headphones are not plugged in, enable the Speaker segment and the following Volume segments:
** Volume level 0: None
** Volume level 1: A
** Volume level 2: B
** Volume level 3: A, B
* Hide all visible segments after 128 frames from the last press.
TODO: This documents the WonderSwan Color. The specifics probably work differently on the mono WonderSwan.
=== TFT LCD Configuration ($70, $71, $72, $73, $74, $75, $76, $77 SwanCrystal only) ===
These eight bytes are read from internal EEPROM and configure unknown aspects of the console's TFT LCD panel.
They are only writable while the [[Boot ROM]] is unlocked - locking has the side effect of making them read-only.
== Notes ==
<references />
8dae2639a7129bdd6ac7f3bfe58723cfb3b9e955
394
362
2024-11-20T02:28:29Z
Tepples
6
/* LCD Final Line ($16) */ I'd suspect row inversion
wikitext
text/x-wiki
The WonderSwan's display functionality generally consists of:
* a 224x144 display clocked at ~75.47 Hz by default, capable of displaying:
** up to sixteen distinct shades of gray
** 12-bit RGB444 color<sup>(color)</sup>
* two 32x32 background layers ("screens"), capable of displaying up to 512 (1024<sup>(color)</sup>) distinct tiles,
* a sprite layer, capable of displaying up to 128 8x8 sprites (up to 32 per line),
* six LCD icons to the bottom or right of the display, usable as additional indicators.
== Components ==
=== Tiles ===
The WonderSwan can display up to 512 distinct tiles at a time, with two bits of palette index information for every pixel.
The WonderSwan Color expands this to 1024 distinct tiles for background (with 512 remaining the limit for sprites), while also introducing modes with four bits of palette index information for every pixel.
==== 2 bits per pixel, planar ====
The tiles are stored in an interleaved planar format, with two bits total for every pixel. Odd bytes store the first plane (bit 0 of each pixel), while even bytes store the second plane (bit 1 of each pixel).
<pre>
tile data (16 bytes)
01 7C 01 FC 00 C0 18 D8 18 D8 00 C0 00 00 C0 00
||
\/
plane 0 plane 1
7 bit 0 7 bit 0 full tile
---- ---- ---- ----
.... ...1 = 01 .222 22.. = 7C .22222.1
.... ...1 = 01 2222 22.. = FC 222222.1
.... .... = 00 22.. .... = C0 22......
...1 1... = 18 22.2 2... = D8 --\ 22.33...
...1 1... = 18 22.2 2... = D8 --/ 22.33...
.... .... = 00 22.. .... = C0 22......
.... .... = 00 .... .... = 00 ........
11.. .... = C0 .... .... = 00 11......
</pre>
This matches the format used by the Game Boy.
==== 4 bits per pixel, planar ====
This mode is stored in a manner similar to the 2 bits per pixel mode, but with an additional two planes for bit 2 and bit 3 of each pixel's palette index, expanding the tile data to 32 bytes.
<pre>
tile data (32 bytes)
54 32 01 00 54 32 F1 00 54 32 01 F0 54 32 F1 F0 04 02 01 00 F8 04 02 01 00 F8 04 02 00 00 F8 04
||
\/
plane 0 plane 1 plane 2 plane 3
7 bit 0 7 bit 0 7 bit 0 7 bit 0 full tile
---- ---- ---- ---- ---- ---- ---- ----
.1.1 .1.. = 54 ..22 ..2. = 32 .... ...4 = 01 .... .... = 00 .123.124
.1.1 .1.. = 54 ..22 ..2. = 32 4444 ...4 = F1 .... .... = 00 4567.124
.1.1 .1.. = 54 ..22 ..2. = 32 .... ...4 = 01 8888 .... = F0 89AB.124
.1.1 .1.. = 54 ..22 ..2. = 32 4444 ...4 = F1 8888 .... = F0 --\ CDEF.124
.... .1.. = 04 .... ..2. = 02 .... ...4 = 01 .... .... = 00 --/ .....124
1111 1... = F8 .... .2.. = 04 .... ..4. = 02 .... ...8 = 01 11111248
.... .... = 00 2222 2... = F8 .... .4.. = 04 .... ..8. = 02 2222248.
.... .... = 00 .... .... = 00 4444 4... = F8 .... .8.. = 04 444448..
</pre>
This format matches the one used by the Sega Master System and Game Gear family of consoles.
==== 4 bits per pixel, packed ====
Unlike the previous two formats, in the packed format each byte stores the complete palette index of two pixels - the high four bits store the left pixel, while the low four bits store the right pixel. Four such bytes make up a row of eight pixels from left to right.
<pre>
tile data (32 bytes)
01 23 01 24 45 67 01 24 89 AB 01 24 CD EF 01 24 00 00 01 24 11 11 12 48 22 22 24 80 44 44 48 00
||
\/
byte 0 1 2 3
bits 7-4 3-0 7-4 3-0 7-4 3-0 7-4 3-0
pixel 0 1 2 3 4 5 6 7 full tile
--- --- --- --- --- --- --- ---
. 1 = 01 2 3 = 23 . 1 = 01 2 4 = 24 .123.124 = 01 23 01 24
4 5 = 45 6 7 = 67 . 1 = 01 2 4 = 24 4567.124 = 45 67 01 24
8 9 = 89 A B = AB . 1 = 01 2 4 = 24 89AB.124 = 89 AB 01 24
C D = CD E F = EF . 1 = 01 2 4 = 24 --\ CDEF.124 = CD EF 01 24
. . = 00 . . = 00 . 1 = 01 2 4 = 24 --/ .....124 = 00 00 01 24
1 1 = 11 1 1 = 11 1 2 = 12 4 8 = 48 11111248 = 11 11 12 48
2 2 = 22 2 2 = 22 2 4 = 24 8 . = 80 2222248. = 22 22 24 80
4 4 = 44 4 4 = 44 4 8 = 48 . . = 00 444448.. = 44 44 48 00
</pre>
This format matches the one used by the Mega Drive console.
=== Palettes ===
The display system provides sixteen different palettes that can be used to color or shade tiles.
* Palettes 0-7 can be used for the two screens only;
* Palettes 8-15 can be used for both screens and sprites.
==== Mono ====
In ''mono'' modes, palettes are stored in I/O ports 0x20 through 0x3F. Each palette contains four three-bit entries, which are pointers into a global, four-bit shade lookup table:
<pre>
Palette Global shade LUT
1 ===========> 2 ==========================> 5
^ (0, 2, 4, 6) ^ (1, 3, 5, 7, 9, 11, 13, 15) ^
| | |
Palette index Value Displayed shade
</pre>
The shade value corresponds to the darkness of the pixel: shade 0 is the brightest, while shade 15 is the darkest.
==== Color ====
In ''color'' modes, palettes are stored as 16-bit words in memory addresses 0xFE00 through 0xFFFF, without additional lookup tables:
<pre>
Address
15 bit 8 7 bit 0
---- ---- ---- ----
1111 111p pppi iii.
| |||| |||
| |||+-+++-- Index in palette (0-15)
+--+++------- Palette number (0-15)
Data
15 bit 8 7 bit 0
---- ---- ---- ----
.... rrrr gggg bbbb
|||| |||| ||||
|||| |||| ++++- Blue (0-15)
|||| ++++------ Green (0-15)
++++------------ Red (0-15)
</pre>
In 2 bits per pixel color modes, palette entries 4 through 15 are not used.
==== Transparency ====
In two bit per pixel modes:
* Palettes 0-3 and 8-11 are ''opaque''. For these, index zero is treated as opaque.
* Palettes 4-7 and 12-15 are ''translucent''. For these, index zero is treated as transparent. This means that the color/shade value set to it is ignored, and only three distinct colors/shades can be used for tiles.
In four bit per pixel modes, all palettes are ''translucent''. Index zero is always treated as transparent, and fifteen different colors/shades can be used for tiles.
=== Background color ===
The background color is displayed if no ''opaque'' pixel from screens or sprites is drawn. This color is set in I/O port ''0x01'':
* In mono modes, it is set to an entry in the shade lookup table (0-7),
* In color modes, it is set to an entry in the color palette (0-255). Note that this allows you to use the first color (color zero) of any palette, which is normally ignored and assumed to be ''transparent''.
=== Screens ===
A screen is a layout of tiles. Each cell in a screen controls one 8x8 tile.
The display system can show two distinct screens simultaneously. It also supports hardware flipping of tiles, both horizontally and vertically.
The size of each screen is fixed at 32x32 cells or 256x256 pixels, while each cell is stored as a two-byte word:
<pre>
Address
15 bit 8 7 bit 0
---- ---- ---- ----
0bbb byyy yyxx xxx.
||| |||| |||| |||
||| |||| ||++-+++-- X coordinate (0-31)
||| |+++--++-------- Y coordinate (0-31)
+++-+--------------- Base address (from I/O port)
Data
15 bit 8 7 bit 0
---- ---- ---- ----
vhbp pppt tttt tttt
|||| |||| |||| ||||
|||| |||+--++++-++++- Tile index (0-511)
|||+-+++------------- Palette (0-15)
||+------------------ Tile bank (0-1) - color only
|+------------------- Horizontal flip
+-------------------- Vertical flip
</pre>
In ''color'' modes, the tile bank selects between tiles 0-511 and 512-1023.
=== Sprites ===
The display system can show up to 128 sprites at once.
Sprites are always drawn in front of Screen 1, but they can be drawn in front of or behind Screen 2.
Sprites are stored in a sprite table in the console's internal RAM. It consists of up to 128 four-byte entries, of which any sequential slice can be displayed:
<pre>
(Byte 1) (Byte 0)
15 bit 8 7 bit 0
---- ---- ---- ----
vhPi pppt tttt tttt
|||| |||| |||| ||||
|||| |||+--++++-++++- Tile index (0-511) - only tile bank 0
|||| +++------------- Palette (0-7) - mapped to screen palettes 8-15
|||+----------------- Window location - 0 = inside, 1 = outside
||+------------------ Priority - 0 = behind Screen 2, 1 = in front of Screen 2
|+------------------- Horizontal flip
+-------------------- Vertical flip
(Byte 2)
7 bit 0
---- ----
yyyy yyyy
|||| ||||
++++-++++- Y coordinate
(Byte 3)
7 bit 0
---- ----
xxxx xxxx
|||| ||||
++++-++++- X coordinate
</pre>
There is a sprite limit of 32 per scanline. This means that for each scanline, only the first 32 sprites will be drawn. Note that this includes sprites obscured by windows or outside of visible X coordinates; this list is determined solely by the Y coordinate. Between sprites themselves, earlier sprites in the list are always drawn on top of later sprites in the list.
The sprite table is copied from the console's RAM to a SoC-internal buffer every frame on line <tt>144</tt>; one word for every clock of the line, totaling 256 words (512 bytes) for 256 clocks. This internal buffer is then used for reading sprite data on the next frame.
=== Visibility priority ===
For display components, the visibility priority is as follows:
* Sprite 0, high priority
* Sprite 127, high priority
* Screen 2
* Sprite 0, low priority
* Sprite 127, low priority
* Screen 1
* Background color
=== Windows ===
Screen 2 and sprites can optionally have their drawing restricted within or outside of their specific rectangular windows.
Note that for sprites, the window is enabled globally (for all sprites), but each sprite can individually decide if it's rendered inside or outside of it.
=== Icons ===
The WonderSwan features six LCD segment icons which are displayed to the right<sup>(color)</sup> or below<sup>(mono)</sup> the main display. These are, as follows:
* Aux 3 - large circle,
* Aux 2 - medium circle,
* Aux 1 - small circle,
* Horizontal orientation,
* Vertical orientation,
* Sleep.
== Interrupts ==
The display circuit generates two interrupts of its own:
* Display Interrupt Line Match - when <code>Display Current Line</code> == <code>Display Interrupt Line</code>, at the beginning of said line.
* Display Vertical Blank - when <code>Display Current Line</code> == <code>144</code>, at the beginning of said line.
It also provides a timing source for the two Horizontal and Vertical Blank [[Timers]], which provide their own respective interrupts.
== I/O ports ==
{{Anchor|Display Control}}
=== Display Control ($00) ===
<pre>
7 bit 0
---- ----
..wo Ws21
|| ||||
|| |||+- Enable Screen 1 layer
|| ||+-- Enable Screen 2 layer
|| |+--- Enable Sprite layer
|| +---- Enable Sprite window
|+------ Screen 2 tiles are drawn (if window enabled):
| 0 = inside window,
| 1 = outside window.
+------- Enable Screen 2 window
</pre>
{{Anchor|Display Background}}
=== Display Background Color ($01) ===
<pre>
(mono) (color)
7 bit 0 7 bit 0
---- ---- ---- ----
.... .sss pppp iiii
||| |||| ||||
+++- Value |||| ++++- Index in palette (0-15)
(0-7) ++++------ Color palette (0-15)
</pre>
{{Anchor|Display Current Line}}
=== Display Current Line ($02 read) ===
The current line being drawn by the display.
Note that lines are sent to the display with a one-line delay. This matters for color palette or shade LUT manipulation; changing these values when <code>current line == 1</code> will actually affect line 0.
{{Anchor|Display Interrupt Line}}
=== Display Interrupt Line ($03) ===
The line to emit an interrupt on.
{{Anchor|Sprite Table Address}}
=== Sprite Table Address ($04) ===
<pre>
7 bit 0
---- ----
..Aa aaaa
|| ||||
|+-++++- Address (bits 9-13)
+------- Address (bit 14) - color only
</pre>
{{Anchor|Sprite Table First}}
=== Sprite Table First ($05) ===
<pre>
7 bit 0
---- ----
.iii iiii
||| ||||
+++-++++- Index of first sprite entry to draw (0-127)
</pre>
{{Anchor|Sprite Table Count}}
=== Sprite Table Count ($06) ===
<pre>
7 bit 0
---- ----
cccc cccc
|||| ||||
++++-++++- Count of sprite entries to draw (1-128)
</pre>
{{Anchor|Screen Address}}
=== Screen Address ($07) ===
<pre>
7 bit 0
---- ----
2222 1111
|||| ||||
|||| |+++- Screen 1 address (bits 11-13)
|||| +---- Screen 1 address (bit 14) - color only
|+++------ Screen 2 address (bits 11-13)
+--------- Screen 2 address (bit 14) - color only
</pre>
{{Anchor|Screen 2 Window}}
=== Screen 2 Window Left ($08) ===
=== Screen 2 Window Top ($09) ===
=== Screen 2 Window Right ($0A) ===
=== Screen 2 Window Bottom ($0B) ===
The X and Y coordinates of the Screen 2 window.
Note that all coordinates are inclusive; for example, for a 200x100 window in the top-left corner, the values should be set as follows:
* Left - 0,
* Top - 0,
* Right - 199,
* Bottom - 99.
{{Anchor|Sprite Window}}
=== Sprite Window Left ($0C) ===
=== Sprite Window Top ($0D) ===
=== Sprite Window Right ($0E) ===
=== Sprite Window Bottom ($0F) ===
The X and Y coordinates of the Sprite window.
Note that all coordinates are inclusive.
{{Anchor|Screen Scroll}}
=== Screen 1 Scroll X ($10) ===
=== Screen 1 Scroll Y ($11) ===
The X and Y coordinates that Screen 1 is scrolled by.
For example, setting Scroll X to 24 and Scroll Y to 8 will omit, in 8x8 tile units, the first three rows and the first two columns of the 32x32 screen.
=== Screen 2 Scroll X ($12) ===
=== Screen 2 Scroll Y ($13) ===
The X and Y coordinates that Screen 2 is scrolled by.
{{Anchor|LCD Control}}
=== LCD Control ($14) ===
<pre>
7 bit 0
---- ----
.... ..Ce
||
|+- LCD enable: 0 = sleep, 1 = enabled
+-- Contrast (WSC): 0 = low, 1 = high
</pre>
The LCD enable bit controls whether or not the LCD screen is displaying graphics; if sleeping, it displays nothing (all white). Note that segments continue displaying regardless of this configuration.
Note that port $1A also provides an LCD sleep bit; the display will be disabled in the same way if any of those bits are set to "sleep".
{{Anchor|LCD Icon Control}}
=== LCD Icon Control ($15) ===
<pre>
7 bit 0
---- ----
..32 1hvs
|| ||||
|| |||+- Sleep
|| ||+-- Vertical orientation
|| |+--- Horizontal orientation
|| +---- Aux 1
|+------ Aux 2
+------- Aux 3
</pre>
{{Anchor|LCD Mono Shade LUT}}
=== LCD Mono Shade LUT ($1C-$1F) ===
<pre>
$1C $1D $1E $1F
7 bit 0 7 bit 0 7 bit 0 7 bit 0
---- ---- ---- ---- ---- ---- ---- ----
1111 0000 3333 2222 5555 4444 7777 6666
</pre>
{{Anchor|LCD Mono Palette}}
=== LCD Mono Palette 0..15 ($20, $21 .. $3E, $3F) ===
The monochrome palette is laid out as sixteen words:
<pre>
N+1 N
15 bit 8 7 bit 0
---- ---- ---- ----
.333 .222 .111 .000
||| ||| ||| |||
||| ||| ||| +++- Shade LUT index for color 0
||| ||| +++------ Shade LUT index for color 1
||| +++------------ Shade LUT index for color 2
+++----------------- Shade LUT index for color 3
</pre>
== Internal I/O ports ==
These I/O ports are said to be internal and not intended for use by commercial games.
{{Anchor|LCD Final Line}}
=== LCD Final Line ($16) ===
The final line preceding line counter restart and the beginning of active display. By default, this is set to 158, which equals 159 total lines per frame.
It is said setting this register to an odd value on SwanCrystal has an adverse effect to the LCD panel,<ref>[http://daifukkat.su/docs/wsman/#REG_LCD_VTOTAL REG_LCD_VTOTAL - WSMan]</ref> but the exact mechanism is unknown. A starting point for research is that an even value, or odd total line count, is needed to balance positive and negative charges on the LCD.<ref>W.A. Steer. "[http://www.techmind.org/lcd/ LCD monitor technology and tests]". Techmind, 2011-12-03. Accessed 2024-11-19.</ref>
{{Anchor|LCD Back Porch Line}}
=== LCD Back Porch Line ($17, WSC only) ===
This port is available on the WonderSwan Color only - not the SwanCrystal!
The final line preceding the vertical back porch; by default, this should be set to 155.
The vertical back porch of the LCD is assumed to be 4 lines by some hardware, including IPS mods, as well as the official "TV Swan" capture device. Given that the first visible line is sent to the LCD on the display's line 1, this should be generally set to <code>LCD Final Line - 3</code>.
Conversely, it is said moving this value closer to vertical blank improves LCD visibility<ref>[http://daifukkat.su/docs/wsman/#REG_LCD_VSYNC REG_LCD_VSYNC - WSMan]</ref>, but the exact mechanism is unknown.
{{Anchor|LCD Status}}
=== LCD Status ($1A) ===
<pre>
7 bit 0
---- ----
...v vvhs
| ||||
| |||+- LCD sleep: 0 = no, 1 = sleep
| ||+-- Headphone segment
| ||
| || Volume segments:
| |+--- - Volume B (medium, high)
| +---- - Volume A (low, high)
+------ - Speaker
</pre>
The LCD sleep bit is writable. The remaining bits are read-only.
The volume and headphone segments are enabled when pressing the SOUND button, according to this algorithm:
* If headphones are plugged in, enable the Headphone segment.
* If headphones are not plugged in, enable the Speaker segment and the following Volume segments:
** Volume level 0: None
** Volume level 1: A
** Volume level 2: B
** Volume level 3: A, B
* Hide all visible segments after 128 frames from the last press.
TODO: This documents the WonderSwan Color. The specifics probably work differently on the mono WonderSwan.
=== TFT LCD Configuration ($70, $71, $72, $73, $74, $75, $76, $77 SwanCrystal only) ===
These eight bytes are read from internal EEPROM and configure unknown aspects of the console's TFT LCD panel.
They are only writable while the [[Boot ROM]] is unlocked - locking has the side effect of making them read-only.
== Notes ==
<references />
8d83ca8f5add34850bb6891c56a8fa3ab13360ea
WonderWitch/FreyaBIOS/Text
0
53
364
324
2024-10-16T15:25:26Z
Asie
351
Fix typo
wikitext
text/x-wiki
The Text interrupt provides a text output display using one of the WonderSwan's screens.
== Interrupts ==
=== INT $13/AH=$00 - text_screen_init ===
* AH = $00
Initializes a text window (see INT $13/AH=$01) with the following default settings:
* X, Y = 0, 0
* width, height = 28, 18
* starting tile = 512 - font tile count (in ASCII mode)
* starting tile = 512 - (width x height) (in Shift-JIS and mixed modes)
=== INT $13/AH=$01 - text_window_init ===
* AH = $01
* BL = X position on screen, in tiles
* BH = Y position on screen, in tiles
* CL = width, in tiles
* CH = height, in tiles
* DX = starting tile
Initializes a text window starting at <code>(BL, BH)</code> with a size of <code>CL x CH</code> tiles on the configured screen.
This requires the following number of tiles, starting at <code>DX</code>:
* font tile count (in ASCII mode)
* width x height (in Shift-JIS and mixed modes)
=== INT $13/AH=$02 - text_set_mode ===
* AH = $02
* BX = Text mode
Available modes:
* 0 = ASCII mode
* 1 = mixed (ASCII and Shift-JIS) mode
* 2 = Shift-JIS mode
=== INT $13/AH=$03 - text_get_mode ===
* AH = $03
Return:
* BX = Text mode
=== INT $13/AH=$04 - text_put_char ===
* AH = $04
* BL = X position in text window
* BH = Y position in text window
* CX = Character code
=== INT $13/AH=$05 - text_put_string ===
* AH = $05
* BL = X position in text window
* BH = Y position in text window
* DS:DX = String to print
=== INT $13/AH=$06 - text_put_substring ===
* AH = $06
* BL = X position in text window
* BH = Y position in text window
* CX = Maximum length of string to print
* DS:DX = String to print
=== INT $13/AH=$07 - text_put_numeric ===
* AH = $07
* BL = X position in text window
* BH = Y position in text window
* CL = Width of area to write number in
* CH = Flags
* DX = Number
* DS:SI = Output buffer (optional, see flags)
Numeric output flags:
<pre>
7 bit 0
---- ----
o... slzx
| ||||
| |||+- 0 = output in decimal
| ||| 1 = output in hexadecimal
| ||+---- 0 = pad with spaces
| || 1 = pad with zeroes
| |+------- 0 = align to right
| | 1 = align to left
| +---------- 0 = number is unsigned
| 1 = number is signed
+----------------- 0 = output to text window (at BL, BH)
1 = output to buffer (DS:SI)
</pre>
=== INT $13/AH=$08 - text_fill_char ===
* AH = $08
* BL = X position in text window
* BH = Y position in text window
* CX = Length
* DX = Character code
Repeat the specified character code <code>CX</code> times.
=== INT $13/AH=$09 - text_set_palette ===
* AH = $09
* BX = Palette color (0-15).
Set the palette used by printed text.
=== INT $13/AH=$0A - text_get_palette ===
* AH = $0A
Return:
* AX = Palette color (0-15).
Retrieve the palette used by printed text.
=== INT $13/AH=$0B - text_set_ank_font ===
* AH = $0B
* BL = Starting character code.
* BH = Bit depth; 0 = 1bpp, 1 = 2bpp.
* CX = Number of tiles.
* DS:DX = Input buffer containing font data.
=== INT $13/AH=$0C - text_set_sjis_font ===
TODO
=== INT $13/AH=$0D - text_get_fontdata ===
* AH = $0D
* CX = Character code.
* DS:DX = Output buffer for the character's tile data.
=== INT $13/AH=$0E - text_set_screen ===
* AH = $0E
* AL = Screen ID (0, 1).
=== INT $13/AH=$0F - text_get_screen ===
* AH = $0F
Return:
* AL = Screen ID (0, 1).
=== INT $13/AH=$10 - cursor_display ===
* AH = $10
* AL = Cursor status (0 = disabled, 1 = enabled).
Controls the visibility of a blinking cursor on the text screen.
=== INT $13/AH=$11 - cursor_status ===
* AH = $11
Return:
* AX = Cursor status.
<pre>
7 bit 0
---- ----
.... ..ve
||
|+- 0 = disabled, 1 = enabled
+-- 0 = currently not visible, 1 = visible
</pre>
=== INT $13/AH=$12 - cursor_set_location ===
* AH = $12
* BL = X position
* BH = Y position
* CL = Width, in tiles
* CH = Height, in tiles
=== INT $13/AH=$13 - cursor_get_location ===
* AH = $13
Return:
* AL = X position
* AH = Y position
* DL = Width, in tiles
* DH = Height, in tiles
=== INT $13/AH=$14 - cursor_set_type ===
* AH = $14
* BL = Palette (0-15) used by cursor area when visible
* CL = Blinking rate, in frames (0 = always visible)
The defaults are as follows:
* Palette = 1
* Blinking rate = 30
=== INT $13/AH=$15 - cursor_get_type ===
* AH = $15
Return:
* AL = Palette (0-15) used by cursor area when visible
* AH = Blinking rate, in frames (0 = always visible)
0f6a28d0a0f398465208c0bf7f6d4b0f54fb9567
389
364
2024-10-20T08:23:10Z
Asie
351
wikitext
text/x-wiki
The Text interrupt provides a text output display using one of the WonderSwan's screens.
== Interrupts ==
=== INT $13/AH=$00 - text_screen_init ===
* AH = $00
Initializes a text window (see INT $13/AH=$01) with the following default settings:
* X, Y = 0, 0
* width, height = 28, 18
* starting tile = 512 - font tile count (in ASCII mode)
* starting tile = 512 - (width x height) (in Shift-JIS and mixed modes)
=== INT $13/AH=$01 - text_window_init ===
* AH = $01
* BL = X position on screen, in tiles
* BH = Y position on screen, in tiles
* CL = width, in tiles
* CH = height, in tiles
* DX = starting tile
Initializes a text window starting at <code>(BL, BH)</code> with a size of <code>CL x CH</code> tiles on the configured screen.
This requires the following number of tiles, starting at <code>DX</code>:
* font tile count (in ASCII mode)
* width x height (in Shift-JIS and mixed modes)
=== INT $13/AH=$02 - text_set_mode ===
* AH = $02
* BX = Text mode
Available modes:
* 0 = ASCII mode
* 1 = mixed (ASCII and Shift-JIS) mode
* 2 = Shift-JIS mode
=== INT $13/AH=$03 - text_get_mode ===
* AH = $03
Return:
* BX = Text mode
=== INT $13/AH=$04 - text_put_char ===
* AH = $04
* BL = X position in text window
* BH = Y position in text window
* CX = Character code
=== INT $13/AH=$05 - text_put_string ===
* AH = $05
* BL = X position in text window
* BH = Y position in text window
* DS:DX = String to print
Return:
* AX = Number of characters displayed
=== INT $13/AH=$06 - text_put_substring ===
* AH = $06
* BL = X position in text window
* BH = Y position in text window
* CX = Maximum length of string to print
* DS:DX = String to print
Return:
* AX = Number of characters displayed
=== INT $13/AH=$07 - text_put_numeric ===
* AH = $07
* BL = X position in text window
* BH = Y position in text window
* CL = Width of area to write number in
* CH = Flags
* DX = Number
* DS:SI = Output buffer (optional, see flags)
Return:
* AX = Number of characters displayed
Numeric output flags:
<pre>
7 bit 0
---- ----
o... slzx
| ||||
| |||+- 0 = output in decimal
| ||| 1 = output in hexadecimal
| ||+---- 0 = pad with spaces
| || 1 = pad with zeroes
| |+------- 0 = align to right
| | 1 = align to left
| +---------- 0 = number is unsigned
| 1 = number is signed
+----------------- 0 = output to text window (at BL, BH)
1 = output to buffer (DS:SI)
</pre>
=== INT $13/AH=$08 - text_fill_char ===
* AH = $08
* BL = X position in text window
* BH = Y position in text window
* CX = Length
* DX = Character code
Repeat the specified character code <code>CX</code> times.
=== INT $13/AH=$09 - text_set_palette ===
* AH = $09
* BX = Palette color (0-15).
Set the palette used by printed text.
=== INT $13/AH=$0A - text_get_palette ===
* AH = $0A
Return:
* AX = Palette color (0-15).
Retrieve the palette used by printed text.
=== INT $13/AH=$0B - text_set_ank_font ===
* AH = $0B
* BL = Starting character code.
* BH = Bit depth; 0 = 1bpp, 1 = 2bpp.
* CX = Number of tiles.
* DS:DX = Input buffer containing font data.
=== INT $13/AH=$0C - text_set_sjis_font ===
TODO
=== INT $13/AH=$0D - text_get_fontdata ===
* AH = $0D
* CX = Character code.
* DS:DX = Output buffer for the character's tile data.
=== INT $13/AH=$0E - text_set_screen ===
* AH = $0E
* AL = Screen ID (0, 1).
=== INT $13/AH=$0F - text_get_screen ===
* AH = $0F
Return:
* AL = Screen ID (0, 1).
=== INT $13/AH=$10 - cursor_display ===
* AH = $10
* AL = Cursor status (0 = disabled, 1 = enabled).
Controls the visibility of a blinking cursor on the text screen.
=== INT $13/AH=$11 - cursor_status ===
* AH = $11
Return:
* AX = Cursor status.
<pre>
7 bit 0
---- ----
.... ..ve
||
|+- 0 = disabled, 1 = enabled
+-- 0 = currently not visible, 1 = visible
</pre>
=== INT $13/AH=$12 - cursor_set_location ===
* AH = $12
* BL = X position
* BH = Y position
* CL = Width, in tiles
* CH = Height, in tiles
=== INT $13/AH=$13 - cursor_get_location ===
* AH = $13
Return:
* AL = X position
* AH = Y position
* DL = Width, in tiles
* DH = Height, in tiles
=== INT $13/AH=$14 - cursor_set_type ===
* AH = $14
* BL = Palette (0-15) used by cursor area when visible
* CL = Blinking rate, in frames (0 = always visible)
The defaults are as follows:
* Palette = 1
* Blinking rate = 30
=== INT $13/AH=$15 - cursor_get_type ===
* AH = $15
Return:
* AL = Palette (0-15) used by cursor area when visible
* AH = Blinking rate, in frames (0 = always visible)
55179b226aae9b24f1f50a0c0a580ad4cd8aa719
WonderWitch/Filesystem
0
59
365
2024-10-17T14:21:13Z
Asie
351
Created page with "== Mount points == {| class="wikitable" |+ FreyaOS mount points |- ! Path !! File data location !! File table location !! File table size (entries) !! Description |- | <code>/rom0</code> || ROM (384 KB) || SRAM bank 3, $16F2 || 128 || |- | <code>/ram0</code> || SRAM bank 0 (64 KB) || SRAM bank 3, $06F2 || 64 || |- | <code>/</code> || || SRAM bank 3, $02F2 || 16 || |} == File table entry format == {| class="wikitable" |+ Header contents |- ! Offset !! Length !! Conten..."
wikitext
text/x-wiki
== Mount points ==
{| class="wikitable"
|+ FreyaOS mount points
|-
! Path !! File data location !! File table location !! File table size (entries) !! Description
|-
| <code>/rom0</code> || ROM (384 KB) || SRAM bank 3, $16F2 || 128 ||
|-
| <code>/ram0</code> || SRAM bank 0 (64 KB) || SRAM bank 3, $06F2 || 64 ||
|-
| <code>/</code> || || SRAM bank 3, $02F2 || 16 ||
|}
== File table entry format ==
{| class="wikitable"
|+ Header contents
|-
! Offset !! Length !! Contents
|-
| 0 || 16 || File name; zero-terminated Shift-JIS string.
|-
| 16 || 24 || User-friendly file name; zero-terminated Shift-JIS string.
FreyaOS displays the first 12 characters in its file selector.
|-
| 40 || 4 || Location in CPU address space (segment:offset)
|-
| 44 || 4 || Total file size, in bytes, excluding the header.
|-
| 48 || 2 || XMODEM chunk count - above file size divided by 128, then rounded up.
|-
| 50 || 2 || File mode
|-
| 52 || 4 || Modification time - seconds since January 1st, 2000.
|-
| 56 || 4 || TODO
|-
| 60 || 4 || Offset to resource data, bytes excluding header; -1 if not present.
|}
=== File modes ===
----
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
???? ???? dlis mrwx
|||| ||||
|||| |||+- Execute
|||| ||+-- Write
|||| |+--- Read
|||| +---- Prohibit mmap() use
|||+------ StreamIL-related?
||+------- Intermediate library
|+-------- Symbolic link
+--------- Directory
</pre>
8e7bd8e15d95adc17a95cc7a5e40cf89bd92a68c
WonderWitch .fx files
0
6
366
259
2024-10-17T14:21:54Z
Asie
351
wikitext
text/x-wiki
[[WonderWitch/FreyaOS|FreyaOS]] uses [[XMODEM]] transfers to send and receive files through the serial port. These transfers do not include any file metadata by default - such as the file's name, size, permissions or creation date. As such, .fx files are used - binary files with a special 128-byte header<ref>XMODEM transfers are performed in 128-byte blocks; this allows fetching the file's metadata as the first block</ref>.
== Format ==
{| class="wikitable"
|+ Header contents
|-
! Offset !! Length !! Contents
|-
| $00 || 4 || Magic string: <code>#!ws</code>
|-
| $04 || 60 || Padding; typically 0xFF.
|-
| $40 || 64 || [[WonderWitch/Filesystem|File entry]] (pointers relative to 0000:0000).
|}
dd3a5d9ed5a8acde26cc7cb4a66c682fb6249334
WSdev Wiki
0
1
367
310
2024-10-17T14:22:18Z
Asie
351
/* WonderWitch */
wikitext
text/x-wiki
'''WonderSwan Development Wiki'''
== Reference ==
=== General ===
* [[Memory map]]
* [[I/O port map]]
* [[ROM header]]
* [[NEC V30MZ]] - the WonderSwan CPU (80186-compatible)
* [[Timing]]
=== Console components ===
* [[SoC]]
** [[Display]]
** [[Sound]]
*** [[Hyper Voice]]<sup>(color)</sup>
** [[Keypad]]
** [[Timers]]
** [[Interrupts]]
** [[UART]]
** [[DMA]]<sup>(color)</sup>
* [[Boot ROM]]
* [[EEPROM|Internal EEPROM]]
** [[Splash animation]]<sup>(color)</sup>
=== Cartridge components ===
* [[Cartridge connector]]
* [[Mapper]]
** [[Bandai 2001]]
** [[Bandai 2003]]
** [[KARNAK]]
* [[EEPROM]] (2001)
* [[Real-Time Clock]] (2003)
=== Pinouts ===
* [[Cartridge connector#Pinout|Cartridge pinout]]
* [[Accessory port pinout]]
* [[2001 Mapper pinout]]
* [[2003 Mapper pinout]]
* [[KARNAK pinout]]
* [[GIZA pinout]]
* [[S-3511A pinout]]
=== Accessories ===
* [[WonderBeat 9480]] headphone adapter
* [[WonderBorg]] robot
* [[WonderGate]] mobile adapter
* [[WonderWave]] infrared adapter
=== WonderWitch ===
* [[WonderWitch]]
** [[WonderWitch/FreyaBIOS|FreyaBIOS]]
** [[WonderWitch/FreyaOS|FreyaOS]]
** [[WonderWitch/Filesystem|File system]]
** [[WonderWitch .fx files|.fx file format]]
== Links ==
* [https://wonderful.asie.pl/wiki/doku.php?id=wswan:index#guides Wonderful Toolchain Wiki] - gcc-ia16-based homebrew toolchain guides and documentation
* [https://github.com/WonderfulToolchain/awesome-wsdev awesome-wsdev] - curated documentation/tools/source code link list
== MediaWiki ==
* [https://www.mediawiki.org/wiki/Special:MyLanguage/Help:Contents User's Guide]
* [https://www.mediawiki.org/wiki/Special:MyLanguage/Manual:FAQ MediaWiki FAQ]
* [[:Category:Deletion requests|Deletion requests]]
8f41898fca4172bf24ee5a70e86e9e41c97089e7
368
367
2024-10-18T15:33:13Z
Asie
351
/* WonderWitch */
wikitext
text/x-wiki
'''WonderSwan Development Wiki'''
== Reference ==
=== General ===
* [[Memory map]]
* [[I/O port map]]
* [[ROM header]]
* [[NEC V30MZ]] - the WonderSwan CPU (80186-compatible)
* [[Timing]]
=== Console components ===
* [[SoC]]
** [[Display]]
** [[Sound]]
*** [[Hyper Voice]]<sup>(color)</sup>
** [[Keypad]]
** [[Timers]]
** [[Interrupts]]
** [[UART]]
** [[DMA]]<sup>(color)</sup>
* [[Boot ROM]]
* [[EEPROM|Internal EEPROM]]
** [[Splash animation]]<sup>(color)</sup>
=== Cartridge components ===
* [[Cartridge connector]]
* [[Mapper]]
** [[Bandai 2001]]
** [[Bandai 2003]]
** [[KARNAK]]
* [[EEPROM]] (2001)
* [[Real-Time Clock]] (2003)
=== Pinouts ===
* [[Cartridge connector#Pinout|Cartridge pinout]]
* [[Accessory port pinout]]
* [[2001 Mapper pinout]]
* [[2003 Mapper pinout]]
* [[KARNAK pinout]]
* [[GIZA pinout]]
* [[S-3511A pinout]]
=== Accessories ===
* [[WonderBeat 9480]] headphone adapter
* [[WonderBorg]] robot
* [[WonderGate]] mobile adapter
* [[WonderWave]] infrared adapter
=== WonderWitch ===
* [[WonderWitch]]
** [[WonderWitch/FreyaBIOS|FreyaBIOS]]
** [[WonderWitch/FreyaOS|FreyaOS]]
** [[WonderWitch/Filesystem|File system]]
** [[WonderWitch/Executable|Executable]]
** [[WonderWitch/IL|Indirect Library (IL)]]
** [[WonderWitch .fx files|.fx file format]]
== Links ==
* [https://wonderful.asie.pl/wiki/doku.php?id=wswan:index#guides Wonderful Toolchain Wiki] - gcc-ia16-based homebrew toolchain guides and documentation
* [https://github.com/WonderfulToolchain/awesome-wsdev awesome-wsdev] - curated documentation/tools/source code link list
== MediaWiki ==
* [https://www.mediawiki.org/wiki/Special:MyLanguage/Help:Contents User's Guide]
* [https://www.mediawiki.org/wiki/Special:MyLanguage/Manual:FAQ MediaWiki FAQ]
* [[:Category:Deletion requests|Deletion requests]]
48075adf7156cc54cf42ad4698aae87dcca9381d
371
368
2024-10-18T17:46:42Z
Asie
351
/* WonderWitch */
wikitext
text/x-wiki
'''WonderSwan Development Wiki'''
== Reference ==
=== General ===
* [[Memory map]]
* [[I/O port map]]
* [[ROM header]]
* [[NEC V30MZ]] - the WonderSwan CPU (80186-compatible)
* [[Timing]]
=== Console components ===
* [[SoC]]
** [[Display]]
** [[Sound]]
*** [[Hyper Voice]]<sup>(color)</sup>
** [[Keypad]]
** [[Timers]]
** [[Interrupts]]
** [[UART]]
** [[DMA]]<sup>(color)</sup>
* [[Boot ROM]]
* [[EEPROM|Internal EEPROM]]
** [[Splash animation]]<sup>(color)</sup>
=== Cartridge components ===
* [[Cartridge connector]]
* [[Mapper]]
** [[Bandai 2001]]
** [[Bandai 2003]]
** [[KARNAK]]
* [[EEPROM]] (2001)
* [[Real-Time Clock]] (2003)
=== Pinouts ===
* [[Cartridge connector#Pinout|Cartridge pinout]]
* [[Accessory port pinout]]
* [[2001 Mapper pinout]]
* [[2003 Mapper pinout]]
* [[KARNAK pinout]]
* [[GIZA pinout]]
* [[S-3511A pinout]]
=== Accessories ===
* [[WonderBeat 9480]] headphone adapter
* [[WonderBorg]] robot
* [[WonderGate]] mobile adapter
* [[WonderWave]] infrared adapter
=== WonderWitch ===
* [[WonderWitch]]
** [[WonderWitch/FreyaBIOS|FreyaBIOS]]
** [[WonderWitch/FreyaOS|FreyaOS]]
** [[WonderWitch/Filesystem|File system]]
** [[WonderWitch/Process|Process]]
** [[WonderWitch/IL|Indirect Library (IL)]]
** [[WonderWitch .fx files|.fx file format]]
== Links ==
* [https://wonderful.asie.pl/wiki/doku.php?id=wswan:index#guides Wonderful Toolchain Wiki] - gcc-ia16-based homebrew toolchain guides and documentation
* [https://github.com/WonderfulToolchain/awesome-wsdev awesome-wsdev] - curated documentation/tools/source code link list
== MediaWiki ==
* [https://www.mediawiki.org/wiki/Special:MyLanguage/Help:Contents User's Guide]
* [https://www.mediawiki.org/wiki/Special:MyLanguage/Manual:FAQ MediaWiki FAQ]
* [[:Category:Deletion requests|Deletion requests]]
9b221ade48597f63860dee91699fa3cc391f4c52
381
371
2024-10-19T19:01:36Z
Asie
351
/* WonderWitch */
wikitext
text/x-wiki
'''WonderSwan Development Wiki'''
== Reference ==
=== General ===
* [[Memory map]]
* [[I/O port map]]
* [[ROM header]]
* [[NEC V30MZ]] - the WonderSwan CPU (80186-compatible)
* [[Timing]]
=== Console components ===
* [[SoC]]
** [[Display]]
** [[Sound]]
*** [[Hyper Voice]]<sup>(color)</sup>
** [[Keypad]]
** [[Timers]]
** [[Interrupts]]
** [[UART]]
** [[DMA]]<sup>(color)</sup>
* [[Boot ROM]]
* [[EEPROM|Internal EEPROM]]
** [[Splash animation]]<sup>(color)</sup>
=== Cartridge components ===
* [[Cartridge connector]]
* [[Mapper]]
** [[Bandai 2001]]
** [[Bandai 2003]]
** [[KARNAK]]
* [[EEPROM]] (2001)
* [[Real-Time Clock]] (2003)
=== Pinouts ===
* [[Cartridge connector#Pinout|Cartridge pinout]]
* [[Accessory port pinout]]
* [[2001 Mapper pinout]]
* [[2003 Mapper pinout]]
* [[KARNAK pinout]]
* [[GIZA pinout]]
* [[S-3511A pinout]]
=== Accessories ===
* [[WonderBeat 9480]] headphone adapter
* [[WonderBorg]] robot
* [[WonderGate]] mobile adapter
* [[WonderWave]] infrared adapter
=== WonderWitch ===
* [[WonderWitch]]
** [[WonderWitch/Memory map|Memory map]]
** [[WonderWitch/FreyaBIOS|FreyaBIOS]]
** [[WonderWitch/FreyaOS|FreyaOS]]
** [[WonderWitch/Filesystem|File system]]
** [[WonderWitch/Process|Process]]
** [[WonderWitch/IL|Indirect Library (IL)]]
** [[WonderWitch .fx files|.fx file format]]
== Links ==
* [https://wonderful.asie.pl/wiki/doku.php?id=wswan:index#guides Wonderful Toolchain Wiki] - gcc-ia16-based homebrew toolchain guides and documentation
* [https://github.com/WonderfulToolchain/awesome-wsdev awesome-wsdev] - curated documentation/tools/source code link list
== MediaWiki ==
* [https://www.mediawiki.org/wiki/Special:MyLanguage/Help:Contents User's Guide]
* [https://www.mediawiki.org/wiki/Special:MyLanguage/Manual:FAQ MediaWiki FAQ]
* [[:Category:Deletion requests|Deletion requests]]
78c9cf9e864511aa08a00e40250a3124692373af
398
381
2024-11-24T17:46:48Z
Asie
351
/* WonderWitch */
wikitext
text/x-wiki
'''WonderSwan Development Wiki'''
== Reference ==
=== General ===
* [[Memory map]]
* [[I/O port map]]
* [[ROM header]]
* [[NEC V30MZ]] - the WonderSwan CPU (80186-compatible)
* [[Timing]]
=== Console components ===
* [[SoC]]
** [[Display]]
** [[Sound]]
*** [[Hyper Voice]]<sup>(color)</sup>
** [[Keypad]]
** [[Timers]]
** [[Interrupts]]
** [[UART]]
** [[DMA]]<sup>(color)</sup>
* [[Boot ROM]]
* [[EEPROM|Internal EEPROM]]
** [[Splash animation]]<sup>(color)</sup>
=== Cartridge components ===
* [[Cartridge connector]]
* [[Mapper]]
** [[Bandai 2001]]
** [[Bandai 2003]]
** [[KARNAK]]
* [[EEPROM]] (2001)
* [[Real-Time Clock]] (2003)
=== Pinouts ===
* [[Cartridge connector#Pinout|Cartridge pinout]]
* [[Accessory port pinout]]
* [[2001 Mapper pinout]]
* [[2003 Mapper pinout]]
* [[KARNAK pinout]]
* [[GIZA pinout]]
* [[S-3511A pinout]]
=== Accessories ===
* [[WonderBeat 9480]] headphone adapter
* [[WonderBorg]] robot
* [[WonderGate]] mobile adapter
* [[WonderWave]] infrared adapter
=== WonderWitch ===
* [[WonderWitch]]
** [[WonderWitch/Flash|NOR flash]]
** [[WonderWitch/Memory map|Memory map]]
** [[WonderWitch/FreyaBIOS|FreyaBIOS]]
** [[WonderWitch/FreyaOS|FreyaOS]]
** [[WonderWitch/Filesystem|File system]]
** [[WonderWitch/Process|Process]]
** [[WonderWitch/IL|Indirect Library (IL)]]
** [[WonderWitch .fx files|.fx file format]]
== Links ==
* [https://wonderful.asie.pl/wiki/doku.php?id=wswan:index#guides Wonderful Toolchain Wiki] - gcc-ia16-based homebrew toolchain guides and documentation
* [https://github.com/WonderfulToolchain/awesome-wsdev awesome-wsdev] - curated documentation/tools/source code link list
== MediaWiki ==
* [https://www.mediawiki.org/wiki/Special:MyLanguage/Help:Contents User's Guide]
* [https://www.mediawiki.org/wiki/Special:MyLanguage/Manual:FAQ MediaWiki FAQ]
* [[:Category:Deletion requests|Deletion requests]]
009244dd9b2eac56848caea56f674e55d095f58f
399
398
2024-11-24T17:48:22Z
Asie
351
/* Cartridge components */
wikitext
text/x-wiki
'''WonderSwan Development Wiki'''
== Reference ==
=== General ===
* [[Memory map]]
* [[I/O port map]]
* [[ROM header]]
* [[NEC V30MZ]] - the WonderSwan CPU (80186-compatible)
* [[Timing]]
=== Console components ===
* [[SoC]]
** [[Display]]
** [[Sound]]
*** [[Hyper Voice]]<sup>(color)</sup>
** [[Keypad]]
** [[Timers]]
** [[Interrupts]]
** [[UART]]
** [[DMA]]<sup>(color)</sup>
* [[Boot ROM]]
* [[EEPROM|Internal EEPROM]]
** [[Splash animation]]<sup>(color)</sup>
=== Cartridge components ===
* [[Cartridge connector]]
* [[Mapper]]
** [[Bandai 2001]]
** [[Bandai 2003]]
** [[KARNAK]]
* Mapper-specific components
** [[EEPROM]] (2001)
** [[Real-Time Clock]] (2003)
* Cartridge-specific components
** [[WonderWitch/Flash|WonderWitch NOR flash]]
** [[Handy Sonar]]
=== Pinouts ===
* [[Cartridge connector#Pinout|Cartridge pinout]]
* [[Accessory port pinout]]
* [[2001 Mapper pinout]]
* [[2003 Mapper pinout]]
* [[KARNAK pinout]]
* [[GIZA pinout]]
* [[S-3511A pinout]]
=== Accessories ===
* [[WonderBeat 9480]] headphone adapter
* [[WonderBorg]] robot
* [[WonderGate]] mobile adapter
* [[WonderWave]] infrared adapter
=== WonderWitch ===
* [[WonderWitch]]
** [[WonderWitch/Flash|NOR flash]]
** [[WonderWitch/Memory map|Memory map]]
** [[WonderWitch/FreyaBIOS|FreyaBIOS]]
** [[WonderWitch/FreyaOS|FreyaOS]]
** [[WonderWitch/Filesystem|File system]]
** [[WonderWitch/Process|Process]]
** [[WonderWitch/IL|Indirect Library (IL)]]
** [[WonderWitch .fx files|.fx file format]]
== Links ==
* [https://wonderful.asie.pl/wiki/doku.php?id=wswan:index#guides Wonderful Toolchain Wiki] - gcc-ia16-based homebrew toolchain guides and documentation
* [https://github.com/WonderfulToolchain/awesome-wsdev awesome-wsdev] - curated documentation/tools/source code link list
== MediaWiki ==
* [https://www.mediawiki.org/wiki/Special:MyLanguage/Help:Contents User's Guide]
* [https://www.mediawiki.org/wiki/Special:MyLanguage/Manual:FAQ MediaWiki FAQ]
* [[:Category:Deletion requests|Deletion requests]]
30a738d9252399d740abfc0489bb57d09fdc384f
WonderWitch/IL
0
60
369
2024-10-18T15:53:34Z
Asie
351
Created page with "Indirect libraries (IL) are a FreyaOS feature designed to work around the 64KB segment limit of applications by offloading helper functionality to separate library binaries. == Calling convention == All functions exposed by an IL use the standard 8086 C calling convention - cdecl. * The stack is allocated and cleaned by the caller. * <code>AX</code>, <code>BX</code>, <code>CX</code>, <code>DX</code> can be modified freely by the callee. All other registers must be res..."
wikitext
text/x-wiki
Indirect libraries (IL) are a FreyaOS feature designed to work around the 64KB segment limit of applications by offloading helper functionality to separate library binaries.
== Calling convention ==
All functions exposed by an IL use the standard 8086 C calling convention - cdecl.
* The stack is allocated and cleaned by the caller.
* <code>AX</code>, <code>BX</code>, <code>CX</code>, <code>DX</code> can be modified freely by the callee. All other registers must be restored before returning to its caller.
Note that <code>DS</code> is not changed upon entry and points to the caller function's data segment.
== Format ==
=== Header ===
The location of the IL header is provided by the [[WonderWitch/Filesystem|file entry]].
{| class="wikitable"
|+ Header structure
|-
! Offset !! Length !! Contents
|-
| 0 || 4 || File name; zero-terminated Shift-JIS string.
|-
| 4 || 2 || Number of functions, including <code>get_info</code>.
|-
| 6 || 4 || Far pointer to the function <code>ILinfo __far *get_info(void);</code>.
The function returns a pointer to the IL information structure with a valid segment (for example, sourced from CS).
|-
| 10... || 4... || Further instruction pointers according to the IL's specification.
|}
=== IL information ===
{| class="wikitable"
|+ IL information structure
|-
! Offset !! Length !! Contents
|-
| 0 || 4 || Far pointer to a zero-terminated string containing the IL class name; the segment is ignored.
|-
| 4 || 4 || Far pointer to a zero-terminated string containing the IL name; the segment is ignored.
|-
| 8 || 4 || Far pointer to a zero-terminated string containing the IL version; the segment is ignored.
|-
| 12 || 4 || Far pointer to a zero-terminated string containing the IL description; the segment is ignored.
|-
| 16 || 4 || Far pointer to an array of far pointers to zero-terminated strings containing the IL dependency list; the segment is ignored.
|}
== List of ILs ==
=== Built-in ILs ===
These ILs are included in FreyaOS.
* [[WonderWitch/IL/IlibIL|IlibIL]]
* [[WonderWitch/IL/ProcIL|ProcIL]]
* [[WonderWitch/IL/FsIL|FsIL]]
* [[WonderWitch/IL/RunnableIL|RunnableIL]]
* [[WonderWitch/IL/StreamIL|StreamIL]]
=== SDK-provided ILs ===
These ILs are not included in FreyaOS, but are provided on the WonderWitch disc.
* [[WonderWitch/IL/SoundIL|SoundIL]]
* [[WonderWitch/IL/ResumeIL|ResumeIL]]
0baaea4f0670f32d35843baa14e155e472ae406e
370
369
2024-10-18T16:02:36Z
Asie
351
/* Header */
wikitext
text/x-wiki
Indirect libraries (IL) are a FreyaOS feature designed to work around the 64KB segment limit of applications by offloading helper functionality to separate library binaries.
== Calling convention ==
All functions exposed by an IL use the standard 8086 C calling convention - cdecl.
* The stack is allocated and cleaned by the caller.
* <code>AX</code>, <code>BX</code>, <code>CX</code>, <code>DX</code> can be modified freely by the callee. All other registers must be restored before returning to its caller.
Note that <code>DS</code> is not changed upon entry and points to the caller function's data segment.
== Format ==
=== Header ===
The location of the IL header is provided by the [[WonderWitch/Filesystem|file entry]].
{| class="wikitable"
|+ Header structure
|-
! Offset !! Length !! Contents
|-
| 0 || 4 || TODO
|-
| 4 || 2 || Number of functions, including <code>get_info</code>.
|-
| 6 || 4 || Far pointer to the function <code>ILinfo __far *get_info(void);</code>.
The function returns a pointer to the IL information structure with a valid segment (for example, sourced from CS).
|-
| 10... || 4... || Further instruction pointers according to the IL's specification.
|}
=== IL information ===
{| class="wikitable"
|+ IL information structure
|-
! Offset !! Length !! Contents
|-
| 0 || 4 || Far pointer to a zero-terminated string containing the IL class name; the segment is ignored.
|-
| 4 || 4 || Far pointer to a zero-terminated string containing the IL name; the segment is ignored.
|-
| 8 || 4 || Far pointer to a zero-terminated string containing the IL version; the segment is ignored.
|-
| 12 || 4 || Far pointer to a zero-terminated string containing the IL description; the segment is ignored.
|-
| 16 || 4 || Far pointer to an array of far pointers to zero-terminated strings containing the IL dependency list; the segment is ignored.
|}
== List of ILs ==
=== Built-in ILs ===
These ILs are included in FreyaOS.
* [[WonderWitch/IL/IlibIL|IlibIL]]
* [[WonderWitch/IL/ProcIL|ProcIL]]
* [[WonderWitch/IL/FsIL|FsIL]]
* [[WonderWitch/IL/RunnableIL|RunnableIL]]
* [[WonderWitch/IL/StreamIL|StreamIL]]
=== SDK-provided ILs ===
These ILs are not included in FreyaOS, but are provided on the WonderWitch disc.
* [[WonderWitch/IL/SoundIL|SoundIL]]
* [[WonderWitch/IL/ResumeIL|ResumeIL]]
9e634a68b8d97cc668b63f70ab570f6295dbbb05
380
370
2024-10-19T17:12:13Z
Asie
351
wikitext
text/x-wiki
Indirect libraries (IL) are a FreyaOS feature designed to work around the 64KB segment limit of applications by offloading helper functionality to separate library binaries.
Traditionally, ILs use a file system name prefixed with <code>@</code>; for example, <code>@proc</code> for ProcIL.
== Calling convention ==
All functions exposed by an IL use the standard 8086 C calling convention - cdecl.
* The stack is allocated and cleaned by the caller.
* <code>AX</code>, <code>BX</code>, <code>CX</code>, <code>DX</code> can be modified freely by the callee. All other registers must be restored before returning to its caller.
Note that <code>DS</code> is not changed upon entry and points to the caller function's data segment.
== Format ==
=== Header ===
The location of the IL header is provided by the [[WonderWitch/Filesystem|file entry]].
{| class="wikitable"
|+ Header structure
|-
! Offset !! Length !! Contents
|-
| 0 || 4 || TODO
|-
| 4 || 2 || Number of functions, including <code>get_info</code>.
|-
| 6 || 4 || Far pointer to the function <code>ILinfo __far *get_info(void);</code>.
The function returns a pointer to the IL information structure with a valid segment (for example, sourced from CS).
|-
| 10... || 4... || Further instruction pointers according to the IL's specification.
|}
=== IL information ===
{| class="wikitable"
|+ IL information structure
|-
! Offset !! Length !! Contents
|-
| 0 || 4 || Far pointer to a zero-terminated string containing the IL class name; the segment is ignored.
|-
| 4 || 4 || Far pointer to a zero-terminated string containing the IL name; the segment is ignored.
|-
| 8 || 4 || Far pointer to a zero-terminated string containing the IL version; the segment is ignored.
|-
| 12 || 4 || Far pointer to a zero-terminated string containing the IL description; the segment is ignored.
|-
| 16 || 4 || Far pointer to an array of far pointers to zero-terminated strings containing the IL dependency list; the segment is ignored.
|}
== List of ILs ==
=== Built-in ILs ===
These ILs are included in FreyaOS.
* [[WonderWitch/IL/IlibIL|IlibIL]]
* [[WonderWitch/IL/ProcIL|ProcIL]]
* [[WonderWitch/IL/FsIL|FsIL]]
* [[WonderWitch/IL/RunnableIL|RunnableIL]]
* [[WonderWitch/IL/StreamIL|StreamIL]]
=== SDK-provided ILs ===
These ILs are not included in FreyaOS, but are provided on the WonderWitch disc.
* [[WonderWitch/IL/SoundIL|SoundIL]]
* [[WonderWitch/IL/ResumeIL|ResumeIL]]
266938f7d7fafa07791f715be1f091f594b7b840
WonderWitch/Process
0
61
372
2024-10-18T18:02:49Z
Asie
351
Created page with "== Memory layout == Process memory is stored in SRAM banks 3 (process 0 - typically used by FreyaOS), 2 (process 1) and 1 (process 2). The entire bank is available to the process. === Process control block === The process control block contains information about the running process. It is stored in the first 96 bytes of data. {| class="wikitable" |+ Process control block structure |- ! Offset !! Length !! Contents |- | 0 || 4 || Compiler ID, zero-terminated string; s..."
wikitext
text/x-wiki
== Memory layout ==
Process memory is stored in SRAM banks 3 (process 0 - typically used by FreyaOS), 2 (process 1) and 1 (process 2). The entire bank is available to the process.
=== Process control block ===
The process control block contains information about the running process. It is stored in the first 96 bytes of data.
{| class="wikitable"
|+ Process control block structure
|-
! Offset !! Length !! Contents
|-
| 0 || 4 || Compiler ID, zero-terminated string; see below
|-
| 4 || 2 || TODO
|-
| 6 || 2 || TODO
|-
| 8 || 2 || TODO
|-
| 10 || 2 || TODO
|-
| 12 || 4 || Far pointer to [[WonderWitch/IL/IlibIL|IlibIL]] library
|-
| 16 || 4 || Far pointer to [[WonderWitch/IL/ProcIL|ProcIL]] library
|-
| 20 || 4 || TODO
|-
| 24 || 64 || Current working directory of the process
|-
| 88 || 2 || Near pointer to an array of near pointers to arguments (argv)
|-
| 90 || 4 || Far pointer to the process's resource data
|-
| 94 || 2 || Near pointer to the beginning of the process's free heap area.
|}
=== Compiler IDs ===
{| class="wikitable"
|+ Known compiler IDs
|-
! ID !! Compiler !! Source
|-
| <code>LCC</code> || LSI C || WonderWitch SDK
|-
| <code>TCC</code> || Turbo C/C++ || WonderWitch SDK
|-
| <code>DMC</code> || Digital Mars C || WonderWitch SDK (newer versions)
|-
| <code>GCC</code> || GCC || Wonderful Toolchain
|-
| <code>TCC</code> || Visual C++ || WonBe
|}
== Launching procedure ==
Launching a process is split into two stages: loading and running.
=== Load ===
The load routine begins at offset 0 into the application. It performs the following activities:
- SRAM initialization: copying static data from ROM to SRAM and zeroing SRAM memory,
- copying the compiler ID to the PCB,
- heap initialization: setting the argv and heap pointers to the location of the first free byte in SRAM,
- returning in <code>AX</code> a near pointer to the start function (see "Run").
=== Run ===
The start function is of the form <code>void main(int argc, char* argv);</code>. It typically performs the following activities before jumping to C code:
- configuring the stack pointer,
- resetting the display (disabling screen/sprite layers, clearing window and sprite configuration, resetting scroll),
- initializing screen/sprite VRAM locations according to user needs (one/two screens, 256/512 free tiles),
- initializing the default display settings (configuring text mode, enabling screen layers).
After running C code, <code>INT $10</code> is triggered to exit the process.
1db410ec4719df82df8403c2e3479d57f923be9b
373
372
2024-10-18T18:11:01Z
Asie
351
/* Compiler IDs */
wikitext
text/x-wiki
== Memory layout ==
Process memory is stored in SRAM banks 3 (process 0 - typically used by FreyaOS), 2 (process 1) and 1 (process 2). The entire bank is available to the process.
=== Process control block ===
The process control block contains information about the running process. It is stored in the first 96 bytes of data.
{| class="wikitable"
|+ Process control block structure
|-
! Offset !! Length !! Contents
|-
| 0 || 4 || Compiler ID, zero-terminated string; see below
|-
| 4 || 2 || TODO
|-
| 6 || 2 || TODO
|-
| 8 || 2 || TODO
|-
| 10 || 2 || TODO
|-
| 12 || 4 || Far pointer to [[WonderWitch/IL/IlibIL|IlibIL]] library
|-
| 16 || 4 || Far pointer to [[WonderWitch/IL/ProcIL|ProcIL]] library
|-
| 20 || 4 || TODO
|-
| 24 || 64 || Current working directory of the process
|-
| 88 || 2 || Near pointer to an array of near pointers to arguments (argv)
|-
| 90 || 4 || Far pointer to the process's resource data
|-
| 94 || 2 || Near pointer to the beginning of the process's free heap area.
|}
=== Compiler IDs ===
{| class="wikitable"
|+ Known compiler IDs
|-
! ID !! Compiler !! Source
|-
| <code>LCC</code> || LSI C || WonderWitch SDK
|-
| <code>TCC</code> || Turbo C/C++ || WonderWitch SDK
|-
| <code>DMC</code> || Digital Mars C || WonderWitch SDK (newer versions)
|-
| <code>GCC</code> || gcc-ia16 || Wonderful Toolchain
|-
| <code>TCC</code> || Visual C++ || WonBe
|}
== Launching procedure ==
Launching a process is split into two stages: loading and running.
=== Load ===
The load routine begins at offset 0 into the application. It performs the following activities:
- SRAM initialization: copying static data from ROM to SRAM and zeroing SRAM memory,
- copying the compiler ID to the PCB,
- heap initialization: setting the argv and heap pointers to the location of the first free byte in SRAM,
- returning in <code>AX</code> a near pointer to the start function (see "Run").
=== Run ===
The start function is of the form <code>void main(int argc, char* argv);</code>. It typically performs the following activities before jumping to C code:
- configuring the stack pointer,
- resetting the display (disabling screen/sprite layers, clearing window and sprite configuration, resetting scroll),
- initializing screen/sprite VRAM locations according to user needs (one/two screens, 256/512 free tiles),
- initializing the default display settings (configuring text mode, enabling screen layers).
After running C code, <code>INT $10</code> is triggered to exit the process.
c41bfaee469d9bedef3b42e69850663824880dc5
374
373
2024-10-19T07:51:11Z
Asie
351
/* Launching procedure */
wikitext
text/x-wiki
== Memory layout ==
Process memory is stored in SRAM banks 3 (process 0 - typically used by FreyaOS), 2 (process 1) and 1 (process 2). The entire bank is available to the process.
=== Process control block ===
The process control block contains information about the running process. It is stored in the first 96 bytes of data.
{| class="wikitable"
|+ Process control block structure
|-
! Offset !! Length !! Contents
|-
| 0 || 4 || Compiler ID, zero-terminated string; see below
|-
| 4 || 2 || TODO
|-
| 6 || 2 || TODO
|-
| 8 || 2 || TODO
|-
| 10 || 2 || TODO
|-
| 12 || 4 || Far pointer to [[WonderWitch/IL/IlibIL|IlibIL]] library
|-
| 16 || 4 || Far pointer to [[WonderWitch/IL/ProcIL|ProcIL]] library
|-
| 20 || 4 || TODO
|-
| 24 || 64 || Current working directory of the process
|-
| 88 || 2 || Near pointer to an array of near pointers to arguments (argv)
|-
| 90 || 4 || Far pointer to the process's resource data
|-
| 94 || 2 || Near pointer to the beginning of the process's free heap area.
|}
=== Compiler IDs ===
{| class="wikitable"
|+ Known compiler IDs
|-
! ID !! Compiler !! Source
|-
| <code>LCC</code> || LSI C || WonderWitch SDK
|-
| <code>TCC</code> || Turbo C/C++ || WonderWitch SDK
|-
| <code>DMC</code> || Digital Mars C || WonderWitch SDK (newer versions)
|-
| <code>GCC</code> || gcc-ia16 || Wonderful Toolchain
|-
| <code>TCC</code> || Visual C++ || WonBe
|}
== Launching procedure ==
Launching a process is split into two stages: loading and running.
=== Load ===
The load routine begins at offset 0 into the application. It performs the following activities:
* SRAM initialization: copying static data from ROM to SRAM and zeroing SRAM memory,
* copying the compiler ID to the PCB,
* heap initialization: setting the argv and heap pointers to the location of the first free byte in SRAM,
* returning in <code>AX</code> a near pointer to the start function (see "Run").
=== Run ===
The start function is of the form <code>void main(int argc, char* argv);</code>. It typically performs the following activities before jumping to C code:
* configuring the stack pointer (SP) and data segment (DS),
* resetting the display (disabling screen/sprite layers, clearing window and sprite configuration, resetting scroll),
* initializing screen/sprite VRAM locations according to user needs (one/two screens, 256/512 free tiles),
* initializing the default display settings (configuring text mode, enabling screen layers).
After running C code, <code>INT $10</code> is triggered to exit the process.
45fdf39b96f5fa5c357b14aa47565a014f941009
WonderWitch/FreyaBIOS/Timer
0
62
375
2024-10-19T11:19:10Z
Asie
351
Created page with "The Timer interrupt provides an abstraction layer for the WonderSwan's [[Timers|timers]], as well as the on-cartridge [[Real-Time Clock|RTC]]. == Types == === RTC fields === The RTC field indexes match the order of fields returned by the RTC chip. Note that FreyaBIOS transparently converts the values to and from BCD. {| class="wikitable" |- ! Index !! Data !! Format |- | 0 || Year || 0 - 99; 0 is assumed to be the year 2000. |- | 1 || Month || 1 - 12 |- | 2 || Date..."
wikitext
text/x-wiki
The Timer interrupt provides an abstraction layer for the WonderSwan's [[Timers|timers]], as well as the on-cartridge [[Real-Time Clock|RTC]].
== Types ==
=== RTC fields ===
The RTC field indexes match the order of fields returned by the RTC chip.
Note that FreyaBIOS transparently converts the values to and from BCD.
{| class="wikitable"
|-
! Index !! Data !! Format
|-
| 0 || Year || 0 - 99; 0 is assumed to be the year 2000.
|-
| 1 || Month || 1 - 12
|-
| 2 || Date (day of month) || 1 - 31
|-
| 3 || Day of week || 0 - 6; 0 = Sunday, 1 = Monday, ..., 6 = Saturday
|-
| 4 || Hour || 0 - 23
|-
| 5 || Minute || 0 - 59
|-
| 6 || Second || 0 - 59
|}
=== RTC struct ===
The RTC struct is a seven-byte memory structure, containing all RTC fields consecutively, taking up one unsinged byte each.
== Interrupts ==
=== INT $16/AH=$00 - rtc_reset ===
* AH = $00
=== INT $16/AH=$01 - rtc_set_datetime ===
* AH = $01
* BX = Field
* CX = Value of field
=== INT $16/AH=$02 - rtc_get_datetime ===
* AH = $02
* BX = Field
Return:
* AX = Value of field
=== INT $16/AH=$03 - rtc_set_datetime_struct ===
* AH = $03
* DS:DX = Pointer to RTC struct
=== INT $16/AH=$04 - rtc_get_datetime_struct ===
* AH = $04
* DS:DX = Pointer to RTC struct
=== INT $16/AH=$05 - rtc_enable_alarm ===
* AH = $05
* BL = Hour
* BH = Minute
=== INT $16/AH=$06 - rtc_disable_alarm ===
* AH = $06
=== INT $16/AH=$07 - timer_enable ===
* AH = $07
* AL = Type (0 = HBlank, 1 = VBlank)
* BL = Reload mode (0 = one-shot, 1 = repeating)
* CX = Time, in lines or frames, to wait.
=== INT $16/AH=$08 - timer_disable ===
* AH = $08
* AL = Type (0 = HBlank, 1 = VBlank)
=== INT $16/AH=$09 - timer_get_count ===
* AH = $09
* AL = Type (0 = HBlank, 1 = VBlank)
Return:
* AX = The current counter value, from the time set in <code>timer_enable</code> down.
1a54d001519a9a65502b35f001b0fbaf8307dd6a
WonderWitch/IL/ResumeIL
0
63
376
2024-10-19T12:01:42Z
Asie
351
Created page with "== ResumeIL == ResumeIL is a library which augments the process suspend/resume functionality of the built-in [[WonderWitch/IL/ProcIL|ProcIL]] library to also archive the memory areas <code>0x4000 - 0xBFFF</code> (WSC expanded/4bpp tile memory) and <code>0xFE00 - 0xFFFF</code> (WSC palette memory). This is done by copying this memory to <code>/ram0/resume.dat</code>. === Limitations === - This approach only allows suspending and resuming one process."
wikitext
text/x-wiki
== ResumeIL ==
ResumeIL is a library which augments the process suspend/resume functionality of the built-in [[WonderWitch/IL/ProcIL|ProcIL]] library to also archive the memory areas <code>0x4000 - 0xBFFF</code> (WSC expanded/4bpp tile memory) and <code>0xFE00 - 0xFFFF</code> (WSC palette memory). This is done by copying this memory to <code>/ram0/resume.dat</code>.
=== Limitations ===
- This approach only allows suspending and resuming one process.
e41e168a5fc691d566281069a1ef1613c5bfce01
WonderWitch/FreyaOS
0
49
377
260
2024-10-19T12:05:01Z
Asie
351
add FreyaOS 1.1.2 and 1.1.3 changelog information
wikitext
text/x-wiki
FreyaOS is an operating system and library set for [[WonderWitch]], present in the second-to-last 64 KB of any WonderWitch cartridge.
It provides the following library functionality:
* process management,
* file system access,
* [[WonderWitch/IL|IL]] library management.
It additionally provides an user interface, which allows launching programs and performing file management/transfer operations.
== Revisions ==
* FreyaOS 1.0.0
* FreyaOS 1.0.2 (September 2nd, 2000 <ref>[http://wonderwitch.qute.co.jp/announce/archives/msg00001.html FreyaOS バージョンアップのお知らせ]</ref>)
* FreyaOS 1.0.3 (November 1st, 2000 <ref>[http://wonderwitch.qute.co.jp/announce/archives/msg00004.html FreyaOS バージョンアップのお知らせ]</ref>)
* FreyaOS 1.1.0 (December 24th, 2000 <ref name="history2001">[http://wonderwitch.qute.co.jp/history200107.htm WonderWitch これまでの歩み]</ref>)
* FreyaOS 1.1.1 (February 7th, 2001 <ref name="history2001"/>)
* FreyaOS 1.1.2 (June 20th, 2001 <ref>http://wonderwitch.qute.co.jp/announce/archives/msg00298.html</ref>)
** Improved file system stability.
* FreyaOS 1.1.3 (June 26th, 2001 <ref>http://wonderwitch.qute.co.jp/announce/archives/msg00300.html</ref>)
** Fixed a regression in programs which used resource files.
** Fixed the ''lseek()'' function in the file system library.
* FreyaOS 1.1.4 (September 27th, 2001 <ref name="history2002">[http://wonderwitch.qute.co.jp/history200207.htm WonderWitch これまでの歩み 2002]</ref>)
* FreyaOS 1.1.5 (March 5th, 2002 <ref name="history2002"/>)
* FreyaOS 1.1.6 beta1 (April 30th, 2002 <ref>[http://wonderwitch.qute.co.jp/announce/archives/msg00321.html FreyaOS βバージョン提供のお知らせ]</ref>)
** Fixed IRAM corruption when calling ''open()''/''stat()'' after initializing SoundIL.
* FreyaOS 1.2.0 (July 13th, 2002 <ref>[http://wonderwitch.qute.co.jp/index_wwp.html WonderWitchプレーヤー サポートページ]</ref>)
** Validated for SwanCrystal consoles.
* FreyaOS 1.2.0S
** Special, stripped-down version of FreyaOS 1.2.0 used on pre-programmed Judgement Silversword and Dicing Knight cartridges.
== Documentation ==
* [[WonderWitch .fx files|.fx file format]]
== Notes ==
<references />
6b5814d38420b4343f07e1202569d841c8d532ab
378
377
2024-10-19T12:05:44Z
Asie
351
/* Revisions */
wikitext
text/x-wiki
FreyaOS is an operating system and library set for [[WonderWitch]], present in the second-to-last 64 KB of any WonderWitch cartridge.
It provides the following library functionality:
* process management,
* file system access,
* [[WonderWitch/IL|IL]] library management.
It additionally provides an user interface, which allows launching programs and performing file management/transfer operations.
== Revisions ==
* FreyaOS 1.0.0
* FreyaOS 1.0.2 (September 2nd, 2000 <ref>[http://wonderwitch.qute.co.jp/announce/archives/msg00001.html FreyaOS バージョンアップのお知らせ]</ref>)
* FreyaOS 1.0.3 (November 1st, 2000 <ref>[http://wonderwitch.qute.co.jp/announce/archives/msg00004.html FreyaOS バージョンアップのお知らせ]</ref>)
* FreyaOS 1.1.0 (December 24th, 2000 <ref name="history2001">[http://wonderwitch.qute.co.jp/history200107.htm WonderWitch これまでの歩み]</ref>)
* FreyaOS 1.1.1 (February 7th, 2001 <ref name="history2001"/>)
* FreyaOS 1.1.2 (June 20th, 2001 <ref>[http://wonderwitch.qute.co.jp/announce/archives/msg00298.html 最新ソフトウェアリリースのお知らせ]</ref>)
** Improved file system stability.
* FreyaOS 1.1.3 (June 26th, 2001 <ref>[http://wonderwitch.qute.co.jp/announce/archives/msg00300.html 最新ソフトウェアリリースのお知らせ]</ref>)
** Fixed a regression in programs which used resource files.
** Fixed the ''lseek()'' function in the file system library.
* FreyaOS 1.1.4 (September 27th, 2001 <ref name="history2002">[http://wonderwitch.qute.co.jp/history200207.htm WonderWitch これまでの歩み 2002]</ref>)
* FreyaOS 1.1.5 (March 5th, 2002 <ref name="history2002"/>)
* FreyaOS 1.1.6 beta1 (April 30th, 2002 <ref>[http://wonderwitch.qute.co.jp/announce/archives/msg00321.html FreyaOS βバージョン提供のお知らせ]</ref>)
** Fixed IRAM corruption when calling ''open()''/''stat()'' after initializing SoundIL.
* FreyaOS 1.2.0 (July 13th, 2002 <ref>[http://wonderwitch.qute.co.jp/index_wwp.html WonderWitchプレーヤー サポートページ]</ref>)
** Validated for SwanCrystal consoles.
* FreyaOS 1.2.0S
** Special, stripped-down version of FreyaOS 1.2.0 used on pre-programmed Judgement Silversword and Dicing Knight cartridges.
== Documentation ==
* [[WonderWitch .fx files|.fx file format]]
== Notes ==
<references />
1ff1fa541ff80d9f75ea7f13a1ac26a563a012ee
WonderWitch/IL/IlibIL
0
64
379
2024-10-19T12:51:36Z
Asie
351
Created page with "IlibIL is a library used to load other indirect libraries present on the system. == Functions == === open === <code>int open(const char far *name, IL far *buffer);</code> Load the specified IL <code>name</code> from <code>/rom0</code> or <code>/kern</code>. The IL header is copied to the provided <code>buffer</code> with addresses appropriately relocated to match the IL's location in ROM. === open_system === <code>int open_system(const char far *name, IL far *buffe..."
wikitext
text/x-wiki
IlibIL is a library used to load other indirect libraries present on the system.
== Functions ==
=== open ===
<code>int open(const char far *name, IL far *buffer);</code>
Load the specified IL <code>name</code> from <code>/rom0</code> or <code>/kern</code>. The IL header is copied to the provided <code>buffer</code> with addresses appropriately relocated to match the IL's location in ROM.
=== open_system ===
<code>int open_system(const char far *name, IL far *buffer);</code>
Works like <code>open</code>, except only <code>/kern</code> is queried for the presence of the library.
861bb838fcd4dc14863a0e74f723b35f79da2fc7
WonderWitch/Memory map
0
65
382
2024-10-19T19:13:28Z
Asie
351
Created page with "== Memory map == {| class="wikitable" |+ WonderWitch memory map ! Address ! ASCII, 1 screen ! ASCII, 2 screens ! Shift-JIS, 1 screen ! Shift-JIS, 2 screens |- | style="text-align: center;" | 0x0000 | colspan="4" style="text-align: center;" | Interrupt vectors |- | style="text-align: center;" | 0x0100 | colspan="4" style="text-align: center;" | ? |- | style="text-align: center;" | 0x0E00 | rowspan="7" style="text-align: center;" | | rowspan="5" style="text-align: center;..."
wikitext
text/x-wiki
== Memory map ==
{| class="wikitable"
|+ WonderWitch memory map
! Address
! ASCII, 1 screen
! ASCII, 2 screens
! Shift-JIS, 1 screen
! Shift-JIS, 2 screens
|-
| style="text-align: center;" | 0x0000
| colspan="4" style="text-align: center;" | Interrupt vectors
|-
| style="text-align: center;" | 0x0100
| colspan="4" style="text-align: center;" | ?
|-
| style="text-align: center;" | 0x0E00
| rowspan="7" style="text-align: center;" |
| rowspan="5" style="text-align: center;" |
| rowspan="2" style="text-align: center;" |
| style="text-align: center;" | Sprite table
|-
| style="text-align: center;" | 0x1000
| rowspan="2" style="text-align: center;" | Screen 1
|-
| style="text-align: center;" | 0x1600
| style="text-align: center;" | Sprite table
|-
| style="text-align: center;" | 0x1800
| style="text-align: center;" | Screen 1
| style="text-align: center;" | Screen 2
|-
| style="text-align: center;" | 0x2000
| rowspan="6" colspan="2" style="text-align: center;" | Tile data (512 tiles)
|-
| style="text-align: center;" | 0x2600
| style="text-align: center;" | Sprite table
|-
| style="text-align: center;" | 0x2800
| rowspan="2" style="text-align: center;" | Screen 2
|-
| style="text-align: center;" | 0x2E00
| style="text-align: center;" | Sprite table
|-
| style="text-align: center;" | 0x3000
| colspan="2" style="text-align: center;" | Screen 1
|-
| style="text-align: center;" | 0x3800
| colspan="2" style="text-align: center;" | Tile data (128 tiles)
|-
| style="text-align: center;" | 0x4000
| colspan="4" style="text-align: center;" | Color tile data; only restored with [[WonderWitch/IL/ResumeIL|ResumeIL]].
|-
| style="text-align: center;" | 0xC000
| colspan="4" style="text-align: center;" | Unused; never restored on program suspend/resume.
|-
| style="text-align: center;" | 0xFE00
| colspan="4" style="text-align: center;" | Color palette data; only restored with [[WonderWitch/IL/ResumeIL|ResumeIL]].
|}
In all modes, the stack is placed immediately before the sprite table.
8471ae4596bd9d84af48164ade565d829fcfc827
383
382
2024-10-19T19:13:34Z
Asie
351
wikitext
text/x-wiki
{| class="wikitable"
|+ WonderWitch memory map
! Address
! ASCII, 1 screen
! ASCII, 2 screens
! Shift-JIS, 1 screen
! Shift-JIS, 2 screens
|-
| style="text-align: center;" | 0x0000
| colspan="4" style="text-align: center;" | Interrupt vectors
|-
| style="text-align: center;" | 0x0100
| colspan="4" style="text-align: center;" | ?
|-
| style="text-align: center;" | 0x0E00
| rowspan="7" style="text-align: center;" |
| rowspan="5" style="text-align: center;" |
| rowspan="2" style="text-align: center;" |
| style="text-align: center;" | Sprite table
|-
| style="text-align: center;" | 0x1000
| rowspan="2" style="text-align: center;" | Screen 1
|-
| style="text-align: center;" | 0x1600
| style="text-align: center;" | Sprite table
|-
| style="text-align: center;" | 0x1800
| style="text-align: center;" | Screen 1
| style="text-align: center;" | Screen 2
|-
| style="text-align: center;" | 0x2000
| rowspan="6" colspan="2" style="text-align: center;" | Tile data (512 tiles)
|-
| style="text-align: center;" | 0x2600
| style="text-align: center;" | Sprite table
|-
| style="text-align: center;" | 0x2800
| rowspan="2" style="text-align: center;" | Screen 2
|-
| style="text-align: center;" | 0x2E00
| style="text-align: center;" | Sprite table
|-
| style="text-align: center;" | 0x3000
| colspan="2" style="text-align: center;" | Screen 1
|-
| style="text-align: center;" | 0x3800
| colspan="2" style="text-align: center;" | Tile data (128 tiles)
|-
| style="text-align: center;" | 0x4000
| colspan="4" style="text-align: center;" | Color tile data; only restored with [[WonderWitch/IL/ResumeIL|ResumeIL]].
|-
| style="text-align: center;" | 0xC000
| colspan="4" style="text-align: center;" | Unused; never restored on program suspend/resume.
|-
| style="text-align: center;" | 0xFE00
| colspan="4" style="text-align: center;" | Color palette data; only restored with [[WonderWitch/IL/ResumeIL|ResumeIL]].
|}
In all modes, the stack is placed immediately before the sprite table.
0fafea4cf92f1fc0afacf809039c328fb956baeb
384
383
2024-10-19T19:20:55Z
Asie
351
wikitext
text/x-wiki
The following documents the official WonderWitch memory map. Note that you are not required to follow these rules to the letter; however, some amount of the beginning of memory is expected to be left to FreyaBIOS, FreyaOS, etc.
{| class="wikitable"
|+ WonderWitch memory map
! Address
! ASCII, 1 screen
! ASCII, 2 screens
! Shift-JIS, 1 screen
! Shift-JIS, 2 screens
|-
| style="text-align: center;" | 0x0000
| colspan="4" style="text-align: center;" | Interrupt vectors
|-
| style="text-align: center;" | 0x0100
| colspan="4" style="text-align: center;" | ?
|-
| style="text-align: center;" | 0x0E00
| rowspan="7" style="text-align: center;" |
| rowspan="5" style="text-align: center;" |
| rowspan="2" style="text-align: center;" |
| style="text-align: center;" | Sprite table
|-
| style="text-align: center;" | 0x1000
| rowspan="2" style="text-align: center;" | Screen 1
|-
| style="text-align: center;" | 0x1600
| style="text-align: center;" | Sprite table
|-
| style="text-align: center;" | 0x1800
| style="text-align: center;" | Screen 1
| style="text-align: center;" | Screen 2
|-
| style="text-align: center;" | 0x2000
| rowspan="6" colspan="2" style="text-align: center;" | Tile data (512 tiles)
|-
| style="text-align: center;" | 0x2600
| style="text-align: center;" | Sprite table
|-
| style="text-align: center;" | 0x2800
| rowspan="2" style="text-align: center;" | Screen 2
|-
| style="text-align: center;" | 0x2E00
| style="text-align: center;" | Sprite table
|-
| style="text-align: center;" | 0x3000
| colspan="2" style="text-align: center;" | Screen 1
|-
| style="text-align: center;" | 0x3800
| colspan="2" style="text-align: center;" | Tile data (128 tiles)
|-
| style="text-align: center;" | 0x4000
| colspan="4" style="text-align: center;" | Color tile data; only restored with [[WonderWitch/IL/ResumeIL|ResumeIL]].
|-
| style="text-align: center;" | 0xC000
| colspan="4" style="text-align: center;" | Unused; never restored on program suspend/resume.
|-
| style="text-align: center;" | 0xFE00
| colspan="4" style="text-align: center;" | Color palette data; only restored with [[WonderWitch/IL/ResumeIL|ResumeIL]].
|}
In all modes, the stack is placed immediately before the sprite table.
32fb33df1ab7176cc4e4d019b83d2e2c13b1a9f9
386
384
2024-10-19T20:46:12Z
Asie
351
wikitext
text/x-wiki
The following documents the official WonderWitch memory map. Note that you are not required to follow these rules to the letter; however, some amount of the beginning of memory is expected to be left to FreyaBIOS, FreyaOS, etc.
=== Internal RAM (0x00000 - 0x0FFFF) ===
{| class="wikitable"
|+ WonderWitch memory map
! Address
! ASCII, 1 screen
! ASCII, 2 screens
! Shift-JIS, 1 screen
! Shift-JIS, 2 screens
|-
| style="text-align: center;" | 0x0000
| colspan="4" style="text-align: center;" | Interrupt vectors
|-
| style="text-align: center;" | 0x0100
| colspan="4" style="text-align: center;" | ?
|-
| style="text-align: center;" | 0x0E00
| rowspan="7" style="text-align: center;" |
| rowspan="5" style="text-align: center;" |
| rowspan="2" style="text-align: center;" |
| style="text-align: center;" | Sprite table
|-
| style="text-align: center;" | 0x1000
| rowspan="2" style="text-align: center;" | Screen 1
|-
| style="text-align: center;" | 0x1600
| style="text-align: center;" | Sprite table
|-
| style="text-align: center;" | 0x1800
| style="text-align: center;" | Screen 1
| style="text-align: center;" | Screen 2
|-
| style="text-align: center;" | 0x2000
| rowspan="6" colspan="2" style="text-align: center;" | Tile data (512 tiles)
|-
| style="text-align: center;" | 0x2600
| style="text-align: center;" | Sprite table
|-
| style="text-align: center;" | 0x2800
| rowspan="2" style="text-align: center;" | Screen 2
|-
| style="text-align: center;" | 0x2E00
| style="text-align: center;" | Sprite table
|-
| style="text-align: center;" | 0x3000
| colspan="2" style="text-align: center;" | Screen 1
|-
| style="text-align: center;" | 0x3800
| colspan="2" style="text-align: center;" | Tile data (128 tiles)
|-
| style="text-align: center;" | 0x4000
| colspan="4" style="text-align: center;" | Color tile data; only restored with [[WonderWitch/IL/ResumeIL|ResumeIL]].
|-
| style="text-align: center;" | 0xC000
| colspan="4" style="text-align: center;" | Unused; never restored on program suspend/resume.
|-
| style="text-align: center;" | 0xFE00
| colspan="4" style="text-align: center;" | Color palette data; only restored with [[WonderWitch/IL/ResumeIL|ResumeIL]].
|}
In all modes, the stack is placed immediately before the sprite table.
==== Interrupt vectors ====
{| class="wikitable"
! Start
! End
! Description
|-
| 0x00
| 0x07
| CPU interrupts
|-
| 0x08
| 0x0F
|
|-
| 0x10
| 0x18
| [[WonderWitch/FreyaBIOS|FreyaBIOS]] interrupts
|}
=== Cartridge SRAM (0x10000 - 0x1FFFF) ===
{| class="wikitable"
! Bank
! Description
|-
| 0
| [[WonderWitch/Filesystem|/ram0 file data]]
|-
| 1
| Third process data
|-
| 2
| Second process data
|-
| 3
| First process data; typically used by [[WonderWitch/FreyaOS|FreyaOS]]
|}
=== Cartridge flash (0x80000 - 0xFFFFF) ===
The 512KB of NOR flash memory is mapped and partitioned as follows:
{| class="wikitable"
! Linear address
! Size
! Description
|-
| 0x8nnnn
| rowspan="6" | 384 KB
| rowspan="6" | [[WonderWitch/Filesystem|/rom0 file data]]
|-
| 0x9nnnn
|-
| 0xAnnnn
|-
| 0xBnnnn
|-
| 0xCnnnn
|-
| 0xDnnnn
|-
| 0xEnnnn
| 64 KB
| [[WonderWitch/FreyaOS|FreyaOS]]
|-
| 0xFnnnn
| 64 KB
| [[WonderWitch/FreyaBIOS|FreyaBIOS]]
|}
98cf901fca2451abe57fded75f0cbaea9ee4ae81
WonderWitch
0
41
385
318
2024-10-19T20:43:52Z
Asie
351
/* Memory map */
wikitext
text/x-wiki
The WonderWitch is an official homebrew development kit released by Qute Corporation on July 18th, 2000.
== Hardware ==
The WonderWitch cartridge is based on the [[Bandai 2003]] mapper. It provides an RTC, as well as NOR self-flashing functionality using the Fujitsu MBM29DL400TC chip.
There were three means of acquiring WonderWitch cartridges:
* '''WonderWitch''', a software development kit containing a reflashable cartridge, a WonderSwan<->RS-232 adapter, a development manual and a development tool CD;
* '''WonderWitch Player''', a priced-down user-only version omitting the development manual and tooling;
* The VAR program, allowing independent creators to buy reflashable cartridges in bulk, in units of 20 or 100.
== Software ==
The WonderWitch provides an abstraction layer and helper libraries, split into two modules:
* [[WonderWitch/FreyaBIOS|FreyaBIOS]] - providing a hardware abstraction layer and some utility functions,
* [[WonderWitch/FreyaOS|FreyaOS]] - providing helper libraries and higher-level concepts, such as processes and files.
== Development tools ==
TODO
== Links ==
* [https://github.com/up-n-atom/WonderWitch/blob/main/Datasheets/MBM29DL400BC-12PFTN_to_MBM29DL400TC-90PFTN.pdf Fujitsu MBM29DL400TC datasheet]
894f1dc0e2516dd182d318fdefff73e1d84b282f
WonderWitch/FreyaBIOS
0
42
387
327
2024-10-19T20:46:38Z
Asie
351
/* Revisions */
wikitext
text/x-wiki
FreyaBIOS is a boot program and hardware abstraction layer for [[WonderWitch]], present in the top-most (last) 64 KB of any WonderWitch cartridge.
It provides the following functionality:
* bring-up code,
* interrupt-based hardware abstraction layer, providing a more user-friendly (and less direct) interface to the WonderSwan hardware,
* 8x8 ASCII and kanji fonts,
* a monitor program, allowing FreyaOS recovery and updates via XMODEM.
Other functionality (like file system access) is instead included as part of [[WonderWitch/FreyaOS|FreyaOS]]' system libraries; some other functionality (like [[WonderWitch/libwwc|WonderSwan Color support]]) is implemented as part of the development tooling.
== Revisions ==
- FreyaBIOS 1.0.0
== Fonts ==
As part of its ROM image, FreyaBIOS provides two fonts:
* an 8x8 ASCII font,
* an 8x8 Shift-JIS kanji font - [http://hp.vector.co.jp/authors/VA002310/original.html ELISA FONT].
== Interrupts ==
* [[WonderWitch/FreyaBIOS/Exit|Exit]] (INT $10)
* [[WonderWitch/FreyaBIOS/Key|Key]] (INT $11)
* [[WonderWitch/FreyaBIOS/Display|Display]] (INT $12)
* [[WonderWitch/FreyaBIOS/Text|Text]] (INT $13)
* [[WonderWitch/FreyaBIOS/Communication|Communication]] (INT $14)
* [[WonderWitch/FreyaBIOS/Sound|Sound]] (INT $15)
* [[WonderWitch/FreyaBIOS/Timer|Timer]] (INT $16)
* [[WonderWitch/FreyaBIOS/System|System]] (INT $17)
* [[WonderWitch/FreyaBIOS/Bank|Bank]] (INT $18)
== Freya Monitor ==
TODO
caf9df887b876b8c9395fad863fa44868a270826
388
387
2024-10-19T20:46:45Z
Asie
351
/* Revisions */
wikitext
text/x-wiki
FreyaBIOS is a boot program and hardware abstraction layer for [[WonderWitch]], present in the top-most (last) 64 KB of any WonderWitch cartridge.
It provides the following functionality:
* bring-up code,
* interrupt-based hardware abstraction layer, providing a more user-friendly (and less direct) interface to the WonderSwan hardware,
* 8x8 ASCII and kanji fonts,
* a monitor program, allowing FreyaOS recovery and updates via XMODEM.
Other functionality (like file system access) is instead included as part of [[WonderWitch/FreyaOS|FreyaOS]]' system libraries; some other functionality (like [[WonderWitch/libwwc|WonderSwan Color support]]) is implemented as part of the development tooling.
== Revisions ==
* FreyaBIOS 1.0.0
== Fonts ==
As part of its ROM image, FreyaBIOS provides two fonts:
* an 8x8 ASCII font,
* an 8x8 Shift-JIS kanji font - [http://hp.vector.co.jp/authors/VA002310/original.html ELISA FONT].
== Interrupts ==
* [[WonderWitch/FreyaBIOS/Exit|Exit]] (INT $10)
* [[WonderWitch/FreyaBIOS/Key|Key]] (INT $11)
* [[WonderWitch/FreyaBIOS/Display|Display]] (INT $12)
* [[WonderWitch/FreyaBIOS/Text|Text]] (INT $13)
* [[WonderWitch/FreyaBIOS/Communication|Communication]] (INT $14)
* [[WonderWitch/FreyaBIOS/Sound|Sound]] (INT $15)
* [[WonderWitch/FreyaBIOS/Timer|Timer]] (INT $16)
* [[WonderWitch/FreyaBIOS/System|System]] (INT $17)
* [[WonderWitch/FreyaBIOS/Bank|Bank]] (INT $18)
== Freya Monitor ==
TODO
1c138b256e4b0221a7ef4b209b78cb4fdedc2cef
WonderWitch/FreyaBIOS/Bank
0
55
390
329
2024-10-20T10:29:53Z
Asie
351
wikitext
text/x-wiki
The Bank interrupt provides an abstraction layer for accessing the WonderWitch cartridge's flash and RAM.
== Interrupts ==
=== INT $18/AH=$00 - bank_set_map ===
* AH = $00
* BL = Bank region
* CX = Number of bank to map to region
Bank regions:
* 0 = SRAM (1000:xxxx)
* 1 = ROM0 (2000:xxxx)
* 2 = ROM1 (3000:xxxx)
=== INT $18/AH=$01 - bank_get_map ===
* AH = $01
* BL = Bank region
Return:
* AX = Number of bank mapped to region
=== INT $18/AH=$02 - bank_read_byte ===
* AH = $02
* BX = Bank ID
* DX = Offset within bank
Return:
* AL = Byte read
Bank ID format:
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
tiii iiii iiii iiii
|||| |||| |||| ||||
|+++-++++--++++-++++- Number of bank
+-------------------- 0 = SRAM, 1 = Flash
</pre>
=== INT $18/AH=$03 - bank_write_byte ===
* AH = $03
* BX = Bank ID
* CL = Byte to write
* DX = Offset within bank
=== INT $18/AH=$04 - bank_read_word ===
* AH = $04
* BX = Bank ID
* DX = Offset within bank
Return:
* AX = Word read
=== INT $18/AH=$05 - bank_write_word ===
* AH = $05
* BX = Bank ID
* CX = Word to write
* DX = Offset within bank
=== INT $18/AH=$06 - bank_read_block ===
* AH = $06
* BX = Bank ID
* CX = Number of bytes to read
* DX = Offset within bank
* DS:SI = Output buffer, of size <code>CX</code>
=== INT $18/AH=$07 - bank_write_block ===
* AH = $07
* BX = Bank ID
* CX = Number of bytes to write
* DX = Offset within bank
* DS:SI = Input buffer, of size <code>CX</code>
=== INT $18/AH=$08 - bank_fill_block ===
* AH = $08
* AL = Fill value
* BX = Bank ID
* CX = Number of bytes to write
* DX = Offset within bank
Sets <code>CX</code> bytes in bank <code>BX</code> to value <code>AL</code> starting at offset <code>DX</code>.
=== INT $18/AH=$09 - bank_erase_flash ===
* AH = $09
* BX = Bank ID
cb27db74fdd6fa22113fa81a4aefcdf43cffe6cc
391
390
2024-10-20T10:39:52Z
Asie
351
/* INT $18/AH=$09 - bank_erase_flash */
wikitext
text/x-wiki
The Bank interrupt provides an abstraction layer for accessing the WonderWitch cartridge's flash and RAM.
== Interrupts ==
=== INT $18/AH=$00 - bank_set_map ===
* AH = $00
* BL = Bank region
* CX = Number of bank to map to region
Bank regions:
* 0 = SRAM (1000:xxxx)
* 1 = ROM0 (2000:xxxx)
* 2 = ROM1 (3000:xxxx)
=== INT $18/AH=$01 - bank_get_map ===
* AH = $01
* BL = Bank region
Return:
* AX = Number of bank mapped to region
=== INT $18/AH=$02 - bank_read_byte ===
* AH = $02
* BX = Bank ID
* DX = Offset within bank
Return:
* AL = Byte read
Bank ID format:
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
tiii iiii iiii iiii
|||| |||| |||| ||||
|+++-++++--++++-++++- Number of bank
+-------------------- 0 = SRAM, 1 = Flash
</pre>
=== INT $18/AH=$03 - bank_write_byte ===
* AH = $03
* BX = Bank ID
* CL = Byte to write
* DX = Offset within bank
=== INT $18/AH=$04 - bank_read_word ===
* AH = $04
* BX = Bank ID
* DX = Offset within bank
Return:
* AX = Word read
=== INT $18/AH=$05 - bank_write_word ===
* AH = $05
* BX = Bank ID
* CX = Word to write
* DX = Offset within bank
=== INT $18/AH=$06 - bank_read_block ===
* AH = $06
* BX = Bank ID
* CX = Number of bytes to read
* DX = Offset within bank
* DS:SI = Output buffer, of size <code>CX</code>
=== INT $18/AH=$07 - bank_write_block ===
* AH = $07
* BX = Bank ID
* CX = Number of bytes to write
* DX = Offset within bank
* DS:SI = Input buffer, of size <code>CX</code>
=== INT $18/AH=$08 - bank_fill_block ===
* AH = $08
* AL = Fill value
* BX = Bank ID
* CX = Number of bytes to write
* DX = Offset within bank
Sets <code>CX</code> bytes in bank <code>BX</code> to value <code>AL</code> starting at offset <code>DX</code>.
=== INT $18/AH=$09 - bank_erase_flash ===
* AH = $09
* BX = Bank ID
Return:
* AX = zero on success (undocumented)
78e79cae9ca99df150ec4b413138bdf851896253
392
391
2024-10-20T13:13:02Z
Asie
351
/* INT $18/AH=$07 - bank_write_block */
wikitext
text/x-wiki
The Bank interrupt provides an abstraction layer for accessing the WonderWitch cartridge's flash and RAM.
== Interrupts ==
=== INT $18/AH=$00 - bank_set_map ===
* AH = $00
* BL = Bank region
* CX = Number of bank to map to region
Bank regions:
* 0 = SRAM (1000:xxxx)
* 1 = ROM0 (2000:xxxx)
* 2 = ROM1 (3000:xxxx)
=== INT $18/AH=$01 - bank_get_map ===
* AH = $01
* BL = Bank region
Return:
* AX = Number of bank mapped to region
=== INT $18/AH=$02 - bank_read_byte ===
* AH = $02
* BX = Bank ID
* DX = Offset within bank
Return:
* AL = Byte read
Bank ID format:
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
tiii iiii iiii iiii
|||| |||| |||| ||||
|+++-++++--++++-++++- Number of bank
+-------------------- 0 = SRAM, 1 = Flash
</pre>
=== INT $18/AH=$03 - bank_write_byte ===
* AH = $03
* BX = Bank ID
* CL = Byte to write
* DX = Offset within bank
=== INT $18/AH=$04 - bank_read_word ===
* AH = $04
* BX = Bank ID
* DX = Offset within bank
Return:
* AX = Word read
=== INT $18/AH=$05 - bank_write_word ===
* AH = $05
* BX = Bank ID
* CX = Word to write
* DX = Offset within bank
=== INT $18/AH=$06 - bank_read_block ===
* AH = $06
* BX = Bank ID
* CX = Number of bytes to read
* DX = Offset within bank
* DS:SI = Output buffer, of size <code>CX</code>
=== INT $18/AH=$07 - bank_write_block ===
* AH = $07
* BX = Bank ID
* CX = Number of bytes to write
* DX = Offset within bank
* DS:SI = Input buffer, of size <code>CX</code>
Return:
* AX = zero on success (undocumented)
=== INT $18/AH=$08 - bank_fill_block ===
* AH = $08
* AL = Fill value
* BX = Bank ID
* CX = Number of bytes to write
* DX = Offset within bank
Sets <code>CX</code> bytes in bank <code>BX</code> to value <code>AL</code> starting at offset <code>DX</code>.
=== INT $18/AH=$09 - bank_erase_flash ===
* AH = $09
* BX = Bank ID
Return:
* AX = zero on success (undocumented)
b28fbd81f885a66fa1b67bb7549991d0a9476c65
WonderWitch/FreyaBIOS/System
0
66
393
2024-10-20T16:39:04Z
Asie
351
Created page with "The System interrupt provides assorted system-related functionality. == Types == === Suspend/resume structure === This structure is stored in SRAM block 3, offset <code>$7E00</code> (core 1) and <code>$BF00</code> (core 0). {| class="wikitable" |- ! Offset !! Size !! Contents |- | $0000 || 16384 || Copy of RAM area <code>$0000</code> - <code>$3FFF</code> |- | $4000 || 2 || Stack segment? |- | $4002 || 2 || Data segment? |- | $4004 || 224 || Copy of IO ports <code>$00..."
wikitext
text/x-wiki
The System interrupt provides assorted system-related functionality.
== Types ==
=== Suspend/resume structure ===
This structure is stored in SRAM block 3, offset <code>$7E00</code> (core 1) and <code>$BF00</code> (core 0).
{| class="wikitable"
|-
! Offset !! Size !! Contents
|-
| $0000 || 16384 || Copy of RAM area <code>$0000</code> - <code>$3FFF</code>
|-
| $4000 || 2 || Stack segment?
|-
| $4002 || 2 || Data segment?
|-
| $4004 || 224 || Copy of IO ports <code>$00</code> - <code>$DF</code>
|-
| $40E4 || 6 || ?
|}
== Interrupts ==
TODO
adfb4ba8b26151611ec8c5d94a2a4e1d272256c0
Mapper
0
17
395
53
2024-11-24T17:40:34Z
Asie
351
clarify terminology
wikitext
text/x-wiki
There are three documented memory-mapping chips used on the WonderSwan and Pocket Challenge V2:
* [[Bandai 2001]]
* [[Bandai 2003]]
* [[KARNAK]] (Pocket Challenge V2 cartridges only)
All three provide this same common subset for memory banking:
{| class="wikitable"
! Category
! Port
! Description
! Bits
! Type
! Notes
|-
! rowspan="4" | Extended bankswitching
! $C0
| ROM Linear (EX) Bank
| style="text-align: right" | <tt style="white-space: nowrap">00BB bbbb</tt>
| RW8
| Selects a 1MiB bank accessed via memory addresses 0x40000 - 0xFFFFF.
Note that only the top 768KiB of said bank can be read this way.
|-
! $C1
| RAM Bank
| style="text-align: right" | <tt style="white-space: nowrap">bbbb bbbb</tt>
| RW8
| Selects a 64KiB bank accessed via memory addresses 0x10000 - 0x1FFFF.
|-
! $C2
| ROM0 Bank
| style="text-align: right" | <tt style="white-space: nowrap">bbbb bbbb</tt>
| RW8
| Selects a 64KiB bank accessed via memory addresses 0x20000 - 0x2FFFF.
|-
! $C3
| ROM1 Bank
| style="text-align: right" | <tt style="white-space: nowrap">bbbb bbbb</tt>
| RW8
| Selects a 64KiB bank accessed via memory addresses 0x30000 - 0x3FFFF.
|}
Note that the number of bits in the Linear bank register depends on the mapper.
The "mono" WonderSwan expects that the register at $C3 will power up holding $FF.
a2bf6ca1b9045148a0d0e8c802721f238fb338d5
Bandai 2003
0
13
396
253
2024-11-24T17:44:04Z
Asie
351
clarify terminology
wikitext
text/x-wiki
The Bandai 2003 (LUXSOR2) is one of the two mappers used in WonderSwan cartridges.
In addition to the normal [[Mapper]] banking interface, Bandai's 2003 adds registers for an RTC interface, GPO pins, self flashing, and accessing more than 16MiB of ROM.
{| class="wikitable"
! Category
! Port
! Description
! Bits
! Type
! Notes
|-
! rowspan="3" | RTC
! rowspan="2" | $CA
| RTC Command
| style="text-align: right" | <tt style="white-space: nowrap">...1 CCCC</tt>
| W8
| Command (C)
|-
| RTC Status
| style="text-align: right" | <tt style="white-space: nowrap">D00B CCCC</tt>
| R8
| Busy (B), Command (C), Data needed (D)
|-
! $CB
| RTC Payload
| style="text-align: right" | <tt style="white-space: nowrap">dddd dddd</tt>
| RW8
| Data (d)
|-
! rowspan="2" | GPO
! $CC
| GPO Data Direction
| style="text-align: right" | <tt style="white-space: nowrap">0000 oooo</tt>
| RW8
| 1 = output, 0 = high-impedance (weak pull-down)
|-
! $CD
| GPO Data
| style="text-align: right" | <tt style="white-space: nowrap">0000 dddd</tt>
| RW8
| 1 = 3V, if enabled by data direction
|-
! Self-Flash
! $CE
| Self-Flash Control
| style="text-align: right" | <tt style="white-space: nowrap">0000 000r</tt>
| RW8
| 1 = ROM is accessed via the 0x10000 - 0x1FFFF memory region.
0 = RAM is accessed via the region.
|-
! rowspan="4" | Extended bankswitching
! $CF
| ROM Linear (EX) Bank
| style="text-align: right" | <tt style="white-space: nowrap">00bb bbbb</tt>
| RW8
| Selects a 1MiB bank accessed via memory addresses 0x40000 - 0xFFFFF.
Identical to the $C0 port.
|-
! $D0
| RAM(/ROM) Bank
| style="text-align: right" | <tt style="white-space: nowrap">0000 00bb bbbb bbbb</tt>
| RW16
| Selects a 64KiB bank accessed via memory addresses 0x10000 - 0x1FFFF.
Lower 8 bits are identical to the $C1 port.
|-
! $D2
| ROM0 Bank
| style="text-align: right" | <tt style="white-space: nowrap">0000 00bb bbbb bbbb</tt>
| RW16
| Selects a 64KiB bank accessed via memory addresses 0x20000 - 0x2FFFF.
Lower 8 bits are identical to the $C2 port.
|-
! $D4
| ROM1 Bank
| style="text-align: right" | <tt style="white-space: nowrap">0000 00bb bbbb bbbb</tt>
| RW16
| Selects a 64KiB bank accessed via memory addresses 0x30000 - 0x3FFFF.
Lower 8 bits are identical to the $C3 port.
|}
Note that the SRAM memory area is always accessed in byte as opposed to word mode. This means that, if the ROM/flash chip is normally accessed in word mode, the $CE port will only work correctly with the /BYTE pin connected to the mapper.
== Real-Time Clock interface ==
The 2003's RTC interface is a simple half-duplex SPI-like protocol. A write to $CA will start a transaction, depending on the exact value written.
If there is no external S-3511A, all bytes will read back as $FF due to a weak pull-up inside the 2003.
For specifics of what the S-3511A expects to be done with these bytes, see [[Real-Time Clock]].
(Put logic analyzer traces here)
Values are as follows:
=== $00-$0F, $1C-$1F ===
Immediately stop the transaction. This cannot be safely used to abort an ongoing transaction, because the 2003 still relays the 384kHz clock. In contrast, normal termination stops relaying that clock.
=== $10, $11 ===
Send command byte ($60 or $61 respectively) and stop.
=== $12 ===
Send command byte ($62), then send byte stored in $CB, then stop. The 2003 expects that the value in $CB is valid and does not pause if the CPU hasn't yet written a value.
=== $13 ===
Send command byte ($63), then receive byte, then stop. After the "data needed" is set or the "busy" bit is clear the value can be read from $CB.
=== $14 ===
Send command byte ($64), then send seven bytes of payload, then stop. The 2003 expects that the ''first'' byte is preloaded in $CB, but pauses for the CPU to write each subsequent byte by setting the "Data needed" bit.
=== $15 ===
Send command byte ($65), then receive seven bytes of payload, then stop. The 2003 pauses for the CPU to read each subsequent byte by setting the "Data needed" bit.
=== $16 ===
Send command byte ($66), then send three bytes of payload, then stop.
=== $17 ===
Send command byte ($67), then receive three bytes of payload, then stop.
=== $18, $1A ===
Send command byte ($68 or $6A), then send two bytes of payload, then stop.
=== $19, $1B ===
Send command byte ($69 or $6B), then receive two bytes of payload, then stop.
== Lockout ==
Unlike the 2001 mapper, the 2003 mapper checks for the address line changes which are part of the authentication handshake after power-up. Until this handshake occurs, ROM access is inhibited. (TODO: How exactly?)
eca9cb380cda5f76b432d14b1dc15aaabd83ed26
WonderWitch/Flash
0
67
397
2024-11-24T17:46:29Z
Asie
351
Created page with "The WonderWitch cartridge features a 512KiB flash chip - the MBM29DL400TC. While the WonderSwan SoC pervents writes to the ROM area, it can be written to via the SRAM area using port $CE on the [[Bandai 2003]] mapper. TODO: Document commands. == Links == * [https://github.com/up-n-atom/WonderWitch/blob/main/Datasheets/MBM29DL400BC-12PFTN_to_MBM29DL400TC-90PFTN.pdf Datasheet]"
wikitext
text/x-wiki
The WonderWitch cartridge features a 512KiB flash chip - the MBM29DL400TC. While the WonderSwan SoC pervents writes to the ROM area, it can be written to via the SRAM area using port $CE on the [[Bandai 2003]] mapper.
TODO: Document commands.
== Links ==
* [https://github.com/up-n-atom/WonderWitch/blob/main/Datasheets/MBM29DL400BC-12PFTN_to_MBM29DL400TC-90PFTN.pdf Datasheet]
a66d3c4628432fb01557e88cf51b45c74615c067
ROM header
0
5
400
274
2024-12-01T20:32:31Z
Asie
351
/* Developer/Publisher ID ($6) */ add Hearty Robin
wikitext
text/x-wiki
Every WonderSwan ROM contains a header. It is stored at the end - final sixteen bytes - of the ROM image.
== ROM header ==
Parts of this header are validated or otherwise used by the console's [[boot ROM]] - they are marked in '''bold'''.
{| class="wikitable"
|+ Header contents
|-
! Offset !! Length !! Contents
|-
| '''$0''' || '''5''' || Far jump instruction: '''0xEA''', offset, segment.
|-
| '''$5''' || '''1''' || '''Maintenance'''
|-
| $6 || 1 || Developer/Publisher ID
|-
| $7 || 1 || Color
|-
| $8 || 1 || Game ID (binary-coded decimal)
|-
| '''$9''' || '''1''' || '''Game version? / Safe mode'''
|-
| $A || 1 || ROM size
|-
| $B || 1 || Save type/size
|-
| '''$C''' || '''1''' || '''Flags'''
|-
| $D || 1 || Mapper
|-
| $E || 2 || Checksum (sum of all ROM bytes excluding the checksum)
|}
=== Maintenance ($5) ===
----
<pre>
7 bit 0
---- ----
s... 0000
| ||||
| ++++- Must be zero; otherwise the console will prohibit execution.
| Purpose unknown.
+--------- (Color) Splash bypass: 0 = Disable, 1 = Enable.
Bypasses the custom boot splash stored in the console's
internal EEPROM; presumably used for bricked console recovery.
</pre>
=== Developer/Publisher ID ($6) ===
----
{| class="wikitable"
|+ Known official developer/publisher IDs
|-
! ID !! Publisher code !! Publisher
|-
| $01 || BAN || Bandai
|-
| $02 || TAT || Taito
|-
| $03 || TMY || Tomy
|-
| $04 || KEX || Koei
|-
| $05 || DTE || Data East
|-
| $06 || AAE || Asmik Ace
|-
| $07 || MDE || Media Entertainment
|-
| $08 || NHB || Nichibutsu
|-
| $0A || CCJ || Coconuts Japan
|-
| $0B || SUM || Sammy
|-
| $0C || SUN || Sunsoft
|-
| $0D || PAW || Mebius
|-
| $0E || BPR || Banpresto
|-
| $10 || JLC || Jaleco
|-
| $11 || MGA || Imagineer
|-
| $12 || KNM || Konami
|-
| $16 || KBS || Kobunsha
|-
| $17 || BTM || Bottom Up
|-
| $18 || KGT || Kaga Tech
|-
| $19 || SRV || Sunrise
|-
| $1A || CFT || Cyber Front
|-
| $1B || MGH || Megahouse
|-
| $1D || BEC || Interbec
|-
| $1E || NAP || Nihon Application
|-
| $1F || BVL || Bandai Visual
|-
| $20 || ATN || Athena
|-
| $21 || KDX || KID
|-
| $22 || HAL || HAL Corporation
|-
| $23 || YKE || Yuki Enterprise
|-
| $24 || OMN || Omega Micott
|-
| $25 || LAY || Layup
|-
| $26 || KDK || Kadokawa Shoten
|-
| $27 || SHL || Shall Luck
|-
| $28 || SQR || Squaresoft
|-
| $2A || SCC || ?
|-
| $2B || TMC || Tom Create
|-
| $2D || NMC || Namco
|-
| $2E || SES || ?
|-
| $2F || HTR || Hearty Robin
|-
| $31 || VGD || Vanguard
|-
| $32 || MGT || Megatron
|-
| $33 || WIZ || Wiz
|-
| $35 || TAN || Tanita
|-
| $36 || CPC || Capcom
|}
Note that IDs $00 and $01 are used across a variety of commercial games. Homebrew is known to use arbitrary values in this field.
=== Color ($7) ===
----
<pre>
7 bit 0
---- ----
???? ???c
|
+- 0 = Monochrome only, 1 = Supports Color mode.
</pre>
=== Game version? / Safe mode ($9) ===
----
<pre>
7 bit 0
---- ----
pvvv vvvv
|||| ||||
|+++ ++++- Game version?
+--------- Internal EEPROM write protect: 0 = Enable, 1 = Disable.
This prohibits writing to the internal EEPROM for addresses
0x60 and above (user settings, custom splash screen).
Games are expected to enable write protection; however, the
WonderWitch is factory configured with it disabled.
</pre>
=== ROM size ($A) ===
----
Unofficial/inferred ROM size values are marked in ''italic''.
{| class="wikitable"
|+ ROM size values
|-
! ID !! Size
|-
| ''$00'' || ''1 Mbit (128 KiB)''
|-
| ''$01'' || ''2 Mbit (256 KiB)''
|-
| $02 || 4 Mbit (512 KiB)
|-
| $03 || 8 Mbit (1 MiB)
|-
| $04 || 16 Mbit (2 MiB)
|-
| ''$05'' || ''24 Mbit (3 MiB)''
|-
| $06 || 32 Mbit (4 MiB)
|-
| ''$07'' || ''48 Mbit (6 MiB)''
|-
| $08 || 64 Mbit (8 MiB)
|-
| $09 || 128 Mbit (16 MiB)
|-
| ''$0A'' || ''256 Mbit (32 MiB)''
|-
| ''$0B'' || ''512 Mbit (64 MiB)''
|}
Note that ROM sizes over 16 MiB are not supported by the [[Bandai 2001]] mapper. The [[Bandai 2003]] mapper is limited to 64 MiB.
=== Save type/size ($B) ===
----
{| class="wikitable"
|+ Save type values
|-
! ID !! Type !! Size
|-
| $00 || colspan="2" style="text-align:center;" | None
|-
| $01 || rowspan="5" | SRAM || rowspan="2" | 256 Kbit (32 KiB)
|-
| $02
|-
| $03 || 1 Mbit (128 KiB)
|-
| $04 || 2 Mbit (256 KiB)
|-
| $05 || 4 Mbit (512 KiB)
|-
| $10 || rowspan="3" | EEPROM || 1 Kbit (128 B)
|-
| $20 || 16 Kbit (2 KiB)
|-
| $50 || 8 Kbit (1 KiB)
|}
Note that while ID <code>$01</code> is commonly documented as <code>64 Kbit</code>, all known cartridges using that value come with <code>256 Kbit</code> SRAM chips. This requires further investigation.
=== Flags ($C) ===
----
<pre>
7 bit 0
---- ----
???? ?SBv
|||
||+- Starting screen orientation: 0 = Horizontal, 1 = Vertical.
|| Controls the splash screen's orientation.
|+-- ROM bus width: 0 = 16-bit, 1 = 8-bit.
+--- ROM access time: 0 = 3 CPU cycles, 1 = 1 CPU cycle.
</pre>
=== Mapper ($D) ===
----
{| class="wikitable"
|+ Known mapper types
|-
! ID !! Mapper
|-
| $00 || [[Bandai 2001]] or [[KARNAK]]
|-
| $01 || [[Bandai 2003]]
|}
b65ace0ec0f51bbe73f05dcf4779c52a5c323541
Display
0
26
401
394
2024-12-07T21:48:19Z
Asie
351
/* LCD Control ($14) */ briefly document high contrast
wikitext
text/x-wiki
The WonderSwan's display functionality generally consists of:
* a 224x144 display clocked at ~75.47 Hz by default, capable of displaying:
** up to sixteen distinct shades of gray
** 12-bit RGB444 color<sup>(color)</sup>
* two 32x32 background layers ("screens"), capable of displaying up to 512 (1024<sup>(color)</sup>) distinct tiles,
* a sprite layer, capable of displaying up to 128 8x8 sprites (up to 32 per line),
* six LCD icons to the bottom or right of the display, usable as additional indicators.
== Components ==
=== Tiles ===
The WonderSwan can display up to 512 distinct tiles at a time, with two bits of palette index information for every pixel.
The WonderSwan Color expands this to 1024 distinct tiles for background (with 512 remaining the limit for sprites), while also introducing modes with four bits of palette index information for every pixel.
==== 2 bits per pixel, planar ====
The tiles are stored in an interleaved planar format, with two bits total for every pixel. Odd bytes store the first plane (bit 0 of each pixel), while even bytes store the second plane (bit 1 of each pixel).
<pre>
tile data (16 bytes)
01 7C 01 FC 00 C0 18 D8 18 D8 00 C0 00 00 C0 00
||
\/
plane 0 plane 1
7 bit 0 7 bit 0 full tile
---- ---- ---- ----
.... ...1 = 01 .222 22.. = 7C .22222.1
.... ...1 = 01 2222 22.. = FC 222222.1
.... .... = 00 22.. .... = C0 22......
...1 1... = 18 22.2 2... = D8 --\ 22.33...
...1 1... = 18 22.2 2... = D8 --/ 22.33...
.... .... = 00 22.. .... = C0 22......
.... .... = 00 .... .... = 00 ........
11.. .... = C0 .... .... = 00 11......
</pre>
This matches the format used by the Game Boy.
==== 4 bits per pixel, planar ====
This mode is stored in a manner similar to the 2 bits per pixel mode, but with an additional two planes for bit 2 and bit 3 of each pixel's palette index, expanding the tile data to 32 bytes.
<pre>
tile data (32 bytes)
54 32 01 00 54 32 F1 00 54 32 01 F0 54 32 F1 F0 04 02 01 00 F8 04 02 01 00 F8 04 02 00 00 F8 04
||
\/
plane 0 plane 1 plane 2 plane 3
7 bit 0 7 bit 0 7 bit 0 7 bit 0 full tile
---- ---- ---- ---- ---- ---- ---- ----
.1.1 .1.. = 54 ..22 ..2. = 32 .... ...4 = 01 .... .... = 00 .123.124
.1.1 .1.. = 54 ..22 ..2. = 32 4444 ...4 = F1 .... .... = 00 4567.124
.1.1 .1.. = 54 ..22 ..2. = 32 .... ...4 = 01 8888 .... = F0 89AB.124
.1.1 .1.. = 54 ..22 ..2. = 32 4444 ...4 = F1 8888 .... = F0 --\ CDEF.124
.... .1.. = 04 .... ..2. = 02 .... ...4 = 01 .... .... = 00 --/ .....124
1111 1... = F8 .... .2.. = 04 .... ..4. = 02 .... ...8 = 01 11111248
.... .... = 00 2222 2... = F8 .... .4.. = 04 .... ..8. = 02 2222248.
.... .... = 00 .... .... = 00 4444 4... = F8 .... .8.. = 04 444448..
</pre>
This format matches the one used by the Sega Master System and Game Gear family of consoles.
==== 4 bits per pixel, packed ====
Unlike the previous two formats, in the packed format each byte stores the complete palette index of two pixels - the high four bits store the left pixel, while the low four bits store the right pixel. Four such bytes make up a row of eight pixels from left to right.
<pre>
tile data (32 bytes)
01 23 01 24 45 67 01 24 89 AB 01 24 CD EF 01 24 00 00 01 24 11 11 12 48 22 22 24 80 44 44 48 00
||
\/
byte 0 1 2 3
bits 7-4 3-0 7-4 3-0 7-4 3-0 7-4 3-0
pixel 0 1 2 3 4 5 6 7 full tile
--- --- --- --- --- --- --- ---
. 1 = 01 2 3 = 23 . 1 = 01 2 4 = 24 .123.124 = 01 23 01 24
4 5 = 45 6 7 = 67 . 1 = 01 2 4 = 24 4567.124 = 45 67 01 24
8 9 = 89 A B = AB . 1 = 01 2 4 = 24 89AB.124 = 89 AB 01 24
C D = CD E F = EF . 1 = 01 2 4 = 24 --\ CDEF.124 = CD EF 01 24
. . = 00 . . = 00 . 1 = 01 2 4 = 24 --/ .....124 = 00 00 01 24
1 1 = 11 1 1 = 11 1 2 = 12 4 8 = 48 11111248 = 11 11 12 48
2 2 = 22 2 2 = 22 2 4 = 24 8 . = 80 2222248. = 22 22 24 80
4 4 = 44 4 4 = 44 4 8 = 48 . . = 00 444448.. = 44 44 48 00
</pre>
This format matches the one used by the Mega Drive console.
=== Palettes ===
The display system provides sixteen different palettes that can be used to color or shade tiles.
* Palettes 0-7 can be used for the two screens only;
* Palettes 8-15 can be used for both screens and sprites.
==== Mono ====
In ''mono'' modes, palettes are stored in I/O ports 0x20 through 0x3F. Each palette contains four three-bit entries, which are pointers into a global, four-bit shade lookup table:
<pre>
Palette Global shade LUT
1 ===========> 2 ==========================> 5
^ (0, 2, 4, 6) ^ (1, 3, 5, 7, 9, 11, 13, 15) ^
| | |
Palette index Value Displayed shade
</pre>
The shade value corresponds to the darkness of the pixel: shade 0 is the brightest, while shade 15 is the darkest.
==== Color ====
In ''color'' modes, palettes are stored as 16-bit words in memory addresses 0xFE00 through 0xFFFF, without additional lookup tables:
<pre>
Address
15 bit 8 7 bit 0
---- ---- ---- ----
1111 111p pppi iii.
| |||| |||
| |||+-+++-- Index in palette (0-15)
+--+++------- Palette number (0-15)
Data
15 bit 8 7 bit 0
---- ---- ---- ----
.... rrrr gggg bbbb
|||| |||| ||||
|||| |||| ++++- Blue (0-15)
|||| ++++------ Green (0-15)
++++------------ Red (0-15)
</pre>
In 2 bits per pixel color modes, palette entries 4 through 15 are not used.
==== Transparency ====
In two bit per pixel modes:
* Palettes 0-3 and 8-11 are ''opaque''. For these, index zero is treated as opaque.
* Palettes 4-7 and 12-15 are ''translucent''. For these, index zero is treated as transparent. This means that the color/shade value set to it is ignored, and only three distinct colors/shades can be used for tiles.
In four bit per pixel modes, all palettes are ''translucent''. Index zero is always treated as transparent, and fifteen different colors/shades can be used for tiles.
=== Background color ===
The background color is displayed if no ''opaque'' pixel from screens or sprites is drawn. This color is set in I/O port ''0x01'':
* In mono modes, it is set to an entry in the shade lookup table (0-7),
* In color modes, it is set to an entry in the color palette (0-255). Note that this allows you to use the first color (color zero) of any palette, which is normally ignored and assumed to be ''transparent''.
=== Screens ===
A screen is a layout of tiles. Each cell in a screen controls one 8x8 tile.
The display system can show two distinct screens simultaneously. It also supports hardware flipping of tiles, both horizontally and vertically.
The size of each screen is fixed at 32x32 cells or 256x256 pixels, while each cell is stored as a two-byte word:
<pre>
Address
15 bit 8 7 bit 0
---- ---- ---- ----
0bbb byyy yyxx xxx.
||| |||| |||| |||
||| |||| ||++-+++-- X coordinate (0-31)
||| |+++--++-------- Y coordinate (0-31)
+++-+--------------- Base address (from I/O port)
Data
15 bit 8 7 bit 0
---- ---- ---- ----
vhbp pppt tttt tttt
|||| |||| |||| ||||
|||| |||+--++++-++++- Tile index (0-511)
|||+-+++------------- Palette (0-15)
||+------------------ Tile bank (0-1) - color only
|+------------------- Horizontal flip
+-------------------- Vertical flip
</pre>
In ''color'' modes, the tile bank selects between tiles 0-511 and 512-1023.
=== Sprites ===
The display system can show up to 128 sprites at once.
Sprites are always drawn in front of Screen 1, but they can be drawn in front of or behind Screen 2.
Sprites are stored in a sprite table in the console's internal RAM. It consists of up to 128 four-byte entries, of which any sequential slice can be displayed:
<pre>
(Byte 1) (Byte 0)
15 bit 8 7 bit 0
---- ---- ---- ----
vhPi pppt tttt tttt
|||| |||| |||| ||||
|||| |||+--++++-++++- Tile index (0-511) - only tile bank 0
|||| +++------------- Palette (0-7) - mapped to screen palettes 8-15
|||+----------------- Window location - 0 = inside, 1 = outside
||+------------------ Priority - 0 = behind Screen 2, 1 = in front of Screen 2
|+------------------- Horizontal flip
+-------------------- Vertical flip
(Byte 2)
7 bit 0
---- ----
yyyy yyyy
|||| ||||
++++-++++- Y coordinate
(Byte 3)
7 bit 0
---- ----
xxxx xxxx
|||| ||||
++++-++++- X coordinate
</pre>
There is a sprite limit of 32 per scanline. This means that for each scanline, only the first 32 sprites will be drawn. Note that this includes sprites obscured by windows or outside of visible X coordinates; this list is determined solely by the Y coordinate. Between sprites themselves, earlier sprites in the list are always drawn on top of later sprites in the list.
The sprite table is copied from the console's RAM to a SoC-internal buffer every frame on line <tt>144</tt>; one word for every clock of the line, totaling 256 words (512 bytes) for 256 clocks. This internal buffer is then used for reading sprite data on the next frame.
=== Visibility priority ===
For display components, the visibility priority is as follows:
* Sprite 0, high priority
* Sprite 127, high priority
* Screen 2
* Sprite 0, low priority
* Sprite 127, low priority
* Screen 1
* Background color
=== Windows ===
Screen 2 and sprites can optionally have their drawing restricted within or outside of their specific rectangular windows.
Note that for sprites, the window is enabled globally (for all sprites), but each sprite can individually decide if it's rendered inside or outside of it.
=== Icons ===
The WonderSwan features six LCD segment icons which are displayed to the right<sup>(color)</sup> or below<sup>(mono)</sup> the main display. These are, as follows:
* Aux 3 - large circle,
* Aux 2 - medium circle,
* Aux 1 - small circle,
* Horizontal orientation,
* Vertical orientation,
* Sleep.
== Interrupts ==
The display circuit generates two interrupts of its own:
* Display Interrupt Line Match - when <code>Display Current Line</code> == <code>Display Interrupt Line</code>, at the beginning of said line.
* Display Vertical Blank - when <code>Display Current Line</code> == <code>144</code>, at the beginning of said line.
It also provides a timing source for the two Horizontal and Vertical Blank [[Timers]], which provide their own respective interrupts.
== I/O ports ==
{{Anchor|Display Control}}
=== Display Control ($00) ===
<pre>
7 bit 0
---- ----
..wo Ws21
|| ||||
|| |||+- Enable Screen 1 layer
|| ||+-- Enable Screen 2 layer
|| |+--- Enable Sprite layer
|| +---- Enable Sprite window
|+------ Screen 2 tiles are drawn (if window enabled):
| 0 = inside window,
| 1 = outside window.
+------- Enable Screen 2 window
</pre>
{{Anchor|Display Background}}
=== Display Background Color ($01) ===
<pre>
(mono) (color)
7 bit 0 7 bit 0
---- ---- ---- ----
.... .sss pppp iiii
||| |||| ||||
+++- Value |||| ++++- Index in palette (0-15)
(0-7) ++++------ Color palette (0-15)
</pre>
{{Anchor|Display Current Line}}
=== Display Current Line ($02 read) ===
The current line being drawn by the display.
Note that lines are sent to the display with a one-line delay. This matters for color palette or shade LUT manipulation; changing these values when <code>current line == 1</code> will actually affect line 0.
{{Anchor|Display Interrupt Line}}
=== Display Interrupt Line ($03) ===
The line to emit an interrupt on.
{{Anchor|Sprite Table Address}}
=== Sprite Table Address ($04) ===
<pre>
7 bit 0
---- ----
..Aa aaaa
|| ||||
|+-++++- Address (bits 9-13)
+------- Address (bit 14) - color only
</pre>
{{Anchor|Sprite Table First}}
=== Sprite Table First ($05) ===
<pre>
7 bit 0
---- ----
.iii iiii
||| ||||
+++-++++- Index of first sprite entry to draw (0-127)
</pre>
{{Anchor|Sprite Table Count}}
=== Sprite Table Count ($06) ===
<pre>
7 bit 0
---- ----
cccc cccc
|||| ||||
++++-++++- Count of sprite entries to draw (1-128)
</pre>
{{Anchor|Screen Address}}
=== Screen Address ($07) ===
<pre>
7 bit 0
---- ----
2222 1111
|||| ||||
|||| |+++- Screen 1 address (bits 11-13)
|||| +---- Screen 1 address (bit 14) - color only
|+++------ Screen 2 address (bits 11-13)
+--------- Screen 2 address (bit 14) - color only
</pre>
{{Anchor|Screen 2 Window}}
=== Screen 2 Window Left ($08) ===
=== Screen 2 Window Top ($09) ===
=== Screen 2 Window Right ($0A) ===
=== Screen 2 Window Bottom ($0B) ===
The X and Y coordinates of the Screen 2 window.
Note that all coordinates are inclusive; for example, for a 200x100 window in the top-left corner, the values should be set as follows:
* Left - 0,
* Top - 0,
* Right - 199,
* Bottom - 99.
{{Anchor|Sprite Window}}
=== Sprite Window Left ($0C) ===
=== Sprite Window Top ($0D) ===
=== Sprite Window Right ($0E) ===
=== Sprite Window Bottom ($0F) ===
The X and Y coordinates of the Sprite window.
Note that all coordinates are inclusive.
{{Anchor|Screen Scroll}}
=== Screen 1 Scroll X ($10) ===
=== Screen 1 Scroll Y ($11) ===
The X and Y coordinates that Screen 1 is scrolled by.
For example, setting Scroll X to 24 and Scroll Y to 8 will omit, in 8x8 tile units, the first three rows and the first two columns of the 32x32 screen.
=== Screen 2 Scroll X ($12) ===
=== Screen 2 Scroll Y ($13) ===
The X and Y coordinates that Screen 2 is scrolled by.
{{Anchor|LCD Control}}
=== LCD Control ($14) ===
<pre>
7 bit 0
---- ----
.... ..Ce
||
|+- LCD enable: 0 = sleep, 1 = enabled
+-- Contrast (WSC): 0 = low, 1 = high
</pre>
The enable bit controls whether or not the LCD screen is displaying graphics; if sleeping, it displays nothing (all white). Note that segments continue displaying regardless of this configuration.
Note that port $1A provides a separate LCD sleep bit; the display will be disabled in the same way if any of those bits are set to "sleep".
The contrast bit allows enabling a "high contrast" mode: this works by having the LCD drive two lines with data received from the SoC - so the first line of the LCD is driven by the first line from the SoC, then additionally by the second line from the SoC.
{{Anchor|LCD Icon Control}}
=== LCD Icon Control ($15) ===
<pre>
7 bit 0
---- ----
..32 1hvs
|| ||||
|| |||+- Sleep
|| ||+-- Vertical orientation
|| |+--- Horizontal orientation
|| +---- Aux 1
|+------ Aux 2
+------- Aux 3
</pre>
{{Anchor|LCD Mono Shade LUT}}
=== LCD Mono Shade LUT ($1C-$1F) ===
<pre>
$1C $1D $1E $1F
7 bit 0 7 bit 0 7 bit 0 7 bit 0
---- ---- ---- ---- ---- ---- ---- ----
1111 0000 3333 2222 5555 4444 7777 6666
</pre>
{{Anchor|LCD Mono Palette}}
=== LCD Mono Palette 0..15 ($20, $21 .. $3E, $3F) ===
The monochrome palette is laid out as sixteen words:
<pre>
N+1 N
15 bit 8 7 bit 0
---- ---- ---- ----
.333 .222 .111 .000
||| ||| ||| |||
||| ||| ||| +++- Shade LUT index for color 0
||| ||| +++------ Shade LUT index for color 1
||| +++------------ Shade LUT index for color 2
+++----------------- Shade LUT index for color 3
</pre>
== Internal I/O ports ==
These I/O ports are said to be internal and not intended for use by commercial games.
{{Anchor|LCD Final Line}}
=== LCD Final Line ($16) ===
The final line preceding line counter restart and the beginning of active display. By default, this is set to 158, which equals 159 total lines per frame.
It is said setting this register to an odd value on SwanCrystal has an adverse effect to the LCD panel,<ref>[http://daifukkat.su/docs/wsman/#REG_LCD_VTOTAL REG_LCD_VTOTAL - WSMan]</ref> but the exact mechanism is unknown. A starting point for research is that an even value, or odd total line count, is needed to balance positive and negative charges on the LCD.<ref>W.A. Steer. "[http://www.techmind.org/lcd/ LCD monitor technology and tests]". Techmind, 2011-12-03. Accessed 2024-11-19.</ref>
{{Anchor|LCD Back Porch Line}}
=== LCD Back Porch Line ($17, WSC only) ===
This port is available on the WonderSwan Color only - not the SwanCrystal!
The final line preceding the vertical back porch; by default, this should be set to 155.
The vertical back porch of the LCD is assumed to be 4 lines by some hardware, including IPS mods, as well as the official "TV Swan" capture device. Given that the first visible line is sent to the LCD on the display's line 1, this should be generally set to <code>LCD Final Line - 3</code>.
Conversely, it is said moving this value closer to vertical blank improves LCD visibility<ref>[http://daifukkat.su/docs/wsman/#REG_LCD_VSYNC REG_LCD_VSYNC - WSMan]</ref>, but the exact mechanism is unknown.
{{Anchor|LCD Status}}
=== LCD Status ($1A) ===
<pre>
7 bit 0
---- ----
...v vvhs
| ||||
| |||+- LCD sleep: 0 = no, 1 = sleep
| ||+-- Headphone segment
| ||
| || Volume segments:
| |+--- - Volume B (medium, high)
| +---- - Volume A (low, high)
+------ - Speaker
</pre>
The LCD sleep bit is writable. The remaining bits are read-only.
The volume and headphone segments are enabled when pressing the SOUND button, according to this algorithm:
* If headphones are plugged in, enable the Headphone segment.
* If headphones are not plugged in, enable the Speaker segment and the following Volume segments:
** Volume level 0: None
** Volume level 1: A
** Volume level 2: B
** Volume level 3: A, B
* Hide all visible segments after 128 frames from the last press.
TODO: This documents the WonderSwan Color. The specifics probably work differently on the mono WonderSwan.
=== TFT LCD Configuration ($70, $71, $72, $73, $74, $75, $76, $77 SwanCrystal only) ===
These eight bytes are read from internal EEPROM and configure unknown aspects of the console's TFT LCD panel.
They are only writable while the [[Boot ROM]] is unlocked - locking has the side effect of making them read-only.
== Notes ==
<references />
b6c5f29eabb6583fe9dc484800741607efe5de9c
431
401
2024-12-17T20:40:11Z
Asie
351
/* LCD Icon Control ($15) */
wikitext
text/x-wiki
The WonderSwan's display functionality generally consists of:
* a 224x144 display clocked at ~75.47 Hz by default, capable of displaying:
** up to sixteen distinct shades of gray
** 12-bit RGB444 color<sup>(color)</sup>
* two 32x32 background layers ("screens"), capable of displaying up to 512 (1024<sup>(color)</sup>) distinct tiles,
* a sprite layer, capable of displaying up to 128 8x8 sprites (up to 32 per line),
* six LCD icons to the bottom or right of the display, usable as additional indicators.
== Components ==
=== Tiles ===
The WonderSwan can display up to 512 distinct tiles at a time, with two bits of palette index information for every pixel.
The WonderSwan Color expands this to 1024 distinct tiles for background (with 512 remaining the limit for sprites), while also introducing modes with four bits of palette index information for every pixel.
==== 2 bits per pixel, planar ====
The tiles are stored in an interleaved planar format, with two bits total for every pixel. Odd bytes store the first plane (bit 0 of each pixel), while even bytes store the second plane (bit 1 of each pixel).
<pre>
tile data (16 bytes)
01 7C 01 FC 00 C0 18 D8 18 D8 00 C0 00 00 C0 00
||
\/
plane 0 plane 1
7 bit 0 7 bit 0 full tile
---- ---- ---- ----
.... ...1 = 01 .222 22.. = 7C .22222.1
.... ...1 = 01 2222 22.. = FC 222222.1
.... .... = 00 22.. .... = C0 22......
...1 1... = 18 22.2 2... = D8 --\ 22.33...
...1 1... = 18 22.2 2... = D8 --/ 22.33...
.... .... = 00 22.. .... = C0 22......
.... .... = 00 .... .... = 00 ........
11.. .... = C0 .... .... = 00 11......
</pre>
This matches the format used by the Game Boy.
==== 4 bits per pixel, planar ====
This mode is stored in a manner similar to the 2 bits per pixel mode, but with an additional two planes for bit 2 and bit 3 of each pixel's palette index, expanding the tile data to 32 bytes.
<pre>
tile data (32 bytes)
54 32 01 00 54 32 F1 00 54 32 01 F0 54 32 F1 F0 04 02 01 00 F8 04 02 01 00 F8 04 02 00 00 F8 04
||
\/
plane 0 plane 1 plane 2 plane 3
7 bit 0 7 bit 0 7 bit 0 7 bit 0 full tile
---- ---- ---- ---- ---- ---- ---- ----
.1.1 .1.. = 54 ..22 ..2. = 32 .... ...4 = 01 .... .... = 00 .123.124
.1.1 .1.. = 54 ..22 ..2. = 32 4444 ...4 = F1 .... .... = 00 4567.124
.1.1 .1.. = 54 ..22 ..2. = 32 .... ...4 = 01 8888 .... = F0 89AB.124
.1.1 .1.. = 54 ..22 ..2. = 32 4444 ...4 = F1 8888 .... = F0 --\ CDEF.124
.... .1.. = 04 .... ..2. = 02 .... ...4 = 01 .... .... = 00 --/ .....124
1111 1... = F8 .... .2.. = 04 .... ..4. = 02 .... ...8 = 01 11111248
.... .... = 00 2222 2... = F8 .... .4.. = 04 .... ..8. = 02 2222248.
.... .... = 00 .... .... = 00 4444 4... = F8 .... .8.. = 04 444448..
</pre>
This format matches the one used by the Sega Master System and Game Gear family of consoles.
==== 4 bits per pixel, packed ====
Unlike the previous two formats, in the packed format each byte stores the complete palette index of two pixels - the high four bits store the left pixel, while the low four bits store the right pixel. Four such bytes make up a row of eight pixels from left to right.
<pre>
tile data (32 bytes)
01 23 01 24 45 67 01 24 89 AB 01 24 CD EF 01 24 00 00 01 24 11 11 12 48 22 22 24 80 44 44 48 00
||
\/
byte 0 1 2 3
bits 7-4 3-0 7-4 3-0 7-4 3-0 7-4 3-0
pixel 0 1 2 3 4 5 6 7 full tile
--- --- --- --- --- --- --- ---
. 1 = 01 2 3 = 23 . 1 = 01 2 4 = 24 .123.124 = 01 23 01 24
4 5 = 45 6 7 = 67 . 1 = 01 2 4 = 24 4567.124 = 45 67 01 24
8 9 = 89 A B = AB . 1 = 01 2 4 = 24 89AB.124 = 89 AB 01 24
C D = CD E F = EF . 1 = 01 2 4 = 24 --\ CDEF.124 = CD EF 01 24
. . = 00 . . = 00 . 1 = 01 2 4 = 24 --/ .....124 = 00 00 01 24
1 1 = 11 1 1 = 11 1 2 = 12 4 8 = 48 11111248 = 11 11 12 48
2 2 = 22 2 2 = 22 2 4 = 24 8 . = 80 2222248. = 22 22 24 80
4 4 = 44 4 4 = 44 4 8 = 48 . . = 00 444448.. = 44 44 48 00
</pre>
This format matches the one used by the Mega Drive console.
=== Palettes ===
The display system provides sixteen different palettes that can be used to color or shade tiles.
* Palettes 0-7 can be used for the two screens only;
* Palettes 8-15 can be used for both screens and sprites.
==== Mono ====
In ''mono'' modes, palettes are stored in I/O ports 0x20 through 0x3F. Each palette contains four three-bit entries, which are pointers into a global, four-bit shade lookup table:
<pre>
Palette Global shade LUT
1 ===========> 2 ==========================> 5
^ (0, 2, 4, 6) ^ (1, 3, 5, 7, 9, 11, 13, 15) ^
| | |
Palette index Value Displayed shade
</pre>
The shade value corresponds to the darkness of the pixel: shade 0 is the brightest, while shade 15 is the darkest.
==== Color ====
In ''color'' modes, palettes are stored as 16-bit words in memory addresses 0xFE00 through 0xFFFF, without additional lookup tables:
<pre>
Address
15 bit 8 7 bit 0
---- ---- ---- ----
1111 111p pppi iii.
| |||| |||
| |||+-+++-- Index in palette (0-15)
+--+++------- Palette number (0-15)
Data
15 bit 8 7 bit 0
---- ---- ---- ----
.... rrrr gggg bbbb
|||| |||| ||||
|||| |||| ++++- Blue (0-15)
|||| ++++------ Green (0-15)
++++------------ Red (0-15)
</pre>
In 2 bits per pixel color modes, palette entries 4 through 15 are not used.
==== Transparency ====
In two bit per pixel modes:
* Palettes 0-3 and 8-11 are ''opaque''. For these, index zero is treated as opaque.
* Palettes 4-7 and 12-15 are ''translucent''. For these, index zero is treated as transparent. This means that the color/shade value set to it is ignored, and only three distinct colors/shades can be used for tiles.
In four bit per pixel modes, all palettes are ''translucent''. Index zero is always treated as transparent, and fifteen different colors/shades can be used for tiles.
=== Background color ===
The background color is displayed if no ''opaque'' pixel from screens or sprites is drawn. This color is set in I/O port ''0x01'':
* In mono modes, it is set to an entry in the shade lookup table (0-7),
* In color modes, it is set to an entry in the color palette (0-255). Note that this allows you to use the first color (color zero) of any palette, which is normally ignored and assumed to be ''transparent''.
=== Screens ===
A screen is a layout of tiles. Each cell in a screen controls one 8x8 tile.
The display system can show two distinct screens simultaneously. It also supports hardware flipping of tiles, both horizontally and vertically.
The size of each screen is fixed at 32x32 cells or 256x256 pixels, while each cell is stored as a two-byte word:
<pre>
Address
15 bit 8 7 bit 0
---- ---- ---- ----
0bbb byyy yyxx xxx.
||| |||| |||| |||
||| |||| ||++-+++-- X coordinate (0-31)
||| |+++--++-------- Y coordinate (0-31)
+++-+--------------- Base address (from I/O port)
Data
15 bit 8 7 bit 0
---- ---- ---- ----
vhbp pppt tttt tttt
|||| |||| |||| ||||
|||| |||+--++++-++++- Tile index (0-511)
|||+-+++------------- Palette (0-15)
||+------------------ Tile bank (0-1) - color only
|+------------------- Horizontal flip
+-------------------- Vertical flip
</pre>
In ''color'' modes, the tile bank selects between tiles 0-511 and 512-1023.
=== Sprites ===
The display system can show up to 128 sprites at once.
Sprites are always drawn in front of Screen 1, but they can be drawn in front of or behind Screen 2.
Sprites are stored in a sprite table in the console's internal RAM. It consists of up to 128 four-byte entries, of which any sequential slice can be displayed:
<pre>
(Byte 1) (Byte 0)
15 bit 8 7 bit 0
---- ---- ---- ----
vhPi pppt tttt tttt
|||| |||| |||| ||||
|||| |||+--++++-++++- Tile index (0-511) - only tile bank 0
|||| +++------------- Palette (0-7) - mapped to screen palettes 8-15
|||+----------------- Window location - 0 = inside, 1 = outside
||+------------------ Priority - 0 = behind Screen 2, 1 = in front of Screen 2
|+------------------- Horizontal flip
+-------------------- Vertical flip
(Byte 2)
7 bit 0
---- ----
yyyy yyyy
|||| ||||
++++-++++- Y coordinate
(Byte 3)
7 bit 0
---- ----
xxxx xxxx
|||| ||||
++++-++++- X coordinate
</pre>
There is a sprite limit of 32 per scanline. This means that for each scanline, only the first 32 sprites will be drawn. Note that this includes sprites obscured by windows or outside of visible X coordinates; this list is determined solely by the Y coordinate. Between sprites themselves, earlier sprites in the list are always drawn on top of later sprites in the list.
The sprite table is copied from the console's RAM to a SoC-internal buffer every frame on line <tt>144</tt>; one word for every clock of the line, totaling 256 words (512 bytes) for 256 clocks. This internal buffer is then used for reading sprite data on the next frame.
=== Visibility priority ===
For display components, the visibility priority is as follows:
* Sprite 0, high priority
* Sprite 127, high priority
* Screen 2
* Sprite 0, low priority
* Sprite 127, low priority
* Screen 1
* Background color
=== Windows ===
Screen 2 and sprites can optionally have their drawing restricted within or outside of their specific rectangular windows.
Note that for sprites, the window is enabled globally (for all sprites), but each sprite can individually decide if it's rendered inside or outside of it.
=== Icons ===
The WonderSwan features six LCD segment icons which are displayed to the right<sup>(color)</sup> or below<sup>(mono)</sup> the main display. These are, as follows:
* Aux 3 - large circle,
* Aux 2 - medium circle,
* Aux 1 - small circle,
* Horizontal orientation,
* Vertical orientation,
* Sleep.
== Interrupts ==
The display circuit generates two interrupts of its own:
* Display Interrupt Line Match - when <code>Display Current Line</code> == <code>Display Interrupt Line</code>, at the beginning of said line.
* Display Vertical Blank - when <code>Display Current Line</code> == <code>144</code>, at the beginning of said line.
It also provides a timing source for the two Horizontal and Vertical Blank [[Timers]], which provide their own respective interrupts.
== I/O ports ==
{{Anchor|Display Control}}
=== Display Control ($00) ===
<pre>
7 bit 0
---- ----
..wo Ws21
|| ||||
|| |||+- Enable Screen 1 layer
|| ||+-- Enable Screen 2 layer
|| |+--- Enable Sprite layer
|| +---- Enable Sprite window
|+------ Screen 2 tiles are drawn (if window enabled):
| 0 = inside window,
| 1 = outside window.
+------- Enable Screen 2 window
</pre>
{{Anchor|Display Background}}
=== Display Background Color ($01) ===
<pre>
(mono) (color)
7 bit 0 7 bit 0
---- ---- ---- ----
.... .sss pppp iiii
||| |||| ||||
+++- Value |||| ++++- Index in palette (0-15)
(0-7) ++++------ Color palette (0-15)
</pre>
{{Anchor|Display Current Line}}
=== Display Current Line ($02 read) ===
The current line being drawn by the display.
Note that lines are sent to the display with a one-line delay. This matters for color palette or shade LUT manipulation; changing these values when <code>current line == 1</code> will actually affect line 0.
{{Anchor|Display Interrupt Line}}
=== Display Interrupt Line ($03) ===
The line to emit an interrupt on.
{{Anchor|Sprite Table Address}}
=== Sprite Table Address ($04) ===
<pre>
7 bit 0
---- ----
..Aa aaaa
|| ||||
|+-++++- Address (bits 9-13)
+------- Address (bit 14) - color only
</pre>
{{Anchor|Sprite Table First}}
=== Sprite Table First ($05) ===
<pre>
7 bit 0
---- ----
.iii iiii
||| ||||
+++-++++- Index of first sprite entry to draw (0-127)
</pre>
{{Anchor|Sprite Table Count}}
=== Sprite Table Count ($06) ===
<pre>
7 bit 0
---- ----
cccc cccc
|||| ||||
++++-++++- Count of sprite entries to draw (1-128)
</pre>
{{Anchor|Screen Address}}
=== Screen Address ($07) ===
<pre>
7 bit 0
---- ----
2222 1111
|||| ||||
|||| |+++- Screen 1 address (bits 11-13)
|||| +---- Screen 1 address (bit 14) - color only
|+++------ Screen 2 address (bits 11-13)
+--------- Screen 2 address (bit 14) - color only
</pre>
{{Anchor|Screen 2 Window}}
=== Screen 2 Window Left ($08) ===
=== Screen 2 Window Top ($09) ===
=== Screen 2 Window Right ($0A) ===
=== Screen 2 Window Bottom ($0B) ===
The X and Y coordinates of the Screen 2 window.
Note that all coordinates are inclusive; for example, for a 200x100 window in the top-left corner, the values should be set as follows:
* Left - 0,
* Top - 0,
* Right - 199,
* Bottom - 99.
{{Anchor|Sprite Window}}
=== Sprite Window Left ($0C) ===
=== Sprite Window Top ($0D) ===
=== Sprite Window Right ($0E) ===
=== Sprite Window Bottom ($0F) ===
The X and Y coordinates of the Sprite window.
Note that all coordinates are inclusive.
{{Anchor|Screen Scroll}}
=== Screen 1 Scroll X ($10) ===
=== Screen 1 Scroll Y ($11) ===
The X and Y coordinates that Screen 1 is scrolled by.
For example, setting Scroll X to 24 and Scroll Y to 8 will omit, in 8x8 tile units, the first three rows and the first two columns of the 32x32 screen.
=== Screen 2 Scroll X ($12) ===
=== Screen 2 Scroll Y ($13) ===
The X and Y coordinates that Screen 2 is scrolled by.
{{Anchor|LCD Control}}
=== LCD Control ($14) ===
<pre>
7 bit 0
---- ----
.... ..Ce
||
|+- LCD enable: 0 = sleep, 1 = enabled
+-- Contrast (WSC): 0 = low, 1 = high
</pre>
The enable bit controls whether or not the LCD screen is displaying graphics; if sleeping, it displays nothing (all white). Note that segments continue displaying regardless of this configuration.
Note that port $1A provides a separate LCD sleep bit; the display will be disabled in the same way if any of those bits are set to "sleep".
The contrast bit allows enabling a "high contrast" mode: this works by having the LCD drive two lines with data received from the SoC - so the first line of the LCD is driven by the first line from the SoC, then additionally by the second line from the SoC.
{{Anchor|LCD Icon Control}}
=== LCD Icon Control ($15) ===
<pre>
7 bit 0
---- ----
..32 1hvs
|| ||||
|| |||+- Sleep
|| ||+-- Vertical orientation
|| |+--- Horizontal orientation
|| +---- Aux 1 (Small circle)
|+------ Aux 2 (Medium circle)
+------- Aux 3 (Large circle)
</pre>
{{Anchor|LCD Mono Shade LUT}}
=== LCD Mono Shade LUT ($1C-$1F) ===
<pre>
$1C $1D $1E $1F
7 bit 0 7 bit 0 7 bit 0 7 bit 0
---- ---- ---- ---- ---- ---- ---- ----
1111 0000 3333 2222 5555 4444 7777 6666
</pre>
{{Anchor|LCD Mono Palette}}
=== LCD Mono Palette 0..15 ($20, $21 .. $3E, $3F) ===
The monochrome palette is laid out as sixteen words:
<pre>
N+1 N
15 bit 8 7 bit 0
---- ---- ---- ----
.333 .222 .111 .000
||| ||| ||| |||
||| ||| ||| +++- Shade LUT index for color 0
||| ||| +++------ Shade LUT index for color 1
||| +++------------ Shade LUT index for color 2
+++----------------- Shade LUT index for color 3
</pre>
== Internal I/O ports ==
These I/O ports are said to be internal and not intended for use by commercial games.
{{Anchor|LCD Final Line}}
=== LCD Final Line ($16) ===
The final line preceding line counter restart and the beginning of active display. By default, this is set to 158, which equals 159 total lines per frame.
It is said setting this register to an odd value on SwanCrystal has an adverse effect to the LCD panel,<ref>[http://daifukkat.su/docs/wsman/#REG_LCD_VTOTAL REG_LCD_VTOTAL - WSMan]</ref> but the exact mechanism is unknown. A starting point for research is that an even value, or odd total line count, is needed to balance positive and negative charges on the LCD.<ref>W.A. Steer. "[http://www.techmind.org/lcd/ LCD monitor technology and tests]". Techmind, 2011-12-03. Accessed 2024-11-19.</ref>
{{Anchor|LCD Back Porch Line}}
=== LCD Back Porch Line ($17, WSC only) ===
This port is available on the WonderSwan Color only - not the SwanCrystal!
The final line preceding the vertical back porch; by default, this should be set to 155.
The vertical back porch of the LCD is assumed to be 4 lines by some hardware, including IPS mods, as well as the official "TV Swan" capture device. Given that the first visible line is sent to the LCD on the display's line 1, this should be generally set to <code>LCD Final Line - 3</code>.
Conversely, it is said moving this value closer to vertical blank improves LCD visibility<ref>[http://daifukkat.su/docs/wsman/#REG_LCD_VSYNC REG_LCD_VSYNC - WSMan]</ref>, but the exact mechanism is unknown.
{{Anchor|LCD Status}}
=== LCD Status ($1A) ===
<pre>
7 bit 0
---- ----
...v vvhs
| ||||
| |||+- LCD sleep: 0 = no, 1 = sleep
| ||+-- Headphone segment
| ||
| || Volume segments:
| |+--- - Volume B (medium, high)
| +---- - Volume A (low, high)
+------ - Speaker
</pre>
The LCD sleep bit is writable. The remaining bits are read-only.
The volume and headphone segments are enabled when pressing the SOUND button, according to this algorithm:
* If headphones are plugged in, enable the Headphone segment.
* If headphones are not plugged in, enable the Speaker segment and the following Volume segments:
** Volume level 0: None
** Volume level 1: A
** Volume level 2: B
** Volume level 3: A, B
* Hide all visible segments after 128 frames from the last press.
TODO: This documents the WonderSwan Color. The specifics probably work differently on the mono WonderSwan.
=== TFT LCD Configuration ($70, $71, $72, $73, $74, $75, $76, $77 SwanCrystal only) ===
These eight bytes are read from internal EEPROM and configure unknown aspects of the console's TFT LCD panel.
They are only writable while the [[Boot ROM]] is unlocked - locking has the side effect of making them read-only.
== Notes ==
<references />
25c3a76ce7d8fb8b351e2772e7c0bfc42deafebe
WonderWitch/FreyaBIOS/System
0
66
402
393
2024-12-08T09:44:45Z
Asie
351
/* Interrupts */ start
wikitext
text/x-wiki
The System interrupt provides assorted system-related functionality.
== Types ==
=== Suspend/resume structure ===
This structure is stored in SRAM block 3, offset <code>$7E00</code> (core 1) and <code>$BF00</code> (core 0).
{| class="wikitable"
|-
! Offset !! Size !! Contents
|-
| $0000 || 16384 || Copy of RAM area <code>$0000</code> - <code>$3FFF</code>
|-
| $4000 || 2 || Stack segment?
|-
| $4002 || 2 || Data segment?
|-
| $4004 || 224 || Copy of IO ports <code>$00</code> - <code>$DF</code>
|-
| $40E4 || 6 || ?
|}
== Interrupts ==
=== INT $17/AH=$00 - sys_interrupt_set_hook ===
* AH = $00
* AL = Interrupt index
* DS:BX = Pointer to new vector (read from)
* DS:DX = Pointer to old vector (written to)
=== INT $17/AH=$01 - sys_interrupt_reset_hook ===
* AH = $01
* AL = Interrupt index
* DS:BX = Pointer to old vector (read from)
=== INT $17/AH=$02 - sys_wait ===
* AH = $02
* CX = Frames to wait
=== INT $17/AH=$03 - sys_get_tick_count ===
* AH = $03
Return:
* DX:AX = Number of frames since system start
=== INT $17/AH=$04 - sys_sleep ===
=== INT $17/AH=$05 - sys_set_sleep_time ===
=== INT $17/AH=$06 - sys_get_sleep_time ===
=== INT $17/AH=$07 - sys_set_awake_key ===
=== INT $17/AH=$08 - sys_get_awake_key ===
=== INT $17/AH=$09 - sys_set_keepalive_int ===
=== INT $17/AH=$0A - sys_get_ownerinfo ===
* AH = $0A
* DS:DX = Output buffer
* CX = Output buffer size, in bytes
Errata:
* The FreyaBIOS implementation only works correctly in the "mono" mode. An alternate implementation that supports "color" mode is provided as part of libwwc.
=== INT $17/AH=$0B - sys_suspend ===
=== INT $17/AH=$0C - sys_resume ===
=== INT $17/AH=$0D - sys_set_remote ===
=== INT $17/AH=$0E - sys_get_remote ===
=== INT $17/AH=$0F - sys_alloc_iram ===
=== INT $17/AH=$10 - sys_free_iram ===
=== INT $17/AH=$11 - sys_get_my_iram ===
=== INT $17/AH=$12 - sys_get_version ===
* AH = $12
Return:
* AX = BIOS version
=== INT $17/AH=$13 - sys_swap ===
=== INT $17/AH=$14 - sys_set_resume ===
=== INT $17/AH=$15 - sys_get_resume ===
40c816ee73f278dfc209b0c472db017e1fe60820
419
402
2024-12-15T07:51:44Z
Asie
351
provide initial inormation on sys_suspend/resume
wikitext
text/x-wiki
The System interrupt provides assorted system-related functionality.
== Interrupts ==
=== INT $17/AH=$00 - sys_interrupt_set_hook ===
* AH = $00
* AL = Interrupt index
* DS:BX = Pointer to new vector (read from)
* DS:DX = Pointer to old vector (written to)
=== INT $17/AH=$01 - sys_interrupt_reset_hook ===
* AH = $01
* AL = Interrupt index
* DS:BX = Pointer to old vector (read from)
=== INT $17/AH=$02 - sys_wait ===
* AH = $02
* CX = Frames to wait
=== INT $17/AH=$03 - sys_get_tick_count ===
* AH = $03
Return:
* DX:AX = Number of frames since system start
=== INT $17/AH=$04 - sys_sleep ===
=== INT $17/AH=$05 - sys_set_sleep_time ===
=== INT $17/AH=$06 - sys_get_sleep_time ===
=== INT $17/AH=$07 - sys_set_awake_key ===
=== INT $17/AH=$08 - sys_get_awake_key ===
=== INT $17/AH=$09 - sys_set_keepalive_int ===
=== INT $17/AH=$0A - sys_get_ownerinfo ===
* AH = $0A
* DS:DX = Output buffer
* CX = Output buffer size, in bytes
Errata:
* The FreyaBIOS implementation only works correctly in the "mono" mode. An alternate implementation that supports "color" mode is provided as part of libwwc.
=== INT $17/AH=$0B - sys_suspend ===
* AH = $0B
* AL = Suspend slot (see below)
* DS:BX = ?
Return:
* AX = ?
TODO
==== Suspend/resume structure ====
This structure is stored in SRAM block 3, offset <code>$7E00</code> (slot 1) and <code>$BF00</code> (slot 0).
{| class="wikitable"
|-
! Offset !! Size !! Contents
|-
| $0000 || 16384 || Copy of RAM area <code>$0000</code> - <code>$3FFF</code>
|-
| $4000 || 2 || Stack segment?
|-
| $4002 || 2 || Data segment?
|-
| $4004 || 224 || Copy of IO ports <code>$00</code> - <code>$DF</code>
|-
| $40E4 || 6 || ?
|}
=== INT $17/AH=$0C - sys_resume ===
* AH = $0B
* AL = Suspend slot (see below)
TODO
=== INT $17/AH=$0D - sys_set_remote ===
=== INT $17/AH=$0E - sys_get_remote ===
=== INT $17/AH=$0F - sys_alloc_iram ===
=== INT $17/AH=$10 - sys_free_iram ===
=== INT $17/AH=$11 - sys_get_my_iram ===
=== INT $17/AH=$12 - sys_get_version ===
* AH = $12
Return:
* AX = BIOS version
=== INT $17/AH=$13 - sys_swap ===
=== INT $17/AH=$14 - sys_set_resume ===
=== INT $17/AH=$15 - sys_get_resume ===
847f602f0f4b231c1270bedc2fe8dd7128788d11
420
419
2024-12-15T08:02:25Z
Asie
351
/* INT $17/AH=$0B - sys_suspend */
wikitext
text/x-wiki
The System interrupt provides assorted system-related functionality.
== Interrupts ==
=== INT $17/AH=$00 - sys_interrupt_set_hook ===
* AH = $00
* AL = Interrupt index
* DS:BX = Pointer to new vector (read from)
* DS:DX = Pointer to old vector (written to)
=== INT $17/AH=$01 - sys_interrupt_reset_hook ===
* AH = $01
* AL = Interrupt index
* DS:BX = Pointer to old vector (read from)
=== INT $17/AH=$02 - sys_wait ===
* AH = $02
* CX = Frames to wait
=== INT $17/AH=$03 - sys_get_tick_count ===
* AH = $03
Return:
* DX:AX = Number of frames since system start
=== INT $17/AH=$04 - sys_sleep ===
=== INT $17/AH=$05 - sys_set_sleep_time ===
=== INT $17/AH=$06 - sys_get_sleep_time ===
=== INT $17/AH=$07 - sys_set_awake_key ===
=== INT $17/AH=$08 - sys_get_awake_key ===
=== INT $17/AH=$09 - sys_set_keepalive_int ===
=== INT $17/AH=$0A - sys_get_ownerinfo ===
* AH = $0A
* DS:DX = Output buffer
* CX = Output buffer size, in bytes
Errata:
* The FreyaBIOS implementation only works correctly in the "mono" mode. An alternate implementation that supports "color" mode is provided as part of libwwc.
=== INT $17/AH=$0B - sys_suspend ===
* AH = $0B
* AL = Suspend slot (see below)
* DS:BX = ?
Return:
* AX = ?
TODO
==== Suspend/resume structure ====
This structure is stored in SRAM block 3, offset <code>$7E00</code> (slot 1) and <code>$BF00</code> (slot 0).
{| class="wikitable"
|-
! Offset !! Size !! Contents
|-
| $0000 || 16384 || Copy of RAM area <code>$0000</code> - <code>$3FFF</code>
|-
| $4000 || 4 || Far pointer to I/O resume table (DS:BX), plus 1
|-
| $4004 || 224 || Copy of IO ports <code>$00</code> - <code>$DF</code>
|-
| $40E4 || 2 || Value of CX?
|-
| $40E6 || 2 || Value of SP?
|-
| $40E8 || 2 || Value of SS?
|}
==== I/O resume table ====
{| class="wikitable"
|-
! Offset !! Size !! Contents
|-
| $00 || 2 || 'IO'
|-
| $02 || 224 || Resume configuration for each I/O port
|}
=== INT $17/AH=$0C - sys_resume ===
* AH = $0B
* AL = Suspend slot (see below)
TODO
=== INT $17/AH=$0D - sys_set_remote ===
=== INT $17/AH=$0E - sys_get_remote ===
=== INT $17/AH=$0F - sys_alloc_iram ===
=== INT $17/AH=$10 - sys_free_iram ===
=== INT $17/AH=$11 - sys_get_my_iram ===
=== INT $17/AH=$12 - sys_get_version ===
* AH = $12
Return:
* AX = BIOS version
=== INT $17/AH=$13 - sys_swap ===
=== INT $17/AH=$14 - sys_set_resume ===
=== INT $17/AH=$15 - sys_get_resume ===
a5bfbf8baedefe873503934d9561660ee6329553
421
420
2024-12-15T09:08:37Z
Asie
351
wikitext
text/x-wiki
The System interrupt provides assorted system-related functionality.
== Interrupts ==
=== INT $17/AH=$00 - sys_interrupt_set_hook ===
* AH = $00
* AL = Interrupt index
* DS:BX = Pointer to new vector (read from)
* DS:DX = Pointer to old vector (written to)
=== INT $17/AH=$01 - sys_interrupt_reset_hook ===
* AH = $01
* AL = Interrupt index
* DS:BX = Pointer to old vector (read from)
=== INT $17/AH=$02 - sys_wait ===
* AH = $02
* CX = Frames to wait
=== INT $17/AH=$03 - sys_get_tick_count ===
* AH = $03
Return:
* DX:AX = Number of frames since system start
=== INT $17/AH=$04 - sys_sleep ===
=== INT $17/AH=$05 - sys_set_sleep_time ===
=== INT $17/AH=$06 - sys_get_sleep_time ===
=== INT $17/AH=$07 - sys_set_awake_key ===
=== INT $17/AH=$08 - sys_get_awake_key ===
=== INT $17/AH=$09 - sys_set_keepalive_int ===
=== INT $17/AH=$0A - sys_get_ownerinfo ===
* AH = $0A
* DS:DX = Output buffer
* CX = Output buffer size, in bytes
Errata:
* The FreyaBIOS implementation only works correctly in the "mono" mode. An alternate implementation that supports "color" mode is provided as part of libwwc.
=== INT $17/AH=$0B - sys_suspend ===
* AH = $0B
* AL = Suspend slot (see below)
* DS:BX = ?
Return:
* AX = 0 if suspend successful, 1 if returning from suspend (via sys_resume).
TODO
==== Suspend/resume structure ====
This structure is stored in SRAM block 3, offset <code>$7E00</code> (slot 1) and <code>$BF00</code> (slot 0).
{| class="wikitable"
|-
! Offset !! Size !! Contents
|-
| $0000 || 16384 || Copy of RAM area <code>$0000</code> - <code>$3FFF</code>
|-
| $4000 || 4 || Far pointer to I/O resume table (DS:BX), plus 1
|-
| $4004 || 224 || Copy of IO ports <code>$00</code> - <code>$DF</code>
|-
| $40E4 || 2 || Value of CX?
|-
| $40E6 || 2 || Value of SP?
|-
| $40E8 || 2 || Value of SS?
|}
==== I/O resume table ====
{| class="wikitable"
|-
! Offset !! Size !! Contents
|-
| $00 || 2 || 'IO'
|-
| $02 || 224 || Resume configuration for each I/O port
|}
=== INT $17/AH=$0C - sys_resume ===
* AH = $0C
* AL = Suspend slot?
Resumes execution from an existing suspend slot. Returns to where ''sys_suspend'' was last called, but with a different return value.
=== INT $17/AH=$0D - sys_set_remote ===
=== INT $17/AH=$0E - sys_get_remote ===
=== INT $17/AH=$0F - sys_alloc_iram ===
=== INT $17/AH=$10 - sys_free_iram ===
=== INT $17/AH=$11 - sys_get_my_iram ===
=== INT $17/AH=$12 - sys_get_version ===
* AH = $12
Return:
* AX = BIOS version
=== INT $17/AH=$13 - sys_swap ===
=== INT $17/AH=$14 - sys_set_resume ===
=== INT $17/AH=$15 - sys_get_resume ===
42a9d95bb375cfafa4bf2d74d3a12510dca1120f
422
421
2024-12-15T09:09:06Z
Asie
351
/* INT $17/AH=$0B - sys_suspend */
wikitext
text/x-wiki
The System interrupt provides assorted system-related functionality.
== Interrupts ==
=== INT $17/AH=$00 - sys_interrupt_set_hook ===
* AH = $00
* AL = Interrupt index
* DS:BX = Pointer to new vector (read from)
* DS:DX = Pointer to old vector (written to)
=== INT $17/AH=$01 - sys_interrupt_reset_hook ===
* AH = $01
* AL = Interrupt index
* DS:BX = Pointer to old vector (read from)
=== INT $17/AH=$02 - sys_wait ===
* AH = $02
* CX = Frames to wait
=== INT $17/AH=$03 - sys_get_tick_count ===
* AH = $03
Return:
* DX:AX = Number of frames since system start
=== INT $17/AH=$04 - sys_sleep ===
=== INT $17/AH=$05 - sys_set_sleep_time ===
=== INT $17/AH=$06 - sys_get_sleep_time ===
=== INT $17/AH=$07 - sys_set_awake_key ===
=== INT $17/AH=$08 - sys_get_awake_key ===
=== INT $17/AH=$09 - sys_set_keepalive_int ===
=== INT $17/AH=$0A - sys_get_ownerinfo ===
* AH = $0A
* DS:DX = Output buffer
* CX = Output buffer size, in bytes
Errata:
* The FreyaBIOS implementation only works correctly in the "mono" mode. An alternate implementation that supports "color" mode is provided as part of libwwc.
=== INT $17/AH=$0B - sys_suspend ===
* AH = $0B
* AL = Suspend slot (see below)
* DS:BX = ?
Return:
* AX = 0 if suspend successful, 1 if returning from suspend (via sys_resume).
Makes a copy of the execution state (IRAM, I/O ports, stack) to be restored via sys_resume (see below).
==== Suspend/resume structure ====
This structure is stored in SRAM block 3, offset <code>$7E00</code> (slot 1) and <code>$BF00</code> (slot 0).
{| class="wikitable"
|-
! Offset !! Size !! Contents
|-
| $0000 || 16384 || Copy of RAM area <code>$0000</code> - <code>$3FFF</code>
|-
| $4000 || 4 || Far pointer to I/O resume table (DS:BX), plus 1
|-
| $4004 || 224 || Copy of IO ports <code>$00</code> - <code>$DF</code>
|-
| $40E4 || 2 || Value of CX?
|-
| $40E6 || 2 || Value of SP?
|-
| $40E8 || 2 || Value of SS?
|}
==== I/O resume table ====
{| class="wikitable"
|-
! Offset !! Size !! Contents
|-
| $00 || 2 || 'IO'
|-
| $02 || 224 || Resume configuration for each I/O port
|}
=== INT $17/AH=$0C - sys_resume ===
* AH = $0C
* AL = Suspend slot?
Resumes execution from an existing suspend slot. Returns to where ''sys_suspend'' was last called, but with a different return value.
=== INT $17/AH=$0D - sys_set_remote ===
=== INT $17/AH=$0E - sys_get_remote ===
=== INT $17/AH=$0F - sys_alloc_iram ===
=== INT $17/AH=$10 - sys_free_iram ===
=== INT $17/AH=$11 - sys_get_my_iram ===
=== INT $17/AH=$12 - sys_get_version ===
* AH = $12
Return:
* AX = BIOS version
=== INT $17/AH=$13 - sys_swap ===
=== INT $17/AH=$14 - sys_set_resume ===
=== INT $17/AH=$15 - sys_get_resume ===
200aeec551f031aae5007f2a55bb83a423be265d
423
422
2024-12-15T09:09:16Z
Asie
351
/* INT $17/AH=$0B - sys_suspend */
wikitext
text/x-wiki
The System interrupt provides assorted system-related functionality.
== Interrupts ==
=== INT $17/AH=$00 - sys_interrupt_set_hook ===
* AH = $00
* AL = Interrupt index
* DS:BX = Pointer to new vector (read from)
* DS:DX = Pointer to old vector (written to)
=== INT $17/AH=$01 - sys_interrupt_reset_hook ===
* AH = $01
* AL = Interrupt index
* DS:BX = Pointer to old vector (read from)
=== INT $17/AH=$02 - sys_wait ===
* AH = $02
* CX = Frames to wait
=== INT $17/AH=$03 - sys_get_tick_count ===
* AH = $03
Return:
* DX:AX = Number of frames since system start
=== INT $17/AH=$04 - sys_sleep ===
=== INT $17/AH=$05 - sys_set_sleep_time ===
=== INT $17/AH=$06 - sys_get_sleep_time ===
=== INT $17/AH=$07 - sys_set_awake_key ===
=== INT $17/AH=$08 - sys_get_awake_key ===
=== INT $17/AH=$09 - sys_set_keepalive_int ===
=== INT $17/AH=$0A - sys_get_ownerinfo ===
* AH = $0A
* DS:DX = Output buffer
* CX = Output buffer size, in bytes
Errata:
* The FreyaBIOS implementation only works correctly in the "mono" mode. An alternate implementation that supports "color" mode is provided as part of libwwc.
=== INT $17/AH=$0B - sys_suspend ===
* AH = $0B
* AL = Suspend slot (see below)
* DS:BX = Pointer to I/O resume table (see below)
Return:
* AX = 0 if suspend successful, 1 if returning from suspend (via sys_resume).
Makes a copy of the execution state (IRAM, I/O ports, stack) to be restored via sys_resume (see below).
==== Suspend/resume structure ====
This structure is stored in SRAM block 3, offset <code>$7E00</code> (slot 1) and <code>$BF00</code> (slot 0).
{| class="wikitable"
|-
! Offset !! Size !! Contents
|-
| $0000 || 16384 || Copy of RAM area <code>$0000</code> - <code>$3FFF</code>
|-
| $4000 || 4 || Far pointer to I/O resume table (DS:BX), plus 1
|-
| $4004 || 224 || Copy of IO ports <code>$00</code> - <code>$DF</code>
|-
| $40E4 || 2 || Value of CX?
|-
| $40E6 || 2 || Value of SP?
|-
| $40E8 || 2 || Value of SS?
|}
==== I/O resume table ====
{| class="wikitable"
|-
! Offset !! Size !! Contents
|-
| $00 || 2 || 'IO'
|-
| $02 || 224 || Resume configuration for each I/O port
|}
=== INT $17/AH=$0C - sys_resume ===
* AH = $0C
* AL = Suspend slot?
Resumes execution from an existing suspend slot. Returns to where ''sys_suspend'' was last called, but with a different return value.
=== INT $17/AH=$0D - sys_set_remote ===
=== INT $17/AH=$0E - sys_get_remote ===
=== INT $17/AH=$0F - sys_alloc_iram ===
=== INT $17/AH=$10 - sys_free_iram ===
=== INT $17/AH=$11 - sys_get_my_iram ===
=== INT $17/AH=$12 - sys_get_version ===
* AH = $12
Return:
* AX = BIOS version
=== INT $17/AH=$13 - sys_swap ===
=== INT $17/AH=$14 - sys_set_resume ===
=== INT $17/AH=$15 - sys_get_resume ===
6adea9b76a79b7fb18cb1cf639a17e25200780bf
424
423
2024-12-15T11:30:32Z
Asie
351
initially document sys_set/get_resume
wikitext
text/x-wiki
The System interrupt provides assorted system-related functionality.
== Interrupts ==
=== INT $17/AH=$00 - sys_interrupt_set_hook ===
* AH = $00
* AL = Interrupt index
* DS:BX = Pointer to new vector (read from)
* DS:DX = Pointer to old vector (written to)
=== INT $17/AH=$01 - sys_interrupt_reset_hook ===
* AH = $01
* AL = Interrupt index
* DS:BX = Pointer to old vector (read from)
=== INT $17/AH=$02 - sys_wait ===
* AH = $02
* CX = Frames to wait
=== INT $17/AH=$03 - sys_get_tick_count ===
* AH = $03
Return:
* DX:AX = Number of frames since system start
=== INT $17/AH=$04 - sys_sleep ===
=== INT $17/AH=$05 - sys_set_sleep_time ===
=== INT $17/AH=$06 - sys_get_sleep_time ===
=== INT $17/AH=$07 - sys_set_awake_key ===
=== INT $17/AH=$08 - sys_get_awake_key ===
=== INT $17/AH=$09 - sys_set_keepalive_int ===
=== INT $17/AH=$0A - sys_get_ownerinfo ===
* AH = $0A
* DS:DX = Output buffer
* CX = Output buffer size, in bytes
Errata:
* The FreyaBIOS implementation only works correctly in the "mono" mode. An alternate implementation that supports "color" mode is provided as part of libwwc.
=== INT $17/AH=$0B - sys_suspend ===
* AH = $0B
* AL = Suspend slot (see below)
* DS:BX = Pointer to I/O resume table (see below)
Return:
* AX = 0 if suspend successful, 1 if returning from suspend (via sys_resume).
Makes a copy of the execution state (IRAM, I/O ports, stack) to be restored via sys_resume (see below).
==== Suspend/resume structure ====
This structure is stored in SRAM block 3, offset <code>$7E00</code> (slot 1) and <code>$BF00</code> (slot 0).
{| class="wikitable"
|-
! Offset !! Size !! Contents
|-
| $0000 || 16384 || Copy of RAM area <code>$0000</code> - <code>$3FFF</code>
|-
| $4000 || 4 || Far pointer to I/O resume table (DS:BX), plus 1
|-
| $4004 || 224 || Copy of IO ports <code>$00</code> - <code>$DF</code>
|-
| $40E4 || 2 || Value of CX?
|-
| $40E6 || 2 || Value of SP?
|-
| $40E8 || 2 || Value of SS?
|}
In addition, these SRAM block 3 locations are used:
{| class="wikitable"
|-
! Offset !! Contents
|-
| $FFEE || Resumable status for slot 0 (bit 7 = resumable?, bit ?..0 = ID)
|-
| $FFEF || Resumable status for slot 1 (bit 7 = resumable?, bit ?..0 = ID)
|}
==== I/O resume table ====
{| class="wikitable"
|-
! Offset !! Size !! Contents
|-
| $00 || 2 || 'IO'
|-
| $02 || 224 || Resume configuration for each I/O port
|}
=== INT $17/AH=$0C - sys_resume ===
* AH = $0C
* AL = Suspend slot?
Resumes execution from an existing suspend slot. Returns to where ''sys_suspend'' was last called, but with a different return value.
=== INT $17/AH=$0D - sys_set_remote ===
=== INT $17/AH=$0E - sys_get_remote ===
=== INT $17/AH=$0F - sys_alloc_iram ===
=== INT $17/AH=$10 - sys_free_iram ===
=== INT $17/AH=$11 - sys_get_my_iram ===
=== INT $17/AH=$12 - sys_get_version ===
* AH = $12
Return:
* AX = BIOS version
=== INT $17/AH=$13 - sys_swap ===
=== INT $17/AH=$14 - sys_set_resume ===
* AH = $14
* BL = Resumable flag for slot ?
* BH = Resumable flag for slot ?
=== INT $17/AH=$15 - sys_get_resume ===
* AH = $14
Return:
* AL = Resumable flag for slot ?
* AH = Resumable flag for slot ?
657fb2a86b30f8c4871020b20585db16ae54285e
425
424
2024-12-15T11:31:42Z
Asie
351
document sys_get_version
wikitext
text/x-wiki
The System interrupt provides assorted system-related functionality.
== Interrupts ==
=== INT $17/AH=$00 - sys_interrupt_set_hook ===
* AH = $00
* AL = Interrupt index
* DS:BX = Pointer to new vector (read from)
* DS:DX = Pointer to old vector (written to)
=== INT $17/AH=$01 - sys_interrupt_reset_hook ===
* AH = $01
* AL = Interrupt index
* DS:BX = Pointer to old vector (read from)
=== INT $17/AH=$02 - sys_wait ===
* AH = $02
* CX = Frames to wait
=== INT $17/AH=$03 - sys_get_tick_count ===
* AH = $03
Return:
* DX:AX = Number of frames since system start
=== INT $17/AH=$04 - sys_sleep ===
=== INT $17/AH=$05 - sys_set_sleep_time ===
=== INT $17/AH=$06 - sys_get_sleep_time ===
=== INT $17/AH=$07 - sys_set_awake_key ===
=== INT $17/AH=$08 - sys_get_awake_key ===
=== INT $17/AH=$09 - sys_set_keepalive_int ===
=== INT $17/AH=$0A - sys_get_ownerinfo ===
* AH = $0A
* DS:DX = Output buffer
* CX = Output buffer size, in bytes
Errata:
* The FreyaBIOS implementation only works correctly in the "mono" mode. An alternate implementation that supports "color" mode is provided as part of libwwc.
=== INT $17/AH=$0B - sys_suspend ===
* AH = $0B
* AL = Suspend slot (see below)
* DS:BX = Pointer to I/O resume table (see below)
Return:
* AX = 0 if suspend successful, 1 if returning from suspend (via sys_resume).
Makes a copy of the execution state (IRAM, I/O ports, stack) to be restored via sys_resume (see below).
==== Suspend/resume structure ====
This structure is stored in SRAM block 3, offset <code>$7E00</code> (slot 1) and <code>$BF00</code> (slot 0).
{| class="wikitable"
|-
! Offset !! Size !! Contents
|-
| $0000 || 16384 || Copy of RAM area <code>$0000</code> - <code>$3FFF</code>
|-
| $4000 || 4 || Far pointer to I/O resume table (DS:BX), plus 1
|-
| $4004 || 224 || Copy of IO ports <code>$00</code> - <code>$DF</code>
|-
| $40E4 || 2 || Value of CX?
|-
| $40E6 || 2 || Value of SP?
|-
| $40E8 || 2 || Value of SS?
|}
In addition, these SRAM block 3 locations are used:
{| class="wikitable"
|-
! Offset !! Contents
|-
| $FFEE || Resumable status for slot 0 (bit 7 = resumable?, bit ?..0 = ID)
|-
| $FFEF || Resumable status for slot 1 (bit 7 = resumable?, bit ?..0 = ID)
|}
==== I/O resume table ====
{| class="wikitable"
|-
! Offset !! Size !! Contents
|-
| $00 || 2 || 'IO'
|-
| $02 || 224 || Resume configuration for each I/O port
|}
=== INT $17/AH=$0C - sys_resume ===
* AH = $0C
* AL = Suspend slot?
Resumes execution from an existing suspend slot. Returns to where ''sys_suspend'' was last called, but with a different return value.
=== INT $17/AH=$0D - sys_set_remote ===
=== INT $17/AH=$0E - sys_get_remote ===
=== INT $17/AH=$0F - sys_alloc_iram ===
=== INT $17/AH=$10 - sys_free_iram ===
=== INT $17/AH=$11 - sys_get_my_iram ===
=== INT $17/AH=$12 - sys_get_version ===
* AH = $12
Return:
* AX = BIOS version
15 bit 0
---- ---- ---- ----
MMMM mmmm pppp pppp
|||| |||| |||| ||||
|||| |||| ++++-++++- Patch version (0-127)
|||| ++++----------- Minor version (0-15)
++++---------------- Major version (0-15)
=== INT $17/AH=$13 - sys_swap ===
=== INT $17/AH=$14 - sys_set_resume ===
* AH = $14
* BL = Resumable flag for slot ?
* BH = Resumable flag for slot ?
=== INT $17/AH=$15 - sys_get_resume ===
* AH = $15
Return:
* AL = Resumable flag for slot ?
* AH = Resumable flag for slot ?
8a896858286b52f4abd8e7e89809399f19fab041
429
425
2024-12-17T15:56:45Z
Asie
351
wikitext
text/x-wiki
The System interrupt provides assorted system-related functionality.
== Interrupts ==
=== INT $17/AH=$00 - sys_interrupt_set_hook ===
* AH = $00
* AL = Interrupt index
* DS:BX = Pointer to new vector (read from)
* DS:DX = Pointer to old vector (written to)
Hook the given interrupt handler and enable the interrupt.
=== INT $17/AH=$01 - sys_interrupt_reset_hook ===
* AH = $01
* AL = Interrupt index
* DS:BX = Pointer to old vector (read from)
Unhook the given interrupt handler and disable the interrupt.
=== INT $17/AH=$02 - sys_wait ===
* AH = $02
* CX = Frames to wait
=== INT $17/AH=$03 - sys_get_tick_count ===
* AH = $03
Return:
* DX:AX = Number of frames since system start
=== INT $17/AH=$04 - sys_sleep ===
=== INT $17/AH=$05 - sys_set_sleep_time ===
=== INT $17/AH=$06 - sys_get_sleep_time ===
=== INT $17/AH=$07 - sys_set_awake_key ===
=== INT $17/AH=$08 - sys_get_awake_key ===
=== INT $17/AH=$09 - sys_set_keepalive_int ===
=== INT $17/AH=$0A - sys_get_ownerinfo ===
* AH = $0A
* DS:DX = Output buffer
* CX = Output buffer size, in bytes
Errata:
* The FreyaBIOS implementation only works correctly in the "mono" mode. An alternate implementation that supports "color" mode is provided as part of libwwc.
=== INT $17/AH=$0B - sys_suspend ===
* AH = $0B
* AL = Suspend slot (see below)
* DS:BX = Pointer to I/O resume table (see below)
Return:
* AX = 0 if suspend successful, 1 if returning from suspend (via sys_resume).
Makes a copy of the execution state (IRAM, I/O ports, stack) to be restored via sys_resume (see below).
==== Suspend/resume structure ====
This structure is stored in SRAM block 3, offset <code>$7E00</code> (slot 1) and <code>$BF00</code> (slot 0).
{| class="wikitable"
|-
! Offset !! Size !! Contents
|-
| $0000 || 16384 || Copy of RAM area <code>$0000</code> - <code>$3FFF</code>
|-
| $4000 || 4 || Far pointer to I/O resume table (DS:BX), plus 1
|-
| $4004 || 224 || Copy of IO ports <code>$00</code> - <code>$DF</code>
|-
| $40E4 || 2 || Value of CX?
|-
| $40E6 || 2 || Value of SP?
|-
| $40E8 || 2 || Value of SS?
|}
In addition, these SRAM block 3 locations are used:
{| class="wikitable"
|-
! Offset !! Contents
|-
| $FFEE || Resumable status for slot 0 (bit 7 = resumable?, bit ?..0 = ID)
|-
| $FFEF || Resumable status for slot 1 (bit 7 = resumable?, bit ?..0 = ID)
|}
==== I/O resume table ====
{| class="wikitable"
|-
! Offset !! Size !! Contents
|-
| $00 || 2 || 'IO'
|-
| $02 || 224 || Resume configuration for each I/O port
|}
=== INT $17/AH=$0C - sys_resume ===
* AH = $0C
* AL = Suspend slot?
Resumes execution from an existing suspend slot. Returns to where ''sys_suspend'' was last called, but with a different return value.
=== INT $17/AH=$0D - sys_set_remote ===
=== INT $17/AH=$0E - sys_get_remote ===
=== INT $17/AH=$0F - sys_alloc_iram ===
=== INT $17/AH=$10 - sys_free_iram ===
=== INT $17/AH=$11 - sys_get_my_iram ===
=== INT $17/AH=$12 - sys_get_version ===
* AH = $12
Return:
* AX = BIOS version
15 bit 0
---- ---- ---- ----
MMMM mmmm pppp pppp
|||| |||| |||| ||||
|||| |||| ++++-++++- Patch version (0-127)
|||| ++++----------- Minor version (0-15)
++++---------------- Major version (0-15)
=== INT $17/AH=$13 - sys_swap ===
=== INT $17/AH=$14 - sys_set_resume ===
* AH = $14
* BL = Resumable flag for slot ?
* BH = Resumable flag for slot ?
=== INT $17/AH=$15 - sys_get_resume ===
* AH = $15
Return:
* AL = Resumable flag for slot ?
* AH = Resumable flag for slot ?
8c3098857aad69154deb09c10676f34ee02725f1
430
429
2024-12-17T16:34:53Z
Asie
351
/* INT $17/AH=$0F - sys_alloc_iram */
wikitext
text/x-wiki
The System interrupt provides assorted system-related functionality.
== Interrupts ==
=== INT $17/AH=$00 - sys_interrupt_set_hook ===
* AH = $00
* AL = Interrupt index
* DS:BX = Pointer to new vector (read from)
* DS:DX = Pointer to old vector (written to)
Hook the given interrupt handler and enable the interrupt.
=== INT $17/AH=$01 - sys_interrupt_reset_hook ===
* AH = $01
* AL = Interrupt index
* DS:BX = Pointer to old vector (read from)
Unhook the given interrupt handler and disable the interrupt.
=== INT $17/AH=$02 - sys_wait ===
* AH = $02
* CX = Frames to wait
=== INT $17/AH=$03 - sys_get_tick_count ===
* AH = $03
Return:
* DX:AX = Number of frames since system start
=== INT $17/AH=$04 - sys_sleep ===
=== INT $17/AH=$05 - sys_set_sleep_time ===
=== INT $17/AH=$06 - sys_get_sleep_time ===
=== INT $17/AH=$07 - sys_set_awake_key ===
=== INT $17/AH=$08 - sys_get_awake_key ===
=== INT $17/AH=$09 - sys_set_keepalive_int ===
=== INT $17/AH=$0A - sys_get_ownerinfo ===
* AH = $0A
* DS:DX = Output buffer
* CX = Output buffer size, in bytes
Errata:
* The FreyaBIOS implementation only works correctly in the "mono" mode. An alternate implementation that supports "color" mode is provided as part of libwwc.
=== INT $17/AH=$0B - sys_suspend ===
* AH = $0B
* AL = Suspend slot (see below)
* DS:BX = Pointer to I/O resume table (see below)
Return:
* AX = 0 if suspend successful, 1 if returning from suspend (via sys_resume).
Makes a copy of the execution state (IRAM, I/O ports, stack) to be restored via sys_resume (see below).
==== Suspend/resume structure ====
This structure is stored in SRAM block 3, offset <code>$7E00</code> (slot 1) and <code>$BF00</code> (slot 0).
{| class="wikitable"
|-
! Offset !! Size !! Contents
|-
| $0000 || 16384 || Copy of RAM area <code>$0000</code> - <code>$3FFF</code>
|-
| $4000 || 4 || Far pointer to I/O resume table (DS:BX), plus 1
|-
| $4004 || 224 || Copy of IO ports <code>$00</code> - <code>$DF</code>
|-
| $40E4 || 2 || Value of CX?
|-
| $40E6 || 2 || Value of SP?
|-
| $40E8 || 2 || Value of SS?
|}
In addition, these SRAM block 3 locations are used:
{| class="wikitable"
|-
! Offset !! Contents
|-
| $FFEE || Resumable status for slot 0 (bit 7 = resumable?, bit ?..0 = ID)
|-
| $FFEF || Resumable status for slot 1 (bit 7 = resumable?, bit ?..0 = ID)
|}
==== I/O resume table ====
{| class="wikitable"
|-
! Offset !! Size !! Contents
|-
| $00 || 2 || 'IO'
|-
| $02 || 224 || Resume configuration for each I/O port
|}
=== INT $17/AH=$0C - sys_resume ===
* AH = $0C
* AL = Suspend slot?
Resumes execution from an existing suspend slot. Returns to where ''sys_suspend'' was last called, but with a different return value.
=== INT $17/AH=$0D - sys_set_remote ===
=== INT $17/AH=$0E - sys_get_remote ===
=== INT $17/AH=$0F - sys_alloc_iram ===
* BX = ?
* CX = bytes to allocate
Return:
* AX = near pointer to allocated IRAM block
Pointers to IRAM blocks are always segment (16 byte)-aligned.
=== INT $17/AH=$10 - sys_free_iram ===
=== INT $17/AH=$11 - sys_get_my_iram ===
=== INT $17/AH=$12 - sys_get_version ===
* AH = $12
Return:
* AX = BIOS version
15 bit 0
---- ---- ---- ----
MMMM mmmm pppp pppp
|||| |||| |||| ||||
|||| |||| ++++-++++- Patch version (0-127)
|||| ++++----------- Minor version (0-15)
++++---------------- Major version (0-15)
=== INT $17/AH=$13 - sys_swap ===
=== INT $17/AH=$14 - sys_set_resume ===
* AH = $14
* BL = Resumable flag for slot ?
* BH = Resumable flag for slot ?
=== INT $17/AH=$15 - sys_get_resume ===
* AH = $15
Return:
* AL = Resumable flag for slot ?
* AH = Resumable flag for slot ?
685426b41308bef66a06e5bbeab129cd1c787655
WonderWitch/Flash
0
67
403
397
2024-12-08T09:57:24Z
Asie
351
document sector layout
wikitext
text/x-wiki
The WonderWitch cartridge features a 512KiB flash chip - the MBM29DL400TC. While the WonderSwan SoC pervents writes to the ROM area, it can be written to via the SRAM area using port $CE on the [[Bandai 2003]] mapper.
== Sector layout ==
{| class="wikitable"
! Bank
! Start
! End
! Size
|-
| rowspan="6" | 2
| $00000
| $0FFFF
| 64 KB
|-
| $10000
| $1FFFF
| 64 KB
|-
| $20000
| $2FFFF
| 64 KB
|-
| $30000
| $3FFFF
| 64 KB
|-
| $40000
| $4FFFF
| 64 KB
|-
| $50000
| $5FFFF
| 64 KB
|-
| rowspan="8" | 1
| $60000
| $63FFF
| 16 KB
|-
| $64000
| $6BFFF
| 32 KB
|-
| $6C000
| $6DFFF
| 8 KB
|-
| $6E000
| $6FFFF
| 8 KB
|-
| $70000
| $71FFF
| 8 KB
|-
| $72000
| $73FFF
| 8 KB
|-
| $74000
| $7BFFF
| 32 KB
|-
| $7C000
| $7FFFF
| 16 KB
|}
Note that MBM29DL400TC allows operating simultaneously in two banks: the first 384 KB can be programmed or erased while the last 128 KB remains readable, and vice versa.
== Commands ==
TODO
== Links ==
* [https://github.com/up-n-atom/WonderWitch/blob/main/Datasheets/MBM29DL400BC-12PFTN_to_MBM29DL400TC-90PFTN.pdf Datasheet]
8136c75714649a7fef0cdfc9b261e3e3ff9561ec
404
403
2024-12-08T09:57:39Z
Asie
351
/* Sector layout */
wikitext
text/x-wiki
The WonderWitch cartridge features a 512KiB flash chip - the MBM29DL400TC. While the WonderSwan SoC pervents writes to the ROM area, it can be written to via the SRAM area using port $CE on the [[Bandai 2003]] mapper.
== Sector layout ==
{| class="wikitable"
! Bank
! Start
! End
! Size
|-
| rowspan="6" | 2
| $00000
| $0FFFF
| 64 KB
|-
| $10000
| $1FFFF
| 64 KB
|-
| $20000
| $2FFFF
| 64 KB
|-
| $30000
| $3FFFF
| 64 KB
|-
| $40000
| $4FFFF
| 64 KB
|-
| $50000
| $5FFFF
| 64 KB
|-
| rowspan="8" | 1
| $60000
| $63FFF
| 16 KB
|-
| $64000
| $6BFFF
| 32 KB
|-
| $6C000
| $6DFFF
| 8 KB
|-
| $6E000
| $6FFFF
| 8 KB
|-
| $70000
| $71FFF
| 8 KB
|-
| $72000
| $73FFF
| 8 KB
|-
| $74000
| $7BFFF
| 32 KB
|-
| $7C000
| $7FFFF
| 16 KB
|}
Note that the MBM29DL400TC allows operating simultaneously in two banks: the first 384 KB can be programmed or erased while the last 128 KB remains readable, and vice versa.
== Commands ==
TODO
== Links ==
* [https://github.com/up-n-atom/WonderWitch/blob/main/Datasheets/MBM29DL400BC-12PFTN_to_MBM29DL400TC-90PFTN.pdf Datasheet]
ff65adbefb78d4f7f23b80e46dc35321654497f1
ROM header
0
5
405
400
2024-12-08T10:01:38Z
Asie
351
/* Developer/Publisher ID ($6) */ add Soeishinsha
wikitext
text/x-wiki
Every WonderSwan ROM contains a header. It is stored at the end - final sixteen bytes - of the ROM image.
== ROM header ==
Parts of this header are validated or otherwise used by the console's [[boot ROM]] - they are marked in '''bold'''.
{| class="wikitable"
|+ Header contents
|-
! Offset !! Length !! Contents
|-
| '''$0''' || '''5''' || Far jump instruction: '''0xEA''', offset, segment.
|-
| '''$5''' || '''1''' || '''Maintenance'''
|-
| $6 || 1 || Developer/Publisher ID
|-
| $7 || 1 || Color
|-
| $8 || 1 || Game ID (binary-coded decimal)
|-
| '''$9''' || '''1''' || '''Game version? / Safe mode'''
|-
| $A || 1 || ROM size
|-
| $B || 1 || Save type/size
|-
| '''$C''' || '''1''' || '''Flags'''
|-
| $D || 1 || Mapper
|-
| $E || 2 || Checksum (sum of all ROM bytes excluding the checksum)
|}
=== Maintenance ($5) ===
----
<pre>
7 bit 0
---- ----
s... 0000
| ||||
| ++++- Must be zero; otherwise the console will prohibit execution.
| Purpose unknown.
+--------- (Color) Splash bypass: 0 = Disable, 1 = Enable.
Bypasses the custom boot splash stored in the console's
internal EEPROM; presumably used for bricked console recovery.
</pre>
=== Developer/Publisher ID ($6) ===
----
{| class="wikitable"
|+ Known official developer/publisher IDs
|-
! ID !! Publisher code !! Publisher
|-
| $01 || BAN || Bandai
|-
| $02 || TAT || Taito
|-
| $03 || TMY || Tomy
|-
| $04 || KEX || Koei
|-
| $05 || DTE || Data East
|-
| $06 || AAE || Asmik Ace
|-
| $07 || MDE || Media Entertainment
|-
| $08 || NHB || Nichibutsu
|-
| $0A || CCJ || Coconuts Japan
|-
| $0B || SUM || Sammy
|-
| $0C || SUN || Sunsoft
|-
| $0D || PAW || Mebius
|-
| $0E || BPR || Banpresto
|-
| $10 || JLC || Jaleco
|-
| $11 || MGA || Imagineer
|-
| $12 || KNM || Konami
|-
| $16 || KBS || Kobunsha
|-
| $17 || BTM || Bottom Up
|-
| $18 || KGT || Kaga Tech
|-
| $19 || SRV || Sunrise
|-
| $1A || CFT || Cyber Front
|-
| $1B || MGH || Megahouse
|-
| $1D || BEC || Interbec
|-
| $1E || NAP || Nihon Application
|-
| $1F || BVL || Bandai Visual
|-
| $20 || ATN || Athena
|-
| $21 || KDX || KID
|-
| $22 || HAL || HAL Corporation
|-
| $23 || YKE || Yuki Enterprise
|-
| $24 || OMN || Omega Micott
|-
| $25 || LAY || Layup
|-
| $26 || KDK || Kadokawa Shoten
|-
| $27 || SHL || Shall Luck
|-
| $28 || SQR || Squaresoft
|-
| $2A || SCC || ?
|-
| $2B || TMC || Tom Create
|-
| $2D || NMC || Namco
|-
| $2E || SES || Soeishinsha
|-
| $2F || HTR || Hearty Robin
|-
| $31 || VGD || Vanguard
|-
| $32 || MGT || Megatron
|-
| $33 || WIZ || Wiz
|-
| $35 || TAN || Tanita
|-
| $36 || CPC || Capcom
|}
Note that IDs $00 and $01 are used across a variety of commercial games. Homebrew is known to use arbitrary values in this field.
=== Color ($7) ===
----
<pre>
7 bit 0
---- ----
???? ???c
|
+- 0 = Monochrome only, 1 = Supports Color mode.
</pre>
=== Game version? / Safe mode ($9) ===
----
<pre>
7 bit 0
---- ----
pvvv vvvv
|||| ||||
|+++ ++++- Game version?
+--------- Internal EEPROM write protect: 0 = Enable, 1 = Disable.
This prohibits writing to the internal EEPROM for addresses
0x60 and above (user settings, custom splash screen).
Games are expected to enable write protection; however, the
WonderWitch is factory configured with it disabled.
</pre>
=== ROM size ($A) ===
----
Unofficial/inferred ROM size values are marked in ''italic''.
{| class="wikitable"
|+ ROM size values
|-
! ID !! Size
|-
| ''$00'' || ''1 Mbit (128 KiB)''
|-
| ''$01'' || ''2 Mbit (256 KiB)''
|-
| $02 || 4 Mbit (512 KiB)
|-
| $03 || 8 Mbit (1 MiB)
|-
| $04 || 16 Mbit (2 MiB)
|-
| ''$05'' || ''24 Mbit (3 MiB)''
|-
| $06 || 32 Mbit (4 MiB)
|-
| ''$07'' || ''48 Mbit (6 MiB)''
|-
| $08 || 64 Mbit (8 MiB)
|-
| $09 || 128 Mbit (16 MiB)
|-
| ''$0A'' || ''256 Mbit (32 MiB)''
|-
| ''$0B'' || ''512 Mbit (64 MiB)''
|}
Note that ROM sizes over 16 MiB are not supported by the [[Bandai 2001]] mapper. The [[Bandai 2003]] mapper is limited to 64 MiB.
=== Save type/size ($B) ===
----
{| class="wikitable"
|+ Save type values
|-
! ID !! Type !! Size
|-
| $00 || colspan="2" style="text-align:center;" | None
|-
| $01 || rowspan="5" | SRAM || rowspan="2" | 256 Kbit (32 KiB)
|-
| $02
|-
| $03 || 1 Mbit (128 KiB)
|-
| $04 || 2 Mbit (256 KiB)
|-
| $05 || 4 Mbit (512 KiB)
|-
| $10 || rowspan="3" | EEPROM || 1 Kbit (128 B)
|-
| $20 || 16 Kbit (2 KiB)
|-
| $50 || 8 Kbit (1 KiB)
|}
Note that while ID <code>$01</code> is commonly documented as <code>64 Kbit</code>, all known cartridges using that value come with <code>256 Kbit</code> SRAM chips. This requires further investigation.
=== Flags ($C) ===
----
<pre>
7 bit 0
---- ----
???? ?SBv
|||
||+- Starting screen orientation: 0 = Horizontal, 1 = Vertical.
|| Controls the splash screen's orientation.
|+-- ROM bus width: 0 = 16-bit, 1 = 8-bit.
+--- ROM access time: 0 = 3 CPU cycles, 1 = 1 CPU cycle.
</pre>
=== Mapper ($D) ===
----
{| class="wikitable"
|+ Known mapper types
|-
! ID !! Mapper
|-
| $00 || [[Bandai 2001]] or [[KARNAK]]
|-
| $01 || [[Bandai 2003]]
|}
65c20f7bac877bcb9eaa7425d1b56e88e26f34a7
406
405
2024-12-08T13:18:28Z
Asie
351
/* Developer/Publisher ID ($6) */
wikitext
text/x-wiki
Every WonderSwan ROM contains a header. It is stored at the end - final sixteen bytes - of the ROM image.
== ROM header ==
Parts of this header are validated or otherwise used by the console's [[boot ROM]] - they are marked in '''bold'''.
{| class="wikitable"
|+ Header contents
|-
! Offset !! Length !! Contents
|-
| '''$0''' || '''5''' || Far jump instruction: '''0xEA''', offset, segment.
|-
| '''$5''' || '''1''' || '''Maintenance'''
|-
| $6 || 1 || Developer/Publisher ID
|-
| $7 || 1 || Color
|-
| $8 || 1 || Game ID (binary-coded decimal)
|-
| '''$9''' || '''1''' || '''Game version? / Safe mode'''
|-
| $A || 1 || ROM size
|-
| $B || 1 || Save type/size
|-
| '''$C''' || '''1''' || '''Flags'''
|-
| $D || 1 || Mapper
|-
| $E || 2 || Checksum (sum of all ROM bytes excluding the checksum)
|}
=== Maintenance ($5) ===
----
<pre>
7 bit 0
---- ----
s... 0000
| ||||
| ++++- Must be zero; otherwise the console will prohibit execution.
| Purpose unknown.
+--------- (Color) Splash bypass: 0 = Disable, 1 = Enable.
Bypasses the custom boot splash stored in the console's
internal EEPROM; presumably used for bricked console recovery.
</pre>
=== Developer/Publisher ID ($6) ===
----
{| class="wikitable"
|+ Known official developer/publisher IDs
|-
! ID !! Publisher code !! Publisher
|-
| $01 || BAN || Bandai
|-
| $02 || TAT || Taito
|-
| $03 || TMY || Tomy
|-
| $04 || KEX || Koei
|-
| $05 || DTE || Data East
|-
| $06 || AAE || Asmik Ace
|-
| $07 || MDE || Media Entertainment
|-
| $08 || NHB || Nichibutsu
|-
| $0A || CCJ || Coconuts Japan
|-
| $0B || SUM || Sammy
|-
| $0C || SUN || Sunsoft
|-
| $0D || PAW || Mebius
|-
| $0E || BPR || Banpresto
|-
| $10 || JLC || Jaleco
|-
| $11 || MGA || Imagineer
|-
| $12 || KNM || Konami
|-
| $16 || KBS || Kobunsha
|-
| $17 || BTM || Bottom Up
|-
| $18 || KGT || Kaga Tech
|-
| $19 || SRV || Sunrise
|-
| $1A || CFT || Cyber Front
|-
| $1B || MGH || Megahouse
|-
| $1D || BEC || Interbec
|-
| $1E || NAP || Nihon Application
|-
| $1F || BVL || Bandai Visual
|-
| $20 || ATN || Athena
|-
| $21 || KDX || KID
|-
| $22 || HAL || HAL Corporation
|-
| $23 || YKE || Yuki Enterprise
|-
| $24 || OMN || Omega Micott
|-
| $25 || LAY || Layup
|-
| $26 || KDK || Kadokawa Shoten
|-
| $27 || SHL || Shall Luck
|-
| $28 || SQR || Squaresoft
|-
| $2A || SCC || ? (SUNCORPORATION?)
|-
| $2B || TMC || Tom Create
|-
| $2D || NMC || Namco
|-
| $2E || SES || Soeishinsha
|-
| $2F || HTR || Hearty Robin
|-
| $31 || VGD || Vanguard
|-
| $32 || MGT || Megatron
|-
| $33 || WIZ || Wiz
|-
| $35 || TAN || Tanita
|-
| $36 || CPC || Capcom
|}
Note that IDs $00 and $01 are used across a variety of commercial games. Homebrew is known to use arbitrary values in this field.
=== Color ($7) ===
----
<pre>
7 bit 0
---- ----
???? ???c
|
+- 0 = Monochrome only, 1 = Supports Color mode.
</pre>
=== Game version? / Safe mode ($9) ===
----
<pre>
7 bit 0
---- ----
pvvv vvvv
|||| ||||
|+++ ++++- Game version?
+--------- Internal EEPROM write protect: 0 = Enable, 1 = Disable.
This prohibits writing to the internal EEPROM for addresses
0x60 and above (user settings, custom splash screen).
Games are expected to enable write protection; however, the
WonderWitch is factory configured with it disabled.
</pre>
=== ROM size ($A) ===
----
Unofficial/inferred ROM size values are marked in ''italic''.
{| class="wikitable"
|+ ROM size values
|-
! ID !! Size
|-
| ''$00'' || ''1 Mbit (128 KiB)''
|-
| ''$01'' || ''2 Mbit (256 KiB)''
|-
| $02 || 4 Mbit (512 KiB)
|-
| $03 || 8 Mbit (1 MiB)
|-
| $04 || 16 Mbit (2 MiB)
|-
| ''$05'' || ''24 Mbit (3 MiB)''
|-
| $06 || 32 Mbit (4 MiB)
|-
| ''$07'' || ''48 Mbit (6 MiB)''
|-
| $08 || 64 Mbit (8 MiB)
|-
| $09 || 128 Mbit (16 MiB)
|-
| ''$0A'' || ''256 Mbit (32 MiB)''
|-
| ''$0B'' || ''512 Mbit (64 MiB)''
|}
Note that ROM sizes over 16 MiB are not supported by the [[Bandai 2001]] mapper. The [[Bandai 2003]] mapper is limited to 64 MiB.
=== Save type/size ($B) ===
----
{| class="wikitable"
|+ Save type values
|-
! ID !! Type !! Size
|-
| $00 || colspan="2" style="text-align:center;" | None
|-
| $01 || rowspan="5" | SRAM || rowspan="2" | 256 Kbit (32 KiB)
|-
| $02
|-
| $03 || 1 Mbit (128 KiB)
|-
| $04 || 2 Mbit (256 KiB)
|-
| $05 || 4 Mbit (512 KiB)
|-
| $10 || rowspan="3" | EEPROM || 1 Kbit (128 B)
|-
| $20 || 16 Kbit (2 KiB)
|-
| $50 || 8 Kbit (1 KiB)
|}
Note that while ID <code>$01</code> is commonly documented as <code>64 Kbit</code>, all known cartridges using that value come with <code>256 Kbit</code> SRAM chips. This requires further investigation.
=== Flags ($C) ===
----
<pre>
7 bit 0
---- ----
???? ?SBv
|||
||+- Starting screen orientation: 0 = Horizontal, 1 = Vertical.
|| Controls the splash screen's orientation.
|+-- ROM bus width: 0 = 16-bit, 1 = 8-bit.
+--- ROM access time: 0 = 3 CPU cycles, 1 = 1 CPU cycle.
</pre>
=== Mapper ($D) ===
----
{| class="wikitable"
|+ Known mapper types
|-
! ID !! Mapper
|-
| $00 || [[Bandai 2001]] or [[KARNAK]]
|-
| $01 || [[Bandai 2003]]
|}
5a3f0e7fc44ae69303307ce9bf26bd84df5a1de6
Bandai 2001
0
12
407
283
2024-12-11T18:21:33Z
Asie
351
Command -> Control, disambiguate
wikitext
text/x-wiki
The Bandai 2001 (LUXSOR) is one of the two mappers used in WonderSwan cartridges.
In addition to the normal [[Mapper]] banking interface, Bandai's 2001 adds three registers for interacting with a Microwire EEPROM:
{| class="wikitable"
! Category
! Port
! Description
! Bits
! Type
! Notes
|-
! rowspan="4" | External EEPROM
! $C4
| External EEPROM Data
| style="text-align: right" | <tt style="white-space: nowrap">dddd dddd dddd dddd</tt>
| RW16
| Data (d)
|-
! $C6
| External EEPROM Command
| style="text-align: right" | <tt style="white-space: nowrap">0001 CCaa aaaa aaaa</tt><br/>or <tt style="white-space: nowrap">0000 01CC aaaa aaaa</tt><br/> or <tt style="white-space: nowrap">0000 0001 CCaa aaaa</tt>
| RW16
| Command and address
|-
! rowspan=2|$C8
| External EEPROM Control
| style="text-align: right" | <tt style="white-space: nowrap">ASWR ....</tt>
| W8
| Abort (A), Short (S), Write (W), Read (R)
|-
| External EEPROM Status
| style="text-align: right" | <tt style="white-space: nowrap">.... ..rd</tt>
| R8
| Ready (r), Done (d)
|-
|}
== EEPROM ==
The 2001's EEPROM interface is similar to the internal EEPROM interface, as documented on [[EEPROM#I/O_ports|the EEPROM page]]. Differences include:
* Instead of the internal EEPROM interface's P(rotect) bit, the A(bort) bit is provided. When the A bit is set, the transaction immediately stops.
* The EEPROM "done" bit is buggy and doesn't have useful information. It's set when a Read completes, but is only cleared when a Command or Write is started. (To be useful it would need to also be cleared when a Read is started).
(Upload logic analyzer traces here)
f5e14a33fb4d55ea5ad6ce489a39783f870ba2b7
EEPROM
0
35
408
341
2024-12-12T15:26:05Z
Asie
351
/* Commands */ ERAL/WRAL
wikitext
text/x-wiki
The WonderSwan utilizes M93LCx6-compatible EEPROMs:
* in the SoC:
** 1 Kbit internal EEPROM (M93LC46-compatible) on the WonderSwan,
** 16 Kbit internal EEPROM (M93LC86-compatible) on the WonderSwan Color,
* on cartridges:
** 1 Kbit cartridge EEPROM (M93LC46-compatible)
** 8 Kbit cartridge EEPROM (M93LC76-compatible)
** 16 Kbit cartridge EEPROM (M93LC86-compatible)
Additional variants exists which were not seen on any production cartridge:
* 256 bit EEPROM (M93LC06-compatible)
* 2 Kbit EEPROM (M93LC56-compatible)
* 4 Kbit EEPROM (M93LC66-compatible)
== Commands ==
=== READ - Read Word ===
The READ command takes an address of a word (address 0 => bytes 0, 1; address 1 => bytes 2, 3; ...) and returns the word at that address.
=== WRITE - Write Word ===
The WRITE command takes an address of a word (address 0 => bytes 0, 1; address 1 => bytes 2, 3; ...) and the word to write to it, then writes the word.
=== ERASE - Erase Word ===
The ERASE command takes an address of a word (address 0 => bytes 0, 1; address 1 => bytes 2, 3; ...) and erases the word at that address, setting it to 0xFFFF.
=== WDS - Write Disable ===
The WDS command prevents issued write and erase commands from having an effect on the EEPROM.
=== WRAL - Write All ===
The WRAL command erases the word at all address of the EEPROM, setting them to 0xFFFF.
This command is not guaranteed to be present on all EEPROMs.
=== ERAL - Erase All ===
The WRAL command takes a word and writes it to all addresses of the EEPROM.
This command is not guaranteed to be present on all EEPROMs.
=== WEN - Write Enable ===
The WEN command restores the effect of issued write and erase commands on the EEPROM disabled using WDS.
== I/O ports ==
The I/O ports listed refer to the internal EEPROM; for the cartridge EEPROM port numbers, refer to the [[Bandai 2001|mapper documentation]].
It is recommended to only access the data and command ports with aligned word reads/writes; see the ''Errata'' section for more information.
{{Anchor|Internal EEPROM Data}}
=== Internal EEPROM Data ($BA, $BB read) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
dddd dddd dddd dddd
|||| |||| |||| ||||
++++-++++--++++-++++- Data read from the EEPROM.
</pre>
The read buffer's value changes only once the Read command is completed.
=== Internal EEPROM Data ($BA, $BB write) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
dddd dddd dddd dddd
|||| |||| |||| ||||
++++-++++--++++-++++- Data to write to the EEPROM.
</pre>
The write buffer is latched when a Write command is initiated; further writes to it do not affect the value written by that specific command.
The two EEPROM data buffers are not shared; neither writes to the write buffer nor the execution of non-read commands affect the contents of the read buffer.
{{Anchor|Internal EEPROM Command}}
=== Internal EEPROM Command ($BC, $BD) ===
<pre>
Command Pattern 1
15 bit 8 7 bit 0
---- ---- ---- ----
0000 0001 ooaa aaaa (¼, 1 Kbit - M93LC06/46)
0000 01oo aaaa aaaa (2, 4 Kbit - M93LC56/66)
0001 ooaa aaaa aaaa (8, 16 Kbit - M93LC76/86)
|||| |||| ||||
||++--++++-++++- Address (MSb .. LSb)
++-------------- Opcode:
01 - WRITE
10 - READ
11 - ERASE
</pre>
<pre>
Command Pattern 2
15 bit 8 7 bit 0
---- ---- ---- ----
0000 0001 00ss .... (¼, 1 Kbit - M93LC06/46)
0000 0100 ss.. .... (2, 4 Kbit - M93LC56/66)
0001 00ss .... .... (8, 16 Kbit - M93LC76/86)
||||
||++------------ Sub-Opcode:
|| 00 - WDS
|| 01 - WRAL
|| 10 - ERAL
|| 11 - WEN
++-------------- Opcode:
00
</pre>
The value written to this port can be read back; it is not affected by ''EEPROM Control''.
{{Anchor|Internal EEPROM Control}}
=== Internal EEPROM Control ($BE, $BF write) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
.... .... PSWR ....
||||
|||+------ Read operation: 1 for READ command, 0 otherwise
||+------- Write operation: 1 for WRITE and WRAL command, 0 otherwise
|+-------- Short operation: 1 for ERASE, WDS, ERAL and WEN command, 0 otherwise
+--------- Protection: 1 to enable internal EEPROM write protection.
Cannot be cleared once set.
</pre>
* Read operation: Sends 16 bits from Command, then reads 16 bits to Data.
* Write operation: Sends 16 bits from Command, then 16 bits from Data. De-asserts Microwire chip select, then re-asserts it and waits for the EEPROM to confirm command completion.
* Short operation: Sends 16 bits from Command, de-asserts Microwire chip select.
* Protection: Enables internal EEPROM write protection (addresses >= 0x30, or anything after the first 96 bytes, can no longer be written to).
If more than one of the Read, Write, Short, Protect bits are set, the operation is treated as invalid (all four operation bits are cleared and no communication is done with the EEPROM). Notably, this means that writing, for example, 0x90 does not protect the internal EEPROM if it wasn't already protected, but writing 0x80 does.
The command requested here should match the command sent to the EEPROM in port ''$BC''.
{{Anchor|Internal EEPROM Status}}
=== Internal EEPROM Status ($BE, $BF read) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
.... .... P... ..rd
| ||
| |+- 0 after a Read command is initiated,
| | 1 once a Read command is completed.
| | Unaffected by Write/Erase commands.
| +-- 0 if the EEPROM is busy,
| 1 if a command can be accepted (idle).
+--------- Internal EEPROM write protection:
0 = disabled, 1 = enabled
</pre>
== Internal EEPROM Layout ==
{| class="wikitable"
|-
! Offset !! Length !! Contents
|-
| $00 || 96 || Program data. Can be written by programs even if write protection has been enabled.
|-
| $60 || 16 || Owner name, custom character set.
|-
| $70 || 1 || Owner birthday year, BCD, first/higher two digits
|-
| $71 || 1 || Owner birthday year, BCD, last/lower two digits
|-
| $72 || 1 || Owner birthday month, BCD
|-
| $73 || 1 || Owner birthday day, BCD
|-
| $74 || 1 || Owner gender:<br/>
0 - ?<br/>
1 - Male<br/>
2 - Female
|-
| $75 || 1 || Owner blood type:<br/>
0 - ?<br/>
1 - A<br/>
2 - B<br/>
3 - 0<br/>
4 - AB
|-
| $76 || 1 || Last booted [[ROM header]] byte 6 (developer/publisher ID)
|-
| $77 || 1 || Last booted [[ROM header]] byte 7 (color)
|-
| $78 || 1 || Last booted [[ROM header]] byte 8 (game ID)
|-
| $7C || 1 || Stored cartridge ID/version change counter
|-
| $7D || 1 || Owner name change counter
|-
| $7E || 2 || System startup counter
|-
| $80 || 1 || Last booted [[ROM header]] byte 6 (developer/publisher ID) - only changed if byte 7 (color) != 0
|-
| $81 || 1 || Last booted [[ROM header]] byte 7 (color) - only changed if byte 7 (color) != 0
|-
| $82 || 1 || Last booted [[ROM header]] byte 8 (game ID) - only changed if byte 7 (color) != 0
|-
| $83 || 1 || Color console configuration
|-
| $84 || ? || [[Splash animation|Custom splash animation]], if present
|}
=== Owner name character set ===
{| class="wikitable"
|-
!
! <code>.0</code>
! <code>.1</code>
! <code>.2</code>
! <code>.3</code>
! <code>.4</code>
! <code>.5</code>
! <code>.6</code>
! <code>.7</code>
! <code>.8</code>
! <code>.9</code>
! <code>.A</code>
! <code>.B</code>
! <code>.C</code>
! <code>.D</code>
! <code>.E</code>
! <code>.F</code>
|-
! <code>0.</code>
| || 0 || 1 || 2 || 3 || 4 || 5 || 6 || 7 || 8 || 9 || A || B || C || D || E
|-
! <code>1.</code>
| F || G || H || I || J || K || L || M || N || O || P || Q || R || S || T || U
|-
! <code>2.</code>
| V || W || X || Y || Z || ♥ || ♪ || + || - || ? || .
!
!
!
!
!
|}
=== Color console configuration ===
<pre>
7 bit 0
---- ----
sc.. ..vv
|| ||
|| ++- Volume level
|+-------- Contrast (WSC): 0 = Low, 1 = High
+--------- Custom splash animation enabled
</pre>
== Hardware notes ==
EEPROM command bits are shifted out starting from the ''most'' significant bit of the port.
<pre>
+----> EEPROM Serial Data
|
[0] <= [0000 0001 ooaa aaaa]
EEPROM Command Port
</pre>
While the M93LCx6 family supports byte organization, the WonderSwan always uses word organization. As such, this implementation detail is omitted in this documentation.
The SPHINX SoC family emulates a 93C46 in ASWAN compatibility mode by manipulating the shifted out command value when sending it to the EEPROM (TODO: How exactly?).
== Errata ==
=== Non-word access on ASWAN ===
On the ASWAN SoC, accessing the internal EEPROM command ports as bytes only works correctly for even addresses. For odd addresses, these accesses return open bus; this means that unaligned word accesses also don't work, as they are converted to one odd and one even byte access internally.
It is recommended to only use aligned word port accesses to talk to the internal EEPROM.
This issue is not present on the SPHINX and newer SoCs, including in "mono" emulation mode, as well as the cartridge bus (which is always forced to be accessed per byte).
== Links ==
* [https://www.st.com/resource/en/datasheet/m93c46-w.pdf STMicroelectronics M93LCx6 datasheet]
60f284030b96c4d35ac57887e0a471f6e3eeda24
Real-Time Clock
0
40
409
177
2024-12-13T15:14:30Z
Asie
351
clarify register layout
wikitext
text/x-wiki
The [[Bandai 2003|2003]] mapper provides a special-purpose interface to interact with Seiko's S-3511A RTC chip.
This page will cover how games expect to interact with it; not the low-level protocol specifics. (For that see the datasheet and the Timing section of this wiki)
== Registers ==
=== Configuration ===
7 bit 0
---- ----
p2a0 m0f0
||| | |
||+--+-+-- Interrupt mode; see below
|+-------- 12/24 hour mode
| - 0: 12 hour mode
| - 1: 24 hour mode
+--------- Power failure occurred
Note that sending the Reset or Read Configuration commands clears the "power failure" bit.
==== Interrupt mode ====
{| class="wikitable"
! A
! M
! F
! Name
! Description
|-
| 0
| 0
| 0
| Disabled
| Continuously deasserts /IRQ pin.
|-
| 1
| 0
| 0
| Alarm
| Asserts /IRQ during the hour and minute set in the alarm configuration register.
|-
| rowspan="3" | x
| 0
| 1
| Frequency
| Subsecond prescaler is bitwise inverted, bitwise ANDed with the lower 15 bits of the "alarm configuration" register, then all fifteen bits are NORed together. This signal directly drives the /IRQ pin.
|-
| 1
| 0
| Per-minute edge
| Asserts /IRQ during the first 10 ms of each minute. During the following 990 ms, /IRQ can be deasserted by reading the configuration register.
|-
| 1
| 1
| Per-minute steady
| Asserts /IRQ during the first 10 ms of each minute. De-asserts /IRQ at the 30th second.
|}
=== Date/Time ===
The date and time is stored using seven bytes, of which the latter three correspond to the time.
==== Date ====
7 bit 0
---- ---- Byte 0
yyyy yyyy
|||| ||||
++++-++++- Year (00 - 99, BCD)
7 bit 0
---- ---- Byte 1
...m mmmm
| ||||
+-++++- Month (01 - 12, BCD)
7 bit 0
---- ---- Byte 2
..dd dddd
|| ||||
++-++++- Day of month (01 - 31, BCD)
7 bit 0
---- ---- Byte 3
.... .www
|||
+++- Day of week (0 - 6)
While this convention does not have to be followed, [[WonderWitch/FreyaBIOS|FreyaBIOS]] assumes that the first day of the week (0) is a Sunday, (1) is a Monday, ... (6) is a Saturday.
==== Time ====
7 bit 0
---- ---- Byte 4
p.hh hhhh
| || ||||
| ++-++++- Hour (00 - 11 or 23, BCD)
+--------- 0 = AM, 1 = PM
In the 24-hour mode, reading the AM/PM bit returns correct values (set if hour >= 12); however, writes to the bit are ignored.
7 bit 0
---- ---- Byte 5
.mmm mmmm
||| ||||
+++-++++- Minute (00 - 59, BCD)
7 bit 0
---- ---- Byte 6
.sss ssss
||| ||||
+++-++++- Second (00 - 59, BCD)
=== Alarm configuration ===
The alarm configuration register is two bytes in size; its interpretation depends on the configured interrupt mode.
==== Interrupt mode: Alarm ====
7 bit 0
---- ----
p.hh hhhh
| || ||||
| ++-++++- Hour to match for the alarm (BCD)
+--------- AM/PM bit to match for the alarm
7 bit 0
---- ----
.mmm mmmm
||| ||||
+++-++++- Minute to match for the alarm (BCD)
Note that the hour encoding of the alarm must match the hour encoding used by the clock itself.
==== Interrupt mode: Frequency ====
7 bit 0
---- ----
abcd efgh
|||| ||||
|||| |||+- 32768 Hz
|||| ||+-- 16384 Hz
|||| |+--- 8192 Hz
|||| +---- 4096 Hz
|||+------ 2048 Hz
||+------- 1024 Hz
|+-------- 512 Hz
+--------- 256 Hz
7 bit 0
---- ----
abcd efgh
|||| ||||
|||| |||+- 128 Hz
|||| ||+-- 64 Hz
|||| |+--- 32 Hz
|||| +---- 16 Hz
|||+------ 8 Hz
||+------- 4 Hz
|+-------- 2 Hz
+--------- 1 Hz
== Commands ==
=== Reset RTC ($10, $11) ===
Writing $10 or $11 to port $CA will send the "reset" command to the RTC. The S-3511A will then reset the year, month, day-of-month, day-of-week, hour, minute, second, config, and alarm registers. It is unknown if it resets the sub-second prescaler.
=== Write Configuration ($12) ===
Writing $12 to port $CA will send the "set configuration" command to the RTC. The 2003 expects that $CB contains valid contents by the time the 2003 sends that register's contents.
=== Read Configuration ($13) ===
Writing $13 to port $CA will send the "get configuration" command to the RTC.
=== Write current YMDdHMS ($14) ===
Writing $14 will set the current Year, Month, Day-of-Month, Day-of-Week, Hour, Minute, and Second.
=== Read current YMDdHMS ($15) ===
Writing $15 will get the current Year, Month, Day-of-Month, Day-of-Week, Hour, Minute, and Second.
=== Write current HMS ($16) ===
Writing $16 will set the current Hour, Minute, and Second.
These are the same as command $14.
=== Read current HMS ($17) ===
Writing $17 will get the current Hour, Minute, and Second.
=== Write alarm configuration ($18) ===
Writing $18 will set the current alarm configuration. The interpretation of these two bytes depend on the Configuration register
=== Nonsense alarm configuration ($19) ===
Writing $19 will set the current alarm configuration to $FFFF. The 2003 thinks it's reading from the S-3511A, but the S-3511A disagrees.
$FFFF will be read back by the 2003.
=== Write nonsense ($1A) ===
Writing $1A expects to send 2 bytes to the RTC. The S-3511A ignores them.
=== Read nonsense ($1B) ===
Writing $1B expects to read 2 bytes from the RTC. The S-3511A leaves its output high, returning $FFFF.
== Interrupts ==
The 2003 and S-3511A do not provide a thread-safe way to acknowledge the IRQ. Since the 2003 only holds one byte at a time, an interrupt can be fired in the middle of a multi-byte read or write without knowing what needs to be done for the rest of the command, nor how to safely restart that command when exiting the interrupt.
As such, the only choices are:
* all communication to the 2003 happens while cartridge IRQs are disabled, or
* the only thing the interrupt handler can do is [[Interrupts#Interrupt_Enable|mask]] the interrupt and then [[Interrupts#Interrupt_Acknowledge|acknowledge]] it, and only afterwards handle any subsequent communication.
2de1c770ad7e9153610e1c0751ed0cb9efbd3e90
410
409
2024-12-13T15:17:46Z
Asie
351
/* Alarm configuration */
wikitext
text/x-wiki
The [[Bandai 2003|2003]] mapper provides a special-purpose interface to interact with Seiko's S-3511A RTC chip.
This page will cover how games expect to interact with it; not the low-level protocol specifics. (For that see the datasheet and the Timing section of this wiki)
== Registers ==
=== Configuration ===
7 bit 0
---- ----
p2a0 m0f0
||| | |
||+--+-+-- Interrupt mode; see below
|+-------- 12/24 hour mode
| - 0: 12 hour mode
| - 1: 24 hour mode
+--------- Power failure occurred
Note that sending the Reset or Read Configuration commands clears the "power failure" bit.
==== Interrupt mode ====
{| class="wikitable"
! A
! M
! F
! Name
! Description
|-
| 0
| 0
| 0
| Disabled
| Continuously deasserts /IRQ pin.
|-
| 1
| 0
| 0
| Alarm
| Asserts /IRQ during the hour and minute set in the alarm configuration register.
|-
| rowspan="3" | x
| 0
| 1
| Frequency
| Subsecond prescaler is bitwise inverted, bitwise ANDed with the lower 15 bits of the "alarm configuration" register, then all fifteen bits are NORed together. This signal directly drives the /IRQ pin.
|-
| 1
| 0
| Per-minute edge
| Asserts /IRQ during the first 10 ms of each minute. During the following 990 ms, /IRQ can be deasserted by reading the configuration register.
|-
| 1
| 1
| Per-minute steady
| Asserts /IRQ during the first 10 ms of each minute. De-asserts /IRQ at the 30th second.
|}
=== Date/Time ===
The date and time is stored using seven bytes, of which the latter three correspond to the time.
==== Date ====
7 bit 0
---- ---- Byte 0
yyyy yyyy
|||| ||||
++++-++++- Year (00 - 99, BCD)
7 bit 0
---- ---- Byte 1
...m mmmm
| ||||
+-++++- Month (01 - 12, BCD)
7 bit 0
---- ---- Byte 2
..dd dddd
|| ||||
++-++++- Day of month (01 - 31, BCD)
7 bit 0
---- ---- Byte 3
.... .www
|||
+++- Day of week (0 - 6)
While this convention does not have to be followed, [[WonderWitch/FreyaBIOS|FreyaBIOS]] assumes that the first day of the week (0) is a Sunday, (1) is a Monday, ... (6) is a Saturday.
==== Time ====
7 bit 0
---- ---- Byte 4
p.hh hhhh
| || ||||
| ++-++++- Hour (00 - 11 or 23, BCD)
+--------- 0 = AM, 1 = PM
In the 24-hour mode, reading the AM/PM bit returns correct values (set if hour >= 12); however, writes to the bit are ignored.
7 bit 0
---- ---- Byte 5
.mmm mmmm
||| ||||
+++-++++- Minute (00 - 59, BCD)
7 bit 0
---- ---- Byte 6
.sss ssss
||| ||||
+++-++++- Second (00 - 59, BCD)
=== Alarm configuration ===
The alarm configuration register is two bytes in size; its interpretation depends on the configured interrupt mode.
==== Interrupt mode: Alarm ====
7 bit 0
---- ---- Byte 0
p.hh hhhh
| || ||||
| ++-++++- Hour to match for the alarm (BCD)
+--------- AM/PM bit to match for the alarm
7 bit 0
---- ---- Byte 1
.mmm mmmm
||| ||||
+++-++++- Minute to match for the alarm (BCD)
Note that the hour encoding of the alarm must match the hour encoding used by the clock itself.
==== Interrupt mode: Frequency ====
7 bit 0
---- ---- Byte 0
abcd efgh
|||| ||||
|||| |||+- 32768 Hz
|||| ||+-- 16384 Hz
|||| |+--- 8192 Hz
|||| +---- 4096 Hz
|||+------ 2048 Hz
||+------- 1024 Hz
|+-------- 512 Hz
+--------- 256 Hz
7 bit 0
---- ---- Byte 1
abcd efgh
|||| ||||
|||| |||+- 128 Hz
|||| ||+-- 64 Hz
|||| |+--- 32 Hz
|||| +---- 16 Hz
|||+------ 8 Hz
||+------- 4 Hz
|+-------- 2 Hz
+--------- 1 Hz
== Commands ==
=== Reset RTC ($10, $11) ===
Writing $10 or $11 to port $CA will send the "reset" command to the RTC. The S-3511A will then reset the year, month, day-of-month, day-of-week, hour, minute, second, config, and alarm registers. It is unknown if it resets the sub-second prescaler.
=== Write Configuration ($12) ===
Writing $12 to port $CA will send the "set configuration" command to the RTC. The 2003 expects that $CB contains valid contents by the time the 2003 sends that register's contents.
=== Read Configuration ($13) ===
Writing $13 to port $CA will send the "get configuration" command to the RTC.
=== Write current YMDdHMS ($14) ===
Writing $14 will set the current Year, Month, Day-of-Month, Day-of-Week, Hour, Minute, and Second.
=== Read current YMDdHMS ($15) ===
Writing $15 will get the current Year, Month, Day-of-Month, Day-of-Week, Hour, Minute, and Second.
=== Write current HMS ($16) ===
Writing $16 will set the current Hour, Minute, and Second.
These are the same as command $14.
=== Read current HMS ($17) ===
Writing $17 will get the current Hour, Minute, and Second.
=== Write alarm configuration ($18) ===
Writing $18 will set the current alarm configuration. The interpretation of these two bytes depend on the Configuration register
=== Nonsense alarm configuration ($19) ===
Writing $19 will set the current alarm configuration to $FFFF. The 2003 thinks it's reading from the S-3511A, but the S-3511A disagrees.
$FFFF will be read back by the 2003.
=== Write nonsense ($1A) ===
Writing $1A expects to send 2 bytes to the RTC. The S-3511A ignores them.
=== Read nonsense ($1B) ===
Writing $1B expects to read 2 bytes from the RTC. The S-3511A leaves its output high, returning $FFFF.
== Interrupts ==
The 2003 and S-3511A do not provide a thread-safe way to acknowledge the IRQ. Since the 2003 only holds one byte at a time, an interrupt can be fired in the middle of a multi-byte read or write without knowing what needs to be done for the rest of the command, nor how to safely restart that command when exiting the interrupt.
As such, the only choices are:
* all communication to the 2003 happens while cartridge IRQs are disabled, or
* the only thing the interrupt handler can do is [[Interrupts#Interrupt_Enable|mask]] the interrupt and then [[Interrupts#Interrupt_Acknowledge|acknowledge]] it, and only afterwards handle any subsequent communication.
4a6e5162754a9d230c62a337d7a6c4ec0821ef9b
WonderWitch/FreyaBIOS/Timer
0
62
411
375
2024-12-13T15:19:34Z
Asie
351
wikitext
text/x-wiki
The Timer interrupt provides an abstraction layer for the WonderSwan's [[Timers|timers]], as well as the on-cartridge [[Real-Time Clock|RTC]].
== Types ==
=== RTC fields ===
The RTC field indexes match the order of fields returned by the S-3511A chip. Note that the values returned by FreyaBIOS are binary numbers rather than BCD numbers - they are transparently converted when communicating with the on-cartridge RTC.
{| class="wikitable"
|-
! Index !! Data !! Format
|-
| 0 || Year || 0 - 99; 0 is assumed to be the year 2000.
|-
| 1 || Month || 1 - 12
|-
| 2 || Date (day of month) || 1 - 31
|-
| 3 || Day of week || 0 - 6; 0 = Sunday, 1 = Monday, ..., 6 = Saturday
|-
| 4 || Hour || 0 - 23
|-
| 5 || Minute || 0 - 59
|-
| 6 || Second || 0 - 59
|}
=== RTC struct ===
The RTC struct is a seven-byte memory structure, containing all RTC fields consecutively, taking up one unsinged byte each.
== Interrupts ==
=== INT $16/AH=$00 - rtc_reset ===
* AH = $00
=== INT $16/AH=$01 - rtc_set_datetime ===
* AH = $01
* BX = Field
* CX = Value of field
=== INT $16/AH=$02 - rtc_get_datetime ===
* AH = $02
* BX = Field
Return:
* AX = Value of field
=== INT $16/AH=$03 - rtc_set_datetime_struct ===
* AH = $03
* DS:DX = Pointer to RTC struct
=== INT $16/AH=$04 - rtc_get_datetime_struct ===
* AH = $04
* DS:DX = Pointer to RTC struct
=== INT $16/AH=$05 - rtc_enable_alarm ===
* AH = $05
* BL = Hour
* BH = Minute
=== INT $16/AH=$06 - rtc_disable_alarm ===
* AH = $06
=== INT $16/AH=$07 - timer_enable ===
* AH = $07
* AL = Type (0 = HBlank, 1 = VBlank)
* BL = Reload mode (0 = one-shot, 1 = repeating)
* CX = Time, in lines or frames, to wait.
=== INT $16/AH=$08 - timer_disable ===
* AH = $08
* AL = Type (0 = HBlank, 1 = VBlank)
=== INT $16/AH=$09 - timer_get_count ===
* AH = $09
* AL = Type (0 = HBlank, 1 = VBlank)
Return:
* AX = The current counter value, from the time set in <code>timer_enable</code> down.
38826513f6f38c92cfefc4054956e0970f14956e
432
411
2024-12-20T13:29:06Z
Asie
351
/* INT $16/AH=$00 - rtc_reset */
wikitext
text/x-wiki
The Timer interrupt provides an abstraction layer for the WonderSwan's [[Timers|timers]], as well as the on-cartridge [[Real-Time Clock|RTC]].
== Types ==
=== RTC fields ===
The RTC field indexes match the order of fields returned by the S-3511A chip. Note that the values returned by FreyaBIOS are binary numbers rather than BCD numbers - they are transparently converted when communicating with the on-cartridge RTC.
{| class="wikitable"
|-
! Index !! Data !! Format
|-
| 0 || Year || 0 - 99; 0 is assumed to be the year 2000.
|-
| 1 || Month || 1 - 12
|-
| 2 || Date (day of month) || 1 - 31
|-
| 3 || Day of week || 0 - 6; 0 = Sunday, 1 = Monday, ..., 6 = Saturday
|-
| 4 || Hour || 0 - 23
|-
| 5 || Minute || 0 - 59
|-
| 6 || Second || 0 - 59
|}
=== RTC struct ===
The RTC struct is a seven-byte memory structure, containing all RTC fields consecutively, taking up one unsinged byte each.
== Interrupts ==
=== INT $16/AH=$00 - rtc_reset ===
* AH = $00
Initializes the RTC status register (all interrupts disabled, 24-hour mode enabled).
=== INT $16/AH=$01 - rtc_set_datetime ===
* AH = $01
* BX = Field
* CX = Value of field
=== INT $16/AH=$02 - rtc_get_datetime ===
* AH = $02
* BX = Field
Return:
* AX = Value of field
=== INT $16/AH=$03 - rtc_set_datetime_struct ===
* AH = $03
* DS:DX = Pointer to RTC struct
=== INT $16/AH=$04 - rtc_get_datetime_struct ===
* AH = $04
* DS:DX = Pointer to RTC struct
=== INT $16/AH=$05 - rtc_enable_alarm ===
* AH = $05
* BL = Hour
* BH = Minute
=== INT $16/AH=$06 - rtc_disable_alarm ===
* AH = $06
=== INT $16/AH=$07 - timer_enable ===
* AH = $07
* AL = Type (0 = HBlank, 1 = VBlank)
* BL = Reload mode (0 = one-shot, 1 = repeating)
* CX = Time, in lines or frames, to wait.
=== INT $16/AH=$08 - timer_disable ===
* AH = $08
* AL = Type (0 = HBlank, 1 = VBlank)
=== INT $16/AH=$09 - timer_get_count ===
* AH = $09
* AL = Type (0 = HBlank, 1 = VBlank)
Return:
* AX = The current counter value, from the time set in <code>timer_enable</code> down.
da3adb44c44b18b2ce2d5876729486c779d7fbcd
WonderWitch/Memory map
0
65
412
386
2024-12-13T20:45:42Z
Asie
351
wikitext
text/x-wiki
The following documents the WonderWitch memory map. Note that you are not required to follow these rules to the letter; however, some amount of the beginning of memory is expected to be left to FreyaBIOS, FreyaOS, etc.
=== Internal RAM (0x00000 - 0x0FFFF) ===
{| class="wikitable"
|+ WonderWitch memory map
! Address
! ASCII, 1 screen
! ASCII, 2 screens
! Shift-JIS, 1 screen
! Shift-JIS, 2 screens
|-
| style="text-align: center;" | 0x0000
| colspan="4" style="text-align: center;" | Interrupt vectors
|-
| style="text-align: center;" | 0x0100
| colspan="4" style="text-align: center;" | Internal BIOS area
|-
| style="text-align: center;" | 0x0290
| rowspan="8" style="text-align: center;" | Stack, User IRAM
| rowspan="6" style="text-align: center;" | Stack, User IRAM
| rowspan="3" style="text-align: center;" | Stack, User IRAM
| style="text-align: center;" | Stack, User IRAM
|-
| style="text-align: center;" | 0x0E00
| style="text-align: center;" | Sprite table
|-
| style="text-align: center;" | 0x1000
| rowspan="2" style="text-align: center;" | Screen 1
|-
| style="text-align: center;" | 0x1600
| style="text-align: center;" | Sprite table
|-
| style="text-align: center;" | 0x1800
| style="text-align: center;" | Screen 1
| style="text-align: center;" | Screen 2
|-
| style="text-align: center;" | 0x2000
| rowspan="6" colspan="2" style="text-align: center;" | Tile data (512 tiles)
|-
| style="text-align: center;" | 0x2600
| style="text-align: center;" | Sprite table
|-
| style="text-align: center;" | 0x2800
| rowspan="2" style="text-align: center;" | Screen 2
|-
| style="text-align: center;" | 0x2E00
| style="text-align: center;" | Sprite table
|-
| style="text-align: center;" | 0x3000
| colspan="2" style="text-align: center;" | Screen 1
|-
| style="text-align: center;" | 0x3800
| colspan="2" style="text-align: center;" | Tile data (128 tiles)
|-
| style="text-align: center;" | 0x4000
| colspan="4" style="text-align: center;" | Color tile data; only restored with [[WonderWitch/IL/ResumeIL|ResumeIL]].
|-
| style="text-align: center;" | 0xC000
| colspan="4" style="text-align: center;" | Unused; never restored on program suspend/resume.
|-
| style="text-align: center;" | 0xFE00
| colspan="4" style="text-align: center;" | Color palette data; only restored with [[WonderWitch/IL/ResumeIL|ResumeIL]].
|}
In all modes, the stack is placed immediately before the sprite table.
==== Interrupt vectors ====
{| class="wikitable"
! Start
! End
! Description
|-
| 0x00
| 0x07
| CPU interrupts
|-
| 0x08
| 0x0F
|
|-
| 0x10
| 0x18
| [[WonderWitch/FreyaBIOS|FreyaBIOS]] interrupts
|}
=== Cartridge SRAM (0x10000 - 0x1FFFF) ===
{| class="wikitable"
! Bank
! Description
|-
| 0
| [[WonderWitch/Filesystem|/ram0 file data]]
|-
| 1
| Third process data
|-
| 2
| Second process data
|-
| 3
| First process data; typically used by [[WonderWitch/FreyaOS|FreyaOS]]
|}
=== Cartridge flash (0x80000 - 0xFFFFF) ===
The 512KB of NOR flash memory is mapped and partitioned as follows:
{| class="wikitable"
! Linear address
! Size
! Description
|-
| 0x8nnnn
| rowspan="6" | 384 KB
| rowspan="6" | [[WonderWitch/Filesystem|/rom0 file data]]
|-
| 0x9nnnn
|-
| 0xAnnnn
|-
| 0xBnnnn
|-
| 0xCnnnn
|-
| 0xDnnnn
|-
| 0xEnnnn
| 64 KB
| [[WonderWitch/FreyaOS|FreyaOS]]
|-
| 0xFnnnn
| 64 KB
| [[WonderWitch/FreyaBIOS|FreyaBIOS]]
|}
264ad8388151bd616edbccd3031616216c77b303
413
412
2024-12-13T20:46:49Z
Asie
351
/* Internal RAM (0x00000 - 0x0FFFF) */
wikitext
text/x-wiki
The following documents the WonderWitch memory map. Note that you are not required to follow these rules to the letter; however, some amount of the beginning of memory is expected to be left to FreyaBIOS, FreyaOS, etc.
=== Internal RAM (0x00000 - 0x0FFFF) ===
{| class="wikitable"
|+ WonderWitch memory map
! Address
! ASCII, 1 screen
! ASCII, 2 screens
! Shift-JIS, 1 screen
! Shift-JIS, 2 screens
|-
| style="text-align: center;" | 0x0000
| colspan="4" style="text-align: center;" | Interrupt vectors
|-
| style="text-align: center;" | 0x0100
| colspan="4" style="text-align: center;" | Internal BIOS area
|-
| style="text-align: center;" | 0x0290
| rowspan="8" style="text-align: center;" | Stack, user IRAM
| rowspan="6" style="text-align: center;" | Stack, user IRAM
| rowspan="3" style="text-align: center;" | Stack, user IRAM
| style="text-align: center;" | Stack, User IRAM
|-
| style="text-align: center;" | 0x0E00
| style="text-align: center;" | Sprite table
|-
| style="text-align: center;" | 0x1000
| rowspan="2" style="text-align: center;" | Screen 1
|-
| style="text-align: center;" | 0x1600
| style="text-align: center;" | Sprite table
|-
| style="text-align: center;" | 0x1800
| style="text-align: center;" | Screen 1
| style="text-align: center;" | Screen 2
|-
| style="text-align: center;" | 0x2000
| rowspan="6" colspan="2" style="text-align: center;" | Tile data (512 tiles)
|-
| style="text-align: center;" | 0x2600
| style="text-align: center;" | Sprite table
|-
| style="text-align: center;" | 0x2800
| rowspan="2" style="text-align: center;" | Screen 2
|-
| style="text-align: center;" | 0x2E00
| style="text-align: center;" | Sprite table
|-
| style="text-align: center;" | 0x3000
| colspan="2" style="text-align: center;" | Screen 1
|-
| style="text-align: center;" | 0x3800
| colspan="2" style="text-align: center;" | Tile data (128 tiles)
|-
| style="text-align: center;" | 0x4000
| colspan="4" style="text-align: center;" | Color tile data; only restored with [[WonderWitch/IL/ResumeIL|ResumeIL]].
|-
| style="text-align: center;" | 0xC000
| colspan="4" style="text-align: center;" | Unused; never restored on program suspend/resume.
|-
| style="text-align: center;" | 0xFE00
| colspan="4" style="text-align: center;" | Color palette data; only restored with [[WonderWitch/IL/ResumeIL|ResumeIL]].
|}
In all modes, the stack is placed immediately before the sprite table.
==== Interrupt vectors ====
{| class="wikitable"
! Start
! End
! Description
|-
| 0x00
| 0x07
| CPU interrupts
|-
| 0x08
| 0x0F
|
|-
| 0x10
| 0x18
| [[WonderWitch/FreyaBIOS|FreyaBIOS]] interrupts
|}
==== Internal BIOS area ====
{| class="wikitable"
! Start
! Length
! Description
|-
| 0x100
| 128
| Temporary memory buffer. Used for XMODEM transfers by FreyaOS.
|-
| 0x230
| 2
| Near pointer to temporary memory buffer (0x0100).
|}
=== Cartridge SRAM (0x10000 - 0x1FFFF) ===
{| class="wikitable"
! Bank
! Description
|-
| 0
| [[WonderWitch/Filesystem|/ram0 file data]]
|-
| 1
| Third process data
|-
| 2
| Second process data
|-
| 3
| First process data; typically used by [[WonderWitch/FreyaOS|FreyaOS]]
|}
=== Cartridge flash (0x80000 - 0xFFFFF) ===
The 512KB of NOR flash memory is mapped and partitioned as follows:
{| class="wikitable"
! Linear address
! Size
! Description
|-
| 0x8nnnn
| rowspan="6" | 384 KB
| rowspan="6" | [[WonderWitch/Filesystem|/rom0 file data]]
|-
| 0x9nnnn
|-
| 0xAnnnn
|-
| 0xBnnnn
|-
| 0xCnnnn
|-
| 0xDnnnn
|-
| 0xEnnnn
| 64 KB
| [[WonderWitch/FreyaOS|FreyaOS]]
|-
| 0xFnnnn
| 64 KB
| [[WonderWitch/FreyaBIOS|FreyaBIOS]]
|}
8795f1daf3c49da52baa170f58ecec1e40015fb5
414
413
2024-12-13T20:48:15Z
Asie
351
wikitext
text/x-wiki
The following documents the WonderWitch memory map. Note that you are not required to follow these rules to the letter; however, some amount of the beginning of memory is expected to be left to FreyaBIOS, FreyaOS, etc.
=== Internal RAM (0x00000 - 0x0FFFF) ===
{| class="wikitable"
|+ WonderWitch memory map
! Address
! ASCII, 1 screen
! ASCII, 2 screens
! Shift-JIS, 1 screen
! Shift-JIS, 2 screens
|-
| style="text-align: center;" | 0x0000
| colspan="4" style="text-align: center;" | Interrupt vectors
|-
| style="text-align: center;" | 0x0100
| colspan="4" style="text-align: center;" | Internal BIOS area
|-
| style="text-align: center;" | 0x0290
| rowspan="8" style="text-align: center;" | Stack, user IRAM
| rowspan="6" style="text-align: center;" | Stack, user IRAM
| rowspan="3" style="text-align: center;" | Stack, user IRAM
| style="text-align: center;" | Stack, User IRAM
|-
| style="text-align: center;" | 0x0E00
| style="text-align: center;" | Sprite table
|-
| style="text-align: center;" | 0x1000
| rowspan="2" style="text-align: center;" | Screen 1
|-
| style="text-align: center;" | 0x1600
| style="text-align: center;" | Sprite table
|-
| style="text-align: center;" | 0x1800
| style="text-align: center;" | Screen 1
| style="text-align: center;" | Screen 2
|-
| style="text-align: center;" | 0x2000
| rowspan="6" colspan="2" style="text-align: center;" | Tile data (512 tiles)
|-
| style="text-align: center;" | 0x2600
| style="text-align: center;" | Sprite table
|-
| style="text-align: center;" | 0x2800
| rowspan="2" style="text-align: center;" | Screen 2
|-
| style="text-align: center;" | 0x2E00
| style="text-align: center;" | Sprite table
|-
| style="text-align: center;" | 0x3000
| colspan="2" style="text-align: center;" | Screen 1
|-
| style="text-align: center;" | 0x3800
| colspan="2" style="text-align: center;" | Tile data (128 tiles)
|-
| style="text-align: center;" | 0x4000
| colspan="4" style="text-align: center;" | Color tile data; only restored with [[WonderWitch/IL/ResumeIL|ResumeIL]].
|-
| style="text-align: center;" | 0xC000
| colspan="4" style="text-align: center;" | Unused; never restored on program suspend/resume.
|-
| style="text-align: center;" | 0xFE00
| colspan="4" style="text-align: center;" | Color palette data; only restored with [[WonderWitch/IL/ResumeIL|ResumeIL]].
|}
In all modes, the stack is placed immediately before the sprite table.
==== Interrupt vectors ====
{| class="wikitable"
! Start
! End
! Description
|-
| 0x00
| 0x07
| CPU interrupts
|-
| 0x08
| 0x0F
|
|-
| 0x10
| 0x18
| [[WonderWitch/FreyaBIOS|FreyaBIOS]] interrupts
|}
==== Internal BIOS area ====
{| class="wikitable"
! Start
! Length
! Description
|-
| 0x100
| 128
| Temporary memory buffer. Used for XMODEM transfers by FreyaOS.
|-
| 0x180
| 64
| Wavetable memory location.
|-
| 0x230
| 2
| Near pointer to temporary memory buffer (0x0100).
|}
=== Cartridge SRAM (0x10000 - 0x1FFFF) ===
{| class="wikitable"
! Bank
! Description
|-
| 0
| [[WonderWitch/Filesystem|/ram0 file data]]
|-
| 1
| Third process data
|-
| 2
| Second process data
|-
| 3
| First process data; typically used by [[WonderWitch/FreyaOS|FreyaOS]]
|}
=== Cartridge flash (0x80000 - 0xFFFFF) ===
The 512KB of NOR flash memory is mapped and partitioned as follows:
{| class="wikitable"
! Linear address
! Size
! Description
|-
| 0x8nnnn
| rowspan="6" | 384 KB
| rowspan="6" | [[WonderWitch/Filesystem|/rom0 file data]]
|-
| 0x9nnnn
|-
| 0xAnnnn
|-
| 0xBnnnn
|-
| 0xCnnnn
|-
| 0xDnnnn
|-
| 0xEnnnn
| 64 KB
| [[WonderWitch/FreyaOS|FreyaOS]]
|-
| 0xFnnnn
| 64 KB
| [[WonderWitch/FreyaBIOS|FreyaBIOS]]
|}
c8f8fec7ca7cd8e501b3877c69e38597a73d9004
415
414
2024-12-13T21:05:00Z
Asie
351
/* Internal RAM (0x00000 - 0x0FFFF) */
wikitext
text/x-wiki
The following documents the WonderWitch memory map. Note that you are not required to follow these rules to the letter; however, some amount of the beginning of memory is expected to be left to FreyaBIOS, FreyaOS, etc.
=== Internal RAM (0x00000 - 0x0FFFF) ===
{| class="wikitable"
|+ WonderWitch memory map
! Address
! ASCII, 1 screen
! ASCII, 2 screens
! Shift-JIS, 1 screen
! Shift-JIS, 2 screens
|-
| style="text-align: center;" | 0x0000
| colspan="4" style="text-align: center;" | Interrupt vectors
|-
| style="text-align: center;" | 0x0100
| colspan="4" style="text-align: center;" | Internal BIOS area
|-
| style="text-align: center;" | 0x0290
| rowspan="8" style="text-align: center;" | Stack, user IRAM
| rowspan="6" style="text-align: center;" | Stack, user IRAM
| rowspan="3" style="text-align: center;" | Stack, user IRAM
| style="text-align: center;" | Stack, User IRAM
|-
| style="text-align: center;" | 0x0E00
| style="text-align: center;" | Sprite table
|-
| style="text-align: center;" | 0x1000
| rowspan="2" style="text-align: center;" | Screen 1
|-
| style="text-align: center;" | 0x1600
| style="text-align: center;" | Sprite table
|-
| style="text-align: center;" | 0x1800
| style="text-align: center;" | Screen 1
| style="text-align: center;" | Screen 2
|-
| style="text-align: center;" | 0x2000
| rowspan="6" colspan="2" style="text-align: center;" | Tile data (512 tiles)
|-
| style="text-align: center;" | 0x2600
| style="text-align: center;" | Sprite table
|-
| style="text-align: center;" | 0x2800
| rowspan="2" style="text-align: center;" | Screen 2
|-
| style="text-align: center;" | 0x2E00
| style="text-align: center;" | Sprite table
|-
| style="text-align: center;" | 0x3000
| colspan="2" style="text-align: center;" | Screen 1
|-
| style="text-align: center;" | 0x3800
| colspan="2" style="text-align: center;" | Tile data (128 tiles)
|-
| style="text-align: center;" | 0x4000
| colspan="4" style="text-align: center;" | Color tile data; only restored with [[WonderWitch/IL/ResumeIL|ResumeIL]].
|-
| style="text-align: center;" | 0xC000
| colspan="4" style="text-align: center;" | Unused; never restored on program suspend/resume.
|-
| style="text-align: center;" | 0xFE00
| colspan="4" style="text-align: center;" | Color palette data; only restored with [[WonderWitch/IL/ResumeIL|ResumeIL]].
|}
In all modes, the stack is placed immediately before the sprite table.
Note that the user IRAM area is shared between all users of FreyaBIOS - notably, FreyaOS puts
==== Interrupt vectors ====
{| class="wikitable"
! Start
! End
! Description
|-
| 0x00
| 0x07
| CPU interrupts
|-
| 0x08
| 0x0F
|
|-
| 0x10
| 0x18
| [[WonderWitch/FreyaBIOS|FreyaBIOS]] interrupts
|}
==== Internal BIOS area ====
{| class="wikitable"
! Start
! Length
! Description
|-
| 0x100
| 128
| Temporary memory buffer. Used for XMODEM transfers by FreyaOS.
|-
| 0x180
| 64
| Wavetable memory location.
|-
| 0x204
| 2/4?
| Written to by FreyaOS using ''sys_alloc_iram'' to point to its IRAM area.
|-
| 0x230
| 2
| Near pointer to temporary memory buffer (0x0100).
|}
=== Cartridge SRAM (0x10000 - 0x1FFFF) ===
{| class="wikitable"
! Bank
! Description
|-
| 0
| [[WonderWitch/Filesystem|/ram0 file data]]
|-
| 1
| Third process data
|-
| 2
| Second process data
|-
| 3
| First process data; typically used by [[WonderWitch/FreyaOS|FreyaOS]]
|}
=== Cartridge flash (0x80000 - 0xFFFFF) ===
The 512KB of NOR flash memory is mapped and partitioned as follows:
{| class="wikitable"
! Linear address
! Size
! Description
|-
| 0x8nnnn
| rowspan="6" | 384 KB
| rowspan="6" | [[WonderWitch/Filesystem|/rom0 file data]]
|-
| 0x9nnnn
|-
| 0xAnnnn
|-
| 0xBnnnn
|-
| 0xCnnnn
|-
| 0xDnnnn
|-
| 0xEnnnn
| 64 KB
| [[WonderWitch/FreyaOS|FreyaOS]]
|-
| 0xFnnnn
| 64 KB
| [[WonderWitch/FreyaBIOS|FreyaBIOS]]
|}
8f3627615b1d16a795a728d87f7892e5b3ff29a7
427
415
2024-12-16T15:29:39Z
Asie
351
/* Interrupt vectors */ document SoC interrupts
wikitext
text/x-wiki
The following documents the WonderWitch memory map. Note that you are not required to follow these rules to the letter; however, some amount of the beginning of memory is expected to be left to FreyaBIOS, FreyaOS, etc.
=== Internal RAM (0x00000 - 0x0FFFF) ===
{| class="wikitable"
|+ WonderWitch memory map
! Address
! ASCII, 1 screen
! ASCII, 2 screens
! Shift-JIS, 1 screen
! Shift-JIS, 2 screens
|-
| style="text-align: center;" | 0x0000
| colspan="4" style="text-align: center;" | Interrupt vectors
|-
| style="text-align: center;" | 0x0100
| colspan="4" style="text-align: center;" | Internal BIOS area
|-
| style="text-align: center;" | 0x0290
| rowspan="8" style="text-align: center;" | Stack, user IRAM
| rowspan="6" style="text-align: center;" | Stack, user IRAM
| rowspan="3" style="text-align: center;" | Stack, user IRAM
| style="text-align: center;" | Stack, User IRAM
|-
| style="text-align: center;" | 0x0E00
| style="text-align: center;" | Sprite table
|-
| style="text-align: center;" | 0x1000
| rowspan="2" style="text-align: center;" | Screen 1
|-
| style="text-align: center;" | 0x1600
| style="text-align: center;" | Sprite table
|-
| style="text-align: center;" | 0x1800
| style="text-align: center;" | Screen 1
| style="text-align: center;" | Screen 2
|-
| style="text-align: center;" | 0x2000
| rowspan="6" colspan="2" style="text-align: center;" | Tile data (512 tiles)
|-
| style="text-align: center;" | 0x2600
| style="text-align: center;" | Sprite table
|-
| style="text-align: center;" | 0x2800
| rowspan="2" style="text-align: center;" | Screen 2
|-
| style="text-align: center;" | 0x2E00
| style="text-align: center;" | Sprite table
|-
| style="text-align: center;" | 0x3000
| colspan="2" style="text-align: center;" | Screen 1
|-
| style="text-align: center;" | 0x3800
| colspan="2" style="text-align: center;" | Tile data (128 tiles)
|-
| style="text-align: center;" | 0x4000
| colspan="4" style="text-align: center;" | Color tile data; only restored with [[WonderWitch/IL/ResumeIL|ResumeIL]].
|-
| style="text-align: center;" | 0xC000
| colspan="4" style="text-align: center;" | Unused; never restored on program suspend/resume.
|-
| style="text-align: center;" | 0xFE00
| colspan="4" style="text-align: center;" | Color palette data; only restored with [[WonderWitch/IL/ResumeIL|ResumeIL]].
|}
In all modes, the stack is placed immediately before the sprite table.
Note that the user IRAM area is shared between all users of FreyaBIOS - notably, FreyaOS puts
==== Interrupt vectors ====
{| class="wikitable"
! Start
! End
! Description
|-
| 0x00
| 0x07
| CPU interrupts
|-
| 0x08
| 0x0F
|
|-
| 0x10
| 0x18
| [[WonderWitch/FreyaBIOS|FreyaBIOS]] interrupts
|-
| 0x19
| 0x27
|
|-
| 0x28
| 0x2F
| SoC interrupts
|}
==== Internal BIOS area ====
{| class="wikitable"
! Start
! Length
! Description
|-
| 0x100
| 128
| Temporary memory buffer. Used for XMODEM transfers by FreyaOS.
|-
| 0x180
| 64
| Wavetable memory location.
|-
| 0x204
| 2/4?
| Written to by FreyaOS using ''sys_alloc_iram'' to point to its IRAM area.
|-
| 0x230
| 2
| Near pointer to temporary memory buffer (0x0100).
|}
=== Cartridge SRAM (0x10000 - 0x1FFFF) ===
{| class="wikitable"
! Bank
! Description
|-
| 0
| [[WonderWitch/Filesystem|/ram0 file data]]
|-
| 1
| Third process data
|-
| 2
| Second process data
|-
| 3
| First process data; typically used by [[WonderWitch/FreyaOS|FreyaOS]]
|}
=== Cartridge flash (0x80000 - 0xFFFFF) ===
The 512KB of NOR flash memory is mapped and partitioned as follows:
{| class="wikitable"
! Linear address
! Size
! Description
|-
| 0x8nnnn
| rowspan="6" | 384 KB
| rowspan="6" | [[WonderWitch/Filesystem|/rom0 file data]]
|-
| 0x9nnnn
|-
| 0xAnnnn
|-
| 0xBnnnn
|-
| 0xCnnnn
|-
| 0xDnnnn
|-
| 0xEnnnn
| 64 KB
| [[WonderWitch/FreyaOS|FreyaOS]]
|-
| 0xFnnnn
| 64 KB
| [[WonderWitch/FreyaBIOS|FreyaBIOS]]
|}
6945e1835188234a04d4b6019249c68571d2ff53
WonderWitch/FreyaBIOS/Communication
0
54
416
326
2024-12-14T10:36:13Z
Asie
351
/* INT $14/AH=$0D - comm_xmodem */
wikitext
text/x-wiki
The Communication (comm) interrupt provides an abstraction layer and helpers for the WonderSwan's [[UART|serial port]].
== Interrupts ==
=== INT $14/AH=$00 - comm_open ===
* AH = $00
Opens the serial port. Note that the baud rate must be set before calling <code>comm_open</code>.
=== INT $14/AH=$01 - comm_close ===
* AH = $01
Closes the serial port.
=== INT $14/AH=$02 - comm_send_char ===
* AH = $02
* BL = Character (byte) to send.
Return:
* AX = Return code.
Return codes:
* 0x0000 - Success
* 0x8101 - Transfer timeout
* 0x8102 - Transfer RX overrun
* 0x8103 - Transfer cancelled
=== INT $14/AH=$03 - comm_receive_char ===
* AH = $03
Return:
* AX = Character (byte) read (0x0000 - 0xFFFF) or error return code.
=== INT $14/AH=$04 - comm_receive_with_timeout ===
* AH = $03
* CX = Timeout, in frames (as in <code>comm_set_timeout</code>).
Return:
* AX = Character (byte) read (0x0000 - 0xFFFF) or error return code.
Unlike <code>comm_receive_char</code>, this function uses an user-provided timeout.
=== INT $14/AH=$05 - comm_send_string ===
* AH = $05
* DS:DX = Input string to send.
Return:
* AX = Return code.
=== INT $14/AH=$06 - comm_send_block ===
* AH = $06
* CX = Buffer size, in bytes.
* DS:DX = Input buffer to send.
Return:
* AX = Return code.
=== INT $14/AH=$07 - comm_receive_block ===
* AH = $07
* CX = Buffer size, in bytes.
* DS:DX = Buffer to receive bytes to.
Return:
* AX = Return code.
* DX = Number of bytes successfully received.
=== INT $14/AH=$08 - comm_set_timeout ===
* AH = $08
* BX = Receive timeout (in frames; 0xFFFF - wait forever)
* CX = Send timeout (in frames; 0xFFFF - wait forever)
=== INT $14/AH=$09 - comm_set_baudrate ===
* AH = $09
* BX = Baud rate (0 = 9600 bps, 1 = 38400 bps).
Only affects newly opened serial port connections.
=== INT $14/AH=$0A - comm_get_baudrate ===
* AH = $0A
Return:
* AX = Baud rate (0 = 9600 bps, 1 = 38400 bps).
=== INT $14/AH=$0B - comm_set_cancel_key ===
* AH = $0B
* BX = Cancel key combination.
=== INT $14/AH=$0C - comm_get_cancel_key ===
* AH = $0C
Return:
* AX = Cancel key combination.
=== INT $14/AH=$0D - comm_xmodem ===
* AH = $0D
* DS:BX = pointer to XMODEM state structure
Returns:
* AX = new state (equal to ''State'' in the structure)
==== Usage ====
==== Data structures ====
{| class="wikitable"
|+ XMODEM state structure
! Offset
! Size
! Description
|-
| $00
| 2
| State (or error code, if bit 15 set)
|-
| $02
| 1
| Mode
|-
| $03
| 1
| Number of total block transfer retries performed
|-
| $04
| 2
| Number of blocks received/sent
|-
| $06
| 2
| Maximum number of blocks to receive
Number of blocks to send
|-
| $08
| 2
| Size of block, typically 128 bytes
|-
| $0A
| 2
| Bank to write to/read from
|-
| $0C
| 2
| Offset to write to/read from
|-
| $0E
| 2
| ?
|}
{| class="wikitable"
|+ XMODEM state values
! Value
! Description
|-
| $0001
| Start
Set initial values:
* Number of retries = 0
* Current block = 0
* Block size = 128 bytes
Goes to state "Negotiate".
|-
| $0002
| Negotiate
Also receives the first block.<br/>
Goes to state "Block".
|-
| $0003
| Block
Sends or receives a block.<br/>
Goes to state "Block" (if successful), "Retry Block" (if failed), or "Close" (if transfer complete).
|-
| $0004
| Retry Block
Same as Block.
|-
| $0005
| Close
Finishes the XMODEM transfer.<br/>
Goes to state "Done".
|-
| $0006
| Abort
Treated as an "Invalid state value".
|-
| $0007
| Done
Treated as an "Invalid state value".
|-
| $0008
| Erase bank
Goes to state "Block".
|-
| $8100
| Serial I/O: Busy
|-
| $8101
| Serial I/O: Transfer timeout
|-
| $8102
| Serial I/O: Transfer RX overrun
|-
| $8103
| Serial I/O: Transfer cancelled
|-
| $8104
| Invalid state value
|-
| $8105
| XMODEM transfer cancelled
|-
| $8106
| XMODEM block lost during transfer
|-
| $8107
| XMODEM transfer too large
|}
XMODEM mode:
7 bit 0
---- ----
.... .?od
||
|+- Direction: 0 = Send, 1 = Receive
+-- Enable obfuscation
c4d7e0f4928cde730e170e7fef8316a5bf8abb69
417
416
2024-12-14T10:39:31Z
Asie
351
/* Usage */
wikitext
text/x-wiki
The Communication (comm) interrupt provides an abstraction layer and helpers for the WonderSwan's [[UART|serial port]].
== Interrupts ==
=== INT $14/AH=$00 - comm_open ===
* AH = $00
Opens the serial port. Note that the baud rate must be set before calling <code>comm_open</code>.
=== INT $14/AH=$01 - comm_close ===
* AH = $01
Closes the serial port.
=== INT $14/AH=$02 - comm_send_char ===
* AH = $02
* BL = Character (byte) to send.
Return:
* AX = Return code.
Return codes:
* 0x0000 - Success
* 0x8101 - Transfer timeout
* 0x8102 - Transfer RX overrun
* 0x8103 - Transfer cancelled
=== INT $14/AH=$03 - comm_receive_char ===
* AH = $03
Return:
* AX = Character (byte) read (0x0000 - 0xFFFF) or error return code.
=== INT $14/AH=$04 - comm_receive_with_timeout ===
* AH = $03
* CX = Timeout, in frames (as in <code>comm_set_timeout</code>).
Return:
* AX = Character (byte) read (0x0000 - 0xFFFF) or error return code.
Unlike <code>comm_receive_char</code>, this function uses an user-provided timeout.
=== INT $14/AH=$05 - comm_send_string ===
* AH = $05
* DS:DX = Input string to send.
Return:
* AX = Return code.
=== INT $14/AH=$06 - comm_send_block ===
* AH = $06
* CX = Buffer size, in bytes.
* DS:DX = Input buffer to send.
Return:
* AX = Return code.
=== INT $14/AH=$07 - comm_receive_block ===
* AH = $07
* CX = Buffer size, in bytes.
* DS:DX = Buffer to receive bytes to.
Return:
* AX = Return code.
* DX = Number of bytes successfully received.
=== INT $14/AH=$08 - comm_set_timeout ===
* AH = $08
* BX = Receive timeout (in frames; 0xFFFF - wait forever)
* CX = Send timeout (in frames; 0xFFFF - wait forever)
=== INT $14/AH=$09 - comm_set_baudrate ===
* AH = $09
* BX = Baud rate (0 = 9600 bps, 1 = 38400 bps).
Only affects newly opened serial port connections.
=== INT $14/AH=$0A - comm_get_baudrate ===
* AH = $0A
Return:
* AX = Baud rate (0 = 9600 bps, 1 = 38400 bps).
=== INT $14/AH=$0B - comm_set_cancel_key ===
* AH = $0B
* BX = Cancel key combination.
=== INT $14/AH=$0C - comm_get_cancel_key ===
* AH = $0C
Return:
* AX = Cancel key combination.
=== INT $14/AH=$0D - comm_xmodem ===
* AH = $0D
* DS:BX = pointer to XMODEM state structure
Returns:
* AX = new state (equal to ''State'' in the structure)
==== Usage ====
To use comm_xmodem, allocate the state structure and set the following values:
* State = $0001 ("Start")
* Mode = your mode of choice
* Maximum number of blocks = the transfer size, in XMODEM blocks
* Bank, Offset = the transfer source/destination
Next, keep calling comm_xmodem until the "Done" state, or an error, is returned.
==== Data structures ====
{| class="wikitable"
|+ XMODEM state structure
! Offset
! Size
! Description
|-
| $00
| 2
| State (or error code, if bit 15 set)
|-
| $02
| 1
| Mode
|-
| $03
| 1
| Number of total block transfer retries performed
|-
| $04
| 2
| Number of blocks received/sent
|-
| $06
| 2
| Maximum number of blocks to receive
Number of blocks to send
|-
| $08
| 2
| Size of block, typically 128 bytes
|-
| $0A
| 2
| Bank to write to/read from
|-
| $0C
| 2
| Offset to write to/read from
|-
| $0E
| 2
| ?
|}
{| class="wikitable"
|+ XMODEM state values
! Value
! Description
|-
| $0001
| Start
Set initial values:
* Number of retries = 0
* Current block = 0
* Block size = 128 bytes
Goes to state "Negotiate".
|-
| $0002
| Negotiate
Also receives the first block.<br/>
Goes to state "Block".
|-
| $0003
| Block
Sends or receives a block.<br/>
Goes to state "Block" (if successful), "Retry Block" (if failed), or "Close" (if transfer complete).
|-
| $0004
| Retry Block
Same as Block.
|-
| $0005
| Close
Finishes the XMODEM transfer.<br/>
Goes to state "Done".
|-
| $0006
| Abort
Treated as an "Invalid state value".
|-
| $0007
| Done
Treated as an "Invalid state value".
|-
| $0008
| Erase bank
Goes to state "Block".
|-
| $8100
| Serial I/O: Busy
|-
| $8101
| Serial I/O: Transfer timeout
|-
| $8102
| Serial I/O: Transfer RX overrun
|-
| $8103
| Serial I/O: Transfer cancelled
|-
| $8104
| Invalid state value
|-
| $8105
| XMODEM transfer cancelled
|-
| $8106
| XMODEM block lost during transfer
|-
| $8107
| XMODEM transfer too large
|}
XMODEM mode:
7 bit 0
---- ----
.... .?od
||
|+- Direction: 0 = Send, 1 = Receive
+-- Enable obfuscation
b0cf24c05046ff8f87b3b65322fc7e5195223863
418
417
2024-12-14T21:27:23Z
Asie
351
comm_xmodem: clarify basic workflows
wikitext
text/x-wiki
The Communication (comm) interrupt provides an abstraction layer and helpers for the WonderSwan's [[UART|serial port]].
== Interrupts ==
=== INT $14/AH=$00 - comm_open ===
* AH = $00
Opens the serial port. Note that the baud rate must be set before calling <code>comm_open</code>.
=== INT $14/AH=$01 - comm_close ===
* AH = $01
Closes the serial port.
=== INT $14/AH=$02 - comm_send_char ===
* AH = $02
* BL = Character (byte) to send.
Return:
* AX = Return code.
Return codes:
* 0x0000 - Success
* 0x8101 - Transfer timeout
* 0x8102 - Transfer RX overrun
* 0x8103 - Transfer cancelled
=== INT $14/AH=$03 - comm_receive_char ===
* AH = $03
Return:
* AX = Character (byte) read (0x0000 - 0xFFFF) or error return code.
=== INT $14/AH=$04 - comm_receive_with_timeout ===
* AH = $03
* CX = Timeout, in frames (as in <code>comm_set_timeout</code>).
Return:
* AX = Character (byte) read (0x0000 - 0xFFFF) or error return code.
Unlike <code>comm_receive_char</code>, this function uses an user-provided timeout.
=== INT $14/AH=$05 - comm_send_string ===
* AH = $05
* DS:DX = Input string to send.
Return:
* AX = Return code.
=== INT $14/AH=$06 - comm_send_block ===
* AH = $06
* CX = Buffer size, in bytes.
* DS:DX = Input buffer to send.
Return:
* AX = Return code.
=== INT $14/AH=$07 - comm_receive_block ===
* AH = $07
* CX = Buffer size, in bytes.
* DS:DX = Buffer to receive bytes to.
Return:
* AX = Return code.
* DX = Number of bytes successfully received.
=== INT $14/AH=$08 - comm_set_timeout ===
* AH = $08
* BX = Receive timeout (in frames; 0xFFFF - wait forever)
* CX = Send timeout (in frames; 0xFFFF - wait forever)
=== INT $14/AH=$09 - comm_set_baudrate ===
* AH = $09
* BX = Baud rate (0 = 9600 bps, 1 = 38400 bps).
Only affects newly opened serial port connections.
=== INT $14/AH=$0A - comm_get_baudrate ===
* AH = $0A
Return:
* AX = Baud rate (0 = 9600 bps, 1 = 38400 bps).
=== INT $14/AH=$0B - comm_set_cancel_key ===
* AH = $0B
* BX = Cancel key combination.
=== INT $14/AH=$0C - comm_get_cancel_key ===
* AH = $0C
Return:
* AX = Cancel key combination.
=== INT $14/AH=$0D - comm_xmodem ===
* AH = $0D
* DS:BX = pointer to XMODEM state structure
Returns:
* AX = new state (equal to ''State'' in the structure)
==== Usage ====
To use comm_xmodem, allocate the state structure and set the following values:
* State = $0001 ("Start")
* Mode = your mode of choice
* Maximum number of blocks = the transfer size, in XMODEM blocks
* Bank, Offset = the transfer source/destination
Next, keep calling comm_xmodem until the "Done" state, or an error, is returned.
===== Typical flow - Send =====
* Initial: State = Start, Mode = Send
* State = Negotiate
* State = Block, Count = 0
* State = Block, Count = 1
* ...
* State = Block, Count = Max
* State = Close
* State = Done
===== Typical flow - Receive =====
* Initial: State = Start, Mode = Receive
* State = Negotiate
* State = Block, Count = 1
* State = Block, Count = 2
* ...
* State = Block, Count = N
* State = Close
* State = Done
Note that in the ''Receive'' flow, the Negotiate state returns ''after'' receiving the first block, as opposed to ''before'' sending the first block.
In both cases, the final block (Max) is not sent/received; if such a value is reached, the "transfer too large" error code is returned.
==== Data structures ====
{| class="wikitable"
|+ XMODEM state structure
! Offset
! Size
! Description
|-
| $00
| 2
| State (or error code, if bit 15 set)
|-
| $02
| 1
| Mode
|-
| $03
| 1
| Number of total block transfer retries performed
|-
| $04
| 2
| Number of blocks received/sent
|-
| $06
| 2
| Maximum number of blocks to receive
Number of blocks to send
|-
| $08
| 2
| Size of block, typically 128 bytes
|-
| $0A
| 2
| Bank to write to/read from
|-
| $0C
| 2
| Offset to write to/read from
|-
| $0E
| 2
| ?
|}
{| class="wikitable"
|+ XMODEM state values
! Value
! Description
|-
| $0001
| Start
Set initial values:
* Number of retries = 0
* Current block = 0
* Block size = 128 bytes
Goes to state "Negotiate".
|-
| $0002
| Negotiate
Also receives the first block.<br/>
Goes to state "Block".
|-
| $0003
| Block
Sends or receives a block.<br/>
Goes to state "Block" (if successful), "Retry Block" (if failed), or "Close" (if transfer complete).
|-
| $0004
| Retry Block
Same as Block.
|-
| $0005
| Close
Finishes the XMODEM transfer.<br/>
Goes to state "Done".
|-
| $0006
| Abort
Treated as an "Invalid state value".
|-
| $0007
| Done
Treated as an "Invalid state value".
|-
| $0008
| Erase bank
Goes to state "Block".
|-
| $8100
| Serial I/O: Busy
|-
| $8101
| Serial I/O: Transfer timeout
|-
| $8102
| Serial I/O: Transfer RX overrun
|-
| $8103
| Serial I/O: Transfer cancelled
|-
| $8104
| Invalid state value
|-
| $8105
| XMODEM transfer cancelled
|-
| $8106
| XMODEM block lost during transfer
|-
| $8107
| XMODEM transfer too large
|}
XMODEM mode:
7 bit 0
---- ----
.... .?od
||
|+- Direction: 0 = Send, 1 = Receive
+-- Enable obfuscation
1211a7c4c967af7539dc477a6d5fa5c4eb154682
426
418
2024-12-16T14:13:05Z
Asie
351
/* INT $14/AH=$0D - comm_xmodem */
wikitext
text/x-wiki
The Communication (comm) interrupt provides an abstraction layer and helpers for the WonderSwan's [[UART|serial port]].
== Interrupts ==
=== INT $14/AH=$00 - comm_open ===
* AH = $00
Opens the serial port. Note that the baud rate must be set before calling <code>comm_open</code>.
=== INT $14/AH=$01 - comm_close ===
* AH = $01
Closes the serial port.
=== INT $14/AH=$02 - comm_send_char ===
* AH = $02
* BL = Character (byte) to send.
Return:
* AX = Return code.
Return codes:
* 0x0000 - Success
* 0x8101 - Transfer timeout
* 0x8102 - Transfer RX overrun
* 0x8103 - Transfer cancelled
=== INT $14/AH=$03 - comm_receive_char ===
* AH = $03
Return:
* AX = Character (byte) read (0x0000 - 0xFFFF) or error return code.
=== INT $14/AH=$04 - comm_receive_with_timeout ===
* AH = $03
* CX = Timeout, in frames (as in <code>comm_set_timeout</code>).
Return:
* AX = Character (byte) read (0x0000 - 0xFFFF) or error return code.
Unlike <code>comm_receive_char</code>, this function uses an user-provided timeout.
=== INT $14/AH=$05 - comm_send_string ===
* AH = $05
* DS:DX = Input string to send.
Return:
* AX = Return code.
=== INT $14/AH=$06 - comm_send_block ===
* AH = $06
* CX = Buffer size, in bytes.
* DS:DX = Input buffer to send.
Return:
* AX = Return code.
=== INT $14/AH=$07 - comm_receive_block ===
* AH = $07
* CX = Buffer size, in bytes.
* DS:DX = Buffer to receive bytes to.
Return:
* AX = Return code.
* DX = Number of bytes successfully received.
=== INT $14/AH=$08 - comm_set_timeout ===
* AH = $08
* BX = Receive timeout (in frames; 0xFFFF - wait forever)
* CX = Send timeout (in frames; 0xFFFF - wait forever)
=== INT $14/AH=$09 - comm_set_baudrate ===
* AH = $09
* BX = Baud rate (0 = 9600 bps, 1 = 38400 bps).
Only affects newly opened serial port connections.
=== INT $14/AH=$0A - comm_get_baudrate ===
* AH = $0A
Return:
* AX = Baud rate (0 = 9600 bps, 1 = 38400 bps).
=== INT $14/AH=$0B - comm_set_cancel_key ===
* AH = $0B
* BX = Cancel key combination.
=== INT $14/AH=$0C - comm_get_cancel_key ===
* AH = $0C
Return:
* AX = Cancel key combination.
=== INT $14/AH=$0D - comm_xmodem ===
* AH = $0D
* DS:BX = pointer to XMODEM state structure
Returns:
* AX = new state (equal to ''State'' in the structure)
==== Usage ====
To use comm_xmodem, allocate the state structure and set the following values:
* State = $0001 ("Start")
* Mode = your mode of choice
* Maximum number of blocks = the transfer size, in XMODEM blocks
* Bank, Offset = the transfer source/destination
Next, keep calling comm_xmodem until the "Done" state, or an error, is returned.
The Bank and Offset are auto-incremented by the block size (in bytes) on each successful transfer.
===== Typical flow - Send =====
* Initial: State = Start, Mode = Send
* State = Negotiate
* State = Block, Count = 0
* State = Block, Count = 1
* ...
* State = Block, Count = Max
* State = Close
* State = Done
===== Typical flow - Receive =====
* Initial: State = Start, Mode = Receive
* State = Negotiate
* State = Block, Count = 1
* State = Block, Count = 2
* ...
* State = Block, Count = N
* State = Close
* State = Done
Note that in the ''Receive'' flow, the Negotiate state returns ''after'' receiving the first block, as opposed to ''before'' sending the first block.
In both cases, the final block (Max) is not sent/received; if such a value is reached, the "transfer too large" error code is returned.
==== Data structures ====
{| class="wikitable"
|+ XMODEM state structure
! Offset
! Size
! Description
|-
| $00
| 2
| State (or error code, if bit 15 set)
|-
| $02
| 1
| Mode
|-
| $03
| 1
| Number of total block transfer retries performed
|-
| $04
| 2
| Number of blocks received/sent
|-
| $06
| 2
| Maximum number of blocks to receive
Number of blocks to send
|-
| $08
| 2
| Size of block, typically 128 bytes
|-
| $0A
| 2
| Bank to write to/read from
|-
| $0C
| 2
| Offset to write to/read from
|-
| $0E
| 2
| ?
|}
{| class="wikitable"
|+ XMODEM state values
! Value
! Description
|-
| $0001
| Start
Set initial values:
* Number of retries = 0
* Current block = 0
* Block size = 128 bytes
Goes to state "Negotiate".
|-
| $0002
| Negotiate
Also receives the first block.<br/>
Goes to state "Block".
|-
| $0003
| Block
Sends or receives a block.<br/>
Goes to state "Block" (if successful), "Retry Block" (if failed), or "Close" (if transfer complete).
|-
| $0004
| Retry Block
Same as Block.
|-
| $0005
| Close
Finishes the XMODEM transfer.<br/>
Goes to state "Done".
|-
| $0006
| Abort
Treated as an "Invalid state value".
|-
| $0007
| Done
Treated as an "Invalid state value".
|-
| $0008
| Erase bank
Goes to state "Block".
|-
| $8100
| Serial I/O: Busy
|-
| $8101
| Serial I/O: Transfer timeout
|-
| $8102
| Serial I/O: Transfer RX overrun
|-
| $8103
| Serial I/O: Transfer cancelled
|-
| $8104
| Invalid state value
|-
| $8105
| XMODEM transfer cancelled
|-
| $8106
| XMODEM block lost during transfer
|-
| $8107
| XMODEM transfer too large
|}
XMODEM mode:
7 bit 0
---- ----
.... .?od
||
|+- Direction: 0 = Send, 1 = Receive
+-- Enable obfuscation
6c32fe368ca29d43c4730d77804c2be827333f95
428
426
2024-12-16T20:01:37Z
Asie
351
/* INT $14/AH=$0D - comm_xmodem */
wikitext
text/x-wiki
The Communication (comm) interrupt provides an abstraction layer and helpers for the WonderSwan's [[UART|serial port]].
== Interrupts ==
=== INT $14/AH=$00 - comm_open ===
* AH = $00
Opens the serial port. Note that the baud rate must be set before calling <code>comm_open</code>.
=== INT $14/AH=$01 - comm_close ===
* AH = $01
Closes the serial port.
=== INT $14/AH=$02 - comm_send_char ===
* AH = $02
* BL = Character (byte) to send.
Return:
* AX = Return code.
Return codes:
* 0x0000 - Success
* 0x8101 - Transfer timeout
* 0x8102 - Transfer RX overrun
* 0x8103 - Transfer cancelled
=== INT $14/AH=$03 - comm_receive_char ===
* AH = $03
Return:
* AX = Character (byte) read (0x0000 - 0xFFFF) or error return code.
=== INT $14/AH=$04 - comm_receive_with_timeout ===
* AH = $03
* CX = Timeout, in frames (as in <code>comm_set_timeout</code>).
Return:
* AX = Character (byte) read (0x0000 - 0xFFFF) or error return code.
Unlike <code>comm_receive_char</code>, this function uses an user-provided timeout.
=== INT $14/AH=$05 - comm_send_string ===
* AH = $05
* DS:DX = Input string to send.
Return:
* AX = Return code.
=== INT $14/AH=$06 - comm_send_block ===
* AH = $06
* CX = Buffer size, in bytes.
* DS:DX = Input buffer to send.
Return:
* AX = Return code.
=== INT $14/AH=$07 - comm_receive_block ===
* AH = $07
* CX = Buffer size, in bytes.
* DS:DX = Buffer to receive bytes to.
Return:
* AX = Return code.
* DX = Number of bytes successfully received.
=== INT $14/AH=$08 - comm_set_timeout ===
* AH = $08
* BX = Receive timeout (in frames; 0xFFFF - wait forever)
* CX = Send timeout (in frames; 0xFFFF - wait forever)
=== INT $14/AH=$09 - comm_set_baudrate ===
* AH = $09
* BX = Baud rate (0 = 9600 bps, 1 = 38400 bps).
Only affects newly opened serial port connections.
=== INT $14/AH=$0A - comm_get_baudrate ===
* AH = $0A
Return:
* AX = Baud rate (0 = 9600 bps, 1 = 38400 bps).
=== INT $14/AH=$0B - comm_set_cancel_key ===
* AH = $0B
* BX = Cancel key combination.
=== INT $14/AH=$0C - comm_get_cancel_key ===
* AH = $0C
Return:
* AX = Cancel key combination.
=== INT $14/AH=$0D - comm_xmodem ===
* AH = $0D
* DS:BX = pointer to XMODEM state structure
Returns:
* AX = new state (equal to ''State'' in the structure)
==== Usage ====
To use comm_xmodem, allocate the state structure and set the following values:
* State = $0001 ("Start")
* Mode = your mode of choice
* Maximum number of blocks = the transfer size, in XMODEM blocks
* Bank, Offset = the transfer source/destination
Next, keep calling comm_xmodem until the "Done" state, or an error, is returned.
The Bank and Offset are auto-incremented by the block size (in bytes) on each successful transfer.
===== Typical flow - Send =====
* Initial: State = Start, Mode = Send
* State = Negotiate
* State = Block, Count = 0
* State = Block, Count = 1
* ...
* State = Block, Count = Max
* State = Close
* State = Done
===== Typical flow - Receive =====
* Initial: State = Start, Mode = Receive
* State = Negotiate
* State = Block, Count = 1
* State = Block, Count = 2
* ...
* State = Block, Count = N
* State = Close
* State = Done
Note that in the ''Receive'' flow, the Negotiate state returns ''after'' receiving the first block, as opposed to ''before'' sending the first block.
In both cases, the final block (Max) is not sent/received; if such a value is reached, the "transfer too large" error code is returned.
==== Data structures ====
{| class="wikitable"
|+ XMODEM state structure
! Offset
! Size
! Description
|-
| $00
| 2
| State (or error code, if bit 15 set)
|-
| $02
| 1
| Mode
|-
| $03
| 1
| Number of total block transfer retries performed
|-
| $04
| 2
| Number of blocks received/sent
|-
| $06
| 2
| Maximum number of blocks to receive
Number of blocks to send
|-
| $08
| 2
| Size of block, typically 128 bytes
|-
| $0A
| 2
| Bank to write to/read from
|-
| $0C
| 2
| Offset to write to/read from
|-
| $0E
| 2
| ?
|}
{| class="wikitable"
|+ XMODEM state values
! Value
! Description
|-
| $0001
| Start
Set initial values:
* Number of retries = 0
* Current block = 0
* Block size = 128 bytes
Goes to state "Negotiate".
|-
| $0002
| Negotiate
Also receives the first block.<br/>
Goes to state "Block".
|-
| $0003
| Block
Send: Sends a block and waits for ACK/NAK.<br/>
Receive: Sends ACK and receives a block.</br>
Goes to state "Block" (if successful), "Retry Block" (if failed), or "Close" (if transfer complete).
|-
| $0004
| Retry Block
Same as Block, except NAK is sent in "Receive" mode.
|-
| $0005
| Close
Finishes the XMODEM transfer.<br/>
Goes to state "Done".
|-
| $0006
| Abort
Treated as an "Invalid state value".
|-
| $0007
| Done
Treated as an "Invalid state value".
|-
| $0008
| Erase bank
Goes to state "Block".
|-
| $8100
| Serial I/O: Busy
|-
| $8101
| Serial I/O: Transfer timeout
|-
| $8102
| Serial I/O: Transfer RX overrun
|-
| $8103
| Serial I/O: Transfer cancelled
|-
| $8104
| Invalid state value
|-
| $8105
| XMODEM transfer cancelled
|-
| $8106
| XMODEM block lost during transfer
|-
| $8107
| XMODEM transfer too large
|}
XMODEM mode:
7 bit 0
---- ----
.... .?od
||
|+- Direction: 0 = Send, 1 = Receive
+-- Enable obfuscation
7038af5a9e43a47733ce5de8a8ac1016ad1f684a
NEC V30MZ instruction set
0
68
433
2024-12-26T14:32:59Z
Asie
351
auto-generated initial template
wikitext
text/x-wiki
__NOTOC__
{| class="wikitable" style="text-align: center"
|+ Official V30MZ (80186) Instructions
|-
| [[#AAA|AAA]] || [[#AAD|AAD]] || [[#AAM|AAM]] || [[#AAS|AAS]] || [[#ADC|ADC]] || [[#ADD|ADD]] || [[#AND|AND]] || [[#BOUND|BOUND]] || [[#CALL|CALL]] || [[#CBW|CBW]] || [[#CLC|CLC]]
|-
| [[#CLD|CLD]] || [[#CLI|CLI]] || [[#CMC|CMC]] || [[#CMP|CMP]] || [[#CMPSB|CMPSB]] || [[#CMPSW|CMPSW]] || [[#CS|CS]] || [[#CWD|CWD]] || [[#DAA|DAA]] || [[#DAS|DAS]] || [[#DEC|DEC]]
|-
| [[#DIV|DIV]] || [[#DS|DS]] || [[#ENTER|ENTER]] || [[#ES|ES]] || [[#HLT|HLT]] || [[#IDIV|IDIV]] || [[#IMUL|IMUL]] || [[#IN|IN]] || [[#INC|INC]] || [[#INSB|INSB]] || [[#INSW|INSW]]
|-
| [[#INT|INT]] || [[#INTO|INTO]] || [[#IRET|IRET]] || [[#JA|JA]] || [[#JBE|JBE]] || [[#JC|JC]] || [[#JCXZ|JCXZ]] || [[#JG|JG]] || [[#JGE|JGE]] || [[#JL|JL]] || [[#JLE|JLE]]
|-
| [[#JMP|JMP]] || [[#JNC|JNC]] || [[#JNO|JNO]] || [[#JNP|JNP]] || [[#JNS|JNS]] || [[#JNZ|JNZ]] || [[#JO|JO]] || [[#JP|JP]] || [[#JS|JS]] || [[#JZ|JZ]] || [[#LAHF|LAHF]]
|-
| [[#LDS|LDS]] || [[#LEA|LEA]] || [[#LEAVE|LEAVE]] || [[#LES|LES]] || [[#LOCK|LOCK]] || [[#LODSB|LODSB]] || [[#LODSW|LODSW]] || [[#LOOP|LOOP]] || [[#LOOPE|LOOPE]] || [[#LOOPNE|LOOPNE]] || [[#MOV|MOV]]
|-
| [[#MOVSB|MOVSB]] || [[#MOVSW|MOVSW]] || [[#MUL|MUL]] || [[#NEG|NEG]] || [[#NOP|NOP]] || [[#NOT|NOT]] || [[#OR|OR]] || [[#OUT|OUT]] || [[#OUTSB|OUTSB]] || [[#OUTSW|OUTSW]] || [[#POLL|POLL]]
|-
| [[#POP|POP]] || [[#POPA|POPA]] || [[#POPF|POPF]] || [[#PUSH|PUSH]] || [[#PUSHA|PUSHA]] || [[#PUSHF|PUSHF]] || [[#RCL|RCL]] || [[#RCR|RCR]] || [[#REP|REP]] || [[#REPNE|REPNE]] || [[#RET|RET]]
|-
| [[#RETF|RETF]] || [[#ROL|ROL]] || [[#ROR|ROR]] || [[#SAHF|SAHF]] || [[#SAR|SAR]] || [[#SBB|SBB]] || [[#SCASB|SCASB]] || [[#SCASW|SCASW]] || [[#SHL|SHL]] || [[#SHR|SHR]] || [[#SS|SS]]
|-
| [[#STC|STC]] || [[#STD|STD]] || [[#STI|STI]] || [[#STOSB|STOSB]] || [[#STOSW|STOSW]] || [[#SUB|SUB]] || [[#TEST|TEST]] || [[#XCHG|XCHG]] || [[#XLAT|XLAT]] || [[#XOR|XOR]]
|}
== Official instructions by type ==
{| class="wikitable sortable" style="text-align: center"
!Type
!colspan=16 class="unsortable" | Instructions
|-
| style="text-align:left;" | Memory
| style="" | [[#MOV|MOV]]
| style="" | [[#XCHG|XCHG]]
| style="" | [[#XLAT|XLAT]]
| style="" | [[#LEA|LEA]]
| style="border-right:none;" | [[#LDS|LDS]]
| style="border-left:none;" | [[#LES|LES]]
| style="border-right:none;" | [[#IN|IN]]
| style="border-left:none;" | [[#OUT|OUT]]
| colspan="8" |
|-
| style="text-align:left;" | Ports
| style="border-right:none;" | [[#IN|IN]]
| style="border-left:none;" | [[#OUT|OUT]]
| style="border-right:none;" | [[#INSB|INSB]]
| style="border-left:none;" | [[#OUTSB|OUTSB]]
| style="border-right:none;" | [[#INSW|INSW]]
| style="border-left:none;" | [[#OUTSW|OUTSW]]
| colspan="10" |
|-
| style="text-align:left;" | Arithmetic
| style="border-right:none;" | [[#ADD|ADD]]
| style="border-left:none;" | [[#SUB|SUB]]
| style="border-right:none;" | [[#ADC|ADC]]
| style="border-left:none;" | [[#SBB|SBB]]
| style="border-right:none;" | [[#INC|INC]]
| style="border-left:none;" | [[#DEC|DEC]]
| style="border-right:none;" | [[#MUL|MUL]]
| style="border-left:none;" | [[#DIV|DIV]]
| style="border-right:none;" | [[#IMUL|IMUL]]
| style="border-left:none;" | [[#IDIV|IDIV]]
| style="" | [[#CMP|CMP]]
| style="" | [[#NEG|NEG]]
| colspan="4" |
|-
| style="text-align:left;" | Numeric
| style="" | [[#CBW|CBW]]
| style="" | [[#CWD|CWD]]
| style="" | [[#AAA|AAA]]
| style="" | [[#AAS|AAS]]
| style="" | [[#AAM|AAM]]
| style="" | [[#AAD|AAD]]
| style="" | [[#DAA|DAA]]
| style="" | [[#DAS|DAS]]
| colspan="8" |
|-
| style="text-align:left;" | Shift
| style="border-right:none;" | [[#ROL|ROL]]
| style="border-left:none;" | [[#ROR|ROR]]
| style="border-right:none;" | [[#RCL|RCL]]
| style="border-left:none;" | [[#RCR|RCR]]
| style="border-right:none;" | [[#SHL|SHL]]
| style="border-left:none;" | [[#SHR|SHR]]
| style="" | [[#SAR|SAR]]
| colspan="9" |
|-
| style="text-align:left;" | Bitwise
| style="" | [[#AND|AND]]
| style="" | [[#OR|OR]]
| style="" | [[#XOR|XOR]]
| style="" | [[#NOT|NOT]]
| style="" | [[#TEST|TEST]]
| colspan="11" |
|-
| style="text-align:left;" | Branch
| style="border-right:none;" | [[#JC|JC]]
| style="border-left:none;" | [[#JNC|JNC]]
| style="border-right:none;" | [[#JZ|JZ]]
| style="border-left:none;" | [[#JNZ|JNZ]]
| style="border-right:none;" | [[#JBE|JBE]]
| style="border-left:none;" | [[#JA|JA]]
| style="border-right:none;" | [[#JO|JO]]
| style="border-left:none;" | [[#JNO|JNO]]
| style="border-right:none;" | [[#JP|JP]]
| style="border-left:none;" | [[#JNP|JNP]]
| style="border-right:none;" | [[#JS|JS]]
| style="border-left:none;" | [[#JNS|JNS]]
| style="border-right:none;" | [[#JL|JL]]
| style="border-left:none;" | [[#JGE|JGE]]
| style="border-right:none;" | [[#JLE|JLE]]
| style="border-left:none;" | [[#JG|JG]]
|-
| style="text-align:left;" | Jump
| style="" | [[#JMP|JMP]]
| style="border-right:none;" | [[#CALL|CALL]]
| style="border-left:none;border-right:none;" | [[#RET|RET]]
| style="border-left:none;" | [[#RETF|RETF]]
| colspan="12" |
|-
| style="text-align:left;" | Loop
| style="" | [[#LOOP|LOOP]]
| style="" | [[#LOOPE|LOOPE]]
| style="" | [[#LOOPNE|LOOPNE]]
| colspan="13" |
|-
| style="text-align:left;" | Interrupt
| style="border-right:none;" | [[#INT|INT]]
| style="border-left:none;" | [[#IRET|IRET]]
| style="" | [[#INTO|INTO]]
| style="" | [[#HLT|HLT]]
| style="" | [[#BOUND|BOUND]]
| colspan="11" |
|-
| style="text-align:left;" | Stack
| style="border-right:none;" | [[#PUSH|PUSH]]
| style="border-left:none;" | [[#POP|POP]]
| style="border-right:none;" | [[#PUSHA|PUSHA]]
| style="border-left:none;" | [[#POPA|POPA]]
| style="border-right:none;" | [[#PUSHF|PUSHF]]
| style="border-left:none;" | [[#POPF|POPF]]
| colspan="10" |
|-
| style="text-align:left;" | Flags
| style="border-right:none;" | [[#CLC|CLC]]
| style="border-left:none;" | [[#STC|STC]]
| style="border-right:none;" | [[#CLD|CLD]]
| style="border-left:none;" | [[#STD|STD]]
| style="border-right:none;" | [[#CLI|CLI]]
| style="border-left:none;" | [[#STI|STI]]
| style="" | [[#CMC|CMC]]
| style="border-right:none;" | [[#LAHF|LAHF]]
| style="border-left:none;" | [[#SAHF|SAHF]]
| colspan="7" |
|-
| style="text-align:left;" | Prefix
| style="" | [[#CS|CS]]
| style="" | [[#DS|DS]]
| style="" | [[#ES|ES]]
| style="" | [[#SS|SS]]
| colspan="12" |
|-
| style="text-align:left;" | String
| style="border-right:none;" | [[#REP|REP]]
| style="border-left:none;border-right:none;" | [[#REP|REPE]]
| style="border-left:none;" | [[#REPNE|REPNE]]
| style="" | [[#MOVSB|MOVSB]]
| style="" | [[#MOVSW|MOVSW]]
| style="border-right:none;" | [[#LODSB|LODSB]]
| style="border-left:none;" | [[#STOSB|STOSB]]
| style="border-right:none;" | [[#LODSW|LODSW]]
| style="border-left:none;" | [[#STOSW|STOSW]]
| style="" | [[#CMPSB|CMPSB]]
| style="" | [[#SCASB|SCASB]]
| style="" | [[#CMPSW|CMPSW]]
| style="" | [[#SCASW|SCASW]]
| colspan="3" |
|-
| style="text-align:left;" | Other
| style="" | [[#NOP|NOP]]
| style="border-right:none;" | [[#ENTER|ENTER]]
| style="border-left:none;" | [[#LEAVE|LEAVE]]
| style="" | [[#LOCK|LOCK]]
| style="" | [[#POLL|POLL]]
| colspan="11" |
|}
== Official instructions ==
{{Anchor|AAA}}
=== AAA ===
{{Anchor|AAD}}
=== AAD ===
{{Anchor|AAM}}
=== AAM ===
{{Anchor|AAS}}
=== AAS ===
{{Anchor|ADC}}
=== ADC ===
{{Anchor|ADD}}
=== ADD ===
{{Anchor|AND}}
=== AND ===
{{Anchor|BOUND}}
=== BOUND ===
{{Anchor|CALL}}
=== CALL ===
{{Anchor|CBW}}
=== CBW ===
{{Anchor|CLC}}
=== CLC ===
{{Anchor|CLD}}
=== CLD ===
{{Anchor|CLI}}
=== CLI ===
{{Anchor|CMC}}
=== CMC ===
{{Anchor|CMP}}
=== CMP ===
{{Anchor|CMPSB}}
=== CMPSB ===
{{Anchor|CMPSW}}
=== CMPSW ===
{{Anchor|CS}}
=== CS ===
{{Anchor|CWD}}
=== CWD ===
{{Anchor|DAA}}
=== DAA ===
{{Anchor|DAS}}
=== DAS ===
{{Anchor|DEC}}
=== DEC ===
{{Anchor|DIV}}
=== DIV ===
{{Anchor|DS}}
=== DS ===
{{Anchor|ENTER}}
=== ENTER ===
{{Anchor|ES}}
=== ES ===
{{Anchor|HLT}}
=== HLT ===
{{Anchor|IDIV}}
=== IDIV ===
{{Anchor|IMUL}}
=== IMUL ===
{{Anchor|IN}}
=== IN ===
{{Anchor|INC}}
=== INC ===
{{Anchor|INSB}}
=== INSB ===
{{Anchor|INSW}}
=== INSW ===
{{Anchor|INT}}
=== INT ===
{{Anchor|INTO}}
=== INTO ===
{{Anchor|IRET}}
=== IRET ===
{{Anchor|JA}}
=== JA ===
{{Anchor|JBE}}
=== JBE ===
{{Anchor|JC}}
=== JC/JB ===
{{Anchor|JCXZ}}
=== JCXZ ===
{{Anchor|JG}}
=== JG ===
{{Anchor|JGE}}
=== JGE ===
{{Anchor|JL}}
=== JL ===
{{Anchor|JLE}}
=== JLE ===
{{Anchor|JMP}}
=== JMP ===
{{Anchor|JNC}}
=== JNC/JAE ===
{{Anchor|JNO}}
=== JNO ===
{{Anchor|JNP}}
=== JNP ===
{{Anchor|JNS}}
=== JNS ===
{{Anchor|JNZ}}
=== JNZ/JNE ===
{{Anchor|JO}}
=== JO ===
{{Anchor|JP}}
=== JP ===
{{Anchor|JS}}
=== JS ===
{{Anchor|JZ}}
=== JZ/JE ===
{{Anchor|LAHF}}
=== LAHF ===
{{Anchor|LDS}}
=== LDS ===
{{Anchor|LEA}}
=== LEA ===
{{Anchor|LEAVE}}
=== LEAVE ===
{{Anchor|LES}}
=== LES ===
{{Anchor|LOCK}}
=== LOCK ===
{{Anchor|LODSB}}
=== LODSB ===
{{Anchor|LODSW}}
=== LODSW ===
{{Anchor|LOOP}}
=== LOOP ===
{{Anchor|LOOPE}}
=== LOOPE ===
{{Anchor|LOOPNE}}
=== LOOPNE ===
{{Anchor|MOV}}
=== MOV ===
{{Anchor|MOVSB}}
=== MOVSB ===
{{Anchor|MOVSW}}
=== MOVSW ===
{{Anchor|MUL}}
=== MUL ===
{{Anchor|NEG}}
=== NEG ===
{{Anchor|NOP}}
=== NOP ===
{{Anchor|NOT}}
=== NOT ===
{{Anchor|OR}}
=== OR ===
{{Anchor|OUT}}
=== OUT ===
{{Anchor|OUTSB}}
=== OUTSB ===
{{Anchor|OUTSW}}
=== OUTSW ===
{{Anchor|POLL}}
=== POLL ===
{{Anchor|POP}}
=== POP ===
{{Anchor|POPA}}
=== POPA ===
{{Anchor|POPF}}
=== POPF ===
{{Anchor|PUSH}}
=== PUSH ===
{{Anchor|PUSHA}}
=== PUSHA ===
{{Anchor|PUSHF}}
=== PUSHF ===
{{Anchor|RCL}}
=== RCL ===
{{Anchor|RCR}}
=== RCR ===
{{Anchor|REP}}
=== REP/REPE/REPZ ===
{{Anchor|REPNE}}
=== REPNE/REPNZ ===
{{Anchor|RET}}
=== RET ===
{{Anchor|RETF}}
=== RETF ===
{{Anchor|ROL}}
=== ROL ===
{{Anchor|ROR}}
=== ROR ===
{{Anchor|SAHF}}
=== SAHF ===
{{Anchor|SAR}}
=== SAR ===
{{Anchor|SBB}}
=== SBB ===
{{Anchor|SCASB}}
=== SCASB ===
{{Anchor|SCASW}}
=== SCASW ===
{{Anchor|SHL}}
=== SHL ===
{{Anchor|SHR}}
=== SHR ===
{{Anchor|SS}}
=== SS ===
{{Anchor|STC}}
=== STC ===
{{Anchor|STD}}
=== STD ===
{{Anchor|STI}}
=== STI ===
{{Anchor|STOSB}}
=== STOSB ===
{{Anchor|STOSW}}
=== STOSW ===
{{Anchor|SUB}}
=== SUB ===
{{Anchor|TEST}}
=== TEST ===
{{Anchor|XCHG}}
=== XCHG ===
{{Anchor|XLAT}}
=== XLAT ===
{{Anchor|XOR}}
=== XOR ===
2320bb20f029f40380308beea1159d595414d86c
434
433
2024-12-26T14:34:58Z
Asie
351
/* Official instructions by type */
wikitext
text/x-wiki
__NOTOC__
{| class="wikitable" style="text-align: center"
|+ Official V30MZ (80186) Instructions
|-
| [[#AAA|AAA]] || [[#AAD|AAD]] || [[#AAM|AAM]] || [[#AAS|AAS]] || [[#ADC|ADC]] || [[#ADD|ADD]] || [[#AND|AND]] || [[#BOUND|BOUND]] || [[#CALL|CALL]] || [[#CBW|CBW]] || [[#CLC|CLC]]
|-
| [[#CLD|CLD]] || [[#CLI|CLI]] || [[#CMC|CMC]] || [[#CMP|CMP]] || [[#CMPSB|CMPSB]] || [[#CMPSW|CMPSW]] || [[#CS|CS]] || [[#CWD|CWD]] || [[#DAA|DAA]] || [[#DAS|DAS]] || [[#DEC|DEC]]
|-
| [[#DIV|DIV]] || [[#DS|DS]] || [[#ENTER|ENTER]] || [[#ES|ES]] || [[#HLT|HLT]] || [[#IDIV|IDIV]] || [[#IMUL|IMUL]] || [[#IN|IN]] || [[#INC|INC]] || [[#INSB|INSB]] || [[#INSW|INSW]]
|-
| [[#INT|INT]] || [[#INTO|INTO]] || [[#IRET|IRET]] || [[#JA|JA]] || [[#JBE|JBE]] || [[#JC|JC]] || [[#JCXZ|JCXZ]] || [[#JG|JG]] || [[#JGE|JGE]] || [[#JL|JL]] || [[#JLE|JLE]]
|-
| [[#JMP|JMP]] || [[#JNC|JNC]] || [[#JNO|JNO]] || [[#JNP|JNP]] || [[#JNS|JNS]] || [[#JNZ|JNZ]] || [[#JO|JO]] || [[#JP|JP]] || [[#JS|JS]] || [[#JZ|JZ]] || [[#LAHF|LAHF]]
|-
| [[#LDS|LDS]] || [[#LEA|LEA]] || [[#LEAVE|LEAVE]] || [[#LES|LES]] || [[#LOCK|LOCK]] || [[#LODSB|LODSB]] || [[#LODSW|LODSW]] || [[#LOOP|LOOP]] || [[#LOOPE|LOOPE]] || [[#LOOPNE|LOOPNE]] || [[#MOV|MOV]]
|-
| [[#MOVSB|MOVSB]] || [[#MOVSW|MOVSW]] || [[#MUL|MUL]] || [[#NEG|NEG]] || [[#NOP|NOP]] || [[#NOT|NOT]] || [[#OR|OR]] || [[#OUT|OUT]] || [[#OUTSB|OUTSB]] || [[#OUTSW|OUTSW]] || [[#POLL|POLL]]
|-
| [[#POP|POP]] || [[#POPA|POPA]] || [[#POPF|POPF]] || [[#PUSH|PUSH]] || [[#PUSHA|PUSHA]] || [[#PUSHF|PUSHF]] || [[#RCL|RCL]] || [[#RCR|RCR]] || [[#REP|REP]] || [[#REPNE|REPNE]] || [[#RET|RET]]
|-
| [[#RETF|RETF]] || [[#ROL|ROL]] || [[#ROR|ROR]] || [[#SAHF|SAHF]] || [[#SAR|SAR]] || [[#SBB|SBB]] || [[#SCASB|SCASB]] || [[#SCASW|SCASW]] || [[#SHL|SHL]] || [[#SHR|SHR]] || [[#SS|SS]]
|-
| [[#STC|STC]] || [[#STD|STD]] || [[#STI|STI]] || [[#STOSB|STOSB]] || [[#STOSW|STOSW]] || [[#SUB|SUB]] || [[#TEST|TEST]] || [[#XCHG|XCHG]] || [[#XLAT|XLAT]] || [[#XOR|XOR]]
|}
== Official instructions by type ==
{| class="wikitable sortable" style="text-align: center"
!Type
!colspan=16 class="unsortable" | Instructions
|-
| style="text-align:left;" | Memory
| style="" | [[#MOV|MOV]]
| style="" | [[#XCHG|XCHG]]
| style="" | [[#XLAT|XLAT]]
| style="" | [[#LEA|LEA]]
| style="border-right:none;" | [[#LDS|LDS]]
| style="border-left:none;" | [[#LES|LES]]
| colspan="10" |
|-
| style="text-align:left;" | Ports
| style="border-right:none;" | [[#IN|IN]]
| style="border-left:none;" | [[#OUT|OUT]]
| style="border-right:none;" | [[#INSB|INSB]]
| style="border-left:none;" | [[#OUTSB|OUTSB]]
| style="border-right:none;" | [[#INSW|INSW]]
| style="border-left:none;" | [[#OUTSW|OUTSW]]
| colspan="10" |
|-
| style="text-align:left;" | Arithmetic
| style="border-right:none;" | [[#ADD|ADD]]
| style="border-left:none;" | [[#SUB|SUB]]
| style="border-right:none;" | [[#ADC|ADC]]
| style="border-left:none;" | [[#SBB|SBB]]
| style="border-right:none;" | [[#INC|INC]]
| style="border-left:none;" | [[#DEC|DEC]]
| style="border-right:none;" | [[#MUL|MUL]]
| style="border-left:none;" | [[#DIV|DIV]]
| style="border-right:none;" | [[#IMUL|IMUL]]
| style="border-left:none;" | [[#IDIV|IDIV]]
| style="" | [[#CMP|CMP]]
| style="" | [[#NEG|NEG]]
| colspan="4" |
|-
| style="text-align:left;" | Numeric
| style="" | [[#CBW|CBW]]
| style="" | [[#CWD|CWD]]
| style="" | [[#AAA|AAA]]
| style="" | [[#AAS|AAS]]
| style="" | [[#AAM|AAM]]
| style="" | [[#AAD|AAD]]
| style="" | [[#DAA|DAA]]
| style="" | [[#DAS|DAS]]
| colspan="8" |
|-
| style="text-align:left;" | Shift
| style="border-right:none;" | [[#ROL|ROL]]
| style="border-left:none;" | [[#ROR|ROR]]
| style="border-right:none;" | [[#RCL|RCL]]
| style="border-left:none;" | [[#RCR|RCR]]
| style="border-right:none;" | [[#SHL|SHL]]
| style="border-left:none;" | [[#SHR|SHR]]
| style="" | [[#SAR|SAR]]
| colspan="9" |
|-
| style="text-align:left;" | Bitwise
| style="" | [[#AND|AND]]
| style="" | [[#OR|OR]]
| style="" | [[#XOR|XOR]]
| style="" | [[#NOT|NOT]]
| style="" | [[#TEST|TEST]]
| colspan="11" |
|-
| style="text-align:left;" | Branch
| style="border-right:none;" | [[#JC|JC]]
| style="border-left:none;" | [[#JNC|JNC]]
| style="border-right:none;" | [[#JZ|JZ]]
| style="border-left:none;" | [[#JNZ|JNZ]]
| style="border-right:none;" | [[#JBE|JBE]]
| style="border-left:none;" | [[#JA|JA]]
| style="border-right:none;" | [[#JO|JO]]
| style="border-left:none;" | [[#JNO|JNO]]
| style="border-right:none;" | [[#JP|JP]]
| style="border-left:none;" | [[#JNP|JNP]]
| style="border-right:none;" | [[#JS|JS]]
| style="border-left:none;" | [[#JNS|JNS]]
| style="border-right:none;" | [[#JL|JL]]
| style="border-left:none;" | [[#JGE|JGE]]
| style="border-right:none;" | [[#JLE|JLE]]
| style="border-left:none;" | [[#JG|JG]]
|-
| style="text-align:left;" | Jump
| style="" | [[#JMP|JMP]]
| style="border-right:none;" | [[#CALL|CALL]]
| style="border-left:none;border-right:none;" | [[#RET|RET]]
| style="border-left:none;" | [[#RETF|RETF]]
| colspan="12" |
|-
| style="text-align:left;" | Loop
| style="" | [[#LOOP|LOOP]]
| style="" | [[#LOOPE|LOOPE]]
| style="" | [[#LOOPNE|LOOPNE]]
| colspan="13" |
|-
| style="text-align:left;" | Interrupt
| style="border-right:none;" | [[#INT|INT]]
| style="border-left:none;" | [[#IRET|IRET]]
| style="" | [[#INTO|INTO]]
| style="" | [[#HLT|HLT]]
| style="" | [[#BOUND|BOUND]]
| colspan="11" |
|-
| style="text-align:left;" | Stack
| style="border-right:none;" | [[#PUSH|PUSH]]
| style="border-left:none;" | [[#POP|POP]]
| style="border-right:none;" | [[#PUSHA|PUSHA]]
| style="border-left:none;" | [[#POPA|POPA]]
| style="border-right:none;" | [[#PUSHF|PUSHF]]
| style="border-left:none;" | [[#POPF|POPF]]
| colspan="10" |
|-
| style="text-align:left;" | Flags
| style="border-right:none;" | [[#CLC|CLC]]
| style="border-left:none;" | [[#STC|STC]]
| style="border-right:none;" | [[#CLD|CLD]]
| style="border-left:none;" | [[#STD|STD]]
| style="border-right:none;" | [[#CLI|CLI]]
| style="border-left:none;" | [[#STI|STI]]
| style="" | [[#CMC|CMC]]
| style="border-right:none;" | [[#LAHF|LAHF]]
| style="border-left:none;" | [[#SAHF|SAHF]]
| colspan="7" |
|-
| style="text-align:left;" | Prefix
| style="" | [[#CS|CS]]
| style="" | [[#DS|DS]]
| style="" | [[#ES|ES]]
| style="" | [[#SS|SS]]
| colspan="12" |
|-
| style="text-align:left;" | String
| style="border-right:none;" | [[#REP|REP]]
| style="border-left:none;border-right:none;" | [[#REP|REPE]]
| style="border-left:none;" | [[#REPNE|REPNE]]
| style="" | [[#MOVSB|MOVSB]]
| style="" | [[#MOVSW|MOVSW]]
| style="border-right:none;" | [[#LODSB|LODSB]]
| style="border-left:none;" | [[#STOSB|STOSB]]
| style="border-right:none;" | [[#LODSW|LODSW]]
| style="border-left:none;" | [[#STOSW|STOSW]]
| style="" | [[#CMPSB|CMPSB]]
| style="" | [[#SCASB|SCASB]]
| style="" | [[#CMPSW|CMPSW]]
| style="" | [[#SCASW|SCASW]]
| colspan="3" |
|-
| style="text-align:left;" | Other
| style="" | [[#NOP|NOP]]
| style="border-right:none;" | [[#ENTER|ENTER]]
| style="border-left:none;" | [[#LEAVE|LEAVE]]
| style="" | [[#LOCK|LOCK]]
| style="" | [[#POLL|POLL]]
| colspan="11" |
|}
== Official instructions ==
{{Anchor|AAA}}
=== AAA ===
{{Anchor|AAD}}
=== AAD ===
{{Anchor|AAM}}
=== AAM ===
{{Anchor|AAS}}
=== AAS ===
{{Anchor|ADC}}
=== ADC ===
{{Anchor|ADD}}
=== ADD ===
{{Anchor|AND}}
=== AND ===
{{Anchor|BOUND}}
=== BOUND ===
{{Anchor|CALL}}
=== CALL ===
{{Anchor|CBW}}
=== CBW ===
{{Anchor|CLC}}
=== CLC ===
{{Anchor|CLD}}
=== CLD ===
{{Anchor|CLI}}
=== CLI ===
{{Anchor|CMC}}
=== CMC ===
{{Anchor|CMP}}
=== CMP ===
{{Anchor|CMPSB}}
=== CMPSB ===
{{Anchor|CMPSW}}
=== CMPSW ===
{{Anchor|CS}}
=== CS ===
{{Anchor|CWD}}
=== CWD ===
{{Anchor|DAA}}
=== DAA ===
{{Anchor|DAS}}
=== DAS ===
{{Anchor|DEC}}
=== DEC ===
{{Anchor|DIV}}
=== DIV ===
{{Anchor|DS}}
=== DS ===
{{Anchor|ENTER}}
=== ENTER ===
{{Anchor|ES}}
=== ES ===
{{Anchor|HLT}}
=== HLT ===
{{Anchor|IDIV}}
=== IDIV ===
{{Anchor|IMUL}}
=== IMUL ===
{{Anchor|IN}}
=== IN ===
{{Anchor|INC}}
=== INC ===
{{Anchor|INSB}}
=== INSB ===
{{Anchor|INSW}}
=== INSW ===
{{Anchor|INT}}
=== INT ===
{{Anchor|INTO}}
=== INTO ===
{{Anchor|IRET}}
=== IRET ===
{{Anchor|JA}}
=== JA ===
{{Anchor|JBE}}
=== JBE ===
{{Anchor|JC}}
=== JC/JB ===
{{Anchor|JCXZ}}
=== JCXZ ===
{{Anchor|JG}}
=== JG ===
{{Anchor|JGE}}
=== JGE ===
{{Anchor|JL}}
=== JL ===
{{Anchor|JLE}}
=== JLE ===
{{Anchor|JMP}}
=== JMP ===
{{Anchor|JNC}}
=== JNC/JAE ===
{{Anchor|JNO}}
=== JNO ===
{{Anchor|JNP}}
=== JNP ===
{{Anchor|JNS}}
=== JNS ===
{{Anchor|JNZ}}
=== JNZ/JNE ===
{{Anchor|JO}}
=== JO ===
{{Anchor|JP}}
=== JP ===
{{Anchor|JS}}
=== JS ===
{{Anchor|JZ}}
=== JZ/JE ===
{{Anchor|LAHF}}
=== LAHF ===
{{Anchor|LDS}}
=== LDS ===
{{Anchor|LEA}}
=== LEA ===
{{Anchor|LEAVE}}
=== LEAVE ===
{{Anchor|LES}}
=== LES ===
{{Anchor|LOCK}}
=== LOCK ===
{{Anchor|LODSB}}
=== LODSB ===
{{Anchor|LODSW}}
=== LODSW ===
{{Anchor|LOOP}}
=== LOOP ===
{{Anchor|LOOPE}}
=== LOOPE ===
{{Anchor|LOOPNE}}
=== LOOPNE ===
{{Anchor|MOV}}
=== MOV ===
{{Anchor|MOVSB}}
=== MOVSB ===
{{Anchor|MOVSW}}
=== MOVSW ===
{{Anchor|MUL}}
=== MUL ===
{{Anchor|NEG}}
=== NEG ===
{{Anchor|NOP}}
=== NOP ===
{{Anchor|NOT}}
=== NOT ===
{{Anchor|OR}}
=== OR ===
{{Anchor|OUT}}
=== OUT ===
{{Anchor|OUTSB}}
=== OUTSB ===
{{Anchor|OUTSW}}
=== OUTSW ===
{{Anchor|POLL}}
=== POLL ===
{{Anchor|POP}}
=== POP ===
{{Anchor|POPA}}
=== POPA ===
{{Anchor|POPF}}
=== POPF ===
{{Anchor|PUSH}}
=== PUSH ===
{{Anchor|PUSHA}}
=== PUSHA ===
{{Anchor|PUSHF}}
=== PUSHF ===
{{Anchor|RCL}}
=== RCL ===
{{Anchor|RCR}}
=== RCR ===
{{Anchor|REP}}
=== REP/REPE/REPZ ===
{{Anchor|REPNE}}
=== REPNE/REPNZ ===
{{Anchor|RET}}
=== RET ===
{{Anchor|RETF}}
=== RETF ===
{{Anchor|ROL}}
=== ROL ===
{{Anchor|ROR}}
=== ROR ===
{{Anchor|SAHF}}
=== SAHF ===
{{Anchor|SAR}}
=== SAR ===
{{Anchor|SBB}}
=== SBB ===
{{Anchor|SCASB}}
=== SCASB ===
{{Anchor|SCASW}}
=== SCASW ===
{{Anchor|SHL}}
=== SHL ===
{{Anchor|SHR}}
=== SHR ===
{{Anchor|SS}}
=== SS ===
{{Anchor|STC}}
=== STC ===
{{Anchor|STD}}
=== STD ===
{{Anchor|STI}}
=== STI ===
{{Anchor|STOSB}}
=== STOSB ===
{{Anchor|STOSW}}
=== STOSW ===
{{Anchor|SUB}}
=== SUB ===
{{Anchor|TEST}}
=== TEST ===
{{Anchor|XCHG}}
=== XCHG ===
{{Anchor|XLAT}}
=== XLAT ===
{{Anchor|XOR}}
=== XOR ===
0d7210c40961af4989a76a932abc106762294306
435
434
2024-12-26T14:45:39Z
Asie
351
add NEC opcode translation table, line separators
wikitext
text/x-wiki
__NOTOC__
{| class="wikitable" style="text-align: center"
|+ Official V30MZ (80186) Instructions
|-
| [[#AAA|AAA]] || [[#AAD|AAD]] || [[#AAM|AAM]] || [[#AAS|AAS]] || [[#ADC|ADC]] || [[#ADD|ADD]] || [[#AND|AND]] || [[#BOUND|BOUND]] || [[#CALL|CALL]] || [[#CBW|CBW]] || [[#CLC|CLC]]
|-
| [[#CLD|CLD]] || [[#CLI|CLI]] || [[#CMC|CMC]] || [[#CMP|CMP]] || [[#CMPSB|CMPSB]] || [[#CMPSW|CMPSW]] || [[#CS|CS]] || [[#CWD|CWD]] || [[#DAA|DAA]] || [[#DAS|DAS]] || [[#DEC|DEC]]
|-
| [[#DIV|DIV]] || [[#DS|DS]] || [[#ENTER|ENTER]] || [[#ES|ES]] || [[#HLT|HLT]] || [[#IDIV|IDIV]] || [[#IMUL|IMUL]] || [[#IN|IN]] || [[#INC|INC]] || [[#INSB|INSB]] || [[#INSW|INSW]]
|-
| [[#INT|INT]] || [[#INTO|INTO]] || [[#IRET|IRET]] || [[#JA|JA]] || [[#JBE|JBE]] || [[#JC|JC]] || [[#JCXZ|JCXZ]] || [[#JG|JG]] || [[#JGE|JGE]] || [[#JL|JL]] || [[#JLE|JLE]]
|-
| [[#JMP|JMP]] || [[#JNC|JNC]] || [[#JNO|JNO]] || [[#JNP|JNP]] || [[#JNS|JNS]] || [[#JNZ|JNZ]] || [[#JO|JO]] || [[#JP|JP]] || [[#JS|JS]] || [[#JZ|JZ]] || [[#LAHF|LAHF]]
|-
| [[#LDS|LDS]] || [[#LEA|LEA]] || [[#LEAVE|LEAVE]] || [[#LES|LES]] || [[#LOCK|LOCK]] || [[#LODSB|LODSB]] || [[#LODSW|LODSW]] || [[#LOOP|LOOP]] || [[#LOOPE|LOOPE]] || [[#LOOPNE|LOOPNE]] || [[#MOV|MOV]]
|-
| [[#MOVSB|MOVSB]] || [[#MOVSW|MOVSW]] || [[#MUL|MUL]] || [[#NEG|NEG]] || [[#NOP|NOP]] || [[#NOT|NOT]] || [[#OR|OR]] || [[#OUT|OUT]] || [[#OUTSB|OUTSB]] || [[#OUTSW|OUTSW]] || [[#POLL|POLL]]
|-
| [[#POP|POP]] || [[#POPA|POPA]] || [[#POPF|POPF]] || [[#PUSH|PUSH]] || [[#PUSHA|PUSHA]] || [[#PUSHF|PUSHF]] || [[#RCL|RCL]] || [[#RCR|RCR]] || [[#REP|REP]] || [[#REPNE|REPNE]] || [[#RET|RET]]
|-
| [[#RETF|RETF]] || [[#ROL|ROL]] || [[#ROR|ROR]] || [[#SAHF|SAHF]] || [[#SAR|SAR]] || [[#SBB|SBB]] || [[#SCASB|SCASB]] || [[#SCASW|SCASW]] || [[#SHL|SHL]] || [[#SHR|SHR]] || [[#SS|SS]]
|-
| [[#STC|STC]] || [[#STD|STD]] || [[#STI|STI]] || [[#STOSB|STOSB]] || [[#STOSW|STOSW]] || [[#SUB|SUB]] || [[#TEST|TEST]] || [[#XCHG|XCHG]] || [[#XLAT|XLAT]] || [[#XOR|XOR]]
|}
{| class="mw-collapsible mw-collapsed wikitable sortable" style="width: 340px;"
|+ style="white-space:nowrap; border:1px solid; padding:3px; border-color:rgb(162, 169, 177); background-color:rgb(234, 236, 240);" | Intel <-> NEC mnemonic translation table
!Intel
!NEC
|-
| [[#AAA|AAA]]
| [[#AAA|ADJBA]]
|-
| [[#AAD|AAD]]
| [[#AAD|CVTDB]]
|-
| [[#AAM|AAM]]
| [[#AAM|CVTBD]]
|-
| [[#AAS|AAS]]
| [[#AAS|ADJBS]]
|-
| [[#ADC|ADC]]
| [[#ADC|ADDC]]
|-
| [[#ADD|ADD]]
| [[#ADD|ADD]]
|-
| [[#AND|AND]]
| [[#AND|AND]]
|-
| [[#BOUND|BOUND]]
| [[#BOUND|CHKIND]]
|-
| [[#CALL|CALL]]
| [[#CALL|CALL]]
|-
| [[#CBW|CBW]]
| [[#CBW|CVTBW]]
|-
| [[#CLC|CLC]]
| [[#CLC|CLR1 CY]]
|-
| [[#CLD|CLD]]
| [[#CLD|CLR1 DIR]]
|-
| [[#CLI|CLI]]
| [[#CLI|DI]]
|-
| [[#CMC|CMC]]
| [[#CMC|NOT1 CY]]
|-
| [[#CMP|CMP]]
| [[#CMP|CMP]]
|-
| [[#CMPSB|CMPSB]]
| [[#CMPSB|CMPBKB]]
|-
| [[#CMPSW|CMPSW]]
| [[#CMPSW|CMPBKW]]
|-
| [[#CS|CS]]
| [[#CS|PS]]
|-
| [[#CWD|CWD]]
| [[#CWD|CVTWL]]
|-
| [[#DAA|DAA]]
| [[#DAA|ADJ4A]]
|-
| [[#DAS|DAS]]
| [[#DAS|ADJ4S]]
|-
| [[#DEC|DEC]]
| [[#DEC|DEC]]
|-
| [[#DIV|DIV]]
| [[#DIV|DIVU]]
|-
| [[#DS|DS]]
| [[#DS|DS0]]
|-
| [[#ENTER|ENTER]]
| [[#ENTER|PREPARE]]
|-
| [[#ES|ES]]
| [[#ES|DS1]]
|-
| [[#HLT|HLT]]
| [[#HLT|HALT]]
|-
| [[#IDIV|IDIV]]
| [[#IDIV|DIV]]
|-
| [[#IMUL|IMUL]]
| [[#IMUL|MUL]]
|-
| [[#IN|IN]]
| [[#IN|IN]]
|-
| [[#INC|INC]]
| [[#INC|INC]]
|-
| [[#INSB|INSB]]
| [[#INSB|INMB]]
|-
| [[#INSW|INSW]]
| [[#INSW|INMW]]
|-
| [[#INT|INT]]
| [[#INT|BRK]]
|-
| [[#INTO|INTO]]
| [[#INTO|BRKV]]
|-
| [[#IRET|IRET]]
| [[#IRET|RETI]]
|-
| [[#JA|JA]]
| [[#JA|BH]]
|-
| [[#JBE|JBE]]
| [[#JBE|BNH]]
|-
| [[#JC|JC/JB]]
| [[#JC|BC/BL]]
|-
| [[#JCXZ|JCXZ]]
| [[#JCXZ|BCWZ]]
|-
| [[#JG|JG]]
| [[#JG|BGT]]
|-
| [[#JGE|JGE]]
| [[#JGE|BGE]]
|-
| [[#JL|JL]]
| [[#JL|BLT]]
|-
| [[#JLE|JLE]]
| [[#JLE|BLE]]
|-
| [[#JMP|JMP]]
| [[#JMP|BR]]
|-
| [[#JNC|JNC/JAE]]
| [[#JNC|BNC/BNL]]
|-
| [[#JNO|JNO]]
| [[#JNO|BNV]]
|-
| [[#JNP|JNP]]
| [[#JNP|BPO]]
|-
| [[#JNS|JNS]]
| [[#JNS|BP]]
|-
| [[#JNZ|JNZ/JNE]]
| [[#JNZ|BNZ/BNE]]
|-
| [[#JO|JO]]
| [[#JO|BV]]
|-
| [[#JP|JP]]
| [[#JP|BPE]]
|-
| [[#JS|JS]]
| [[#JS|BN]]
|-
| [[#JZ|JZ/JE]]
| [[#JZ|BZ/BE]]
|-
| [[#LAHF|LAHF]]
| [[#LAHF|MOV]]
|-
| [[#LDS|LDS]]
| [[#LDS|MOV]]
|-
| [[#LEA|LEA]]
| [[#LEA|LDEA]]
|-
| [[#LEAVE|LEAVE]]
| [[#LEAVE|DISPOSE]]
|-
| [[#LES|LES]]
| [[#LES|MOV]]
|-
| [[#LOCK|LOCK]]
| [[#LOCK|BUSLOCK]]
|-
| [[#LODSB|LODSB]]
| [[#LODSB|LDMB]]
|-
| [[#LODSW|LODSW]]
| [[#LODSW|LDMW]]
|-
| [[#LOOP|LOOP]]
| [[#LOOP|DBNZ]]
|-
| [[#LOOPE|LOOPE]]
| [[#LOOPE|DBNZE]]
|-
| [[#LOOPNE|LOOPNE]]
| [[#LOOPNE|DBNZNE]]
|-
| [[#MOV|MOV]]
| [[#MOV|MOV]]
|-
| [[#MOVSB|MOVSB]]
| [[#MOVSB|MOVBKB]]
|-
| [[#MOVSW|MOVSW]]
| [[#MOVSW|MOVBKW]]
|-
| [[#MUL|MUL]]
| [[#MUL|MULU]]
|-
| [[#NEG|NEG]]
| [[#NEG|NEG]]
|-
| [[#NOP|NOP]]
| [[#NOP|NOP]]
|-
| [[#NOT|NOT]]
| [[#NOT|NOT]]
|-
| [[#OR|OR]]
| [[#OR|OR]]
|-
| [[#OUT|OUT]]
| [[#OUT|OUT]]
|-
| [[#OUTSB|OUTSB]]
| [[#OUTSB|OUTM]]
|-
| [[#OUTSW|OUTSW]]
| [[#OUTSW|OUTM]]
|-
| [[#POLL|POLL]]
| [[#POLL|POLL]]
|-
| [[#POP|POP]]
| [[#POP|POP]]
|-
| [[#POPA|POPA]]
| [[#POPA|POP]]
|-
| [[#POPF|POPF]]
| [[#POPF|POP]]
|-
| [[#PUSH|PUSH]]
| [[#PUSH|PUSH]]
|-
| [[#PUSHA|PUSHA]]
| [[#PUSHA|PUSH]]
|-
| [[#PUSHF|PUSHF]]
| [[#PUSHF|PUSH]]
|-
| [[#RCL|RCL]]
| [[#RCL|ROLC]]
|-
| [[#RCR|RCR]]
| [[#RCR|RORC]]
|-
| [[#REP|REP/REPE/REPZ]]
| [[#REP|REP/REPE/REPZ]]
|-
| [[#REPNE|REPNE/REPNZ]]
| [[#REPNE|REPNE/REPNZ]]
|-
| [[#RET|RET]]
| [[#RET|RET]]
|-
| [[#RETF|RETF]]
| [[#RETF|RET]]
|-
| [[#ROL|ROL]]
| [[#ROL|ROL]]
|-
| [[#ROR|ROR]]
| [[#ROR|ROR]]
|-
| [[#SAHF|SAHF]]
| [[#SAHF|MOV]]
|-
| [[#SAR|SAR]]
| [[#SAR|SHRA]]
|-
| [[#SBB|SBB]]
| [[#SBB|SUBC]]
|-
| [[#SCASB|SCASB]]
| [[#SCASB|CMPMB]]
|-
| [[#SCASW|SCASW]]
| [[#SCASW|CMPMW]]
|-
| [[#SHL|SHL]]
| [[#SHL|SHL]]
|-
| [[#SHR|SHR]]
| [[#SHR|SHR]]
|-
| [[#SS|SS]]
| [[#SS|SS]]
|-
| [[#STC|STC]]
| [[#STC|SET1 CY]]
|-
| [[#STD|STD]]
| [[#STD|SET1 DIR]]
|-
| [[#STI|STI]]
| [[#STI|EI]]
|-
| [[#STOSB|STOSB]]
| [[#STOSB|STMB]]
|-
| [[#STOSW|STOSW]]
| [[#STOSW|STMW]]
|-
| [[#SUB|SUB]]
| [[#SUB|SUB]]
|-
| [[#TEST|TEST]]
| [[#TEST|TEST]]
|-
| [[#XCHG|XCHG]]
| [[#XCHG|XCH]]
|-
| [[#XLAT|XLAT]]
| [[#XLAT|TRANS]]
|-
| [[#XOR|XOR]]
| [[#XOR|XOR]]
|}
== Official instructions by type ==
{| class="wikitable sortable" style="text-align: center"
!Type
!colspan=16 class="unsortable" | Instructions
|-
| style="text-align:left;" | Memory
| style="" | [[#MOV|MOV]]
| style="" | [[#XCHG|XCHG]]
| style="" | [[#XLAT|XLAT]]
| style="" | [[#LEA|LEA]]
| style="border-right:none;" | [[#LDS|LDS]]
| style="border-left:none;" | [[#LES|LES]]
| style="border-right:none;" | [[#IN|IN]]
| style="border-left:none;" | [[#OUT|OUT]]
| colspan="8" |
|-
| style="text-align:left;" | Ports
| style="border-right:none;" | [[#IN|IN]]
| style="border-left:none;" | [[#OUT|OUT]]
| style="border-right:none;" | [[#INSB|INSB]]
| style="border-left:none;" | [[#OUTSB|OUTSB]]
| style="border-right:none;" | [[#INSW|INSW]]
| style="border-left:none;" | [[#OUTSW|OUTSW]]
| colspan="10" |
|-
| style="text-align:left;" | Arithmetic
| style="border-right:none;" | [[#ADD|ADD]]
| style="border-left:none;" | [[#SUB|SUB]]
| style="border-right:none;" | [[#ADC|ADC]]
| style="border-left:none;" | [[#SBB|SBB]]
| style="border-right:none;" | [[#INC|INC]]
| style="border-left:none;" | [[#DEC|DEC]]
| style="border-right:none;" | [[#MUL|MUL]]
| style="border-left:none;" | [[#DIV|DIV]]
| style="border-right:none;" | [[#IMUL|IMUL]]
| style="border-left:none;" | [[#IDIV|IDIV]]
| style="" | [[#CMP|CMP]]
| style="" | [[#NEG|NEG]]
| colspan="4" |
|-
| style="text-align:left;" | Numeric
| style="" | [[#CBW|CBW]]
| style="" | [[#CWD|CWD]]
| style="" | [[#AAA|AAA]]
| style="" | [[#AAS|AAS]]
| style="" | [[#AAM|AAM]]
| style="" | [[#AAD|AAD]]
| style="" | [[#DAA|DAA]]
| style="" | [[#DAS|DAS]]
| colspan="8" |
|-
| style="text-align:left;" | Shift
| style="border-right:none;" | [[#ROL|ROL]]
| style="border-left:none;" | [[#ROR|ROR]]
| style="border-right:none;" | [[#RCL|RCL]]
| style="border-left:none;" | [[#RCR|RCR]]
| style="border-right:none;" | [[#SHL|SHL]]
| style="border-left:none;" | [[#SHR|SHR]]
| style="" | [[#SAR|SAR]]
| colspan="9" |
|-
| style="text-align:left;" | Bitwise
| style="" | [[#AND|AND]]
| style="" | [[#OR|OR]]
| style="" | [[#XOR|XOR]]
| style="" | [[#NOT|NOT]]
| style="" | [[#TEST|TEST]]
| colspan="11" |
|-
| style="text-align:left;" | Branch
| style="border-right:none;" | [[#JC|JC]]
| style="border-left:none;" | [[#JNC|JNC]]
| style="border-right:none;" | [[#JZ|JZ]]
| style="border-left:none;" | [[#JNZ|JNZ]]
| style="border-right:none;" | [[#JBE|JBE]]
| style="border-left:none;" | [[#JA|JA]]
| style="border-right:none;" | [[#JO|JO]]
| style="border-left:none;" | [[#JNO|JNO]]
| style="border-right:none;" | [[#JP|JP]]
| style="border-left:none;" | [[#JNP|JNP]]
| style="border-right:none;" | [[#JS|JS]]
| style="border-left:none;" | [[#JNS|JNS]]
| style="border-right:none;" | [[#JL|JL]]
| style="border-left:none;" | [[#JGE|JGE]]
| style="border-right:none;" | [[#JLE|JLE]]
| style="border-left:none;" | [[#JG|JG]]
|-
| style="text-align:left;" | Jump
| style="" | [[#JMP|JMP]]
| style="border-right:none;" | [[#CALL|CALL]]
| style="border-left:none;border-right:none;" | [[#RET|RET]]
| style="border-left:none;" | [[#RETF|RETF]]
| colspan="12" |
|-
| style="text-align:left;" | Loop
| style="" | [[#LOOP|LOOP]]
| style="" | [[#LOOPE|LOOPE]]
| style="" | [[#LOOPNE|LOOPNE]]
| colspan="13" |
|-
| style="text-align:left;" | Interrupt
| style="border-right:none;" | [[#INT|INT]]
| style="border-left:none;" | [[#IRET|IRET]]
| style="" | [[#INTO|INTO]]
| style="" | [[#HLT|HLT]]
| style="" | [[#BOUND|BOUND]]
| colspan="11" |
|-
| style="text-align:left;" | Stack
| style="border-right:none;" | [[#PUSH|PUSH]]
| style="border-left:none;" | [[#POP|POP]]
| style="border-right:none;" | [[#PUSHA|PUSHA]]
| style="border-left:none;" | [[#POPA|POPA]]
| style="border-right:none;" | [[#PUSHF|PUSHF]]
| style="border-left:none;" | [[#POPF|POPF]]
| colspan="10" |
|-
| style="text-align:left;" | Flags
| style="border-right:none;" | [[#CLC|CLC]]
| style="border-left:none;" | [[#STC|STC]]
| style="border-right:none;" | [[#CLD|CLD]]
| style="border-left:none;" | [[#STD|STD]]
| style="border-right:none;" | [[#CLI|CLI]]
| style="border-left:none;" | [[#STI|STI]]
| style="" | [[#CMC|CMC]]
| style="border-right:none;" | [[#LAHF|LAHF]]
| style="border-left:none;" | [[#SAHF|SAHF]]
| colspan="7" |
|-
| style="text-align:left;" | Prefix
| style="" | [[#CS|CS]]
| style="" | [[#DS|DS]]
| style="" | [[#ES|ES]]
| style="" | [[#SS|SS]]
| colspan="12" |
|-
| style="text-align:left;" | String
| style="border-right:none;" | [[#REP|REP]]
| style="border-left:none;border-right:none;" | [[#REP|REPE]]
| style="border-left:none;" | [[#REPNE|REPNE]]
| style="" | [[#MOVSB|MOVSB]]
| style="" | [[#MOVSW|MOVSW]]
| style="border-right:none;" | [[#LODSB|LODSB]]
| style="border-left:none;" | [[#STOSB|STOSB]]
| style="border-right:none;" | [[#LODSW|LODSW]]
| style="border-left:none;" | [[#STOSW|STOSW]]
| style="" | [[#CMPSB|CMPSB]]
| style="" | [[#SCASB|SCASB]]
| style="" | [[#CMPSW|CMPSW]]
| style="" | [[#SCASW|SCASW]]
| colspan="3" |
|-
| style="text-align:left;" | Other
| style="" | [[#NOP|NOP]]
| style="border-right:none;" | [[#ENTER|ENTER]]
| style="border-left:none;" | [[#LEAVE|LEAVE]]
| style="" | [[#LOCK|LOCK]]
| style="" | [[#POLL|POLL]]
| colspan="11" |
|}
== Official instructions ==
{{Anchor|AAA}}
=== AAA ===
----
{{Anchor|AAD}}
=== AAD ===
----
{{Anchor|AAM}}
=== AAM ===
----
{{Anchor|AAS}}
=== AAS ===
----
{{Anchor|ADC}}
=== ADC ===
----
{{Anchor|ADD}}
=== ADD ===
----
{{Anchor|AND}}
=== AND ===
----
{{Anchor|BOUND}}
=== BOUND ===
----
{{Anchor|CALL}}
=== CALL ===
----
{{Anchor|CBW}}
=== CBW ===
----
{{Anchor|CLC}}
=== CLC ===
----
{{Anchor|CLD}}
=== CLD ===
----
{{Anchor|CLI}}
=== CLI ===
----
{{Anchor|CMC}}
=== CMC ===
----
{{Anchor|CMP}}
=== CMP ===
----
{{Anchor|CMPSB}}
=== CMPSB ===
----
{{Anchor|CMPSW}}
=== CMPSW ===
----
{{Anchor|CS}}
=== CS ===
----
{{Anchor|CWD}}
=== CWD ===
----
{{Anchor|DAA}}
=== DAA ===
----
{{Anchor|DAS}}
=== DAS ===
----
{{Anchor|DEC}}
=== DEC ===
----
{{Anchor|DIV}}
=== DIV ===
----
{{Anchor|DS}}
=== DS ===
----
{{Anchor|ENTER}}
=== ENTER ===
----
{{Anchor|ES}}
=== ES ===
----
{{Anchor|HLT}}
=== HLT ===
----
{{Anchor|IDIV}}
=== IDIV ===
----
{{Anchor|IMUL}}
=== IMUL ===
----
{{Anchor|IN}}
=== IN ===
----
{{Anchor|INC}}
=== INC ===
----
{{Anchor|INSB}}
=== INSB ===
----
{{Anchor|INSW}}
=== INSW ===
----
{{Anchor|INT}}
=== INT ===
----
{{Anchor|INTO}}
=== INTO ===
----
{{Anchor|IRET}}
=== IRET ===
----
{{Anchor|JA}}
=== JA ===
----
{{Anchor|JBE}}
=== JBE ===
----
{{Anchor|JC}}
=== JC/JB ===
----
{{Anchor|JCXZ}}
=== JCXZ ===
----
{{Anchor|JG}}
=== JG ===
----
{{Anchor|JGE}}
=== JGE ===
----
{{Anchor|JL}}
=== JL ===
----
{{Anchor|JLE}}
=== JLE ===
----
{{Anchor|JMP}}
=== JMP ===
----
{{Anchor|JNC}}
=== JNC/JAE ===
----
{{Anchor|JNO}}
=== JNO ===
----
{{Anchor|JNP}}
=== JNP ===
----
{{Anchor|JNS}}
=== JNS ===
----
{{Anchor|JNZ}}
=== JNZ/JNE ===
----
{{Anchor|JO}}
=== JO ===
----
{{Anchor|JP}}
=== JP ===
----
{{Anchor|JS}}
=== JS ===
----
{{Anchor|JZ}}
=== JZ/JE ===
----
{{Anchor|LAHF}}
=== LAHF ===
----
{{Anchor|LDS}}
=== LDS ===
----
{{Anchor|LEA}}
=== LEA ===
----
{{Anchor|LEAVE}}
=== LEAVE ===
----
{{Anchor|LES}}
=== LES ===
----
{{Anchor|LOCK}}
=== LOCK ===
----
{{Anchor|LODSB}}
=== LODSB ===
----
{{Anchor|LODSW}}
=== LODSW ===
----
{{Anchor|LOOP}}
=== LOOP ===
----
{{Anchor|LOOPE}}
=== LOOPE ===
----
{{Anchor|LOOPNE}}
=== LOOPNE ===
----
{{Anchor|MOV}}
=== MOV ===
----
{{Anchor|MOVSB}}
=== MOVSB ===
----
{{Anchor|MOVSW}}
=== MOVSW ===
----
{{Anchor|MUL}}
=== MUL ===
----
{{Anchor|NEG}}
=== NEG ===
----
{{Anchor|NOP}}
=== NOP ===
----
{{Anchor|NOT}}
=== NOT ===
----
{{Anchor|OR}}
=== OR ===
----
{{Anchor|OUT}}
=== OUT ===
----
{{Anchor|OUTSB}}
=== OUTSB ===
----
{{Anchor|OUTSW}}
=== OUTSW ===
----
{{Anchor|POLL}}
=== POLL ===
----
{{Anchor|POP}}
=== POP ===
----
{{Anchor|POPA}}
=== POPA ===
----
{{Anchor|POPF}}
=== POPF ===
----
{{Anchor|PUSH}}
=== PUSH ===
----
{{Anchor|PUSHA}}
=== PUSHA ===
----
{{Anchor|PUSHF}}
=== PUSHF ===
----
{{Anchor|RCL}}
=== RCL ===
----
{{Anchor|RCR}}
=== RCR ===
----
{{Anchor|REP}}
=== REP/REPE/REPZ ===
----
{{Anchor|REPNE}}
=== REPNE/REPNZ ===
----
{{Anchor|RET}}
=== RET ===
----
{{Anchor|RETF}}
=== RETF ===
----
{{Anchor|ROL}}
=== ROL ===
----
{{Anchor|ROR}}
=== ROR ===
----
{{Anchor|SAHF}}
=== SAHF ===
----
{{Anchor|SAR}}
=== SAR ===
----
{{Anchor|SBB}}
=== SBB ===
----
{{Anchor|SCASB}}
=== SCASB ===
----
{{Anchor|SCASW}}
=== SCASW ===
----
{{Anchor|SHL}}
=== SHL ===
----
{{Anchor|SHR}}
=== SHR ===
----
{{Anchor|SS}}
=== SS ===
----
{{Anchor|STC}}
=== STC ===
----
{{Anchor|STD}}
=== STD ===
----
{{Anchor|STI}}
=== STI ===
----
{{Anchor|STOSB}}
=== STOSB ===
----
{{Anchor|STOSW}}
=== STOSW ===
----
{{Anchor|SUB}}
=== SUB ===
----
{{Anchor|TEST}}
=== TEST ===
----
{{Anchor|XCHG}}
=== XCHG ===
----
{{Anchor|XLAT}}
=== XLAT ===
----
{{Anchor|XOR}}
=== XOR ===
----
a3343a9e168cbacc3a5662720878ece8b8542393
436
435
2024-12-26T17:47:12Z
Asie
351
add modr/m byte section
wikitext
text/x-wiki
__NOTOC__
{| class="wikitable" style="text-align: center"
|+ Official V30MZ (80186) Instructions
|-
| [[#AAA|AAA]] || [[#AAD|AAD]] || [[#AAM|AAM]] || [[#AAS|AAS]] || [[#ADC|ADC]] || [[#ADD|ADD]] || [[#AND|AND]] || [[#BOUND|BOUND]] || [[#CALL|CALL]] || [[#CBW|CBW]] || [[#CLC|CLC]]
|-
| [[#CLD|CLD]] || [[#CLI|CLI]] || [[#CMC|CMC]] || [[#CMP|CMP]] || [[#CMPSB|CMPSB]] || [[#CMPSW|CMPSW]] || [[#CS|CS]] || [[#CWD|CWD]] || [[#DAA|DAA]] || [[#DAS|DAS]] || [[#DEC|DEC]]
|-
| [[#DIV|DIV]] || [[#DS|DS]] || [[#ENTER|ENTER]] || [[#ES|ES]] || [[#HLT|HLT]] || [[#IDIV|IDIV]] || [[#IMUL|IMUL]] || [[#IN|IN]] || [[#INC|INC]] || [[#INSB|INSB]] || [[#INSW|INSW]]
|-
| [[#INT|INT]] || [[#INTO|INTO]] || [[#IRET|IRET]] || [[#JA|JA]] || [[#JBE|JBE]] || [[#JC|JC]] || [[#JCXZ|JCXZ]] || [[#JG|JG]] || [[#JGE|JGE]] || [[#JL|JL]] || [[#JLE|JLE]]
|-
| [[#JMP|JMP]] || [[#JNC|JNC]] || [[#JNO|JNO]] || [[#JNP|JNP]] || [[#JNS|JNS]] || [[#JNZ|JNZ]] || [[#JO|JO]] || [[#JP|JP]] || [[#JS|JS]] || [[#JZ|JZ]] || [[#LAHF|LAHF]]
|-
| [[#LDS|LDS]] || [[#LEA|LEA]] || [[#LEAVE|LEAVE]] || [[#LES|LES]] || [[#LOCK|LOCK]] || [[#LODSB|LODSB]] || [[#LODSW|LODSW]] || [[#LOOP|LOOP]] || [[#LOOPE|LOOPE]] || [[#LOOPNE|LOOPNE]] || [[#MOV|MOV]]
|-
| [[#MOVSB|MOVSB]] || [[#MOVSW|MOVSW]] || [[#MUL|MUL]] || [[#NEG|NEG]] || [[#NOP|NOP]] || [[#NOT|NOT]] || [[#OR|OR]] || [[#OUT|OUT]] || [[#OUTSB|OUTSB]] || [[#OUTSW|OUTSW]] || [[#POLL|POLL]]
|-
| [[#POP|POP]] || [[#POPA|POPA]] || [[#POPF|POPF]] || [[#PUSH|PUSH]] || [[#PUSHA|PUSHA]] || [[#PUSHF|PUSHF]] || [[#RCL|RCL]] || [[#RCR|RCR]] || [[#REP|REP]] || [[#REPNE|REPNE]] || [[#RET|RET]]
|-
| [[#RETF|RETF]] || [[#ROL|ROL]] || [[#ROR|ROR]] || [[#SAHF|SAHF]] || [[#SAR|SAR]] || [[#SBB|SBB]] || [[#SCASB|SCASB]] || [[#SCASW|SCASW]] || [[#SHL|SHL]] || [[#SHR|SHR]] || [[#SS|SS]]
|-
| [[#STC|STC]] || [[#STD|STD]] || [[#STI|STI]] || [[#STOSB|STOSB]] || [[#STOSW|STOSW]] || [[#SUB|SUB]] || [[#TEST|TEST]] || [[#XCHG|XCHG]] || [[#XLAT|XLAT]] || [[#XOR|XOR]]
|}
{| class="mw-collapsible mw-collapsed wikitable sortable" style="width: 340px;"
|+ style="white-space:nowrap; border:1px solid; padding:3px; border-color:rgb(162, 169, 177); background-color:rgb(234, 236, 240);" | Intel <-> NEC mnemonic translation table
!Intel
!NEC
|-
| [[#AAA|AAA]]
| [[#AAA|ADJBA]]
|-
| [[#AAD|AAD]]
| [[#AAD|CVTDB]]
|-
| [[#AAM|AAM]]
| [[#AAM|CVTBD]]
|-
| [[#AAS|AAS]]
| [[#AAS|ADJBS]]
|-
| [[#ADC|ADC]]
| [[#ADC|ADDC]]
|-
| [[#ADD|ADD]]
| [[#ADD|ADD]]
|-
| [[#AND|AND]]
| [[#AND|AND]]
|-
| [[#BOUND|BOUND]]
| [[#BOUND|CHKIND]]
|-
| [[#CALL|CALL]]
| [[#CALL|CALL]]
|-
| [[#CBW|CBW]]
| [[#CBW|CVTBW]]
|-
| [[#CLC|CLC]]
| [[#CLC|CLR1 CY]]
|-
| [[#CLD|CLD]]
| [[#CLD|CLR1 DIR]]
|-
| [[#CLI|CLI]]
| [[#CLI|DI]]
|-
| [[#CMC|CMC]]
| [[#CMC|NOT1 CY]]
|-
| [[#CMP|CMP]]
| [[#CMP|CMP]]
|-
| [[#CMPSB|CMPSB]]
| [[#CMPSB|CMPBKB]]
|-
| [[#CMPSW|CMPSW]]
| [[#CMPSW|CMPBKW]]
|-
| [[#CS|CS]]
| [[#CS|PS]]
|-
| [[#CWD|CWD]]
| [[#CWD|CVTWL]]
|-
| [[#DAA|DAA]]
| [[#DAA|ADJ4A]]
|-
| [[#DAS|DAS]]
| [[#DAS|ADJ4S]]
|-
| [[#DEC|DEC]]
| [[#DEC|DEC]]
|-
| [[#DIV|DIV]]
| [[#DIV|DIVU]]
|-
| [[#DS|DS]]
| [[#DS|DS0]]
|-
| [[#ENTER|ENTER]]
| [[#ENTER|PREPARE]]
|-
| [[#ES|ES]]
| [[#ES|DS1]]
|-
| [[#HLT|HLT]]
| [[#HLT|HALT]]
|-
| [[#IDIV|IDIV]]
| [[#IDIV|DIV]]
|-
| [[#IMUL|IMUL]]
| [[#IMUL|MUL]]
|-
| [[#IN|IN]]
| [[#IN|IN]]
|-
| [[#INC|INC]]
| [[#INC|INC]]
|-
| [[#INSB|INSB]]
| [[#INSB|INMB]]
|-
| [[#INSW|INSW]]
| [[#INSW|INMW]]
|-
| [[#INT|INT]]
| [[#INT|BRK]]
|-
| [[#INTO|INTO]]
| [[#INTO|BRKV]]
|-
| [[#IRET|IRET]]
| [[#IRET|RETI]]
|-
| [[#JA|JA]]
| [[#JA|BH]]
|-
| [[#JBE|JBE]]
| [[#JBE|BNH]]
|-
| [[#JC|JC/JB]]
| [[#JC|BC/BL]]
|-
| [[#JCXZ|JCXZ]]
| [[#JCXZ|BCWZ]]
|-
| [[#JG|JG]]
| [[#JG|BGT]]
|-
| [[#JGE|JGE]]
| [[#JGE|BGE]]
|-
| [[#JL|JL]]
| [[#JL|BLT]]
|-
| [[#JLE|JLE]]
| [[#JLE|BLE]]
|-
| [[#JMP|JMP]]
| [[#JMP|BR]]
|-
| [[#JNC|JNC/JAE]]
| [[#JNC|BNC/BNL]]
|-
| [[#JNO|JNO]]
| [[#JNO|BNV]]
|-
| [[#JNP|JNP]]
| [[#JNP|BPO]]
|-
| [[#JNS|JNS]]
| [[#JNS|BP]]
|-
| [[#JNZ|JNZ/JNE]]
| [[#JNZ|BNZ/BNE]]
|-
| [[#JO|JO]]
| [[#JO|BV]]
|-
| [[#JP|JP]]
| [[#JP|BPE]]
|-
| [[#JS|JS]]
| [[#JS|BN]]
|-
| [[#JZ|JZ/JE]]
| [[#JZ|BZ/BE]]
|-
| [[#LAHF|LAHF]]
| [[#LAHF|MOV]]
|-
| [[#LDS|LDS]]
| [[#LDS|MOV]]
|-
| [[#LEA|LEA]]
| [[#LEA|LDEA]]
|-
| [[#LEAVE|LEAVE]]
| [[#LEAVE|DISPOSE]]
|-
| [[#LES|LES]]
| [[#LES|MOV]]
|-
| [[#LOCK|LOCK]]
| [[#LOCK|BUSLOCK]]
|-
| [[#LODSB|LODSB]]
| [[#LODSB|LDMB]]
|-
| [[#LODSW|LODSW]]
| [[#LODSW|LDMW]]
|-
| [[#LOOP|LOOP]]
| [[#LOOP|DBNZ]]
|-
| [[#LOOPE|LOOPE]]
| [[#LOOPE|DBNZE]]
|-
| [[#LOOPNE|LOOPNE]]
| [[#LOOPNE|DBNZNE]]
|-
| [[#MOV|MOV]]
| [[#MOV|MOV]]
|-
| [[#MOVSB|MOVSB]]
| [[#MOVSB|MOVBKB]]
|-
| [[#MOVSW|MOVSW]]
| [[#MOVSW|MOVBKW]]
|-
| [[#MUL|MUL]]
| [[#MUL|MULU]]
|-
| [[#NEG|NEG]]
| [[#NEG|NEG]]
|-
| [[#NOP|NOP]]
| [[#NOP|NOP]]
|-
| [[#NOT|NOT]]
| [[#NOT|NOT]]
|-
| [[#OR|OR]]
| [[#OR|OR]]
|-
| [[#OUT|OUT]]
| [[#OUT|OUT]]
|-
| [[#OUTSB|OUTSB]]
| [[#OUTSB|OUTM]]
|-
| [[#OUTSW|OUTSW]]
| [[#OUTSW|OUTM]]
|-
| [[#POLL|POLL]]
| [[#POLL|POLL]]
|-
| [[#POP|POP]]
| [[#POP|POP]]
|-
| [[#POPA|POPA]]
| [[#POPA|POP]]
|-
| [[#POPF|POPF]]
| [[#POPF|POP]]
|-
| [[#PUSH|PUSH]]
| [[#PUSH|PUSH]]
|-
| [[#PUSHA|PUSHA]]
| [[#PUSHA|PUSH]]
|-
| [[#PUSHF|PUSHF]]
| [[#PUSHF|PUSH]]
|-
| [[#RCL|RCL]]
| [[#RCL|ROLC]]
|-
| [[#RCR|RCR]]
| [[#RCR|RORC]]
|-
| [[#REP|REP/REPE/REPZ]]
| [[#REP|REP/REPE/REPZ]]
|-
| [[#REPNE|REPNE/REPNZ]]
| [[#REPNE|REPNE/REPNZ]]
|-
| [[#RET|RET]]
| [[#RET|RET]]
|-
| [[#RETF|RETF]]
| [[#RETF|RET]]
|-
| [[#ROL|ROL]]
| [[#ROL|ROL]]
|-
| [[#ROR|ROR]]
| [[#ROR|ROR]]
|-
| [[#SAHF|SAHF]]
| [[#SAHF|MOV]]
|-
| [[#SAR|SAR]]
| [[#SAR|SHRA]]
|-
| [[#SBB|SBB]]
| [[#SBB|SUBC]]
|-
| [[#SCASB|SCASB]]
| [[#SCASB|CMPMB]]
|-
| [[#SCASW|SCASW]]
| [[#SCASW|CMPMW]]
|-
| [[#SHL|SHL]]
| [[#SHL|SHL]]
|-
| [[#SHR|SHR]]
| [[#SHR|SHR]]
|-
| [[#SS|SS]]
| [[#SS|SS]]
|-
| [[#STC|STC]]
| [[#STC|SET1 CY]]
|-
| [[#STD|STD]]
| [[#STD|SET1 DIR]]
|-
| [[#STI|STI]]
| [[#STI|EI]]
|-
| [[#STOSB|STOSB]]
| [[#STOSB|STMB]]
|-
| [[#STOSW|STOSW]]
| [[#STOSW|STMW]]
|-
| [[#SUB|SUB]]
| [[#SUB|SUB]]
|-
| [[#TEST|TEST]]
| [[#TEST|TEST]]
|-
| [[#XCHG|XCHG]]
| [[#XCHG|XCH]]
|-
| [[#XLAT|XLAT]]
| [[#XLAT|TRANS]]
|-
| [[#XOR|XOR]]
| [[#XOR|XOR]]
|}
== Official instructions by type ==
{| class="wikitable sortable" style="text-align: center"
!Type
!colspan=16 class="unsortable" | Instructions
|-
| style="text-align:left;" | Memory
| style="" | [[#MOV|MOV]]
| style="" | [[#XCHG|XCHG]]
| style="" | [[#XLAT|XLAT]]
| style="" | [[#LEA|LEA]]
| style="border-right:none;" | [[#LDS|LDS]]
| style="border-left:none;" | [[#LES|LES]]
| style="border-right:none;" | [[#IN|IN]]
| style="border-left:none;" | [[#OUT|OUT]]
| colspan="8" |
|-
| style="text-align:left;" | Ports
| style="border-right:none;" | [[#IN|IN]]
| style="border-left:none;" | [[#OUT|OUT]]
| style="border-right:none;" | [[#INSB|INSB]]
| style="border-left:none;" | [[#OUTSB|OUTSB]]
| style="border-right:none;" | [[#INSW|INSW]]
| style="border-left:none;" | [[#OUTSW|OUTSW]]
| colspan="10" |
|-
| style="text-align:left;" | Arithmetic
| style="border-right:none;" | [[#ADD|ADD]]
| style="border-left:none;" | [[#SUB|SUB]]
| style="border-right:none;" | [[#ADC|ADC]]
| style="border-left:none;" | [[#SBB|SBB]]
| style="border-right:none;" | [[#INC|INC]]
| style="border-left:none;" | [[#DEC|DEC]]
| style="border-right:none;" | [[#MUL|MUL]]
| style="border-left:none;" | [[#DIV|DIV]]
| style="border-right:none;" | [[#IMUL|IMUL]]
| style="border-left:none;" | [[#IDIV|IDIV]]
| style="" | [[#CMP|CMP]]
| style="" | [[#NEG|NEG]]
| colspan="4" |
|-
| style="text-align:left;" | Numeric
| style="" | [[#CBW|CBW]]
| style="" | [[#CWD|CWD]]
| style="" | [[#AAA|AAA]]
| style="" | [[#AAS|AAS]]
| style="" | [[#AAM|AAM]]
| style="" | [[#AAD|AAD]]
| style="" | [[#DAA|DAA]]
| style="" | [[#DAS|DAS]]
| colspan="8" |
|-
| style="text-align:left;" | Shift
| style="border-right:none;" | [[#ROL|ROL]]
| style="border-left:none;" | [[#ROR|ROR]]
| style="border-right:none;" | [[#RCL|RCL]]
| style="border-left:none;" | [[#RCR|RCR]]
| style="border-right:none;" | [[#SHL|SHL]]
| style="border-left:none;" | [[#SHR|SHR]]
| style="" | [[#SAR|SAR]]
| colspan="9" |
|-
| style="text-align:left;" | Bitwise
| style="" | [[#AND|AND]]
| style="" | [[#OR|OR]]
| style="" | [[#XOR|XOR]]
| style="" | [[#NOT|NOT]]
| style="" | [[#TEST|TEST]]
| colspan="11" |
|-
| style="text-align:left;" | Branch
| style="border-right:none;" | [[#JC|JC]]
| style="border-left:none;" | [[#JNC|JNC]]
| style="border-right:none;" | [[#JZ|JZ]]
| style="border-left:none;" | [[#JNZ|JNZ]]
| style="border-right:none;" | [[#JBE|JBE]]
| style="border-left:none;" | [[#JA|JA]]
| style="border-right:none;" | [[#JO|JO]]
| style="border-left:none;" | [[#JNO|JNO]]
| style="border-right:none;" | [[#JP|JP]]
| style="border-left:none;" | [[#JNP|JNP]]
| style="border-right:none;" | [[#JS|JS]]
| style="border-left:none;" | [[#JNS|JNS]]
| style="border-right:none;" | [[#JL|JL]]
| style="border-left:none;" | [[#JGE|JGE]]
| style="border-right:none;" | [[#JLE|JLE]]
| style="border-left:none;" | [[#JG|JG]]
|-
| style="text-align:left;" | Jump
| style="" | [[#JMP|JMP]]
| style="border-right:none;" | [[#CALL|CALL]]
| style="border-left:none;border-right:none;" | [[#RET|RET]]
| style="border-left:none;" | [[#RETF|RETF]]
| colspan="12" |
|-
| style="text-align:left;" | Loop
| style="" | [[#LOOP|LOOP]]
| style="" | [[#LOOPE|LOOPE]]
| style="" | [[#LOOPNE|LOOPNE]]
| colspan="13" |
|-
| style="text-align:left;" | Interrupt
| style="border-right:none;" | [[#INT|INT]]
| style="border-left:none;" | [[#IRET|IRET]]
| style="" | [[#INTO|INTO]]
| style="" | [[#HLT|HLT]]
| style="" | [[#BOUND|BOUND]]
| colspan="11" |
|-
| style="text-align:left;" | Stack
| style="border-right:none;" | [[#PUSH|PUSH]]
| style="border-left:none;" | [[#POP|POP]]
| style="border-right:none;" | [[#PUSHA|PUSHA]]
| style="border-left:none;" | [[#POPA|POPA]]
| style="border-right:none;" | [[#PUSHF|PUSHF]]
| style="border-left:none;" | [[#POPF|POPF]]
| colspan="10" |
|-
| style="text-align:left;" | Flags
| style="border-right:none;" | [[#CLC|CLC]]
| style="border-left:none;" | [[#STC|STC]]
| style="border-right:none;" | [[#CLD|CLD]]
| style="border-left:none;" | [[#STD|STD]]
| style="border-right:none;" | [[#CLI|CLI]]
| style="border-left:none;" | [[#STI|STI]]
| style="" | [[#CMC|CMC]]
| style="border-right:none;" | [[#LAHF|LAHF]]
| style="border-left:none;" | [[#SAHF|SAHF]]
| colspan="7" |
|-
| style="text-align:left;" | Prefix
| style="" | [[#CS|CS]]
| style="" | [[#DS|DS]]
| style="" | [[#ES|ES]]
| style="" | [[#SS|SS]]
| colspan="12" |
|-
| style="text-align:left;" | String
| style="border-right:none;" | [[#REP|REP]]
| style="border-left:none;border-right:none;" | [[#REP|REPE]]
| style="border-left:none;" | [[#REPNE|REPNE]]
| style="" | [[#MOVSB|MOVSB]]
| style="" | [[#MOVSW|MOVSW]]
| style="border-right:none;" | [[#LODSB|LODSB]]
| style="border-left:none;" | [[#STOSB|STOSB]]
| style="border-right:none;" | [[#LODSW|LODSW]]
| style="border-left:none;" | [[#STOSW|STOSW]]
| style="" | [[#CMPSB|CMPSB]]
| style="" | [[#SCASB|SCASB]]
| style="" | [[#CMPSW|CMPSW]]
| style="" | [[#SCASW|SCASW]]
| colspan="3" |
|-
| style="text-align:left;" | Other
| style="" | [[#NOP|NOP]]
| style="border-right:none;" | [[#ENTER|ENTER]]
| style="border-left:none;" | [[#LEAVE|LEAVE]]
| style="" | [[#LOCK|LOCK]]
| style="" | [[#POLL|POLL]]
| colspan="11" |
|}
== Instruction encoding ==
=== ModR/M byte ===
== Official instructions ==
{{Anchor|AAA}}
=== AAA ===
----
{{Anchor|AAD}}
=== AAD ===
----
{{Anchor|AAM}}
=== AAM ===
----
{{Anchor|AAS}}
=== AAS ===
----
{{Anchor|ADC}}
=== ADC ===
----
{{Anchor|ADD}}
=== ADD ===
----
{{Anchor|AND}}
=== AND ===
----
{{Anchor|BOUND}}
=== BOUND ===
----
{{Anchor|CALL}}
=== CALL ===
----
{{Anchor|CBW}}
=== CBW ===
----
{{Anchor|CLC}}
=== CLC ===
----
{{Anchor|CLD}}
=== CLD ===
----
{{Anchor|CLI}}
=== CLI ===
----
{{Anchor|CMC}}
=== CMC ===
----
{{Anchor|CMP}}
=== CMP ===
----
{{Anchor|CMPSB}}
=== CMPSB ===
----
{{Anchor|CMPSW}}
=== CMPSW ===
----
{{Anchor|CS}}
=== CS ===
----
{{Anchor|CWD}}
=== CWD ===
----
{{Anchor|DAA}}
=== DAA ===
----
{{Anchor|DAS}}
=== DAS ===
----
{{Anchor|DEC}}
=== DEC ===
----
{{Anchor|DIV}}
=== DIV ===
----
{{Anchor|DS}}
=== DS ===
----
{{Anchor|ENTER}}
=== ENTER ===
----
{{Anchor|ES}}
=== ES ===
----
{{Anchor|HLT}}
=== HLT ===
----
{{Anchor|IDIV}}
=== IDIV ===
----
{{Anchor|IMUL}}
=== IMUL ===
----
{{Anchor|IN}}
=== IN ===
----
{{Anchor|INC}}
=== INC ===
----
{{Anchor|INSB}}
=== INSB ===
----
{{Anchor|INSW}}
=== INSW ===
----
{{Anchor|INT}}
=== INT ===
----
{{Anchor|INTO}}
=== INTO ===
----
{{Anchor|IRET}}
=== IRET ===
----
{{Anchor|JA}}
=== JA ===
----
{{Anchor|JBE}}
=== JBE ===
----
{{Anchor|JC}}
=== JC/JB ===
----
{{Anchor|JCXZ}}
=== JCXZ ===
----
{{Anchor|JG}}
=== JG ===
----
{{Anchor|JGE}}
=== JGE ===
----
{{Anchor|JL}}
=== JL ===
----
{{Anchor|JLE}}
=== JLE ===
----
{{Anchor|JMP}}
=== JMP ===
----
{{Anchor|JNC}}
=== JNC/JAE ===
----
{{Anchor|JNO}}
=== JNO ===
----
{{Anchor|JNP}}
=== JNP ===
----
{{Anchor|JNS}}
=== JNS ===
----
{{Anchor|JNZ}}
=== JNZ/JNE ===
----
{{Anchor|JO}}
=== JO ===
----
{{Anchor|JP}}
=== JP ===
----
{{Anchor|JS}}
=== JS ===
----
{{Anchor|JZ}}
=== JZ/JE ===
----
{{Anchor|LAHF}}
=== LAHF ===
----
{{Anchor|LDS}}
=== LDS ===
----
{{Anchor|LEA}}
=== LEA ===
----
{{Anchor|LEAVE}}
=== LEAVE ===
----
{{Anchor|LES}}
=== LES ===
----
{{Anchor|LOCK}}
=== LOCK ===
----
{{Anchor|LODSB}}
=== LODSB ===
----
{{Anchor|LODSW}}
=== LODSW ===
----
{{Anchor|LOOP}}
=== LOOP ===
----
{{Anchor|LOOPE}}
=== LOOPE ===
----
{{Anchor|LOOPNE}}
=== LOOPNE ===
----
{{Anchor|MOV}}
=== MOV ===
----
{{Anchor|MOVSB}}
=== MOVSB ===
----
{{Anchor|MOVSW}}
=== MOVSW ===
----
{{Anchor|MUL}}
=== MUL ===
----
{{Anchor|NEG}}
=== NEG ===
----
{{Anchor|NOP}}
=== NOP ===
----
{{Anchor|NOT}}
=== NOT ===
----
{{Anchor|OR}}
=== OR ===
----
{{Anchor|OUT}}
=== OUT ===
----
{{Anchor|OUTSB}}
=== OUTSB ===
----
{{Anchor|OUTSW}}
=== OUTSW ===
----
{{Anchor|POLL}}
=== POLL ===
----
{{Anchor|POP}}
=== POP ===
----
{{Anchor|POPA}}
=== POPA ===
----
{{Anchor|POPF}}
=== POPF ===
----
{{Anchor|PUSH}}
=== PUSH ===
----
{{Anchor|PUSHA}}
=== PUSHA ===
----
{{Anchor|PUSHF}}
=== PUSHF ===
----
{{Anchor|RCL}}
=== RCL ===
----
{{Anchor|RCR}}
=== RCR ===
----
{{Anchor|REP}}
=== REP/REPE/REPZ ===
----
{{Anchor|REPNE}}
=== REPNE/REPNZ ===
----
{{Anchor|RET}}
=== RET ===
----
{{Anchor|RETF}}
=== RETF ===
----
{{Anchor|ROL}}
=== ROL ===
----
{{Anchor|ROR}}
=== ROR ===
----
{{Anchor|SAHF}}
=== SAHF ===
----
{{Anchor|SAR}}
=== SAR ===
----
{{Anchor|SBB}}
=== SBB ===
----
{{Anchor|SCASB}}
=== SCASB ===
----
{{Anchor|SCASW}}
=== SCASW ===
----
{{Anchor|SHL}}
=== SHL ===
----
{{Anchor|SHR}}
=== SHR ===
----
{{Anchor|SS}}
=== SS ===
----
{{Anchor|STC}}
=== STC ===
----
{{Anchor|STD}}
=== STD ===
----
{{Anchor|STI}}
=== STI ===
----
{{Anchor|STOSB}}
=== STOSB ===
----
{{Anchor|STOSW}}
=== STOSW ===
----
{{Anchor|SUB}}
=== SUB ===
----
{{Anchor|TEST}}
=== TEST ===
----
{{Anchor|XCHG}}
=== XCHG ===
----
{{Anchor|XLAT}}
=== XLAT ===
----
{{Anchor|XOR}}
=== XOR ===
----
8d80146217376a4dda1effc28ad7e99c9ce72643
437
436
2024-12-26T18:02:14Z
Asie
351
/* ModR/M byte */
wikitext
text/x-wiki
__NOTOC__
{| class="wikitable" style="text-align: center"
|+ Official V30MZ (80186) Instructions
|-
| [[#AAA|AAA]] || [[#AAD|AAD]] || [[#AAM|AAM]] || [[#AAS|AAS]] || [[#ADC|ADC]] || [[#ADD|ADD]] || [[#AND|AND]] || [[#BOUND|BOUND]] || [[#CALL|CALL]] || [[#CBW|CBW]] || [[#CLC|CLC]]
|-
| [[#CLD|CLD]] || [[#CLI|CLI]] || [[#CMC|CMC]] || [[#CMP|CMP]] || [[#CMPSB|CMPSB]] || [[#CMPSW|CMPSW]] || [[#CS|CS]] || [[#CWD|CWD]] || [[#DAA|DAA]] || [[#DAS|DAS]] || [[#DEC|DEC]]
|-
| [[#DIV|DIV]] || [[#DS|DS]] || [[#ENTER|ENTER]] || [[#ES|ES]] || [[#HLT|HLT]] || [[#IDIV|IDIV]] || [[#IMUL|IMUL]] || [[#IN|IN]] || [[#INC|INC]] || [[#INSB|INSB]] || [[#INSW|INSW]]
|-
| [[#INT|INT]] || [[#INTO|INTO]] || [[#IRET|IRET]] || [[#JA|JA]] || [[#JBE|JBE]] || [[#JC|JC]] || [[#JCXZ|JCXZ]] || [[#JG|JG]] || [[#JGE|JGE]] || [[#JL|JL]] || [[#JLE|JLE]]
|-
| [[#JMP|JMP]] || [[#JNC|JNC]] || [[#JNO|JNO]] || [[#JNP|JNP]] || [[#JNS|JNS]] || [[#JNZ|JNZ]] || [[#JO|JO]] || [[#JP|JP]] || [[#JS|JS]] || [[#JZ|JZ]] || [[#LAHF|LAHF]]
|-
| [[#LDS|LDS]] || [[#LEA|LEA]] || [[#LEAVE|LEAVE]] || [[#LES|LES]] || [[#LOCK|LOCK]] || [[#LODSB|LODSB]] || [[#LODSW|LODSW]] || [[#LOOP|LOOP]] || [[#LOOPE|LOOPE]] || [[#LOOPNE|LOOPNE]] || [[#MOV|MOV]]
|-
| [[#MOVSB|MOVSB]] || [[#MOVSW|MOVSW]] || [[#MUL|MUL]] || [[#NEG|NEG]] || [[#NOP|NOP]] || [[#NOT|NOT]] || [[#OR|OR]] || [[#OUT|OUT]] || [[#OUTSB|OUTSB]] || [[#OUTSW|OUTSW]] || [[#POLL|POLL]]
|-
| [[#POP|POP]] || [[#POPA|POPA]] || [[#POPF|POPF]] || [[#PUSH|PUSH]] || [[#PUSHA|PUSHA]] || [[#PUSHF|PUSHF]] || [[#RCL|RCL]] || [[#RCR|RCR]] || [[#REP|REP]] || [[#REPNE|REPNE]] || [[#RET|RET]]
|-
| [[#RETF|RETF]] || [[#ROL|ROL]] || [[#ROR|ROR]] || [[#SAHF|SAHF]] || [[#SAR|SAR]] || [[#SBB|SBB]] || [[#SCASB|SCASB]] || [[#SCASW|SCASW]] || [[#SHL|SHL]] || [[#SHR|SHR]] || [[#SS|SS]]
|-
| [[#STC|STC]] || [[#STD|STD]] || [[#STI|STI]] || [[#STOSB|STOSB]] || [[#STOSW|STOSW]] || [[#SUB|SUB]] || [[#TEST|TEST]] || [[#XCHG|XCHG]] || [[#XLAT|XLAT]] || [[#XOR|XOR]]
|}
{| class="mw-collapsible mw-collapsed wikitable sortable" style="width: 340px;"
|+ style="white-space:nowrap; border:1px solid; padding:3px; border-color:rgb(162, 169, 177); background-color:rgb(234, 236, 240);" | Intel <-> NEC mnemonic translation table
!Intel
!NEC
|-
| [[#AAA|AAA]]
| [[#AAA|ADJBA]]
|-
| [[#AAD|AAD]]
| [[#AAD|CVTDB]]
|-
| [[#AAM|AAM]]
| [[#AAM|CVTBD]]
|-
| [[#AAS|AAS]]
| [[#AAS|ADJBS]]
|-
| [[#ADC|ADC]]
| [[#ADC|ADDC]]
|-
| [[#ADD|ADD]]
| [[#ADD|ADD]]
|-
| [[#AND|AND]]
| [[#AND|AND]]
|-
| [[#BOUND|BOUND]]
| [[#BOUND|CHKIND]]
|-
| [[#CALL|CALL]]
| [[#CALL|CALL]]
|-
| [[#CBW|CBW]]
| [[#CBW|CVTBW]]
|-
| [[#CLC|CLC]]
| [[#CLC|CLR1 CY]]
|-
| [[#CLD|CLD]]
| [[#CLD|CLR1 DIR]]
|-
| [[#CLI|CLI]]
| [[#CLI|DI]]
|-
| [[#CMC|CMC]]
| [[#CMC|NOT1 CY]]
|-
| [[#CMP|CMP]]
| [[#CMP|CMP]]
|-
| [[#CMPSB|CMPSB]]
| [[#CMPSB|CMPBKB]]
|-
| [[#CMPSW|CMPSW]]
| [[#CMPSW|CMPBKW]]
|-
| [[#CS|CS]]
| [[#CS|PS]]
|-
| [[#CWD|CWD]]
| [[#CWD|CVTWL]]
|-
| [[#DAA|DAA]]
| [[#DAA|ADJ4A]]
|-
| [[#DAS|DAS]]
| [[#DAS|ADJ4S]]
|-
| [[#DEC|DEC]]
| [[#DEC|DEC]]
|-
| [[#DIV|DIV]]
| [[#DIV|DIVU]]
|-
| [[#DS|DS]]
| [[#DS|DS0]]
|-
| [[#ENTER|ENTER]]
| [[#ENTER|PREPARE]]
|-
| [[#ES|ES]]
| [[#ES|DS1]]
|-
| [[#HLT|HLT]]
| [[#HLT|HALT]]
|-
| [[#IDIV|IDIV]]
| [[#IDIV|DIV]]
|-
| [[#IMUL|IMUL]]
| [[#IMUL|MUL]]
|-
| [[#IN|IN]]
| [[#IN|IN]]
|-
| [[#INC|INC]]
| [[#INC|INC]]
|-
| [[#INSB|INSB]]
| [[#INSB|INMB]]
|-
| [[#INSW|INSW]]
| [[#INSW|INMW]]
|-
| [[#INT|INT]]
| [[#INT|BRK]]
|-
| [[#INTO|INTO]]
| [[#INTO|BRKV]]
|-
| [[#IRET|IRET]]
| [[#IRET|RETI]]
|-
| [[#JA|JA]]
| [[#JA|BH]]
|-
| [[#JBE|JBE]]
| [[#JBE|BNH]]
|-
| [[#JC|JC/JB]]
| [[#JC|BC/BL]]
|-
| [[#JCXZ|JCXZ]]
| [[#JCXZ|BCWZ]]
|-
| [[#JG|JG]]
| [[#JG|BGT]]
|-
| [[#JGE|JGE]]
| [[#JGE|BGE]]
|-
| [[#JL|JL]]
| [[#JL|BLT]]
|-
| [[#JLE|JLE]]
| [[#JLE|BLE]]
|-
| [[#JMP|JMP]]
| [[#JMP|BR]]
|-
| [[#JNC|JNC/JAE]]
| [[#JNC|BNC/BNL]]
|-
| [[#JNO|JNO]]
| [[#JNO|BNV]]
|-
| [[#JNP|JNP]]
| [[#JNP|BPO]]
|-
| [[#JNS|JNS]]
| [[#JNS|BP]]
|-
| [[#JNZ|JNZ/JNE]]
| [[#JNZ|BNZ/BNE]]
|-
| [[#JO|JO]]
| [[#JO|BV]]
|-
| [[#JP|JP]]
| [[#JP|BPE]]
|-
| [[#JS|JS]]
| [[#JS|BN]]
|-
| [[#JZ|JZ/JE]]
| [[#JZ|BZ/BE]]
|-
| [[#LAHF|LAHF]]
| [[#LAHF|MOV]]
|-
| [[#LDS|LDS]]
| [[#LDS|MOV]]
|-
| [[#LEA|LEA]]
| [[#LEA|LDEA]]
|-
| [[#LEAVE|LEAVE]]
| [[#LEAVE|DISPOSE]]
|-
| [[#LES|LES]]
| [[#LES|MOV]]
|-
| [[#LOCK|LOCK]]
| [[#LOCK|BUSLOCK]]
|-
| [[#LODSB|LODSB]]
| [[#LODSB|LDMB]]
|-
| [[#LODSW|LODSW]]
| [[#LODSW|LDMW]]
|-
| [[#LOOP|LOOP]]
| [[#LOOP|DBNZ]]
|-
| [[#LOOPE|LOOPE]]
| [[#LOOPE|DBNZE]]
|-
| [[#LOOPNE|LOOPNE]]
| [[#LOOPNE|DBNZNE]]
|-
| [[#MOV|MOV]]
| [[#MOV|MOV]]
|-
| [[#MOVSB|MOVSB]]
| [[#MOVSB|MOVBKB]]
|-
| [[#MOVSW|MOVSW]]
| [[#MOVSW|MOVBKW]]
|-
| [[#MUL|MUL]]
| [[#MUL|MULU]]
|-
| [[#NEG|NEG]]
| [[#NEG|NEG]]
|-
| [[#NOP|NOP]]
| [[#NOP|NOP]]
|-
| [[#NOT|NOT]]
| [[#NOT|NOT]]
|-
| [[#OR|OR]]
| [[#OR|OR]]
|-
| [[#OUT|OUT]]
| [[#OUT|OUT]]
|-
| [[#OUTSB|OUTSB]]
| [[#OUTSB|OUTM]]
|-
| [[#OUTSW|OUTSW]]
| [[#OUTSW|OUTM]]
|-
| [[#POLL|POLL]]
| [[#POLL|POLL]]
|-
| [[#POP|POP]]
| [[#POP|POP]]
|-
| [[#POPA|POPA]]
| [[#POPA|POP]]
|-
| [[#POPF|POPF]]
| [[#POPF|POP]]
|-
| [[#PUSH|PUSH]]
| [[#PUSH|PUSH]]
|-
| [[#PUSHA|PUSHA]]
| [[#PUSHA|PUSH]]
|-
| [[#PUSHF|PUSHF]]
| [[#PUSHF|PUSH]]
|-
| [[#RCL|RCL]]
| [[#RCL|ROLC]]
|-
| [[#RCR|RCR]]
| [[#RCR|RORC]]
|-
| [[#REP|REP/REPE/REPZ]]
| [[#REP|REP/REPE/REPZ]]
|-
| [[#REPNE|REPNE/REPNZ]]
| [[#REPNE|REPNE/REPNZ]]
|-
| [[#RET|RET]]
| [[#RET|RET]]
|-
| [[#RETF|RETF]]
| [[#RETF|RET]]
|-
| [[#ROL|ROL]]
| [[#ROL|ROL]]
|-
| [[#ROR|ROR]]
| [[#ROR|ROR]]
|-
| [[#SAHF|SAHF]]
| [[#SAHF|MOV]]
|-
| [[#SAR|SAR]]
| [[#SAR|SHRA]]
|-
| [[#SBB|SBB]]
| [[#SBB|SUBC]]
|-
| [[#SCASB|SCASB]]
| [[#SCASB|CMPMB]]
|-
| [[#SCASW|SCASW]]
| [[#SCASW|CMPMW]]
|-
| [[#SHL|SHL]]
| [[#SHL|SHL]]
|-
| [[#SHR|SHR]]
| [[#SHR|SHR]]
|-
| [[#SS|SS]]
| [[#SS|SS]]
|-
| [[#STC|STC]]
| [[#STC|SET1 CY]]
|-
| [[#STD|STD]]
| [[#STD|SET1 DIR]]
|-
| [[#STI|STI]]
| [[#STI|EI]]
|-
| [[#STOSB|STOSB]]
| [[#STOSB|STMB]]
|-
| [[#STOSW|STOSW]]
| [[#STOSW|STMW]]
|-
| [[#SUB|SUB]]
| [[#SUB|SUB]]
|-
| [[#TEST|TEST]]
| [[#TEST|TEST]]
|-
| [[#XCHG|XCHG]]
| [[#XCHG|XCH]]
|-
| [[#XLAT|XLAT]]
| [[#XLAT|TRANS]]
|-
| [[#XOR|XOR]]
| [[#XOR|XOR]]
|}
== Official instructions by type ==
{| class="wikitable sortable" style="text-align: center"
!Type
!colspan=16 class="unsortable" | Instructions
|-
| style="text-align:left;" | Memory
| style="" | [[#MOV|MOV]]
| style="" | [[#XCHG|XCHG]]
| style="" | [[#XLAT|XLAT]]
| style="" | [[#LEA|LEA]]
| style="border-right:none;" | [[#LDS|LDS]]
| style="border-left:none;" | [[#LES|LES]]
| style="border-right:none;" | [[#IN|IN]]
| style="border-left:none;" | [[#OUT|OUT]]
| colspan="8" |
|-
| style="text-align:left;" | Ports
| style="border-right:none;" | [[#IN|IN]]
| style="border-left:none;" | [[#OUT|OUT]]
| style="border-right:none;" | [[#INSB|INSB]]
| style="border-left:none;" | [[#OUTSB|OUTSB]]
| style="border-right:none;" | [[#INSW|INSW]]
| style="border-left:none;" | [[#OUTSW|OUTSW]]
| colspan="10" |
|-
| style="text-align:left;" | Arithmetic
| style="border-right:none;" | [[#ADD|ADD]]
| style="border-left:none;" | [[#SUB|SUB]]
| style="border-right:none;" | [[#ADC|ADC]]
| style="border-left:none;" | [[#SBB|SBB]]
| style="border-right:none;" | [[#INC|INC]]
| style="border-left:none;" | [[#DEC|DEC]]
| style="border-right:none;" | [[#MUL|MUL]]
| style="border-left:none;" | [[#DIV|DIV]]
| style="border-right:none;" | [[#IMUL|IMUL]]
| style="border-left:none;" | [[#IDIV|IDIV]]
| style="" | [[#CMP|CMP]]
| style="" | [[#NEG|NEG]]
| colspan="4" |
|-
| style="text-align:left;" | Numeric
| style="" | [[#CBW|CBW]]
| style="" | [[#CWD|CWD]]
| style="" | [[#AAA|AAA]]
| style="" | [[#AAS|AAS]]
| style="" | [[#AAM|AAM]]
| style="" | [[#AAD|AAD]]
| style="" | [[#DAA|DAA]]
| style="" | [[#DAS|DAS]]
| colspan="8" |
|-
| style="text-align:left;" | Shift
| style="border-right:none;" | [[#ROL|ROL]]
| style="border-left:none;" | [[#ROR|ROR]]
| style="border-right:none;" | [[#RCL|RCL]]
| style="border-left:none;" | [[#RCR|RCR]]
| style="border-right:none;" | [[#SHL|SHL]]
| style="border-left:none;" | [[#SHR|SHR]]
| style="" | [[#SAR|SAR]]
| colspan="9" |
|-
| style="text-align:left;" | Bitwise
| style="" | [[#AND|AND]]
| style="" | [[#OR|OR]]
| style="" | [[#XOR|XOR]]
| style="" | [[#NOT|NOT]]
| style="" | [[#TEST|TEST]]
| colspan="11" |
|-
| style="text-align:left;" | Branch
| style="border-right:none;" | [[#JC|JC]]
| style="border-left:none;" | [[#JNC|JNC]]
| style="border-right:none;" | [[#JZ|JZ]]
| style="border-left:none;" | [[#JNZ|JNZ]]
| style="border-right:none;" | [[#JBE|JBE]]
| style="border-left:none;" | [[#JA|JA]]
| style="border-right:none;" | [[#JO|JO]]
| style="border-left:none;" | [[#JNO|JNO]]
| style="border-right:none;" | [[#JP|JP]]
| style="border-left:none;" | [[#JNP|JNP]]
| style="border-right:none;" | [[#JS|JS]]
| style="border-left:none;" | [[#JNS|JNS]]
| style="border-right:none;" | [[#JL|JL]]
| style="border-left:none;" | [[#JGE|JGE]]
| style="border-right:none;" | [[#JLE|JLE]]
| style="border-left:none;" | [[#JG|JG]]
|-
| style="text-align:left;" | Jump
| style="" | [[#JMP|JMP]]
| style="border-right:none;" | [[#CALL|CALL]]
| style="border-left:none;border-right:none;" | [[#RET|RET]]
| style="border-left:none;" | [[#RETF|RETF]]
| colspan="12" |
|-
| style="text-align:left;" | Loop
| style="" | [[#LOOP|LOOP]]
| style="" | [[#LOOPE|LOOPE]]
| style="" | [[#LOOPNE|LOOPNE]]
| colspan="13" |
|-
| style="text-align:left;" | Interrupt
| style="border-right:none;" | [[#INT|INT]]
| style="border-left:none;" | [[#IRET|IRET]]
| style="" | [[#INTO|INTO]]
| style="" | [[#HLT|HLT]]
| style="" | [[#BOUND|BOUND]]
| colspan="11" |
|-
| style="text-align:left;" | Stack
| style="border-right:none;" | [[#PUSH|PUSH]]
| style="border-left:none;" | [[#POP|POP]]
| style="border-right:none;" | [[#PUSHA|PUSHA]]
| style="border-left:none;" | [[#POPA|POPA]]
| style="border-right:none;" | [[#PUSHF|PUSHF]]
| style="border-left:none;" | [[#POPF|POPF]]
| colspan="10" |
|-
| style="text-align:left;" | Flags
| style="border-right:none;" | [[#CLC|CLC]]
| style="border-left:none;" | [[#STC|STC]]
| style="border-right:none;" | [[#CLD|CLD]]
| style="border-left:none;" | [[#STD|STD]]
| style="border-right:none;" | [[#CLI|CLI]]
| style="border-left:none;" | [[#STI|STI]]
| style="" | [[#CMC|CMC]]
| style="border-right:none;" | [[#LAHF|LAHF]]
| style="border-left:none;" | [[#SAHF|SAHF]]
| colspan="7" |
|-
| style="text-align:left;" | Prefix
| style="" | [[#CS|CS]]
| style="" | [[#DS|DS]]
| style="" | [[#ES|ES]]
| style="" | [[#SS|SS]]
| colspan="12" |
|-
| style="text-align:left;" | String
| style="border-right:none;" | [[#REP|REP]]
| style="border-left:none;border-right:none;" | [[#REP|REPE]]
| style="border-left:none;" | [[#REPNE|REPNE]]
| style="" | [[#MOVSB|MOVSB]]
| style="" | [[#MOVSW|MOVSW]]
| style="border-right:none;" | [[#LODSB|LODSB]]
| style="border-left:none;" | [[#STOSB|STOSB]]
| style="border-right:none;" | [[#LODSW|LODSW]]
| style="border-left:none;" | [[#STOSW|STOSW]]
| style="" | [[#CMPSB|CMPSB]]
| style="" | [[#SCASB|SCASB]]
| style="" | [[#CMPSW|CMPSW]]
| style="" | [[#SCASW|SCASW]]
| colspan="3" |
|-
| style="text-align:left;" | Other
| style="" | [[#NOP|NOP]]
| style="border-right:none;" | [[#ENTER|ENTER]]
| style="border-left:none;" | [[#LEAVE|LEAVE]]
| style="" | [[#LOCK|LOCK]]
| style="" | [[#POLL|POLL]]
| colspan="11" |
|}
== Instruction encoding ==
=== ModR/M byte ===
The ModR/M byte, marked as <tt>oorrrmmm</tt>, is used in most addressing modes which reference a memory location. This byte consists of three bitfield values:
* <tt>oo</tt> - M'''o'''de;
* <tt>rrr</tt> - Two possible functions:
** '''R'''egister (for addressing modes which require both a register and a register/memory operand),
** Opcode extension (for some opcodes' addressing modes which do not have such a requirement);
* <tt>mmm</tt> - Register/'''M'''emory.
The ''Mode'' and ''Register/Memory'' bitfields can refer to a memory location with an optional signed 8-bit (disp8) or 16-bit (disp16) displacement or to a register, as shown in the table below. In some addressing modes, the ''Register'' field also refers to a register; it is always interpreted as if ''Mode'' was equal to <tt>11</tt>.
{| class="wikitable" style="text-align: center"
! R/M \ Mode
! <tt>00</tt>
! <tt>01</tt>
! <tt>10</tt>
! <tt>11</tt> ''(byte)''
! <tt>11</tt> ''(word)''
|-
| <tt>000</tt>
| DS:[BX + SI]
| DS:[BX + SI + disp8]
| DS:[BX + SI + disp16]
| AL
| AX
|-
| <tt>001</tt>
| DS:[BX + DI]
| DS:[BX + DI + disp8]
| DS:[BX + DI + disp16]
| CL
| CX
|-
| <tt>010</tt>
| SS:[BP + SI]
| SS:[BP + SI + disp8]
| SS:[BP + SI + disp16]
| DL
| DX
|-
| <tt>011</tt>
| SS:[BP + DI]
| SS:[BP + DI + disp8]
| SS:[BP + DI + disp16]
| BL
| BX
|-
| <tt>100</tt>
| DS:[SI]
| DS:[SI + disp8]
| DS:[SI + disp16]
| AH
| SP
|-
| <tt>101</tt>
| DS:[DI]
| DS:[DI + disp8]
| DS:[DI + disp16]
| CH
| BP
|-
| <tt>110</tt>
| ''DS:[disp16]''
| SS:[BP + disp8]
| SS:[BP + disp16]
| DH
| SI
|-
| <tt>111</tt>
| DS:[BX]
| DS:[BX + disp8]
| DS:[BX + disp16]
| BH
| DI
|}
Note that ''oo'' = <tt>00</tt>, ''mmm'' = <tt>110</tt> is a special case.
== Official instructions ==
{{Anchor|AAA}}
=== AAA ===
----
{{Anchor|AAD}}
=== AAD ===
----
{{Anchor|AAM}}
=== AAM ===
----
{{Anchor|AAS}}
=== AAS ===
----
{{Anchor|ADC}}
=== ADC ===
----
{{Anchor|ADD}}
=== ADD ===
----
{{Anchor|AND}}
=== AND ===
----
{{Anchor|BOUND}}
=== BOUND ===
----
{{Anchor|CALL}}
=== CALL ===
----
{{Anchor|CBW}}
=== CBW ===
----
{{Anchor|CLC}}
=== CLC ===
----
{{Anchor|CLD}}
=== CLD ===
----
{{Anchor|CLI}}
=== CLI ===
----
{{Anchor|CMC}}
=== CMC ===
----
{{Anchor|CMP}}
=== CMP ===
----
{{Anchor|CMPSB}}
=== CMPSB ===
----
{{Anchor|CMPSW}}
=== CMPSW ===
----
{{Anchor|CS}}
=== CS ===
----
{{Anchor|CWD}}
=== CWD ===
----
{{Anchor|DAA}}
=== DAA ===
----
{{Anchor|DAS}}
=== DAS ===
----
{{Anchor|DEC}}
=== DEC ===
----
{{Anchor|DIV}}
=== DIV ===
----
{{Anchor|DS}}
=== DS ===
----
{{Anchor|ENTER}}
=== ENTER ===
----
{{Anchor|ES}}
=== ES ===
----
{{Anchor|HLT}}
=== HLT ===
----
{{Anchor|IDIV}}
=== IDIV ===
----
{{Anchor|IMUL}}
=== IMUL ===
----
{{Anchor|IN}}
=== IN ===
----
{{Anchor|INC}}
=== INC ===
----
{{Anchor|INSB}}
=== INSB ===
----
{{Anchor|INSW}}
=== INSW ===
----
{{Anchor|INT}}
=== INT ===
----
{{Anchor|INTO}}
=== INTO ===
----
{{Anchor|IRET}}
=== IRET ===
----
{{Anchor|JA}}
=== JA ===
----
{{Anchor|JBE}}
=== JBE ===
----
{{Anchor|JC}}
=== JC/JB ===
----
{{Anchor|JCXZ}}
=== JCXZ ===
----
{{Anchor|JG}}
=== JG ===
----
{{Anchor|JGE}}
=== JGE ===
----
{{Anchor|JL}}
=== JL ===
----
{{Anchor|JLE}}
=== JLE ===
----
{{Anchor|JMP}}
=== JMP ===
----
{{Anchor|JNC}}
=== JNC/JAE ===
----
{{Anchor|JNO}}
=== JNO ===
----
{{Anchor|JNP}}
=== JNP ===
----
{{Anchor|JNS}}
=== JNS ===
----
{{Anchor|JNZ}}
=== JNZ/JNE ===
----
{{Anchor|JO}}
=== JO ===
----
{{Anchor|JP}}
=== JP ===
----
{{Anchor|JS}}
=== JS ===
----
{{Anchor|JZ}}
=== JZ/JE ===
----
{{Anchor|LAHF}}
=== LAHF ===
----
{{Anchor|LDS}}
=== LDS ===
----
{{Anchor|LEA}}
=== LEA ===
----
{{Anchor|LEAVE}}
=== LEAVE ===
----
{{Anchor|LES}}
=== LES ===
----
{{Anchor|LOCK}}
=== LOCK ===
----
{{Anchor|LODSB}}
=== LODSB ===
----
{{Anchor|LODSW}}
=== LODSW ===
----
{{Anchor|LOOP}}
=== LOOP ===
----
{{Anchor|LOOPE}}
=== LOOPE ===
----
{{Anchor|LOOPNE}}
=== LOOPNE ===
----
{{Anchor|MOV}}
=== MOV ===
----
{{Anchor|MOVSB}}
=== MOVSB ===
----
{{Anchor|MOVSW}}
=== MOVSW ===
----
{{Anchor|MUL}}
=== MUL ===
----
{{Anchor|NEG}}
=== NEG ===
----
{{Anchor|NOP}}
=== NOP ===
----
{{Anchor|NOT}}
=== NOT ===
----
{{Anchor|OR}}
=== OR ===
----
{{Anchor|OUT}}
=== OUT ===
----
{{Anchor|OUTSB}}
=== OUTSB ===
----
{{Anchor|OUTSW}}
=== OUTSW ===
----
{{Anchor|POLL}}
=== POLL ===
----
{{Anchor|POP}}
=== POP ===
----
{{Anchor|POPA}}
=== POPA ===
----
{{Anchor|POPF}}
=== POPF ===
----
{{Anchor|PUSH}}
=== PUSH ===
----
{{Anchor|PUSHA}}
=== PUSHA ===
----
{{Anchor|PUSHF}}
=== PUSHF ===
----
{{Anchor|RCL}}
=== RCL ===
----
{{Anchor|RCR}}
=== RCR ===
----
{{Anchor|REP}}
=== REP/REPE/REPZ ===
----
{{Anchor|REPNE}}
=== REPNE/REPNZ ===
----
{{Anchor|RET}}
=== RET ===
----
{{Anchor|RETF}}
=== RETF ===
----
{{Anchor|ROL}}
=== ROL ===
----
{{Anchor|ROR}}
=== ROR ===
----
{{Anchor|SAHF}}
=== SAHF ===
----
{{Anchor|SAR}}
=== SAR ===
----
{{Anchor|SBB}}
=== SBB ===
----
{{Anchor|SCASB}}
=== SCASB ===
----
{{Anchor|SCASW}}
=== SCASW ===
----
{{Anchor|SHL}}
=== SHL ===
----
{{Anchor|SHR}}
=== SHR ===
----
{{Anchor|SS}}
=== SS ===
----
{{Anchor|STC}}
=== STC ===
----
{{Anchor|STD}}
=== STD ===
----
{{Anchor|STI}}
=== STI ===
----
{{Anchor|STOSB}}
=== STOSB ===
----
{{Anchor|STOSW}}
=== STOSW ===
----
{{Anchor|SUB}}
=== SUB ===
----
{{Anchor|TEST}}
=== TEST ===
----
{{Anchor|XCHG}}
=== XCHG ===
----
{{Anchor|XLAT}}
=== XLAT ===
----
{{Anchor|XOR}}
=== XOR ===
----
611d31a260470ad4b3d258e064be92cdb6528104
438
437
2024-12-26T18:04:11Z
Asie
351
/* ModR/M byte */
wikitext
text/x-wiki
__NOTOC__
{| class="wikitable" style="text-align: center"
|+ Official V30MZ (80186) Instructions
|-
| [[#AAA|AAA]] || [[#AAD|AAD]] || [[#AAM|AAM]] || [[#AAS|AAS]] || [[#ADC|ADC]] || [[#ADD|ADD]] || [[#AND|AND]] || [[#BOUND|BOUND]] || [[#CALL|CALL]] || [[#CBW|CBW]] || [[#CLC|CLC]]
|-
| [[#CLD|CLD]] || [[#CLI|CLI]] || [[#CMC|CMC]] || [[#CMP|CMP]] || [[#CMPSB|CMPSB]] || [[#CMPSW|CMPSW]] || [[#CS|CS]] || [[#CWD|CWD]] || [[#DAA|DAA]] || [[#DAS|DAS]] || [[#DEC|DEC]]
|-
| [[#DIV|DIV]] || [[#DS|DS]] || [[#ENTER|ENTER]] || [[#ES|ES]] || [[#HLT|HLT]] || [[#IDIV|IDIV]] || [[#IMUL|IMUL]] || [[#IN|IN]] || [[#INC|INC]] || [[#INSB|INSB]] || [[#INSW|INSW]]
|-
| [[#INT|INT]] || [[#INTO|INTO]] || [[#IRET|IRET]] || [[#JA|JA]] || [[#JBE|JBE]] || [[#JC|JC]] || [[#JCXZ|JCXZ]] || [[#JG|JG]] || [[#JGE|JGE]] || [[#JL|JL]] || [[#JLE|JLE]]
|-
| [[#JMP|JMP]] || [[#JNC|JNC]] || [[#JNO|JNO]] || [[#JNP|JNP]] || [[#JNS|JNS]] || [[#JNZ|JNZ]] || [[#JO|JO]] || [[#JP|JP]] || [[#JS|JS]] || [[#JZ|JZ]] || [[#LAHF|LAHF]]
|-
| [[#LDS|LDS]] || [[#LEA|LEA]] || [[#LEAVE|LEAVE]] || [[#LES|LES]] || [[#LOCK|LOCK]] || [[#LODSB|LODSB]] || [[#LODSW|LODSW]] || [[#LOOP|LOOP]] || [[#LOOPE|LOOPE]] || [[#LOOPNE|LOOPNE]] || [[#MOV|MOV]]
|-
| [[#MOVSB|MOVSB]] || [[#MOVSW|MOVSW]] || [[#MUL|MUL]] || [[#NEG|NEG]] || [[#NOP|NOP]] || [[#NOT|NOT]] || [[#OR|OR]] || [[#OUT|OUT]] || [[#OUTSB|OUTSB]] || [[#OUTSW|OUTSW]] || [[#POLL|POLL]]
|-
| [[#POP|POP]] || [[#POPA|POPA]] || [[#POPF|POPF]] || [[#PUSH|PUSH]] || [[#PUSHA|PUSHA]] || [[#PUSHF|PUSHF]] || [[#RCL|RCL]] || [[#RCR|RCR]] || [[#REP|REP]] || [[#REPNE|REPNE]] || [[#RET|RET]]
|-
| [[#RETF|RETF]] || [[#ROL|ROL]] || [[#ROR|ROR]] || [[#SAHF|SAHF]] || [[#SAR|SAR]] || [[#SBB|SBB]] || [[#SCASB|SCASB]] || [[#SCASW|SCASW]] || [[#SHL|SHL]] || [[#SHR|SHR]] || [[#SS|SS]]
|-
| [[#STC|STC]] || [[#STD|STD]] || [[#STI|STI]] || [[#STOSB|STOSB]] || [[#STOSW|STOSW]] || [[#SUB|SUB]] || [[#TEST|TEST]] || [[#XCHG|XCHG]] || [[#XLAT|XLAT]] || [[#XOR|XOR]]
|}
{| class="mw-collapsible mw-collapsed wikitable sortable" style="width: 340px;"
|+ style="white-space:nowrap; border:1px solid; padding:3px; border-color:rgb(162, 169, 177); background-color:rgb(234, 236, 240);" | Intel <-> NEC mnemonic translation table
!Intel
!NEC
|-
| [[#AAA|AAA]]
| [[#AAA|ADJBA]]
|-
| [[#AAD|AAD]]
| [[#AAD|CVTDB]]
|-
| [[#AAM|AAM]]
| [[#AAM|CVTBD]]
|-
| [[#AAS|AAS]]
| [[#AAS|ADJBS]]
|-
| [[#ADC|ADC]]
| [[#ADC|ADDC]]
|-
| [[#ADD|ADD]]
| [[#ADD|ADD]]
|-
| [[#AND|AND]]
| [[#AND|AND]]
|-
| [[#BOUND|BOUND]]
| [[#BOUND|CHKIND]]
|-
| [[#CALL|CALL]]
| [[#CALL|CALL]]
|-
| [[#CBW|CBW]]
| [[#CBW|CVTBW]]
|-
| [[#CLC|CLC]]
| [[#CLC|CLR1 CY]]
|-
| [[#CLD|CLD]]
| [[#CLD|CLR1 DIR]]
|-
| [[#CLI|CLI]]
| [[#CLI|DI]]
|-
| [[#CMC|CMC]]
| [[#CMC|NOT1 CY]]
|-
| [[#CMP|CMP]]
| [[#CMP|CMP]]
|-
| [[#CMPSB|CMPSB]]
| [[#CMPSB|CMPBKB]]
|-
| [[#CMPSW|CMPSW]]
| [[#CMPSW|CMPBKW]]
|-
| [[#CS|CS]]
| [[#CS|PS]]
|-
| [[#CWD|CWD]]
| [[#CWD|CVTWL]]
|-
| [[#DAA|DAA]]
| [[#DAA|ADJ4A]]
|-
| [[#DAS|DAS]]
| [[#DAS|ADJ4S]]
|-
| [[#DEC|DEC]]
| [[#DEC|DEC]]
|-
| [[#DIV|DIV]]
| [[#DIV|DIVU]]
|-
| [[#DS|DS]]
| [[#DS|DS0]]
|-
| [[#ENTER|ENTER]]
| [[#ENTER|PREPARE]]
|-
| [[#ES|ES]]
| [[#ES|DS1]]
|-
| [[#HLT|HLT]]
| [[#HLT|HALT]]
|-
| [[#IDIV|IDIV]]
| [[#IDIV|DIV]]
|-
| [[#IMUL|IMUL]]
| [[#IMUL|MUL]]
|-
| [[#IN|IN]]
| [[#IN|IN]]
|-
| [[#INC|INC]]
| [[#INC|INC]]
|-
| [[#INSB|INSB]]
| [[#INSB|INMB]]
|-
| [[#INSW|INSW]]
| [[#INSW|INMW]]
|-
| [[#INT|INT]]
| [[#INT|BRK]]
|-
| [[#INTO|INTO]]
| [[#INTO|BRKV]]
|-
| [[#IRET|IRET]]
| [[#IRET|RETI]]
|-
| [[#JA|JA]]
| [[#JA|BH]]
|-
| [[#JBE|JBE]]
| [[#JBE|BNH]]
|-
| [[#JC|JC/JB]]
| [[#JC|BC/BL]]
|-
| [[#JCXZ|JCXZ]]
| [[#JCXZ|BCWZ]]
|-
| [[#JG|JG]]
| [[#JG|BGT]]
|-
| [[#JGE|JGE]]
| [[#JGE|BGE]]
|-
| [[#JL|JL]]
| [[#JL|BLT]]
|-
| [[#JLE|JLE]]
| [[#JLE|BLE]]
|-
| [[#JMP|JMP]]
| [[#JMP|BR]]
|-
| [[#JNC|JNC/JAE]]
| [[#JNC|BNC/BNL]]
|-
| [[#JNO|JNO]]
| [[#JNO|BNV]]
|-
| [[#JNP|JNP]]
| [[#JNP|BPO]]
|-
| [[#JNS|JNS]]
| [[#JNS|BP]]
|-
| [[#JNZ|JNZ/JNE]]
| [[#JNZ|BNZ/BNE]]
|-
| [[#JO|JO]]
| [[#JO|BV]]
|-
| [[#JP|JP]]
| [[#JP|BPE]]
|-
| [[#JS|JS]]
| [[#JS|BN]]
|-
| [[#JZ|JZ/JE]]
| [[#JZ|BZ/BE]]
|-
| [[#LAHF|LAHF]]
| [[#LAHF|MOV]]
|-
| [[#LDS|LDS]]
| [[#LDS|MOV]]
|-
| [[#LEA|LEA]]
| [[#LEA|LDEA]]
|-
| [[#LEAVE|LEAVE]]
| [[#LEAVE|DISPOSE]]
|-
| [[#LES|LES]]
| [[#LES|MOV]]
|-
| [[#LOCK|LOCK]]
| [[#LOCK|BUSLOCK]]
|-
| [[#LODSB|LODSB]]
| [[#LODSB|LDMB]]
|-
| [[#LODSW|LODSW]]
| [[#LODSW|LDMW]]
|-
| [[#LOOP|LOOP]]
| [[#LOOP|DBNZ]]
|-
| [[#LOOPE|LOOPE]]
| [[#LOOPE|DBNZE]]
|-
| [[#LOOPNE|LOOPNE]]
| [[#LOOPNE|DBNZNE]]
|-
| [[#MOV|MOV]]
| [[#MOV|MOV]]
|-
| [[#MOVSB|MOVSB]]
| [[#MOVSB|MOVBKB]]
|-
| [[#MOVSW|MOVSW]]
| [[#MOVSW|MOVBKW]]
|-
| [[#MUL|MUL]]
| [[#MUL|MULU]]
|-
| [[#NEG|NEG]]
| [[#NEG|NEG]]
|-
| [[#NOP|NOP]]
| [[#NOP|NOP]]
|-
| [[#NOT|NOT]]
| [[#NOT|NOT]]
|-
| [[#OR|OR]]
| [[#OR|OR]]
|-
| [[#OUT|OUT]]
| [[#OUT|OUT]]
|-
| [[#OUTSB|OUTSB]]
| [[#OUTSB|OUTM]]
|-
| [[#OUTSW|OUTSW]]
| [[#OUTSW|OUTM]]
|-
| [[#POLL|POLL]]
| [[#POLL|POLL]]
|-
| [[#POP|POP]]
| [[#POP|POP]]
|-
| [[#POPA|POPA]]
| [[#POPA|POP]]
|-
| [[#POPF|POPF]]
| [[#POPF|POP]]
|-
| [[#PUSH|PUSH]]
| [[#PUSH|PUSH]]
|-
| [[#PUSHA|PUSHA]]
| [[#PUSHA|PUSH]]
|-
| [[#PUSHF|PUSHF]]
| [[#PUSHF|PUSH]]
|-
| [[#RCL|RCL]]
| [[#RCL|ROLC]]
|-
| [[#RCR|RCR]]
| [[#RCR|RORC]]
|-
| [[#REP|REP/REPE/REPZ]]
| [[#REP|REP/REPE/REPZ]]
|-
| [[#REPNE|REPNE/REPNZ]]
| [[#REPNE|REPNE/REPNZ]]
|-
| [[#RET|RET]]
| [[#RET|RET]]
|-
| [[#RETF|RETF]]
| [[#RETF|RET]]
|-
| [[#ROL|ROL]]
| [[#ROL|ROL]]
|-
| [[#ROR|ROR]]
| [[#ROR|ROR]]
|-
| [[#SAHF|SAHF]]
| [[#SAHF|MOV]]
|-
| [[#SAR|SAR]]
| [[#SAR|SHRA]]
|-
| [[#SBB|SBB]]
| [[#SBB|SUBC]]
|-
| [[#SCASB|SCASB]]
| [[#SCASB|CMPMB]]
|-
| [[#SCASW|SCASW]]
| [[#SCASW|CMPMW]]
|-
| [[#SHL|SHL]]
| [[#SHL|SHL]]
|-
| [[#SHR|SHR]]
| [[#SHR|SHR]]
|-
| [[#SS|SS]]
| [[#SS|SS]]
|-
| [[#STC|STC]]
| [[#STC|SET1 CY]]
|-
| [[#STD|STD]]
| [[#STD|SET1 DIR]]
|-
| [[#STI|STI]]
| [[#STI|EI]]
|-
| [[#STOSB|STOSB]]
| [[#STOSB|STMB]]
|-
| [[#STOSW|STOSW]]
| [[#STOSW|STMW]]
|-
| [[#SUB|SUB]]
| [[#SUB|SUB]]
|-
| [[#TEST|TEST]]
| [[#TEST|TEST]]
|-
| [[#XCHG|XCHG]]
| [[#XCHG|XCH]]
|-
| [[#XLAT|XLAT]]
| [[#XLAT|TRANS]]
|-
| [[#XOR|XOR]]
| [[#XOR|XOR]]
|}
== Official instructions by type ==
{| class="wikitable sortable" style="text-align: center"
!Type
!colspan=16 class="unsortable" | Instructions
|-
| style="text-align:left;" | Memory
| style="" | [[#MOV|MOV]]
| style="" | [[#XCHG|XCHG]]
| style="" | [[#XLAT|XLAT]]
| style="" | [[#LEA|LEA]]
| style="border-right:none;" | [[#LDS|LDS]]
| style="border-left:none;" | [[#LES|LES]]
| style="border-right:none;" | [[#IN|IN]]
| style="border-left:none;" | [[#OUT|OUT]]
| colspan="8" |
|-
| style="text-align:left;" | Ports
| style="border-right:none;" | [[#IN|IN]]
| style="border-left:none;" | [[#OUT|OUT]]
| style="border-right:none;" | [[#INSB|INSB]]
| style="border-left:none;" | [[#OUTSB|OUTSB]]
| style="border-right:none;" | [[#INSW|INSW]]
| style="border-left:none;" | [[#OUTSW|OUTSW]]
| colspan="10" |
|-
| style="text-align:left;" | Arithmetic
| style="border-right:none;" | [[#ADD|ADD]]
| style="border-left:none;" | [[#SUB|SUB]]
| style="border-right:none;" | [[#ADC|ADC]]
| style="border-left:none;" | [[#SBB|SBB]]
| style="border-right:none;" | [[#INC|INC]]
| style="border-left:none;" | [[#DEC|DEC]]
| style="border-right:none;" | [[#MUL|MUL]]
| style="border-left:none;" | [[#DIV|DIV]]
| style="border-right:none;" | [[#IMUL|IMUL]]
| style="border-left:none;" | [[#IDIV|IDIV]]
| style="" | [[#CMP|CMP]]
| style="" | [[#NEG|NEG]]
| colspan="4" |
|-
| style="text-align:left;" | Numeric
| style="" | [[#CBW|CBW]]
| style="" | [[#CWD|CWD]]
| style="" | [[#AAA|AAA]]
| style="" | [[#AAS|AAS]]
| style="" | [[#AAM|AAM]]
| style="" | [[#AAD|AAD]]
| style="" | [[#DAA|DAA]]
| style="" | [[#DAS|DAS]]
| colspan="8" |
|-
| style="text-align:left;" | Shift
| style="border-right:none;" | [[#ROL|ROL]]
| style="border-left:none;" | [[#ROR|ROR]]
| style="border-right:none;" | [[#RCL|RCL]]
| style="border-left:none;" | [[#RCR|RCR]]
| style="border-right:none;" | [[#SHL|SHL]]
| style="border-left:none;" | [[#SHR|SHR]]
| style="" | [[#SAR|SAR]]
| colspan="9" |
|-
| style="text-align:left;" | Bitwise
| style="" | [[#AND|AND]]
| style="" | [[#OR|OR]]
| style="" | [[#XOR|XOR]]
| style="" | [[#NOT|NOT]]
| style="" | [[#TEST|TEST]]
| colspan="11" |
|-
| style="text-align:left;" | Branch
| style="border-right:none;" | [[#JC|JC]]
| style="border-left:none;" | [[#JNC|JNC]]
| style="border-right:none;" | [[#JZ|JZ]]
| style="border-left:none;" | [[#JNZ|JNZ]]
| style="border-right:none;" | [[#JBE|JBE]]
| style="border-left:none;" | [[#JA|JA]]
| style="border-right:none;" | [[#JO|JO]]
| style="border-left:none;" | [[#JNO|JNO]]
| style="border-right:none;" | [[#JP|JP]]
| style="border-left:none;" | [[#JNP|JNP]]
| style="border-right:none;" | [[#JS|JS]]
| style="border-left:none;" | [[#JNS|JNS]]
| style="border-right:none;" | [[#JL|JL]]
| style="border-left:none;" | [[#JGE|JGE]]
| style="border-right:none;" | [[#JLE|JLE]]
| style="border-left:none;" | [[#JG|JG]]
|-
| style="text-align:left;" | Jump
| style="" | [[#JMP|JMP]]
| style="border-right:none;" | [[#CALL|CALL]]
| style="border-left:none;border-right:none;" | [[#RET|RET]]
| style="border-left:none;" | [[#RETF|RETF]]
| colspan="12" |
|-
| style="text-align:left;" | Loop
| style="" | [[#LOOP|LOOP]]
| style="" | [[#LOOPE|LOOPE]]
| style="" | [[#LOOPNE|LOOPNE]]
| colspan="13" |
|-
| style="text-align:left;" | Interrupt
| style="border-right:none;" | [[#INT|INT]]
| style="border-left:none;" | [[#IRET|IRET]]
| style="" | [[#INTO|INTO]]
| style="" | [[#HLT|HLT]]
| style="" | [[#BOUND|BOUND]]
| colspan="11" |
|-
| style="text-align:left;" | Stack
| style="border-right:none;" | [[#PUSH|PUSH]]
| style="border-left:none;" | [[#POP|POP]]
| style="border-right:none;" | [[#PUSHA|PUSHA]]
| style="border-left:none;" | [[#POPA|POPA]]
| style="border-right:none;" | [[#PUSHF|PUSHF]]
| style="border-left:none;" | [[#POPF|POPF]]
| colspan="10" |
|-
| style="text-align:left;" | Flags
| style="border-right:none;" | [[#CLC|CLC]]
| style="border-left:none;" | [[#STC|STC]]
| style="border-right:none;" | [[#CLD|CLD]]
| style="border-left:none;" | [[#STD|STD]]
| style="border-right:none;" | [[#CLI|CLI]]
| style="border-left:none;" | [[#STI|STI]]
| style="" | [[#CMC|CMC]]
| style="border-right:none;" | [[#LAHF|LAHF]]
| style="border-left:none;" | [[#SAHF|SAHF]]
| colspan="7" |
|-
| style="text-align:left;" | Prefix
| style="" | [[#CS|CS]]
| style="" | [[#DS|DS]]
| style="" | [[#ES|ES]]
| style="" | [[#SS|SS]]
| colspan="12" |
|-
| style="text-align:left;" | String
| style="border-right:none;" | [[#REP|REP]]
| style="border-left:none;border-right:none;" | [[#REP|REPE]]
| style="border-left:none;" | [[#REPNE|REPNE]]
| style="" | [[#MOVSB|MOVSB]]
| style="" | [[#MOVSW|MOVSW]]
| style="border-right:none;" | [[#LODSB|LODSB]]
| style="border-left:none;" | [[#STOSB|STOSB]]
| style="border-right:none;" | [[#LODSW|LODSW]]
| style="border-left:none;" | [[#STOSW|STOSW]]
| style="" | [[#CMPSB|CMPSB]]
| style="" | [[#SCASB|SCASB]]
| style="" | [[#CMPSW|CMPSW]]
| style="" | [[#SCASW|SCASW]]
| colspan="3" |
|-
| style="text-align:left;" | Other
| style="" | [[#NOP|NOP]]
| style="border-right:none;" | [[#ENTER|ENTER]]
| style="border-left:none;" | [[#LEAVE|LEAVE]]
| style="" | [[#LOCK|LOCK]]
| style="" | [[#POLL|POLL]]
| colspan="11" |
|}
== Instruction encoding ==
=== ModR/M byte ===
The ModR/M byte is used in most addressing modes which reference a memory location. This byte consists of three bitfield values:
* <tt>oo</tt> - M'''o'''de;
* <tt>rrr</tt> - Two possible functions:
** '''R'''egister (for addressing modes which require both a register and a register/memory operand),
** Opcode extension (for some opcodes' addressing modes which do not have such a requirement);
* <tt>mmm</tt> - Register/'''M'''emory.
The ''Mode'' and ''Register/Memory'' bitfields can refer to a memory location with an optional signed 8-bit (disp8) or 16-bit (disp16) displacement or to a register, as shown in the table below. In some addressing modes, the ''Register'' field also refers to a register; it is always interpreted as if ''Mode'' was equal to <tt>11</tt>.
{| class="wikitable" style="text-align: center"
! R/M \ Mode
! <tt>00</tt>
! <tt>01</tt>
! <tt>10</tt>
! <tt>11</tt> ''(byte)''
! <tt>11</tt> ''(word)''
|-
| <tt>000</tt>
| DS:[BX + SI]
| DS:[BX + SI + disp8]
| DS:[BX + SI + disp16]
| AL
| AX
|-
| <tt>001</tt>
| DS:[BX + DI]
| DS:[BX + DI + disp8]
| DS:[BX + DI + disp16]
| CL
| CX
|-
| <tt>010</tt>
| SS:[BP + SI]
| SS:[BP + SI + disp8]
| SS:[BP + SI + disp16]
| DL
| DX
|-
| <tt>011</tt>
| SS:[BP + DI]
| SS:[BP + DI + disp8]
| SS:[BP + DI + disp16]
| BL
| BX
|-
| <tt>100</tt>
| DS:[SI]
| DS:[SI + disp8]
| DS:[SI + disp16]
| AH
| SP
|-
| <tt>101</tt>
| DS:[DI]
| DS:[DI + disp8]
| DS:[DI + disp16]
| CH
| BP
|-
| <tt>110</tt>
| ''DS:[disp16]''
| SS:[BP + disp8]
| SS:[BP + disp16]
| DH
| SI
|-
| <tt>111</tt>
| DS:[BX]
| DS:[BX + disp8]
| DS:[BX + disp16]
| BH
| DI
|}
Note that (<tt>oo</tt> = <tt>00</tt>, <tt>mmm</tt> = <tt>110</tt>) is a special case.
The instruction encoding lists below refer to this byte as <tt>oorrrmmm</tt> (binary), <tt>rm</tt> (hexadecimal) or <tt>/0</tt> (hexademical, <tt>rrr</tt> used as function <tt>0</tt>).
== Official instructions ==
{{Anchor|AAA}}
=== AAA ===
----
{{Anchor|AAD}}
=== AAD ===
----
{{Anchor|AAM}}
=== AAM ===
----
{{Anchor|AAS}}
=== AAS ===
----
{{Anchor|ADC}}
=== ADC ===
----
{{Anchor|ADD}}
=== ADD ===
----
{{Anchor|AND}}
=== AND ===
----
{{Anchor|BOUND}}
=== BOUND ===
----
{{Anchor|CALL}}
=== CALL ===
----
{{Anchor|CBW}}
=== CBW ===
----
{{Anchor|CLC}}
=== CLC ===
----
{{Anchor|CLD}}
=== CLD ===
----
{{Anchor|CLI}}
=== CLI ===
----
{{Anchor|CMC}}
=== CMC ===
----
{{Anchor|CMP}}
=== CMP ===
----
{{Anchor|CMPSB}}
=== CMPSB ===
----
{{Anchor|CMPSW}}
=== CMPSW ===
----
{{Anchor|CS}}
=== CS ===
----
{{Anchor|CWD}}
=== CWD ===
----
{{Anchor|DAA}}
=== DAA ===
----
{{Anchor|DAS}}
=== DAS ===
----
{{Anchor|DEC}}
=== DEC ===
----
{{Anchor|DIV}}
=== DIV ===
----
{{Anchor|DS}}
=== DS ===
----
{{Anchor|ENTER}}
=== ENTER ===
----
{{Anchor|ES}}
=== ES ===
----
{{Anchor|HLT}}
=== HLT ===
----
{{Anchor|IDIV}}
=== IDIV ===
----
{{Anchor|IMUL}}
=== IMUL ===
----
{{Anchor|IN}}
=== IN ===
----
{{Anchor|INC}}
=== INC ===
----
{{Anchor|INSB}}
=== INSB ===
----
{{Anchor|INSW}}
=== INSW ===
----
{{Anchor|INT}}
=== INT ===
----
{{Anchor|INTO}}
=== INTO ===
----
{{Anchor|IRET}}
=== IRET ===
----
{{Anchor|JA}}
=== JA ===
----
{{Anchor|JBE}}
=== JBE ===
----
{{Anchor|JC}}
=== JC/JB ===
----
{{Anchor|JCXZ}}
=== JCXZ ===
----
{{Anchor|JG}}
=== JG ===
----
{{Anchor|JGE}}
=== JGE ===
----
{{Anchor|JL}}
=== JL ===
----
{{Anchor|JLE}}
=== JLE ===
----
{{Anchor|JMP}}
=== JMP ===
----
{{Anchor|JNC}}
=== JNC/JAE ===
----
{{Anchor|JNO}}
=== JNO ===
----
{{Anchor|JNP}}
=== JNP ===
----
{{Anchor|JNS}}
=== JNS ===
----
{{Anchor|JNZ}}
=== JNZ/JNE ===
----
{{Anchor|JO}}
=== JO ===
----
{{Anchor|JP}}
=== JP ===
----
{{Anchor|JS}}
=== JS ===
----
{{Anchor|JZ}}
=== JZ/JE ===
----
{{Anchor|LAHF}}
=== LAHF ===
----
{{Anchor|LDS}}
=== LDS ===
----
{{Anchor|LEA}}
=== LEA ===
----
{{Anchor|LEAVE}}
=== LEAVE ===
----
{{Anchor|LES}}
=== LES ===
----
{{Anchor|LOCK}}
=== LOCK ===
----
{{Anchor|LODSB}}
=== LODSB ===
----
{{Anchor|LODSW}}
=== LODSW ===
----
{{Anchor|LOOP}}
=== LOOP ===
----
{{Anchor|LOOPE}}
=== LOOPE ===
----
{{Anchor|LOOPNE}}
=== LOOPNE ===
----
{{Anchor|MOV}}
=== MOV ===
----
{{Anchor|MOVSB}}
=== MOVSB ===
----
{{Anchor|MOVSW}}
=== MOVSW ===
----
{{Anchor|MUL}}
=== MUL ===
----
{{Anchor|NEG}}
=== NEG ===
----
{{Anchor|NOP}}
=== NOP ===
----
{{Anchor|NOT}}
=== NOT ===
----
{{Anchor|OR}}
=== OR ===
----
{{Anchor|OUT}}
=== OUT ===
----
{{Anchor|OUTSB}}
=== OUTSB ===
----
{{Anchor|OUTSW}}
=== OUTSW ===
----
{{Anchor|POLL}}
=== POLL ===
----
{{Anchor|POP}}
=== POP ===
----
{{Anchor|POPA}}
=== POPA ===
----
{{Anchor|POPF}}
=== POPF ===
----
{{Anchor|PUSH}}
=== PUSH ===
----
{{Anchor|PUSHA}}
=== PUSHA ===
----
{{Anchor|PUSHF}}
=== PUSHF ===
----
{{Anchor|RCL}}
=== RCL ===
----
{{Anchor|RCR}}
=== RCR ===
----
{{Anchor|REP}}
=== REP/REPE/REPZ ===
----
{{Anchor|REPNE}}
=== REPNE/REPNZ ===
----
{{Anchor|RET}}
=== RET ===
----
{{Anchor|RETF}}
=== RETF ===
----
{{Anchor|ROL}}
=== ROL ===
----
{{Anchor|ROR}}
=== ROR ===
----
{{Anchor|SAHF}}
=== SAHF ===
----
{{Anchor|SAR}}
=== SAR ===
----
{{Anchor|SBB}}
=== SBB ===
----
{{Anchor|SCASB}}
=== SCASB ===
----
{{Anchor|SCASW}}
=== SCASW ===
----
{{Anchor|SHL}}
=== SHL ===
----
{{Anchor|SHR}}
=== SHR ===
----
{{Anchor|SS}}
=== SS ===
----
{{Anchor|STC}}
=== STC ===
----
{{Anchor|STD}}
=== STD ===
----
{{Anchor|STI}}
=== STI ===
----
{{Anchor|STOSB}}
=== STOSB ===
----
{{Anchor|STOSW}}
=== STOSW ===
----
{{Anchor|SUB}}
=== SUB ===
----
{{Anchor|TEST}}
=== TEST ===
----
{{Anchor|XCHG}}
=== XCHG ===
----
{{Anchor|XLAT}}
=== XLAT ===
----
{{Anchor|XOR}}
=== XOR ===
----
886c8cba11ea7da29c50b9214b80813ff149bee8
439
438
2024-12-26T18:09:48Z
Asie
351
/* ModR/M byte */
wikitext
text/x-wiki
__NOTOC__
{| class="wikitable" style="text-align: center"
|+ Official V30MZ (80186) Instructions
|-
| [[#AAA|AAA]] || [[#AAD|AAD]] || [[#AAM|AAM]] || [[#AAS|AAS]] || [[#ADC|ADC]] || [[#ADD|ADD]] || [[#AND|AND]] || [[#BOUND|BOUND]] || [[#CALL|CALL]] || [[#CBW|CBW]] || [[#CLC|CLC]]
|-
| [[#CLD|CLD]] || [[#CLI|CLI]] || [[#CMC|CMC]] || [[#CMP|CMP]] || [[#CMPSB|CMPSB]] || [[#CMPSW|CMPSW]] || [[#CS|CS]] || [[#CWD|CWD]] || [[#DAA|DAA]] || [[#DAS|DAS]] || [[#DEC|DEC]]
|-
| [[#DIV|DIV]] || [[#DS|DS]] || [[#ENTER|ENTER]] || [[#ES|ES]] || [[#HLT|HLT]] || [[#IDIV|IDIV]] || [[#IMUL|IMUL]] || [[#IN|IN]] || [[#INC|INC]] || [[#INSB|INSB]] || [[#INSW|INSW]]
|-
| [[#INT|INT]] || [[#INTO|INTO]] || [[#IRET|IRET]] || [[#JA|JA]] || [[#JBE|JBE]] || [[#JC|JC]] || [[#JCXZ|JCXZ]] || [[#JG|JG]] || [[#JGE|JGE]] || [[#JL|JL]] || [[#JLE|JLE]]
|-
| [[#JMP|JMP]] || [[#JNC|JNC]] || [[#JNO|JNO]] || [[#JNP|JNP]] || [[#JNS|JNS]] || [[#JNZ|JNZ]] || [[#JO|JO]] || [[#JP|JP]] || [[#JS|JS]] || [[#JZ|JZ]] || [[#LAHF|LAHF]]
|-
| [[#LDS|LDS]] || [[#LEA|LEA]] || [[#LEAVE|LEAVE]] || [[#LES|LES]] || [[#LOCK|LOCK]] || [[#LODSB|LODSB]] || [[#LODSW|LODSW]] || [[#LOOP|LOOP]] || [[#LOOPE|LOOPE]] || [[#LOOPNE|LOOPNE]] || [[#MOV|MOV]]
|-
| [[#MOVSB|MOVSB]] || [[#MOVSW|MOVSW]] || [[#MUL|MUL]] || [[#NEG|NEG]] || [[#NOP|NOP]] || [[#NOT|NOT]] || [[#OR|OR]] || [[#OUT|OUT]] || [[#OUTSB|OUTSB]] || [[#OUTSW|OUTSW]] || [[#POLL|POLL]]
|-
| [[#POP|POP]] || [[#POPA|POPA]] || [[#POPF|POPF]] || [[#PUSH|PUSH]] || [[#PUSHA|PUSHA]] || [[#PUSHF|PUSHF]] || [[#RCL|RCL]] || [[#RCR|RCR]] || [[#REP|REP]] || [[#REPNE|REPNE]] || [[#RET|RET]]
|-
| [[#RETF|RETF]] || [[#ROL|ROL]] || [[#ROR|ROR]] || [[#SAHF|SAHF]] || [[#SAR|SAR]] || [[#SBB|SBB]] || [[#SCASB|SCASB]] || [[#SCASW|SCASW]] || [[#SHL|SHL]] || [[#SHR|SHR]] || [[#SS|SS]]
|-
| [[#STC|STC]] || [[#STD|STD]] || [[#STI|STI]] || [[#STOSB|STOSB]] || [[#STOSW|STOSW]] || [[#SUB|SUB]] || [[#TEST|TEST]] || [[#XCHG|XCHG]] || [[#XLAT|XLAT]] || [[#XOR|XOR]]
|}
{| class="mw-collapsible mw-collapsed wikitable sortable" style="width: 340px;"
|+ style="white-space:nowrap; border:1px solid; padding:3px; border-color:rgb(162, 169, 177); background-color:rgb(234, 236, 240);" | Intel <-> NEC mnemonic translation table
!Intel
!NEC
|-
| [[#AAA|AAA]]
| [[#AAA|ADJBA]]
|-
| [[#AAD|AAD]]
| [[#AAD|CVTDB]]
|-
| [[#AAM|AAM]]
| [[#AAM|CVTBD]]
|-
| [[#AAS|AAS]]
| [[#AAS|ADJBS]]
|-
| [[#ADC|ADC]]
| [[#ADC|ADDC]]
|-
| [[#ADD|ADD]]
| [[#ADD|ADD]]
|-
| [[#AND|AND]]
| [[#AND|AND]]
|-
| [[#BOUND|BOUND]]
| [[#BOUND|CHKIND]]
|-
| [[#CALL|CALL]]
| [[#CALL|CALL]]
|-
| [[#CBW|CBW]]
| [[#CBW|CVTBW]]
|-
| [[#CLC|CLC]]
| [[#CLC|CLR1 CY]]
|-
| [[#CLD|CLD]]
| [[#CLD|CLR1 DIR]]
|-
| [[#CLI|CLI]]
| [[#CLI|DI]]
|-
| [[#CMC|CMC]]
| [[#CMC|NOT1 CY]]
|-
| [[#CMP|CMP]]
| [[#CMP|CMP]]
|-
| [[#CMPSB|CMPSB]]
| [[#CMPSB|CMPBKB]]
|-
| [[#CMPSW|CMPSW]]
| [[#CMPSW|CMPBKW]]
|-
| [[#CS|CS]]
| [[#CS|PS]]
|-
| [[#CWD|CWD]]
| [[#CWD|CVTWL]]
|-
| [[#DAA|DAA]]
| [[#DAA|ADJ4A]]
|-
| [[#DAS|DAS]]
| [[#DAS|ADJ4S]]
|-
| [[#DEC|DEC]]
| [[#DEC|DEC]]
|-
| [[#DIV|DIV]]
| [[#DIV|DIVU]]
|-
| [[#DS|DS]]
| [[#DS|DS0]]
|-
| [[#ENTER|ENTER]]
| [[#ENTER|PREPARE]]
|-
| [[#ES|ES]]
| [[#ES|DS1]]
|-
| [[#HLT|HLT]]
| [[#HLT|HALT]]
|-
| [[#IDIV|IDIV]]
| [[#IDIV|DIV]]
|-
| [[#IMUL|IMUL]]
| [[#IMUL|MUL]]
|-
| [[#IN|IN]]
| [[#IN|IN]]
|-
| [[#INC|INC]]
| [[#INC|INC]]
|-
| [[#INSB|INSB]]
| [[#INSB|INMB]]
|-
| [[#INSW|INSW]]
| [[#INSW|INMW]]
|-
| [[#INT|INT]]
| [[#INT|BRK]]
|-
| [[#INTO|INTO]]
| [[#INTO|BRKV]]
|-
| [[#IRET|IRET]]
| [[#IRET|RETI]]
|-
| [[#JA|JA]]
| [[#JA|BH]]
|-
| [[#JBE|JBE]]
| [[#JBE|BNH]]
|-
| [[#JC|JC/JB]]
| [[#JC|BC/BL]]
|-
| [[#JCXZ|JCXZ]]
| [[#JCXZ|BCWZ]]
|-
| [[#JG|JG]]
| [[#JG|BGT]]
|-
| [[#JGE|JGE]]
| [[#JGE|BGE]]
|-
| [[#JL|JL]]
| [[#JL|BLT]]
|-
| [[#JLE|JLE]]
| [[#JLE|BLE]]
|-
| [[#JMP|JMP]]
| [[#JMP|BR]]
|-
| [[#JNC|JNC/JAE]]
| [[#JNC|BNC/BNL]]
|-
| [[#JNO|JNO]]
| [[#JNO|BNV]]
|-
| [[#JNP|JNP]]
| [[#JNP|BPO]]
|-
| [[#JNS|JNS]]
| [[#JNS|BP]]
|-
| [[#JNZ|JNZ/JNE]]
| [[#JNZ|BNZ/BNE]]
|-
| [[#JO|JO]]
| [[#JO|BV]]
|-
| [[#JP|JP]]
| [[#JP|BPE]]
|-
| [[#JS|JS]]
| [[#JS|BN]]
|-
| [[#JZ|JZ/JE]]
| [[#JZ|BZ/BE]]
|-
| [[#LAHF|LAHF]]
| [[#LAHF|MOV]]
|-
| [[#LDS|LDS]]
| [[#LDS|MOV]]
|-
| [[#LEA|LEA]]
| [[#LEA|LDEA]]
|-
| [[#LEAVE|LEAVE]]
| [[#LEAVE|DISPOSE]]
|-
| [[#LES|LES]]
| [[#LES|MOV]]
|-
| [[#LOCK|LOCK]]
| [[#LOCK|BUSLOCK]]
|-
| [[#LODSB|LODSB]]
| [[#LODSB|LDMB]]
|-
| [[#LODSW|LODSW]]
| [[#LODSW|LDMW]]
|-
| [[#LOOP|LOOP]]
| [[#LOOP|DBNZ]]
|-
| [[#LOOPE|LOOPE]]
| [[#LOOPE|DBNZE]]
|-
| [[#LOOPNE|LOOPNE]]
| [[#LOOPNE|DBNZNE]]
|-
| [[#MOV|MOV]]
| [[#MOV|MOV]]
|-
| [[#MOVSB|MOVSB]]
| [[#MOVSB|MOVBKB]]
|-
| [[#MOVSW|MOVSW]]
| [[#MOVSW|MOVBKW]]
|-
| [[#MUL|MUL]]
| [[#MUL|MULU]]
|-
| [[#NEG|NEG]]
| [[#NEG|NEG]]
|-
| [[#NOP|NOP]]
| [[#NOP|NOP]]
|-
| [[#NOT|NOT]]
| [[#NOT|NOT]]
|-
| [[#OR|OR]]
| [[#OR|OR]]
|-
| [[#OUT|OUT]]
| [[#OUT|OUT]]
|-
| [[#OUTSB|OUTSB]]
| [[#OUTSB|OUTM]]
|-
| [[#OUTSW|OUTSW]]
| [[#OUTSW|OUTM]]
|-
| [[#POLL|POLL]]
| [[#POLL|POLL]]
|-
| [[#POP|POP]]
| [[#POP|POP]]
|-
| [[#POPA|POPA]]
| [[#POPA|POP]]
|-
| [[#POPF|POPF]]
| [[#POPF|POP]]
|-
| [[#PUSH|PUSH]]
| [[#PUSH|PUSH]]
|-
| [[#PUSHA|PUSHA]]
| [[#PUSHA|PUSH]]
|-
| [[#PUSHF|PUSHF]]
| [[#PUSHF|PUSH]]
|-
| [[#RCL|RCL]]
| [[#RCL|ROLC]]
|-
| [[#RCR|RCR]]
| [[#RCR|RORC]]
|-
| [[#REP|REP/REPE/REPZ]]
| [[#REP|REP/REPE/REPZ]]
|-
| [[#REPNE|REPNE/REPNZ]]
| [[#REPNE|REPNE/REPNZ]]
|-
| [[#RET|RET]]
| [[#RET|RET]]
|-
| [[#RETF|RETF]]
| [[#RETF|RET]]
|-
| [[#ROL|ROL]]
| [[#ROL|ROL]]
|-
| [[#ROR|ROR]]
| [[#ROR|ROR]]
|-
| [[#SAHF|SAHF]]
| [[#SAHF|MOV]]
|-
| [[#SAR|SAR]]
| [[#SAR|SHRA]]
|-
| [[#SBB|SBB]]
| [[#SBB|SUBC]]
|-
| [[#SCASB|SCASB]]
| [[#SCASB|CMPMB]]
|-
| [[#SCASW|SCASW]]
| [[#SCASW|CMPMW]]
|-
| [[#SHL|SHL]]
| [[#SHL|SHL]]
|-
| [[#SHR|SHR]]
| [[#SHR|SHR]]
|-
| [[#SS|SS]]
| [[#SS|SS]]
|-
| [[#STC|STC]]
| [[#STC|SET1 CY]]
|-
| [[#STD|STD]]
| [[#STD|SET1 DIR]]
|-
| [[#STI|STI]]
| [[#STI|EI]]
|-
| [[#STOSB|STOSB]]
| [[#STOSB|STMB]]
|-
| [[#STOSW|STOSW]]
| [[#STOSW|STMW]]
|-
| [[#SUB|SUB]]
| [[#SUB|SUB]]
|-
| [[#TEST|TEST]]
| [[#TEST|TEST]]
|-
| [[#XCHG|XCHG]]
| [[#XCHG|XCH]]
|-
| [[#XLAT|XLAT]]
| [[#XLAT|TRANS]]
|-
| [[#XOR|XOR]]
| [[#XOR|XOR]]
|}
== Official instructions by type ==
{| class="wikitable sortable" style="text-align: center"
!Type
!colspan=16 class="unsortable" | Instructions
|-
| style="text-align:left;" | Memory
| style="" | [[#MOV|MOV]]
| style="" | [[#XCHG|XCHG]]
| style="" | [[#XLAT|XLAT]]
| style="" | [[#LEA|LEA]]
| style="border-right:none;" | [[#LDS|LDS]]
| style="border-left:none;" | [[#LES|LES]]
| style="border-right:none;" | [[#IN|IN]]
| style="border-left:none;" | [[#OUT|OUT]]
| colspan="8" |
|-
| style="text-align:left;" | Ports
| style="border-right:none;" | [[#IN|IN]]
| style="border-left:none;" | [[#OUT|OUT]]
| style="border-right:none;" | [[#INSB|INSB]]
| style="border-left:none;" | [[#OUTSB|OUTSB]]
| style="border-right:none;" | [[#INSW|INSW]]
| style="border-left:none;" | [[#OUTSW|OUTSW]]
| colspan="10" |
|-
| style="text-align:left;" | Arithmetic
| style="border-right:none;" | [[#ADD|ADD]]
| style="border-left:none;" | [[#SUB|SUB]]
| style="border-right:none;" | [[#ADC|ADC]]
| style="border-left:none;" | [[#SBB|SBB]]
| style="border-right:none;" | [[#INC|INC]]
| style="border-left:none;" | [[#DEC|DEC]]
| style="border-right:none;" | [[#MUL|MUL]]
| style="border-left:none;" | [[#DIV|DIV]]
| style="border-right:none;" | [[#IMUL|IMUL]]
| style="border-left:none;" | [[#IDIV|IDIV]]
| style="" | [[#CMP|CMP]]
| style="" | [[#NEG|NEG]]
| colspan="4" |
|-
| style="text-align:left;" | Numeric
| style="" | [[#CBW|CBW]]
| style="" | [[#CWD|CWD]]
| style="" | [[#AAA|AAA]]
| style="" | [[#AAS|AAS]]
| style="" | [[#AAM|AAM]]
| style="" | [[#AAD|AAD]]
| style="" | [[#DAA|DAA]]
| style="" | [[#DAS|DAS]]
| colspan="8" |
|-
| style="text-align:left;" | Shift
| style="border-right:none;" | [[#ROL|ROL]]
| style="border-left:none;" | [[#ROR|ROR]]
| style="border-right:none;" | [[#RCL|RCL]]
| style="border-left:none;" | [[#RCR|RCR]]
| style="border-right:none;" | [[#SHL|SHL]]
| style="border-left:none;" | [[#SHR|SHR]]
| style="" | [[#SAR|SAR]]
| colspan="9" |
|-
| style="text-align:left;" | Bitwise
| style="" | [[#AND|AND]]
| style="" | [[#OR|OR]]
| style="" | [[#XOR|XOR]]
| style="" | [[#NOT|NOT]]
| style="" | [[#TEST|TEST]]
| colspan="11" |
|-
| style="text-align:left;" | Branch
| style="border-right:none;" | [[#JC|JC]]
| style="border-left:none;" | [[#JNC|JNC]]
| style="border-right:none;" | [[#JZ|JZ]]
| style="border-left:none;" | [[#JNZ|JNZ]]
| style="border-right:none;" | [[#JBE|JBE]]
| style="border-left:none;" | [[#JA|JA]]
| style="border-right:none;" | [[#JO|JO]]
| style="border-left:none;" | [[#JNO|JNO]]
| style="border-right:none;" | [[#JP|JP]]
| style="border-left:none;" | [[#JNP|JNP]]
| style="border-right:none;" | [[#JS|JS]]
| style="border-left:none;" | [[#JNS|JNS]]
| style="border-right:none;" | [[#JL|JL]]
| style="border-left:none;" | [[#JGE|JGE]]
| style="border-right:none;" | [[#JLE|JLE]]
| style="border-left:none;" | [[#JG|JG]]
|-
| style="text-align:left;" | Jump
| style="" | [[#JMP|JMP]]
| style="border-right:none;" | [[#CALL|CALL]]
| style="border-left:none;border-right:none;" | [[#RET|RET]]
| style="border-left:none;" | [[#RETF|RETF]]
| colspan="12" |
|-
| style="text-align:left;" | Loop
| style="" | [[#LOOP|LOOP]]
| style="" | [[#LOOPE|LOOPE]]
| style="" | [[#LOOPNE|LOOPNE]]
| colspan="13" |
|-
| style="text-align:left;" | Interrupt
| style="border-right:none;" | [[#INT|INT]]
| style="border-left:none;" | [[#IRET|IRET]]
| style="" | [[#INTO|INTO]]
| style="" | [[#HLT|HLT]]
| style="" | [[#BOUND|BOUND]]
| colspan="11" |
|-
| style="text-align:left;" | Stack
| style="border-right:none;" | [[#PUSH|PUSH]]
| style="border-left:none;" | [[#POP|POP]]
| style="border-right:none;" | [[#PUSHA|PUSHA]]
| style="border-left:none;" | [[#POPA|POPA]]
| style="border-right:none;" | [[#PUSHF|PUSHF]]
| style="border-left:none;" | [[#POPF|POPF]]
| colspan="10" |
|-
| style="text-align:left;" | Flags
| style="border-right:none;" | [[#CLC|CLC]]
| style="border-left:none;" | [[#STC|STC]]
| style="border-right:none;" | [[#CLD|CLD]]
| style="border-left:none;" | [[#STD|STD]]
| style="border-right:none;" | [[#CLI|CLI]]
| style="border-left:none;" | [[#STI|STI]]
| style="" | [[#CMC|CMC]]
| style="border-right:none;" | [[#LAHF|LAHF]]
| style="border-left:none;" | [[#SAHF|SAHF]]
| colspan="7" |
|-
| style="text-align:left;" | Prefix
| style="" | [[#CS|CS]]
| style="" | [[#DS|DS]]
| style="" | [[#ES|ES]]
| style="" | [[#SS|SS]]
| colspan="12" |
|-
| style="text-align:left;" | String
| style="border-right:none;" | [[#REP|REP]]
| style="border-left:none;border-right:none;" | [[#REP|REPE]]
| style="border-left:none;" | [[#REPNE|REPNE]]
| style="" | [[#MOVSB|MOVSB]]
| style="" | [[#MOVSW|MOVSW]]
| style="border-right:none;" | [[#LODSB|LODSB]]
| style="border-left:none;" | [[#STOSB|STOSB]]
| style="border-right:none;" | [[#LODSW|LODSW]]
| style="border-left:none;" | [[#STOSW|STOSW]]
| style="" | [[#CMPSB|CMPSB]]
| style="" | [[#SCASB|SCASB]]
| style="" | [[#CMPSW|CMPSW]]
| style="" | [[#SCASW|SCASW]]
| colspan="3" |
|-
| style="text-align:left;" | Other
| style="" | [[#NOP|NOP]]
| style="border-right:none;" | [[#ENTER|ENTER]]
| style="border-left:none;" | [[#LEAVE|LEAVE]]
| style="" | [[#LOCK|LOCK]]
| style="" | [[#POLL|POLL]]
| colspan="11" |
|}
== Instruction encoding ==
=== ModR/M byte ===
The ModR/M byte is used in most addressing modes which reference a memory location. This byte consists of three bitfield values:
* <tt>oo</tt> - M'''o'''de;
* <tt>rrr</tt> - Two possible functions:
** '''R'''egister (for addressing modes which require both a register and a register/memory operand),
** Opcode extension (for some opcodes' addressing modes which do not have such a requirement);
* <tt>mmm</tt> - Register/'''M'''emory.
The ''Mode'' and ''Register/Memory'' bitfields can refer to a memory location with an optional signed 8-bit (disp8) or 16-bit (disp16) displacement or to a register, as shown in the table below. In some addressing modes, the ''Register'' field also refers to a register; it is always interpreted as if ''Mode'' was equal to <tt>11</tt>.
{| class="wikitable" style="text-align: center"
! R/M \ Mode
! <tt>00</tt>
! <tt>01</tt>
! <tt>10</tt>
! <tt>11</tt> ''(byte)''
! <tt>11</tt> ''(word)''
|-
| <tt>000</tt>
| DS:[BX + SI]
| DS:[BX + SI + disp8]
| DS:[BX + SI + disp16]
| AL
| AX
|-
| <tt>001</tt>
| DS:[BX + DI]
| DS:[BX + DI + disp8]
| DS:[BX + DI + disp16]
| CL
| CX
|-
| <tt>010</tt>
| SS:[BP + SI]
| SS:[BP + SI + disp8]
| SS:[BP + SI + disp16]
| DL
| DX
|-
| <tt>011</tt>
| SS:[BP + DI]
| SS:[BP + DI + disp8]
| SS:[BP + DI + disp16]
| BL
| BX
|-
| <tt>100</tt>
| DS:[SI]
| DS:[SI + disp8]
| DS:[SI + disp16]
| AH
| SP
|-
| <tt>101</tt>
| DS:[DI]
| DS:[DI + disp8]
| DS:[DI + disp16]
| CH
| BP
|-
| <tt>110</tt>
| ''DS:[disp16]''
| SS:[BP + disp8]
| SS:[BP + disp16]
| DH
| SI
|-
| <tt>111</tt>
| DS:[BX]
| DS:[BX + disp8]
| DS:[BX + disp16]
| BH
| DI
|}
Note that (<tt>oo</tt> = <tt>00</tt>, <tt>mmm</tt> = <tt>110</tt>) is a special case.
The instruction encoding lists below refer to this byte as <tt>oorrrmmm</tt> (binary), <tt>/r</tt> (hexadecimal) or <tt>/0</tt> (hexademical, <tt>rrr</tt> used as function <tt>0</tt>).
== Official instructions ==
{{Anchor|AAA}}
=== AAA ===
----
{{Anchor|AAD}}
=== AAD ===
----
{{Anchor|AAM}}
=== AAM ===
----
{{Anchor|AAS}}
=== AAS ===
----
{{Anchor|ADC}}
=== ADC ===
----
{{Anchor|ADD}}
=== ADD ===
----
{{Anchor|AND}}
=== AND ===
----
{{Anchor|BOUND}}
=== BOUND ===
----
{{Anchor|CALL}}
=== CALL ===
----
{{Anchor|CBW}}
=== CBW ===
----
{{Anchor|CLC}}
=== CLC ===
----
{{Anchor|CLD}}
=== CLD ===
----
{{Anchor|CLI}}
=== CLI ===
----
{{Anchor|CMC}}
=== CMC ===
----
{{Anchor|CMP}}
=== CMP ===
----
{{Anchor|CMPSB}}
=== CMPSB ===
----
{{Anchor|CMPSW}}
=== CMPSW ===
----
{{Anchor|CS}}
=== CS ===
----
{{Anchor|CWD}}
=== CWD ===
----
{{Anchor|DAA}}
=== DAA ===
----
{{Anchor|DAS}}
=== DAS ===
----
{{Anchor|DEC}}
=== DEC ===
----
{{Anchor|DIV}}
=== DIV ===
----
{{Anchor|DS}}
=== DS ===
----
{{Anchor|ENTER}}
=== ENTER ===
----
{{Anchor|ES}}
=== ES ===
----
{{Anchor|HLT}}
=== HLT ===
----
{{Anchor|IDIV}}
=== IDIV ===
----
{{Anchor|IMUL}}
=== IMUL ===
----
{{Anchor|IN}}
=== IN ===
----
{{Anchor|INC}}
=== INC ===
----
{{Anchor|INSB}}
=== INSB ===
----
{{Anchor|INSW}}
=== INSW ===
----
{{Anchor|INT}}
=== INT ===
----
{{Anchor|INTO}}
=== INTO ===
----
{{Anchor|IRET}}
=== IRET ===
----
{{Anchor|JA}}
=== JA ===
----
{{Anchor|JBE}}
=== JBE ===
----
{{Anchor|JC}}
=== JC/JB ===
----
{{Anchor|JCXZ}}
=== JCXZ ===
----
{{Anchor|JG}}
=== JG ===
----
{{Anchor|JGE}}
=== JGE ===
----
{{Anchor|JL}}
=== JL ===
----
{{Anchor|JLE}}
=== JLE ===
----
{{Anchor|JMP}}
=== JMP ===
----
{{Anchor|JNC}}
=== JNC/JAE ===
----
{{Anchor|JNO}}
=== JNO ===
----
{{Anchor|JNP}}
=== JNP ===
----
{{Anchor|JNS}}
=== JNS ===
----
{{Anchor|JNZ}}
=== JNZ/JNE ===
----
{{Anchor|JO}}
=== JO ===
----
{{Anchor|JP}}
=== JP ===
----
{{Anchor|JS}}
=== JS ===
----
{{Anchor|JZ}}
=== JZ/JE ===
----
{{Anchor|LAHF}}
=== LAHF ===
----
{{Anchor|LDS}}
=== LDS ===
----
{{Anchor|LEA}}
=== LEA ===
----
{{Anchor|LEAVE}}
=== LEAVE ===
----
{{Anchor|LES}}
=== LES ===
----
{{Anchor|LOCK}}
=== LOCK ===
----
{{Anchor|LODSB}}
=== LODSB ===
----
{{Anchor|LODSW}}
=== LODSW ===
----
{{Anchor|LOOP}}
=== LOOP ===
----
{{Anchor|LOOPE}}
=== LOOPE ===
----
{{Anchor|LOOPNE}}
=== LOOPNE ===
----
{{Anchor|MOV}}
=== MOV ===
----
{{Anchor|MOVSB}}
=== MOVSB ===
----
{{Anchor|MOVSW}}
=== MOVSW ===
----
{{Anchor|MUL}}
=== MUL ===
----
{{Anchor|NEG}}
=== NEG ===
----
{{Anchor|NOP}}
=== NOP ===
----
{{Anchor|NOT}}
=== NOT ===
----
{{Anchor|OR}}
=== OR ===
----
{{Anchor|OUT}}
=== OUT ===
----
{{Anchor|OUTSB}}
=== OUTSB ===
----
{{Anchor|OUTSW}}
=== OUTSW ===
----
{{Anchor|POLL}}
=== POLL ===
----
{{Anchor|POP}}
=== POP ===
----
{{Anchor|POPA}}
=== POPA ===
----
{{Anchor|POPF}}
=== POPF ===
----
{{Anchor|PUSH}}
=== PUSH ===
----
{{Anchor|PUSHA}}
=== PUSHA ===
----
{{Anchor|PUSHF}}
=== PUSHF ===
----
{{Anchor|RCL}}
=== RCL ===
----
{{Anchor|RCR}}
=== RCR ===
----
{{Anchor|REP}}
=== REP/REPE/REPZ ===
----
{{Anchor|REPNE}}
=== REPNE/REPNZ ===
----
{{Anchor|RET}}
=== RET ===
----
{{Anchor|RETF}}
=== RETF ===
----
{{Anchor|ROL}}
=== ROL ===
----
{{Anchor|ROR}}
=== ROR ===
----
{{Anchor|SAHF}}
=== SAHF ===
----
{{Anchor|SAR}}
=== SAR ===
----
{{Anchor|SBB}}
=== SBB ===
----
{{Anchor|SCASB}}
=== SCASB ===
----
{{Anchor|SCASW}}
=== SCASW ===
----
{{Anchor|SHL}}
=== SHL ===
----
{{Anchor|SHR}}
=== SHR ===
----
{{Anchor|SS}}
=== SS ===
----
{{Anchor|STC}}
=== STC ===
----
{{Anchor|STD}}
=== STD ===
----
{{Anchor|STI}}
=== STI ===
----
{{Anchor|STOSB}}
=== STOSB ===
----
{{Anchor|STOSW}}
=== STOSW ===
----
{{Anchor|SUB}}
=== SUB ===
----
{{Anchor|TEST}}
=== TEST ===
----
{{Anchor|XCHG}}
=== XCHG ===
----
{{Anchor|XLAT}}
=== XLAT ===
----
{{Anchor|XOR}}
=== XOR ===
----
45480ee9df666f29bd83589225959eb52f35c630
440
439
2024-12-26T18:18:02Z
Asie
351
/* ADD */ first attempt at an instruction encoding table
wikitext
text/x-wiki
__NOTOC__
{| class="wikitable" style="text-align: center"
|+ Official V30MZ (80186) Instructions
|-
| [[#AAA|AAA]] || [[#AAD|AAD]] || [[#AAM|AAM]] || [[#AAS|AAS]] || [[#ADC|ADC]] || [[#ADD|ADD]] || [[#AND|AND]] || [[#BOUND|BOUND]] || [[#CALL|CALL]] || [[#CBW|CBW]] || [[#CLC|CLC]]
|-
| [[#CLD|CLD]] || [[#CLI|CLI]] || [[#CMC|CMC]] || [[#CMP|CMP]] || [[#CMPSB|CMPSB]] || [[#CMPSW|CMPSW]] || [[#CS|CS]] || [[#CWD|CWD]] || [[#DAA|DAA]] || [[#DAS|DAS]] || [[#DEC|DEC]]
|-
| [[#DIV|DIV]] || [[#DS|DS]] || [[#ENTER|ENTER]] || [[#ES|ES]] || [[#HLT|HLT]] || [[#IDIV|IDIV]] || [[#IMUL|IMUL]] || [[#IN|IN]] || [[#INC|INC]] || [[#INSB|INSB]] || [[#INSW|INSW]]
|-
| [[#INT|INT]] || [[#INTO|INTO]] || [[#IRET|IRET]] || [[#JA|JA]] || [[#JBE|JBE]] || [[#JC|JC]] || [[#JCXZ|JCXZ]] || [[#JG|JG]] || [[#JGE|JGE]] || [[#JL|JL]] || [[#JLE|JLE]]
|-
| [[#JMP|JMP]] || [[#JNC|JNC]] || [[#JNO|JNO]] || [[#JNP|JNP]] || [[#JNS|JNS]] || [[#JNZ|JNZ]] || [[#JO|JO]] || [[#JP|JP]] || [[#JS|JS]] || [[#JZ|JZ]] || [[#LAHF|LAHF]]
|-
| [[#LDS|LDS]] || [[#LEA|LEA]] || [[#LEAVE|LEAVE]] || [[#LES|LES]] || [[#LOCK|LOCK]] || [[#LODSB|LODSB]] || [[#LODSW|LODSW]] || [[#LOOP|LOOP]] || [[#LOOPE|LOOPE]] || [[#LOOPNE|LOOPNE]] || [[#MOV|MOV]]
|-
| [[#MOVSB|MOVSB]] || [[#MOVSW|MOVSW]] || [[#MUL|MUL]] || [[#NEG|NEG]] || [[#NOP|NOP]] || [[#NOT|NOT]] || [[#OR|OR]] || [[#OUT|OUT]] || [[#OUTSB|OUTSB]] || [[#OUTSW|OUTSW]] || [[#POLL|POLL]]
|-
| [[#POP|POP]] || [[#POPA|POPA]] || [[#POPF|POPF]] || [[#PUSH|PUSH]] || [[#PUSHA|PUSHA]] || [[#PUSHF|PUSHF]] || [[#RCL|RCL]] || [[#RCR|RCR]] || [[#REP|REP]] || [[#REPNE|REPNE]] || [[#RET|RET]]
|-
| [[#RETF|RETF]] || [[#ROL|ROL]] || [[#ROR|ROR]] || [[#SAHF|SAHF]] || [[#SAR|SAR]] || [[#SBB|SBB]] || [[#SCASB|SCASB]] || [[#SCASW|SCASW]] || [[#SHL|SHL]] || [[#SHR|SHR]] || [[#SS|SS]]
|-
| [[#STC|STC]] || [[#STD|STD]] || [[#STI|STI]] || [[#STOSB|STOSB]] || [[#STOSW|STOSW]] || [[#SUB|SUB]] || [[#TEST|TEST]] || [[#XCHG|XCHG]] || [[#XLAT|XLAT]] || [[#XOR|XOR]]
|}
{| class="mw-collapsible mw-collapsed wikitable sortable" style="width: 340px;"
|+ style="white-space:nowrap; border:1px solid; padding:3px; border-color:rgb(162, 169, 177); background-color:rgb(234, 236, 240);" | Intel <-> NEC mnemonic translation table
!Intel
!NEC
|-
| [[#AAA|AAA]]
| [[#AAA|ADJBA]]
|-
| [[#AAD|AAD]]
| [[#AAD|CVTDB]]
|-
| [[#AAM|AAM]]
| [[#AAM|CVTBD]]
|-
| [[#AAS|AAS]]
| [[#AAS|ADJBS]]
|-
| [[#ADC|ADC]]
| [[#ADC|ADDC]]
|-
| [[#ADD|ADD]]
| [[#ADD|ADD]]
|-
| [[#AND|AND]]
| [[#AND|AND]]
|-
| [[#BOUND|BOUND]]
| [[#BOUND|CHKIND]]
|-
| [[#CALL|CALL]]
| [[#CALL|CALL]]
|-
| [[#CBW|CBW]]
| [[#CBW|CVTBW]]
|-
| [[#CLC|CLC]]
| [[#CLC|CLR1 CY]]
|-
| [[#CLD|CLD]]
| [[#CLD|CLR1 DIR]]
|-
| [[#CLI|CLI]]
| [[#CLI|DI]]
|-
| [[#CMC|CMC]]
| [[#CMC|NOT1 CY]]
|-
| [[#CMP|CMP]]
| [[#CMP|CMP]]
|-
| [[#CMPSB|CMPSB]]
| [[#CMPSB|CMPBKB]]
|-
| [[#CMPSW|CMPSW]]
| [[#CMPSW|CMPBKW]]
|-
| [[#CS|CS]]
| [[#CS|PS]]
|-
| [[#CWD|CWD]]
| [[#CWD|CVTWL]]
|-
| [[#DAA|DAA]]
| [[#DAA|ADJ4A]]
|-
| [[#DAS|DAS]]
| [[#DAS|ADJ4S]]
|-
| [[#DEC|DEC]]
| [[#DEC|DEC]]
|-
| [[#DIV|DIV]]
| [[#DIV|DIVU]]
|-
| [[#DS|DS]]
| [[#DS|DS0]]
|-
| [[#ENTER|ENTER]]
| [[#ENTER|PREPARE]]
|-
| [[#ES|ES]]
| [[#ES|DS1]]
|-
| [[#HLT|HLT]]
| [[#HLT|HALT]]
|-
| [[#IDIV|IDIV]]
| [[#IDIV|DIV]]
|-
| [[#IMUL|IMUL]]
| [[#IMUL|MUL]]
|-
| [[#IN|IN]]
| [[#IN|IN]]
|-
| [[#INC|INC]]
| [[#INC|INC]]
|-
| [[#INSB|INSB]]
| [[#INSB|INMB]]
|-
| [[#INSW|INSW]]
| [[#INSW|INMW]]
|-
| [[#INT|INT]]
| [[#INT|BRK]]
|-
| [[#INTO|INTO]]
| [[#INTO|BRKV]]
|-
| [[#IRET|IRET]]
| [[#IRET|RETI]]
|-
| [[#JA|JA]]
| [[#JA|BH]]
|-
| [[#JBE|JBE]]
| [[#JBE|BNH]]
|-
| [[#JC|JC/JB]]
| [[#JC|BC/BL]]
|-
| [[#JCXZ|JCXZ]]
| [[#JCXZ|BCWZ]]
|-
| [[#JG|JG]]
| [[#JG|BGT]]
|-
| [[#JGE|JGE]]
| [[#JGE|BGE]]
|-
| [[#JL|JL]]
| [[#JL|BLT]]
|-
| [[#JLE|JLE]]
| [[#JLE|BLE]]
|-
| [[#JMP|JMP]]
| [[#JMP|BR]]
|-
| [[#JNC|JNC/JAE]]
| [[#JNC|BNC/BNL]]
|-
| [[#JNO|JNO]]
| [[#JNO|BNV]]
|-
| [[#JNP|JNP]]
| [[#JNP|BPO]]
|-
| [[#JNS|JNS]]
| [[#JNS|BP]]
|-
| [[#JNZ|JNZ/JNE]]
| [[#JNZ|BNZ/BNE]]
|-
| [[#JO|JO]]
| [[#JO|BV]]
|-
| [[#JP|JP]]
| [[#JP|BPE]]
|-
| [[#JS|JS]]
| [[#JS|BN]]
|-
| [[#JZ|JZ/JE]]
| [[#JZ|BZ/BE]]
|-
| [[#LAHF|LAHF]]
| [[#LAHF|MOV]]
|-
| [[#LDS|LDS]]
| [[#LDS|MOV]]
|-
| [[#LEA|LEA]]
| [[#LEA|LDEA]]
|-
| [[#LEAVE|LEAVE]]
| [[#LEAVE|DISPOSE]]
|-
| [[#LES|LES]]
| [[#LES|MOV]]
|-
| [[#LOCK|LOCK]]
| [[#LOCK|BUSLOCK]]
|-
| [[#LODSB|LODSB]]
| [[#LODSB|LDMB]]
|-
| [[#LODSW|LODSW]]
| [[#LODSW|LDMW]]
|-
| [[#LOOP|LOOP]]
| [[#LOOP|DBNZ]]
|-
| [[#LOOPE|LOOPE]]
| [[#LOOPE|DBNZE]]
|-
| [[#LOOPNE|LOOPNE]]
| [[#LOOPNE|DBNZNE]]
|-
| [[#MOV|MOV]]
| [[#MOV|MOV]]
|-
| [[#MOVSB|MOVSB]]
| [[#MOVSB|MOVBKB]]
|-
| [[#MOVSW|MOVSW]]
| [[#MOVSW|MOVBKW]]
|-
| [[#MUL|MUL]]
| [[#MUL|MULU]]
|-
| [[#NEG|NEG]]
| [[#NEG|NEG]]
|-
| [[#NOP|NOP]]
| [[#NOP|NOP]]
|-
| [[#NOT|NOT]]
| [[#NOT|NOT]]
|-
| [[#OR|OR]]
| [[#OR|OR]]
|-
| [[#OUT|OUT]]
| [[#OUT|OUT]]
|-
| [[#OUTSB|OUTSB]]
| [[#OUTSB|OUTM]]
|-
| [[#OUTSW|OUTSW]]
| [[#OUTSW|OUTM]]
|-
| [[#POLL|POLL]]
| [[#POLL|POLL]]
|-
| [[#POP|POP]]
| [[#POP|POP]]
|-
| [[#POPA|POPA]]
| [[#POPA|POP]]
|-
| [[#POPF|POPF]]
| [[#POPF|POP]]
|-
| [[#PUSH|PUSH]]
| [[#PUSH|PUSH]]
|-
| [[#PUSHA|PUSHA]]
| [[#PUSHA|PUSH]]
|-
| [[#PUSHF|PUSHF]]
| [[#PUSHF|PUSH]]
|-
| [[#RCL|RCL]]
| [[#RCL|ROLC]]
|-
| [[#RCR|RCR]]
| [[#RCR|RORC]]
|-
| [[#REP|REP/REPE/REPZ]]
| [[#REP|REP/REPE/REPZ]]
|-
| [[#REPNE|REPNE/REPNZ]]
| [[#REPNE|REPNE/REPNZ]]
|-
| [[#RET|RET]]
| [[#RET|RET]]
|-
| [[#RETF|RETF]]
| [[#RETF|RET]]
|-
| [[#ROL|ROL]]
| [[#ROL|ROL]]
|-
| [[#ROR|ROR]]
| [[#ROR|ROR]]
|-
| [[#SAHF|SAHF]]
| [[#SAHF|MOV]]
|-
| [[#SAR|SAR]]
| [[#SAR|SHRA]]
|-
| [[#SBB|SBB]]
| [[#SBB|SUBC]]
|-
| [[#SCASB|SCASB]]
| [[#SCASB|CMPMB]]
|-
| [[#SCASW|SCASW]]
| [[#SCASW|CMPMW]]
|-
| [[#SHL|SHL]]
| [[#SHL|SHL]]
|-
| [[#SHR|SHR]]
| [[#SHR|SHR]]
|-
| [[#SS|SS]]
| [[#SS|SS]]
|-
| [[#STC|STC]]
| [[#STC|SET1 CY]]
|-
| [[#STD|STD]]
| [[#STD|SET1 DIR]]
|-
| [[#STI|STI]]
| [[#STI|EI]]
|-
| [[#STOSB|STOSB]]
| [[#STOSB|STMB]]
|-
| [[#STOSW|STOSW]]
| [[#STOSW|STMW]]
|-
| [[#SUB|SUB]]
| [[#SUB|SUB]]
|-
| [[#TEST|TEST]]
| [[#TEST|TEST]]
|-
| [[#XCHG|XCHG]]
| [[#XCHG|XCH]]
|-
| [[#XLAT|XLAT]]
| [[#XLAT|TRANS]]
|-
| [[#XOR|XOR]]
| [[#XOR|XOR]]
|}
== Official instructions by type ==
{| class="wikitable sortable" style="text-align: center"
!Type
!colspan=16 class="unsortable" | Instructions
|-
| style="text-align:left;" | Memory
| style="" | [[#MOV|MOV]]
| style="" | [[#XCHG|XCHG]]
| style="" | [[#XLAT|XLAT]]
| style="" | [[#LEA|LEA]]
| style="border-right:none;" | [[#LDS|LDS]]
| style="border-left:none;" | [[#LES|LES]]
| style="border-right:none;" | [[#IN|IN]]
| style="border-left:none;" | [[#OUT|OUT]]
| colspan="8" |
|-
| style="text-align:left;" | Ports
| style="border-right:none;" | [[#IN|IN]]
| style="border-left:none;" | [[#OUT|OUT]]
| style="border-right:none;" | [[#INSB|INSB]]
| style="border-left:none;" | [[#OUTSB|OUTSB]]
| style="border-right:none;" | [[#INSW|INSW]]
| style="border-left:none;" | [[#OUTSW|OUTSW]]
| colspan="10" |
|-
| style="text-align:left;" | Arithmetic
| style="border-right:none;" | [[#ADD|ADD]]
| style="border-left:none;" | [[#SUB|SUB]]
| style="border-right:none;" | [[#ADC|ADC]]
| style="border-left:none;" | [[#SBB|SBB]]
| style="border-right:none;" | [[#INC|INC]]
| style="border-left:none;" | [[#DEC|DEC]]
| style="border-right:none;" | [[#MUL|MUL]]
| style="border-left:none;" | [[#DIV|DIV]]
| style="border-right:none;" | [[#IMUL|IMUL]]
| style="border-left:none;" | [[#IDIV|IDIV]]
| style="" | [[#CMP|CMP]]
| style="" | [[#NEG|NEG]]
| colspan="4" |
|-
| style="text-align:left;" | Numeric
| style="" | [[#CBW|CBW]]
| style="" | [[#CWD|CWD]]
| style="" | [[#AAA|AAA]]
| style="" | [[#AAS|AAS]]
| style="" | [[#AAM|AAM]]
| style="" | [[#AAD|AAD]]
| style="" | [[#DAA|DAA]]
| style="" | [[#DAS|DAS]]
| colspan="8" |
|-
| style="text-align:left;" | Shift
| style="border-right:none;" | [[#ROL|ROL]]
| style="border-left:none;" | [[#ROR|ROR]]
| style="border-right:none;" | [[#RCL|RCL]]
| style="border-left:none;" | [[#RCR|RCR]]
| style="border-right:none;" | [[#SHL|SHL]]
| style="border-left:none;" | [[#SHR|SHR]]
| style="" | [[#SAR|SAR]]
| colspan="9" |
|-
| style="text-align:left;" | Bitwise
| style="" | [[#AND|AND]]
| style="" | [[#OR|OR]]
| style="" | [[#XOR|XOR]]
| style="" | [[#NOT|NOT]]
| style="" | [[#TEST|TEST]]
| colspan="11" |
|-
| style="text-align:left;" | Branch
| style="border-right:none;" | [[#JC|JC]]
| style="border-left:none;" | [[#JNC|JNC]]
| style="border-right:none;" | [[#JZ|JZ]]
| style="border-left:none;" | [[#JNZ|JNZ]]
| style="border-right:none;" | [[#JBE|JBE]]
| style="border-left:none;" | [[#JA|JA]]
| style="border-right:none;" | [[#JO|JO]]
| style="border-left:none;" | [[#JNO|JNO]]
| style="border-right:none;" | [[#JP|JP]]
| style="border-left:none;" | [[#JNP|JNP]]
| style="border-right:none;" | [[#JS|JS]]
| style="border-left:none;" | [[#JNS|JNS]]
| style="border-right:none;" | [[#JL|JL]]
| style="border-left:none;" | [[#JGE|JGE]]
| style="border-right:none;" | [[#JLE|JLE]]
| style="border-left:none;" | [[#JG|JG]]
|-
| style="text-align:left;" | Jump
| style="" | [[#JMP|JMP]]
| style="border-right:none;" | [[#CALL|CALL]]
| style="border-left:none;border-right:none;" | [[#RET|RET]]
| style="border-left:none;" | [[#RETF|RETF]]
| colspan="12" |
|-
| style="text-align:left;" | Loop
| style="" | [[#LOOP|LOOP]]
| style="" | [[#LOOPE|LOOPE]]
| style="" | [[#LOOPNE|LOOPNE]]
| colspan="13" |
|-
| style="text-align:left;" | Interrupt
| style="border-right:none;" | [[#INT|INT]]
| style="border-left:none;" | [[#IRET|IRET]]
| style="" | [[#INTO|INTO]]
| style="" | [[#HLT|HLT]]
| style="" | [[#BOUND|BOUND]]
| colspan="11" |
|-
| style="text-align:left;" | Stack
| style="border-right:none;" | [[#PUSH|PUSH]]
| style="border-left:none;" | [[#POP|POP]]
| style="border-right:none;" | [[#PUSHA|PUSHA]]
| style="border-left:none;" | [[#POPA|POPA]]
| style="border-right:none;" | [[#PUSHF|PUSHF]]
| style="border-left:none;" | [[#POPF|POPF]]
| colspan="10" |
|-
| style="text-align:left;" | Flags
| style="border-right:none;" | [[#CLC|CLC]]
| style="border-left:none;" | [[#STC|STC]]
| style="border-right:none;" | [[#CLD|CLD]]
| style="border-left:none;" | [[#STD|STD]]
| style="border-right:none;" | [[#CLI|CLI]]
| style="border-left:none;" | [[#STI|STI]]
| style="" | [[#CMC|CMC]]
| style="border-right:none;" | [[#LAHF|LAHF]]
| style="border-left:none;" | [[#SAHF|SAHF]]
| colspan="7" |
|-
| style="text-align:left;" | Prefix
| style="" | [[#CS|CS]]
| style="" | [[#DS|DS]]
| style="" | [[#ES|ES]]
| style="" | [[#SS|SS]]
| colspan="12" |
|-
| style="text-align:left;" | String
| style="border-right:none;" | [[#REP|REP]]
| style="border-left:none;border-right:none;" | [[#REP|REPE]]
| style="border-left:none;" | [[#REPNE|REPNE]]
| style="" | [[#MOVSB|MOVSB]]
| style="" | [[#MOVSW|MOVSW]]
| style="border-right:none;" | [[#LODSB|LODSB]]
| style="border-left:none;" | [[#STOSB|STOSB]]
| style="border-right:none;" | [[#LODSW|LODSW]]
| style="border-left:none;" | [[#STOSW|STOSW]]
| style="" | [[#CMPSB|CMPSB]]
| style="" | [[#SCASB|SCASB]]
| style="" | [[#CMPSW|CMPSW]]
| style="" | [[#SCASW|SCASW]]
| colspan="3" |
|-
| style="text-align:left;" | Other
| style="" | [[#NOP|NOP]]
| style="border-right:none;" | [[#ENTER|ENTER]]
| style="border-left:none;" | [[#LEAVE|LEAVE]]
| style="" | [[#LOCK|LOCK]]
| style="" | [[#POLL|POLL]]
| colspan="11" |
|}
== Instruction encoding ==
=== ModR/M byte ===
The ModR/M byte is used in most addressing modes which reference a memory location. This byte consists of three bitfield values:
* <tt>oo</tt> - M'''o'''de;
* <tt>rrr</tt> - Two possible functions:
** '''R'''egister (for addressing modes which require both a register and a register/memory operand),
** Opcode extension (for some opcodes' addressing modes which do not have such a requirement);
* <tt>mmm</tt> - Register/'''M'''emory.
The ''Mode'' and ''Register/Memory'' bitfields can refer to a memory location with an optional signed 8-bit (disp8) or 16-bit (disp16) displacement or to a register, as shown in the table below. In some addressing modes, the ''Register'' field also refers to a register; it is always interpreted as if ''Mode'' was equal to <tt>11</tt>.
{| class="wikitable" style="text-align: center"
! R/M \ Mode
! <tt>00</tt>
! <tt>01</tt>
! <tt>10</tt>
! <tt>11</tt> ''(byte)''
! <tt>11</tt> ''(word)''
|-
| <tt>000</tt>
| DS:[BX + SI]
| DS:[BX + SI + disp8]
| DS:[BX + SI + disp16]
| AL
| AX
|-
| <tt>001</tt>
| DS:[BX + DI]
| DS:[BX + DI + disp8]
| DS:[BX + DI + disp16]
| CL
| CX
|-
| <tt>010</tt>
| SS:[BP + SI]
| SS:[BP + SI + disp8]
| SS:[BP + SI + disp16]
| DL
| DX
|-
| <tt>011</tt>
| SS:[BP + DI]
| SS:[BP + DI + disp8]
| SS:[BP + DI + disp16]
| BL
| BX
|-
| <tt>100</tt>
| DS:[SI]
| DS:[SI + disp8]
| DS:[SI + disp16]
| AH
| SP
|-
| <tt>101</tt>
| DS:[DI]
| DS:[DI + disp8]
| DS:[DI + disp16]
| CH
| BP
|-
| <tt>110</tt>
| ''DS:[disp16]''
| SS:[BP + disp8]
| SS:[BP + disp16]
| DH
| SI
|-
| <tt>111</tt>
| DS:[BX]
| DS:[BX + disp8]
| DS:[BX + disp16]
| BH
| DI
|}
Note that (<tt>oo</tt> = <tt>00</tt>, <tt>mmm</tt> = <tt>110</tt>) is a special case.
The instruction encoding lists below refer to this byte as <tt>oorrrmmm</tt> (binary), <tt>/r</tt> (hexadecimal) or <tt>/0</tt> (hexademical, <tt>rrr</tt> used as function <tt>0</tt>).
== Official instructions ==
{{Anchor|AAA}}
=== AAA ===
----
{{Anchor|AAD}}
=== AAD ===
----
{{Anchor|AAM}}
=== AAM ===
----
{{Anchor|AAS}}
=== AAS ===
----
{{Anchor|ADC}}
=== ADC ===
----
{{Anchor|ADD}}
=== ADD ===
{| class="wikitable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| ADD AL, imm || <tt>04 ii</tt> || <tt>00000100 iiiiiiii</tt> || 2 || 1
|-
| ADD AX, imm || <tt>05 ii ii</tt> || <tt>00000101 iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| ADD mem8, imm8 || <tt>80 /0 ii</tt> || <tt>10000000 oo000mmm iiiiiiii</tt> || 3+ || 3
|-
| ADD mem16, imm16 || <tt>81 /0 ii ii</tt> || <tt>10000001 oo000mmm iiiiiiii iiiiiiii</tt> || 4+ || 3
|-
| ADD mem16, simm8 || <tt>83 /0 ii ii</tt> || <tt>10000011 oo000mmm iiiiiiii iiiiiiii</tt> || 4+ || 3
|-
| ADD mem8, reg8 || <tt>00 /r</tt> || <tt>00000000 oorrrmmm</tt> || 2+ || 3
|-
| ADD mem16, reg16 || <tt>01 /r</tt> || <tt>00000001 oorrrmmm</tt> || 2+ || 3
|-
| ADD reg8, imm8 || <tt>80 /0 ii</tt> || <tt>10000000 11000mmm iiiiiiii</tt> || 3+ || 1
|-
| ADD reg16, imm16 || <tt>81 /0 ii ii</tt> || <tt>10000001 11000mmm iiiiiiii iiiiiiii</tt> || 4+ || 1
|-
| ADD reg16, simm8 || <tt>83 /0 ii ii</tt> || <tt>10000011 11000mmm iiiiiiii iiiiiiii</tt> || 4+ || 1
|-
| ADD reg8, mem8 || <tt>02 /r</tt> || <tt>00000010 oorrrmmm</tt> || 2+ || 2
|-
| ADD reg16, mem16 || <tt>03 /r</tt> || <tt>00000011 oorrrmmm</tt> || 2+ || 2
|-
| ADD reg8, reg8 || <tt>00 /r</tt> || <tt>000000.0 11rrrmmm</tt> || 2 || 1
|-
| ADD reg16, reg16 || <tt>01 /r</tt> || <tt>000000.1 11rrrmmm</tt> || 2 || 1
|}
----
{{Anchor|AND}}
=== AND ===
----
{{Anchor|BOUND}}
=== BOUND ===
----
{{Anchor|CALL}}
=== CALL ===
----
{{Anchor|CBW}}
=== CBW ===
----
{{Anchor|CLC}}
=== CLC ===
----
{{Anchor|CLD}}
=== CLD ===
----
{{Anchor|CLI}}
=== CLI ===
----
{{Anchor|CMC}}
=== CMC ===
----
{{Anchor|CMP}}
=== CMP ===
----
{{Anchor|CMPSB}}
=== CMPSB ===
----
{{Anchor|CMPSW}}
=== CMPSW ===
----
{{Anchor|CS}}
=== CS ===
----
{{Anchor|CWD}}
=== CWD ===
----
{{Anchor|DAA}}
=== DAA ===
----
{{Anchor|DAS}}
=== DAS ===
----
{{Anchor|DEC}}
=== DEC ===
----
{{Anchor|DIV}}
=== DIV ===
----
{{Anchor|DS}}
=== DS ===
----
{{Anchor|ENTER}}
=== ENTER ===
----
{{Anchor|ES}}
=== ES ===
----
{{Anchor|HLT}}
=== HLT ===
----
{{Anchor|IDIV}}
=== IDIV ===
----
{{Anchor|IMUL}}
=== IMUL ===
----
{{Anchor|IN}}
=== IN ===
----
{{Anchor|INC}}
=== INC ===
----
{{Anchor|INSB}}
=== INSB ===
----
{{Anchor|INSW}}
=== INSW ===
----
{{Anchor|INT}}
=== INT ===
----
{{Anchor|INTO}}
=== INTO ===
----
{{Anchor|IRET}}
=== IRET ===
----
{{Anchor|JA}}
=== JA ===
----
{{Anchor|JBE}}
=== JBE ===
----
{{Anchor|JC}}
=== JC/JB ===
----
{{Anchor|JCXZ}}
=== JCXZ ===
----
{{Anchor|JG}}
=== JG ===
----
{{Anchor|JGE}}
=== JGE ===
----
{{Anchor|JL}}
=== JL ===
----
{{Anchor|JLE}}
=== JLE ===
----
{{Anchor|JMP}}
=== JMP ===
----
{{Anchor|JNC}}
=== JNC/JAE ===
----
{{Anchor|JNO}}
=== JNO ===
----
{{Anchor|JNP}}
=== JNP ===
----
{{Anchor|JNS}}
=== JNS ===
----
{{Anchor|JNZ}}
=== JNZ/JNE ===
----
{{Anchor|JO}}
=== JO ===
----
{{Anchor|JP}}
=== JP ===
----
{{Anchor|JS}}
=== JS ===
----
{{Anchor|JZ}}
=== JZ/JE ===
----
{{Anchor|LAHF}}
=== LAHF ===
----
{{Anchor|LDS}}
=== LDS ===
----
{{Anchor|LEA}}
=== LEA ===
----
{{Anchor|LEAVE}}
=== LEAVE ===
----
{{Anchor|LES}}
=== LES ===
----
{{Anchor|LOCK}}
=== LOCK ===
----
{{Anchor|LODSB}}
=== LODSB ===
----
{{Anchor|LODSW}}
=== LODSW ===
----
{{Anchor|LOOP}}
=== LOOP ===
----
{{Anchor|LOOPE}}
=== LOOPE ===
----
{{Anchor|LOOPNE}}
=== LOOPNE ===
----
{{Anchor|MOV}}
=== MOV ===
----
{{Anchor|MOVSB}}
=== MOVSB ===
----
{{Anchor|MOVSW}}
=== MOVSW ===
----
{{Anchor|MUL}}
=== MUL ===
----
{{Anchor|NEG}}
=== NEG ===
----
{{Anchor|NOP}}
=== NOP ===
----
{{Anchor|NOT}}
=== NOT ===
----
{{Anchor|OR}}
=== OR ===
----
{{Anchor|OUT}}
=== OUT ===
----
{{Anchor|OUTSB}}
=== OUTSB ===
----
{{Anchor|OUTSW}}
=== OUTSW ===
----
{{Anchor|POLL}}
=== POLL ===
----
{{Anchor|POP}}
=== POP ===
----
{{Anchor|POPA}}
=== POPA ===
----
{{Anchor|POPF}}
=== POPF ===
----
{{Anchor|PUSH}}
=== PUSH ===
----
{{Anchor|PUSHA}}
=== PUSHA ===
----
{{Anchor|PUSHF}}
=== PUSHF ===
----
{{Anchor|RCL}}
=== RCL ===
----
{{Anchor|RCR}}
=== RCR ===
----
{{Anchor|REP}}
=== REP/REPE/REPZ ===
----
{{Anchor|REPNE}}
=== REPNE/REPNZ ===
----
{{Anchor|RET}}
=== RET ===
----
{{Anchor|RETF}}
=== RETF ===
----
{{Anchor|ROL}}
=== ROL ===
----
{{Anchor|ROR}}
=== ROR ===
----
{{Anchor|SAHF}}
=== SAHF ===
----
{{Anchor|SAR}}
=== SAR ===
----
{{Anchor|SBB}}
=== SBB ===
----
{{Anchor|SCASB}}
=== SCASB ===
----
{{Anchor|SCASW}}
=== SCASW ===
----
{{Anchor|SHL}}
=== SHL ===
----
{{Anchor|SHR}}
=== SHR ===
----
{{Anchor|SS}}
=== SS ===
----
{{Anchor|STC}}
=== STC ===
----
{{Anchor|STD}}
=== STD ===
----
{{Anchor|STI}}
=== STI ===
----
{{Anchor|STOSB}}
=== STOSB ===
----
{{Anchor|STOSW}}
=== STOSW ===
----
{{Anchor|SUB}}
=== SUB ===
----
{{Anchor|TEST}}
=== TEST ===
----
{{Anchor|XCHG}}
=== XCHG ===
----
{{Anchor|XLAT}}
=== XLAT ===
----
{{Anchor|XOR}}
=== XOR ===
----
b233e4a3c2aaa70239e917528e82534b0ce5dc08
441
440
2024-12-26T18:18:41Z
Asie
351
/* ADD */
wikitext
text/x-wiki
__NOTOC__
{| class="wikitable" style="text-align: center"
|+ Official V30MZ (80186) Instructions
|-
| [[#AAA|AAA]] || [[#AAD|AAD]] || [[#AAM|AAM]] || [[#AAS|AAS]] || [[#ADC|ADC]] || [[#ADD|ADD]] || [[#AND|AND]] || [[#BOUND|BOUND]] || [[#CALL|CALL]] || [[#CBW|CBW]] || [[#CLC|CLC]]
|-
| [[#CLD|CLD]] || [[#CLI|CLI]] || [[#CMC|CMC]] || [[#CMP|CMP]] || [[#CMPSB|CMPSB]] || [[#CMPSW|CMPSW]] || [[#CS|CS]] || [[#CWD|CWD]] || [[#DAA|DAA]] || [[#DAS|DAS]] || [[#DEC|DEC]]
|-
| [[#DIV|DIV]] || [[#DS|DS]] || [[#ENTER|ENTER]] || [[#ES|ES]] || [[#HLT|HLT]] || [[#IDIV|IDIV]] || [[#IMUL|IMUL]] || [[#IN|IN]] || [[#INC|INC]] || [[#INSB|INSB]] || [[#INSW|INSW]]
|-
| [[#INT|INT]] || [[#INTO|INTO]] || [[#IRET|IRET]] || [[#JA|JA]] || [[#JBE|JBE]] || [[#JC|JC]] || [[#JCXZ|JCXZ]] || [[#JG|JG]] || [[#JGE|JGE]] || [[#JL|JL]] || [[#JLE|JLE]]
|-
| [[#JMP|JMP]] || [[#JNC|JNC]] || [[#JNO|JNO]] || [[#JNP|JNP]] || [[#JNS|JNS]] || [[#JNZ|JNZ]] || [[#JO|JO]] || [[#JP|JP]] || [[#JS|JS]] || [[#JZ|JZ]] || [[#LAHF|LAHF]]
|-
| [[#LDS|LDS]] || [[#LEA|LEA]] || [[#LEAVE|LEAVE]] || [[#LES|LES]] || [[#LOCK|LOCK]] || [[#LODSB|LODSB]] || [[#LODSW|LODSW]] || [[#LOOP|LOOP]] || [[#LOOPE|LOOPE]] || [[#LOOPNE|LOOPNE]] || [[#MOV|MOV]]
|-
| [[#MOVSB|MOVSB]] || [[#MOVSW|MOVSW]] || [[#MUL|MUL]] || [[#NEG|NEG]] || [[#NOP|NOP]] || [[#NOT|NOT]] || [[#OR|OR]] || [[#OUT|OUT]] || [[#OUTSB|OUTSB]] || [[#OUTSW|OUTSW]] || [[#POLL|POLL]]
|-
| [[#POP|POP]] || [[#POPA|POPA]] || [[#POPF|POPF]] || [[#PUSH|PUSH]] || [[#PUSHA|PUSHA]] || [[#PUSHF|PUSHF]] || [[#RCL|RCL]] || [[#RCR|RCR]] || [[#REP|REP]] || [[#REPNE|REPNE]] || [[#RET|RET]]
|-
| [[#RETF|RETF]] || [[#ROL|ROL]] || [[#ROR|ROR]] || [[#SAHF|SAHF]] || [[#SAR|SAR]] || [[#SBB|SBB]] || [[#SCASB|SCASB]] || [[#SCASW|SCASW]] || [[#SHL|SHL]] || [[#SHR|SHR]] || [[#SS|SS]]
|-
| [[#STC|STC]] || [[#STD|STD]] || [[#STI|STI]] || [[#STOSB|STOSB]] || [[#STOSW|STOSW]] || [[#SUB|SUB]] || [[#TEST|TEST]] || [[#XCHG|XCHG]] || [[#XLAT|XLAT]] || [[#XOR|XOR]]
|}
{| class="mw-collapsible mw-collapsed wikitable sortable" style="width: 340px;"
|+ style="white-space:nowrap; border:1px solid; padding:3px; border-color:rgb(162, 169, 177); background-color:rgb(234, 236, 240);" | Intel <-> NEC mnemonic translation table
!Intel
!NEC
|-
| [[#AAA|AAA]]
| [[#AAA|ADJBA]]
|-
| [[#AAD|AAD]]
| [[#AAD|CVTDB]]
|-
| [[#AAM|AAM]]
| [[#AAM|CVTBD]]
|-
| [[#AAS|AAS]]
| [[#AAS|ADJBS]]
|-
| [[#ADC|ADC]]
| [[#ADC|ADDC]]
|-
| [[#ADD|ADD]]
| [[#ADD|ADD]]
|-
| [[#AND|AND]]
| [[#AND|AND]]
|-
| [[#BOUND|BOUND]]
| [[#BOUND|CHKIND]]
|-
| [[#CALL|CALL]]
| [[#CALL|CALL]]
|-
| [[#CBW|CBW]]
| [[#CBW|CVTBW]]
|-
| [[#CLC|CLC]]
| [[#CLC|CLR1 CY]]
|-
| [[#CLD|CLD]]
| [[#CLD|CLR1 DIR]]
|-
| [[#CLI|CLI]]
| [[#CLI|DI]]
|-
| [[#CMC|CMC]]
| [[#CMC|NOT1 CY]]
|-
| [[#CMP|CMP]]
| [[#CMP|CMP]]
|-
| [[#CMPSB|CMPSB]]
| [[#CMPSB|CMPBKB]]
|-
| [[#CMPSW|CMPSW]]
| [[#CMPSW|CMPBKW]]
|-
| [[#CS|CS]]
| [[#CS|PS]]
|-
| [[#CWD|CWD]]
| [[#CWD|CVTWL]]
|-
| [[#DAA|DAA]]
| [[#DAA|ADJ4A]]
|-
| [[#DAS|DAS]]
| [[#DAS|ADJ4S]]
|-
| [[#DEC|DEC]]
| [[#DEC|DEC]]
|-
| [[#DIV|DIV]]
| [[#DIV|DIVU]]
|-
| [[#DS|DS]]
| [[#DS|DS0]]
|-
| [[#ENTER|ENTER]]
| [[#ENTER|PREPARE]]
|-
| [[#ES|ES]]
| [[#ES|DS1]]
|-
| [[#HLT|HLT]]
| [[#HLT|HALT]]
|-
| [[#IDIV|IDIV]]
| [[#IDIV|DIV]]
|-
| [[#IMUL|IMUL]]
| [[#IMUL|MUL]]
|-
| [[#IN|IN]]
| [[#IN|IN]]
|-
| [[#INC|INC]]
| [[#INC|INC]]
|-
| [[#INSB|INSB]]
| [[#INSB|INMB]]
|-
| [[#INSW|INSW]]
| [[#INSW|INMW]]
|-
| [[#INT|INT]]
| [[#INT|BRK]]
|-
| [[#INTO|INTO]]
| [[#INTO|BRKV]]
|-
| [[#IRET|IRET]]
| [[#IRET|RETI]]
|-
| [[#JA|JA]]
| [[#JA|BH]]
|-
| [[#JBE|JBE]]
| [[#JBE|BNH]]
|-
| [[#JC|JC/JB]]
| [[#JC|BC/BL]]
|-
| [[#JCXZ|JCXZ]]
| [[#JCXZ|BCWZ]]
|-
| [[#JG|JG]]
| [[#JG|BGT]]
|-
| [[#JGE|JGE]]
| [[#JGE|BGE]]
|-
| [[#JL|JL]]
| [[#JL|BLT]]
|-
| [[#JLE|JLE]]
| [[#JLE|BLE]]
|-
| [[#JMP|JMP]]
| [[#JMP|BR]]
|-
| [[#JNC|JNC/JAE]]
| [[#JNC|BNC/BNL]]
|-
| [[#JNO|JNO]]
| [[#JNO|BNV]]
|-
| [[#JNP|JNP]]
| [[#JNP|BPO]]
|-
| [[#JNS|JNS]]
| [[#JNS|BP]]
|-
| [[#JNZ|JNZ/JNE]]
| [[#JNZ|BNZ/BNE]]
|-
| [[#JO|JO]]
| [[#JO|BV]]
|-
| [[#JP|JP]]
| [[#JP|BPE]]
|-
| [[#JS|JS]]
| [[#JS|BN]]
|-
| [[#JZ|JZ/JE]]
| [[#JZ|BZ/BE]]
|-
| [[#LAHF|LAHF]]
| [[#LAHF|MOV]]
|-
| [[#LDS|LDS]]
| [[#LDS|MOV]]
|-
| [[#LEA|LEA]]
| [[#LEA|LDEA]]
|-
| [[#LEAVE|LEAVE]]
| [[#LEAVE|DISPOSE]]
|-
| [[#LES|LES]]
| [[#LES|MOV]]
|-
| [[#LOCK|LOCK]]
| [[#LOCK|BUSLOCK]]
|-
| [[#LODSB|LODSB]]
| [[#LODSB|LDMB]]
|-
| [[#LODSW|LODSW]]
| [[#LODSW|LDMW]]
|-
| [[#LOOP|LOOP]]
| [[#LOOP|DBNZ]]
|-
| [[#LOOPE|LOOPE]]
| [[#LOOPE|DBNZE]]
|-
| [[#LOOPNE|LOOPNE]]
| [[#LOOPNE|DBNZNE]]
|-
| [[#MOV|MOV]]
| [[#MOV|MOV]]
|-
| [[#MOVSB|MOVSB]]
| [[#MOVSB|MOVBKB]]
|-
| [[#MOVSW|MOVSW]]
| [[#MOVSW|MOVBKW]]
|-
| [[#MUL|MUL]]
| [[#MUL|MULU]]
|-
| [[#NEG|NEG]]
| [[#NEG|NEG]]
|-
| [[#NOP|NOP]]
| [[#NOP|NOP]]
|-
| [[#NOT|NOT]]
| [[#NOT|NOT]]
|-
| [[#OR|OR]]
| [[#OR|OR]]
|-
| [[#OUT|OUT]]
| [[#OUT|OUT]]
|-
| [[#OUTSB|OUTSB]]
| [[#OUTSB|OUTM]]
|-
| [[#OUTSW|OUTSW]]
| [[#OUTSW|OUTM]]
|-
| [[#POLL|POLL]]
| [[#POLL|POLL]]
|-
| [[#POP|POP]]
| [[#POP|POP]]
|-
| [[#POPA|POPA]]
| [[#POPA|POP]]
|-
| [[#POPF|POPF]]
| [[#POPF|POP]]
|-
| [[#PUSH|PUSH]]
| [[#PUSH|PUSH]]
|-
| [[#PUSHA|PUSHA]]
| [[#PUSHA|PUSH]]
|-
| [[#PUSHF|PUSHF]]
| [[#PUSHF|PUSH]]
|-
| [[#RCL|RCL]]
| [[#RCL|ROLC]]
|-
| [[#RCR|RCR]]
| [[#RCR|RORC]]
|-
| [[#REP|REP/REPE/REPZ]]
| [[#REP|REP/REPE/REPZ]]
|-
| [[#REPNE|REPNE/REPNZ]]
| [[#REPNE|REPNE/REPNZ]]
|-
| [[#RET|RET]]
| [[#RET|RET]]
|-
| [[#RETF|RETF]]
| [[#RETF|RET]]
|-
| [[#ROL|ROL]]
| [[#ROL|ROL]]
|-
| [[#ROR|ROR]]
| [[#ROR|ROR]]
|-
| [[#SAHF|SAHF]]
| [[#SAHF|MOV]]
|-
| [[#SAR|SAR]]
| [[#SAR|SHRA]]
|-
| [[#SBB|SBB]]
| [[#SBB|SUBC]]
|-
| [[#SCASB|SCASB]]
| [[#SCASB|CMPMB]]
|-
| [[#SCASW|SCASW]]
| [[#SCASW|CMPMW]]
|-
| [[#SHL|SHL]]
| [[#SHL|SHL]]
|-
| [[#SHR|SHR]]
| [[#SHR|SHR]]
|-
| [[#SS|SS]]
| [[#SS|SS]]
|-
| [[#STC|STC]]
| [[#STC|SET1 CY]]
|-
| [[#STD|STD]]
| [[#STD|SET1 DIR]]
|-
| [[#STI|STI]]
| [[#STI|EI]]
|-
| [[#STOSB|STOSB]]
| [[#STOSB|STMB]]
|-
| [[#STOSW|STOSW]]
| [[#STOSW|STMW]]
|-
| [[#SUB|SUB]]
| [[#SUB|SUB]]
|-
| [[#TEST|TEST]]
| [[#TEST|TEST]]
|-
| [[#XCHG|XCHG]]
| [[#XCHG|XCH]]
|-
| [[#XLAT|XLAT]]
| [[#XLAT|TRANS]]
|-
| [[#XOR|XOR]]
| [[#XOR|XOR]]
|}
== Official instructions by type ==
{| class="wikitable sortable" style="text-align: center"
!Type
!colspan=16 class="unsortable" | Instructions
|-
| style="text-align:left;" | Memory
| style="" | [[#MOV|MOV]]
| style="" | [[#XCHG|XCHG]]
| style="" | [[#XLAT|XLAT]]
| style="" | [[#LEA|LEA]]
| style="border-right:none;" | [[#LDS|LDS]]
| style="border-left:none;" | [[#LES|LES]]
| style="border-right:none;" | [[#IN|IN]]
| style="border-left:none;" | [[#OUT|OUT]]
| colspan="8" |
|-
| style="text-align:left;" | Ports
| style="border-right:none;" | [[#IN|IN]]
| style="border-left:none;" | [[#OUT|OUT]]
| style="border-right:none;" | [[#INSB|INSB]]
| style="border-left:none;" | [[#OUTSB|OUTSB]]
| style="border-right:none;" | [[#INSW|INSW]]
| style="border-left:none;" | [[#OUTSW|OUTSW]]
| colspan="10" |
|-
| style="text-align:left;" | Arithmetic
| style="border-right:none;" | [[#ADD|ADD]]
| style="border-left:none;" | [[#SUB|SUB]]
| style="border-right:none;" | [[#ADC|ADC]]
| style="border-left:none;" | [[#SBB|SBB]]
| style="border-right:none;" | [[#INC|INC]]
| style="border-left:none;" | [[#DEC|DEC]]
| style="border-right:none;" | [[#MUL|MUL]]
| style="border-left:none;" | [[#DIV|DIV]]
| style="border-right:none;" | [[#IMUL|IMUL]]
| style="border-left:none;" | [[#IDIV|IDIV]]
| style="" | [[#CMP|CMP]]
| style="" | [[#NEG|NEG]]
| colspan="4" |
|-
| style="text-align:left;" | Numeric
| style="" | [[#CBW|CBW]]
| style="" | [[#CWD|CWD]]
| style="" | [[#AAA|AAA]]
| style="" | [[#AAS|AAS]]
| style="" | [[#AAM|AAM]]
| style="" | [[#AAD|AAD]]
| style="" | [[#DAA|DAA]]
| style="" | [[#DAS|DAS]]
| colspan="8" |
|-
| style="text-align:left;" | Shift
| style="border-right:none;" | [[#ROL|ROL]]
| style="border-left:none;" | [[#ROR|ROR]]
| style="border-right:none;" | [[#RCL|RCL]]
| style="border-left:none;" | [[#RCR|RCR]]
| style="border-right:none;" | [[#SHL|SHL]]
| style="border-left:none;" | [[#SHR|SHR]]
| style="" | [[#SAR|SAR]]
| colspan="9" |
|-
| style="text-align:left;" | Bitwise
| style="" | [[#AND|AND]]
| style="" | [[#OR|OR]]
| style="" | [[#XOR|XOR]]
| style="" | [[#NOT|NOT]]
| style="" | [[#TEST|TEST]]
| colspan="11" |
|-
| style="text-align:left;" | Branch
| style="border-right:none;" | [[#JC|JC]]
| style="border-left:none;" | [[#JNC|JNC]]
| style="border-right:none;" | [[#JZ|JZ]]
| style="border-left:none;" | [[#JNZ|JNZ]]
| style="border-right:none;" | [[#JBE|JBE]]
| style="border-left:none;" | [[#JA|JA]]
| style="border-right:none;" | [[#JO|JO]]
| style="border-left:none;" | [[#JNO|JNO]]
| style="border-right:none;" | [[#JP|JP]]
| style="border-left:none;" | [[#JNP|JNP]]
| style="border-right:none;" | [[#JS|JS]]
| style="border-left:none;" | [[#JNS|JNS]]
| style="border-right:none;" | [[#JL|JL]]
| style="border-left:none;" | [[#JGE|JGE]]
| style="border-right:none;" | [[#JLE|JLE]]
| style="border-left:none;" | [[#JG|JG]]
|-
| style="text-align:left;" | Jump
| style="" | [[#JMP|JMP]]
| style="border-right:none;" | [[#CALL|CALL]]
| style="border-left:none;border-right:none;" | [[#RET|RET]]
| style="border-left:none;" | [[#RETF|RETF]]
| colspan="12" |
|-
| style="text-align:left;" | Loop
| style="" | [[#LOOP|LOOP]]
| style="" | [[#LOOPE|LOOPE]]
| style="" | [[#LOOPNE|LOOPNE]]
| colspan="13" |
|-
| style="text-align:left;" | Interrupt
| style="border-right:none;" | [[#INT|INT]]
| style="border-left:none;" | [[#IRET|IRET]]
| style="" | [[#INTO|INTO]]
| style="" | [[#HLT|HLT]]
| style="" | [[#BOUND|BOUND]]
| colspan="11" |
|-
| style="text-align:left;" | Stack
| style="border-right:none;" | [[#PUSH|PUSH]]
| style="border-left:none;" | [[#POP|POP]]
| style="border-right:none;" | [[#PUSHA|PUSHA]]
| style="border-left:none;" | [[#POPA|POPA]]
| style="border-right:none;" | [[#PUSHF|PUSHF]]
| style="border-left:none;" | [[#POPF|POPF]]
| colspan="10" |
|-
| style="text-align:left;" | Flags
| style="border-right:none;" | [[#CLC|CLC]]
| style="border-left:none;" | [[#STC|STC]]
| style="border-right:none;" | [[#CLD|CLD]]
| style="border-left:none;" | [[#STD|STD]]
| style="border-right:none;" | [[#CLI|CLI]]
| style="border-left:none;" | [[#STI|STI]]
| style="" | [[#CMC|CMC]]
| style="border-right:none;" | [[#LAHF|LAHF]]
| style="border-left:none;" | [[#SAHF|SAHF]]
| colspan="7" |
|-
| style="text-align:left;" | Prefix
| style="" | [[#CS|CS]]
| style="" | [[#DS|DS]]
| style="" | [[#ES|ES]]
| style="" | [[#SS|SS]]
| colspan="12" |
|-
| style="text-align:left;" | String
| style="border-right:none;" | [[#REP|REP]]
| style="border-left:none;border-right:none;" | [[#REP|REPE]]
| style="border-left:none;" | [[#REPNE|REPNE]]
| style="" | [[#MOVSB|MOVSB]]
| style="" | [[#MOVSW|MOVSW]]
| style="border-right:none;" | [[#LODSB|LODSB]]
| style="border-left:none;" | [[#STOSB|STOSB]]
| style="border-right:none;" | [[#LODSW|LODSW]]
| style="border-left:none;" | [[#STOSW|STOSW]]
| style="" | [[#CMPSB|CMPSB]]
| style="" | [[#SCASB|SCASB]]
| style="" | [[#CMPSW|CMPSW]]
| style="" | [[#SCASW|SCASW]]
| colspan="3" |
|-
| style="text-align:left;" | Other
| style="" | [[#NOP|NOP]]
| style="border-right:none;" | [[#ENTER|ENTER]]
| style="border-left:none;" | [[#LEAVE|LEAVE]]
| style="" | [[#LOCK|LOCK]]
| style="" | [[#POLL|POLL]]
| colspan="11" |
|}
== Instruction encoding ==
=== ModR/M byte ===
The ModR/M byte is used in most addressing modes which reference a memory location. This byte consists of three bitfield values:
* <tt>oo</tt> - M'''o'''de;
* <tt>rrr</tt> - Two possible functions:
** '''R'''egister (for addressing modes which require both a register and a register/memory operand),
** Opcode extension (for some opcodes' addressing modes which do not have such a requirement);
* <tt>mmm</tt> - Register/'''M'''emory.
The ''Mode'' and ''Register/Memory'' bitfields can refer to a memory location with an optional signed 8-bit (disp8) or 16-bit (disp16) displacement or to a register, as shown in the table below. In some addressing modes, the ''Register'' field also refers to a register; it is always interpreted as if ''Mode'' was equal to <tt>11</tt>.
{| class="wikitable" style="text-align: center"
! R/M \ Mode
! <tt>00</tt>
! <tt>01</tt>
! <tt>10</tt>
! <tt>11</tt> ''(byte)''
! <tt>11</tt> ''(word)''
|-
| <tt>000</tt>
| DS:[BX + SI]
| DS:[BX + SI + disp8]
| DS:[BX + SI + disp16]
| AL
| AX
|-
| <tt>001</tt>
| DS:[BX + DI]
| DS:[BX + DI + disp8]
| DS:[BX + DI + disp16]
| CL
| CX
|-
| <tt>010</tt>
| SS:[BP + SI]
| SS:[BP + SI + disp8]
| SS:[BP + SI + disp16]
| DL
| DX
|-
| <tt>011</tt>
| SS:[BP + DI]
| SS:[BP + DI + disp8]
| SS:[BP + DI + disp16]
| BL
| BX
|-
| <tt>100</tt>
| DS:[SI]
| DS:[SI + disp8]
| DS:[SI + disp16]
| AH
| SP
|-
| <tt>101</tt>
| DS:[DI]
| DS:[DI + disp8]
| DS:[DI + disp16]
| CH
| BP
|-
| <tt>110</tt>
| ''DS:[disp16]''
| SS:[BP + disp8]
| SS:[BP + disp16]
| DH
| SI
|-
| <tt>111</tt>
| DS:[BX]
| DS:[BX + disp8]
| DS:[BX + disp16]
| BH
| DI
|}
Note that (<tt>oo</tt> = <tt>00</tt>, <tt>mmm</tt> = <tt>110</tt>) is a special case.
The instruction encoding lists below refer to this byte as <tt>oorrrmmm</tt> (binary), <tt>/r</tt> (hexadecimal) or <tt>/0</tt> (hexademical, <tt>rrr</tt> used as function <tt>0</tt>).
== Official instructions ==
{{Anchor|AAA}}
=== AAA ===
----
{{Anchor|AAD}}
=== AAD ===
----
{{Anchor|AAM}}
=== AAM ===
----
{{Anchor|AAS}}
=== AAS ===
----
{{Anchor|ADC}}
=== ADC ===
----
{{Anchor|ADD}}
=== ADD ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| ADD AL, imm || <tt>04 ii</tt> || <tt>00000100 iiiiiiii</tt> || 2 || 1
|-
| ADD AX, imm || <tt>05 ii ii</tt> || <tt>00000101 iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| ADD mem8, imm8 || <tt>80 /0 ii</tt> || <tt>10000000 oo000mmm iiiiiiii</tt> || 3+ || 3
|-
| ADD mem16, imm16 || <tt>81 /0 ii ii</tt> || <tt>10000001 oo000mmm iiiiiiii iiiiiiii</tt> || 4+ || 3
|-
| ADD mem16, simm8 || <tt>83 /0 ii ii</tt> || <tt>10000011 oo000mmm iiiiiiii iiiiiiii</tt> || 4+ || 3
|-
| ADD mem8, reg8 || <tt>00 /r</tt> || <tt>00000000 oorrrmmm</tt> || 2+ || 3
|-
| ADD mem16, reg16 || <tt>01 /r</tt> || <tt>00000001 oorrrmmm</tt> || 2+ || 3
|-
| ADD reg8, imm8 || <tt>80 /0 ii</tt> || <tt>10000000 11000mmm iiiiiiii</tt> || 3+ || 1
|-
| ADD reg16, imm16 || <tt>81 /0 ii ii</tt> || <tt>10000001 11000mmm iiiiiiii iiiiiiii</tt> || 4+ || 1
|-
| ADD reg16, simm8 || <tt>83 /0 ii ii</tt> || <tt>10000011 11000mmm iiiiiiii iiiiiiii</tt> || 4+ || 1
|-
| ADD reg8, mem8 || <tt>02 /r</tt> || <tt>00000010 oorrrmmm</tt> || 2+ || 2
|-
| ADD reg16, mem16 || <tt>03 /r</tt> || <tt>00000011 oorrrmmm</tt> || 2+ || 2
|-
| ADD reg8, reg8 || <tt>00 /r</tt> || <tt>000000.0 11rrrmmm</tt> || 2 || 1
|-
| ADD reg16, reg16 || <tt>01 /r</tt> || <tt>000000.1 11rrrmmm</tt> || 2 || 1
|}
----
{{Anchor|AND}}
=== AND ===
----
{{Anchor|BOUND}}
=== BOUND ===
----
{{Anchor|CALL}}
=== CALL ===
----
{{Anchor|CBW}}
=== CBW ===
----
{{Anchor|CLC}}
=== CLC ===
----
{{Anchor|CLD}}
=== CLD ===
----
{{Anchor|CLI}}
=== CLI ===
----
{{Anchor|CMC}}
=== CMC ===
----
{{Anchor|CMP}}
=== CMP ===
----
{{Anchor|CMPSB}}
=== CMPSB ===
----
{{Anchor|CMPSW}}
=== CMPSW ===
----
{{Anchor|CS}}
=== CS ===
----
{{Anchor|CWD}}
=== CWD ===
----
{{Anchor|DAA}}
=== DAA ===
----
{{Anchor|DAS}}
=== DAS ===
----
{{Anchor|DEC}}
=== DEC ===
----
{{Anchor|DIV}}
=== DIV ===
----
{{Anchor|DS}}
=== DS ===
----
{{Anchor|ENTER}}
=== ENTER ===
----
{{Anchor|ES}}
=== ES ===
----
{{Anchor|HLT}}
=== HLT ===
----
{{Anchor|IDIV}}
=== IDIV ===
----
{{Anchor|IMUL}}
=== IMUL ===
----
{{Anchor|IN}}
=== IN ===
----
{{Anchor|INC}}
=== INC ===
----
{{Anchor|INSB}}
=== INSB ===
----
{{Anchor|INSW}}
=== INSW ===
----
{{Anchor|INT}}
=== INT ===
----
{{Anchor|INTO}}
=== INTO ===
----
{{Anchor|IRET}}
=== IRET ===
----
{{Anchor|JA}}
=== JA ===
----
{{Anchor|JBE}}
=== JBE ===
----
{{Anchor|JC}}
=== JC/JB ===
----
{{Anchor|JCXZ}}
=== JCXZ ===
----
{{Anchor|JG}}
=== JG ===
----
{{Anchor|JGE}}
=== JGE ===
----
{{Anchor|JL}}
=== JL ===
----
{{Anchor|JLE}}
=== JLE ===
----
{{Anchor|JMP}}
=== JMP ===
----
{{Anchor|JNC}}
=== JNC/JAE ===
----
{{Anchor|JNO}}
=== JNO ===
----
{{Anchor|JNP}}
=== JNP ===
----
{{Anchor|JNS}}
=== JNS ===
----
{{Anchor|JNZ}}
=== JNZ/JNE ===
----
{{Anchor|JO}}
=== JO ===
----
{{Anchor|JP}}
=== JP ===
----
{{Anchor|JS}}
=== JS ===
----
{{Anchor|JZ}}
=== JZ/JE ===
----
{{Anchor|LAHF}}
=== LAHF ===
----
{{Anchor|LDS}}
=== LDS ===
----
{{Anchor|LEA}}
=== LEA ===
----
{{Anchor|LEAVE}}
=== LEAVE ===
----
{{Anchor|LES}}
=== LES ===
----
{{Anchor|LOCK}}
=== LOCK ===
----
{{Anchor|LODSB}}
=== LODSB ===
----
{{Anchor|LODSW}}
=== LODSW ===
----
{{Anchor|LOOP}}
=== LOOP ===
----
{{Anchor|LOOPE}}
=== LOOPE ===
----
{{Anchor|LOOPNE}}
=== LOOPNE ===
----
{{Anchor|MOV}}
=== MOV ===
----
{{Anchor|MOVSB}}
=== MOVSB ===
----
{{Anchor|MOVSW}}
=== MOVSW ===
----
{{Anchor|MUL}}
=== MUL ===
----
{{Anchor|NEG}}
=== NEG ===
----
{{Anchor|NOP}}
=== NOP ===
----
{{Anchor|NOT}}
=== NOT ===
----
{{Anchor|OR}}
=== OR ===
----
{{Anchor|OUT}}
=== OUT ===
----
{{Anchor|OUTSB}}
=== OUTSB ===
----
{{Anchor|OUTSW}}
=== OUTSW ===
----
{{Anchor|POLL}}
=== POLL ===
----
{{Anchor|POP}}
=== POP ===
----
{{Anchor|POPA}}
=== POPA ===
----
{{Anchor|POPF}}
=== POPF ===
----
{{Anchor|PUSH}}
=== PUSH ===
----
{{Anchor|PUSHA}}
=== PUSHA ===
----
{{Anchor|PUSHF}}
=== PUSHF ===
----
{{Anchor|RCL}}
=== RCL ===
----
{{Anchor|RCR}}
=== RCR ===
----
{{Anchor|REP}}
=== REP/REPE/REPZ ===
----
{{Anchor|REPNE}}
=== REPNE/REPNZ ===
----
{{Anchor|RET}}
=== RET ===
----
{{Anchor|RETF}}
=== RETF ===
----
{{Anchor|ROL}}
=== ROL ===
----
{{Anchor|ROR}}
=== ROR ===
----
{{Anchor|SAHF}}
=== SAHF ===
----
{{Anchor|SAR}}
=== SAR ===
----
{{Anchor|SBB}}
=== SBB ===
----
{{Anchor|SCASB}}
=== SCASB ===
----
{{Anchor|SCASW}}
=== SCASW ===
----
{{Anchor|SHL}}
=== SHL ===
----
{{Anchor|SHR}}
=== SHR ===
----
{{Anchor|SS}}
=== SS ===
----
{{Anchor|STC}}
=== STC ===
----
{{Anchor|STD}}
=== STD ===
----
{{Anchor|STI}}
=== STI ===
----
{{Anchor|STOSB}}
=== STOSB ===
----
{{Anchor|STOSW}}
=== STOSW ===
----
{{Anchor|SUB}}
=== SUB ===
----
{{Anchor|TEST}}
=== TEST ===
----
{{Anchor|XCHG}}
=== XCHG ===
----
{{Anchor|XLAT}}
=== XLAT ===
----
{{Anchor|XOR}}
=== XOR ===
----
9cfb48a075c6ee00f49d9543f0692fee7bdb5fa2
443
441
2024-12-26T18:39:03Z
Asie
351
/* Official instructions */ progress on opcode tables
wikitext
text/x-wiki
__NOTOC__
{| class="wikitable" style="text-align: center"
|+ Official V30MZ (80186) Instructions
|-
| [[#AAA|AAA]] || [[#AAD|AAD]] || [[#AAM|AAM]] || [[#AAS|AAS]] || [[#ADC|ADC]] || [[#ADD|ADD]] || [[#AND|AND]] || [[#BOUND|BOUND]] || [[#CALL|CALL]] || [[#CBW|CBW]] || [[#CLC|CLC]]
|-
| [[#CLD|CLD]] || [[#CLI|CLI]] || [[#CMC|CMC]] || [[#CMP|CMP]] || [[#CMPSB|CMPSB]] || [[#CMPSW|CMPSW]] || [[#CS|CS]] || [[#CWD|CWD]] || [[#DAA|DAA]] || [[#DAS|DAS]] || [[#DEC|DEC]]
|-
| [[#DIV|DIV]] || [[#DS|DS]] || [[#ENTER|ENTER]] || [[#ES|ES]] || [[#HLT|HLT]] || [[#IDIV|IDIV]] || [[#IMUL|IMUL]] || [[#IN|IN]] || [[#INC|INC]] || [[#INSB|INSB]] || [[#INSW|INSW]]
|-
| [[#INT|INT]] || [[#INTO|INTO]] || [[#IRET|IRET]] || [[#JA|JA]] || [[#JBE|JBE]] || [[#JC|JC]] || [[#JCXZ|JCXZ]] || [[#JG|JG]] || [[#JGE|JGE]] || [[#JL|JL]] || [[#JLE|JLE]]
|-
| [[#JMP|JMP]] || [[#JNC|JNC]] || [[#JNO|JNO]] || [[#JNP|JNP]] || [[#JNS|JNS]] || [[#JNZ|JNZ]] || [[#JO|JO]] || [[#JP|JP]] || [[#JS|JS]] || [[#JZ|JZ]] || [[#LAHF|LAHF]]
|-
| [[#LDS|LDS]] || [[#LEA|LEA]] || [[#LEAVE|LEAVE]] || [[#LES|LES]] || [[#LOCK|LOCK]] || [[#LODSB|LODSB]] || [[#LODSW|LODSW]] || [[#LOOP|LOOP]] || [[#LOOPE|LOOPE]] || [[#LOOPNE|LOOPNE]] || [[#MOV|MOV]]
|-
| [[#MOVSB|MOVSB]] || [[#MOVSW|MOVSW]] || [[#MUL|MUL]] || [[#NEG|NEG]] || [[#NOP|NOP]] || [[#NOT|NOT]] || [[#OR|OR]] || [[#OUT|OUT]] || [[#OUTSB|OUTSB]] || [[#OUTSW|OUTSW]] || [[#POLL|POLL]]
|-
| [[#POP|POP]] || [[#POPA|POPA]] || [[#POPF|POPF]] || [[#PUSH|PUSH]] || [[#PUSHA|PUSHA]] || [[#PUSHF|PUSHF]] || [[#RCL|RCL]] || [[#RCR|RCR]] || [[#REP|REP]] || [[#REPNE|REPNE]] || [[#RET|RET]]
|-
| [[#RETF|RETF]] || [[#ROL|ROL]] || [[#ROR|ROR]] || [[#SAHF|SAHF]] || [[#SAR|SAR]] || [[#SBB|SBB]] || [[#SCASB|SCASB]] || [[#SCASW|SCASW]] || [[#SHL|SHL]] || [[#SHR|SHR]] || [[#SS|SS]]
|-
| [[#STC|STC]] || [[#STD|STD]] || [[#STI|STI]] || [[#STOSB|STOSB]] || [[#STOSW|STOSW]] || [[#SUB|SUB]] || [[#TEST|TEST]] || [[#XCHG|XCHG]] || [[#XLAT|XLAT]] || [[#XOR|XOR]]
|}
{| class="mw-collapsible mw-collapsed wikitable sortable" style="width: 340px;"
|+ style="white-space:nowrap; border:1px solid; padding:3px; border-color:rgb(162, 169, 177); background-color:rgb(234, 236, 240);" | Intel <-> NEC mnemonic translation table
!Intel
!NEC
|-
| [[#AAA|AAA]]
| [[#AAA|ADJBA]]
|-
| [[#AAD|AAD]]
| [[#AAD|CVTDB]]
|-
| [[#AAM|AAM]]
| [[#AAM|CVTBD]]
|-
| [[#AAS|AAS]]
| [[#AAS|ADJBS]]
|-
| [[#ADC|ADC]]
| [[#ADC|ADDC]]
|-
| [[#ADD|ADD]]
| [[#ADD|ADD]]
|-
| [[#AND|AND]]
| [[#AND|AND]]
|-
| [[#BOUND|BOUND]]
| [[#BOUND|CHKIND]]
|-
| [[#CALL|CALL]]
| [[#CALL|CALL]]
|-
| [[#CBW|CBW]]
| [[#CBW|CVTBW]]
|-
| [[#CLC|CLC]]
| [[#CLC|CLR1 CY]]
|-
| [[#CLD|CLD]]
| [[#CLD|CLR1 DIR]]
|-
| [[#CLI|CLI]]
| [[#CLI|DI]]
|-
| [[#CMC|CMC]]
| [[#CMC|NOT1 CY]]
|-
| [[#CMP|CMP]]
| [[#CMP|CMP]]
|-
| [[#CMPSB|CMPSB]]
| [[#CMPSB|CMPBKB]]
|-
| [[#CMPSW|CMPSW]]
| [[#CMPSW|CMPBKW]]
|-
| [[#CS|CS]]
| [[#CS|PS]]
|-
| [[#CWD|CWD]]
| [[#CWD|CVTWL]]
|-
| [[#DAA|DAA]]
| [[#DAA|ADJ4A]]
|-
| [[#DAS|DAS]]
| [[#DAS|ADJ4S]]
|-
| [[#DEC|DEC]]
| [[#DEC|DEC]]
|-
| [[#DIV|DIV]]
| [[#DIV|DIVU]]
|-
| [[#DS|DS]]
| [[#DS|DS0]]
|-
| [[#ENTER|ENTER]]
| [[#ENTER|PREPARE]]
|-
| [[#ES|ES]]
| [[#ES|DS1]]
|-
| [[#HLT|HLT]]
| [[#HLT|HALT]]
|-
| [[#IDIV|IDIV]]
| [[#IDIV|DIV]]
|-
| [[#IMUL|IMUL]]
| [[#IMUL|MUL]]
|-
| [[#IN|IN]]
| [[#IN|IN]]
|-
| [[#INC|INC]]
| [[#INC|INC]]
|-
| [[#INSB|INSB]]
| [[#INSB|INMB]]
|-
| [[#INSW|INSW]]
| [[#INSW|INMW]]
|-
| [[#INT|INT]]
| [[#INT|BRK]]
|-
| [[#INTO|INTO]]
| [[#INTO|BRKV]]
|-
| [[#IRET|IRET]]
| [[#IRET|RETI]]
|-
| [[#JA|JA]]
| [[#JA|BH]]
|-
| [[#JBE|JBE]]
| [[#JBE|BNH]]
|-
| [[#JC|JC/JB]]
| [[#JC|BC/BL]]
|-
| [[#JCXZ|JCXZ]]
| [[#JCXZ|BCWZ]]
|-
| [[#JG|JG]]
| [[#JG|BGT]]
|-
| [[#JGE|JGE]]
| [[#JGE|BGE]]
|-
| [[#JL|JL]]
| [[#JL|BLT]]
|-
| [[#JLE|JLE]]
| [[#JLE|BLE]]
|-
| [[#JMP|JMP]]
| [[#JMP|BR]]
|-
| [[#JNC|JNC/JAE]]
| [[#JNC|BNC/BNL]]
|-
| [[#JNO|JNO]]
| [[#JNO|BNV]]
|-
| [[#JNP|JNP]]
| [[#JNP|BPO]]
|-
| [[#JNS|JNS]]
| [[#JNS|BP]]
|-
| [[#JNZ|JNZ/JNE]]
| [[#JNZ|BNZ/BNE]]
|-
| [[#JO|JO]]
| [[#JO|BV]]
|-
| [[#JP|JP]]
| [[#JP|BPE]]
|-
| [[#JS|JS]]
| [[#JS|BN]]
|-
| [[#JZ|JZ/JE]]
| [[#JZ|BZ/BE]]
|-
| [[#LAHF|LAHF]]
| [[#LAHF|MOV]]
|-
| [[#LDS|LDS]]
| [[#LDS|MOV]]
|-
| [[#LEA|LEA]]
| [[#LEA|LDEA]]
|-
| [[#LEAVE|LEAVE]]
| [[#LEAVE|DISPOSE]]
|-
| [[#LES|LES]]
| [[#LES|MOV]]
|-
| [[#LOCK|LOCK]]
| [[#LOCK|BUSLOCK]]
|-
| [[#LODSB|LODSB]]
| [[#LODSB|LDMB]]
|-
| [[#LODSW|LODSW]]
| [[#LODSW|LDMW]]
|-
| [[#LOOP|LOOP]]
| [[#LOOP|DBNZ]]
|-
| [[#LOOPE|LOOPE]]
| [[#LOOPE|DBNZE]]
|-
| [[#LOOPNE|LOOPNE]]
| [[#LOOPNE|DBNZNE]]
|-
| [[#MOV|MOV]]
| [[#MOV|MOV]]
|-
| [[#MOVSB|MOVSB]]
| [[#MOVSB|MOVBKB]]
|-
| [[#MOVSW|MOVSW]]
| [[#MOVSW|MOVBKW]]
|-
| [[#MUL|MUL]]
| [[#MUL|MULU]]
|-
| [[#NEG|NEG]]
| [[#NEG|NEG]]
|-
| [[#NOP|NOP]]
| [[#NOP|NOP]]
|-
| [[#NOT|NOT]]
| [[#NOT|NOT]]
|-
| [[#OR|OR]]
| [[#OR|OR]]
|-
| [[#OUT|OUT]]
| [[#OUT|OUT]]
|-
| [[#OUTSB|OUTSB]]
| [[#OUTSB|OUTM]]
|-
| [[#OUTSW|OUTSW]]
| [[#OUTSW|OUTM]]
|-
| [[#POLL|POLL]]
| [[#POLL|POLL]]
|-
| [[#POP|POP]]
| [[#POP|POP]]
|-
| [[#POPA|POPA]]
| [[#POPA|POP]]
|-
| [[#POPF|POPF]]
| [[#POPF|POP]]
|-
| [[#PUSH|PUSH]]
| [[#PUSH|PUSH]]
|-
| [[#PUSHA|PUSHA]]
| [[#PUSHA|PUSH]]
|-
| [[#PUSHF|PUSHF]]
| [[#PUSHF|PUSH]]
|-
| [[#RCL|RCL]]
| [[#RCL|ROLC]]
|-
| [[#RCR|RCR]]
| [[#RCR|RORC]]
|-
| [[#REP|REP/REPE/REPZ]]
| [[#REP|REP/REPE/REPZ]]
|-
| [[#REPNE|REPNE/REPNZ]]
| [[#REPNE|REPNE/REPNZ]]
|-
| [[#RET|RET]]
| [[#RET|RET]]
|-
| [[#RETF|RETF]]
| [[#RETF|RET]]
|-
| [[#ROL|ROL]]
| [[#ROL|ROL]]
|-
| [[#ROR|ROR]]
| [[#ROR|ROR]]
|-
| [[#SAHF|SAHF]]
| [[#SAHF|MOV]]
|-
| [[#SAR|SAR]]
| [[#SAR|SHRA]]
|-
| [[#SBB|SBB]]
| [[#SBB|SUBC]]
|-
| [[#SCASB|SCASB]]
| [[#SCASB|CMPMB]]
|-
| [[#SCASW|SCASW]]
| [[#SCASW|CMPMW]]
|-
| [[#SHL|SHL]]
| [[#SHL|SHL]]
|-
| [[#SHR|SHR]]
| [[#SHR|SHR]]
|-
| [[#SS|SS]]
| [[#SS|SS]]
|-
| [[#STC|STC]]
| [[#STC|SET1 CY]]
|-
| [[#STD|STD]]
| [[#STD|SET1 DIR]]
|-
| [[#STI|STI]]
| [[#STI|EI]]
|-
| [[#STOSB|STOSB]]
| [[#STOSB|STMB]]
|-
| [[#STOSW|STOSW]]
| [[#STOSW|STMW]]
|-
| [[#SUB|SUB]]
| [[#SUB|SUB]]
|-
| [[#TEST|TEST]]
| [[#TEST|TEST]]
|-
| [[#XCHG|XCHG]]
| [[#XCHG|XCH]]
|-
| [[#XLAT|XLAT]]
| [[#XLAT|TRANS]]
|-
| [[#XOR|XOR]]
| [[#XOR|XOR]]
|}
== Official instructions by type ==
{| class="wikitable sortable" style="text-align: center"
!Type
!colspan=16 class="unsortable" | Instructions
|-
| style="text-align:left;" | Memory
| style="" | [[#MOV|MOV]]
| style="" | [[#XCHG|XCHG]]
| style="" | [[#XLAT|XLAT]]
| style="" | [[#LEA|LEA]]
| style="border-right:none;" | [[#LDS|LDS]]
| style="border-left:none;" | [[#LES|LES]]
| style="border-right:none;" | [[#IN|IN]]
| style="border-left:none;" | [[#OUT|OUT]]
| colspan="8" |
|-
| style="text-align:left;" | Ports
| style="border-right:none;" | [[#IN|IN]]
| style="border-left:none;" | [[#OUT|OUT]]
| style="border-right:none;" | [[#INSB|INSB]]
| style="border-left:none;" | [[#OUTSB|OUTSB]]
| style="border-right:none;" | [[#INSW|INSW]]
| style="border-left:none;" | [[#OUTSW|OUTSW]]
| colspan="10" |
|-
| style="text-align:left;" | Arithmetic
| style="border-right:none;" | [[#ADD|ADD]]
| style="border-left:none;" | [[#SUB|SUB]]
| style="border-right:none;" | [[#ADC|ADC]]
| style="border-left:none;" | [[#SBB|SBB]]
| style="border-right:none;" | [[#INC|INC]]
| style="border-left:none;" | [[#DEC|DEC]]
| style="border-right:none;" | [[#MUL|MUL]]
| style="border-left:none;" | [[#DIV|DIV]]
| style="border-right:none;" | [[#IMUL|IMUL]]
| style="border-left:none;" | [[#IDIV|IDIV]]
| style="" | [[#CMP|CMP]]
| style="" | [[#NEG|NEG]]
| colspan="4" |
|-
| style="text-align:left;" | Numeric
| style="" | [[#CBW|CBW]]
| style="" | [[#CWD|CWD]]
| style="" | [[#AAA|AAA]]
| style="" | [[#AAS|AAS]]
| style="" | [[#AAM|AAM]]
| style="" | [[#AAD|AAD]]
| style="" | [[#DAA|DAA]]
| style="" | [[#DAS|DAS]]
| colspan="8" |
|-
| style="text-align:left;" | Shift
| style="border-right:none;" | [[#ROL|ROL]]
| style="border-left:none;" | [[#ROR|ROR]]
| style="border-right:none;" | [[#RCL|RCL]]
| style="border-left:none;" | [[#RCR|RCR]]
| style="border-right:none;" | [[#SHL|SHL]]
| style="border-left:none;" | [[#SHR|SHR]]
| style="" | [[#SAR|SAR]]
| colspan="9" |
|-
| style="text-align:left;" | Bitwise
| style="" | [[#AND|AND]]
| style="" | [[#OR|OR]]
| style="" | [[#XOR|XOR]]
| style="" | [[#NOT|NOT]]
| style="" | [[#TEST|TEST]]
| colspan="11" |
|-
| style="text-align:left;" | Branch
| style="border-right:none;" | [[#JC|JC]]
| style="border-left:none;" | [[#JNC|JNC]]
| style="border-right:none;" | [[#JZ|JZ]]
| style="border-left:none;" | [[#JNZ|JNZ]]
| style="border-right:none;" | [[#JBE|JBE]]
| style="border-left:none;" | [[#JA|JA]]
| style="border-right:none;" | [[#JO|JO]]
| style="border-left:none;" | [[#JNO|JNO]]
| style="border-right:none;" | [[#JP|JP]]
| style="border-left:none;" | [[#JNP|JNP]]
| style="border-right:none;" | [[#JS|JS]]
| style="border-left:none;" | [[#JNS|JNS]]
| style="border-right:none;" | [[#JL|JL]]
| style="border-left:none;" | [[#JGE|JGE]]
| style="border-right:none;" | [[#JLE|JLE]]
| style="border-left:none;" | [[#JG|JG]]
|-
| style="text-align:left;" | Jump
| style="" | [[#JMP|JMP]]
| style="border-right:none;" | [[#CALL|CALL]]
| style="border-left:none;border-right:none;" | [[#RET|RET]]
| style="border-left:none;" | [[#RETF|RETF]]
| colspan="12" |
|-
| style="text-align:left;" | Loop
| style="" | [[#LOOP|LOOP]]
| style="" | [[#LOOPE|LOOPE]]
| style="" | [[#LOOPNE|LOOPNE]]
| colspan="13" |
|-
| style="text-align:left;" | Interrupt
| style="border-right:none;" | [[#INT|INT]]
| style="border-left:none;" | [[#IRET|IRET]]
| style="" | [[#INTO|INTO]]
| style="" | [[#HLT|HLT]]
| style="" | [[#BOUND|BOUND]]
| colspan="11" |
|-
| style="text-align:left;" | Stack
| style="border-right:none;" | [[#PUSH|PUSH]]
| style="border-left:none;" | [[#POP|POP]]
| style="border-right:none;" | [[#PUSHA|PUSHA]]
| style="border-left:none;" | [[#POPA|POPA]]
| style="border-right:none;" | [[#PUSHF|PUSHF]]
| style="border-left:none;" | [[#POPF|POPF]]
| colspan="10" |
|-
| style="text-align:left;" | Flags
| style="border-right:none;" | [[#CLC|CLC]]
| style="border-left:none;" | [[#STC|STC]]
| style="border-right:none;" | [[#CLD|CLD]]
| style="border-left:none;" | [[#STD|STD]]
| style="border-right:none;" | [[#CLI|CLI]]
| style="border-left:none;" | [[#STI|STI]]
| style="" | [[#CMC|CMC]]
| style="border-right:none;" | [[#LAHF|LAHF]]
| style="border-left:none;" | [[#SAHF|SAHF]]
| colspan="7" |
|-
| style="text-align:left;" | Prefix
| style="" | [[#CS|CS]]
| style="" | [[#DS|DS]]
| style="" | [[#ES|ES]]
| style="" | [[#SS|SS]]
| colspan="12" |
|-
| style="text-align:left;" | String
| style="border-right:none;" | [[#REP|REP]]
| style="border-left:none;border-right:none;" | [[#REP|REPE]]
| style="border-left:none;" | [[#REPNE|REPNE]]
| style="" | [[#MOVSB|MOVSB]]
| style="" | [[#MOVSW|MOVSW]]
| style="border-right:none;" | [[#LODSB|LODSB]]
| style="border-left:none;" | [[#STOSB|STOSB]]
| style="border-right:none;" | [[#LODSW|LODSW]]
| style="border-left:none;" | [[#STOSW|STOSW]]
| style="" | [[#CMPSB|CMPSB]]
| style="" | [[#SCASB|SCASB]]
| style="" | [[#CMPSW|CMPSW]]
| style="" | [[#SCASW|SCASW]]
| colspan="3" |
|-
| style="text-align:left;" | Other
| style="" | [[#NOP|NOP]]
| style="border-right:none;" | [[#ENTER|ENTER]]
| style="border-left:none;" | [[#LEAVE|LEAVE]]
| style="" | [[#LOCK|LOCK]]
| style="" | [[#POLL|POLL]]
| colspan="11" |
|}
== Instruction encoding ==
=== ModR/M byte ===
The ModR/M byte is used in most addressing modes which reference a memory location. This byte consists of three bitfield values:
* <tt>oo</tt> - M'''o'''de;
* <tt>rrr</tt> - Two possible functions:
** '''R'''egister (for addressing modes which require both a register and a register/memory operand),
** Opcode extension (for some opcodes' addressing modes which do not have such a requirement);
* <tt>mmm</tt> - Register/'''M'''emory.
The ''Mode'' and ''Register/Memory'' bitfields can refer to a memory location with an optional signed 8-bit (disp8) or 16-bit (disp16) displacement or to a register, as shown in the table below. In some addressing modes, the ''Register'' field also refers to a register; it is always interpreted as if ''Mode'' was equal to <tt>11</tt>.
{| class="wikitable" style="text-align: center"
! R/M \ Mode
! <tt>00</tt>
! <tt>01</tt>
! <tt>10</tt>
! <tt>11</tt> ''(byte)''
! <tt>11</tt> ''(word)''
|-
| <tt>000</tt>
| DS:[BX + SI]
| DS:[BX + SI + disp8]
| DS:[BX + SI + disp16]
| AL
| AX
|-
| <tt>001</tt>
| DS:[BX + DI]
| DS:[BX + DI + disp8]
| DS:[BX + DI + disp16]
| CL
| CX
|-
| <tt>010</tt>
| SS:[BP + SI]
| SS:[BP + SI + disp8]
| SS:[BP + SI + disp16]
| DL
| DX
|-
| <tt>011</tt>
| SS:[BP + DI]
| SS:[BP + DI + disp8]
| SS:[BP + DI + disp16]
| BL
| BX
|-
| <tt>100</tt>
| DS:[SI]
| DS:[SI + disp8]
| DS:[SI + disp16]
| AH
| SP
|-
| <tt>101</tt>
| DS:[DI]
| DS:[DI + disp8]
| DS:[DI + disp16]
| CH
| BP
|-
| <tt>110</tt>
| ''DS:[disp16]''
| SS:[BP + disp8]
| SS:[BP + disp16]
| DH
| SI
|-
| <tt>111</tt>
| DS:[BX]
| DS:[BX + disp8]
| DS:[BX + disp16]
| BH
| DI
|}
Note that (<tt>oo</tt> = <tt>00</tt>, <tt>mmm</tt> = <tt>110</tt>) is a special case.
The instruction encoding lists below refer to this byte as <tt>oorrrmmm</tt> (binary), <tt>/r</tt> (hexadecimal) or <tt>/0</tt> (hexademical, <tt>rrr</tt> used as function <tt>0</tt>).
== Official instructions ==
{{Anchor|AAA}}
=== AAA ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| AAA || <tt>37</tt> || <tt>00110111</tt> || 1 || 9
|}
----
{{Anchor|AAD}}
=== AAD ===
----
{{Anchor|AAM}}
=== AAM ===
----
{{Anchor|AAS}}
=== AAS ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| AAS || <tt>3F</tt> || <tt>00111111</tt> || 1 || 9
|}
----
{{Anchor|ADC}}
=== ADC ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| ADC AL, imm || <tt>14 ii</tt> || <tt>00010100 iiiiiiii</tt> || 2 || 1
|-
| ADC AX, imm || <tt>15 ii ii</tt> || <tt>00010101 iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| ADC mem8, imm8 || <tt>80 /2 ii</tt> || <tt>10000000 oo010mmm iiiiiiii</tt> || 3+ || 3
|-
| ADC mem16, imm16 || <tt>81 /2 ii ii</tt> || <tt>10000001 oo010mmm iiiiiiii iiiiiiii</tt> || 4+ || 3
|-
| ADC mem16, simm8 || <tt>83 /2 ii ii</tt> || <tt>10000011 oo010mmm iiiiiiii iiiiiiii</tt> || 4+ || 3
|-
| ADC mem8, reg8 || <tt>10 /r</tt> || <tt>00010000 oorrrmmm</tt> || 2+ || 3
|-
| ADC mem16, reg16 || <tt>11 /r</tt> || <tt>00010001 oorrrmmm</tt> || 2+ || 3
|-
| ADC reg8, imm8 || <tt>80 /2 ii</tt> || <tt>10000000 11010mmm iiiiiiii</tt> || 3+ || 1
|-
| ADC reg16, imm16 || <tt>81 /2 ii ii</tt> || <tt>10000001 11010mmm iiiiiiii iiiiiiii</tt> || 4+ || 1
|-
| ADC reg16, simm8 || <tt>83 /2 ii ii</tt> || <tt>10000011 11010mmm iiiiiiii iiiiiiii</tt> || 4+ || 1
|-
| ADC reg8, mem8 || <tt>12 /r</tt> || <tt>00010010 oorrrmmm</tt> || 2+ || 2
|-
| ADC reg16, mem16 || <tt>13 /r</tt> || <tt>00010011 oorrrmmm</tt> || 2+ || 2
|-
| ADC reg8, reg8 || <tt>10 /r</tt> || <tt>000100.0 11rrrmmm</tt> || 2 || 1
|-
| ADC reg16, reg16 || <tt>11 /r</tt> || <tt>000100.1 11rrrmmm</tt> || 2 || 1
|}
----
{{Anchor|ADD}}
=== ADD ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| ADD AL, imm || <tt>04 ii</tt> || <tt>00000100 iiiiiiii</tt> || 2 || 1
|-
| ADD AX, imm || <tt>05 ii ii</tt> || <tt>00000101 iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| ADD mem8, imm8 || <tt>80 /0 ii</tt> || <tt>10000000 oo000mmm iiiiiiii</tt> || 3+ || 3
|-
| ADD mem16, imm16 || <tt>81 /0 ii ii</tt> || <tt>10000001 oo000mmm iiiiiiii iiiiiiii</tt> || 4+ || 3
|-
| ADD mem16, simm8 || <tt>83 /0 ii ii</tt> || <tt>10000011 oo000mmm iiiiiiii iiiiiiii</tt> || 4+ || 3
|-
| ADD mem8, reg8 || <tt>00 /r</tt> || <tt>00000000 oorrrmmm</tt> || 2+ || 3
|-
| ADD mem16, reg16 || <tt>01 /r</tt> || <tt>00000001 oorrrmmm</tt> || 2+ || 3
|-
| ADD reg8, imm8 || <tt>80 /0 ii</tt> || <tt>10000000 11000mmm iiiiiiii</tt> || 3+ || 1
|-
| ADD reg16, imm16 || <tt>81 /0 ii ii</tt> || <tt>10000001 11000mmm iiiiiiii iiiiiiii</tt> || 4+ || 1
|-
| ADD reg16, simm8 || <tt>83 /0 ii ii</tt> || <tt>10000011 11000mmm iiiiiiii iiiiiiii</tt> || 4+ || 1
|-
| ADD reg8, mem8 || <tt>02 /r</tt> || <tt>00000010 oorrrmmm</tt> || 2+ || 2
|-
| ADD reg16, mem16 || <tt>03 /r</tt> || <tt>00000011 oorrrmmm</tt> || 2+ || 2
|-
| ADD reg8, reg8 || <tt>00 /r</tt> || <tt>000000.0 11rrrmmm</tt> || 2 || 1
|-
| ADD reg16, reg16 || <tt>01 /r</tt> || <tt>000000.1 11rrrmmm</tt> || 2 || 1
|}
----
{{Anchor|AND}}
=== AND ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| AND AL, imm || <tt>24 ii</tt> || <tt>00100100 iiiiiiii</tt> || 2 || 1
|-
| AND AX, imm || <tt>25 ii ii</tt> || <tt>00100101 iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| AND mem8, imm8 || <tt>80 /4 ii</tt> || <tt>10000000 oo100mmm iiiiiiii</tt> || 3+ || 3
|-
| AND mem16, imm16 || <tt>81 /4 ii ii</tt> || <tt>10000001 oo100mmm iiiiiiii iiiiiiii</tt> || 4+ || 3
|-
| AND mem16, simm8 || <tt>83 /4 ii ii</tt> || <tt>10000011 oo100mmm iiiiiiii iiiiiiii</tt> || 4+ || 3
|-
| AND mem8, reg8 || <tt>20 /r</tt> || <tt>00100000 oorrrmmm</tt> || 2+ || 3
|-
| AND mem16, reg16 || <tt>21 /r</tt> || <tt>00100001 oorrrmmm</tt> || 2+ || 3
|-
| AND reg8, imm8 || <tt>80 /4 ii</tt> || <tt>10000000 11100mmm iiiiiiii</tt> || 3+ || 1
|-
| AND reg16, imm16 || <tt>81 /4 ii ii</tt> || <tt>10000001 11100mmm iiiiiiii iiiiiiii</tt> || 4+ || 1
|-
| AND reg16, simm8 || <tt>83 /4 ii ii</tt> || <tt>10000011 11100mmm iiiiiiii iiiiiiii</tt> || 4+ || 1
|-
| AND reg8, mem8 || <tt>22 /r</tt> || <tt>00100010 oorrrmmm</tt> || 2+ || 2
|-
| AND reg16, mem16 || <tt>23 /r</tt> || <tt>00100011 oorrrmmm</tt> || 2+ || 2
|-
| AND reg8, reg8 || <tt>20 /r</tt> || <tt>001000.0 11rrrmmm</tt> || 2 || 1
|-
| AND reg16, reg16 || <tt>21 /r</tt> || <tt>001000.1 11rrrmmm</tt> || 2 || 1
|}
----
{{Anchor|BOUND}}
=== BOUND ===
----
{{Anchor|CALL}}
=== CALL ===
----
{{Anchor|CBW}}
=== CBW ===
----
{{Anchor|CLC}}
=== CLC ===
----
{{Anchor|CLD}}
=== CLD ===
----
{{Anchor|CLI}}
=== CLI ===
----
{{Anchor|CMC}}
=== CMC ===
----
{{Anchor|CMP}}
=== CMP ===
----
{{Anchor|CMPSB}}
=== CMPSB ===
----
{{Anchor|CMPSW}}
=== CMPSW ===
----
{{Anchor|CS}}
=== CS ===
----
{{Anchor|CWD}}
=== CWD ===
----
{{Anchor|DAA}}
=== DAA ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| DAA || <tt>27</tt> || <tt>00100111</tt> || 1 || 10
|}
----
{{Anchor|DAS}}
=== DAS ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| DAS || <tt>2F</tt> || <tt>00101111</tt> || 1 || 10
|}
----
{{Anchor|DEC}}
=== DEC ===
----
{{Anchor|DIV}}
=== DIV ===
----
{{Anchor|DS}}
=== DS ===
----
{{Anchor|ENTER}}
=== ENTER ===
----
{{Anchor|ES}}
=== ES ===
----
{{Anchor|HLT}}
=== HLT ===
----
{{Anchor|IDIV}}
=== IDIV ===
----
{{Anchor|IMUL}}
=== IMUL ===
----
{{Anchor|IN}}
=== IN ===
----
{{Anchor|INC}}
=== INC ===
----
{{Anchor|INSB}}
=== INSB ===
----
{{Anchor|INSW}}
=== INSW ===
----
{{Anchor|INT}}
=== INT ===
----
{{Anchor|INTO}}
=== INTO ===
----
{{Anchor|IRET}}
=== IRET ===
----
{{Anchor|JA}}
=== JA ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JA rel8 || <tt>77 ii</tt> || <tt>01110111 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JBE}}
=== JBE ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JA rel8 || <tt>76 ii</tt> || <tt>01110110 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JC}}
=== JC/JB ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JC rel8 || <tt>72 ii</tt> || <tt>01110010 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JCXZ}}
=== JCXZ ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JCXZ rel8 || <tt>E3 ii</tt> || <tt>11100011 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JG}}
=== JG ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JG rel8 || <tt>7F ii</tt> || <tt>01111111 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JGE}}
=== JGE ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JGE rel8 || <tt>7D ii</tt> || <tt>01111101 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JL}}
=== JL ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JL rel8 || <tt>7C ii</tt> || <tt>01111100 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JLE}}
=== JLE ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JLE rel8 || <tt>7E ii</tt> || <tt>01111110 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JMP}}
=== JMP ===
----
{{Anchor|JNC}}
=== JNC/JAE ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JNC rel8 || <tt>73 ii</tt> || <tt>01110011 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JNO}}
=== JNO ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JNO rel8 || <tt>71 ii</tt> || <tt>01110001 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JNP}}
=== JNP ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JNP rel8 || <tt>7B ii</tt> || <tt>01111011 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JNS}}
=== JNS ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JNS rel8 || <tt>79 ii</tt> || <tt>01111001 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JNZ}}
=== JNZ/JNE ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JNZ rel8 || <tt>75 ii</tt> || <tt>01110101 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JO}}
=== JO ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JO rel8 || <tt>70 ii</tt> || <tt>01110000 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JP}}
=== JP ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JP rel8 || <tt>7A ii</tt> || <tt>01111010 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JS}}
=== JS ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JS rel8 || <tt>78 ii</tt> || <tt>01111000 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JZ}}
=== JZ/JE ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JZ rel8 || <tt>74 ii</tt> || <tt>01110100 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|LAHF}}
=== LAHF ===
----
{{Anchor|LDS}}
=== LDS ===
----
{{Anchor|LEA}}
=== LEA ===
----
{{Anchor|LEAVE}}
=== LEAVE ===
----
{{Anchor|LES}}
=== LES ===
----
{{Anchor|LOCK}}
=== LOCK ===
----
{{Anchor|LODSB}}
=== LODSB ===
----
{{Anchor|LODSW}}
=== LODSW ===
----
{{Anchor|LOOP}}
=== LOOP ===
----
{{Anchor|LOOPE}}
=== LOOPE ===
----
{{Anchor|LOOPNE}}
=== LOOPNE ===
----
{{Anchor|MOV}}
=== MOV ===
----
{{Anchor|MOVSB}}
=== MOVSB ===
----
{{Anchor|MOVSW}}
=== MOVSW ===
----
{{Anchor|MUL}}
=== MUL ===
----
{{Anchor|NEG}}
=== NEG ===
----
{{Anchor|NOP}}
=== NOP ===
----
{{Anchor|NOT}}
=== NOT ===
----
{{Anchor|OR}}
=== OR ===
----
{{Anchor|OUT}}
=== OUT ===
----
{{Anchor|OUTSB}}
=== OUTSB ===
----
{{Anchor|OUTSW}}
=== OUTSW ===
----
{{Anchor|POLL}}
=== POLL ===
----
{{Anchor|POP}}
=== POP ===
----
{{Anchor|POPA}}
=== POPA ===
----
{{Anchor|POPF}}
=== POPF ===
----
{{Anchor|PUSH}}
=== PUSH ===
----
{{Anchor|PUSHA}}
=== PUSHA ===
----
{{Anchor|PUSHF}}
=== PUSHF ===
----
{{Anchor|RCL}}
=== RCL ===
----
{{Anchor|RCR}}
=== RCR ===
----
{{Anchor|REP}}
=== REP/REPE/REPZ ===
----
{{Anchor|REPNE}}
=== REPNE/REPNZ ===
----
{{Anchor|RET}}
=== RET ===
----
{{Anchor|RETF}}
=== RETF ===
----
{{Anchor|ROL}}
=== ROL ===
----
{{Anchor|ROR}}
=== ROR ===
----
{{Anchor|SAHF}}
=== SAHF ===
----
{{Anchor|SAR}}
=== SAR ===
----
{{Anchor|SBB}}
=== SBB ===
----
{{Anchor|SCASB}}
=== SCASB ===
----
{{Anchor|SCASW}}
=== SCASW ===
----
{{Anchor|SHL}}
=== SHL ===
----
{{Anchor|SHR}}
=== SHR ===
----
{{Anchor|SS}}
=== SS ===
----
{{Anchor|STC}}
=== STC ===
----
{{Anchor|STD}}
=== STD ===
----
{{Anchor|STI}}
=== STI ===
----
{{Anchor|STOSB}}
=== STOSB ===
----
{{Anchor|STOSW}}
=== STOSW ===
----
{{Anchor|SUB}}
=== SUB ===
----
{{Anchor|TEST}}
=== TEST ===
----
{{Anchor|XCHG}}
=== XCHG ===
----
{{Anchor|XLAT}}
=== XLAT ===
----
{{Anchor|XOR}}
=== XOR ===
----
020738bcf615b6cbe04b46cc88ea156fbb1138f8
445
443
2024-12-26T19:01:47Z
Asie
351
/* Official instructions */
wikitext
text/x-wiki
__NOTOC__
{| class="wikitable" style="text-align: center"
|+ Official V30MZ (80186) Instructions
|-
| [[#AAA|AAA]] || [[#AAD|AAD]] || [[#AAM|AAM]] || [[#AAS|AAS]] || [[#ADC|ADC]] || [[#ADD|ADD]] || [[#AND|AND]] || [[#BOUND|BOUND]] || [[#CALL|CALL]] || [[#CBW|CBW]] || [[#CLC|CLC]]
|-
| [[#CLD|CLD]] || [[#CLI|CLI]] || [[#CMC|CMC]] || [[#CMP|CMP]] || [[#CMPSB|CMPSB]] || [[#CMPSW|CMPSW]] || [[#CS|CS]] || [[#CWD|CWD]] || [[#DAA|DAA]] || [[#DAS|DAS]] || [[#DEC|DEC]]
|-
| [[#DIV|DIV]] || [[#DS|DS]] || [[#ENTER|ENTER]] || [[#ES|ES]] || [[#HLT|HLT]] || [[#IDIV|IDIV]] || [[#IMUL|IMUL]] || [[#IN|IN]] || [[#INC|INC]] || [[#INSB|INSB]] || [[#INSW|INSW]]
|-
| [[#INT|INT]] || [[#INTO|INTO]] || [[#IRET|IRET]] || [[#JA|JA]] || [[#JBE|JBE]] || [[#JC|JC]] || [[#JCXZ|JCXZ]] || [[#JG|JG]] || [[#JGE|JGE]] || [[#JL|JL]] || [[#JLE|JLE]]
|-
| [[#JMP|JMP]] || [[#JNC|JNC]] || [[#JNO|JNO]] || [[#JNP|JNP]] || [[#JNS|JNS]] || [[#JNZ|JNZ]] || [[#JO|JO]] || [[#JP|JP]] || [[#JS|JS]] || [[#JZ|JZ]] || [[#LAHF|LAHF]]
|-
| [[#LDS|LDS]] || [[#LEA|LEA]] || [[#LEAVE|LEAVE]] || [[#LES|LES]] || [[#LOCK|LOCK]] || [[#LODSB|LODSB]] || [[#LODSW|LODSW]] || [[#LOOP|LOOP]] || [[#LOOPE|LOOPE]] || [[#LOOPNE|LOOPNE]] || [[#MOV|MOV]]
|-
| [[#MOVSB|MOVSB]] || [[#MOVSW|MOVSW]] || [[#MUL|MUL]] || [[#NEG|NEG]] || [[#NOP|NOP]] || [[#NOT|NOT]] || [[#OR|OR]] || [[#OUT|OUT]] || [[#OUTSB|OUTSB]] || [[#OUTSW|OUTSW]] || [[#POLL|POLL]]
|-
| [[#POP|POP]] || [[#POPA|POPA]] || [[#POPF|POPF]] || [[#PUSH|PUSH]] || [[#PUSHA|PUSHA]] || [[#PUSHF|PUSHF]] || [[#RCL|RCL]] || [[#RCR|RCR]] || [[#REP|REP]] || [[#REPNE|REPNE]] || [[#RET|RET]]
|-
| [[#RETF|RETF]] || [[#ROL|ROL]] || [[#ROR|ROR]] || [[#SAHF|SAHF]] || [[#SAR|SAR]] || [[#SBB|SBB]] || [[#SCASB|SCASB]] || [[#SCASW|SCASW]] || [[#SHL|SHL]] || [[#SHR|SHR]] || [[#SS|SS]]
|-
| [[#STC|STC]] || [[#STD|STD]] || [[#STI|STI]] || [[#STOSB|STOSB]] || [[#STOSW|STOSW]] || [[#SUB|SUB]] || [[#TEST|TEST]] || [[#XCHG|XCHG]] || [[#XLAT|XLAT]] || [[#XOR|XOR]]
|}
{| class="mw-collapsible mw-collapsed wikitable sortable" style="width: 340px;"
|+ style="white-space:nowrap; border:1px solid; padding:3px; border-color:rgb(162, 169, 177); background-color:rgb(234, 236, 240);" | Intel <-> NEC mnemonic translation table
!Intel
!NEC
|-
| [[#AAA|AAA]]
| [[#AAA|ADJBA]]
|-
| [[#AAD|AAD]]
| [[#AAD|CVTDB]]
|-
| [[#AAM|AAM]]
| [[#AAM|CVTBD]]
|-
| [[#AAS|AAS]]
| [[#AAS|ADJBS]]
|-
| [[#ADC|ADC]]
| [[#ADC|ADDC]]
|-
| [[#ADD|ADD]]
| [[#ADD|ADD]]
|-
| [[#AND|AND]]
| [[#AND|AND]]
|-
| [[#BOUND|BOUND]]
| [[#BOUND|CHKIND]]
|-
| [[#CALL|CALL]]
| [[#CALL|CALL]]
|-
| [[#CBW|CBW]]
| [[#CBW|CVTBW]]
|-
| [[#CLC|CLC]]
| [[#CLC|CLR1 CY]]
|-
| [[#CLD|CLD]]
| [[#CLD|CLR1 DIR]]
|-
| [[#CLI|CLI]]
| [[#CLI|DI]]
|-
| [[#CMC|CMC]]
| [[#CMC|NOT1 CY]]
|-
| [[#CMP|CMP]]
| [[#CMP|CMP]]
|-
| [[#CMPSB|CMPSB]]
| [[#CMPSB|CMPBKB]]
|-
| [[#CMPSW|CMPSW]]
| [[#CMPSW|CMPBKW]]
|-
| [[#CS|CS]]
| [[#CS|PS]]
|-
| [[#CWD|CWD]]
| [[#CWD|CVTWL]]
|-
| [[#DAA|DAA]]
| [[#DAA|ADJ4A]]
|-
| [[#DAS|DAS]]
| [[#DAS|ADJ4S]]
|-
| [[#DEC|DEC]]
| [[#DEC|DEC]]
|-
| [[#DIV|DIV]]
| [[#DIV|DIVU]]
|-
| [[#DS|DS]]
| [[#DS|DS0]]
|-
| [[#ENTER|ENTER]]
| [[#ENTER|PREPARE]]
|-
| [[#ES|ES]]
| [[#ES|DS1]]
|-
| [[#HLT|HLT]]
| [[#HLT|HALT]]
|-
| [[#IDIV|IDIV]]
| [[#IDIV|DIV]]
|-
| [[#IMUL|IMUL]]
| [[#IMUL|MUL]]
|-
| [[#IN|IN]]
| [[#IN|IN]]
|-
| [[#INC|INC]]
| [[#INC|INC]]
|-
| [[#INSB|INSB]]
| [[#INSB|INMB]]
|-
| [[#INSW|INSW]]
| [[#INSW|INMW]]
|-
| [[#INT|INT]]
| [[#INT|BRK]]
|-
| [[#INTO|INTO]]
| [[#INTO|BRKV]]
|-
| [[#IRET|IRET]]
| [[#IRET|RETI]]
|-
| [[#JA|JA]]
| [[#JA|BH]]
|-
| [[#JBE|JBE]]
| [[#JBE|BNH]]
|-
| [[#JC|JC/JB]]
| [[#JC|BC/BL]]
|-
| [[#JCXZ|JCXZ]]
| [[#JCXZ|BCWZ]]
|-
| [[#JG|JG]]
| [[#JG|BGT]]
|-
| [[#JGE|JGE]]
| [[#JGE|BGE]]
|-
| [[#JL|JL]]
| [[#JL|BLT]]
|-
| [[#JLE|JLE]]
| [[#JLE|BLE]]
|-
| [[#JMP|JMP]]
| [[#JMP|BR]]
|-
| [[#JNC|JNC/JAE]]
| [[#JNC|BNC/BNL]]
|-
| [[#JNO|JNO]]
| [[#JNO|BNV]]
|-
| [[#JNP|JNP]]
| [[#JNP|BPO]]
|-
| [[#JNS|JNS]]
| [[#JNS|BP]]
|-
| [[#JNZ|JNZ/JNE]]
| [[#JNZ|BNZ/BNE]]
|-
| [[#JO|JO]]
| [[#JO|BV]]
|-
| [[#JP|JP]]
| [[#JP|BPE]]
|-
| [[#JS|JS]]
| [[#JS|BN]]
|-
| [[#JZ|JZ/JE]]
| [[#JZ|BZ/BE]]
|-
| [[#LAHF|LAHF]]
| [[#LAHF|MOV]]
|-
| [[#LDS|LDS]]
| [[#LDS|MOV]]
|-
| [[#LEA|LEA]]
| [[#LEA|LDEA]]
|-
| [[#LEAVE|LEAVE]]
| [[#LEAVE|DISPOSE]]
|-
| [[#LES|LES]]
| [[#LES|MOV]]
|-
| [[#LOCK|LOCK]]
| [[#LOCK|BUSLOCK]]
|-
| [[#LODSB|LODSB]]
| [[#LODSB|LDMB]]
|-
| [[#LODSW|LODSW]]
| [[#LODSW|LDMW]]
|-
| [[#LOOP|LOOP]]
| [[#LOOP|DBNZ]]
|-
| [[#LOOPE|LOOPE]]
| [[#LOOPE|DBNZE]]
|-
| [[#LOOPNE|LOOPNE]]
| [[#LOOPNE|DBNZNE]]
|-
| [[#MOV|MOV]]
| [[#MOV|MOV]]
|-
| [[#MOVSB|MOVSB]]
| [[#MOVSB|MOVBKB]]
|-
| [[#MOVSW|MOVSW]]
| [[#MOVSW|MOVBKW]]
|-
| [[#MUL|MUL]]
| [[#MUL|MULU]]
|-
| [[#NEG|NEG]]
| [[#NEG|NEG]]
|-
| [[#NOP|NOP]]
| [[#NOP|NOP]]
|-
| [[#NOT|NOT]]
| [[#NOT|NOT]]
|-
| [[#OR|OR]]
| [[#OR|OR]]
|-
| [[#OUT|OUT]]
| [[#OUT|OUT]]
|-
| [[#OUTSB|OUTSB]]
| [[#OUTSB|OUTM]]
|-
| [[#OUTSW|OUTSW]]
| [[#OUTSW|OUTM]]
|-
| [[#POLL|POLL]]
| [[#POLL|POLL]]
|-
| [[#POP|POP]]
| [[#POP|POP]]
|-
| [[#POPA|POPA]]
| [[#POPA|POP]]
|-
| [[#POPF|POPF]]
| [[#POPF|POP]]
|-
| [[#PUSH|PUSH]]
| [[#PUSH|PUSH]]
|-
| [[#PUSHA|PUSHA]]
| [[#PUSHA|PUSH]]
|-
| [[#PUSHF|PUSHF]]
| [[#PUSHF|PUSH]]
|-
| [[#RCL|RCL]]
| [[#RCL|ROLC]]
|-
| [[#RCR|RCR]]
| [[#RCR|RORC]]
|-
| [[#REP|REP/REPE/REPZ]]
| [[#REP|REP/REPE/REPZ]]
|-
| [[#REPNE|REPNE/REPNZ]]
| [[#REPNE|REPNE/REPNZ]]
|-
| [[#RET|RET]]
| [[#RET|RET]]
|-
| [[#RETF|RETF]]
| [[#RETF|RET]]
|-
| [[#ROL|ROL]]
| [[#ROL|ROL]]
|-
| [[#ROR|ROR]]
| [[#ROR|ROR]]
|-
| [[#SAHF|SAHF]]
| [[#SAHF|MOV]]
|-
| [[#SAR|SAR]]
| [[#SAR|SHRA]]
|-
| [[#SBB|SBB]]
| [[#SBB|SUBC]]
|-
| [[#SCASB|SCASB]]
| [[#SCASB|CMPMB]]
|-
| [[#SCASW|SCASW]]
| [[#SCASW|CMPMW]]
|-
| [[#SHL|SHL]]
| [[#SHL|SHL]]
|-
| [[#SHR|SHR]]
| [[#SHR|SHR]]
|-
| [[#SS|SS]]
| [[#SS|SS]]
|-
| [[#STC|STC]]
| [[#STC|SET1 CY]]
|-
| [[#STD|STD]]
| [[#STD|SET1 DIR]]
|-
| [[#STI|STI]]
| [[#STI|EI]]
|-
| [[#STOSB|STOSB]]
| [[#STOSB|STMB]]
|-
| [[#STOSW|STOSW]]
| [[#STOSW|STMW]]
|-
| [[#SUB|SUB]]
| [[#SUB|SUB]]
|-
| [[#TEST|TEST]]
| [[#TEST|TEST]]
|-
| [[#XCHG|XCHG]]
| [[#XCHG|XCH]]
|-
| [[#XLAT|XLAT]]
| [[#XLAT|TRANS]]
|-
| [[#XOR|XOR]]
| [[#XOR|XOR]]
|}
== Official instructions by type ==
{| class="wikitable sortable" style="text-align: center"
!Type
!colspan=16 class="unsortable" | Instructions
|-
| style="text-align:left;" | Memory
| style="" | [[#MOV|MOV]]
| style="" | [[#XCHG|XCHG]]
| style="" | [[#XLAT|XLAT]]
| style="" | [[#LEA|LEA]]
| style="border-right:none;" | [[#LDS|LDS]]
| style="border-left:none;" | [[#LES|LES]]
| style="border-right:none;" | [[#IN|IN]]
| style="border-left:none;" | [[#OUT|OUT]]
| colspan="8" |
|-
| style="text-align:left;" | Ports
| style="border-right:none;" | [[#IN|IN]]
| style="border-left:none;" | [[#OUT|OUT]]
| style="border-right:none;" | [[#INSB|INSB]]
| style="border-left:none;" | [[#OUTSB|OUTSB]]
| style="border-right:none;" | [[#INSW|INSW]]
| style="border-left:none;" | [[#OUTSW|OUTSW]]
| colspan="10" |
|-
| style="text-align:left;" | Arithmetic
| style="border-right:none;" | [[#ADD|ADD]]
| style="border-left:none;" | [[#SUB|SUB]]
| style="border-right:none;" | [[#ADC|ADC]]
| style="border-left:none;" | [[#SBB|SBB]]
| style="border-right:none;" | [[#INC|INC]]
| style="border-left:none;" | [[#DEC|DEC]]
| style="border-right:none;" | [[#MUL|MUL]]
| style="border-left:none;" | [[#DIV|DIV]]
| style="border-right:none;" | [[#IMUL|IMUL]]
| style="border-left:none;" | [[#IDIV|IDIV]]
| style="" | [[#CMP|CMP]]
| style="" | [[#NEG|NEG]]
| colspan="4" |
|-
| style="text-align:left;" | Numeric
| style="" | [[#CBW|CBW]]
| style="" | [[#CWD|CWD]]
| style="" | [[#AAA|AAA]]
| style="" | [[#AAS|AAS]]
| style="" | [[#AAM|AAM]]
| style="" | [[#AAD|AAD]]
| style="" | [[#DAA|DAA]]
| style="" | [[#DAS|DAS]]
| colspan="8" |
|-
| style="text-align:left;" | Shift
| style="border-right:none;" | [[#ROL|ROL]]
| style="border-left:none;" | [[#ROR|ROR]]
| style="border-right:none;" | [[#RCL|RCL]]
| style="border-left:none;" | [[#RCR|RCR]]
| style="border-right:none;" | [[#SHL|SHL]]
| style="border-left:none;" | [[#SHR|SHR]]
| style="" | [[#SAR|SAR]]
| colspan="9" |
|-
| style="text-align:left;" | Bitwise
| style="" | [[#AND|AND]]
| style="" | [[#OR|OR]]
| style="" | [[#XOR|XOR]]
| style="" | [[#NOT|NOT]]
| style="" | [[#TEST|TEST]]
| colspan="11" |
|-
| style="text-align:left;" | Branch
| style="border-right:none;" | [[#JC|JC]]
| style="border-left:none;" | [[#JNC|JNC]]
| style="border-right:none;" | [[#JZ|JZ]]
| style="border-left:none;" | [[#JNZ|JNZ]]
| style="border-right:none;" | [[#JBE|JBE]]
| style="border-left:none;" | [[#JA|JA]]
| style="border-right:none;" | [[#JO|JO]]
| style="border-left:none;" | [[#JNO|JNO]]
| style="border-right:none;" | [[#JP|JP]]
| style="border-left:none;" | [[#JNP|JNP]]
| style="border-right:none;" | [[#JS|JS]]
| style="border-left:none;" | [[#JNS|JNS]]
| style="border-right:none;" | [[#JL|JL]]
| style="border-left:none;" | [[#JGE|JGE]]
| style="border-right:none;" | [[#JLE|JLE]]
| style="border-left:none;" | [[#JG|JG]]
|-
| style="text-align:left;" | Jump
| style="" | [[#JMP|JMP]]
| style="border-right:none;" | [[#CALL|CALL]]
| style="border-left:none;border-right:none;" | [[#RET|RET]]
| style="border-left:none;" | [[#RETF|RETF]]
| colspan="12" |
|-
| style="text-align:left;" | Loop
| style="" | [[#LOOP|LOOP]]
| style="" | [[#LOOPE|LOOPE]]
| style="" | [[#LOOPNE|LOOPNE]]
| colspan="13" |
|-
| style="text-align:left;" | Interrupt
| style="border-right:none;" | [[#INT|INT]]
| style="border-left:none;" | [[#IRET|IRET]]
| style="" | [[#INTO|INTO]]
| style="" | [[#HLT|HLT]]
| style="" | [[#BOUND|BOUND]]
| colspan="11" |
|-
| style="text-align:left;" | Stack
| style="border-right:none;" | [[#PUSH|PUSH]]
| style="border-left:none;" | [[#POP|POP]]
| style="border-right:none;" | [[#PUSHA|PUSHA]]
| style="border-left:none;" | [[#POPA|POPA]]
| style="border-right:none;" | [[#PUSHF|PUSHF]]
| style="border-left:none;" | [[#POPF|POPF]]
| colspan="10" |
|-
| style="text-align:left;" | Flags
| style="border-right:none;" | [[#CLC|CLC]]
| style="border-left:none;" | [[#STC|STC]]
| style="border-right:none;" | [[#CLD|CLD]]
| style="border-left:none;" | [[#STD|STD]]
| style="border-right:none;" | [[#CLI|CLI]]
| style="border-left:none;" | [[#STI|STI]]
| style="" | [[#CMC|CMC]]
| style="border-right:none;" | [[#LAHF|LAHF]]
| style="border-left:none;" | [[#SAHF|SAHF]]
| colspan="7" |
|-
| style="text-align:left;" | Prefix
| style="" | [[#CS|CS]]
| style="" | [[#DS|DS]]
| style="" | [[#ES|ES]]
| style="" | [[#SS|SS]]
| colspan="12" |
|-
| style="text-align:left;" | String
| style="border-right:none;" | [[#REP|REP]]
| style="border-left:none;border-right:none;" | [[#REP|REPE]]
| style="border-left:none;" | [[#REPNE|REPNE]]
| style="" | [[#MOVSB|MOVSB]]
| style="" | [[#MOVSW|MOVSW]]
| style="border-right:none;" | [[#LODSB|LODSB]]
| style="border-left:none;" | [[#STOSB|STOSB]]
| style="border-right:none;" | [[#LODSW|LODSW]]
| style="border-left:none;" | [[#STOSW|STOSW]]
| style="" | [[#CMPSB|CMPSB]]
| style="" | [[#SCASB|SCASB]]
| style="" | [[#CMPSW|CMPSW]]
| style="" | [[#SCASW|SCASW]]
| colspan="3" |
|-
| style="text-align:left;" | Other
| style="" | [[#NOP|NOP]]
| style="border-right:none;" | [[#ENTER|ENTER]]
| style="border-left:none;" | [[#LEAVE|LEAVE]]
| style="" | [[#LOCK|LOCK]]
| style="" | [[#POLL|POLL]]
| colspan="11" |
|}
== Instruction encoding ==
=== ModR/M byte ===
The ModR/M byte is used in most addressing modes which reference a memory location. This byte consists of three bitfield values:
* <tt>oo</tt> - M'''o'''de;
* <tt>rrr</tt> - Two possible functions:
** '''R'''egister (for addressing modes which require both a register and a register/memory operand),
** Opcode extension (for some opcodes' addressing modes which do not have such a requirement);
* <tt>mmm</tt> - Register/'''M'''emory.
The ''Mode'' and ''Register/Memory'' bitfields can refer to a memory location with an optional signed 8-bit (disp8) or 16-bit (disp16) displacement or to a register, as shown in the table below. In some addressing modes, the ''Register'' field also refers to a register; it is always interpreted as if ''Mode'' was equal to <tt>11</tt>.
{| class="wikitable" style="text-align: center"
! R/M \ Mode
! <tt>00</tt>
! <tt>01</tt>
! <tt>10</tt>
! <tt>11</tt> ''(byte)''
! <tt>11</tt> ''(word)''
|-
| <tt>000</tt>
| DS:[BX + SI]
| DS:[BX + SI + disp8]
| DS:[BX + SI + disp16]
| AL
| AX
|-
| <tt>001</tt>
| DS:[BX + DI]
| DS:[BX + DI + disp8]
| DS:[BX + DI + disp16]
| CL
| CX
|-
| <tt>010</tt>
| SS:[BP + SI]
| SS:[BP + SI + disp8]
| SS:[BP + SI + disp16]
| DL
| DX
|-
| <tt>011</tt>
| SS:[BP + DI]
| SS:[BP + DI + disp8]
| SS:[BP + DI + disp16]
| BL
| BX
|-
| <tt>100</tt>
| DS:[SI]
| DS:[SI + disp8]
| DS:[SI + disp16]
| AH
| SP
|-
| <tt>101</tt>
| DS:[DI]
| DS:[DI + disp8]
| DS:[DI + disp16]
| CH
| BP
|-
| <tt>110</tt>
| ''DS:[disp16]''
| SS:[BP + disp8]
| SS:[BP + disp16]
| DH
| SI
|-
| <tt>111</tt>
| DS:[BX]
| DS:[BX + disp8]
| DS:[BX + disp16]
| BH
| DI
|}
Note that (<tt>oo</tt> = <tt>00</tt>, <tt>mmm</tt> = <tt>110</tt>) is a special case.
The instruction encoding lists below refer to this byte as <tt>oorrrmmm</tt> (binary), <tt>/r</tt> (hexadecimal) or <tt>/0</tt> (hexademical, <tt>rrr</tt> used as function <tt>0</tt>).
== Official instructions ==
{{Anchor|AAA}}
=== AAA ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| AAA || <tt>37</tt> || <tt>00110111</tt> || 1 || 9
|}
----
{{Anchor|AAD}}
=== AAD ===
----
{{Anchor|AAM}}
=== AAM ===
----
{{Anchor|AAS}}
=== AAS ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| AAS || <tt>3F</tt> || <tt>00111111</tt> || 1 || 9
|}
----
{{Anchor|ADC}}
=== ADC ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| ADC AL, imm || <tt>14 ii</tt> || <tt>00010100 iiiiiiii</tt> || 2 || 1
|-
| ADC AX, imm || <tt>15 ii ii</tt> || <tt>00010101 iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| ADC mem8, imm8 || <tt>80 /2 ii</tt> || <tt>10000000 oo010mmm iiiiiiii</tt> || 3+ || 3
|-
| ADC mem16, imm16 || <tt>81 /2 ii ii</tt> || <tt>10000001 oo010mmm iiiiiiii iiiiiiii</tt> || 4+ || 3
|-
| ADC mem16, simm8 || <tt>83 /2 ii ii</tt> || <tt>10000011 oo010mmm iiiiiiii iiiiiiii</tt> || 4+ || 3
|-
| ADC mem8, reg8 || <tt>10 /r</tt> || <tt>00010000 oorrrmmm</tt> || 2+ || 3
|-
| ADC mem16, reg16 || <tt>11 /r</tt> || <tt>00010001 oorrrmmm</tt> || 2+ || 3
|-
| ADC reg8, imm8 || <tt>80 /2 ii</tt> || <tt>10000000 11010mmm iiiiiiii</tt> || 3+ || 1
|-
| ADC reg16, imm16 || <tt>81 /2 ii ii</tt> || <tt>10000001 11010mmm iiiiiiii iiiiiiii</tt> || 4+ || 1
|-
| ADC reg16, simm8 || <tt>83 /2 ii ii</tt> || <tt>10000011 11010mmm iiiiiiii iiiiiiii</tt> || 4+ || 1
|-
| ADC reg8, mem8 || <tt>12 /r</tt> || <tt>00010010 oorrrmmm</tt> || 2+ || 2
|-
| ADC reg16, mem16 || <tt>13 /r</tt> || <tt>00010011 oorrrmmm</tt> || 2+ || 2
|-
| ADC reg8, reg8 || <tt>10 /r</tt> || <tt>000100.0 11rrrmmm</tt> || 2 || 1
|-
| ADC reg16, reg16 || <tt>11 /r</tt> || <tt>000100.1 11rrrmmm</tt> || 2 || 1
|}
----
{{Anchor|ADD}}
=== ADD ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| ADD AL, imm || <tt>04 ii</tt> || <tt>00000100 iiiiiiii</tt> || 2 || 1
|-
| ADD AX, imm || <tt>05 ii ii</tt> || <tt>00000101 iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| ADD mem8, imm8 || <tt>80 /0 ii</tt> || <tt>10000000 oo000mmm iiiiiiii</tt> || 3+ || 3
|-
| ADD mem16, imm16 || <tt>81 /0 ii ii</tt> || <tt>10000001 oo000mmm iiiiiiii iiiiiiii</tt> || 4+ || 3
|-
| ADD mem16, simm8 || <tt>83 /0 ii ii</tt> || <tt>10000011 oo000mmm iiiiiiii iiiiiiii</tt> || 4+ || 3
|-
| ADD mem8, reg8 || <tt>00 /r</tt> || <tt>00000000 oorrrmmm</tt> || 2+ || 3
|-
| ADD mem16, reg16 || <tt>01 /r</tt> || <tt>00000001 oorrrmmm</tt> || 2+ || 3
|-
| ADD reg8, imm8 || <tt>80 /0 ii</tt> || <tt>10000000 11000mmm iiiiiiii</tt> || 3+ || 1
|-
| ADD reg16, imm16 || <tt>81 /0 ii ii</tt> || <tt>10000001 11000mmm iiiiiiii iiiiiiii</tt> || 4+ || 1
|-
| ADD reg16, simm8 || <tt>83 /0 ii ii</tt> || <tt>10000011 11000mmm iiiiiiii iiiiiiii</tt> || 4+ || 1
|-
| ADD reg8, mem8 || <tt>02 /r</tt> || <tt>00000010 oorrrmmm</tt> || 2+ || 2
|-
| ADD reg16, mem16 || <tt>03 /r</tt> || <tt>00000011 oorrrmmm</tt> || 2+ || 2
|-
| ADD reg8, reg8 || <tt>00 /r</tt> || <tt>000000.0 11rrrmmm</tt> || 2 || 1
|-
| ADD reg16, reg16 || <tt>01 /r</tt> || <tt>000000.1 11rrrmmm</tt> || 2 || 1
|}
----
{{Anchor|AND}}
=== AND ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| AND AL, imm || <tt>24 ii</tt> || <tt>00100100 iiiiiiii</tt> || 2 || 1
|-
| AND AX, imm || <tt>25 ii ii</tt> || <tt>00100101 iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| AND mem8, imm8 || <tt>80 /4 ii</tt> || <tt>10000000 oo100mmm iiiiiiii</tt> || 3+ || 3
|-
| AND mem16, imm16 || <tt>81 /4 ii ii</tt> || <tt>10000001 oo100mmm iiiiiiii iiiiiiii</tt> || 4+ || 3
|-
| AND mem16, simm8 || <tt>83 /4 ii ii</tt> || <tt>10000011 oo100mmm iiiiiiii iiiiiiii</tt> || 4+ || 3
|-
| AND mem8, reg8 || <tt>20 /r</tt> || <tt>00100000 oorrrmmm</tt> || 2+ || 3
|-
| AND mem16, reg16 || <tt>21 /r</tt> || <tt>00100001 oorrrmmm</tt> || 2+ || 3
|-
| AND reg8, imm8 || <tt>80 /4 ii</tt> || <tt>10000000 11100mmm iiiiiiii</tt> || 3+ || 1
|-
| AND reg16, imm16 || <tt>81 /4 ii ii</tt> || <tt>10000001 11100mmm iiiiiiii iiiiiiii</tt> || 4+ || 1
|-
| AND reg16, simm8 || <tt>83 /4 ii ii</tt> || <tt>10000011 11100mmm iiiiiiii iiiiiiii</tt> || 4+ || 1
|-
| AND reg8, mem8 || <tt>22 /r</tt> || <tt>00100010 oorrrmmm</tt> || 2+ || 2
|-
| AND reg16, mem16 || <tt>23 /r</tt> || <tt>00100011 oorrrmmm</tt> || 2+ || 2
|-
| AND reg8, reg8 || <tt>20 /r</tt> || <tt>001000.0 11rrrmmm</tt> || 2 || 1
|-
| AND reg16, reg16 || <tt>21 /r</tt> || <tt>001000.1 11rrrmmm</tt> || 2 || 1
|}
----
{{Anchor|BOUND}}
=== BOUND ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| BOUND reg16, mem16:16 || <tt>62 /r</tt> || <tt>01100010 oorrrmmm</tt> || 2+ || 13 (20 if condition met)
|}
----
{{Anchor|CALL}}
=== CALL ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| CALL ptr16:16 || <tt>CA oo oo ss ss</tt> || <tt>10011010 oooooooo oooooooo ssssssss ssssssss</tt> || 5 || 10
|-
| CALL mem16 || <tt>FF /2</tt> || <tt>11111111 oo010mmm</tt> || 2+ || 6
|-
| CALL mem16:16 || <tt>FF /3</tt> || <tt>11111111 oo011mmm</tt> || 2+ || 12
|-
| CALL reg16 || <tt>FF /2</tt> || <tt>11111111 11010mmm</tt> || 2 || 5
|-
| CALL rel16 || <tt>E8 ii ii</tt> || <tt>11101000 iiiiiiii iiiiiiii</tt> || 3 || 5
|}
----
{{Anchor|CBW}}
=== CBW ===
----
{{Anchor|CLC}}
=== CLC ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| CLC || <tt>F8</tt> || <tt>11111000</tt> || 1 || 4
|}
----
{{Anchor|CLD}}
=== CLD ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| CLD || <tt>FC</tt> || <tt>11111100</tt> || 1 || 4
|}
----
{{Anchor|CLI}}
=== CLI ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| CLI || <tt>FA</tt> || <tt>11111010</tt> || 1 || 4
|}
----
{{Anchor|CMC}}
=== CMC ===
----
{{Anchor|CMP}}
=== CMP ===
----
{{Anchor|CMPSB}}
=== CMPSB ===
----
{{Anchor|CMPSW}}
=== CMPSW ===
----
{{Anchor|CS}}
=== CS ===
----
{{Anchor|CWD}}
=== CWD ===
----
{{Anchor|DAA}}
=== DAA ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| DAA || <tt>27</tt> || <tt>00100111</tt> || 1 || 10
|}
----
{{Anchor|DAS}}
=== DAS ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| DAS || <tt>2F</tt> || <tt>00101111</tt> || 1 || 10
|}
----
{{Anchor|DEC}}
=== DEC ===
----
{{Anchor|DIV}}
=== DIV ===
----
{{Anchor|DS}}
=== DS ===
----
{{Anchor|ENTER}}
=== ENTER ===
----
{{Anchor|ES}}
=== ES ===
----
{{Anchor|HLT}}
=== HLT ===
----
{{Anchor|IDIV}}
=== IDIV ===
----
{{Anchor|IMUL}}
=== IMUL ===
----
{{Anchor|IN}}
=== IN ===
----
{{Anchor|INC}}
=== INC ===
----
{{Anchor|INSB}}
=== INSB ===
----
{{Anchor|INSW}}
=== INSW ===
----
{{Anchor|INT}}
=== INT ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| INT 3 || <tt>CC</tt> || <tt>11001100</tt> || 1 || 9
|-
| INT imm8 || <tt>CD ii</tt> || <tt>11001101 iiiiiiii</tt> || 2 || 10
|}
----
{{Anchor|INTO}}
=== INTO ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| INTO || <tt>CE</tt> || <tt>11001110</tt> || 1 || 6 (13 if OF = 1)
|}
----
{{Anchor|IRET}}
=== IRET ===
----
{{Anchor|JA}}
=== JA ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JA rel8 || <tt>77 ii</tt> || <tt>01110111 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JBE}}
=== JBE ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JA rel8 || <tt>76 ii</tt> || <tt>01110110 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JC}}
=== JC/JB ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JC rel8 || <tt>72 ii</tt> || <tt>01110010 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JCXZ}}
=== JCXZ ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JCXZ rel8 || <tt>E3 ii</tt> || <tt>11100011 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JG}}
=== JG ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JG rel8 || <tt>7F ii</tt> || <tt>01111111 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JGE}}
=== JGE ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JGE rel8 || <tt>7D ii</tt> || <tt>01111101 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JL}}
=== JL ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JL rel8 || <tt>7C ii</tt> || <tt>01111100 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JLE}}
=== JLE ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JLE rel8 || <tt>7E ii</tt> || <tt>01111110 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JMP}}
=== JMP ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JMP ptr16:16 || <tt>EA oo oo ss ss</tt> || <tt>11101010 oooooooo oooooooo ssssssss ssssssss</tt> || 5 || 7
|-
| JMP mem16 || <tt>FF /4</tt> || <tt>11111111 oo100mmm</tt> || 2+ || 5
|-
| JMP mem16:16 || <tt>FF /5</tt> || <tt>11111111 oo101mmm</tt> || 2+ || 10
|-
| JMP reg16 || <tt>FF /4</tt> || <tt>11111111 11100mmm</tt> || 2 || 4
|-
| JMP rel8 || <tt>EB ii</tt> || <tt>11101011 iiiiiiii</tt> || 2 || 4
|-
| JMP rel16 || <tt>E9 ii ii</tt> || <tt>11101001 iiiiiiii iiiiiiii</tt> || 3 || 4
|}
----
{{Anchor|JNC}}
=== JNC/JAE ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JNC rel8 || <tt>73 ii</tt> || <tt>01110011 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JNO}}
=== JNO ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JNO rel8 || <tt>71 ii</tt> || <tt>01110001 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JNP}}
=== JNP ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JNP rel8 || <tt>7B ii</tt> || <tt>01111011 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JNS}}
=== JNS ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JNS rel8 || <tt>79 ii</tt> || <tt>01111001 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JNZ}}
=== JNZ/JNE ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JNZ rel8 || <tt>75 ii</tt> || <tt>01110101 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JO}}
=== JO ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JO rel8 || <tt>70 ii</tt> || <tt>01110000 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JP}}
=== JP ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JP rel8 || <tt>7A ii</tt> || <tt>01111010 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JS}}
=== JS ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JS rel8 || <tt>78 ii</tt> || <tt>01111000 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JZ}}
=== JZ/JE ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JZ rel8 || <tt>74 ii</tt> || <tt>01110100 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|LAHF}}
=== LAHF ===
----
{{Anchor|LDS}}
=== LDS ===
----
{{Anchor|LEA}}
=== LEA ===
----
{{Anchor|LEAVE}}
=== LEAVE ===
----
{{Anchor|LES}}
=== LES ===
----
{{Anchor|LOCK}}
=== LOCK ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| LOCK || <tt>F0</tt> || <tt>11110000</tt> || 1 || 1
|}
----
{{Anchor|LODSB}}
=== LODSB ===
----
{{Anchor|LODSW}}
=== LODSW ===
----
{{Anchor|LOOP}}
=== LOOP ===
----
{{Anchor|LOOPE}}
=== LOOPE ===
----
{{Anchor|LOOPNE}}
=== LOOPNE ===
----
{{Anchor|MOV}}
=== MOV ===
----
{{Anchor|MOVSB}}
=== MOVSB ===
----
{{Anchor|MOVSW}}
=== MOVSW ===
----
{{Anchor|MUL}}
=== MUL ===
----
{{Anchor|NEG}}
=== NEG ===
----
{{Anchor|NOP}}
=== NOP ===
----
{{Anchor|NOT}}
=== NOT ===
----
{{Anchor|OR}}
=== OR ===
----
{{Anchor|OUT}}
=== OUT ===
----
{{Anchor|OUTSB}}
=== OUTSB ===
----
{{Anchor|OUTSW}}
=== OUTSW ===
----
{{Anchor|POLL}}
=== POLL ===
----
{{Anchor|POP}}
=== POP ===
----
{{Anchor|POPA}}
=== POPA ===
----
{{Anchor|POPF}}
=== POPF ===
----
{{Anchor|PUSH}}
=== PUSH ===
----
{{Anchor|PUSHA}}
=== PUSHA ===
----
{{Anchor|PUSHF}}
=== PUSHF ===
----
{{Anchor|RCL}}
=== RCL ===
----
{{Anchor|RCR}}
=== RCR ===
----
{{Anchor|REP}}
=== REP/REPE/REPZ ===
----
{{Anchor|REPNE}}
=== REPNE/REPNZ ===
----
{{Anchor|RET}}
=== RET ===
----
{{Anchor|RETF}}
=== RETF ===
----
{{Anchor|ROL}}
=== ROL ===
----
{{Anchor|ROR}}
=== ROR ===
----
{{Anchor|SAHF}}
=== SAHF ===
----
{{Anchor|SAR}}
=== SAR ===
----
{{Anchor|SBB}}
=== SBB ===
----
{{Anchor|SCASB}}
=== SCASB ===
----
{{Anchor|SCASW}}
=== SCASW ===
----
{{Anchor|SHL}}
=== SHL ===
----
{{Anchor|SHR}}
=== SHR ===
----
{{Anchor|SS}}
=== SS ===
----
{{Anchor|STC}}
=== STC ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| STC || <tt>F9</tt> || <tt>11111001</tt> || 1 || 4
|}
----
{{Anchor|STD}}
=== STD ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| STD || <tt>FD</tt> || <tt>11111101</tt> || 1 || 4
|}
----
{{Anchor|STI}}
=== STI ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| STI || <tt>FB</tt> || <tt>11111011</tt> || 1 || 4
|}
----
{{Anchor|STOSB}}
=== STOSB ===
----
{{Anchor|STOSW}}
=== STOSW ===
----
{{Anchor|SUB}}
=== SUB ===
----
{{Anchor|TEST}}
=== TEST ===
----
{{Anchor|XCHG}}
=== XCHG ===
----
{{Anchor|XLAT}}
=== XLAT ===
----
{{Anchor|XOR}}
=== XOR ===
----
1bfea947b22ee331cf26f9b88fff2c4f4064edf9
446
445
2024-12-26T19:33:29Z
Asie
351
wikitext
text/x-wiki
__NOTOC__
Note that this page is a work in progress.
{| class="wikitable" style="text-align: center"
|+ Official V30MZ (80186) Instructions
|-
| [[#AAA|AAA]] || [[#AAD|AAD]] || [[#AAM|AAM]] || [[#AAS|AAS]] || [[#ADC|ADC]] || [[#ADD|ADD]] || [[#AND|AND]] || [[#BOUND|BOUND]] || [[#CALL|CALL]] || [[#CBW|CBW]] || [[#CLC|CLC]]
|-
| [[#CLD|CLD]] || [[#CLI|CLI]] || [[#CMC|CMC]] || [[#CMP|CMP]] || [[#CMPSB|CMPSB]] || [[#CMPSW|CMPSW]] || [[#CS|CS]] || [[#CWD|CWD]] || [[#DAA|DAA]] || [[#DAS|DAS]] || [[#DEC|DEC]]
|-
| [[#DIV|DIV]] || [[#DS|DS]] || [[#ENTER|ENTER]] || [[#ES|ES]] || [[#HLT|HLT]] || [[#IDIV|IDIV]] || [[#IMUL|IMUL]] || [[#IN|IN]] || [[#INC|INC]] || [[#INSB|INSB]] || [[#INSW|INSW]]
|-
| [[#INT|INT]] || [[#INTO|INTO]] || [[#IRET|IRET]] || [[#JA|JA]] || [[#JBE|JBE]] || [[#JC|JC]] || [[#JCXZ|JCXZ]] || [[#JG|JG]] || [[#JGE|JGE]] || [[#JL|JL]] || [[#JLE|JLE]]
|-
| [[#JMP|JMP]] || [[#JNC|JNC]] || [[#JNO|JNO]] || [[#JNP|JNP]] || [[#JNS|JNS]] || [[#JNZ|JNZ]] || [[#JO|JO]] || [[#JP|JP]] || [[#JS|JS]] || [[#JZ|JZ]] || [[#LAHF|LAHF]]
|-
| [[#LDS|LDS]] || [[#LEA|LEA]] || [[#LEAVE|LEAVE]] || [[#LES|LES]] || [[#LOCK|LOCK]] || [[#LODSB|LODSB]] || [[#LODSW|LODSW]] || [[#LOOP|LOOP]] || [[#LOOPE|LOOPE]] || [[#LOOPNE|LOOPNE]] || [[#MOV|MOV]]
|-
| [[#MOVSB|MOVSB]] || [[#MOVSW|MOVSW]] || [[#MUL|MUL]] || [[#NEG|NEG]] || [[#NOP|NOP]] || [[#NOT|NOT]] || [[#OR|OR]] || [[#OUT|OUT]] || [[#OUTSB|OUTSB]] || [[#OUTSW|OUTSW]] || [[#POLL|POLL]]
|-
| [[#POP|POP]] || [[#POPA|POPA]] || [[#POPF|POPF]] || [[#PUSH|PUSH]] || [[#PUSHA|PUSHA]] || [[#PUSHF|PUSHF]] || [[#RCL|RCL]] || [[#RCR|RCR]] || [[#REP|REP]] || [[#REPNE|REPNE]] || [[#RET|RET]]
|-
| [[#RETF|RETF]] || [[#ROL|ROL]] || [[#ROR|ROR]] || [[#SAHF|SAHF]] || [[#SAR|SAR]] || [[#SBB|SBB]] || [[#SCASB|SCASB]] || [[#SCASW|SCASW]] || [[#SHL|SHL]] || [[#SHR|SHR]] || [[#SS|SS]]
|-
| [[#STC|STC]] || [[#STD|STD]] || [[#STI|STI]] || [[#STOSB|STOSB]] || [[#STOSW|STOSW]] || [[#SUB|SUB]] || [[#TEST|TEST]] || [[#XCHG|XCHG]] || [[#XLAT|XLAT]] || [[#XOR|XOR]]
|}
{| class="mw-collapsible mw-collapsed wikitable sortable" style="width: 340px;"
|+ style="white-space:nowrap; border:1px solid; padding:3px; border-color:rgb(162, 169, 177); background-color:rgb(234, 236, 240);" | Intel <-> NEC mnemonic translation table
!Intel
!NEC
|-
| [[#AAA|AAA]]
| [[#AAA|ADJBA]]
|-
| [[#AAD|AAD]]
| [[#AAD|CVTDB]]
|-
| [[#AAM|AAM]]
| [[#AAM|CVTBD]]
|-
| [[#AAS|AAS]]
| [[#AAS|ADJBS]]
|-
| [[#ADC|ADC]]
| [[#ADC|ADDC]]
|-
| [[#ADD|ADD]]
| [[#ADD|ADD]]
|-
| [[#AND|AND]]
| [[#AND|AND]]
|-
| [[#BOUND|BOUND]]
| [[#BOUND|CHKIND]]
|-
| [[#CALL|CALL]]
| [[#CALL|CALL]]
|-
| [[#CBW|CBW]]
| [[#CBW|CVTBW]]
|-
| [[#CLC|CLC]]
| [[#CLC|CLR1 CY]]
|-
| [[#CLD|CLD]]
| [[#CLD|CLR1 DIR]]
|-
| [[#CLI|CLI]]
| [[#CLI|DI]]
|-
| [[#CMC|CMC]]
| [[#CMC|NOT1 CY]]
|-
| [[#CMP|CMP]]
| [[#CMP|CMP]]
|-
| [[#CMPSB|CMPSB]]
| [[#CMPSB|CMPBKB]]
|-
| [[#CMPSW|CMPSW]]
| [[#CMPSW|CMPBKW]]
|-
| [[#CS|CS]]
| [[#CS|PS]]
|-
| [[#CWD|CWD]]
| [[#CWD|CVTWL]]
|-
| [[#DAA|DAA]]
| [[#DAA|ADJ4A]]
|-
| [[#DAS|DAS]]
| [[#DAS|ADJ4S]]
|-
| [[#DEC|DEC]]
| [[#DEC|DEC]]
|-
| [[#DIV|DIV]]
| [[#DIV|DIVU]]
|-
| [[#DS|DS]]
| [[#DS|DS0]]
|-
| [[#ENTER|ENTER]]
| [[#ENTER|PREPARE]]
|-
| [[#ES|ES]]
| [[#ES|DS1]]
|-
| [[#HLT|HLT]]
| [[#HLT|HALT]]
|-
| [[#IDIV|IDIV]]
| [[#IDIV|DIV]]
|-
| [[#IMUL|IMUL]]
| [[#IMUL|MUL]]
|-
| [[#IN|IN]]
| [[#IN|IN]]
|-
| [[#INC|INC]]
| [[#INC|INC]]
|-
| [[#INSB|INSB]]
| [[#INSB|INMB]]
|-
| [[#INSW|INSW]]
| [[#INSW|INMW]]
|-
| [[#INT|INT]]
| [[#INT|BRK]]
|-
| [[#INTO|INTO]]
| [[#INTO|BRKV]]
|-
| [[#IRET|IRET]]
| [[#IRET|RETI]]
|-
| [[#JA|JA]]
| [[#JA|BH]]
|-
| [[#JBE|JBE]]
| [[#JBE|BNH]]
|-
| [[#JC|JC/JB]]
| [[#JC|BC/BL]]
|-
| [[#JCXZ|JCXZ]]
| [[#JCXZ|BCWZ]]
|-
| [[#JG|JG]]
| [[#JG|BGT]]
|-
| [[#JGE|JGE]]
| [[#JGE|BGE]]
|-
| [[#JL|JL]]
| [[#JL|BLT]]
|-
| [[#JLE|JLE]]
| [[#JLE|BLE]]
|-
| [[#JMP|JMP]]
| [[#JMP|BR]]
|-
| [[#JNC|JNC/JAE]]
| [[#JNC|BNC/BNL]]
|-
| [[#JNO|JNO]]
| [[#JNO|BNV]]
|-
| [[#JNP|JNP]]
| [[#JNP|BPO]]
|-
| [[#JNS|JNS]]
| [[#JNS|BP]]
|-
| [[#JNZ|JNZ/JNE]]
| [[#JNZ|BNZ/BNE]]
|-
| [[#JO|JO]]
| [[#JO|BV]]
|-
| [[#JP|JP]]
| [[#JP|BPE]]
|-
| [[#JS|JS]]
| [[#JS|BN]]
|-
| [[#JZ|JZ/JE]]
| [[#JZ|BZ/BE]]
|-
| [[#LAHF|LAHF]]
| [[#LAHF|MOV]]
|-
| [[#LDS|LDS]]
| [[#LDS|MOV]]
|-
| [[#LEA|LEA]]
| [[#LEA|LDEA]]
|-
| [[#LEAVE|LEAVE]]
| [[#LEAVE|DISPOSE]]
|-
| [[#LES|LES]]
| [[#LES|MOV]]
|-
| [[#LOCK|LOCK]]
| [[#LOCK|BUSLOCK]]
|-
| [[#LODSB|LODSB]]
| [[#LODSB|LDMB]]
|-
| [[#LODSW|LODSW]]
| [[#LODSW|LDMW]]
|-
| [[#LOOP|LOOP]]
| [[#LOOP|DBNZ]]
|-
| [[#LOOPE|LOOPE]]
| [[#LOOPE|DBNZE]]
|-
| [[#LOOPNE|LOOPNE]]
| [[#LOOPNE|DBNZNE]]
|-
| [[#MOV|MOV]]
| [[#MOV|MOV]]
|-
| [[#MOVSB|MOVSB]]
| [[#MOVSB|MOVBKB]]
|-
| [[#MOVSW|MOVSW]]
| [[#MOVSW|MOVBKW]]
|-
| [[#MUL|MUL]]
| [[#MUL|MULU]]
|-
| [[#NEG|NEG]]
| [[#NEG|NEG]]
|-
| [[#NOP|NOP]]
| [[#NOP|NOP]]
|-
| [[#NOT|NOT]]
| [[#NOT|NOT]]
|-
| [[#OR|OR]]
| [[#OR|OR]]
|-
| [[#OUT|OUT]]
| [[#OUT|OUT]]
|-
| [[#OUTSB|OUTSB]]
| [[#OUTSB|OUTM]]
|-
| [[#OUTSW|OUTSW]]
| [[#OUTSW|OUTM]]
|-
| [[#POLL|POLL]]
| [[#POLL|POLL]]
|-
| [[#POP|POP]]
| [[#POP|POP]]
|-
| [[#POPA|POPA]]
| [[#POPA|POP]]
|-
| [[#POPF|POPF]]
| [[#POPF|POP]]
|-
| [[#PUSH|PUSH]]
| [[#PUSH|PUSH]]
|-
| [[#PUSHA|PUSHA]]
| [[#PUSHA|PUSH]]
|-
| [[#PUSHF|PUSHF]]
| [[#PUSHF|PUSH]]
|-
| [[#RCL|RCL]]
| [[#RCL|ROLC]]
|-
| [[#RCR|RCR]]
| [[#RCR|RORC]]
|-
| [[#REP|REP/REPE/REPZ]]
| [[#REP|REP/REPE/REPZ]]
|-
| [[#REPNE|REPNE/REPNZ]]
| [[#REPNE|REPNE/REPNZ]]
|-
| [[#RET|RET]]
| [[#RET|RET]]
|-
| [[#RETF|RETF]]
| [[#RETF|RET]]
|-
| [[#ROL|ROL]]
| [[#ROL|ROL]]
|-
| [[#ROR|ROR]]
| [[#ROR|ROR]]
|-
| [[#SAHF|SAHF]]
| [[#SAHF|MOV]]
|-
| [[#SAR|SAR]]
| [[#SAR|SHRA]]
|-
| [[#SBB|SBB]]
| [[#SBB|SUBC]]
|-
| [[#SCASB|SCASB]]
| [[#SCASB|CMPMB]]
|-
| [[#SCASW|SCASW]]
| [[#SCASW|CMPMW]]
|-
| [[#SHL|SHL]]
| [[#SHL|SHL]]
|-
| [[#SHR|SHR]]
| [[#SHR|SHR]]
|-
| [[#SS|SS]]
| [[#SS|SS]]
|-
| [[#STC|STC]]
| [[#STC|SET1 CY]]
|-
| [[#STD|STD]]
| [[#STD|SET1 DIR]]
|-
| [[#STI|STI]]
| [[#STI|EI]]
|-
| [[#STOSB|STOSB]]
| [[#STOSB|STMB]]
|-
| [[#STOSW|STOSW]]
| [[#STOSW|STMW]]
|-
| [[#SUB|SUB]]
| [[#SUB|SUB]]
|-
| [[#TEST|TEST]]
| [[#TEST|TEST]]
|-
| [[#XCHG|XCHG]]
| [[#XCHG|XCH]]
|-
| [[#XLAT|XLAT]]
| [[#XLAT|TRANS]]
|-
| [[#XOR|XOR]]
| [[#XOR|XOR]]
|}
== Official instructions by type ==
{| class="wikitable sortable" style="text-align: center"
!Type
!colspan=16 class="unsortable" | Instructions
|-
| style="text-align:left;" | Memory
| style="" | [[#MOV|MOV]]
| style="" | [[#XCHG|XCHG]]
| style="" | [[#XLAT|XLAT]]
| style="" | [[#LEA|LEA]]
| style="border-right:none;" | [[#LDS|LDS]]
| style="border-left:none;" | [[#LES|LES]]
| style="border-right:none;" | [[#IN|IN]]
| style="border-left:none;" | [[#OUT|OUT]]
| colspan="8" |
|-
| style="text-align:left;" | Ports
| style="border-right:none;" | [[#IN|IN]]
| style="border-left:none;" | [[#OUT|OUT]]
| style="border-right:none;" | [[#INSB|INSB]]
| style="border-left:none;" | [[#OUTSB|OUTSB]]
| style="border-right:none;" | [[#INSW|INSW]]
| style="border-left:none;" | [[#OUTSW|OUTSW]]
| colspan="10" |
|-
| style="text-align:left;" | Arithmetic
| style="border-right:none;" | [[#ADD|ADD]]
| style="border-left:none;" | [[#SUB|SUB]]
| style="border-right:none;" | [[#ADC|ADC]]
| style="border-left:none;" | [[#SBB|SBB]]
| style="border-right:none;" | [[#INC|INC]]
| style="border-left:none;" | [[#DEC|DEC]]
| style="border-right:none;" | [[#MUL|MUL]]
| style="border-left:none;" | [[#DIV|DIV]]
| style="border-right:none;" | [[#IMUL|IMUL]]
| style="border-left:none;" | [[#IDIV|IDIV]]
| style="" | [[#CMP|CMP]]
| style="" | [[#NEG|NEG]]
| colspan="4" |
|-
| style="text-align:left;" | Numeric
| style="" | [[#CBW|CBW]]
| style="" | [[#CWD|CWD]]
| style="" | [[#AAA|AAA]]
| style="" | [[#AAS|AAS]]
| style="" | [[#AAM|AAM]]
| style="" | [[#AAD|AAD]]
| style="" | [[#DAA|DAA]]
| style="" | [[#DAS|DAS]]
| colspan="8" |
|-
| style="text-align:left;" | Shift
| style="border-right:none;" | [[#ROL|ROL]]
| style="border-left:none;" | [[#ROR|ROR]]
| style="border-right:none;" | [[#RCL|RCL]]
| style="border-left:none;" | [[#RCR|RCR]]
| style="border-right:none;" | [[#SHL|SHL]]
| style="border-left:none;" | [[#SHR|SHR]]
| style="" | [[#SAR|SAR]]
| colspan="9" |
|-
| style="text-align:left;" | Bitwise
| style="" | [[#AND|AND]]
| style="" | [[#OR|OR]]
| style="" | [[#XOR|XOR]]
| style="" | [[#NOT|NOT]]
| style="" | [[#TEST|TEST]]
| colspan="11" |
|-
| style="text-align:left;" | Branch
| style="border-right:none;" | [[#JC|JC]]
| style="border-left:none;" | [[#JNC|JNC]]
| style="border-right:none;" | [[#JZ|JZ]]
| style="border-left:none;" | [[#JNZ|JNZ]]
| style="border-right:none;" | [[#JBE|JBE]]
| style="border-left:none;" | [[#JA|JA]]
| style="border-right:none;" | [[#JO|JO]]
| style="border-left:none;" | [[#JNO|JNO]]
| style="border-right:none;" | [[#JP|JP]]
| style="border-left:none;" | [[#JNP|JNP]]
| style="border-right:none;" | [[#JS|JS]]
| style="border-left:none;" | [[#JNS|JNS]]
| style="border-right:none;" | [[#JL|JL]]
| style="border-left:none;" | [[#JGE|JGE]]
| style="border-right:none;" | [[#JLE|JLE]]
| style="border-left:none;" | [[#JG|JG]]
|-
| style="text-align:left;" | Jump
| style="" | [[#JMP|JMP]]
| style="border-right:none;" | [[#CALL|CALL]]
| style="border-left:none;border-right:none;" | [[#RET|RET]]
| style="border-left:none;" | [[#RETF|RETF]]
| colspan="12" |
|-
| style="text-align:left;" | Loop
| style="" | [[#LOOP|LOOP]]
| style="" | [[#LOOPE|LOOPE]]
| style="" | [[#LOOPNE|LOOPNE]]
| colspan="13" |
|-
| style="text-align:left;" | Interrupt
| style="border-right:none;" | [[#INT|INT]]
| style="border-left:none;" | [[#IRET|IRET]]
| style="" | [[#INTO|INTO]]
| style="" | [[#HLT|HLT]]
| style="" | [[#BOUND|BOUND]]
| colspan="11" |
|-
| style="text-align:left;" | Stack
| style="border-right:none;" | [[#PUSH|PUSH]]
| style="border-left:none;" | [[#POP|POP]]
| style="border-right:none;" | [[#PUSHA|PUSHA]]
| style="border-left:none;" | [[#POPA|POPA]]
| style="border-right:none;" | [[#PUSHF|PUSHF]]
| style="border-left:none;" | [[#POPF|POPF]]
| colspan="10" |
|-
| style="text-align:left;" | Flags
| style="border-right:none;" | [[#CLC|CLC]]
| style="border-left:none;" | [[#STC|STC]]
| style="border-right:none;" | [[#CLD|CLD]]
| style="border-left:none;" | [[#STD|STD]]
| style="border-right:none;" | [[#CLI|CLI]]
| style="border-left:none;" | [[#STI|STI]]
| style="" | [[#CMC|CMC]]
| style="border-right:none;" | [[#LAHF|LAHF]]
| style="border-left:none;" | [[#SAHF|SAHF]]
| colspan="7" |
|-
| style="text-align:left;" | Prefix
| style="" | [[#CS|CS]]
| style="" | [[#DS|DS]]
| style="" | [[#ES|ES]]
| style="" | [[#SS|SS]]
| colspan="12" |
|-
| style="text-align:left;" | String
| style="border-right:none;" | [[#REP|REP]]
| style="border-left:none;border-right:none;" | [[#REP|REPE]]
| style="border-left:none;" | [[#REPNE|REPNE]]
| style="" | [[#MOVSB|MOVSB]]
| style="" | [[#MOVSW|MOVSW]]
| style="border-right:none;" | [[#LODSB|LODSB]]
| style="border-left:none;" | [[#STOSB|STOSB]]
| style="border-right:none;" | [[#LODSW|LODSW]]
| style="border-left:none;" | [[#STOSW|STOSW]]
| style="" | [[#CMPSB|CMPSB]]
| style="" | [[#SCASB|SCASB]]
| style="" | [[#CMPSW|CMPSW]]
| style="" | [[#SCASW|SCASW]]
| colspan="3" |
|-
| style="text-align:left;" | Other
| style="" | [[#NOP|NOP]]
| style="border-right:none;" | [[#ENTER|ENTER]]
| style="border-left:none;" | [[#LEAVE|LEAVE]]
| style="" | [[#LOCK|LOCK]]
| style="" | [[#POLL|POLL]]
| colspan="11" |
|}
== Instruction encoding ==
=== ModR/M byte ===
The ModR/M byte is used in most addressing modes which reference a memory location. This byte consists of three bitfield values:
* <tt>oo</tt> - M'''o'''de;
* <tt>rrr</tt> - Two possible functions:
** '''R'''egister (for addressing modes which require both a register and a register/memory operand),
** Opcode extension (for some opcodes' addressing modes which do not have such a requirement);
* <tt>mmm</tt> - Register/'''M'''emory.
The ''Mode'' and ''Register/Memory'' bitfields can refer to a memory location with an optional signed 8-bit (disp8) or 16-bit (disp16) displacement or to a register, as shown in the table below. In some addressing modes, the ''Register'' field also refers to a register; it is always interpreted as if ''Mode'' was equal to <tt>11</tt>.
{| class="wikitable" style="text-align: center"
! R/M \ Mode
! <tt>00</tt>
! <tt>01</tt>
! <tt>10</tt>
! <tt>11</tt> ''(byte)''
! <tt>11</tt> ''(word)''
|-
| <tt>000</tt>
| DS:[BX + SI]
| DS:[BX + SI + disp8]
| DS:[BX + SI + disp16]
| AL
| AX
|-
| <tt>001</tt>
| DS:[BX + DI]
| DS:[BX + DI + disp8]
| DS:[BX + DI + disp16]
| CL
| CX
|-
| <tt>010</tt>
| SS:[BP + SI]
| SS:[BP + SI + disp8]
| SS:[BP + SI + disp16]
| DL
| DX
|-
| <tt>011</tt>
| SS:[BP + DI]
| SS:[BP + DI + disp8]
| SS:[BP + DI + disp16]
| BL
| BX
|-
| <tt>100</tt>
| DS:[SI]
| DS:[SI + disp8]
| DS:[SI + disp16]
| AH
| SP
|-
| <tt>101</tt>
| DS:[DI]
| DS:[DI + disp8]
| DS:[DI + disp16]
| CH
| BP
|-
| <tt>110</tt>
| ''DS:[disp16]''
| SS:[BP + disp8]
| SS:[BP + disp16]
| DH
| SI
|-
| <tt>111</tt>
| DS:[BX]
| DS:[BX + disp8]
| DS:[BX + disp16]
| BH
| DI
|}
Note that (<tt>oo</tt> = <tt>00</tt>, <tt>mmm</tt> = <tt>110</tt>) is a special case.
The instruction encoding lists below refer to this byte as <tt>oorrrmmm</tt> (binary), <tt>/r</tt> (hexadecimal) or <tt>/0</tt> (hexademical, <tt>rrr</tt> used as function <tt>0</tt>).
== Official instructions ==
{{Anchor|AAA}}
=== AAA ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| AAA || <tt>37</tt> || <tt>00110111</tt> || 1 || 9
|}
----
{{Anchor|AAD}}
=== AAD ===
----
{{Anchor|AAM}}
=== AAM ===
----
{{Anchor|AAS}}
=== AAS ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| AAS || <tt>3F</tt> || <tt>00111111</tt> || 1 || 9
|}
----
{{Anchor|ADC}}
=== ADC ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| ADC AL, imm || <tt>14 ii</tt> || <tt>00010100 iiiiiiii</tt> || 2 || 1
|-
| ADC AX, imm || <tt>15 ii ii</tt> || <tt>00010101 iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| ADC mem8, imm8 || <tt>80 /2 ii</tt> || <tt>10000000 oo010mmm iiiiiiii</tt> || 3+ || 3
|-
| ADC mem16, imm16 || <tt>81 /2 ii ii</tt> || <tt>10000001 oo010mmm iiiiiiii iiiiiiii</tt> || 4+ || 3
|-
| ADC mem16, simm8 || <tt>83 /2 ii ii</tt> || <tt>10000011 oo010mmm iiiiiiii iiiiiiii</tt> || 4+ || 3
|-
| ADC mem8, reg8 || <tt>10 /r</tt> || <tt>00010000 oorrrmmm</tt> || 2+ || 3
|-
| ADC mem16, reg16 || <tt>11 /r</tt> || <tt>00010001 oorrrmmm</tt> || 2+ || 3
|-
| ADC reg8, imm8 || <tt>80 /2 ii</tt> || <tt>10000000 11010mmm iiiiiiii</tt> || 3+ || 1
|-
| ADC reg16, imm16 || <tt>81 /2 ii ii</tt> || <tt>10000001 11010mmm iiiiiiii iiiiiiii</tt> || 4+ || 1
|-
| ADC reg16, simm8 || <tt>83 /2 ii ii</tt> || <tt>10000011 11010mmm iiiiiiii iiiiiiii</tt> || 4+ || 1
|-
| ADC reg8, mem8 || <tt>12 /r</tt> || <tt>00010010 oorrrmmm</tt> || 2+ || 2
|-
| ADC reg16, mem16 || <tt>13 /r</tt> || <tt>00010011 oorrrmmm</tt> || 2+ || 2
|-
| ADC reg8, reg8 || <tt>10 /r</tt> || <tt>000100.0 11rrrmmm</tt> || 2 || 1
|-
| ADC reg16, reg16 || <tt>11 /r</tt> || <tt>000100.1 11rrrmmm</tt> || 2 || 1
|}
----
{{Anchor|ADD}}
=== ADD ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| ADD AL, imm || <tt>04 ii</tt> || <tt>00000100 iiiiiiii</tt> || 2 || 1
|-
| ADD AX, imm || <tt>05 ii ii</tt> || <tt>00000101 iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| ADD mem8, imm8 || <tt>80 /0 ii</tt> || <tt>10000000 oo000mmm iiiiiiii</tt> || 3+ || 3
|-
| ADD mem16, imm16 || <tt>81 /0 ii ii</tt> || <tt>10000001 oo000mmm iiiiiiii iiiiiiii</tt> || 4+ || 3
|-
| ADD mem16, simm8 || <tt>83 /0 ii ii</tt> || <tt>10000011 oo000mmm iiiiiiii iiiiiiii</tt> || 4+ || 3
|-
| ADD mem8, reg8 || <tt>00 /r</tt> || <tt>00000000 oorrrmmm</tt> || 2+ || 3
|-
| ADD mem16, reg16 || <tt>01 /r</tt> || <tt>00000001 oorrrmmm</tt> || 2+ || 3
|-
| ADD reg8, imm8 || <tt>80 /0 ii</tt> || <tt>10000000 11000mmm iiiiiiii</tt> || 3+ || 1
|-
| ADD reg16, imm16 || <tt>81 /0 ii ii</tt> || <tt>10000001 11000mmm iiiiiiii iiiiiiii</tt> || 4+ || 1
|-
| ADD reg16, simm8 || <tt>83 /0 ii ii</tt> || <tt>10000011 11000mmm iiiiiiii iiiiiiii</tt> || 4+ || 1
|-
| ADD reg8, mem8 || <tt>02 /r</tt> || <tt>00000010 oorrrmmm</tt> || 2+ || 2
|-
| ADD reg16, mem16 || <tt>03 /r</tt> || <tt>00000011 oorrrmmm</tt> || 2+ || 2
|-
| ADD reg8, reg8 || <tt>00 /r</tt> || <tt>000000.0 11rrrmmm</tt> || 2 || 1
|-
| ADD reg16, reg16 || <tt>01 /r</tt> || <tt>000000.1 11rrrmmm</tt> || 2 || 1
|}
----
{{Anchor|AND}}
=== AND ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| AND AL, imm || <tt>24 ii</tt> || <tt>00100100 iiiiiiii</tt> || 2 || 1
|-
| AND AX, imm || <tt>25 ii ii</tt> || <tt>00100101 iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| AND mem8, imm8 || <tt>80 /4 ii</tt> || <tt>10000000 oo100mmm iiiiiiii</tt> || 3+ || 3
|-
| AND mem16, imm16 || <tt>81 /4 ii ii</tt> || <tt>10000001 oo100mmm iiiiiiii iiiiiiii</tt> || 4+ || 3
|-
| AND mem16, simm8 || <tt>83 /4 ii ii</tt> || <tt>10000011 oo100mmm iiiiiiii iiiiiiii</tt> || 4+ || 3
|-
| AND mem8, reg8 || <tt>20 /r</tt> || <tt>00100000 oorrrmmm</tt> || 2+ || 3
|-
| AND mem16, reg16 || <tt>21 /r</tt> || <tt>00100001 oorrrmmm</tt> || 2+ || 3
|-
| AND reg8, imm8 || <tt>80 /4 ii</tt> || <tt>10000000 11100mmm iiiiiiii</tt> || 3+ || 1
|-
| AND reg16, imm16 || <tt>81 /4 ii ii</tt> || <tt>10000001 11100mmm iiiiiiii iiiiiiii</tt> || 4+ || 1
|-
| AND reg16, simm8 || <tt>83 /4 ii ii</tt> || <tt>10000011 11100mmm iiiiiiii iiiiiiii</tt> || 4+ || 1
|-
| AND reg8, mem8 || <tt>22 /r</tt> || <tt>00100010 oorrrmmm</tt> || 2+ || 2
|-
| AND reg16, mem16 || <tt>23 /r</tt> || <tt>00100011 oorrrmmm</tt> || 2+ || 2
|-
| AND reg8, reg8 || <tt>20 /r</tt> || <tt>001000.0 11rrrmmm</tt> || 2 || 1
|-
| AND reg16, reg16 || <tt>21 /r</tt> || <tt>001000.1 11rrrmmm</tt> || 2 || 1
|}
----
{{Anchor|BOUND}}
=== BOUND ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| BOUND reg16, mem16:16 || <tt>62 /r</tt> || <tt>01100010 oorrrmmm</tt> || 2+ || 13 (20 if condition met)
|}
----
{{Anchor|CALL}}
=== CALL ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| CALL ptr16:16 || <tt>CA oo oo ss ss</tt> || <tt>10011010 oooooooo oooooooo ssssssss ssssssss</tt> || 5 || 10
|-
| CALL mem16 || <tt>FF /2</tt> || <tt>11111111 oo010mmm</tt> || 2+ || 6
|-
| CALL mem16:16 || <tt>FF /3</tt> || <tt>11111111 oo011mmm</tt> || 2+ || 12
|-
| CALL reg16 || <tt>FF /2</tt> || <tt>11111111 11010mmm</tt> || 2 || 5
|-
| CALL rel16 || <tt>E8 ii ii</tt> || <tt>11101000 iiiiiiii iiiiiiii</tt> || 3 || 5
|}
----
{{Anchor|CBW}}
=== CBW ===
----
{{Anchor|CLC}}
=== CLC ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| CLC || <tt>F8</tt> || <tt>11111000</tt> || 1 || 4
|}
----
{{Anchor|CLD}}
=== CLD ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| CLD || <tt>FC</tt> || <tt>11111100</tt> || 1 || 4
|}
----
{{Anchor|CLI}}
=== CLI ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| CLI || <tt>FA</tt> || <tt>11111010</tt> || 1 || 4
|}
----
{{Anchor|CMC}}
=== CMC ===
----
{{Anchor|CMP}}
=== CMP ===
----
{{Anchor|CMPSB}}
=== CMPSB ===
----
{{Anchor|CMPSW}}
=== CMPSW ===
----
{{Anchor|CS}}
=== CS ===
----
{{Anchor|CWD}}
=== CWD ===
----
{{Anchor|DAA}}
=== DAA ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| DAA || <tt>27</tt> || <tt>00100111</tt> || 1 || 10
|}
----
{{Anchor|DAS}}
=== DAS ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| DAS || <tt>2F</tt> || <tt>00101111</tt> || 1 || 10
|}
----
{{Anchor|DEC}}
=== DEC ===
----
{{Anchor|DIV}}
=== DIV ===
----
{{Anchor|DS}}
=== DS ===
----
{{Anchor|ENTER}}
=== ENTER ===
----
{{Anchor|ES}}
=== ES ===
----
{{Anchor|HLT}}
=== HLT ===
----
{{Anchor|IDIV}}
=== IDIV ===
----
{{Anchor|IMUL}}
=== IMUL ===
----
{{Anchor|IN}}
=== IN ===
----
{{Anchor|INC}}
=== INC ===
----
{{Anchor|INSB}}
=== INSB ===
----
{{Anchor|INSW}}
=== INSW ===
----
{{Anchor|INT}}
=== INT ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| INT 3 || <tt>CC</tt> || <tt>11001100</tt> || 1 || 9
|-
| INT imm8 || <tt>CD ii</tt> || <tt>11001101 iiiiiiii</tt> || 2 || 10
|}
----
{{Anchor|INTO}}
=== INTO ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| INTO || <tt>CE</tt> || <tt>11001110</tt> || 1 || 6 (13 if OF = 1)
|}
----
{{Anchor|IRET}}
=== IRET ===
----
{{Anchor|JA}}
=== JA ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JA rel8 || <tt>77 ii</tt> || <tt>01110111 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JBE}}
=== JBE ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JA rel8 || <tt>76 ii</tt> || <tt>01110110 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JC}}
=== JC/JB ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JC rel8 || <tt>72 ii</tt> || <tt>01110010 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JCXZ}}
=== JCXZ ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JCXZ rel8 || <tt>E3 ii</tt> || <tt>11100011 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JG}}
=== JG ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JG rel8 || <tt>7F ii</tt> || <tt>01111111 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JGE}}
=== JGE ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JGE rel8 || <tt>7D ii</tt> || <tt>01111101 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JL}}
=== JL ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JL rel8 || <tt>7C ii</tt> || <tt>01111100 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JLE}}
=== JLE ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JLE rel8 || <tt>7E ii</tt> || <tt>01111110 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JMP}}
=== JMP ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JMP ptr16:16 || <tt>EA oo oo ss ss</tt> || <tt>11101010 oooooooo oooooooo ssssssss ssssssss</tt> || 5 || 7
|-
| JMP mem16 || <tt>FF /4</tt> || <tt>11111111 oo100mmm</tt> || 2+ || 5
|-
| JMP mem16:16 || <tt>FF /5</tt> || <tt>11111111 oo101mmm</tt> || 2+ || 10
|-
| JMP reg16 || <tt>FF /4</tt> || <tt>11111111 11100mmm</tt> || 2 || 4
|-
| JMP rel8 || <tt>EB ii</tt> || <tt>11101011 iiiiiiii</tt> || 2 || 4
|-
| JMP rel16 || <tt>E9 ii ii</tt> || <tt>11101001 iiiiiiii iiiiiiii</tt> || 3 || 4
|}
----
{{Anchor|JNC}}
=== JNC/JAE ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JNC rel8 || <tt>73 ii</tt> || <tt>01110011 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JNO}}
=== JNO ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JNO rel8 || <tt>71 ii</tt> || <tt>01110001 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JNP}}
=== JNP ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JNP rel8 || <tt>7B ii</tt> || <tt>01111011 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JNS}}
=== JNS ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JNS rel8 || <tt>79 ii</tt> || <tt>01111001 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JNZ}}
=== JNZ/JNE ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JNZ rel8 || <tt>75 ii</tt> || <tt>01110101 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JO}}
=== JO ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JO rel8 || <tt>70 ii</tt> || <tt>01110000 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JP}}
=== JP ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JP rel8 || <tt>7A ii</tt> || <tt>01111010 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JS}}
=== JS ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JS rel8 || <tt>78 ii</tt> || <tt>01111000 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JZ}}
=== JZ/JE ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JZ rel8 || <tt>74 ii</tt> || <tt>01110100 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|LAHF}}
=== LAHF ===
----
{{Anchor|LDS}}
=== LDS ===
----
{{Anchor|LEA}}
=== LEA ===
----
{{Anchor|LEAVE}}
=== LEAVE ===
----
{{Anchor|LES}}
=== LES ===
----
{{Anchor|LOCK}}
=== LOCK ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| LOCK || <tt>F0</tt> || <tt>11110000</tt> || 1 || 1
|}
----
{{Anchor|LODSB}}
=== LODSB ===
----
{{Anchor|LODSW}}
=== LODSW ===
----
{{Anchor|LOOP}}
=== LOOP ===
----
{{Anchor|LOOPE}}
=== LOOPE ===
----
{{Anchor|LOOPNE}}
=== LOOPNE ===
----
{{Anchor|MOV}}
=== MOV ===
----
{{Anchor|MOVSB}}
=== MOVSB ===
----
{{Anchor|MOVSW}}
=== MOVSW ===
----
{{Anchor|MUL}}
=== MUL ===
----
{{Anchor|NEG}}
=== NEG ===
----
{{Anchor|NOP}}
=== NOP ===
----
{{Anchor|NOT}}
=== NOT ===
----
{{Anchor|OR}}
=== OR ===
----
{{Anchor|OUT}}
=== OUT ===
----
{{Anchor|OUTSB}}
=== OUTSB ===
----
{{Anchor|OUTSW}}
=== OUTSW ===
----
{{Anchor|POLL}}
=== POLL ===
----
{{Anchor|POP}}
=== POP ===
----
{{Anchor|POPA}}
=== POPA ===
----
{{Anchor|POPF}}
=== POPF ===
----
{{Anchor|PUSH}}
=== PUSH ===
----
{{Anchor|PUSHA}}
=== PUSHA ===
----
{{Anchor|PUSHF}}
=== PUSHF ===
----
{{Anchor|RCL}}
=== RCL ===
----
{{Anchor|RCR}}
=== RCR ===
----
{{Anchor|REP}}
=== REP/REPE/REPZ ===
----
{{Anchor|REPNE}}
=== REPNE/REPNZ ===
----
{{Anchor|RET}}
=== RET ===
----
{{Anchor|RETF}}
=== RETF ===
----
{{Anchor|ROL}}
=== ROL ===
----
{{Anchor|ROR}}
=== ROR ===
----
{{Anchor|SAHF}}
=== SAHF ===
----
{{Anchor|SAR}}
=== SAR ===
----
{{Anchor|SBB}}
=== SBB ===
----
{{Anchor|SCASB}}
=== SCASB ===
----
{{Anchor|SCASW}}
=== SCASW ===
----
{{Anchor|SHL}}
=== SHL ===
----
{{Anchor|SHR}}
=== SHR ===
----
{{Anchor|SS}}
=== SS ===
----
{{Anchor|STC}}
=== STC ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| STC || <tt>F9</tt> || <tt>11111001</tt> || 1 || 4
|}
----
{{Anchor|STD}}
=== STD ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| STD || <tt>FD</tt> || <tt>11111101</tt> || 1 || 4
|}
----
{{Anchor|STI}}
=== STI ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| STI || <tt>FB</tt> || <tt>11111011</tt> || 1 || 4
|}
----
{{Anchor|STOSB}}
=== STOSB ===
----
{{Anchor|STOSW}}
=== STOSW ===
----
{{Anchor|SUB}}
=== SUB ===
----
{{Anchor|TEST}}
=== TEST ===
----
{{Anchor|XCHG}}
=== XCHG ===
----
{{Anchor|XLAT}}
=== XLAT ===
----
{{Anchor|XOR}}
=== XOR ===
----
80d7ac67480ef1d9f565e4bd04fff27da73e7d8b
447
446
2024-12-26T19:40:50Z
Asie
351
wikitext
text/x-wiki
__NOTOC__
Note that this page is a work in progress.
{| class="wikitable" style="text-align: center"
|+ Official V30MZ (80186) Instructions
|-
| [[#AAA|AAA]] || [[#AAD|AAD]] || [[#AAM|AAM]] || [[#AAS|AAS]] || [[#ADC|ADC]] || [[#ADD|ADD]] || [[#AND|AND]] || [[#BOUND|BOUND]] || [[#CALL|CALL]] || [[#CBW|CBW]] || [[#CLC|CLC]]
|-
| [[#CLD|CLD]] || [[#CLI|CLI]] || [[#CMC|CMC]] || [[#CMP|CMP]] || [[#CMPSB|CMPSB]] || [[#CMPSW|CMPSW]] || [[#CS|CS]] || [[#CWD|CWD]] || [[#DAA|DAA]] || [[#DAS|DAS]] || [[#DEC|DEC]]
|-
| [[#DIV|DIV]] || [[#DS|DS]] || [[#ENTER|ENTER]] || [[#ES|ES]] || [[#HLT|HLT]] || [[#IDIV|IDIV]] || [[#IMUL|IMUL]] || [[#IN|IN]] || [[#INC|INC]] || [[#INSB|INSB]] || [[#INSW|INSW]]
|-
| [[#INT|INT]] || [[#INTO|INTO]] || [[#IRET|IRET]] || [[#JA|JA]] || [[#JBE|JBE]] || [[#JC|JC]] || [[#JCXZ|JCXZ]] || [[#JG|JG]] || [[#JGE|JGE]] || [[#JL|JL]] || [[#JLE|JLE]]
|-
| [[#JMP|JMP]] || [[#JNC|JNC]] || [[#JNO|JNO]] || [[#JNP|JNP]] || [[#JNS|JNS]] || [[#JNZ|JNZ]] || [[#JO|JO]] || [[#JP|JP]] || [[#JS|JS]] || [[#JZ|JZ]] || [[#LAHF|LAHF]]
|-
| [[#LDS|LDS]] || [[#LEA|LEA]] || [[#LEAVE|LEAVE]] || [[#LES|LES]] || [[#LOCK|LOCK]] || [[#LODSB|LODSB]] || [[#LODSW|LODSW]] || [[#LOOP|LOOP]] || [[#LOOPE|LOOPE]] || [[#LOOPNE|LOOPNE]] || [[#MOV|MOV]]
|-
| [[#MOVSB|MOVSB]] || [[#MOVSW|MOVSW]] || [[#MUL|MUL]] || [[#NEG|NEG]] || [[#NOP|NOP]] || [[#NOT|NOT]] || [[#OR|OR]] || [[#OUT|OUT]] || [[#OUTSB|OUTSB]] || [[#OUTSW|OUTSW]] || [[#POLL|POLL]]
|-
| [[#POP|POP]] || [[#POPA|POPA]] || [[#POPF|POPF]] || [[#PUSH|PUSH]] || [[#PUSHA|PUSHA]] || [[#PUSHF|PUSHF]] || [[#RCL|RCL]] || [[#RCR|RCR]] || [[#REP|REP]] || [[#REPNE|REPNE]] || [[#RET|RET]]
|-
| [[#RETF|RETF]] || [[#ROL|ROL]] || [[#ROR|ROR]] || [[#SAHF|SAHF]] || [[#SAR|SAR]] || [[#SBB|SBB]] || [[#SCASB|SCASB]] || [[#SCASW|SCASW]] || [[#SHL|SHL]] || [[#SHR|SHR]] || [[#SS|SS]]
|-
| [[#STC|STC]] || [[#STD|STD]] || [[#STI|STI]] || [[#STOSB|STOSB]] || [[#STOSW|STOSW]] || [[#SUB|SUB]] || [[#TEST|TEST]] || [[#XCHG|XCHG]] || [[#XLAT|XLAT]] || [[#XOR|XOR]]
|}
{| class="mw-collapsible mw-collapsed wikitable sortable" style="width: 340px;"
|+ style="white-space:nowrap; border:1px solid; padding:3px; border-color:rgb(162, 169, 177); background-color:rgb(234, 236, 240);" | Intel <-> NEC mnemonic translation table
!Intel
!NEC
|-
| [[#AAA|AAA]]
| [[#AAA|ADJBA]]
|-
| [[#AAD|AAD]]
| [[#AAD|CVTDB]]
|-
| [[#AAM|AAM]]
| [[#AAM|CVTBD]]
|-
| [[#AAS|AAS]]
| [[#AAS|ADJBS]]
|-
| [[#ADC|ADC]]
| [[#ADC|ADDC]]
|-
| [[#ADD|ADD]]
| [[#ADD|ADD]]
|-
| [[#AND|AND]]
| [[#AND|AND]]
|-
| [[#BOUND|BOUND]]
| [[#BOUND|CHKIND]]
|-
| [[#CALL|CALL]]
| [[#CALL|CALL]]
|-
| [[#CBW|CBW]]
| [[#CBW|CVTBW]]
|-
| [[#CLC|CLC]]
| [[#CLC|CLR1 CY]]
|-
| [[#CLD|CLD]]
| [[#CLD|CLR1 DIR]]
|-
| [[#CLI|CLI]]
| [[#CLI|DI]]
|-
| [[#CMC|CMC]]
| [[#CMC|NOT1 CY]]
|-
| [[#CMP|CMP]]
| [[#CMP|CMP]]
|-
| [[#CMPSB|CMPSB]]
| [[#CMPSB|CMPBKB]]
|-
| [[#CMPSW|CMPSW]]
| [[#CMPSW|CMPBKW]]
|-
| [[#CS|CS]]
| [[#CS|PS]]
|-
| [[#CWD|CWD]]
| [[#CWD|CVTWL]]
|-
| [[#DAA|DAA]]
| [[#DAA|ADJ4A]]
|-
| [[#DAS|DAS]]
| [[#DAS|ADJ4S]]
|-
| [[#DEC|DEC]]
| [[#DEC|DEC]]
|-
| [[#DIV|DIV]]
| [[#DIV|DIVU]]
|-
| [[#DS|DS]]
| [[#DS|DS0]]
|-
| [[#ENTER|ENTER]]
| [[#ENTER|PREPARE]]
|-
| [[#ES|ES]]
| [[#ES|DS1]]
|-
| [[#HLT|HLT]]
| [[#HLT|HALT]]
|-
| [[#IDIV|IDIV]]
| [[#IDIV|DIV]]
|-
| [[#IMUL|IMUL]]
| [[#IMUL|MUL]]
|-
| [[#IN|IN]]
| [[#IN|IN]]
|-
| [[#INC|INC]]
| [[#INC|INC]]
|-
| [[#INSB|INSB]]
| [[#INSB|INMB]]
|-
| [[#INSW|INSW]]
| [[#INSW|INMW]]
|-
| [[#INT|INT]]
| [[#INT|BRK]]
|-
| [[#INTO|INTO]]
| [[#INTO|BRKV]]
|-
| [[#IRET|IRET]]
| [[#IRET|RETI]]
|-
| [[#JA|JA]]
| [[#JA|BH]]
|-
| [[#JBE|JBE]]
| [[#JBE|BNH]]
|-
| [[#JC|JC/JB]]
| [[#JC|BC/BL]]
|-
| [[#JCXZ|JCXZ]]
| [[#JCXZ|BCWZ]]
|-
| [[#JG|JG]]
| [[#JG|BGT]]
|-
| [[#JGE|JGE]]
| [[#JGE|BGE]]
|-
| [[#JL|JL]]
| [[#JL|BLT]]
|-
| [[#JLE|JLE]]
| [[#JLE|BLE]]
|-
| [[#JMP|JMP]]
| [[#JMP|BR]]
|-
| [[#JNC|JNC/JAE]]
| [[#JNC|BNC/BNL]]
|-
| [[#JNO|JNO]]
| [[#JNO|BNV]]
|-
| [[#JNP|JNP]]
| [[#JNP|BPO]]
|-
| [[#JNS|JNS]]
| [[#JNS|BP]]
|-
| [[#JNZ|JNZ/JNE]]
| [[#JNZ|BNZ/BNE]]
|-
| [[#JO|JO]]
| [[#JO|BV]]
|-
| [[#JP|JP]]
| [[#JP|BPE]]
|-
| [[#JS|JS]]
| [[#JS|BN]]
|-
| [[#JZ|JZ/JE]]
| [[#JZ|BZ/BE]]
|-
| [[#LAHF|LAHF]]
| [[#LAHF|MOV]]
|-
| [[#LDS|LDS]]
| [[#LDS|MOV]]
|-
| [[#LEA|LEA]]
| [[#LEA|LDEA]]
|-
| [[#LEAVE|LEAVE]]
| [[#LEAVE|DISPOSE]]
|-
| [[#LES|LES]]
| [[#LES|MOV]]
|-
| [[#LOCK|LOCK]]
| [[#LOCK|BUSLOCK]]
|-
| [[#LODSB|LODSB]]
| [[#LODSB|LDMB]]
|-
| [[#LODSW|LODSW]]
| [[#LODSW|LDMW]]
|-
| [[#LOOP|LOOP]]
| [[#LOOP|DBNZ]]
|-
| [[#LOOPE|LOOPE]]
| [[#LOOPE|DBNZE]]
|-
| [[#LOOPNE|LOOPNE]]
| [[#LOOPNE|DBNZNE]]
|-
| [[#MOV|MOV]]
| [[#MOV|MOV]]
|-
| [[#MOVSB|MOVSB]]
| [[#MOVSB|MOVBKB]]
|-
| [[#MOVSW|MOVSW]]
| [[#MOVSW|MOVBKW]]
|-
| [[#MUL|MUL]]
| [[#MUL|MULU]]
|-
| [[#NEG|NEG]]
| [[#NEG|NEG]]
|-
| [[#NOP|NOP]]
| [[#NOP|NOP]]
|-
| [[#NOT|NOT]]
| [[#NOT|NOT]]
|-
| [[#OR|OR]]
| [[#OR|OR]]
|-
| [[#OUT|OUT]]
| [[#OUT|OUT]]
|-
| [[#OUTSB|OUTSB]]
| [[#OUTSB|OUTM]]
|-
| [[#OUTSW|OUTSW]]
| [[#OUTSW|OUTM]]
|-
| [[#POLL|POLL]]
| [[#POLL|POLL]]
|-
| [[#POP|POP]]
| [[#POP|POP]]
|-
| [[#POPA|POPA]]
| [[#POPA|POP]]
|-
| [[#POPF|POPF]]
| [[#POPF|POP]]
|-
| [[#PUSH|PUSH]]
| [[#PUSH|PUSH]]
|-
| [[#PUSHA|PUSHA]]
| [[#PUSHA|PUSH]]
|-
| [[#PUSHF|PUSHF]]
| [[#PUSHF|PUSH]]
|-
| [[#RCL|RCL]]
| [[#RCL|ROLC]]
|-
| [[#RCR|RCR]]
| [[#RCR|RORC]]
|-
| [[#REP|REP/REPE/REPZ]]
| [[#REP|REP/REPE/REPZ]]
|-
| [[#REPNE|REPNE/REPNZ]]
| [[#REPNE|REPNE/REPNZ]]
|-
| [[#RET|RET]]
| [[#RET|RET]]
|-
| [[#RETF|RETF]]
| [[#RETF|RET]]
|-
| [[#ROL|ROL]]
| [[#ROL|ROL]]
|-
| [[#ROR|ROR]]
| [[#ROR|ROR]]
|-
| [[#SAHF|SAHF]]
| [[#SAHF|MOV]]
|-
| [[#SAR|SAR]]
| [[#SAR|SHRA]]
|-
| [[#SBB|SBB]]
| [[#SBB|SUBC]]
|-
| [[#SCASB|SCASB]]
| [[#SCASB|CMPMB]]
|-
| [[#SCASW|SCASW]]
| [[#SCASW|CMPMW]]
|-
| [[#SHL|SHL]]
| [[#SHL|SHL]]
|-
| [[#SHR|SHR]]
| [[#SHR|SHR]]
|-
| [[#SS|SS]]
| [[#SS|SS]]
|-
| [[#STC|STC]]
| [[#STC|SET1 CY]]
|-
| [[#STD|STD]]
| [[#STD|SET1 DIR]]
|-
| [[#STI|STI]]
| [[#STI|EI]]
|-
| [[#STOSB|STOSB]]
| [[#STOSB|STMB]]
|-
| [[#STOSW|STOSW]]
| [[#STOSW|STMW]]
|-
| [[#SUB|SUB]]
| [[#SUB|SUB]]
|-
| [[#TEST|TEST]]
| [[#TEST|TEST]]
|-
| [[#XCHG|XCHG]]
| [[#XCHG|XCH]]
|-
| [[#XLAT|XLAT]]
| [[#XLAT|TRANS]]
|-
| [[#XOR|XOR]]
| [[#XOR|XOR]]
|}
== Official instructions by type ==
{| class="wikitable sortable" style="text-align: center"
!Type
!colspan=16 class="unsortable" | Instructions
|-
| style="text-align:left;" | Memory
| style="" | [[#MOV|MOV]]
| style="" | [[#XCHG|XCHG]]
| style="" | [[#XLAT|XLAT]]
| style="" | [[#LEA|LEA]]
| style="border-right:none;" | [[#LDS|LDS]]
| style="border-left:none;" | [[#LES|LES]]
| style="border-right:none;" | [[#IN|IN]]
| style="border-left:none;" | [[#OUT|OUT]]
| colspan="8" |
|-
| style="text-align:left;" | Ports
| style="border-right:none;" | [[#IN|IN]]
| style="border-left:none;" | [[#OUT|OUT]]
| style="border-right:none;" | [[#INSB|INSB]]
| style="border-left:none;" | [[#OUTSB|OUTSB]]
| style="border-right:none;" | [[#INSW|INSW]]
| style="border-left:none;" | [[#OUTSW|OUTSW]]
| colspan="10" |
|-
| style="text-align:left;" | Arithmetic
| style="border-right:none;" | [[#ADD|ADD]]
| style="border-left:none;" | [[#SUB|SUB]]
| style="border-right:none;" | [[#ADC|ADC]]
| style="border-left:none;" | [[#SBB|SBB]]
| style="border-right:none;" | [[#INC|INC]]
| style="border-left:none;" | [[#DEC|DEC]]
| style="border-right:none;" | [[#MUL|MUL]]
| style="border-left:none;" | [[#DIV|DIV]]
| style="border-right:none;" | [[#IMUL|IMUL]]
| style="border-left:none;" | [[#IDIV|IDIV]]
| style="" | [[#CMP|CMP]]
| style="" | [[#NEG|NEG]]
| colspan="4" |
|-
| style="text-align:left;" | Numeric
| style="" | [[#CBW|CBW]]
| style="" | [[#CWD|CWD]]
| style="" | [[#AAA|AAA]]
| style="" | [[#AAS|AAS]]
| style="" | [[#AAM|AAM]]
| style="" | [[#AAD|AAD]]
| style="" | [[#DAA|DAA]]
| style="" | [[#DAS|DAS]]
| colspan="8" |
|-
| style="text-align:left;" | Shift
| style="border-right:none;" | [[#ROL|ROL]]
| style="border-left:none;" | [[#ROR|ROR]]
| style="border-right:none;" | [[#RCL|RCL]]
| style="border-left:none;" | [[#RCR|RCR]]
| style="border-right:none;" | [[#SHL|SHL]]
| style="border-left:none;" | [[#SHR|SHR]]
| style="" | [[#SAR|SAR]]
| colspan="9" |
|-
| style="text-align:left;" | Bitwise
| style="" | [[#AND|AND]]
| style="" | [[#OR|OR]]
| style="" | [[#XOR|XOR]]
| style="" | [[#NOT|NOT]]
| style="" | [[#TEST|TEST]]
| colspan="11" |
|-
| style="text-align:left;" | Branch
| style="border-right:none;" | [[#JC|JC]]
| style="border-left:none;" | [[#JNC|JNC]]
| style="border-right:none;" | [[#JZ|JZ]]
| style="border-left:none;" | [[#JNZ|JNZ]]
| style="border-right:none;" | [[#JBE|JBE]]
| style="border-left:none;" | [[#JA|JA]]
| style="border-right:none;" | [[#JO|JO]]
| style="border-left:none;" | [[#JNO|JNO]]
| style="border-right:none;" | [[#JP|JP]]
| style="border-left:none;" | [[#JNP|JNP]]
| style="border-right:none;" | [[#JS|JS]]
| style="border-left:none;" | [[#JNS|JNS]]
| style="border-right:none;" | [[#JL|JL]]
| style="border-left:none;" | [[#JGE|JGE]]
| style="border-right:none;" | [[#JLE|JLE]]
| style="border-left:none;" | [[#JG|JG]]
|-
| style="text-align:left;" | Jump
| style="" | [[#JMP|JMP]]
| style="border-right:none;" | [[#CALL|CALL]]
| style="border-left:none;border-right:none;" | [[#RET|RET]]
| style="border-left:none;" | [[#RETF|RETF]]
| colspan="12" |
|-
| style="text-align:left;" | Loop
| style="" | [[#LOOP|LOOP]]
| style="" | [[#LOOPE|LOOPE]]
| style="" | [[#LOOPNE|LOOPNE]]
| colspan="13" |
|-
| style="text-align:left;" | Interrupt
| style="border-right:none;" | [[#INT|INT]]
| style="border-left:none;" | [[#IRET|IRET]]
| style="" | [[#INTO|INTO]]
| style="" | [[#HLT|HLT]]
| style="" | [[#BOUND|BOUND]]
| colspan="11" |
|-
| style="text-align:left;" | Stack
| style="border-right:none;" | [[#PUSH|PUSH]]
| style="border-left:none;" | [[#POP|POP]]
| style="border-right:none;" | [[#PUSHA|PUSHA]]
| style="border-left:none;" | [[#POPA|POPA]]
| style="border-right:none;" | [[#PUSHF|PUSHF]]
| style="border-left:none;" | [[#POPF|POPF]]
| colspan="10" |
|-
| style="text-align:left;" | Flags
| style="border-right:none;" | [[#CLC|CLC]]
| style="border-left:none;" | [[#STC|STC]]
| style="border-right:none;" | [[#CLD|CLD]]
| style="border-left:none;" | [[#STD|STD]]
| style="border-right:none;" | [[#CLI|CLI]]
| style="border-left:none;" | [[#STI|STI]]
| style="" | [[#CMC|CMC]]
| style="border-right:none;" | [[#LAHF|LAHF]]
| style="border-left:none;" | [[#SAHF|SAHF]]
| colspan="7" |
|-
| style="text-align:left;" | Prefix
| style="" | [[#CS|CS]]
| style="" | [[#DS|DS]]
| style="" | [[#ES|ES]]
| style="" | [[#SS|SS]]
| colspan="12" |
|-
| style="text-align:left;" | String
| style="border-right:none;" | [[#REP|REP]]
| style="border-left:none;border-right:none;" | [[#REP|REPE]]
| style="border-left:none;" | [[#REPNE|REPNE]]
| style="" | [[#MOVSB|MOVSB]]
| style="" | [[#MOVSW|MOVSW]]
| style="border-right:none;" | [[#LODSB|LODSB]]
| style="border-left:none;" | [[#STOSB|STOSB]]
| style="border-right:none;" | [[#LODSW|LODSW]]
| style="border-left:none;" | [[#STOSW|STOSW]]
| style="" | [[#CMPSB|CMPSB]]
| style="" | [[#SCASB|SCASB]]
| style="" | [[#CMPSW|CMPSW]]
| style="" | [[#SCASW|SCASW]]
| colspan="3" |
|-
| style="text-align:left;" | Other
| style="" | [[#NOP|NOP]]
| style="border-right:none;" | [[#ENTER|ENTER]]
| style="border-left:none;" | [[#LEAVE|LEAVE]]
| style="" | [[#LOCK|LOCK]]
| style="" | [[#POLL|POLL]]
| colspan="11" |
|}
== Instruction encoding ==
=== ModR/M byte ===
The ModR/M byte is used in most addressing modes which reference a memory location. This byte consists of three bitfield values:
* <tt>oo</tt> - M'''o'''de;
* <tt>rrr</tt> - Two possible functions:
** '''R'''egister (for addressing modes which require both a register and a register/memory operand),
** Opcode extension (for some opcodes' addressing modes which do not have such a requirement);
* <tt>mmm</tt> - Register/'''M'''emory.
The ''Mode'' and ''Register/Memory'' bitfields can refer to a memory location with an optional signed 8-bit (disp8) or 16-bit (disp16) displacement or to a register, as shown in the table below. In some addressing modes, the ''Register'' field also refers to a register; it is always interpreted as if ''Mode'' was equal to <tt>11</tt>.
{| class="wikitable" style="text-align: center"
! R/M \ Mode
! <tt>00</tt>
! <tt>01</tt>
! <tt>10</tt>
! <tt>11</tt> ''(byte)''
! <tt>11</tt> ''(word)''
|-
| <tt>000</tt>
| DS:[BX + SI]
| DS:[BX + SI + disp8]
| DS:[BX + SI + disp16]
| AL
| AX
|-
| <tt>001</tt>
| DS:[BX + DI]
| DS:[BX + DI + disp8]
| DS:[BX + DI + disp16]
| CL
| CX
|-
| <tt>010</tt>
| SS:[BP + SI]
| SS:[BP + SI + disp8]
| SS:[BP + SI + disp16]
| DL
| DX
|-
| <tt>011</tt>
| SS:[BP + DI]
| SS:[BP + DI + disp8]
| SS:[BP + DI + disp16]
| BL
| BX
|-
| <tt>100</tt>
| DS:[SI]
| DS:[SI + disp8]
| DS:[SI + disp16]
| AH
| SP
|-
| <tt>101</tt>
| DS:[DI]
| DS:[DI + disp8]
| DS:[DI + disp16]
| CH
| BP
|-
| <tt>110</tt>
| ''DS:[disp16]''
| SS:[BP + disp8]
| SS:[BP + disp16]
| DH
| SI
|-
| <tt>111</tt>
| DS:[BX]
| DS:[BX + disp8]
| DS:[BX + disp16]
| BH
| DI
|}
Note that (<tt>oo</tt> = <tt>00</tt>, <tt>mmm</tt> = <tt>110</tt>) is a special case.
The instruction encoding lists below refer to this byte as <tt>oorrrmmm</tt> (binary), <tt>/r</tt> (hexadecimal) or <tt>/0</tt> (hexademical, <tt>rrr</tt> used as function <tt>0</tt>).
== Official instructions ==
{{Anchor|AAA}}
=== AAA ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| AAA || <tt>37</tt> || <tt>00110111</tt> || 1 || 9
|}
----
{{Anchor|AAD}}
=== AAD ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| AAD imm8 || <tt>B5 ii</tt> || <tt>11010100 iiiiiiii</tt> || 2 || 6
|}
----
{{Anchor|AAM}}
=== AAM ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| AAM imm8 || <tt>B4 ii</tt> || <tt>11010100 iiiiiiii</tt> || 2 || 17
|}
----
{{Anchor|AAS}}
=== AAS ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| AAS || <tt>3F</tt> || <tt>00111111</tt> || 1 || 9
|}
----
{{Anchor|ADC}}
=== ADC ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| ADC AL, imm || <tt>14 ii</tt> || <tt>00010100 iiiiiiii</tt> || 2 || 1
|-
| ADC AX, imm || <tt>15 ii ii</tt> || <tt>00010101 iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| ADC mem8, imm8 || <tt>80 /2 ii</tt> || <tt>10000000 oo010mmm iiiiiiii</tt> || 3+ || 3
|-
| ADC mem16, imm16 || <tt>81 /2 ii ii</tt> || <tt>10000001 oo010mmm iiiiiiii iiiiiiii</tt> || 4+ || 3
|-
| ADC mem16, simm8 || <tt>83 /2 ii ii</tt> || <tt>10000011 oo010mmm iiiiiiii iiiiiiii</tt> || 4+ || 3
|-
| ADC mem8, reg8 || <tt>10 /r</tt> || <tt>00010000 oorrrmmm</tt> || 2+ || 3
|-
| ADC mem16, reg16 || <tt>11 /r</tt> || <tt>00010001 oorrrmmm</tt> || 2+ || 3
|-
| ADC reg8, imm8 || <tt>80 /2 ii</tt> || <tt>10000000 11010mmm iiiiiiii</tt> || 3+ || 1
|-
| ADC reg16, imm16 || <tt>81 /2 ii ii</tt> || <tt>10000001 11010mmm iiiiiiii iiiiiiii</tt> || 4+ || 1
|-
| ADC reg16, simm8 || <tt>83 /2 ii ii</tt> || <tt>10000011 11010mmm iiiiiiii iiiiiiii</tt> || 4+ || 1
|-
| ADC reg8, mem8 || <tt>12 /r</tt> || <tt>00010010 oorrrmmm</tt> || 2+ || 2
|-
| ADC reg16, mem16 || <tt>13 /r</tt> || <tt>00010011 oorrrmmm</tt> || 2+ || 2
|-
| ADC reg8, reg8 || <tt>10 /r</tt> || <tt>000100.0 11rrrmmm</tt> || 2 || 1
|-
| ADC reg16, reg16 || <tt>11 /r</tt> || <tt>000100.1 11rrrmmm</tt> || 2 || 1
|}
----
{{Anchor|ADD}}
=== ADD ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| ADD AL, imm || <tt>04 ii</tt> || <tt>00000100 iiiiiiii</tt> || 2 || 1
|-
| ADD AX, imm || <tt>05 ii ii</tt> || <tt>00000101 iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| ADD mem8, imm8 || <tt>80 /0 ii</tt> || <tt>10000000 oo000mmm iiiiiiii</tt> || 3+ || 3
|-
| ADD mem16, imm16 || <tt>81 /0 ii ii</tt> || <tt>10000001 oo000mmm iiiiiiii iiiiiiii</tt> || 4+ || 3
|-
| ADD mem16, simm8 || <tt>83 /0 ii ii</tt> || <tt>10000011 oo000mmm iiiiiiii iiiiiiii</tt> || 4+ || 3
|-
| ADD mem8, reg8 || <tt>00 /r</tt> || <tt>00000000 oorrrmmm</tt> || 2+ || 3
|-
| ADD mem16, reg16 || <tt>01 /r</tt> || <tt>00000001 oorrrmmm</tt> || 2+ || 3
|-
| ADD reg8, imm8 || <tt>80 /0 ii</tt> || <tt>10000000 11000mmm iiiiiiii</tt> || 3+ || 1
|-
| ADD reg16, imm16 || <tt>81 /0 ii ii</tt> || <tt>10000001 11000mmm iiiiiiii iiiiiiii</tt> || 4+ || 1
|-
| ADD reg16, simm8 || <tt>83 /0 ii ii</tt> || <tt>10000011 11000mmm iiiiiiii iiiiiiii</tt> || 4+ || 1
|-
| ADD reg8, mem8 || <tt>02 /r</tt> || <tt>00000010 oorrrmmm</tt> || 2+ || 2
|-
| ADD reg16, mem16 || <tt>03 /r</tt> || <tt>00000011 oorrrmmm</tt> || 2+ || 2
|-
| ADD reg8, reg8 || <tt>00 /r</tt> || <tt>000000.0 11rrrmmm</tt> || 2 || 1
|-
| ADD reg16, reg16 || <tt>01 /r</tt> || <tt>000000.1 11rrrmmm</tt> || 2 || 1
|}
----
{{Anchor|AND}}
=== AND ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| AND AL, imm || <tt>24 ii</tt> || <tt>00100100 iiiiiiii</tt> || 2 || 1
|-
| AND AX, imm || <tt>25 ii ii</tt> || <tt>00100101 iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| AND mem8, imm8 || <tt>80 /4 ii</tt> || <tt>10000000 oo100mmm iiiiiiii</tt> || 3+ || 3
|-
| AND mem16, imm16 || <tt>81 /4 ii ii</tt> || <tt>10000001 oo100mmm iiiiiiii iiiiiiii</tt> || 4+ || 3
|-
| AND mem16, simm8 || <tt>83 /4 ii ii</tt> || <tt>10000011 oo100mmm iiiiiiii iiiiiiii</tt> || 4+ || 3
|-
| AND mem8, reg8 || <tt>20 /r</tt> || <tt>00100000 oorrrmmm</tt> || 2+ || 3
|-
| AND mem16, reg16 || <tt>21 /r</tt> || <tt>00100001 oorrrmmm</tt> || 2+ || 3
|-
| AND reg8, imm8 || <tt>80 /4 ii</tt> || <tt>10000000 11100mmm iiiiiiii</tt> || 3+ || 1
|-
| AND reg16, imm16 || <tt>81 /4 ii ii</tt> || <tt>10000001 11100mmm iiiiiiii iiiiiiii</tt> || 4+ || 1
|-
| AND reg16, simm8 || <tt>83 /4 ii ii</tt> || <tt>10000011 11100mmm iiiiiiii iiiiiiii</tt> || 4+ || 1
|-
| AND reg8, mem8 || <tt>22 /r</tt> || <tt>00100010 oorrrmmm</tt> || 2+ || 2
|-
| AND reg16, mem16 || <tt>23 /r</tt> || <tt>00100011 oorrrmmm</tt> || 2+ || 2
|-
| AND reg8, reg8 || <tt>20 /r</tt> || <tt>001000.0 11rrrmmm</tt> || 2 || 1
|-
| AND reg16, reg16 || <tt>21 /r</tt> || <tt>001000.1 11rrrmmm</tt> || 2 || 1
|}
----
{{Anchor|BOUND}}
=== BOUND ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| BOUND reg16, mem16:16 || <tt>62 /r</tt> || <tt>01100010 oorrrmmm</tt> || 2+ || 13 (20 if condition met)
|}
----
{{Anchor|CALL}}
=== CALL ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| CALL ptr16:16 || <tt>CA oo oo ss ss</tt> || <tt>10011010 oooooooo oooooooo ssssssss ssssssss</tt> || 5 || 10
|-
| CALL mem16 || <tt>FF /2</tt> || <tt>11111111 oo010mmm</tt> || 2+ || 6
|-
| CALL mem16:16 || <tt>FF /3</tt> || <tt>11111111 oo011mmm</tt> || 2+ || 12
|-
| CALL reg16 || <tt>FF /2</tt> || <tt>11111111 11010mmm</tt> || 2 || 5
|-
| CALL rel16 || <tt>E8 ii ii</tt> || <tt>11101000 iiiiiiii iiiiiiii</tt> || 3 || 5
|}
----
{{Anchor|CBW}}
=== CBW ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| CBW || <tt>98</tt> || <tt>10011000</tt> || 1 || 1
|}
----
{{Anchor|CLC}}
=== CLC ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| CLC || <tt>F8</tt> || <tt>11111000</tt> || 1 || 4
|}
----
{{Anchor|CLD}}
=== CLD ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| CLD || <tt>FC</tt> || <tt>11111100</tt> || 1 || 4
|}
----
{{Anchor|CLI}}
=== CLI ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| CLI || <tt>FA</tt> || <tt>11111010</tt> || 1 || 4
|}
----
{{Anchor|CMC}}
=== CMC ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| CMC || <tt>F5</tt> || <tt>11110101</tt> || 1 || 4
|}
----
{{Anchor|CMP}}
=== CMP ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| CMP AL, imm || <tt>3C ii</tt> || <tt>00111100 iiiiiiii</tt> || 2 || 1
|-
| CMP AX, imm || <tt>3D ii ii</tt> || <tt>00111101 iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| CMP mem8, imm8 || <tt>80 /7 ii</tt> || <tt>10000000 oo111mmm iiiiiiii</tt> || 3+ || 2
|-
| CMP mem16, imm16 || <tt>81 /7 ii ii</tt> || <tt>10000001 oo111mmm iiiiiiii iiiiiiii</tt> || 4+ || 2
|-
| CMP mem16, simm8 || <tt>83 /7 ii ii</tt> || <tt>10000011 oo111mmm iiiiiiii iiiiiiii</tt> || 4+ || 2
|-
| CMP mem8, reg8 || <tt>38 /r</tt> || <tt>00111000 oorrrmmm</tt> || 2+ || 2
|-
| CMP mem16, reg16 || <tt>39 /r</tt> || <tt>00111001 oorrrmmm</tt> || 2+ || 2
|-
| CMP reg8, imm8 || <tt>80 /7 ii</tt> || <tt>10000000 11111mmm iiiiiiii</tt> || 3+ || 1
|-
| CMP reg16, imm16 || <tt>81 /7 ii ii</tt> || <tt>10000001 11111mmm iiiiiiii iiiiiiii</tt> || 4+ || 1
|-
| CMP reg16, simm8 || <tt>83 /7 ii ii</tt> || <tt>10000011 11111mmm iiiiiiii iiiiiiii</tt> || 4+ || 1
|-
| CMP reg8, mem8 || <tt>3A /r</tt> || <tt>00111010 oorrrmmm</tt> || 2+ || 2
|-
| CMP reg16, mem16 || <tt>3B /r</tt> || <tt>00111011 oorrrmmm</tt> || 2+ || 2
|-
| CMP reg8, reg8 || <tt>38 /r</tt> || <tt>001110.0 11rrrmmm</tt> || 2 || 1
|-
| CMP reg16, reg16 || <tt>39 /r</tt> || <tt>001110.1 11rrrmmm</tt> || 2 || 1
|}
----
{{Anchor|CMPSB}}
=== CMPSB ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| CMPSB || <tt>A6</tt> || <tt>10100110</tt> || 1 || 6
|}
----
{{Anchor|CMPSW}}
=== CMPSW ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| CMPSW || <tt>A7</tt> || <tt>10100111</tt> || 1 || 6
|}
----
{{Anchor|CS}}
=== CS ===
----
{{Anchor|CWD}}
=== CWD ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| CWD || <tt>99</tt> || <tt>10011001</tt> || 1 || 1
|}
----
{{Anchor|DAA}}
=== DAA ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| DAA || <tt>27</tt> || <tt>00100111</tt> || 1 || 10
|}
----
{{Anchor|DAS}}
=== DAS ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| DAS || <tt>2F</tt> || <tt>00101111</tt> || 1 || 10
|}
----
{{Anchor|DEC}}
=== DEC ===
----
{{Anchor|DIV}}
=== DIV ===
----
{{Anchor|DS}}
=== DS ===
----
{{Anchor|ENTER}}
=== ENTER ===
----
{{Anchor|ES}}
=== ES ===
----
{{Anchor|HLT}}
=== HLT ===
----
{{Anchor|IDIV}}
=== IDIV ===
----
{{Anchor|IMUL}}
=== IMUL ===
----
{{Anchor|IN}}
=== IN ===
----
{{Anchor|INC}}
=== INC ===
----
{{Anchor|INSB}}
=== INSB ===
----
{{Anchor|INSW}}
=== INSW ===
----
{{Anchor|INT}}
=== INT ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| INT 3 || <tt>CC</tt> || <tt>11001100</tt> || 1 || 9
|-
| INT imm8 || <tt>CD ii</tt> || <tt>11001101 iiiiiiii</tt> || 2 || 10
|}
----
{{Anchor|INTO}}
=== INTO ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| INTO || <tt>CE</tt> || <tt>11001110</tt> || 1 || 6 (13 if OF = 1)
|}
----
{{Anchor|IRET}}
=== IRET ===
----
{{Anchor|JA}}
=== JA ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JA rel8 || <tt>77 ii</tt> || <tt>01110111 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JBE}}
=== JBE ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JA rel8 || <tt>76 ii</tt> || <tt>01110110 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JC}}
=== JC/JB ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JC rel8 || <tt>72 ii</tt> || <tt>01110010 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JCXZ}}
=== JCXZ ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JCXZ rel8 || <tt>E3 ii</tt> || <tt>11100011 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JG}}
=== JG ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JG rel8 || <tt>7F ii</tt> || <tt>01111111 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JGE}}
=== JGE ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JGE rel8 || <tt>7D ii</tt> || <tt>01111101 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JL}}
=== JL ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JL rel8 || <tt>7C ii</tt> || <tt>01111100 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JLE}}
=== JLE ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JLE rel8 || <tt>7E ii</tt> || <tt>01111110 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JMP}}
=== JMP ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JMP ptr16:16 || <tt>EA oo oo ss ss</tt> || <tt>11101010 oooooooo oooooooo ssssssss ssssssss</tt> || 5 || 7
|-
| JMP mem16 || <tt>FF /4</tt> || <tt>11111111 oo100mmm</tt> || 2+ || 5
|-
| JMP mem16:16 || <tt>FF /5</tt> || <tt>11111111 oo101mmm</tt> || 2+ || 10
|-
| JMP reg16 || <tt>FF /4</tt> || <tt>11111111 11100mmm</tt> || 2 || 4
|-
| JMP rel8 || <tt>EB ii</tt> || <tt>11101011 iiiiiiii</tt> || 2 || 4
|-
| JMP rel16 || <tt>E9 ii ii</tt> || <tt>11101001 iiiiiiii iiiiiiii</tt> || 3 || 4
|}
----
{{Anchor|JNC}}
=== JNC/JAE ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JNC rel8 || <tt>73 ii</tt> || <tt>01110011 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JNO}}
=== JNO ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JNO rel8 || <tt>71 ii</tt> || <tt>01110001 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JNP}}
=== JNP ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JNP rel8 || <tt>7B ii</tt> || <tt>01111011 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JNS}}
=== JNS ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JNS rel8 || <tt>79 ii</tt> || <tt>01111001 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JNZ}}
=== JNZ/JNE ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JNZ rel8 || <tt>75 ii</tt> || <tt>01110101 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JO}}
=== JO ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JO rel8 || <tt>70 ii</tt> || <tt>01110000 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JP}}
=== JP ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JP rel8 || <tt>7A ii</tt> || <tt>01111010 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JS}}
=== JS ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JS rel8 || <tt>78 ii</tt> || <tt>01111000 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JZ}}
=== JZ/JE ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JZ rel8 || <tt>74 ii</tt> || <tt>01110100 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|LAHF}}
=== LAHF ===
----
{{Anchor|LDS}}
=== LDS ===
----
{{Anchor|LEA}}
=== LEA ===
----
{{Anchor|LEAVE}}
=== LEAVE ===
----
{{Anchor|LES}}
=== LES ===
----
{{Anchor|LOCK}}
=== LOCK ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| LOCK || <tt>F0</tt> || <tt>11110000</tt> || 1 || 1
|}
----
{{Anchor|LODSB}}
=== LODSB ===
----
{{Anchor|LODSW}}
=== LODSW ===
----
{{Anchor|LOOP}}
=== LOOP ===
----
{{Anchor|LOOPE}}
=== LOOPE ===
----
{{Anchor|LOOPNE}}
=== LOOPNE ===
----
{{Anchor|MOV}}
=== MOV ===
----
{{Anchor|MOVSB}}
=== MOVSB ===
----
{{Anchor|MOVSW}}
=== MOVSW ===
----
{{Anchor|MUL}}
=== MUL ===
----
{{Anchor|NEG}}
=== NEG ===
----
{{Anchor|NOP}}
=== NOP ===
----
{{Anchor|NOT}}
=== NOT ===
----
{{Anchor|OR}}
=== OR ===
----
{{Anchor|OUT}}
=== OUT ===
----
{{Anchor|OUTSB}}
=== OUTSB ===
----
{{Anchor|OUTSW}}
=== OUTSW ===
----
{{Anchor|POLL}}
=== POLL ===
----
{{Anchor|POP}}
=== POP ===
----
{{Anchor|POPA}}
=== POPA ===
----
{{Anchor|POPF}}
=== POPF ===
----
{{Anchor|PUSH}}
=== PUSH ===
----
{{Anchor|PUSHA}}
=== PUSHA ===
----
{{Anchor|PUSHF}}
=== PUSHF ===
----
{{Anchor|RCL}}
=== RCL ===
----
{{Anchor|RCR}}
=== RCR ===
----
{{Anchor|REP}}
=== REP/REPE/REPZ ===
----
{{Anchor|REPNE}}
=== REPNE/REPNZ ===
----
{{Anchor|RET}}
=== RET ===
----
{{Anchor|RETF}}
=== RETF ===
----
{{Anchor|ROL}}
=== ROL ===
----
{{Anchor|ROR}}
=== ROR ===
----
{{Anchor|SAHF}}
=== SAHF ===
----
{{Anchor|SAR}}
=== SAR ===
----
{{Anchor|SBB}}
=== SBB ===
----
{{Anchor|SCASB}}
=== SCASB ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| SCASB || <tt>AE</tt> || <tt>10101110</tt> || 1 || 4
|}
----
{{Anchor|SCASW}}
=== SCASW ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| SCASW || <tt>AF</tt> || <tt>10101111</tt> || 1 || 4
|}
----
{{Anchor|SHL}}
=== SHL ===
----
{{Anchor|SHR}}
=== SHR ===
----
{{Anchor|SS}}
=== SS ===
----
{{Anchor|STC}}
=== STC ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| STC || <tt>F9</tt> || <tt>11111001</tt> || 1 || 4
|}
----
{{Anchor|STD}}
=== STD ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| STD || <tt>FD</tt> || <tt>11111101</tt> || 1 || 4
|}
----
{{Anchor|STI}}
=== STI ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| STI || <tt>FB</tt> || <tt>11111011</tt> || 1 || 4
|}
----
{{Anchor|STOSB}}
=== STOSB ===
----
{{Anchor|STOSW}}
=== STOSW ===
----
{{Anchor|SUB}}
=== SUB ===
----
{{Anchor|TEST}}
=== TEST ===
----
{{Anchor|XCHG}}
=== XCHG ===
----
{{Anchor|XLAT}}
=== XLAT ===
----
{{Anchor|XOR}}
=== XOR ===
----
6b9ca4a6b3d227a2789d2acdaaf0d90916cda1a7
448
447
2024-12-26T19:50:36Z
Asie
351
/* ModR/M byte */
wikitext
text/x-wiki
__NOTOC__
Note that this page is a work in progress.
{| class="wikitable" style="text-align: center"
|+ Official V30MZ (80186) Instructions
|-
| [[#AAA|AAA]] || [[#AAD|AAD]] || [[#AAM|AAM]] || [[#AAS|AAS]] || [[#ADC|ADC]] || [[#ADD|ADD]] || [[#AND|AND]] || [[#BOUND|BOUND]] || [[#CALL|CALL]] || [[#CBW|CBW]] || [[#CLC|CLC]]
|-
| [[#CLD|CLD]] || [[#CLI|CLI]] || [[#CMC|CMC]] || [[#CMP|CMP]] || [[#CMPSB|CMPSB]] || [[#CMPSW|CMPSW]] || [[#CS|CS]] || [[#CWD|CWD]] || [[#DAA|DAA]] || [[#DAS|DAS]] || [[#DEC|DEC]]
|-
| [[#DIV|DIV]] || [[#DS|DS]] || [[#ENTER|ENTER]] || [[#ES|ES]] || [[#HLT|HLT]] || [[#IDIV|IDIV]] || [[#IMUL|IMUL]] || [[#IN|IN]] || [[#INC|INC]] || [[#INSB|INSB]] || [[#INSW|INSW]]
|-
| [[#INT|INT]] || [[#INTO|INTO]] || [[#IRET|IRET]] || [[#JA|JA]] || [[#JBE|JBE]] || [[#JC|JC]] || [[#JCXZ|JCXZ]] || [[#JG|JG]] || [[#JGE|JGE]] || [[#JL|JL]] || [[#JLE|JLE]]
|-
| [[#JMP|JMP]] || [[#JNC|JNC]] || [[#JNO|JNO]] || [[#JNP|JNP]] || [[#JNS|JNS]] || [[#JNZ|JNZ]] || [[#JO|JO]] || [[#JP|JP]] || [[#JS|JS]] || [[#JZ|JZ]] || [[#LAHF|LAHF]]
|-
| [[#LDS|LDS]] || [[#LEA|LEA]] || [[#LEAVE|LEAVE]] || [[#LES|LES]] || [[#LOCK|LOCK]] || [[#LODSB|LODSB]] || [[#LODSW|LODSW]] || [[#LOOP|LOOP]] || [[#LOOPE|LOOPE]] || [[#LOOPNE|LOOPNE]] || [[#MOV|MOV]]
|-
| [[#MOVSB|MOVSB]] || [[#MOVSW|MOVSW]] || [[#MUL|MUL]] || [[#NEG|NEG]] || [[#NOP|NOP]] || [[#NOT|NOT]] || [[#OR|OR]] || [[#OUT|OUT]] || [[#OUTSB|OUTSB]] || [[#OUTSW|OUTSW]] || [[#POLL|POLL]]
|-
| [[#POP|POP]] || [[#POPA|POPA]] || [[#POPF|POPF]] || [[#PUSH|PUSH]] || [[#PUSHA|PUSHA]] || [[#PUSHF|PUSHF]] || [[#RCL|RCL]] || [[#RCR|RCR]] || [[#REP|REP]] || [[#REPNE|REPNE]] || [[#RET|RET]]
|-
| [[#RETF|RETF]] || [[#ROL|ROL]] || [[#ROR|ROR]] || [[#SAHF|SAHF]] || [[#SAR|SAR]] || [[#SBB|SBB]] || [[#SCASB|SCASB]] || [[#SCASW|SCASW]] || [[#SHL|SHL]] || [[#SHR|SHR]] || [[#SS|SS]]
|-
| [[#STC|STC]] || [[#STD|STD]] || [[#STI|STI]] || [[#STOSB|STOSB]] || [[#STOSW|STOSW]] || [[#SUB|SUB]] || [[#TEST|TEST]] || [[#XCHG|XCHG]] || [[#XLAT|XLAT]] || [[#XOR|XOR]]
|}
{| class="mw-collapsible mw-collapsed wikitable sortable" style="width: 340px;"
|+ style="white-space:nowrap; border:1px solid; padding:3px; border-color:rgb(162, 169, 177); background-color:rgb(234, 236, 240);" | Intel <-> NEC mnemonic translation table
!Intel
!NEC
|-
| [[#AAA|AAA]]
| [[#AAA|ADJBA]]
|-
| [[#AAD|AAD]]
| [[#AAD|CVTDB]]
|-
| [[#AAM|AAM]]
| [[#AAM|CVTBD]]
|-
| [[#AAS|AAS]]
| [[#AAS|ADJBS]]
|-
| [[#ADC|ADC]]
| [[#ADC|ADDC]]
|-
| [[#ADD|ADD]]
| [[#ADD|ADD]]
|-
| [[#AND|AND]]
| [[#AND|AND]]
|-
| [[#BOUND|BOUND]]
| [[#BOUND|CHKIND]]
|-
| [[#CALL|CALL]]
| [[#CALL|CALL]]
|-
| [[#CBW|CBW]]
| [[#CBW|CVTBW]]
|-
| [[#CLC|CLC]]
| [[#CLC|CLR1 CY]]
|-
| [[#CLD|CLD]]
| [[#CLD|CLR1 DIR]]
|-
| [[#CLI|CLI]]
| [[#CLI|DI]]
|-
| [[#CMC|CMC]]
| [[#CMC|NOT1 CY]]
|-
| [[#CMP|CMP]]
| [[#CMP|CMP]]
|-
| [[#CMPSB|CMPSB]]
| [[#CMPSB|CMPBKB]]
|-
| [[#CMPSW|CMPSW]]
| [[#CMPSW|CMPBKW]]
|-
| [[#CS|CS]]
| [[#CS|PS]]
|-
| [[#CWD|CWD]]
| [[#CWD|CVTWL]]
|-
| [[#DAA|DAA]]
| [[#DAA|ADJ4A]]
|-
| [[#DAS|DAS]]
| [[#DAS|ADJ4S]]
|-
| [[#DEC|DEC]]
| [[#DEC|DEC]]
|-
| [[#DIV|DIV]]
| [[#DIV|DIVU]]
|-
| [[#DS|DS]]
| [[#DS|DS0]]
|-
| [[#ENTER|ENTER]]
| [[#ENTER|PREPARE]]
|-
| [[#ES|ES]]
| [[#ES|DS1]]
|-
| [[#HLT|HLT]]
| [[#HLT|HALT]]
|-
| [[#IDIV|IDIV]]
| [[#IDIV|DIV]]
|-
| [[#IMUL|IMUL]]
| [[#IMUL|MUL]]
|-
| [[#IN|IN]]
| [[#IN|IN]]
|-
| [[#INC|INC]]
| [[#INC|INC]]
|-
| [[#INSB|INSB]]
| [[#INSB|INMB]]
|-
| [[#INSW|INSW]]
| [[#INSW|INMW]]
|-
| [[#INT|INT]]
| [[#INT|BRK]]
|-
| [[#INTO|INTO]]
| [[#INTO|BRKV]]
|-
| [[#IRET|IRET]]
| [[#IRET|RETI]]
|-
| [[#JA|JA]]
| [[#JA|BH]]
|-
| [[#JBE|JBE]]
| [[#JBE|BNH]]
|-
| [[#JC|JC/JB]]
| [[#JC|BC/BL]]
|-
| [[#JCXZ|JCXZ]]
| [[#JCXZ|BCWZ]]
|-
| [[#JG|JG]]
| [[#JG|BGT]]
|-
| [[#JGE|JGE]]
| [[#JGE|BGE]]
|-
| [[#JL|JL]]
| [[#JL|BLT]]
|-
| [[#JLE|JLE]]
| [[#JLE|BLE]]
|-
| [[#JMP|JMP]]
| [[#JMP|BR]]
|-
| [[#JNC|JNC/JAE]]
| [[#JNC|BNC/BNL]]
|-
| [[#JNO|JNO]]
| [[#JNO|BNV]]
|-
| [[#JNP|JNP]]
| [[#JNP|BPO]]
|-
| [[#JNS|JNS]]
| [[#JNS|BP]]
|-
| [[#JNZ|JNZ/JNE]]
| [[#JNZ|BNZ/BNE]]
|-
| [[#JO|JO]]
| [[#JO|BV]]
|-
| [[#JP|JP]]
| [[#JP|BPE]]
|-
| [[#JS|JS]]
| [[#JS|BN]]
|-
| [[#JZ|JZ/JE]]
| [[#JZ|BZ/BE]]
|-
| [[#LAHF|LAHF]]
| [[#LAHF|MOV]]
|-
| [[#LDS|LDS]]
| [[#LDS|MOV]]
|-
| [[#LEA|LEA]]
| [[#LEA|LDEA]]
|-
| [[#LEAVE|LEAVE]]
| [[#LEAVE|DISPOSE]]
|-
| [[#LES|LES]]
| [[#LES|MOV]]
|-
| [[#LOCK|LOCK]]
| [[#LOCK|BUSLOCK]]
|-
| [[#LODSB|LODSB]]
| [[#LODSB|LDMB]]
|-
| [[#LODSW|LODSW]]
| [[#LODSW|LDMW]]
|-
| [[#LOOP|LOOP]]
| [[#LOOP|DBNZ]]
|-
| [[#LOOPE|LOOPE]]
| [[#LOOPE|DBNZE]]
|-
| [[#LOOPNE|LOOPNE]]
| [[#LOOPNE|DBNZNE]]
|-
| [[#MOV|MOV]]
| [[#MOV|MOV]]
|-
| [[#MOVSB|MOVSB]]
| [[#MOVSB|MOVBKB]]
|-
| [[#MOVSW|MOVSW]]
| [[#MOVSW|MOVBKW]]
|-
| [[#MUL|MUL]]
| [[#MUL|MULU]]
|-
| [[#NEG|NEG]]
| [[#NEG|NEG]]
|-
| [[#NOP|NOP]]
| [[#NOP|NOP]]
|-
| [[#NOT|NOT]]
| [[#NOT|NOT]]
|-
| [[#OR|OR]]
| [[#OR|OR]]
|-
| [[#OUT|OUT]]
| [[#OUT|OUT]]
|-
| [[#OUTSB|OUTSB]]
| [[#OUTSB|OUTM]]
|-
| [[#OUTSW|OUTSW]]
| [[#OUTSW|OUTM]]
|-
| [[#POLL|POLL]]
| [[#POLL|POLL]]
|-
| [[#POP|POP]]
| [[#POP|POP]]
|-
| [[#POPA|POPA]]
| [[#POPA|POP]]
|-
| [[#POPF|POPF]]
| [[#POPF|POP]]
|-
| [[#PUSH|PUSH]]
| [[#PUSH|PUSH]]
|-
| [[#PUSHA|PUSHA]]
| [[#PUSHA|PUSH]]
|-
| [[#PUSHF|PUSHF]]
| [[#PUSHF|PUSH]]
|-
| [[#RCL|RCL]]
| [[#RCL|ROLC]]
|-
| [[#RCR|RCR]]
| [[#RCR|RORC]]
|-
| [[#REP|REP/REPE/REPZ]]
| [[#REP|REP/REPE/REPZ]]
|-
| [[#REPNE|REPNE/REPNZ]]
| [[#REPNE|REPNE/REPNZ]]
|-
| [[#RET|RET]]
| [[#RET|RET]]
|-
| [[#RETF|RETF]]
| [[#RETF|RET]]
|-
| [[#ROL|ROL]]
| [[#ROL|ROL]]
|-
| [[#ROR|ROR]]
| [[#ROR|ROR]]
|-
| [[#SAHF|SAHF]]
| [[#SAHF|MOV]]
|-
| [[#SAR|SAR]]
| [[#SAR|SHRA]]
|-
| [[#SBB|SBB]]
| [[#SBB|SUBC]]
|-
| [[#SCASB|SCASB]]
| [[#SCASB|CMPMB]]
|-
| [[#SCASW|SCASW]]
| [[#SCASW|CMPMW]]
|-
| [[#SHL|SHL]]
| [[#SHL|SHL]]
|-
| [[#SHR|SHR]]
| [[#SHR|SHR]]
|-
| [[#SS|SS]]
| [[#SS|SS]]
|-
| [[#STC|STC]]
| [[#STC|SET1 CY]]
|-
| [[#STD|STD]]
| [[#STD|SET1 DIR]]
|-
| [[#STI|STI]]
| [[#STI|EI]]
|-
| [[#STOSB|STOSB]]
| [[#STOSB|STMB]]
|-
| [[#STOSW|STOSW]]
| [[#STOSW|STMW]]
|-
| [[#SUB|SUB]]
| [[#SUB|SUB]]
|-
| [[#TEST|TEST]]
| [[#TEST|TEST]]
|-
| [[#XCHG|XCHG]]
| [[#XCHG|XCH]]
|-
| [[#XLAT|XLAT]]
| [[#XLAT|TRANS]]
|-
| [[#XOR|XOR]]
| [[#XOR|XOR]]
|}
== Official instructions by type ==
{| class="wikitable sortable" style="text-align: center"
!Type
!colspan=16 class="unsortable" | Instructions
|-
| style="text-align:left;" | Memory
| style="" | [[#MOV|MOV]]
| style="" | [[#XCHG|XCHG]]
| style="" | [[#XLAT|XLAT]]
| style="" | [[#LEA|LEA]]
| style="border-right:none;" | [[#LDS|LDS]]
| style="border-left:none;" | [[#LES|LES]]
| style="border-right:none;" | [[#IN|IN]]
| style="border-left:none;" | [[#OUT|OUT]]
| colspan="8" |
|-
| style="text-align:left;" | Ports
| style="border-right:none;" | [[#IN|IN]]
| style="border-left:none;" | [[#OUT|OUT]]
| style="border-right:none;" | [[#INSB|INSB]]
| style="border-left:none;" | [[#OUTSB|OUTSB]]
| style="border-right:none;" | [[#INSW|INSW]]
| style="border-left:none;" | [[#OUTSW|OUTSW]]
| colspan="10" |
|-
| style="text-align:left;" | Arithmetic
| style="border-right:none;" | [[#ADD|ADD]]
| style="border-left:none;" | [[#SUB|SUB]]
| style="border-right:none;" | [[#ADC|ADC]]
| style="border-left:none;" | [[#SBB|SBB]]
| style="border-right:none;" | [[#INC|INC]]
| style="border-left:none;" | [[#DEC|DEC]]
| style="border-right:none;" | [[#MUL|MUL]]
| style="border-left:none;" | [[#DIV|DIV]]
| style="border-right:none;" | [[#IMUL|IMUL]]
| style="border-left:none;" | [[#IDIV|IDIV]]
| style="" | [[#CMP|CMP]]
| style="" | [[#NEG|NEG]]
| colspan="4" |
|-
| style="text-align:left;" | Numeric
| style="" | [[#CBW|CBW]]
| style="" | [[#CWD|CWD]]
| style="" | [[#AAA|AAA]]
| style="" | [[#AAS|AAS]]
| style="" | [[#AAM|AAM]]
| style="" | [[#AAD|AAD]]
| style="" | [[#DAA|DAA]]
| style="" | [[#DAS|DAS]]
| colspan="8" |
|-
| style="text-align:left;" | Shift
| style="border-right:none;" | [[#ROL|ROL]]
| style="border-left:none;" | [[#ROR|ROR]]
| style="border-right:none;" | [[#RCL|RCL]]
| style="border-left:none;" | [[#RCR|RCR]]
| style="border-right:none;" | [[#SHL|SHL]]
| style="border-left:none;" | [[#SHR|SHR]]
| style="" | [[#SAR|SAR]]
| colspan="9" |
|-
| style="text-align:left;" | Bitwise
| style="" | [[#AND|AND]]
| style="" | [[#OR|OR]]
| style="" | [[#XOR|XOR]]
| style="" | [[#NOT|NOT]]
| style="" | [[#TEST|TEST]]
| colspan="11" |
|-
| style="text-align:left;" | Branch
| style="border-right:none;" | [[#JC|JC]]
| style="border-left:none;" | [[#JNC|JNC]]
| style="border-right:none;" | [[#JZ|JZ]]
| style="border-left:none;" | [[#JNZ|JNZ]]
| style="border-right:none;" | [[#JBE|JBE]]
| style="border-left:none;" | [[#JA|JA]]
| style="border-right:none;" | [[#JO|JO]]
| style="border-left:none;" | [[#JNO|JNO]]
| style="border-right:none;" | [[#JP|JP]]
| style="border-left:none;" | [[#JNP|JNP]]
| style="border-right:none;" | [[#JS|JS]]
| style="border-left:none;" | [[#JNS|JNS]]
| style="border-right:none;" | [[#JL|JL]]
| style="border-left:none;" | [[#JGE|JGE]]
| style="border-right:none;" | [[#JLE|JLE]]
| style="border-left:none;" | [[#JG|JG]]
|-
| style="text-align:left;" | Jump
| style="" | [[#JMP|JMP]]
| style="border-right:none;" | [[#CALL|CALL]]
| style="border-left:none;border-right:none;" | [[#RET|RET]]
| style="border-left:none;" | [[#RETF|RETF]]
| colspan="12" |
|-
| style="text-align:left;" | Loop
| style="" | [[#LOOP|LOOP]]
| style="" | [[#LOOPE|LOOPE]]
| style="" | [[#LOOPNE|LOOPNE]]
| colspan="13" |
|-
| style="text-align:left;" | Interrupt
| style="border-right:none;" | [[#INT|INT]]
| style="border-left:none;" | [[#IRET|IRET]]
| style="" | [[#INTO|INTO]]
| style="" | [[#HLT|HLT]]
| style="" | [[#BOUND|BOUND]]
| colspan="11" |
|-
| style="text-align:left;" | Stack
| style="border-right:none;" | [[#PUSH|PUSH]]
| style="border-left:none;" | [[#POP|POP]]
| style="border-right:none;" | [[#PUSHA|PUSHA]]
| style="border-left:none;" | [[#POPA|POPA]]
| style="border-right:none;" | [[#PUSHF|PUSHF]]
| style="border-left:none;" | [[#POPF|POPF]]
| colspan="10" |
|-
| style="text-align:left;" | Flags
| style="border-right:none;" | [[#CLC|CLC]]
| style="border-left:none;" | [[#STC|STC]]
| style="border-right:none;" | [[#CLD|CLD]]
| style="border-left:none;" | [[#STD|STD]]
| style="border-right:none;" | [[#CLI|CLI]]
| style="border-left:none;" | [[#STI|STI]]
| style="" | [[#CMC|CMC]]
| style="border-right:none;" | [[#LAHF|LAHF]]
| style="border-left:none;" | [[#SAHF|SAHF]]
| colspan="7" |
|-
| style="text-align:left;" | Prefix
| style="" | [[#CS|CS]]
| style="" | [[#DS|DS]]
| style="" | [[#ES|ES]]
| style="" | [[#SS|SS]]
| colspan="12" |
|-
| style="text-align:left;" | String
| style="border-right:none;" | [[#REP|REP]]
| style="border-left:none;border-right:none;" | [[#REP|REPE]]
| style="border-left:none;" | [[#REPNE|REPNE]]
| style="" | [[#MOVSB|MOVSB]]
| style="" | [[#MOVSW|MOVSW]]
| style="border-right:none;" | [[#LODSB|LODSB]]
| style="border-left:none;" | [[#STOSB|STOSB]]
| style="border-right:none;" | [[#LODSW|LODSW]]
| style="border-left:none;" | [[#STOSW|STOSW]]
| style="" | [[#CMPSB|CMPSB]]
| style="" | [[#SCASB|SCASB]]
| style="" | [[#CMPSW|CMPSW]]
| style="" | [[#SCASW|SCASW]]
| colspan="3" |
|-
| style="text-align:left;" | Other
| style="" | [[#NOP|NOP]]
| style="border-right:none;" | [[#ENTER|ENTER]]
| style="border-left:none;" | [[#LEAVE|LEAVE]]
| style="" | [[#LOCK|LOCK]]
| style="" | [[#POLL|POLL]]
| colspan="11" |
|}
== Instruction encoding ==
=== ModR/M byte ===
The ModR/M byte is used in most addressing modes which reference a memory location. This byte consists of three bitfield values:
* <tt>oo</tt> - M'''o'''de;
* <tt>rrr</tt> - Two possible functions:
** '''R'''egister (for addressing modes which require both a register and a register/memory operand),
** Opcode extension (for some opcodes' addressing modes which do not have such a requirement);
* <tt>mmm</tt> - Register/'''M'''emory.
The ''Mode'' and ''Register/Memory'' bitfields can refer to a memory location or to a register, as shown in the table below. In some addressing modes, the ''Register'' field also refers to a register; it is always interpreted as if ''Mode'' was equal to <tt>11</tt>.
{| class="wikitable" style="text-align: center"
! R/M \ Mode
! <tt>00</tt>
! <tt>01</tt>
! <tt>10</tt>
! <tt>11</tt> ''(byte)''
! <tt>11</tt> ''(word)''
|-
| <tt>000</tt>
| DS:[BX + SI]
| DS:[BX + SI + disp8]
| DS:[BX + SI + disp16]
| AL
| AX
|-
| <tt>001</tt>
| DS:[BX + DI]
| DS:[BX + DI + disp8]
| DS:[BX + DI + disp16]
| CL
| CX
|-
| <tt>010</tt>
| SS:[BP + SI]
| SS:[BP + SI + disp8]
| SS:[BP + SI + disp16]
| DL
| DX
|-
| <tt>011</tt>
| SS:[BP + DI]
| SS:[BP + DI + disp8]
| SS:[BP + DI + disp16]
| BL
| BX
|-
| <tt>100</tt>
| DS:[SI]
| DS:[SI + disp8]
| DS:[SI + disp16]
| AH
| SP
|-
| <tt>101</tt>
| DS:[DI]
| DS:[DI + disp8]
| DS:[DI + disp16]
| CH
| BP
|-
| <tt>110</tt>
| ''DS:[disp16]''
| SS:[BP + disp8]
| SS:[BP + disp16]
| DH
| SI
|-
| <tt>111</tt>
| DS:[BX]
| DS:[BX + disp8]
| DS:[BX + disp16]
| BH
| DI
|}
Note that (<tt>oo</tt> = <tt>00</tt>, <tt>mmm</tt> = <tt>110</tt>) is a special case. Displacements are either 8-bit or 16-bit signed values and they always immediately follow the ModR/M byte.
The instruction encoding lists below refer to this byte as <tt>oorrrmmm</tt> (binary), <tt>/r</tt> (hexadecimal) or <tt>/0</tt> (hexademical, <tt>rrr</tt> used as function <tt>0</tt>).
== Official instructions ==
{{Anchor|AAA}}
=== AAA ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| AAA || <tt>37</tt> || <tt>00110111</tt> || 1 || 9
|}
----
{{Anchor|AAD}}
=== AAD ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| AAD imm8 || <tt>B5 ii</tt> || <tt>11010100 iiiiiiii</tt> || 2 || 6
|}
----
{{Anchor|AAM}}
=== AAM ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| AAM imm8 || <tt>B4 ii</tt> || <tt>11010100 iiiiiiii</tt> || 2 || 17
|}
----
{{Anchor|AAS}}
=== AAS ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| AAS || <tt>3F</tt> || <tt>00111111</tt> || 1 || 9
|}
----
{{Anchor|ADC}}
=== ADC ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| ADC AL, imm || <tt>14 ii</tt> || <tt>00010100 iiiiiiii</tt> || 2 || 1
|-
| ADC AX, imm || <tt>15 ii ii</tt> || <tt>00010101 iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| ADC mem8, imm8 || <tt>80 /2 ii</tt> || <tt>10000000 oo010mmm iiiiiiii</tt> || 3+ || 3
|-
| ADC mem16, imm16 || <tt>81 /2 ii ii</tt> || <tt>10000001 oo010mmm iiiiiiii iiiiiiii</tt> || 4+ || 3
|-
| ADC mem16, simm8 || <tt>83 /2 ii ii</tt> || <tt>10000011 oo010mmm iiiiiiii iiiiiiii</tt> || 4+ || 3
|-
| ADC mem8, reg8 || <tt>10 /r</tt> || <tt>00010000 oorrrmmm</tt> || 2+ || 3
|-
| ADC mem16, reg16 || <tt>11 /r</tt> || <tt>00010001 oorrrmmm</tt> || 2+ || 3
|-
| ADC reg8, imm8 || <tt>80 /2 ii</tt> || <tt>10000000 11010mmm iiiiiiii</tt> || 3+ || 1
|-
| ADC reg16, imm16 || <tt>81 /2 ii ii</tt> || <tt>10000001 11010mmm iiiiiiii iiiiiiii</tt> || 4+ || 1
|-
| ADC reg16, simm8 || <tt>83 /2 ii ii</tt> || <tt>10000011 11010mmm iiiiiiii iiiiiiii</tt> || 4+ || 1
|-
| ADC reg8, mem8 || <tt>12 /r</tt> || <tt>00010010 oorrrmmm</tt> || 2+ || 2
|-
| ADC reg16, mem16 || <tt>13 /r</tt> || <tt>00010011 oorrrmmm</tt> || 2+ || 2
|-
| ADC reg8, reg8 || <tt>10 /r</tt> || <tt>000100.0 11rrrmmm</tt> || 2 || 1
|-
| ADC reg16, reg16 || <tt>11 /r</tt> || <tt>000100.1 11rrrmmm</tt> || 2 || 1
|}
----
{{Anchor|ADD}}
=== ADD ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| ADD AL, imm || <tt>04 ii</tt> || <tt>00000100 iiiiiiii</tt> || 2 || 1
|-
| ADD AX, imm || <tt>05 ii ii</tt> || <tt>00000101 iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| ADD mem8, imm8 || <tt>80 /0 ii</tt> || <tt>10000000 oo000mmm iiiiiiii</tt> || 3+ || 3
|-
| ADD mem16, imm16 || <tt>81 /0 ii ii</tt> || <tt>10000001 oo000mmm iiiiiiii iiiiiiii</tt> || 4+ || 3
|-
| ADD mem16, simm8 || <tt>83 /0 ii ii</tt> || <tt>10000011 oo000mmm iiiiiiii iiiiiiii</tt> || 4+ || 3
|-
| ADD mem8, reg8 || <tt>00 /r</tt> || <tt>00000000 oorrrmmm</tt> || 2+ || 3
|-
| ADD mem16, reg16 || <tt>01 /r</tt> || <tt>00000001 oorrrmmm</tt> || 2+ || 3
|-
| ADD reg8, imm8 || <tt>80 /0 ii</tt> || <tt>10000000 11000mmm iiiiiiii</tt> || 3+ || 1
|-
| ADD reg16, imm16 || <tt>81 /0 ii ii</tt> || <tt>10000001 11000mmm iiiiiiii iiiiiiii</tt> || 4+ || 1
|-
| ADD reg16, simm8 || <tt>83 /0 ii ii</tt> || <tt>10000011 11000mmm iiiiiiii iiiiiiii</tt> || 4+ || 1
|-
| ADD reg8, mem8 || <tt>02 /r</tt> || <tt>00000010 oorrrmmm</tt> || 2+ || 2
|-
| ADD reg16, mem16 || <tt>03 /r</tt> || <tt>00000011 oorrrmmm</tt> || 2+ || 2
|-
| ADD reg8, reg8 || <tt>00 /r</tt> || <tt>000000.0 11rrrmmm</tt> || 2 || 1
|-
| ADD reg16, reg16 || <tt>01 /r</tt> || <tt>000000.1 11rrrmmm</tt> || 2 || 1
|}
----
{{Anchor|AND}}
=== AND ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| AND AL, imm || <tt>24 ii</tt> || <tt>00100100 iiiiiiii</tt> || 2 || 1
|-
| AND AX, imm || <tt>25 ii ii</tt> || <tt>00100101 iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| AND mem8, imm8 || <tt>80 /4 ii</tt> || <tt>10000000 oo100mmm iiiiiiii</tt> || 3+ || 3
|-
| AND mem16, imm16 || <tt>81 /4 ii ii</tt> || <tt>10000001 oo100mmm iiiiiiii iiiiiiii</tt> || 4+ || 3
|-
| AND mem16, simm8 || <tt>83 /4 ii ii</tt> || <tt>10000011 oo100mmm iiiiiiii iiiiiiii</tt> || 4+ || 3
|-
| AND mem8, reg8 || <tt>20 /r</tt> || <tt>00100000 oorrrmmm</tt> || 2+ || 3
|-
| AND mem16, reg16 || <tt>21 /r</tt> || <tt>00100001 oorrrmmm</tt> || 2+ || 3
|-
| AND reg8, imm8 || <tt>80 /4 ii</tt> || <tt>10000000 11100mmm iiiiiiii</tt> || 3+ || 1
|-
| AND reg16, imm16 || <tt>81 /4 ii ii</tt> || <tt>10000001 11100mmm iiiiiiii iiiiiiii</tt> || 4+ || 1
|-
| AND reg16, simm8 || <tt>83 /4 ii ii</tt> || <tt>10000011 11100mmm iiiiiiii iiiiiiii</tt> || 4+ || 1
|-
| AND reg8, mem8 || <tt>22 /r</tt> || <tt>00100010 oorrrmmm</tt> || 2+ || 2
|-
| AND reg16, mem16 || <tt>23 /r</tt> || <tt>00100011 oorrrmmm</tt> || 2+ || 2
|-
| AND reg8, reg8 || <tt>20 /r</tt> || <tt>001000.0 11rrrmmm</tt> || 2 || 1
|-
| AND reg16, reg16 || <tt>21 /r</tt> || <tt>001000.1 11rrrmmm</tt> || 2 || 1
|}
----
{{Anchor|BOUND}}
=== BOUND ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| BOUND reg16, mem16:16 || <tt>62 /r</tt> || <tt>01100010 oorrrmmm</tt> || 2+ || 13 (20 if condition met)
|}
----
{{Anchor|CALL}}
=== CALL ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| CALL ptr16:16 || <tt>CA oo oo ss ss</tt> || <tt>10011010 oooooooo oooooooo ssssssss ssssssss</tt> || 5 || 10
|-
| CALL mem16 || <tt>FF /2</tt> || <tt>11111111 oo010mmm</tt> || 2+ || 6
|-
| CALL mem16:16 || <tt>FF /3</tt> || <tt>11111111 oo011mmm</tt> || 2+ || 12
|-
| CALL reg16 || <tt>FF /2</tt> || <tt>11111111 11010mmm</tt> || 2 || 5
|-
| CALL rel16 || <tt>E8 ii ii</tt> || <tt>11101000 iiiiiiii iiiiiiii</tt> || 3 || 5
|}
----
{{Anchor|CBW}}
=== CBW ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| CBW || <tt>98</tt> || <tt>10011000</tt> || 1 || 1
|}
----
{{Anchor|CLC}}
=== CLC ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| CLC || <tt>F8</tt> || <tt>11111000</tt> || 1 || 4
|}
----
{{Anchor|CLD}}
=== CLD ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| CLD || <tt>FC</tt> || <tt>11111100</tt> || 1 || 4
|}
----
{{Anchor|CLI}}
=== CLI ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| CLI || <tt>FA</tt> || <tt>11111010</tt> || 1 || 4
|}
----
{{Anchor|CMC}}
=== CMC ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| CMC || <tt>F5</tt> || <tt>11110101</tt> || 1 || 4
|}
----
{{Anchor|CMP}}
=== CMP ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| CMP AL, imm || <tt>3C ii</tt> || <tt>00111100 iiiiiiii</tt> || 2 || 1
|-
| CMP AX, imm || <tt>3D ii ii</tt> || <tt>00111101 iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| CMP mem8, imm8 || <tt>80 /7 ii</tt> || <tt>10000000 oo111mmm iiiiiiii</tt> || 3+ || 2
|-
| CMP mem16, imm16 || <tt>81 /7 ii ii</tt> || <tt>10000001 oo111mmm iiiiiiii iiiiiiii</tt> || 4+ || 2
|-
| CMP mem16, simm8 || <tt>83 /7 ii ii</tt> || <tt>10000011 oo111mmm iiiiiiii iiiiiiii</tt> || 4+ || 2
|-
| CMP mem8, reg8 || <tt>38 /r</tt> || <tt>00111000 oorrrmmm</tt> || 2+ || 2
|-
| CMP mem16, reg16 || <tt>39 /r</tt> || <tt>00111001 oorrrmmm</tt> || 2+ || 2
|-
| CMP reg8, imm8 || <tt>80 /7 ii</tt> || <tt>10000000 11111mmm iiiiiiii</tt> || 3+ || 1
|-
| CMP reg16, imm16 || <tt>81 /7 ii ii</tt> || <tt>10000001 11111mmm iiiiiiii iiiiiiii</tt> || 4+ || 1
|-
| CMP reg16, simm8 || <tt>83 /7 ii ii</tt> || <tt>10000011 11111mmm iiiiiiii iiiiiiii</tt> || 4+ || 1
|-
| CMP reg8, mem8 || <tt>3A /r</tt> || <tt>00111010 oorrrmmm</tt> || 2+ || 2
|-
| CMP reg16, mem16 || <tt>3B /r</tt> || <tt>00111011 oorrrmmm</tt> || 2+ || 2
|-
| CMP reg8, reg8 || <tt>38 /r</tt> || <tt>001110.0 11rrrmmm</tt> || 2 || 1
|-
| CMP reg16, reg16 || <tt>39 /r</tt> || <tt>001110.1 11rrrmmm</tt> || 2 || 1
|}
----
{{Anchor|CMPSB}}
=== CMPSB ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| CMPSB || <tt>A6</tt> || <tt>10100110</tt> || 1 || 6
|}
----
{{Anchor|CMPSW}}
=== CMPSW ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| CMPSW || <tt>A7</tt> || <tt>10100111</tt> || 1 || 6
|}
----
{{Anchor|CS}}
=== CS ===
----
{{Anchor|CWD}}
=== CWD ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| CWD || <tt>99</tt> || <tt>10011001</tt> || 1 || 1
|}
----
{{Anchor|DAA}}
=== DAA ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| DAA || <tt>27</tt> || <tt>00100111</tt> || 1 || 10
|}
----
{{Anchor|DAS}}
=== DAS ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| DAS || <tt>2F</tt> || <tt>00101111</tt> || 1 || 10
|}
----
{{Anchor|DEC}}
=== DEC ===
----
{{Anchor|DIV}}
=== DIV ===
----
{{Anchor|DS}}
=== DS ===
----
{{Anchor|ENTER}}
=== ENTER ===
----
{{Anchor|ES}}
=== ES ===
----
{{Anchor|HLT}}
=== HLT ===
----
{{Anchor|IDIV}}
=== IDIV ===
----
{{Anchor|IMUL}}
=== IMUL ===
----
{{Anchor|IN}}
=== IN ===
----
{{Anchor|INC}}
=== INC ===
----
{{Anchor|INSB}}
=== INSB ===
----
{{Anchor|INSW}}
=== INSW ===
----
{{Anchor|INT}}
=== INT ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| INT 3 || <tt>CC</tt> || <tt>11001100</tt> || 1 || 9
|-
| INT imm8 || <tt>CD ii</tt> || <tt>11001101 iiiiiiii</tt> || 2 || 10
|}
----
{{Anchor|INTO}}
=== INTO ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| INTO || <tt>CE</tt> || <tt>11001110</tt> || 1 || 6 (13 if OF = 1)
|}
----
{{Anchor|IRET}}
=== IRET ===
----
{{Anchor|JA}}
=== JA ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JA rel8 || <tt>77 ii</tt> || <tt>01110111 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JBE}}
=== JBE ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JA rel8 || <tt>76 ii</tt> || <tt>01110110 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JC}}
=== JC/JB ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JC rel8 || <tt>72 ii</tt> || <tt>01110010 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JCXZ}}
=== JCXZ ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JCXZ rel8 || <tt>E3 ii</tt> || <tt>11100011 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JG}}
=== JG ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JG rel8 || <tt>7F ii</tt> || <tt>01111111 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JGE}}
=== JGE ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JGE rel8 || <tt>7D ii</tt> || <tt>01111101 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JL}}
=== JL ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JL rel8 || <tt>7C ii</tt> || <tt>01111100 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JLE}}
=== JLE ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JLE rel8 || <tt>7E ii</tt> || <tt>01111110 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JMP}}
=== JMP ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JMP ptr16:16 || <tt>EA oo oo ss ss</tt> || <tt>11101010 oooooooo oooooooo ssssssss ssssssss</tt> || 5 || 7
|-
| JMP mem16 || <tt>FF /4</tt> || <tt>11111111 oo100mmm</tt> || 2+ || 5
|-
| JMP mem16:16 || <tt>FF /5</tt> || <tt>11111111 oo101mmm</tt> || 2+ || 10
|-
| JMP reg16 || <tt>FF /4</tt> || <tt>11111111 11100mmm</tt> || 2 || 4
|-
| JMP rel8 || <tt>EB ii</tt> || <tt>11101011 iiiiiiii</tt> || 2 || 4
|-
| JMP rel16 || <tt>E9 ii ii</tt> || <tt>11101001 iiiiiiii iiiiiiii</tt> || 3 || 4
|}
----
{{Anchor|JNC}}
=== JNC/JAE ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JNC rel8 || <tt>73 ii</tt> || <tt>01110011 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JNO}}
=== JNO ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JNO rel8 || <tt>71 ii</tt> || <tt>01110001 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JNP}}
=== JNP ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JNP rel8 || <tt>7B ii</tt> || <tt>01111011 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JNS}}
=== JNS ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JNS rel8 || <tt>79 ii</tt> || <tt>01111001 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JNZ}}
=== JNZ/JNE ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JNZ rel8 || <tt>75 ii</tt> || <tt>01110101 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JO}}
=== JO ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JO rel8 || <tt>70 ii</tt> || <tt>01110000 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JP}}
=== JP ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JP rel8 || <tt>7A ii</tt> || <tt>01111010 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JS}}
=== JS ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JS rel8 || <tt>78 ii</tt> || <tt>01111000 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JZ}}
=== JZ/JE ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JZ rel8 || <tt>74 ii</tt> || <tt>01110100 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|LAHF}}
=== LAHF ===
----
{{Anchor|LDS}}
=== LDS ===
----
{{Anchor|LEA}}
=== LEA ===
----
{{Anchor|LEAVE}}
=== LEAVE ===
----
{{Anchor|LES}}
=== LES ===
----
{{Anchor|LOCK}}
=== LOCK ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| LOCK || <tt>F0</tt> || <tt>11110000</tt> || 1 || 1
|}
----
{{Anchor|LODSB}}
=== LODSB ===
----
{{Anchor|LODSW}}
=== LODSW ===
----
{{Anchor|LOOP}}
=== LOOP ===
----
{{Anchor|LOOPE}}
=== LOOPE ===
----
{{Anchor|LOOPNE}}
=== LOOPNE ===
----
{{Anchor|MOV}}
=== MOV ===
----
{{Anchor|MOVSB}}
=== MOVSB ===
----
{{Anchor|MOVSW}}
=== MOVSW ===
----
{{Anchor|MUL}}
=== MUL ===
----
{{Anchor|NEG}}
=== NEG ===
----
{{Anchor|NOP}}
=== NOP ===
----
{{Anchor|NOT}}
=== NOT ===
----
{{Anchor|OR}}
=== OR ===
----
{{Anchor|OUT}}
=== OUT ===
----
{{Anchor|OUTSB}}
=== OUTSB ===
----
{{Anchor|OUTSW}}
=== OUTSW ===
----
{{Anchor|POLL}}
=== POLL ===
----
{{Anchor|POP}}
=== POP ===
----
{{Anchor|POPA}}
=== POPA ===
----
{{Anchor|POPF}}
=== POPF ===
----
{{Anchor|PUSH}}
=== PUSH ===
----
{{Anchor|PUSHA}}
=== PUSHA ===
----
{{Anchor|PUSHF}}
=== PUSHF ===
----
{{Anchor|RCL}}
=== RCL ===
----
{{Anchor|RCR}}
=== RCR ===
----
{{Anchor|REP}}
=== REP/REPE/REPZ ===
----
{{Anchor|REPNE}}
=== REPNE/REPNZ ===
----
{{Anchor|RET}}
=== RET ===
----
{{Anchor|RETF}}
=== RETF ===
----
{{Anchor|ROL}}
=== ROL ===
----
{{Anchor|ROR}}
=== ROR ===
----
{{Anchor|SAHF}}
=== SAHF ===
----
{{Anchor|SAR}}
=== SAR ===
----
{{Anchor|SBB}}
=== SBB ===
----
{{Anchor|SCASB}}
=== SCASB ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| SCASB || <tt>AE</tt> || <tt>10101110</tt> || 1 || 4
|}
----
{{Anchor|SCASW}}
=== SCASW ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| SCASW || <tt>AF</tt> || <tt>10101111</tt> || 1 || 4
|}
----
{{Anchor|SHL}}
=== SHL ===
----
{{Anchor|SHR}}
=== SHR ===
----
{{Anchor|SS}}
=== SS ===
----
{{Anchor|STC}}
=== STC ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| STC || <tt>F9</tt> || <tt>11111001</tt> || 1 || 4
|}
----
{{Anchor|STD}}
=== STD ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| STD || <tt>FD</tt> || <tt>11111101</tt> || 1 || 4
|}
----
{{Anchor|STI}}
=== STI ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| STI || <tt>FB</tt> || <tt>11111011</tt> || 1 || 4
|}
----
{{Anchor|STOSB}}
=== STOSB ===
----
{{Anchor|STOSW}}
=== STOSW ===
----
{{Anchor|SUB}}
=== SUB ===
----
{{Anchor|TEST}}
=== TEST ===
----
{{Anchor|XCHG}}
=== XCHG ===
----
{{Anchor|XLAT}}
=== XLAT ===
----
{{Anchor|XOR}}
=== XOR ===
----
e69fd666fb461ec138e14002d553e83e13ae59a9
449
448
2024-12-26T19:50:51Z
Asie
351
/* Instruction encoding */
wikitext
text/x-wiki
__NOTOC__
Note that this page is a work in progress.
{| class="wikitable" style="text-align: center"
|+ Official V30MZ (80186) Instructions
|-
| [[#AAA|AAA]] || [[#AAD|AAD]] || [[#AAM|AAM]] || [[#AAS|AAS]] || [[#ADC|ADC]] || [[#ADD|ADD]] || [[#AND|AND]] || [[#BOUND|BOUND]] || [[#CALL|CALL]] || [[#CBW|CBW]] || [[#CLC|CLC]]
|-
| [[#CLD|CLD]] || [[#CLI|CLI]] || [[#CMC|CMC]] || [[#CMP|CMP]] || [[#CMPSB|CMPSB]] || [[#CMPSW|CMPSW]] || [[#CS|CS]] || [[#CWD|CWD]] || [[#DAA|DAA]] || [[#DAS|DAS]] || [[#DEC|DEC]]
|-
| [[#DIV|DIV]] || [[#DS|DS]] || [[#ENTER|ENTER]] || [[#ES|ES]] || [[#HLT|HLT]] || [[#IDIV|IDIV]] || [[#IMUL|IMUL]] || [[#IN|IN]] || [[#INC|INC]] || [[#INSB|INSB]] || [[#INSW|INSW]]
|-
| [[#INT|INT]] || [[#INTO|INTO]] || [[#IRET|IRET]] || [[#JA|JA]] || [[#JBE|JBE]] || [[#JC|JC]] || [[#JCXZ|JCXZ]] || [[#JG|JG]] || [[#JGE|JGE]] || [[#JL|JL]] || [[#JLE|JLE]]
|-
| [[#JMP|JMP]] || [[#JNC|JNC]] || [[#JNO|JNO]] || [[#JNP|JNP]] || [[#JNS|JNS]] || [[#JNZ|JNZ]] || [[#JO|JO]] || [[#JP|JP]] || [[#JS|JS]] || [[#JZ|JZ]] || [[#LAHF|LAHF]]
|-
| [[#LDS|LDS]] || [[#LEA|LEA]] || [[#LEAVE|LEAVE]] || [[#LES|LES]] || [[#LOCK|LOCK]] || [[#LODSB|LODSB]] || [[#LODSW|LODSW]] || [[#LOOP|LOOP]] || [[#LOOPE|LOOPE]] || [[#LOOPNE|LOOPNE]] || [[#MOV|MOV]]
|-
| [[#MOVSB|MOVSB]] || [[#MOVSW|MOVSW]] || [[#MUL|MUL]] || [[#NEG|NEG]] || [[#NOP|NOP]] || [[#NOT|NOT]] || [[#OR|OR]] || [[#OUT|OUT]] || [[#OUTSB|OUTSB]] || [[#OUTSW|OUTSW]] || [[#POLL|POLL]]
|-
| [[#POP|POP]] || [[#POPA|POPA]] || [[#POPF|POPF]] || [[#PUSH|PUSH]] || [[#PUSHA|PUSHA]] || [[#PUSHF|PUSHF]] || [[#RCL|RCL]] || [[#RCR|RCR]] || [[#REP|REP]] || [[#REPNE|REPNE]] || [[#RET|RET]]
|-
| [[#RETF|RETF]] || [[#ROL|ROL]] || [[#ROR|ROR]] || [[#SAHF|SAHF]] || [[#SAR|SAR]] || [[#SBB|SBB]] || [[#SCASB|SCASB]] || [[#SCASW|SCASW]] || [[#SHL|SHL]] || [[#SHR|SHR]] || [[#SS|SS]]
|-
| [[#STC|STC]] || [[#STD|STD]] || [[#STI|STI]] || [[#STOSB|STOSB]] || [[#STOSW|STOSW]] || [[#SUB|SUB]] || [[#TEST|TEST]] || [[#XCHG|XCHG]] || [[#XLAT|XLAT]] || [[#XOR|XOR]]
|}
{| class="mw-collapsible mw-collapsed wikitable sortable" style="width: 340px;"
|+ style="white-space:nowrap; border:1px solid; padding:3px; border-color:rgb(162, 169, 177); background-color:rgb(234, 236, 240);" | Intel <-> NEC mnemonic translation table
!Intel
!NEC
|-
| [[#AAA|AAA]]
| [[#AAA|ADJBA]]
|-
| [[#AAD|AAD]]
| [[#AAD|CVTDB]]
|-
| [[#AAM|AAM]]
| [[#AAM|CVTBD]]
|-
| [[#AAS|AAS]]
| [[#AAS|ADJBS]]
|-
| [[#ADC|ADC]]
| [[#ADC|ADDC]]
|-
| [[#ADD|ADD]]
| [[#ADD|ADD]]
|-
| [[#AND|AND]]
| [[#AND|AND]]
|-
| [[#BOUND|BOUND]]
| [[#BOUND|CHKIND]]
|-
| [[#CALL|CALL]]
| [[#CALL|CALL]]
|-
| [[#CBW|CBW]]
| [[#CBW|CVTBW]]
|-
| [[#CLC|CLC]]
| [[#CLC|CLR1 CY]]
|-
| [[#CLD|CLD]]
| [[#CLD|CLR1 DIR]]
|-
| [[#CLI|CLI]]
| [[#CLI|DI]]
|-
| [[#CMC|CMC]]
| [[#CMC|NOT1 CY]]
|-
| [[#CMP|CMP]]
| [[#CMP|CMP]]
|-
| [[#CMPSB|CMPSB]]
| [[#CMPSB|CMPBKB]]
|-
| [[#CMPSW|CMPSW]]
| [[#CMPSW|CMPBKW]]
|-
| [[#CS|CS]]
| [[#CS|PS]]
|-
| [[#CWD|CWD]]
| [[#CWD|CVTWL]]
|-
| [[#DAA|DAA]]
| [[#DAA|ADJ4A]]
|-
| [[#DAS|DAS]]
| [[#DAS|ADJ4S]]
|-
| [[#DEC|DEC]]
| [[#DEC|DEC]]
|-
| [[#DIV|DIV]]
| [[#DIV|DIVU]]
|-
| [[#DS|DS]]
| [[#DS|DS0]]
|-
| [[#ENTER|ENTER]]
| [[#ENTER|PREPARE]]
|-
| [[#ES|ES]]
| [[#ES|DS1]]
|-
| [[#HLT|HLT]]
| [[#HLT|HALT]]
|-
| [[#IDIV|IDIV]]
| [[#IDIV|DIV]]
|-
| [[#IMUL|IMUL]]
| [[#IMUL|MUL]]
|-
| [[#IN|IN]]
| [[#IN|IN]]
|-
| [[#INC|INC]]
| [[#INC|INC]]
|-
| [[#INSB|INSB]]
| [[#INSB|INMB]]
|-
| [[#INSW|INSW]]
| [[#INSW|INMW]]
|-
| [[#INT|INT]]
| [[#INT|BRK]]
|-
| [[#INTO|INTO]]
| [[#INTO|BRKV]]
|-
| [[#IRET|IRET]]
| [[#IRET|RETI]]
|-
| [[#JA|JA]]
| [[#JA|BH]]
|-
| [[#JBE|JBE]]
| [[#JBE|BNH]]
|-
| [[#JC|JC/JB]]
| [[#JC|BC/BL]]
|-
| [[#JCXZ|JCXZ]]
| [[#JCXZ|BCWZ]]
|-
| [[#JG|JG]]
| [[#JG|BGT]]
|-
| [[#JGE|JGE]]
| [[#JGE|BGE]]
|-
| [[#JL|JL]]
| [[#JL|BLT]]
|-
| [[#JLE|JLE]]
| [[#JLE|BLE]]
|-
| [[#JMP|JMP]]
| [[#JMP|BR]]
|-
| [[#JNC|JNC/JAE]]
| [[#JNC|BNC/BNL]]
|-
| [[#JNO|JNO]]
| [[#JNO|BNV]]
|-
| [[#JNP|JNP]]
| [[#JNP|BPO]]
|-
| [[#JNS|JNS]]
| [[#JNS|BP]]
|-
| [[#JNZ|JNZ/JNE]]
| [[#JNZ|BNZ/BNE]]
|-
| [[#JO|JO]]
| [[#JO|BV]]
|-
| [[#JP|JP]]
| [[#JP|BPE]]
|-
| [[#JS|JS]]
| [[#JS|BN]]
|-
| [[#JZ|JZ/JE]]
| [[#JZ|BZ/BE]]
|-
| [[#LAHF|LAHF]]
| [[#LAHF|MOV]]
|-
| [[#LDS|LDS]]
| [[#LDS|MOV]]
|-
| [[#LEA|LEA]]
| [[#LEA|LDEA]]
|-
| [[#LEAVE|LEAVE]]
| [[#LEAVE|DISPOSE]]
|-
| [[#LES|LES]]
| [[#LES|MOV]]
|-
| [[#LOCK|LOCK]]
| [[#LOCK|BUSLOCK]]
|-
| [[#LODSB|LODSB]]
| [[#LODSB|LDMB]]
|-
| [[#LODSW|LODSW]]
| [[#LODSW|LDMW]]
|-
| [[#LOOP|LOOP]]
| [[#LOOP|DBNZ]]
|-
| [[#LOOPE|LOOPE]]
| [[#LOOPE|DBNZE]]
|-
| [[#LOOPNE|LOOPNE]]
| [[#LOOPNE|DBNZNE]]
|-
| [[#MOV|MOV]]
| [[#MOV|MOV]]
|-
| [[#MOVSB|MOVSB]]
| [[#MOVSB|MOVBKB]]
|-
| [[#MOVSW|MOVSW]]
| [[#MOVSW|MOVBKW]]
|-
| [[#MUL|MUL]]
| [[#MUL|MULU]]
|-
| [[#NEG|NEG]]
| [[#NEG|NEG]]
|-
| [[#NOP|NOP]]
| [[#NOP|NOP]]
|-
| [[#NOT|NOT]]
| [[#NOT|NOT]]
|-
| [[#OR|OR]]
| [[#OR|OR]]
|-
| [[#OUT|OUT]]
| [[#OUT|OUT]]
|-
| [[#OUTSB|OUTSB]]
| [[#OUTSB|OUTM]]
|-
| [[#OUTSW|OUTSW]]
| [[#OUTSW|OUTM]]
|-
| [[#POLL|POLL]]
| [[#POLL|POLL]]
|-
| [[#POP|POP]]
| [[#POP|POP]]
|-
| [[#POPA|POPA]]
| [[#POPA|POP]]
|-
| [[#POPF|POPF]]
| [[#POPF|POP]]
|-
| [[#PUSH|PUSH]]
| [[#PUSH|PUSH]]
|-
| [[#PUSHA|PUSHA]]
| [[#PUSHA|PUSH]]
|-
| [[#PUSHF|PUSHF]]
| [[#PUSHF|PUSH]]
|-
| [[#RCL|RCL]]
| [[#RCL|ROLC]]
|-
| [[#RCR|RCR]]
| [[#RCR|RORC]]
|-
| [[#REP|REP/REPE/REPZ]]
| [[#REP|REP/REPE/REPZ]]
|-
| [[#REPNE|REPNE/REPNZ]]
| [[#REPNE|REPNE/REPNZ]]
|-
| [[#RET|RET]]
| [[#RET|RET]]
|-
| [[#RETF|RETF]]
| [[#RETF|RET]]
|-
| [[#ROL|ROL]]
| [[#ROL|ROL]]
|-
| [[#ROR|ROR]]
| [[#ROR|ROR]]
|-
| [[#SAHF|SAHF]]
| [[#SAHF|MOV]]
|-
| [[#SAR|SAR]]
| [[#SAR|SHRA]]
|-
| [[#SBB|SBB]]
| [[#SBB|SUBC]]
|-
| [[#SCASB|SCASB]]
| [[#SCASB|CMPMB]]
|-
| [[#SCASW|SCASW]]
| [[#SCASW|CMPMW]]
|-
| [[#SHL|SHL]]
| [[#SHL|SHL]]
|-
| [[#SHR|SHR]]
| [[#SHR|SHR]]
|-
| [[#SS|SS]]
| [[#SS|SS]]
|-
| [[#STC|STC]]
| [[#STC|SET1 CY]]
|-
| [[#STD|STD]]
| [[#STD|SET1 DIR]]
|-
| [[#STI|STI]]
| [[#STI|EI]]
|-
| [[#STOSB|STOSB]]
| [[#STOSB|STMB]]
|-
| [[#STOSW|STOSW]]
| [[#STOSW|STMW]]
|-
| [[#SUB|SUB]]
| [[#SUB|SUB]]
|-
| [[#TEST|TEST]]
| [[#TEST|TEST]]
|-
| [[#XCHG|XCHG]]
| [[#XCHG|XCH]]
|-
| [[#XLAT|XLAT]]
| [[#XLAT|TRANS]]
|-
| [[#XOR|XOR]]
| [[#XOR|XOR]]
|}
== Official instructions by type ==
{| class="wikitable sortable" style="text-align: center"
!Type
!colspan=16 class="unsortable" | Instructions
|-
| style="text-align:left;" | Memory
| style="" | [[#MOV|MOV]]
| style="" | [[#XCHG|XCHG]]
| style="" | [[#XLAT|XLAT]]
| style="" | [[#LEA|LEA]]
| style="border-right:none;" | [[#LDS|LDS]]
| style="border-left:none;" | [[#LES|LES]]
| style="border-right:none;" | [[#IN|IN]]
| style="border-left:none;" | [[#OUT|OUT]]
| colspan="8" |
|-
| style="text-align:left;" | Ports
| style="border-right:none;" | [[#IN|IN]]
| style="border-left:none;" | [[#OUT|OUT]]
| style="border-right:none;" | [[#INSB|INSB]]
| style="border-left:none;" | [[#OUTSB|OUTSB]]
| style="border-right:none;" | [[#INSW|INSW]]
| style="border-left:none;" | [[#OUTSW|OUTSW]]
| colspan="10" |
|-
| style="text-align:left;" | Arithmetic
| style="border-right:none;" | [[#ADD|ADD]]
| style="border-left:none;" | [[#SUB|SUB]]
| style="border-right:none;" | [[#ADC|ADC]]
| style="border-left:none;" | [[#SBB|SBB]]
| style="border-right:none;" | [[#INC|INC]]
| style="border-left:none;" | [[#DEC|DEC]]
| style="border-right:none;" | [[#MUL|MUL]]
| style="border-left:none;" | [[#DIV|DIV]]
| style="border-right:none;" | [[#IMUL|IMUL]]
| style="border-left:none;" | [[#IDIV|IDIV]]
| style="" | [[#CMP|CMP]]
| style="" | [[#NEG|NEG]]
| colspan="4" |
|-
| style="text-align:left;" | Numeric
| style="" | [[#CBW|CBW]]
| style="" | [[#CWD|CWD]]
| style="" | [[#AAA|AAA]]
| style="" | [[#AAS|AAS]]
| style="" | [[#AAM|AAM]]
| style="" | [[#AAD|AAD]]
| style="" | [[#DAA|DAA]]
| style="" | [[#DAS|DAS]]
| colspan="8" |
|-
| style="text-align:left;" | Shift
| style="border-right:none;" | [[#ROL|ROL]]
| style="border-left:none;" | [[#ROR|ROR]]
| style="border-right:none;" | [[#RCL|RCL]]
| style="border-left:none;" | [[#RCR|RCR]]
| style="border-right:none;" | [[#SHL|SHL]]
| style="border-left:none;" | [[#SHR|SHR]]
| style="" | [[#SAR|SAR]]
| colspan="9" |
|-
| style="text-align:left;" | Bitwise
| style="" | [[#AND|AND]]
| style="" | [[#OR|OR]]
| style="" | [[#XOR|XOR]]
| style="" | [[#NOT|NOT]]
| style="" | [[#TEST|TEST]]
| colspan="11" |
|-
| style="text-align:left;" | Branch
| style="border-right:none;" | [[#JC|JC]]
| style="border-left:none;" | [[#JNC|JNC]]
| style="border-right:none;" | [[#JZ|JZ]]
| style="border-left:none;" | [[#JNZ|JNZ]]
| style="border-right:none;" | [[#JBE|JBE]]
| style="border-left:none;" | [[#JA|JA]]
| style="border-right:none;" | [[#JO|JO]]
| style="border-left:none;" | [[#JNO|JNO]]
| style="border-right:none;" | [[#JP|JP]]
| style="border-left:none;" | [[#JNP|JNP]]
| style="border-right:none;" | [[#JS|JS]]
| style="border-left:none;" | [[#JNS|JNS]]
| style="border-right:none;" | [[#JL|JL]]
| style="border-left:none;" | [[#JGE|JGE]]
| style="border-right:none;" | [[#JLE|JLE]]
| style="border-left:none;" | [[#JG|JG]]
|-
| style="text-align:left;" | Jump
| style="" | [[#JMP|JMP]]
| style="border-right:none;" | [[#CALL|CALL]]
| style="border-left:none;border-right:none;" | [[#RET|RET]]
| style="border-left:none;" | [[#RETF|RETF]]
| colspan="12" |
|-
| style="text-align:left;" | Loop
| style="" | [[#LOOP|LOOP]]
| style="" | [[#LOOPE|LOOPE]]
| style="" | [[#LOOPNE|LOOPNE]]
| colspan="13" |
|-
| style="text-align:left;" | Interrupt
| style="border-right:none;" | [[#INT|INT]]
| style="border-left:none;" | [[#IRET|IRET]]
| style="" | [[#INTO|INTO]]
| style="" | [[#HLT|HLT]]
| style="" | [[#BOUND|BOUND]]
| colspan="11" |
|-
| style="text-align:left;" | Stack
| style="border-right:none;" | [[#PUSH|PUSH]]
| style="border-left:none;" | [[#POP|POP]]
| style="border-right:none;" | [[#PUSHA|PUSHA]]
| style="border-left:none;" | [[#POPA|POPA]]
| style="border-right:none;" | [[#PUSHF|PUSHF]]
| style="border-left:none;" | [[#POPF|POPF]]
| colspan="10" |
|-
| style="text-align:left;" | Flags
| style="border-right:none;" | [[#CLC|CLC]]
| style="border-left:none;" | [[#STC|STC]]
| style="border-right:none;" | [[#CLD|CLD]]
| style="border-left:none;" | [[#STD|STD]]
| style="border-right:none;" | [[#CLI|CLI]]
| style="border-left:none;" | [[#STI|STI]]
| style="" | [[#CMC|CMC]]
| style="border-right:none;" | [[#LAHF|LAHF]]
| style="border-left:none;" | [[#SAHF|SAHF]]
| colspan="7" |
|-
| style="text-align:left;" | Prefix
| style="" | [[#CS|CS]]
| style="" | [[#DS|DS]]
| style="" | [[#ES|ES]]
| style="" | [[#SS|SS]]
| colspan="12" |
|-
| style="text-align:left;" | String
| style="border-right:none;" | [[#REP|REP]]
| style="border-left:none;border-right:none;" | [[#REP|REPE]]
| style="border-left:none;" | [[#REPNE|REPNE]]
| style="" | [[#MOVSB|MOVSB]]
| style="" | [[#MOVSW|MOVSW]]
| style="border-right:none;" | [[#LODSB|LODSB]]
| style="border-left:none;" | [[#STOSB|STOSB]]
| style="border-right:none;" | [[#LODSW|LODSW]]
| style="border-left:none;" | [[#STOSW|STOSW]]
| style="" | [[#CMPSB|CMPSB]]
| style="" | [[#SCASB|SCASB]]
| style="" | [[#CMPSW|CMPSW]]
| style="" | [[#SCASW|SCASW]]
| colspan="3" |
|-
| style="text-align:left;" | Other
| style="" | [[#NOP|NOP]]
| style="border-right:none;" | [[#ENTER|ENTER]]
| style="border-left:none;" | [[#LEAVE|LEAVE]]
| style="" | [[#LOCK|LOCK]]
| style="" | [[#POLL|POLL]]
| colspan="11" |
|}
== Instruction encoding ==
=== ModR/M byte ===
The ModR/M byte is used in most addressing modes which reference a memory location. This byte consists of three bitfield values:
* <tt>oo</tt> - M'''o'''de;
* <tt>rrr</tt> - Two possible functions:
** '''R'''egister (for addressing modes which require both a register and a register/memory operand),
** Opcode extension (for some opcodes' addressing modes which do not have such a requirement);
* <tt>mmm</tt> - Register/'''M'''emory.
The ''Mode'' and ''Register/Memory'' bitfields can refer to a memory location or to a register, as shown in the table below. In some addressing modes, the ''Register'' field also refers to a register; it is always interpreted as if ''Mode'' was equal to <tt>11</tt>.
{| class="wikitable" style="text-align: center"
! R/M \ Mode
! <tt>00</tt>
! <tt>01</tt>
! <tt>10</tt>
! <tt>11</tt> ''(byte)''
! <tt>11</tt> ''(word)''
|-
| <tt>000</tt>
| DS:[BX + SI]
| DS:[BX + SI + disp8]
| DS:[BX + SI + disp16]
| AL
| AX
|-
| <tt>001</tt>
| DS:[BX + DI]
| DS:[BX + DI + disp8]
| DS:[BX + DI + disp16]
| CL
| CX
|-
| <tt>010</tt>
| SS:[BP + SI]
| SS:[BP + SI + disp8]
| SS:[BP + SI + disp16]
| DL
| DX
|-
| <tt>011</tt>
| SS:[BP + DI]
| SS:[BP + DI + disp8]
| SS:[BP + DI + disp16]
| BL
| BX
|-
| <tt>100</tt>
| DS:[SI]
| DS:[SI + disp8]
| DS:[SI + disp16]
| AH
| SP
|-
| <tt>101</tt>
| DS:[DI]
| DS:[DI + disp8]
| DS:[DI + disp16]
| CH
| BP
|-
| <tt>110</tt>
| ''DS:[disp16]''
| SS:[BP + disp8]
| SS:[BP + disp16]
| DH
| SI
|-
| <tt>111</tt>
| DS:[BX]
| DS:[BX + disp8]
| DS:[BX + disp16]
| BH
| DI
|}
Note that (<tt>oo</tt> = <tt>00</tt>, <tt>mmm</tt> = <tt>110</tt>) is a special case. Displacements are either 8-bit (disp8) or 16-bit (disp16) signed values and they always immediately follow the ModR/M byte.
The instruction encoding lists below refer to this byte as <tt>oorrrmmm</tt> (binary), <tt>/r</tt> (hexadecimal) or <tt>/0</tt> (hexademical, <tt>rrr</tt> used as function <tt>0</tt>).
== Official instructions ==
{{Anchor|AAA}}
=== AAA ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| AAA || <tt>37</tt> || <tt>00110111</tt> || 1 || 9
|}
----
{{Anchor|AAD}}
=== AAD ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| AAD imm8 || <tt>B5 ii</tt> || <tt>11010100 iiiiiiii</tt> || 2 || 6
|}
----
{{Anchor|AAM}}
=== AAM ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| AAM imm8 || <tt>B4 ii</tt> || <tt>11010100 iiiiiiii</tt> || 2 || 17
|}
----
{{Anchor|AAS}}
=== AAS ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| AAS || <tt>3F</tt> || <tt>00111111</tt> || 1 || 9
|}
----
{{Anchor|ADC}}
=== ADC ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| ADC AL, imm || <tt>14 ii</tt> || <tt>00010100 iiiiiiii</tt> || 2 || 1
|-
| ADC AX, imm || <tt>15 ii ii</tt> || <tt>00010101 iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| ADC mem8, imm8 || <tt>80 /2 ii</tt> || <tt>10000000 oo010mmm iiiiiiii</tt> || 3+ || 3
|-
| ADC mem16, imm16 || <tt>81 /2 ii ii</tt> || <tt>10000001 oo010mmm iiiiiiii iiiiiiii</tt> || 4+ || 3
|-
| ADC mem16, simm8 || <tt>83 /2 ii ii</tt> || <tt>10000011 oo010mmm iiiiiiii iiiiiiii</tt> || 4+ || 3
|-
| ADC mem8, reg8 || <tt>10 /r</tt> || <tt>00010000 oorrrmmm</tt> || 2+ || 3
|-
| ADC mem16, reg16 || <tt>11 /r</tt> || <tt>00010001 oorrrmmm</tt> || 2+ || 3
|-
| ADC reg8, imm8 || <tt>80 /2 ii</tt> || <tt>10000000 11010mmm iiiiiiii</tt> || 3+ || 1
|-
| ADC reg16, imm16 || <tt>81 /2 ii ii</tt> || <tt>10000001 11010mmm iiiiiiii iiiiiiii</tt> || 4+ || 1
|-
| ADC reg16, simm8 || <tt>83 /2 ii ii</tt> || <tt>10000011 11010mmm iiiiiiii iiiiiiii</tt> || 4+ || 1
|-
| ADC reg8, mem8 || <tt>12 /r</tt> || <tt>00010010 oorrrmmm</tt> || 2+ || 2
|-
| ADC reg16, mem16 || <tt>13 /r</tt> || <tt>00010011 oorrrmmm</tt> || 2+ || 2
|-
| ADC reg8, reg8 || <tt>10 /r</tt> || <tt>000100.0 11rrrmmm</tt> || 2 || 1
|-
| ADC reg16, reg16 || <tt>11 /r</tt> || <tt>000100.1 11rrrmmm</tt> || 2 || 1
|}
----
{{Anchor|ADD}}
=== ADD ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| ADD AL, imm || <tt>04 ii</tt> || <tt>00000100 iiiiiiii</tt> || 2 || 1
|-
| ADD AX, imm || <tt>05 ii ii</tt> || <tt>00000101 iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| ADD mem8, imm8 || <tt>80 /0 ii</tt> || <tt>10000000 oo000mmm iiiiiiii</tt> || 3+ || 3
|-
| ADD mem16, imm16 || <tt>81 /0 ii ii</tt> || <tt>10000001 oo000mmm iiiiiiii iiiiiiii</tt> || 4+ || 3
|-
| ADD mem16, simm8 || <tt>83 /0 ii ii</tt> || <tt>10000011 oo000mmm iiiiiiii iiiiiiii</tt> || 4+ || 3
|-
| ADD mem8, reg8 || <tt>00 /r</tt> || <tt>00000000 oorrrmmm</tt> || 2+ || 3
|-
| ADD mem16, reg16 || <tt>01 /r</tt> || <tt>00000001 oorrrmmm</tt> || 2+ || 3
|-
| ADD reg8, imm8 || <tt>80 /0 ii</tt> || <tt>10000000 11000mmm iiiiiiii</tt> || 3+ || 1
|-
| ADD reg16, imm16 || <tt>81 /0 ii ii</tt> || <tt>10000001 11000mmm iiiiiiii iiiiiiii</tt> || 4+ || 1
|-
| ADD reg16, simm8 || <tt>83 /0 ii ii</tt> || <tt>10000011 11000mmm iiiiiiii iiiiiiii</tt> || 4+ || 1
|-
| ADD reg8, mem8 || <tt>02 /r</tt> || <tt>00000010 oorrrmmm</tt> || 2+ || 2
|-
| ADD reg16, mem16 || <tt>03 /r</tt> || <tt>00000011 oorrrmmm</tt> || 2+ || 2
|-
| ADD reg8, reg8 || <tt>00 /r</tt> || <tt>000000.0 11rrrmmm</tt> || 2 || 1
|-
| ADD reg16, reg16 || <tt>01 /r</tt> || <tt>000000.1 11rrrmmm</tt> || 2 || 1
|}
----
{{Anchor|AND}}
=== AND ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| AND AL, imm || <tt>24 ii</tt> || <tt>00100100 iiiiiiii</tt> || 2 || 1
|-
| AND AX, imm || <tt>25 ii ii</tt> || <tt>00100101 iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| AND mem8, imm8 || <tt>80 /4 ii</tt> || <tt>10000000 oo100mmm iiiiiiii</tt> || 3+ || 3
|-
| AND mem16, imm16 || <tt>81 /4 ii ii</tt> || <tt>10000001 oo100mmm iiiiiiii iiiiiiii</tt> || 4+ || 3
|-
| AND mem16, simm8 || <tt>83 /4 ii ii</tt> || <tt>10000011 oo100mmm iiiiiiii iiiiiiii</tt> || 4+ || 3
|-
| AND mem8, reg8 || <tt>20 /r</tt> || <tt>00100000 oorrrmmm</tt> || 2+ || 3
|-
| AND mem16, reg16 || <tt>21 /r</tt> || <tt>00100001 oorrrmmm</tt> || 2+ || 3
|-
| AND reg8, imm8 || <tt>80 /4 ii</tt> || <tt>10000000 11100mmm iiiiiiii</tt> || 3+ || 1
|-
| AND reg16, imm16 || <tt>81 /4 ii ii</tt> || <tt>10000001 11100mmm iiiiiiii iiiiiiii</tt> || 4+ || 1
|-
| AND reg16, simm8 || <tt>83 /4 ii ii</tt> || <tt>10000011 11100mmm iiiiiiii iiiiiiii</tt> || 4+ || 1
|-
| AND reg8, mem8 || <tt>22 /r</tt> || <tt>00100010 oorrrmmm</tt> || 2+ || 2
|-
| AND reg16, mem16 || <tt>23 /r</tt> || <tt>00100011 oorrrmmm</tt> || 2+ || 2
|-
| AND reg8, reg8 || <tt>20 /r</tt> || <tt>001000.0 11rrrmmm</tt> || 2 || 1
|-
| AND reg16, reg16 || <tt>21 /r</tt> || <tt>001000.1 11rrrmmm</tt> || 2 || 1
|}
----
{{Anchor|BOUND}}
=== BOUND ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| BOUND reg16, mem16:16 || <tt>62 /r</tt> || <tt>01100010 oorrrmmm</tt> || 2+ || 13 (20 if condition met)
|}
----
{{Anchor|CALL}}
=== CALL ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| CALL ptr16:16 || <tt>CA oo oo ss ss</tt> || <tt>10011010 oooooooo oooooooo ssssssss ssssssss</tt> || 5 || 10
|-
| CALL mem16 || <tt>FF /2</tt> || <tt>11111111 oo010mmm</tt> || 2+ || 6
|-
| CALL mem16:16 || <tt>FF /3</tt> || <tt>11111111 oo011mmm</tt> || 2+ || 12
|-
| CALL reg16 || <tt>FF /2</tt> || <tt>11111111 11010mmm</tt> || 2 || 5
|-
| CALL rel16 || <tt>E8 ii ii</tt> || <tt>11101000 iiiiiiii iiiiiiii</tt> || 3 || 5
|}
----
{{Anchor|CBW}}
=== CBW ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| CBW || <tt>98</tt> || <tt>10011000</tt> || 1 || 1
|}
----
{{Anchor|CLC}}
=== CLC ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| CLC || <tt>F8</tt> || <tt>11111000</tt> || 1 || 4
|}
----
{{Anchor|CLD}}
=== CLD ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| CLD || <tt>FC</tt> || <tt>11111100</tt> || 1 || 4
|}
----
{{Anchor|CLI}}
=== CLI ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| CLI || <tt>FA</tt> || <tt>11111010</tt> || 1 || 4
|}
----
{{Anchor|CMC}}
=== CMC ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| CMC || <tt>F5</tt> || <tt>11110101</tt> || 1 || 4
|}
----
{{Anchor|CMP}}
=== CMP ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| CMP AL, imm || <tt>3C ii</tt> || <tt>00111100 iiiiiiii</tt> || 2 || 1
|-
| CMP AX, imm || <tt>3D ii ii</tt> || <tt>00111101 iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| CMP mem8, imm8 || <tt>80 /7 ii</tt> || <tt>10000000 oo111mmm iiiiiiii</tt> || 3+ || 2
|-
| CMP mem16, imm16 || <tt>81 /7 ii ii</tt> || <tt>10000001 oo111mmm iiiiiiii iiiiiiii</tt> || 4+ || 2
|-
| CMP mem16, simm8 || <tt>83 /7 ii ii</tt> || <tt>10000011 oo111mmm iiiiiiii iiiiiiii</tt> || 4+ || 2
|-
| CMP mem8, reg8 || <tt>38 /r</tt> || <tt>00111000 oorrrmmm</tt> || 2+ || 2
|-
| CMP mem16, reg16 || <tt>39 /r</tt> || <tt>00111001 oorrrmmm</tt> || 2+ || 2
|-
| CMP reg8, imm8 || <tt>80 /7 ii</tt> || <tt>10000000 11111mmm iiiiiiii</tt> || 3+ || 1
|-
| CMP reg16, imm16 || <tt>81 /7 ii ii</tt> || <tt>10000001 11111mmm iiiiiiii iiiiiiii</tt> || 4+ || 1
|-
| CMP reg16, simm8 || <tt>83 /7 ii ii</tt> || <tt>10000011 11111mmm iiiiiiii iiiiiiii</tt> || 4+ || 1
|-
| CMP reg8, mem8 || <tt>3A /r</tt> || <tt>00111010 oorrrmmm</tt> || 2+ || 2
|-
| CMP reg16, mem16 || <tt>3B /r</tt> || <tt>00111011 oorrrmmm</tt> || 2+ || 2
|-
| CMP reg8, reg8 || <tt>38 /r</tt> || <tt>001110.0 11rrrmmm</tt> || 2 || 1
|-
| CMP reg16, reg16 || <tt>39 /r</tt> || <tt>001110.1 11rrrmmm</tt> || 2 || 1
|}
----
{{Anchor|CMPSB}}
=== CMPSB ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| CMPSB || <tt>A6</tt> || <tt>10100110</tt> || 1 || 6
|}
----
{{Anchor|CMPSW}}
=== CMPSW ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| CMPSW || <tt>A7</tt> || <tt>10100111</tt> || 1 || 6
|}
----
{{Anchor|CS}}
=== CS ===
----
{{Anchor|CWD}}
=== CWD ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| CWD || <tt>99</tt> || <tt>10011001</tt> || 1 || 1
|}
----
{{Anchor|DAA}}
=== DAA ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| DAA || <tt>27</tt> || <tt>00100111</tt> || 1 || 10
|}
----
{{Anchor|DAS}}
=== DAS ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| DAS || <tt>2F</tt> || <tt>00101111</tt> || 1 || 10
|}
----
{{Anchor|DEC}}
=== DEC ===
----
{{Anchor|DIV}}
=== DIV ===
----
{{Anchor|DS}}
=== DS ===
----
{{Anchor|ENTER}}
=== ENTER ===
----
{{Anchor|ES}}
=== ES ===
----
{{Anchor|HLT}}
=== HLT ===
----
{{Anchor|IDIV}}
=== IDIV ===
----
{{Anchor|IMUL}}
=== IMUL ===
----
{{Anchor|IN}}
=== IN ===
----
{{Anchor|INC}}
=== INC ===
----
{{Anchor|INSB}}
=== INSB ===
----
{{Anchor|INSW}}
=== INSW ===
----
{{Anchor|INT}}
=== INT ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| INT 3 || <tt>CC</tt> || <tt>11001100</tt> || 1 || 9
|-
| INT imm8 || <tt>CD ii</tt> || <tt>11001101 iiiiiiii</tt> || 2 || 10
|}
----
{{Anchor|INTO}}
=== INTO ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| INTO || <tt>CE</tt> || <tt>11001110</tt> || 1 || 6 (13 if OF = 1)
|}
----
{{Anchor|IRET}}
=== IRET ===
----
{{Anchor|JA}}
=== JA ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JA rel8 || <tt>77 ii</tt> || <tt>01110111 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JBE}}
=== JBE ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JA rel8 || <tt>76 ii</tt> || <tt>01110110 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JC}}
=== JC/JB ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JC rel8 || <tt>72 ii</tt> || <tt>01110010 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JCXZ}}
=== JCXZ ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JCXZ rel8 || <tt>E3 ii</tt> || <tt>11100011 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JG}}
=== JG ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JG rel8 || <tt>7F ii</tt> || <tt>01111111 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JGE}}
=== JGE ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JGE rel8 || <tt>7D ii</tt> || <tt>01111101 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JL}}
=== JL ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JL rel8 || <tt>7C ii</tt> || <tt>01111100 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JLE}}
=== JLE ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JLE rel8 || <tt>7E ii</tt> || <tt>01111110 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JMP}}
=== JMP ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JMP ptr16:16 || <tt>EA oo oo ss ss</tt> || <tt>11101010 oooooooo oooooooo ssssssss ssssssss</tt> || 5 || 7
|-
| JMP mem16 || <tt>FF /4</tt> || <tt>11111111 oo100mmm</tt> || 2+ || 5
|-
| JMP mem16:16 || <tt>FF /5</tt> || <tt>11111111 oo101mmm</tt> || 2+ || 10
|-
| JMP reg16 || <tt>FF /4</tt> || <tt>11111111 11100mmm</tt> || 2 || 4
|-
| JMP rel8 || <tt>EB ii</tt> || <tt>11101011 iiiiiiii</tt> || 2 || 4
|-
| JMP rel16 || <tt>E9 ii ii</tt> || <tt>11101001 iiiiiiii iiiiiiii</tt> || 3 || 4
|}
----
{{Anchor|JNC}}
=== JNC/JAE ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JNC rel8 || <tt>73 ii</tt> || <tt>01110011 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JNO}}
=== JNO ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JNO rel8 || <tt>71 ii</tt> || <tt>01110001 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JNP}}
=== JNP ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JNP rel8 || <tt>7B ii</tt> || <tt>01111011 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JNS}}
=== JNS ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JNS rel8 || <tt>79 ii</tt> || <tt>01111001 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JNZ}}
=== JNZ/JNE ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JNZ rel8 || <tt>75 ii</tt> || <tt>01110101 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JO}}
=== JO ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JO rel8 || <tt>70 ii</tt> || <tt>01110000 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JP}}
=== JP ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JP rel8 || <tt>7A ii</tt> || <tt>01111010 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JS}}
=== JS ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JS rel8 || <tt>78 ii</tt> || <tt>01111000 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JZ}}
=== JZ/JE ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JZ rel8 || <tt>74 ii</tt> || <tt>01110100 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|LAHF}}
=== LAHF ===
----
{{Anchor|LDS}}
=== LDS ===
----
{{Anchor|LEA}}
=== LEA ===
----
{{Anchor|LEAVE}}
=== LEAVE ===
----
{{Anchor|LES}}
=== LES ===
----
{{Anchor|LOCK}}
=== LOCK ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| LOCK || <tt>F0</tt> || <tt>11110000</tt> || 1 || 1
|}
----
{{Anchor|LODSB}}
=== LODSB ===
----
{{Anchor|LODSW}}
=== LODSW ===
----
{{Anchor|LOOP}}
=== LOOP ===
----
{{Anchor|LOOPE}}
=== LOOPE ===
----
{{Anchor|LOOPNE}}
=== LOOPNE ===
----
{{Anchor|MOV}}
=== MOV ===
----
{{Anchor|MOVSB}}
=== MOVSB ===
----
{{Anchor|MOVSW}}
=== MOVSW ===
----
{{Anchor|MUL}}
=== MUL ===
----
{{Anchor|NEG}}
=== NEG ===
----
{{Anchor|NOP}}
=== NOP ===
----
{{Anchor|NOT}}
=== NOT ===
----
{{Anchor|OR}}
=== OR ===
----
{{Anchor|OUT}}
=== OUT ===
----
{{Anchor|OUTSB}}
=== OUTSB ===
----
{{Anchor|OUTSW}}
=== OUTSW ===
----
{{Anchor|POLL}}
=== POLL ===
----
{{Anchor|POP}}
=== POP ===
----
{{Anchor|POPA}}
=== POPA ===
----
{{Anchor|POPF}}
=== POPF ===
----
{{Anchor|PUSH}}
=== PUSH ===
----
{{Anchor|PUSHA}}
=== PUSHA ===
----
{{Anchor|PUSHF}}
=== PUSHF ===
----
{{Anchor|RCL}}
=== RCL ===
----
{{Anchor|RCR}}
=== RCR ===
----
{{Anchor|REP}}
=== REP/REPE/REPZ ===
----
{{Anchor|REPNE}}
=== REPNE/REPNZ ===
----
{{Anchor|RET}}
=== RET ===
----
{{Anchor|RETF}}
=== RETF ===
----
{{Anchor|ROL}}
=== ROL ===
----
{{Anchor|ROR}}
=== ROR ===
----
{{Anchor|SAHF}}
=== SAHF ===
----
{{Anchor|SAR}}
=== SAR ===
----
{{Anchor|SBB}}
=== SBB ===
----
{{Anchor|SCASB}}
=== SCASB ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| SCASB || <tt>AE</tt> || <tt>10101110</tt> || 1 || 4
|}
----
{{Anchor|SCASW}}
=== SCASW ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| SCASW || <tt>AF</tt> || <tt>10101111</tt> || 1 || 4
|}
----
{{Anchor|SHL}}
=== SHL ===
----
{{Anchor|SHR}}
=== SHR ===
----
{{Anchor|SS}}
=== SS ===
----
{{Anchor|STC}}
=== STC ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| STC || <tt>F9</tt> || <tt>11111001</tt> || 1 || 4
|}
----
{{Anchor|STD}}
=== STD ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| STD || <tt>FD</tt> || <tt>11111101</tt> || 1 || 4
|}
----
{{Anchor|STI}}
=== STI ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| STI || <tt>FB</tt> || <tt>11111011</tt> || 1 || 4
|}
----
{{Anchor|STOSB}}
=== STOSB ===
----
{{Anchor|STOSW}}
=== STOSW ===
----
{{Anchor|SUB}}
=== SUB ===
----
{{Anchor|TEST}}
=== TEST ===
----
{{Anchor|XCHG}}
=== XCHG ===
----
{{Anchor|XLAT}}
=== XLAT ===
----
{{Anchor|XOR}}
=== XOR ===
----
3d169338085fef12c5d7fdaf56da29438f35d13b
450
449
2024-12-26T19:51:24Z
Asie
351
/* Instruction encoding */
wikitext
text/x-wiki
__NOTOC__
Note that this page is a work in progress.
{| class="wikitable" style="text-align: center"
|+ Official V30MZ (80186) Instructions
|-
| [[#AAA|AAA]] || [[#AAD|AAD]] || [[#AAM|AAM]] || [[#AAS|AAS]] || [[#ADC|ADC]] || [[#ADD|ADD]] || [[#AND|AND]] || [[#BOUND|BOUND]] || [[#CALL|CALL]] || [[#CBW|CBW]] || [[#CLC|CLC]]
|-
| [[#CLD|CLD]] || [[#CLI|CLI]] || [[#CMC|CMC]] || [[#CMP|CMP]] || [[#CMPSB|CMPSB]] || [[#CMPSW|CMPSW]] || [[#CS|CS]] || [[#CWD|CWD]] || [[#DAA|DAA]] || [[#DAS|DAS]] || [[#DEC|DEC]]
|-
| [[#DIV|DIV]] || [[#DS|DS]] || [[#ENTER|ENTER]] || [[#ES|ES]] || [[#HLT|HLT]] || [[#IDIV|IDIV]] || [[#IMUL|IMUL]] || [[#IN|IN]] || [[#INC|INC]] || [[#INSB|INSB]] || [[#INSW|INSW]]
|-
| [[#INT|INT]] || [[#INTO|INTO]] || [[#IRET|IRET]] || [[#JA|JA]] || [[#JBE|JBE]] || [[#JC|JC]] || [[#JCXZ|JCXZ]] || [[#JG|JG]] || [[#JGE|JGE]] || [[#JL|JL]] || [[#JLE|JLE]]
|-
| [[#JMP|JMP]] || [[#JNC|JNC]] || [[#JNO|JNO]] || [[#JNP|JNP]] || [[#JNS|JNS]] || [[#JNZ|JNZ]] || [[#JO|JO]] || [[#JP|JP]] || [[#JS|JS]] || [[#JZ|JZ]] || [[#LAHF|LAHF]]
|-
| [[#LDS|LDS]] || [[#LEA|LEA]] || [[#LEAVE|LEAVE]] || [[#LES|LES]] || [[#LOCK|LOCK]] || [[#LODSB|LODSB]] || [[#LODSW|LODSW]] || [[#LOOP|LOOP]] || [[#LOOPE|LOOPE]] || [[#LOOPNE|LOOPNE]] || [[#MOV|MOV]]
|-
| [[#MOVSB|MOVSB]] || [[#MOVSW|MOVSW]] || [[#MUL|MUL]] || [[#NEG|NEG]] || [[#NOP|NOP]] || [[#NOT|NOT]] || [[#OR|OR]] || [[#OUT|OUT]] || [[#OUTSB|OUTSB]] || [[#OUTSW|OUTSW]] || [[#POLL|POLL]]
|-
| [[#POP|POP]] || [[#POPA|POPA]] || [[#POPF|POPF]] || [[#PUSH|PUSH]] || [[#PUSHA|PUSHA]] || [[#PUSHF|PUSHF]] || [[#RCL|RCL]] || [[#RCR|RCR]] || [[#REP|REP]] || [[#REPNE|REPNE]] || [[#RET|RET]]
|-
| [[#RETF|RETF]] || [[#ROL|ROL]] || [[#ROR|ROR]] || [[#SAHF|SAHF]] || [[#SAR|SAR]] || [[#SBB|SBB]] || [[#SCASB|SCASB]] || [[#SCASW|SCASW]] || [[#SHL|SHL]] || [[#SHR|SHR]] || [[#SS|SS]]
|-
| [[#STC|STC]] || [[#STD|STD]] || [[#STI|STI]] || [[#STOSB|STOSB]] || [[#STOSW|STOSW]] || [[#SUB|SUB]] || [[#TEST|TEST]] || [[#XCHG|XCHG]] || [[#XLAT|XLAT]] || [[#XOR|XOR]]
|}
{| class="mw-collapsible mw-collapsed wikitable sortable" style="width: 340px;"
|+ style="white-space:nowrap; border:1px solid; padding:3px; border-color:rgb(162, 169, 177); background-color:rgb(234, 236, 240);" | Intel <-> NEC mnemonic translation table
!Intel
!NEC
|-
| [[#AAA|AAA]]
| [[#AAA|ADJBA]]
|-
| [[#AAD|AAD]]
| [[#AAD|CVTDB]]
|-
| [[#AAM|AAM]]
| [[#AAM|CVTBD]]
|-
| [[#AAS|AAS]]
| [[#AAS|ADJBS]]
|-
| [[#ADC|ADC]]
| [[#ADC|ADDC]]
|-
| [[#ADD|ADD]]
| [[#ADD|ADD]]
|-
| [[#AND|AND]]
| [[#AND|AND]]
|-
| [[#BOUND|BOUND]]
| [[#BOUND|CHKIND]]
|-
| [[#CALL|CALL]]
| [[#CALL|CALL]]
|-
| [[#CBW|CBW]]
| [[#CBW|CVTBW]]
|-
| [[#CLC|CLC]]
| [[#CLC|CLR1 CY]]
|-
| [[#CLD|CLD]]
| [[#CLD|CLR1 DIR]]
|-
| [[#CLI|CLI]]
| [[#CLI|DI]]
|-
| [[#CMC|CMC]]
| [[#CMC|NOT1 CY]]
|-
| [[#CMP|CMP]]
| [[#CMP|CMP]]
|-
| [[#CMPSB|CMPSB]]
| [[#CMPSB|CMPBKB]]
|-
| [[#CMPSW|CMPSW]]
| [[#CMPSW|CMPBKW]]
|-
| [[#CS|CS]]
| [[#CS|PS]]
|-
| [[#CWD|CWD]]
| [[#CWD|CVTWL]]
|-
| [[#DAA|DAA]]
| [[#DAA|ADJ4A]]
|-
| [[#DAS|DAS]]
| [[#DAS|ADJ4S]]
|-
| [[#DEC|DEC]]
| [[#DEC|DEC]]
|-
| [[#DIV|DIV]]
| [[#DIV|DIVU]]
|-
| [[#DS|DS]]
| [[#DS|DS0]]
|-
| [[#ENTER|ENTER]]
| [[#ENTER|PREPARE]]
|-
| [[#ES|ES]]
| [[#ES|DS1]]
|-
| [[#HLT|HLT]]
| [[#HLT|HALT]]
|-
| [[#IDIV|IDIV]]
| [[#IDIV|DIV]]
|-
| [[#IMUL|IMUL]]
| [[#IMUL|MUL]]
|-
| [[#IN|IN]]
| [[#IN|IN]]
|-
| [[#INC|INC]]
| [[#INC|INC]]
|-
| [[#INSB|INSB]]
| [[#INSB|INMB]]
|-
| [[#INSW|INSW]]
| [[#INSW|INMW]]
|-
| [[#INT|INT]]
| [[#INT|BRK]]
|-
| [[#INTO|INTO]]
| [[#INTO|BRKV]]
|-
| [[#IRET|IRET]]
| [[#IRET|RETI]]
|-
| [[#JA|JA]]
| [[#JA|BH]]
|-
| [[#JBE|JBE]]
| [[#JBE|BNH]]
|-
| [[#JC|JC/JB]]
| [[#JC|BC/BL]]
|-
| [[#JCXZ|JCXZ]]
| [[#JCXZ|BCWZ]]
|-
| [[#JG|JG]]
| [[#JG|BGT]]
|-
| [[#JGE|JGE]]
| [[#JGE|BGE]]
|-
| [[#JL|JL]]
| [[#JL|BLT]]
|-
| [[#JLE|JLE]]
| [[#JLE|BLE]]
|-
| [[#JMP|JMP]]
| [[#JMP|BR]]
|-
| [[#JNC|JNC/JAE]]
| [[#JNC|BNC/BNL]]
|-
| [[#JNO|JNO]]
| [[#JNO|BNV]]
|-
| [[#JNP|JNP]]
| [[#JNP|BPO]]
|-
| [[#JNS|JNS]]
| [[#JNS|BP]]
|-
| [[#JNZ|JNZ/JNE]]
| [[#JNZ|BNZ/BNE]]
|-
| [[#JO|JO]]
| [[#JO|BV]]
|-
| [[#JP|JP]]
| [[#JP|BPE]]
|-
| [[#JS|JS]]
| [[#JS|BN]]
|-
| [[#JZ|JZ/JE]]
| [[#JZ|BZ/BE]]
|-
| [[#LAHF|LAHF]]
| [[#LAHF|MOV]]
|-
| [[#LDS|LDS]]
| [[#LDS|MOV]]
|-
| [[#LEA|LEA]]
| [[#LEA|LDEA]]
|-
| [[#LEAVE|LEAVE]]
| [[#LEAVE|DISPOSE]]
|-
| [[#LES|LES]]
| [[#LES|MOV]]
|-
| [[#LOCK|LOCK]]
| [[#LOCK|BUSLOCK]]
|-
| [[#LODSB|LODSB]]
| [[#LODSB|LDMB]]
|-
| [[#LODSW|LODSW]]
| [[#LODSW|LDMW]]
|-
| [[#LOOP|LOOP]]
| [[#LOOP|DBNZ]]
|-
| [[#LOOPE|LOOPE]]
| [[#LOOPE|DBNZE]]
|-
| [[#LOOPNE|LOOPNE]]
| [[#LOOPNE|DBNZNE]]
|-
| [[#MOV|MOV]]
| [[#MOV|MOV]]
|-
| [[#MOVSB|MOVSB]]
| [[#MOVSB|MOVBKB]]
|-
| [[#MOVSW|MOVSW]]
| [[#MOVSW|MOVBKW]]
|-
| [[#MUL|MUL]]
| [[#MUL|MULU]]
|-
| [[#NEG|NEG]]
| [[#NEG|NEG]]
|-
| [[#NOP|NOP]]
| [[#NOP|NOP]]
|-
| [[#NOT|NOT]]
| [[#NOT|NOT]]
|-
| [[#OR|OR]]
| [[#OR|OR]]
|-
| [[#OUT|OUT]]
| [[#OUT|OUT]]
|-
| [[#OUTSB|OUTSB]]
| [[#OUTSB|OUTM]]
|-
| [[#OUTSW|OUTSW]]
| [[#OUTSW|OUTM]]
|-
| [[#POLL|POLL]]
| [[#POLL|POLL]]
|-
| [[#POP|POP]]
| [[#POP|POP]]
|-
| [[#POPA|POPA]]
| [[#POPA|POP]]
|-
| [[#POPF|POPF]]
| [[#POPF|POP]]
|-
| [[#PUSH|PUSH]]
| [[#PUSH|PUSH]]
|-
| [[#PUSHA|PUSHA]]
| [[#PUSHA|PUSH]]
|-
| [[#PUSHF|PUSHF]]
| [[#PUSHF|PUSH]]
|-
| [[#RCL|RCL]]
| [[#RCL|ROLC]]
|-
| [[#RCR|RCR]]
| [[#RCR|RORC]]
|-
| [[#REP|REP/REPE/REPZ]]
| [[#REP|REP/REPE/REPZ]]
|-
| [[#REPNE|REPNE/REPNZ]]
| [[#REPNE|REPNE/REPNZ]]
|-
| [[#RET|RET]]
| [[#RET|RET]]
|-
| [[#RETF|RETF]]
| [[#RETF|RET]]
|-
| [[#ROL|ROL]]
| [[#ROL|ROL]]
|-
| [[#ROR|ROR]]
| [[#ROR|ROR]]
|-
| [[#SAHF|SAHF]]
| [[#SAHF|MOV]]
|-
| [[#SAR|SAR]]
| [[#SAR|SHRA]]
|-
| [[#SBB|SBB]]
| [[#SBB|SUBC]]
|-
| [[#SCASB|SCASB]]
| [[#SCASB|CMPMB]]
|-
| [[#SCASW|SCASW]]
| [[#SCASW|CMPMW]]
|-
| [[#SHL|SHL]]
| [[#SHL|SHL]]
|-
| [[#SHR|SHR]]
| [[#SHR|SHR]]
|-
| [[#SS|SS]]
| [[#SS|SS]]
|-
| [[#STC|STC]]
| [[#STC|SET1 CY]]
|-
| [[#STD|STD]]
| [[#STD|SET1 DIR]]
|-
| [[#STI|STI]]
| [[#STI|EI]]
|-
| [[#STOSB|STOSB]]
| [[#STOSB|STMB]]
|-
| [[#STOSW|STOSW]]
| [[#STOSW|STMW]]
|-
| [[#SUB|SUB]]
| [[#SUB|SUB]]
|-
| [[#TEST|TEST]]
| [[#TEST|TEST]]
|-
| [[#XCHG|XCHG]]
| [[#XCHG|XCH]]
|-
| [[#XLAT|XLAT]]
| [[#XLAT|TRANS]]
|-
| [[#XOR|XOR]]
| [[#XOR|XOR]]
|}
== Official instructions by type ==
{| class="wikitable sortable" style="text-align: center"
!Type
!colspan=16 class="unsortable" | Instructions
|-
| style="text-align:left;" | Memory
| style="" | [[#MOV|MOV]]
| style="" | [[#XCHG|XCHG]]
| style="" | [[#XLAT|XLAT]]
| style="" | [[#LEA|LEA]]
| style="border-right:none;" | [[#LDS|LDS]]
| style="border-left:none;" | [[#LES|LES]]
| style="border-right:none;" | [[#IN|IN]]
| style="border-left:none;" | [[#OUT|OUT]]
| colspan="8" |
|-
| style="text-align:left;" | Ports
| style="border-right:none;" | [[#IN|IN]]
| style="border-left:none;" | [[#OUT|OUT]]
| style="border-right:none;" | [[#INSB|INSB]]
| style="border-left:none;" | [[#OUTSB|OUTSB]]
| style="border-right:none;" | [[#INSW|INSW]]
| style="border-left:none;" | [[#OUTSW|OUTSW]]
| colspan="10" |
|-
| style="text-align:left;" | Arithmetic
| style="border-right:none;" | [[#ADD|ADD]]
| style="border-left:none;" | [[#SUB|SUB]]
| style="border-right:none;" | [[#ADC|ADC]]
| style="border-left:none;" | [[#SBB|SBB]]
| style="border-right:none;" | [[#INC|INC]]
| style="border-left:none;" | [[#DEC|DEC]]
| style="border-right:none;" | [[#MUL|MUL]]
| style="border-left:none;" | [[#DIV|DIV]]
| style="border-right:none;" | [[#IMUL|IMUL]]
| style="border-left:none;" | [[#IDIV|IDIV]]
| style="" | [[#CMP|CMP]]
| style="" | [[#NEG|NEG]]
| colspan="4" |
|-
| style="text-align:left;" | Numeric
| style="" | [[#CBW|CBW]]
| style="" | [[#CWD|CWD]]
| style="" | [[#AAA|AAA]]
| style="" | [[#AAS|AAS]]
| style="" | [[#AAM|AAM]]
| style="" | [[#AAD|AAD]]
| style="" | [[#DAA|DAA]]
| style="" | [[#DAS|DAS]]
| colspan="8" |
|-
| style="text-align:left;" | Shift
| style="border-right:none;" | [[#ROL|ROL]]
| style="border-left:none;" | [[#ROR|ROR]]
| style="border-right:none;" | [[#RCL|RCL]]
| style="border-left:none;" | [[#RCR|RCR]]
| style="border-right:none;" | [[#SHL|SHL]]
| style="border-left:none;" | [[#SHR|SHR]]
| style="" | [[#SAR|SAR]]
| colspan="9" |
|-
| style="text-align:left;" | Bitwise
| style="" | [[#AND|AND]]
| style="" | [[#OR|OR]]
| style="" | [[#XOR|XOR]]
| style="" | [[#NOT|NOT]]
| style="" | [[#TEST|TEST]]
| colspan="11" |
|-
| style="text-align:left;" | Branch
| style="border-right:none;" | [[#JC|JC]]
| style="border-left:none;" | [[#JNC|JNC]]
| style="border-right:none;" | [[#JZ|JZ]]
| style="border-left:none;" | [[#JNZ|JNZ]]
| style="border-right:none;" | [[#JBE|JBE]]
| style="border-left:none;" | [[#JA|JA]]
| style="border-right:none;" | [[#JO|JO]]
| style="border-left:none;" | [[#JNO|JNO]]
| style="border-right:none;" | [[#JP|JP]]
| style="border-left:none;" | [[#JNP|JNP]]
| style="border-right:none;" | [[#JS|JS]]
| style="border-left:none;" | [[#JNS|JNS]]
| style="border-right:none;" | [[#JL|JL]]
| style="border-left:none;" | [[#JGE|JGE]]
| style="border-right:none;" | [[#JLE|JLE]]
| style="border-left:none;" | [[#JG|JG]]
|-
| style="text-align:left;" | Jump
| style="" | [[#JMP|JMP]]
| style="border-right:none;" | [[#CALL|CALL]]
| style="border-left:none;border-right:none;" | [[#RET|RET]]
| style="border-left:none;" | [[#RETF|RETF]]
| colspan="12" |
|-
| style="text-align:left;" | Loop
| style="" | [[#LOOP|LOOP]]
| style="" | [[#LOOPE|LOOPE]]
| style="" | [[#LOOPNE|LOOPNE]]
| colspan="13" |
|-
| style="text-align:left;" | Interrupt
| style="border-right:none;" | [[#INT|INT]]
| style="border-left:none;" | [[#IRET|IRET]]
| style="" | [[#INTO|INTO]]
| style="" | [[#HLT|HLT]]
| style="" | [[#BOUND|BOUND]]
| colspan="11" |
|-
| style="text-align:left;" | Stack
| style="border-right:none;" | [[#PUSH|PUSH]]
| style="border-left:none;" | [[#POP|POP]]
| style="border-right:none;" | [[#PUSHA|PUSHA]]
| style="border-left:none;" | [[#POPA|POPA]]
| style="border-right:none;" | [[#PUSHF|PUSHF]]
| style="border-left:none;" | [[#POPF|POPF]]
| colspan="10" |
|-
| style="text-align:left;" | Flags
| style="border-right:none;" | [[#CLC|CLC]]
| style="border-left:none;" | [[#STC|STC]]
| style="border-right:none;" | [[#CLD|CLD]]
| style="border-left:none;" | [[#STD|STD]]
| style="border-right:none;" | [[#CLI|CLI]]
| style="border-left:none;" | [[#STI|STI]]
| style="" | [[#CMC|CMC]]
| style="border-right:none;" | [[#LAHF|LAHF]]
| style="border-left:none;" | [[#SAHF|SAHF]]
| colspan="7" |
|-
| style="text-align:left;" | Prefix
| style="" | [[#CS|CS]]
| style="" | [[#DS|DS]]
| style="" | [[#ES|ES]]
| style="" | [[#SS|SS]]
| colspan="12" |
|-
| style="text-align:left;" | String
| style="border-right:none;" | [[#REP|REP]]
| style="border-left:none;border-right:none;" | [[#REP|REPE]]
| style="border-left:none;" | [[#REPNE|REPNE]]
| style="" | [[#MOVSB|MOVSB]]
| style="" | [[#MOVSW|MOVSW]]
| style="border-right:none;" | [[#LODSB|LODSB]]
| style="border-left:none;" | [[#STOSB|STOSB]]
| style="border-right:none;" | [[#LODSW|LODSW]]
| style="border-left:none;" | [[#STOSW|STOSW]]
| style="" | [[#CMPSB|CMPSB]]
| style="" | [[#SCASB|SCASB]]
| style="" | [[#CMPSW|CMPSW]]
| style="" | [[#SCASW|SCASW]]
| colspan="3" |
|-
| style="text-align:left;" | Other
| style="" | [[#NOP|NOP]]
| style="border-right:none;" | [[#ENTER|ENTER]]
| style="border-left:none;" | [[#LEAVE|LEAVE]]
| style="" | [[#LOCK|LOCK]]
| style="" | [[#POLL|POLL]]
| colspan="11" |
|}
== Instruction encoding ==
=== ModR/M byte ===
The ModR/M byte is used in most addressing modes which reference a memory location. This byte consists of three bitfield values:
* <tt>oo</tt> - M'''o'''de;
* <tt>rrr</tt> - Two possible functions:
** '''R'''egister (for addressing modes which require both a register and a register/memory operand),
** Opcode extension (for some opcodes' addressing modes which do not have such a requirement);
* <tt>mmm</tt> - Register/'''M'''emory.
The ''Mode'' and ''Register/Memory'' bitfields can refer to a memory location or to a register, as shown in the table below. In some addressing modes, the ''Register'' field also refers to a register; it is always interpreted as if ''Mode'' was equal to <tt>11</tt>.
{| class="wikitable" style="text-align: center"
! R/M \ Mode
! <tt>00</tt>
! <tt>01</tt>
! <tt>10</tt>
! <tt>11</tt> ''(byte)''
! <tt>11</tt> ''(word)''
|-
| <tt>000</tt>
| DS:[BX + SI]
| DS:[BX + SI + disp8]
| DS:[BX + SI + disp16]
| AL
| AX
|-
| <tt>001</tt>
| DS:[BX + DI]
| DS:[BX + DI + disp8]
| DS:[BX + DI + disp16]
| CL
| CX
|-
| <tt>010</tt>
| SS:[BP + SI]
| SS:[BP + SI + disp8]
| SS:[BP + SI + disp16]
| DL
| DX
|-
| <tt>011</tt>
| SS:[BP + DI]
| SS:[BP + DI + disp8]
| SS:[BP + DI + disp16]
| BL
| BX
|-
| <tt>100</tt>
| DS:[SI]
| DS:[SI + disp8]
| DS:[SI + disp16]
| AH
| SP
|-
| <tt>101</tt>
| DS:[DI]
| DS:[DI + disp8]
| DS:[DI + disp16]
| CH
| BP
|-
| <tt>110</tt>
| ''DS:[disp16]''
| SS:[BP + disp8]
| SS:[BP + disp16]
| DH
| SI
|-
| <tt>111</tt>
| DS:[BX]
| DS:[BX + disp8]
| DS:[BX + disp16]
| BH
| DI
|}
Displacements are either 8-bit (disp8) or 16-bit (disp16) signed values and they always immediately follow the ModR/M byte. Note that (<tt>oo</tt> = <tt>00</tt>, <tt>mmm</tt> = <tt>110</tt>) is a special case, in which the ''disp16'' value is used directly as a near pointer.
The instruction encoding lists below refer to this byte as <tt>oorrrmmm</tt> (binary), <tt>/r</tt> (hexadecimal) or <tt>/0</tt> (hexademical, <tt>rrr</tt> used as function <tt>0</tt>).
== Official instructions ==
{{Anchor|AAA}}
=== AAA ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| AAA || <tt>37</tt> || <tt>00110111</tt> || 1 || 9
|}
----
{{Anchor|AAD}}
=== AAD ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| AAD imm8 || <tt>B5 ii</tt> || <tt>11010100 iiiiiiii</tt> || 2 || 6
|}
----
{{Anchor|AAM}}
=== AAM ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| AAM imm8 || <tt>B4 ii</tt> || <tt>11010100 iiiiiiii</tt> || 2 || 17
|}
----
{{Anchor|AAS}}
=== AAS ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| AAS || <tt>3F</tt> || <tt>00111111</tt> || 1 || 9
|}
----
{{Anchor|ADC}}
=== ADC ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| ADC AL, imm || <tt>14 ii</tt> || <tt>00010100 iiiiiiii</tt> || 2 || 1
|-
| ADC AX, imm || <tt>15 ii ii</tt> || <tt>00010101 iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| ADC mem8, imm8 || <tt>80 /2 ii</tt> || <tt>10000000 oo010mmm iiiiiiii</tt> || 3+ || 3
|-
| ADC mem16, imm16 || <tt>81 /2 ii ii</tt> || <tt>10000001 oo010mmm iiiiiiii iiiiiiii</tt> || 4+ || 3
|-
| ADC mem16, simm8 || <tt>83 /2 ii ii</tt> || <tt>10000011 oo010mmm iiiiiiii iiiiiiii</tt> || 4+ || 3
|-
| ADC mem8, reg8 || <tt>10 /r</tt> || <tt>00010000 oorrrmmm</tt> || 2+ || 3
|-
| ADC mem16, reg16 || <tt>11 /r</tt> || <tt>00010001 oorrrmmm</tt> || 2+ || 3
|-
| ADC reg8, imm8 || <tt>80 /2 ii</tt> || <tt>10000000 11010mmm iiiiiiii</tt> || 3+ || 1
|-
| ADC reg16, imm16 || <tt>81 /2 ii ii</tt> || <tt>10000001 11010mmm iiiiiiii iiiiiiii</tt> || 4+ || 1
|-
| ADC reg16, simm8 || <tt>83 /2 ii ii</tt> || <tt>10000011 11010mmm iiiiiiii iiiiiiii</tt> || 4+ || 1
|-
| ADC reg8, mem8 || <tt>12 /r</tt> || <tt>00010010 oorrrmmm</tt> || 2+ || 2
|-
| ADC reg16, mem16 || <tt>13 /r</tt> || <tt>00010011 oorrrmmm</tt> || 2+ || 2
|-
| ADC reg8, reg8 || <tt>10 /r</tt> || <tt>000100.0 11rrrmmm</tt> || 2 || 1
|-
| ADC reg16, reg16 || <tt>11 /r</tt> || <tt>000100.1 11rrrmmm</tt> || 2 || 1
|}
----
{{Anchor|ADD}}
=== ADD ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| ADD AL, imm || <tt>04 ii</tt> || <tt>00000100 iiiiiiii</tt> || 2 || 1
|-
| ADD AX, imm || <tt>05 ii ii</tt> || <tt>00000101 iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| ADD mem8, imm8 || <tt>80 /0 ii</tt> || <tt>10000000 oo000mmm iiiiiiii</tt> || 3+ || 3
|-
| ADD mem16, imm16 || <tt>81 /0 ii ii</tt> || <tt>10000001 oo000mmm iiiiiiii iiiiiiii</tt> || 4+ || 3
|-
| ADD mem16, simm8 || <tt>83 /0 ii ii</tt> || <tt>10000011 oo000mmm iiiiiiii iiiiiiii</tt> || 4+ || 3
|-
| ADD mem8, reg8 || <tt>00 /r</tt> || <tt>00000000 oorrrmmm</tt> || 2+ || 3
|-
| ADD mem16, reg16 || <tt>01 /r</tt> || <tt>00000001 oorrrmmm</tt> || 2+ || 3
|-
| ADD reg8, imm8 || <tt>80 /0 ii</tt> || <tt>10000000 11000mmm iiiiiiii</tt> || 3+ || 1
|-
| ADD reg16, imm16 || <tt>81 /0 ii ii</tt> || <tt>10000001 11000mmm iiiiiiii iiiiiiii</tt> || 4+ || 1
|-
| ADD reg16, simm8 || <tt>83 /0 ii ii</tt> || <tt>10000011 11000mmm iiiiiiii iiiiiiii</tt> || 4+ || 1
|-
| ADD reg8, mem8 || <tt>02 /r</tt> || <tt>00000010 oorrrmmm</tt> || 2+ || 2
|-
| ADD reg16, mem16 || <tt>03 /r</tt> || <tt>00000011 oorrrmmm</tt> || 2+ || 2
|-
| ADD reg8, reg8 || <tt>00 /r</tt> || <tt>000000.0 11rrrmmm</tt> || 2 || 1
|-
| ADD reg16, reg16 || <tt>01 /r</tt> || <tt>000000.1 11rrrmmm</tt> || 2 || 1
|}
----
{{Anchor|AND}}
=== AND ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| AND AL, imm || <tt>24 ii</tt> || <tt>00100100 iiiiiiii</tt> || 2 || 1
|-
| AND AX, imm || <tt>25 ii ii</tt> || <tt>00100101 iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| AND mem8, imm8 || <tt>80 /4 ii</tt> || <tt>10000000 oo100mmm iiiiiiii</tt> || 3+ || 3
|-
| AND mem16, imm16 || <tt>81 /4 ii ii</tt> || <tt>10000001 oo100mmm iiiiiiii iiiiiiii</tt> || 4+ || 3
|-
| AND mem16, simm8 || <tt>83 /4 ii ii</tt> || <tt>10000011 oo100mmm iiiiiiii iiiiiiii</tt> || 4+ || 3
|-
| AND mem8, reg8 || <tt>20 /r</tt> || <tt>00100000 oorrrmmm</tt> || 2+ || 3
|-
| AND mem16, reg16 || <tt>21 /r</tt> || <tt>00100001 oorrrmmm</tt> || 2+ || 3
|-
| AND reg8, imm8 || <tt>80 /4 ii</tt> || <tt>10000000 11100mmm iiiiiiii</tt> || 3+ || 1
|-
| AND reg16, imm16 || <tt>81 /4 ii ii</tt> || <tt>10000001 11100mmm iiiiiiii iiiiiiii</tt> || 4+ || 1
|-
| AND reg16, simm8 || <tt>83 /4 ii ii</tt> || <tt>10000011 11100mmm iiiiiiii iiiiiiii</tt> || 4+ || 1
|-
| AND reg8, mem8 || <tt>22 /r</tt> || <tt>00100010 oorrrmmm</tt> || 2+ || 2
|-
| AND reg16, mem16 || <tt>23 /r</tt> || <tt>00100011 oorrrmmm</tt> || 2+ || 2
|-
| AND reg8, reg8 || <tt>20 /r</tt> || <tt>001000.0 11rrrmmm</tt> || 2 || 1
|-
| AND reg16, reg16 || <tt>21 /r</tt> || <tt>001000.1 11rrrmmm</tt> || 2 || 1
|}
----
{{Anchor|BOUND}}
=== BOUND ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| BOUND reg16, mem16:16 || <tt>62 /r</tt> || <tt>01100010 oorrrmmm</tt> || 2+ || 13 (20 if condition met)
|}
----
{{Anchor|CALL}}
=== CALL ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| CALL ptr16:16 || <tt>CA oo oo ss ss</tt> || <tt>10011010 oooooooo oooooooo ssssssss ssssssss</tt> || 5 || 10
|-
| CALL mem16 || <tt>FF /2</tt> || <tt>11111111 oo010mmm</tt> || 2+ || 6
|-
| CALL mem16:16 || <tt>FF /3</tt> || <tt>11111111 oo011mmm</tt> || 2+ || 12
|-
| CALL reg16 || <tt>FF /2</tt> || <tt>11111111 11010mmm</tt> || 2 || 5
|-
| CALL rel16 || <tt>E8 ii ii</tt> || <tt>11101000 iiiiiiii iiiiiiii</tt> || 3 || 5
|}
----
{{Anchor|CBW}}
=== CBW ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| CBW || <tt>98</tt> || <tt>10011000</tt> || 1 || 1
|}
----
{{Anchor|CLC}}
=== CLC ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| CLC || <tt>F8</tt> || <tt>11111000</tt> || 1 || 4
|}
----
{{Anchor|CLD}}
=== CLD ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| CLD || <tt>FC</tt> || <tt>11111100</tt> || 1 || 4
|}
----
{{Anchor|CLI}}
=== CLI ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| CLI || <tt>FA</tt> || <tt>11111010</tt> || 1 || 4
|}
----
{{Anchor|CMC}}
=== CMC ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| CMC || <tt>F5</tt> || <tt>11110101</tt> || 1 || 4
|}
----
{{Anchor|CMP}}
=== CMP ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| CMP AL, imm || <tt>3C ii</tt> || <tt>00111100 iiiiiiii</tt> || 2 || 1
|-
| CMP AX, imm || <tt>3D ii ii</tt> || <tt>00111101 iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| CMP mem8, imm8 || <tt>80 /7 ii</tt> || <tt>10000000 oo111mmm iiiiiiii</tt> || 3+ || 2
|-
| CMP mem16, imm16 || <tt>81 /7 ii ii</tt> || <tt>10000001 oo111mmm iiiiiiii iiiiiiii</tt> || 4+ || 2
|-
| CMP mem16, simm8 || <tt>83 /7 ii ii</tt> || <tt>10000011 oo111mmm iiiiiiii iiiiiiii</tt> || 4+ || 2
|-
| CMP mem8, reg8 || <tt>38 /r</tt> || <tt>00111000 oorrrmmm</tt> || 2+ || 2
|-
| CMP mem16, reg16 || <tt>39 /r</tt> || <tt>00111001 oorrrmmm</tt> || 2+ || 2
|-
| CMP reg8, imm8 || <tt>80 /7 ii</tt> || <tt>10000000 11111mmm iiiiiiii</tt> || 3+ || 1
|-
| CMP reg16, imm16 || <tt>81 /7 ii ii</tt> || <tt>10000001 11111mmm iiiiiiii iiiiiiii</tt> || 4+ || 1
|-
| CMP reg16, simm8 || <tt>83 /7 ii ii</tt> || <tt>10000011 11111mmm iiiiiiii iiiiiiii</tt> || 4+ || 1
|-
| CMP reg8, mem8 || <tt>3A /r</tt> || <tt>00111010 oorrrmmm</tt> || 2+ || 2
|-
| CMP reg16, mem16 || <tt>3B /r</tt> || <tt>00111011 oorrrmmm</tt> || 2+ || 2
|-
| CMP reg8, reg8 || <tt>38 /r</tt> || <tt>001110.0 11rrrmmm</tt> || 2 || 1
|-
| CMP reg16, reg16 || <tt>39 /r</tt> || <tt>001110.1 11rrrmmm</tt> || 2 || 1
|}
----
{{Anchor|CMPSB}}
=== CMPSB ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| CMPSB || <tt>A6</tt> || <tt>10100110</tt> || 1 || 6
|}
----
{{Anchor|CMPSW}}
=== CMPSW ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| CMPSW || <tt>A7</tt> || <tt>10100111</tt> || 1 || 6
|}
----
{{Anchor|CS}}
=== CS ===
----
{{Anchor|CWD}}
=== CWD ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| CWD || <tt>99</tt> || <tt>10011001</tt> || 1 || 1
|}
----
{{Anchor|DAA}}
=== DAA ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| DAA || <tt>27</tt> || <tt>00100111</tt> || 1 || 10
|}
----
{{Anchor|DAS}}
=== DAS ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| DAS || <tt>2F</tt> || <tt>00101111</tt> || 1 || 10
|}
----
{{Anchor|DEC}}
=== DEC ===
----
{{Anchor|DIV}}
=== DIV ===
----
{{Anchor|DS}}
=== DS ===
----
{{Anchor|ENTER}}
=== ENTER ===
----
{{Anchor|ES}}
=== ES ===
----
{{Anchor|HLT}}
=== HLT ===
----
{{Anchor|IDIV}}
=== IDIV ===
----
{{Anchor|IMUL}}
=== IMUL ===
----
{{Anchor|IN}}
=== IN ===
----
{{Anchor|INC}}
=== INC ===
----
{{Anchor|INSB}}
=== INSB ===
----
{{Anchor|INSW}}
=== INSW ===
----
{{Anchor|INT}}
=== INT ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| INT 3 || <tt>CC</tt> || <tt>11001100</tt> || 1 || 9
|-
| INT imm8 || <tt>CD ii</tt> || <tt>11001101 iiiiiiii</tt> || 2 || 10
|}
----
{{Anchor|INTO}}
=== INTO ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| INTO || <tt>CE</tt> || <tt>11001110</tt> || 1 || 6 (13 if OF = 1)
|}
----
{{Anchor|IRET}}
=== IRET ===
----
{{Anchor|JA}}
=== JA ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JA rel8 || <tt>77 ii</tt> || <tt>01110111 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JBE}}
=== JBE ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JA rel8 || <tt>76 ii</tt> || <tt>01110110 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JC}}
=== JC/JB ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JC rel8 || <tt>72 ii</tt> || <tt>01110010 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JCXZ}}
=== JCXZ ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JCXZ rel8 || <tt>E3 ii</tt> || <tt>11100011 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JG}}
=== JG ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JG rel8 || <tt>7F ii</tt> || <tt>01111111 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JGE}}
=== JGE ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JGE rel8 || <tt>7D ii</tt> || <tt>01111101 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JL}}
=== JL ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JL rel8 || <tt>7C ii</tt> || <tt>01111100 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JLE}}
=== JLE ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JLE rel8 || <tt>7E ii</tt> || <tt>01111110 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JMP}}
=== JMP ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JMP ptr16:16 || <tt>EA oo oo ss ss</tt> || <tt>11101010 oooooooo oooooooo ssssssss ssssssss</tt> || 5 || 7
|-
| JMP mem16 || <tt>FF /4</tt> || <tt>11111111 oo100mmm</tt> || 2+ || 5
|-
| JMP mem16:16 || <tt>FF /5</tt> || <tt>11111111 oo101mmm</tt> || 2+ || 10
|-
| JMP reg16 || <tt>FF /4</tt> || <tt>11111111 11100mmm</tt> || 2 || 4
|-
| JMP rel8 || <tt>EB ii</tt> || <tt>11101011 iiiiiiii</tt> || 2 || 4
|-
| JMP rel16 || <tt>E9 ii ii</tt> || <tt>11101001 iiiiiiii iiiiiiii</tt> || 3 || 4
|}
----
{{Anchor|JNC}}
=== JNC/JAE ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JNC rel8 || <tt>73 ii</tt> || <tt>01110011 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JNO}}
=== JNO ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JNO rel8 || <tt>71 ii</tt> || <tt>01110001 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JNP}}
=== JNP ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JNP rel8 || <tt>7B ii</tt> || <tt>01111011 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JNS}}
=== JNS ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JNS rel8 || <tt>79 ii</tt> || <tt>01111001 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JNZ}}
=== JNZ/JNE ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JNZ rel8 || <tt>75 ii</tt> || <tt>01110101 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JO}}
=== JO ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JO rel8 || <tt>70 ii</tt> || <tt>01110000 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JP}}
=== JP ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JP rel8 || <tt>7A ii</tt> || <tt>01111010 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JS}}
=== JS ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JS rel8 || <tt>78 ii</tt> || <tt>01111000 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JZ}}
=== JZ/JE ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JZ rel8 || <tt>74 ii</tt> || <tt>01110100 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|LAHF}}
=== LAHF ===
----
{{Anchor|LDS}}
=== LDS ===
----
{{Anchor|LEA}}
=== LEA ===
----
{{Anchor|LEAVE}}
=== LEAVE ===
----
{{Anchor|LES}}
=== LES ===
----
{{Anchor|LOCK}}
=== LOCK ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| LOCK || <tt>F0</tt> || <tt>11110000</tt> || 1 || 1
|}
----
{{Anchor|LODSB}}
=== LODSB ===
----
{{Anchor|LODSW}}
=== LODSW ===
----
{{Anchor|LOOP}}
=== LOOP ===
----
{{Anchor|LOOPE}}
=== LOOPE ===
----
{{Anchor|LOOPNE}}
=== LOOPNE ===
----
{{Anchor|MOV}}
=== MOV ===
----
{{Anchor|MOVSB}}
=== MOVSB ===
----
{{Anchor|MOVSW}}
=== MOVSW ===
----
{{Anchor|MUL}}
=== MUL ===
----
{{Anchor|NEG}}
=== NEG ===
----
{{Anchor|NOP}}
=== NOP ===
----
{{Anchor|NOT}}
=== NOT ===
----
{{Anchor|OR}}
=== OR ===
----
{{Anchor|OUT}}
=== OUT ===
----
{{Anchor|OUTSB}}
=== OUTSB ===
----
{{Anchor|OUTSW}}
=== OUTSW ===
----
{{Anchor|POLL}}
=== POLL ===
----
{{Anchor|POP}}
=== POP ===
----
{{Anchor|POPA}}
=== POPA ===
----
{{Anchor|POPF}}
=== POPF ===
----
{{Anchor|PUSH}}
=== PUSH ===
----
{{Anchor|PUSHA}}
=== PUSHA ===
----
{{Anchor|PUSHF}}
=== PUSHF ===
----
{{Anchor|RCL}}
=== RCL ===
----
{{Anchor|RCR}}
=== RCR ===
----
{{Anchor|REP}}
=== REP/REPE/REPZ ===
----
{{Anchor|REPNE}}
=== REPNE/REPNZ ===
----
{{Anchor|RET}}
=== RET ===
----
{{Anchor|RETF}}
=== RETF ===
----
{{Anchor|ROL}}
=== ROL ===
----
{{Anchor|ROR}}
=== ROR ===
----
{{Anchor|SAHF}}
=== SAHF ===
----
{{Anchor|SAR}}
=== SAR ===
----
{{Anchor|SBB}}
=== SBB ===
----
{{Anchor|SCASB}}
=== SCASB ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| SCASB || <tt>AE</tt> || <tt>10101110</tt> || 1 || 4
|}
----
{{Anchor|SCASW}}
=== SCASW ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| SCASW || <tt>AF</tt> || <tt>10101111</tt> || 1 || 4
|}
----
{{Anchor|SHL}}
=== SHL ===
----
{{Anchor|SHR}}
=== SHR ===
----
{{Anchor|SS}}
=== SS ===
----
{{Anchor|STC}}
=== STC ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| STC || <tt>F9</tt> || <tt>11111001</tt> || 1 || 4
|}
----
{{Anchor|STD}}
=== STD ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| STD || <tt>FD</tt> || <tt>11111101</tt> || 1 || 4
|}
----
{{Anchor|STI}}
=== STI ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| STI || <tt>FB</tt> || <tt>11111011</tt> || 1 || 4
|}
----
{{Anchor|STOSB}}
=== STOSB ===
----
{{Anchor|STOSW}}
=== STOSW ===
----
{{Anchor|SUB}}
=== SUB ===
----
{{Anchor|TEST}}
=== TEST ===
----
{{Anchor|XCHG}}
=== XCHG ===
----
{{Anchor|XLAT}}
=== XLAT ===
----
{{Anchor|XOR}}
=== XOR ===
----
d45320bccce96a0db6298a646be828f1b68bb3e7
NEC V30MZ
0
39
442
345
2024-12-26T18:19:35Z
Asie
351
/* Sections */
wikitext
text/x-wiki
The NEC V30MZ is the CPU component of the WonderSwan SoC.
Unlike the NEC V20/V30 CPU family, the V30MZ is fully compatible with the Intel 80186's documented behaviour, as well as some of its undocumented behaviour (such as the SALC opcode); it also omits the V20/V30's opcode extensions.
== Format ==
The NEC V30MZ datasheet provides distinct names for opcodes, flags and registers, which the wiki refers to as ''NEC names''. As all homebrew compilers and assemblers for the platform utilize Intel's official naming (''Intel names''), the latter is what is used throughout. For registers and flags, distinct NEC names are presented in the following format: Intel<sup>NEC</sup>.
== Sections ==
* [[NEC V30MZ registers]]
* [[NEC V30MZ flags]]
* [[NEC V30MZ instruction set]]
** [[NEC V30MZ undocumented instructions]]
* [[NEC V30MZ interrupts]]
== Links ==
* [https://www.ardent-tool.com/CPU/docs/NEC/V20-V30/v30mz.pdf NEC V30MZ datasheet]
* [http://perfectkiosk.net/stsws.html#cpu STSWS - CPU - V30MZ/V Series Microprocessor]
c7b9ca49e4fc86efa763cf95fd249fdf5ef26c6d
NEC V30MZ undocumented instructions
0
69
444
2024-12-26T18:42:49Z
Asie
351
Created page with "TODO. For now, see https://github.com/FluBBaOfWard/WSCpuTest/blob/main/README.md"
wikitext
text/x-wiki
TODO. For now, see https://github.com/FluBBaOfWard/WSCpuTest/blob/main/README.md
c1b28dfebfd37b9656e454ef198ecb23955ffe58
WonderWitch/FreyaBIOS/System
0
66
451
430
2024-12-27T19:02:06Z
Asie
351
document some sleep functions
wikitext
text/x-wiki
The System interrupt provides assorted system-related functionality.
== Interrupts ==
=== INT $17/AH=$00 - sys_interrupt_set_hook ===
* AH = $00
* AL = Interrupt index
* DS:BX = Pointer to new vector (read from)
* DS:DX = Pointer to old vector (written to)
Hook the given interrupt handler and enable the interrupt.
=== INT $17/AH=$01 - sys_interrupt_reset_hook ===
* AH = $01
* AL = Interrupt index
* DS:BX = Pointer to old vector (read from)
Unhook the given interrupt handler and disable the interrupt.
=== INT $17/AH=$02 - sys_wait ===
* AH = $02
* CX = Frames to wait
=== INT $17/AH=$03 - sys_get_tick_count ===
* AH = $03
Return:
* DX:AX = Number of frames since system start
=== INT $17/AH=$04 - sys_sleep ===
* AH = $04
Puts the system to sleep; the LCD panel is disabled and the CPU is halted.
TODO: Document precise wake up conditions (it's definitely the key pattern - is an interrupt sufficient?).
=== INT $17/AH=$05 - sys_set_sleep_time ===
* AH = $05
* BL = Sleep time, in minutes
=== INT $17/AH=$06 - sys_get_sleep_time ===
* AH = $06
Return:
* AL = Sleep time, in minutes
=== INT $17/AH=$07 - sys_set_awake_key ===
* AH = $07
* BX = Key pattern to wake up from sleep.
If the key pattern is set to $0000, pressing any key will wake up the console.
=== INT $17/AH=$08 - sys_get_awake_key ===
* AH = $08
Return:
* AX = Key pattern to wake up from sleep.
=== INT $17/AH=$09 - sys_set_keepalive_int ===
* AH = $09
* BL = [[Interrupts|Interrupt mask]]
Set the interrupt mask to be applied while the console is sleeping.
By default, this is set to $02 - that is, only the key interrupt is listened to during sleep.
=== INT $17/AH=$0A - sys_get_ownerinfo ===
* AH = $0A
* DS:DX = Output buffer
* CX = Output buffer size, in bytes
Errata:
* The FreyaBIOS implementation only works correctly in the "mono" mode. An alternate implementation that supports "color" mode is provided as part of libwwc.
=== INT $17/AH=$0B - sys_suspend ===
* AH = $0B
* AL = Suspend slot (see below)
* DS:BX = Pointer to I/O resume table (see below)
Return:
* AX = 0 if suspend successful, 1 if returning from suspend (via sys_resume).
Makes a copy of the execution state (IRAM, I/O ports, stack) to be restored via sys_resume (see below).
==== Suspend/resume structure ====
This structure is stored in SRAM block 3, offset <code>$7E00</code> (slot 1) and <code>$BF00</code> (slot 0).
{| class="wikitable"
|-
! Offset !! Size !! Contents
|-
| $0000 || 16384 || Copy of RAM area <code>$0000</code> - <code>$3FFF</code>
|-
| $4000 || 4 || Far pointer to I/O resume table (DS:BX), plus 1
|-
| $4004 || 224 || Copy of IO ports <code>$00</code> - <code>$DF</code>
|-
| $40E4 || 2 || Value of CX?
|-
| $40E6 || 2 || Value of SP?
|-
| $40E8 || 2 || Value of SS?
|}
In addition, these SRAM block 3 locations are used:
{| class="wikitable"
|-
! Offset !! Contents
|-
| $FFEE || Resumable status for slot 0 (bit 7 = resumable?, bit ?..0 = ID)
|-
| $FFEF || Resumable status for slot 1 (bit 7 = resumable?, bit ?..0 = ID)
|}
==== I/O resume table ====
{| class="wikitable"
|-
! Offset !! Size !! Contents
|-
| $00 || 2 || 'IO'
|-
| $02 || 224 || Resume configuration for each I/O port
|}
=== INT $17/AH=$0C - sys_resume ===
* AH = $0C
* AL = Suspend slot?
Resumes execution from an existing suspend slot. Returns to where ''sys_suspend'' was last called, but with a different return value.
=== INT $17/AH=$0D - sys_set_remote ===
=== INT $17/AH=$0E - sys_get_remote ===
=== INT $17/AH=$0F - sys_alloc_iram ===
* BX = ?
* CX = bytes to allocate
Return:
* AX = near pointer to allocated IRAM block
Pointers to IRAM blocks are always segment (16 byte)-aligned.
=== INT $17/AH=$10 - sys_free_iram ===
=== INT $17/AH=$11 - sys_get_my_iram ===
=== INT $17/AH=$12 - sys_get_version ===
* AH = $12
Return:
* AX = BIOS version
15 bit 0
---- ---- ---- ----
MMMM mmmm pppp pppp
|||| |||| |||| ||||
|||| |||| ++++-++++- Patch version (0-127)
|||| ++++----------- Minor version (0-15)
++++---------------- Major version (0-15)
=== INT $17/AH=$13 - sys_swap ===
=== INT $17/AH=$14 - sys_set_resume ===
* AH = $14
* BL = Resumable flag for slot ?
* BH = Resumable flag for slot ?
=== INT $17/AH=$15 - sys_get_resume ===
* AH = $15
Return:
* AL = Resumable flag for slot ?
* AH = Resumable flag for slot ?
3c86aacb392bba5c43d3e9d8c274de579ce0a661
472
451
2024-12-29T09:46:02Z
Asie
351
/* INT $17/AH=$0A - sys_get_ownerinfo */ document return codes
wikitext
text/x-wiki
The System interrupt provides assorted system-related functionality.
== Interrupts ==
=== INT $17/AH=$00 - sys_interrupt_set_hook ===
* AH = $00
* AL = Interrupt index
* DS:BX = Pointer to new vector (read from)
* DS:DX = Pointer to old vector (written to)
Hook the given interrupt handler and enable the interrupt.
=== INT $17/AH=$01 - sys_interrupt_reset_hook ===
* AH = $01
* AL = Interrupt index
* DS:BX = Pointer to old vector (read from)
Unhook the given interrupt handler and disable the interrupt.
=== INT $17/AH=$02 - sys_wait ===
* AH = $02
* CX = Frames to wait
=== INT $17/AH=$03 - sys_get_tick_count ===
* AH = $03
Return:
* DX:AX = Number of frames since system start
=== INT $17/AH=$04 - sys_sleep ===
* AH = $04
Puts the system to sleep; the LCD panel is disabled and the CPU is halted.
TODO: Document precise wake up conditions (it's definitely the key pattern - is an interrupt sufficient?).
=== INT $17/AH=$05 - sys_set_sleep_time ===
* AH = $05
* BL = Sleep time, in minutes
=== INT $17/AH=$06 - sys_get_sleep_time ===
* AH = $06
Return:
* AL = Sleep time, in minutes
=== INT $17/AH=$07 - sys_set_awake_key ===
* AH = $07
* BX = Key pattern to wake up from sleep.
If the key pattern is set to $0000, pressing any key will wake up the console.
=== INT $17/AH=$08 - sys_get_awake_key ===
* AH = $08
Return:
* AX = Key pattern to wake up from sleep.
=== INT $17/AH=$09 - sys_set_keepalive_int ===
* AH = $09
* BL = [[Interrupts|Interrupt mask]]
Set the interrupt mask to be applied while the console is sleeping.
By default, this is set to $02 - that is, only the key interrupt is listened to during sleep.
=== INT $17/AH=$0A - sys_get_ownerinfo ===
* AH = $0A
* DS:DX = Output buffer
* CX = Output buffer size, in bytes
Return:
* AX:
* $0000 - Success
* $8101 - Internal EEPROM communication timeout
Errata:
* The FreyaBIOS implementation only works correctly in the "mono" mode. An alternate implementation that supports "color" mode is provided as part of libwwc.
=== INT $17/AH=$0B - sys_suspend ===
* AH = $0B
* AL = Suspend slot (see below)
* DS:BX = Pointer to I/O resume table (see below)
Return:
* AX = 0 if suspend successful, 1 if returning from suspend (via sys_resume).
Makes a copy of the execution state (IRAM, I/O ports, stack) to be restored via sys_resume (see below).
==== Suspend/resume structure ====
This structure is stored in SRAM block 3, offset <code>$7E00</code> (slot 1) and <code>$BF00</code> (slot 0).
{| class="wikitable"
|-
! Offset !! Size !! Contents
|-
| $0000 || 16384 || Copy of RAM area <code>$0000</code> - <code>$3FFF</code>
|-
| $4000 || 4 || Far pointer to I/O resume table (DS:BX), plus 1
|-
| $4004 || 224 || Copy of IO ports <code>$00</code> - <code>$DF</code>
|-
| $40E4 || 2 || Value of CX?
|-
| $40E6 || 2 || Value of SP?
|-
| $40E8 || 2 || Value of SS?
|}
In addition, these SRAM block 3 locations are used:
{| class="wikitable"
|-
! Offset !! Contents
|-
| $FFEE || Resumable status for slot 0 (bit 7 = resumable?, bit ?..0 = ID)
|-
| $FFEF || Resumable status for slot 1 (bit 7 = resumable?, bit ?..0 = ID)
|}
==== I/O resume table ====
{| class="wikitable"
|-
! Offset !! Size !! Contents
|-
| $00 || 2 || 'IO'
|-
| $02 || 224 || Resume configuration for each I/O port
|}
=== INT $17/AH=$0C - sys_resume ===
* AH = $0C
* AL = Suspend slot?
Resumes execution from an existing suspend slot. Returns to where ''sys_suspend'' was last called, but with a different return value.
=== INT $17/AH=$0D - sys_set_remote ===
=== INT $17/AH=$0E - sys_get_remote ===
=== INT $17/AH=$0F - sys_alloc_iram ===
* BX = ?
* CX = bytes to allocate
Return:
* AX = near pointer to allocated IRAM block
Pointers to IRAM blocks are always segment (16 byte)-aligned.
=== INT $17/AH=$10 - sys_free_iram ===
=== INT $17/AH=$11 - sys_get_my_iram ===
=== INT $17/AH=$12 - sys_get_version ===
* AH = $12
Return:
* AX = BIOS version
15 bit 0
---- ---- ---- ----
MMMM mmmm pppp pppp
|||| |||| |||| ||||
|||| |||| ++++-++++- Patch version (0-127)
|||| ++++----------- Minor version (0-15)
++++---------------- Major version (0-15)
=== INT $17/AH=$13 - sys_swap ===
=== INT $17/AH=$14 - sys_set_resume ===
* AH = $14
* BL = Resumable flag for slot ?
* BH = Resumable flag for slot ?
=== INT $17/AH=$15 - sys_get_resume ===
* AH = $15
Return:
* AL = Resumable flag for slot ?
* AH = Resumable flag for slot ?
80cfcd9695792ba5ee23bb435747339a076d4bb8
473
472
2024-12-29T09:46:19Z
Asie
351
/* INT $17/AH=$0A - sys_get_ownerinfo */
wikitext
text/x-wiki
The System interrupt provides assorted system-related functionality.
== Interrupts ==
=== INT $17/AH=$00 - sys_interrupt_set_hook ===
* AH = $00
* AL = Interrupt index
* DS:BX = Pointer to new vector (read from)
* DS:DX = Pointer to old vector (written to)
Hook the given interrupt handler and enable the interrupt.
=== INT $17/AH=$01 - sys_interrupt_reset_hook ===
* AH = $01
* AL = Interrupt index
* DS:BX = Pointer to old vector (read from)
Unhook the given interrupt handler and disable the interrupt.
=== INT $17/AH=$02 - sys_wait ===
* AH = $02
* CX = Frames to wait
=== INT $17/AH=$03 - sys_get_tick_count ===
* AH = $03
Return:
* DX:AX = Number of frames since system start
=== INT $17/AH=$04 - sys_sleep ===
* AH = $04
Puts the system to sleep; the LCD panel is disabled and the CPU is halted.
TODO: Document precise wake up conditions (it's definitely the key pattern - is an interrupt sufficient?).
=== INT $17/AH=$05 - sys_set_sleep_time ===
* AH = $05
* BL = Sleep time, in minutes
=== INT $17/AH=$06 - sys_get_sleep_time ===
* AH = $06
Return:
* AL = Sleep time, in minutes
=== INT $17/AH=$07 - sys_set_awake_key ===
* AH = $07
* BX = Key pattern to wake up from sleep.
If the key pattern is set to $0000, pressing any key will wake up the console.
=== INT $17/AH=$08 - sys_get_awake_key ===
* AH = $08
Return:
* AX = Key pattern to wake up from sleep.
=== INT $17/AH=$09 - sys_set_keepalive_int ===
* AH = $09
* BL = [[Interrupts|Interrupt mask]]
Set the interrupt mask to be applied while the console is sleeping.
By default, this is set to $02 - that is, only the key interrupt is listened to during sleep.
=== INT $17/AH=$0A - sys_get_ownerinfo ===
* AH = $0A
* DS:DX = Output buffer
* CX = Output buffer size, in bytes
Return:
* AX:
** $0000 - Success
** $8101 - Internal EEPROM communication timeout
Errata:
* The FreyaBIOS implementation only works correctly in the "mono" mode. An alternate implementation that supports "color" mode is provided as part of libwwc.
=== INT $17/AH=$0B - sys_suspend ===
* AH = $0B
* AL = Suspend slot (see below)
* DS:BX = Pointer to I/O resume table (see below)
Return:
* AX = 0 if suspend successful, 1 if returning from suspend (via sys_resume).
Makes a copy of the execution state (IRAM, I/O ports, stack) to be restored via sys_resume (see below).
==== Suspend/resume structure ====
This structure is stored in SRAM block 3, offset <code>$7E00</code> (slot 1) and <code>$BF00</code> (slot 0).
{| class="wikitable"
|-
! Offset !! Size !! Contents
|-
| $0000 || 16384 || Copy of RAM area <code>$0000</code> - <code>$3FFF</code>
|-
| $4000 || 4 || Far pointer to I/O resume table (DS:BX), plus 1
|-
| $4004 || 224 || Copy of IO ports <code>$00</code> - <code>$DF</code>
|-
| $40E4 || 2 || Value of CX?
|-
| $40E6 || 2 || Value of SP?
|-
| $40E8 || 2 || Value of SS?
|}
In addition, these SRAM block 3 locations are used:
{| class="wikitable"
|-
! Offset !! Contents
|-
| $FFEE || Resumable status for slot 0 (bit 7 = resumable?, bit ?..0 = ID)
|-
| $FFEF || Resumable status for slot 1 (bit 7 = resumable?, bit ?..0 = ID)
|}
==== I/O resume table ====
{| class="wikitable"
|-
! Offset !! Size !! Contents
|-
| $00 || 2 || 'IO'
|-
| $02 || 224 || Resume configuration for each I/O port
|}
=== INT $17/AH=$0C - sys_resume ===
* AH = $0C
* AL = Suspend slot?
Resumes execution from an existing suspend slot. Returns to where ''sys_suspend'' was last called, but with a different return value.
=== INT $17/AH=$0D - sys_set_remote ===
=== INT $17/AH=$0E - sys_get_remote ===
=== INT $17/AH=$0F - sys_alloc_iram ===
* BX = ?
* CX = bytes to allocate
Return:
* AX = near pointer to allocated IRAM block
Pointers to IRAM blocks are always segment (16 byte)-aligned.
=== INT $17/AH=$10 - sys_free_iram ===
=== INT $17/AH=$11 - sys_get_my_iram ===
=== INT $17/AH=$12 - sys_get_version ===
* AH = $12
Return:
* AX = BIOS version
15 bit 0
---- ---- ---- ----
MMMM mmmm pppp pppp
|||| |||| |||| ||||
|||| |||| ++++-++++- Patch version (0-127)
|||| ++++----------- Minor version (0-15)
++++---------------- Major version (0-15)
=== INT $17/AH=$13 - sys_swap ===
=== INT $17/AH=$14 - sys_set_resume ===
* AH = $14
* BL = Resumable flag for slot ?
* BH = Resumable flag for slot ?
=== INT $17/AH=$15 - sys_get_resume ===
* AH = $15
Return:
* AL = Resumable flag for slot ?
* AH = Resumable flag for slot ?
afbffc7acd1077ede44ad8091d65bbf8edddb8b2
NEC V30MZ instruction set
0
68
452
450
2024-12-27T21:27:12Z
Asie
351
wikitext
text/x-wiki
__NOTOC__
Note that this page is a work in progress.
{| class="wikitable" style="text-align: center"
|+ Official V30MZ (80186) Instructions
|-
| [[#AAA|AAA]] || [[#AAD|AAD]] || [[#AAM|AAM]] || [[#AAS|AAS]] || [[#ADC|ADC]] || [[#ADD|ADD]] || [[#AND|AND]] || [[#BOUND|BOUND]] || [[#CALL|CALL]] || [[#CBW|CBW]] || [[#CLC|CLC]]
|-
| [[#CLD|CLD]] || [[#CLI|CLI]] || [[#CMC|CMC]] || [[#CMP|CMP]] || [[#CMPSB|CMPSB]] || [[#CMPSW|CMPSW]] || [[#CS|CS]] || [[#CWD|CWD]] || [[#DAA|DAA]] || [[#DAS|DAS]] || [[#DEC|DEC]]
|-
| [[#DIV|DIV]] || [[#DS|DS]] || [[#ENTER|ENTER]] || [[#ES|ES]] || [[#HLT|HLT]] || [[#IDIV|IDIV]] || [[#IMUL|IMUL]] || [[#IN|IN]] || [[#INC|INC]] || [[#INSB|INSB]] || [[#INSW|INSW]]
|-
| [[#INT|INT]] || [[#INTO|INTO]] || [[#IRET|IRET]] || [[#JA|JA]] || [[#JBE|JBE]] || [[#JC|JC]] || [[#JCXZ|JCXZ]] || [[#JG|JG]] || [[#JGE|JGE]] || [[#JL|JL]] || [[#JLE|JLE]]
|-
| [[#JMP|JMP]] || [[#JNC|JNC]] || [[#JNO|JNO]] || [[#JNP|JNP]] || [[#JNS|JNS]] || [[#JNZ|JNZ]] || [[#JO|JO]] || [[#JP|JP]] || [[#JS|JS]] || [[#JZ|JZ]] || [[#LAHF|LAHF]]
|-
| [[#LDS|LDS]] || [[#LEA|LEA]] || [[#LEAVE|LEAVE]] || [[#LES|LES]] || [[#LOCK|LOCK]] || [[#LODSB|LODSB]] || [[#LODSW|LODSW]] || [[#LOOP|LOOP]] || [[#LOOPE|LOOPE]] || [[#LOOPNE|LOOPNE]] || [[#MOV|MOV]]
|-
| [[#MOVSB|MOVSB]] || [[#MOVSW|MOVSW]] || [[#MUL|MUL]] || [[#NEG|NEG]] || [[#NOP|NOP]] || [[#NOT|NOT]] || [[#OR|OR]] || [[#OUT|OUT]] || [[#OUTSB|OUTSB]] || [[#OUTSW|OUTSW]] || [[#POLL|POLL]]
|-
| [[#POP|POP]] || [[#POPA|POPA]] || [[#POPF|POPF]] || [[#PUSH|PUSH]] || [[#PUSHA|PUSHA]] || [[#PUSHF|PUSHF]] || [[#RCL|RCL]] || [[#RCR|RCR]] || [[#REP|REP]] || [[#REPNE|REPNE]] || [[#RET|RET]]
|-
| [[#RETF|RETF]] || [[#ROL|ROL]] || [[#ROR|ROR]] || [[#SAHF|SAHF]] || [[#SAR|SAR]] || [[#SBB|SBB]] || [[#SCASB|SCASB]] || [[#SCASW|SCASW]] || [[#SHL|SHL]] || [[#SHR|SHR]] || [[#SS|SS]]
|-
| [[#STC|STC]] || [[#STD|STD]] || [[#STI|STI]] || [[#STOSB|STOSB]] || [[#STOSW|STOSW]] || [[#SUB|SUB]] || [[#TEST|TEST]] || [[#XCHG|XCHG]] || [[#XLAT|XLAT]] || [[#XOR|XOR]]
|}
{| class="mw-collapsible mw-collapsed wikitable sortable" style="width: 340px;"
|+ style="white-space:nowrap; border:1px solid; padding:3px; border-color:rgb(162, 169, 177); background-color:rgb(234, 236, 240);" | Intel <-> NEC mnemonic translation table
!Intel
!NEC
|-
| [[#AAA|AAA]]
| [[#AAA|ADJBA]]
|-
| [[#AAD|AAD]]
| [[#AAD|CVTDB]]
|-
| [[#AAM|AAM]]
| [[#AAM|CVTBD]]
|-
| [[#AAS|AAS]]
| [[#AAS|ADJBS]]
|-
| [[#ADC|ADC]]
| [[#ADC|ADDC]]
|-
| [[#ADD|ADD]]
| [[#ADD|ADD]]
|-
| [[#AND|AND]]
| [[#AND|AND]]
|-
| [[#BOUND|BOUND]]
| [[#BOUND|CHKIND]]
|-
| [[#CALL|CALL]]
| [[#CALL|CALL]]
|-
| [[#CBW|CBW]]
| [[#CBW|CVTBW]]
|-
| [[#CLC|CLC]]
| [[#CLC|CLR1 CY]]
|-
| [[#CLD|CLD]]
| [[#CLD|CLR1 DIR]]
|-
| [[#CLI|CLI]]
| [[#CLI|DI]]
|-
| [[#CMC|CMC]]
| [[#CMC|NOT1 CY]]
|-
| [[#CMP|CMP]]
| [[#CMP|CMP]]
|-
| [[#CMPSB|CMPSB]]
| [[#CMPSB|CMPBKB]]
|-
| [[#CMPSW|CMPSW]]
| [[#CMPSW|CMPBKW]]
|-
| [[#CS|CS]]
| [[#CS|PS]]
|-
| [[#CWD|CWD]]
| [[#CWD|CVTWL]]
|-
| [[#DAA|DAA]]
| [[#DAA|ADJ4A]]
|-
| [[#DAS|DAS]]
| [[#DAS|ADJ4S]]
|-
| [[#DEC|DEC]]
| [[#DEC|DEC]]
|-
| [[#DIV|DIV]]
| [[#DIV|DIVU]]
|-
| [[#DS|DS]]
| [[#DS|DS0]]
|-
| [[#ENTER|ENTER]]
| [[#ENTER|PREPARE]]
|-
| [[#ES|ES]]
| [[#ES|DS1]]
|-
| [[#HLT|HLT]]
| [[#HLT|HALT]]
|-
| [[#IDIV|IDIV]]
| [[#IDIV|DIV]]
|-
| [[#IMUL|IMUL]]
| [[#IMUL|MUL]]
|-
| [[#IN|IN]]
| [[#IN|IN]]
|-
| [[#INC|INC]]
| [[#INC|INC]]
|-
| [[#INSB|INSB]]
| [[#INSB|INMB]]
|-
| [[#INSW|INSW]]
| [[#INSW|INMW]]
|-
| [[#INT|INT]]
| [[#INT|BRK]]
|-
| [[#INTO|INTO]]
| [[#INTO|BRKV]]
|-
| [[#IRET|IRET]]
| [[#IRET|RETI]]
|-
| [[#JA|JA]]
| [[#JA|BH]]
|-
| [[#JBE|JBE]]
| [[#JBE|BNH]]
|-
| [[#JC|JC/JB]]
| [[#JC|BC/BL]]
|-
| [[#JCXZ|JCXZ]]
| [[#JCXZ|BCWZ]]
|-
| [[#JG|JG]]
| [[#JG|BGT]]
|-
| [[#JGE|JGE]]
| [[#JGE|BGE]]
|-
| [[#JL|JL]]
| [[#JL|BLT]]
|-
| [[#JLE|JLE]]
| [[#JLE|BLE]]
|-
| [[#JMP|JMP]]
| [[#JMP|BR]]
|-
| [[#JNC|JNC/JAE]]
| [[#JNC|BNC/BNL]]
|-
| [[#JNO|JNO]]
| [[#JNO|BNV]]
|-
| [[#JNP|JNP]]
| [[#JNP|BPO]]
|-
| [[#JNS|JNS]]
| [[#JNS|BP]]
|-
| [[#JNZ|JNZ/JNE]]
| [[#JNZ|BNZ/BNE]]
|-
| [[#JO|JO]]
| [[#JO|BV]]
|-
| [[#JP|JP]]
| [[#JP|BPE]]
|-
| [[#JS|JS]]
| [[#JS|BN]]
|-
| [[#JZ|JZ/JE]]
| [[#JZ|BZ/BE]]
|-
| [[#LAHF|LAHF]]
| [[#LAHF|MOV]]
|-
| [[#LDS|LDS]]
| [[#LDS|MOV]]
|-
| [[#LEA|LEA]]
| [[#LEA|LDEA]]
|-
| [[#LEAVE|LEAVE]]
| [[#LEAVE|DISPOSE]]
|-
| [[#LES|LES]]
| [[#LES|MOV]]
|-
| [[#LOCK|LOCK]]
| [[#LOCK|BUSLOCK]]
|-
| [[#LODSB|LODSB]]
| [[#LODSB|LDMB]]
|-
| [[#LODSW|LODSW]]
| [[#LODSW|LDMW]]
|-
| [[#LOOP|LOOP]]
| [[#LOOP|DBNZ]]
|-
| [[#LOOPE|LOOPE]]
| [[#LOOPE|DBNZE]]
|-
| [[#LOOPNE|LOOPNE]]
| [[#LOOPNE|DBNZNE]]
|-
| [[#MOV|MOV]]
| [[#MOV|MOV]]
|-
| [[#MOVSB|MOVSB]]
| [[#MOVSB|MOVBKB]]
|-
| [[#MOVSW|MOVSW]]
| [[#MOVSW|MOVBKW]]
|-
| [[#MUL|MUL]]
| [[#MUL|MULU]]
|-
| [[#NEG|NEG]]
| [[#NEG|NEG]]
|-
| [[#NOP|NOP]]
| [[#NOP|NOP]]
|-
| [[#NOT|NOT]]
| [[#NOT|NOT]]
|-
| [[#OR|OR]]
| [[#OR|OR]]
|-
| [[#OUT|OUT]]
| [[#OUT|OUT]]
|-
| [[#OUTSB|OUTSB]]
| [[#OUTSB|OUTM]]
|-
| [[#OUTSW|OUTSW]]
| [[#OUTSW|OUTM]]
|-
| [[#POLL|POLL]]
| [[#POLL|POLL]]
|-
| [[#POP|POP]]
| [[#POP|POP]]
|-
| [[#POPA|POPA]]
| [[#POPA|POP]]
|-
| [[#POPF|POPF]]
| [[#POPF|POP]]
|-
| [[#PUSH|PUSH]]
| [[#PUSH|PUSH]]
|-
| [[#PUSHA|PUSHA]]
| [[#PUSHA|PUSH]]
|-
| [[#PUSHF|PUSHF]]
| [[#PUSHF|PUSH]]
|-
| [[#RCL|RCL]]
| [[#RCL|ROLC]]
|-
| [[#RCR|RCR]]
| [[#RCR|RORC]]
|-
| [[#REP|REP/REPE/REPZ]]
| [[#REP|REP/REPE/REPZ]]
|-
| [[#REPNE|REPNE/REPNZ]]
| [[#REPNE|REPNE/REPNZ]]
|-
| [[#RET|RET]]
| [[#RET|RET]]
|-
| [[#RETF|RETF]]
| [[#RETF|RET]]
|-
| [[#ROL|ROL]]
| [[#ROL|ROL]]
|-
| [[#ROR|ROR]]
| [[#ROR|ROR]]
|-
| [[#SAHF|SAHF]]
| [[#SAHF|MOV]]
|-
| [[#SAR|SAR]]
| [[#SAR|SHRA]]
|-
| [[#SBB|SBB]]
| [[#SBB|SUBC]]
|-
| [[#SCASB|SCASB]]
| [[#SCASB|CMPMB]]
|-
| [[#SCASW|SCASW]]
| [[#SCASW|CMPMW]]
|-
| [[#SHL|SHL]]
| [[#SHL|SHL]]
|-
| [[#SHR|SHR]]
| [[#SHR|SHR]]
|-
| [[#SS|SS]]
| [[#SS|SS]]
|-
| [[#STC|STC]]
| [[#STC|SET1 CY]]
|-
| [[#STD|STD]]
| [[#STD|SET1 DIR]]
|-
| [[#STI|STI]]
| [[#STI|EI]]
|-
| [[#STOSB|STOSB]]
| [[#STOSB|STMB]]
|-
| [[#STOSW|STOSW]]
| [[#STOSW|STMW]]
|-
| [[#SUB|SUB]]
| [[#SUB|SUB]]
|-
| [[#TEST|TEST]]
| [[#TEST|TEST]]
|-
| [[#XCHG|XCHG]]
| [[#XCHG|XCH]]
|-
| [[#XLAT|XLAT]]
| [[#XLAT|TRANS]]
|-
| [[#XOR|XOR]]
| [[#XOR|XOR]]
|}
== Official instructions by type ==
{| class="wikitable sortable" style="text-align: center"
!Type
!colspan=16 class="unsortable" | Instructions
|-
| style="text-align:left;" | Memory
| style="" | [[#MOV|MOV]]
| style="" | [[#XCHG|XCHG]]
| style="" | [[#XLAT|XLAT]]
| style="" | [[#LEA|LEA]]
| style="border-right:none;" | [[#LDS|LDS]]
| style="border-left:none;" | [[#LES|LES]]
| style="border-right:none;" | [[#IN|IN]]
| style="border-left:none;" | [[#OUT|OUT]]
| colspan="8" |
|-
| style="text-align:left;" | Ports
| style="border-right:none;" | [[#IN|IN]]
| style="border-left:none;" | [[#OUT|OUT]]
| style="border-right:none;" | [[#INSB|INSB]]
| style="border-left:none;" | [[#OUTSB|OUTSB]]
| style="border-right:none;" | [[#INSW|INSW]]
| style="border-left:none;" | [[#OUTSW|OUTSW]]
| colspan="10" |
|-
| style="text-align:left;" | Arithmetic
| style="border-right:none;" | [[#ADD|ADD]]
| style="border-left:none;" | [[#SUB|SUB]]
| style="border-right:none;" | [[#ADC|ADC]]
| style="border-left:none;" | [[#SBB|SBB]]
| style="border-right:none;" | [[#INC|INC]]
| style="border-left:none;" | [[#DEC|DEC]]
| style="border-right:none;" | [[#MUL|MUL]]
| style="border-left:none;" | [[#DIV|DIV]]
| style="border-right:none;" | [[#IMUL|IMUL]]
| style="border-left:none;" | [[#IDIV|IDIV]]
| style="" | [[#CMP|CMP]]
| style="" | [[#NEG|NEG]]
| colspan="4" |
|-
| style="text-align:left;" | Numeric
| style="" | [[#CBW|CBW]]
| style="" | [[#CWD|CWD]]
| style="" | [[#AAA|AAA]]
| style="" | [[#AAS|AAS]]
| style="" | [[#AAM|AAM]]
| style="" | [[#AAD|AAD]]
| style="" | [[#DAA|DAA]]
| style="" | [[#DAS|DAS]]
| colspan="8" |
|-
| style="text-align:left;" | Shift
| style="border-right:none;" | [[#ROL|ROL]]
| style="border-left:none;" | [[#ROR|ROR]]
| style="border-right:none;" | [[#RCL|RCL]]
| style="border-left:none;" | [[#RCR|RCR]]
| style="border-right:none;" | [[#SHL|SHL]]
| style="border-left:none;" | [[#SHR|SHR]]
| style="" | [[#SAR|SAR]]
| colspan="9" |
|-
| style="text-align:left;" | Bitwise
| style="" | [[#AND|AND]]
| style="" | [[#OR|OR]]
| style="" | [[#XOR|XOR]]
| style="" | [[#NOT|NOT]]
| style="" | [[#TEST|TEST]]
| colspan="11" |
|-
| style="text-align:left;" | Branch
| style="border-right:none;" | [[#JC|JC]]
| style="border-left:none;" | [[#JNC|JNC]]
| style="border-right:none;" | [[#JZ|JZ]]
| style="border-left:none;" | [[#JNZ|JNZ]]
| style="border-right:none;" | [[#JBE|JBE]]
| style="border-left:none;" | [[#JA|JA]]
| style="border-right:none;" | [[#JO|JO]]
| style="border-left:none;" | [[#JNO|JNO]]
| style="border-right:none;" | [[#JP|JP]]
| style="border-left:none;" | [[#JNP|JNP]]
| style="border-right:none;" | [[#JS|JS]]
| style="border-left:none;" | [[#JNS|JNS]]
| style="border-right:none;" | [[#JL|JL]]
| style="border-left:none;" | [[#JGE|JGE]]
| style="border-right:none;" | [[#JLE|JLE]]
| style="border-left:none;" | [[#JG|JG]]
|-
| style="text-align:left;" | Jump
| style="" | [[#JMP|JMP]]
| style="border-right:none;" | [[#CALL|CALL]]
| style="border-left:none;border-right:none;" | [[#RET|RET]]
| style="border-left:none;" | [[#RETF|RETF]]
| colspan="12" |
|-
| style="text-align:left;" | Loop
| style="" | [[#LOOP|LOOP]]
| style="" | [[#LOOPE|LOOPE]]
| style="" | [[#LOOPNE|LOOPNE]]
| colspan="13" |
|-
| style="text-align:left;" | Interrupt
| style="border-right:none;" | [[#INT|INT]]
| style="border-left:none;" | [[#IRET|IRET]]
| style="" | [[#INTO|INTO]]
| style="" | [[#HLT|HLT]]
| style="" | [[#BOUND|BOUND]]
| colspan="11" |
|-
| style="text-align:left;" | Stack
| style="border-right:none;" | [[#PUSH|PUSH]]
| style="border-left:none;" | [[#POP|POP]]
| style="border-right:none;" | [[#PUSHA|PUSHA]]
| style="border-left:none;" | [[#POPA|POPA]]
| style="border-right:none;" | [[#PUSHF|PUSHF]]
| style="border-left:none;" | [[#POPF|POPF]]
| colspan="10" |
|-
| style="text-align:left;" | Flags
| style="border-right:none;" | [[#CLC|CLC]]
| style="border-left:none;" | [[#STC|STC]]
| style="border-right:none;" | [[#CLD|CLD]]
| style="border-left:none;" | [[#STD|STD]]
| style="border-right:none;" | [[#CLI|CLI]]
| style="border-left:none;" | [[#STI|STI]]
| style="" | [[#CMC|CMC]]
| style="border-right:none;" | [[#LAHF|LAHF]]
| style="border-left:none;" | [[#SAHF|SAHF]]
| colspan="7" |
|-
| style="text-align:left;" | Prefix
| style="" | [[#CS|CS]]
| style="" | [[#DS|DS]]
| style="" | [[#ES|ES]]
| style="" | [[#SS|SS]]
| colspan="12" |
|-
| style="text-align:left;" | String
| style="border-right:none;" | [[#REP|REP]]
| style="border-left:none;border-right:none;" | [[#REP|REPE]]
| style="border-left:none;" | [[#REPNE|REPNE]]
| style="" | [[#MOVSB|MOVSB]]
| style="" | [[#MOVSW|MOVSW]]
| style="border-right:none;" | [[#LODSB|LODSB]]
| style="border-left:none;" | [[#STOSB|STOSB]]
| style="border-right:none;" | [[#LODSW|LODSW]]
| style="border-left:none;" | [[#STOSW|STOSW]]
| style="" | [[#CMPSB|CMPSB]]
| style="" | [[#SCASB|SCASB]]
| style="" | [[#CMPSW|CMPSW]]
| style="" | [[#SCASW|SCASW]]
| colspan="3" |
|-
| style="text-align:left;" | Other
| style="" | [[#NOP|NOP]]
| style="border-right:none;" | [[#ENTER|ENTER]]
| style="border-left:none;" | [[#LEAVE|LEAVE]]
| style="" | [[#LOCK|LOCK]]
| style="" | [[#POLL|POLL]]
| colspan="11" |
|}
== Instruction encoding ==
=== ModR/M byte ===
The ModR/M byte is used in most addressing modes which reference a memory location. This byte consists of three bitfield values:
* <tt>oo</tt> - M'''o'''de;
* <tt>rrr</tt> - Two possible functions:
** '''R'''egister (for addressing modes which require both a register and a register/memory operand),
** Opcode extension (for some opcodes' addressing modes which do not have such a requirement);
* <tt>mmm</tt> - Register/'''M'''emory.
The ''Mode'' and ''Register/Memory'' bitfields can refer to a memory location or to a register, as shown in the table below. In some addressing modes, the ''Register'' field also refers to a register; it is always interpreted as if ''Mode'' was equal to <tt>11</tt>.
{| class="wikitable" style="text-align: center"
! R/M \ Mode
! <tt>00</tt>
! <tt>01</tt>
! <tt>10</tt>
! <tt>11</tt> ''(byte)''
! <tt>11</tt> ''(word)''
|-
| <tt>000</tt>
| DS:[BX + SI]
| DS:[BX + SI + disp8]
| DS:[BX + SI + disp16]
| AL
| AX
|-
| <tt>001</tt>
| DS:[BX + DI]
| DS:[BX + DI + disp8]
| DS:[BX + DI + disp16]
| CL
| CX
|-
| <tt>010</tt>
| SS:[BP + SI]
| SS:[BP + SI + disp8]
| SS:[BP + SI + disp16]
| DL
| DX
|-
| <tt>011</tt>
| SS:[BP + DI]
| SS:[BP + DI + disp8]
| SS:[BP + DI + disp16]
| BL
| BX
|-
| <tt>100</tt>
| DS:[SI]
| DS:[SI + disp8]
| DS:[SI + disp16]
| AH
| SP
|-
| <tt>101</tt>
| DS:[DI]
| DS:[DI + disp8]
| DS:[DI + disp16]
| CH
| BP
|-
| <tt>110</tt>
| ''DS:[disp16]''
| SS:[BP + disp8]
| SS:[BP + disp16]
| DH
| SI
|-
| <tt>111</tt>
| DS:[BX]
| DS:[BX + disp8]
| DS:[BX + disp16]
| BH
| DI
|}
Displacements are either 8-bit (disp8) or 16-bit (disp16) signed values and they always immediately follow the ModR/M byte. Note that (<tt>oo</tt> = <tt>00</tt>, <tt>mmm</tt> = <tt>110</tt>) is a special case, in which the ''disp16'' value is used directly as a near pointer.
The instruction encoding lists below refer to this byte as <tt>oorrrmmm</tt> (binary), <tt>/r</tt> (hexadecimal) or <tt>/0</tt> (hexademical, <tt>rrr</tt> used as function <tt>0</tt>).
== Official instructions ==
{{Anchor|AAA}}
=== AAA ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| AAA || <tt>37</tt> || <tt>00110111</tt> || 1 || 9
|}
----
{{Anchor|AAD}}
=== AAD ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| AAD imm8 || <tt>B5 ii</tt> || <tt>11010100 iiiiiiii</tt> || 2 || 6
|}
----
{{Anchor|AAM}}
=== AAM ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| AAM imm8 || <tt>B4 ii</tt> || <tt>11010100 iiiiiiii</tt> || 2 || 17
|}
----
{{Anchor|AAS}}
=== AAS ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| AAS || <tt>3F</tt> || <tt>00111111</tt> || 1 || 9
|}
----
{{Anchor|ADC}}
=== ADC ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| ADC AL, imm || <tt>14 ii</tt> || <tt>00010100 iiiiiiii</tt> || 2 || 1
|-
| ADC AX, imm || <tt>15 ii ii</tt> || <tt>00010101 iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| ADC mem8, imm8 || <tt>80 /2 ii</tt> || <tt>10000000 oo010mmm iiiiiiii</tt> || 3+ || 3
|-
| ADC mem16, imm16 || <tt>81 /2 ii ii</tt> || <tt>10000001 oo010mmm iiiiiiii iiiiiiii</tt> || 4+ || 3
|-
| ADC mem16, simm8 || <tt>83 /2 ii ii</tt> || <tt>10000011 oo010mmm iiiiiiii iiiiiiii</tt> || 4+ || 3
|-
| ADC mem8, reg8 || <tt>10 /r</tt> || <tt>00010000 oorrrmmm</tt> || 2+ || 3
|-
| ADC mem16, reg16 || <tt>11 /r</tt> || <tt>00010001 oorrrmmm</tt> || 2+ || 3
|-
| ADC reg8, imm8 || <tt>80 /2 ii</tt> || <tt>10000000 11010mmm iiiiiiii</tt> || 3+ || 1
|-
| ADC reg16, imm16 || <tt>81 /2 ii ii</tt> || <tt>10000001 11010mmm iiiiiiii iiiiiiii</tt> || 4+ || 1
|-
| ADC reg16, simm8 || <tt>83 /2 ii ii</tt> || <tt>10000011 11010mmm iiiiiiii iiiiiiii</tt> || 4+ || 1
|-
| ADC reg8, mem8 || <tt>12 /r</tt> || <tt>00010010 oorrrmmm</tt> || 2+ || 2
|-
| ADC reg16, mem16 || <tt>13 /r</tt> || <tt>00010011 oorrrmmm</tt> || 2+ || 2
|-
| ADC reg8, reg8 || <tt>10 /r</tt> || <tt>000100.0 11rrrmmm</tt> || 2 || 1
|-
| ADC reg16, reg16 || <tt>11 /r</tt> || <tt>000100.1 11rrrmmm</tt> || 2 || 1
|}
----
{{Anchor|ADD}}
=== ADD ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| ADD AL, imm || <tt>04 ii</tt> || <tt>00000100 iiiiiiii</tt> || 2 || 1
|-
| ADD AX, imm || <tt>05 ii ii</tt> || <tt>00000101 iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| ADD mem8, imm8 || <tt>80 /0 ii</tt> || <tt>10000000 oo000mmm iiiiiiii</tt> || 3+ || 3
|-
| ADD mem16, imm16 || <tt>81 /0 ii ii</tt> || <tt>10000001 oo000mmm iiiiiiii iiiiiiii</tt> || 4+ || 3
|-
| ADD mem16, simm8 || <tt>83 /0 ii ii</tt> || <tt>10000011 oo000mmm iiiiiiii iiiiiiii</tt> || 4+ || 3
|-
| ADD mem8, reg8 || <tt>00 /r</tt> || <tt>00000000 oorrrmmm</tt> || 2+ || 3
|-
| ADD mem16, reg16 || <tt>01 /r</tt> || <tt>00000001 oorrrmmm</tt> || 2+ || 3
|-
| ADD reg8, imm8 || <tt>80 /0 ii</tt> || <tt>10000000 11000mmm iiiiiiii</tt> || 3+ || 1
|-
| ADD reg16, imm16 || <tt>81 /0 ii ii</tt> || <tt>10000001 11000mmm iiiiiiii iiiiiiii</tt> || 4+ || 1
|-
| ADD reg16, simm8 || <tt>83 /0 ii ii</tt> || <tt>10000011 11000mmm iiiiiiii iiiiiiii</tt> || 4+ || 1
|-
| ADD reg8, mem8 || <tt>02 /r</tt> || <tt>00000010 oorrrmmm</tt> || 2+ || 2
|-
| ADD reg16, mem16 || <tt>03 /r</tt> || <tt>00000011 oorrrmmm</tt> || 2+ || 2
|-
| ADD reg8, reg8 || <tt>00 /r</tt> || <tt>000000.0 11rrrmmm</tt> || 2 || 1
|-
| ADD reg16, reg16 || <tt>01 /r</tt> || <tt>000000.1 11rrrmmm</tt> || 2 || 1
|}
----
{{Anchor|AND}}
=== AND ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| AND AL, imm || <tt>24 ii</tt> || <tt>00100100 iiiiiiii</tt> || 2 || 1
|-
| AND AX, imm || <tt>25 ii ii</tt> || <tt>00100101 iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| AND mem8, imm8 || <tt>80 /4 ii</tt> || <tt>10000000 oo100mmm iiiiiiii</tt> || 3+ || 3
|-
| AND mem16, imm16 || <tt>81 /4 ii ii</tt> || <tt>10000001 oo100mmm iiiiiiii iiiiiiii</tt> || 4+ || 3
|-
| AND mem16, simm8 || <tt>83 /4 ii ii</tt> || <tt>10000011 oo100mmm iiiiiiii iiiiiiii</tt> || 4+ || 3
|-
| AND mem8, reg8 || <tt>20 /r</tt> || <tt>00100000 oorrrmmm</tt> || 2+ || 3
|-
| AND mem16, reg16 || <tt>21 /r</tt> || <tt>00100001 oorrrmmm</tt> || 2+ || 3
|-
| AND reg8, imm8 || <tt>80 /4 ii</tt> || <tt>10000000 11100mmm iiiiiiii</tt> || 3+ || 1
|-
| AND reg16, imm16 || <tt>81 /4 ii ii</tt> || <tt>10000001 11100mmm iiiiiiii iiiiiiii</tt> || 4+ || 1
|-
| AND reg16, simm8 || <tt>83 /4 ii ii</tt> || <tt>10000011 11100mmm iiiiiiii iiiiiiii</tt> || 4+ || 1
|-
| AND reg8, mem8 || <tt>22 /r</tt> || <tt>00100010 oorrrmmm</tt> || 2+ || 2
|-
| AND reg16, mem16 || <tt>23 /r</tt> || <tt>00100011 oorrrmmm</tt> || 2+ || 2
|-
| AND reg8, reg8 || <tt>20 /r</tt> || <tt>001000.0 11rrrmmm</tt> || 2 || 1
|-
| AND reg16, reg16 || <tt>21 /r</tt> || <tt>001000.1 11rrrmmm</tt> || 2 || 1
|}
----
{{Anchor|BOUND}}
=== BOUND ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| BOUND reg16, mem16:16 || <tt>62 /r</tt> || <tt>01100010 oorrrmmm</tt> || 2+ || 13 (20 if condition met)
|}
----
{{Anchor|CALL}}
=== CALL ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| CALL ptr16:16 || <tt>CA oo oo ss ss</tt> || <tt>10011010 oooooooo oooooooo ssssssss ssssssss</tt> || 5 || 10
|-
| CALL mem16 || <tt>FF /2</tt> || <tt>11111111 oo010mmm</tt> || 2+ || 6
|-
| CALL mem16:16 || <tt>FF /3</tt> || <tt>11111111 oo011mmm</tt> || 2+ || 12
|-
| CALL reg16 || <tt>FF /2</tt> || <tt>11111111 11010mmm</tt> || 2 || 5
|-
| CALL rel16 || <tt>E8 ii ii</tt> || <tt>11101000 iiiiiiii iiiiiiii</tt> || 3 || 5
|}
----
{{Anchor|CBW}}
=== CBW ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| CBW || <tt>98</tt> || <tt>10011000</tt> || 1 || 1
|}
----
{{Anchor|CLC}}
=== CLC ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| CLC || <tt>F8</tt> || <tt>11111000</tt> || 1 || 4
|}
----
{{Anchor|CLD}}
=== CLD ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| CLD || <tt>FC</tt> || <tt>11111100</tt> || 1 || 4
|}
----
{{Anchor|CLI}}
=== CLI ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| CLI || <tt>FA</tt> || <tt>11111010</tt> || 1 || 4
|}
----
{{Anchor|CMC}}
=== CMC ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| CMC || <tt>F5</tt> || <tt>11110101</tt> || 1 || 4
|}
----
{{Anchor|CMP}}
=== CMP ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| CMP AL, imm || <tt>3C ii</tt> || <tt>00111100 iiiiiiii</tt> || 2 || 1
|-
| CMP AX, imm || <tt>3D ii ii</tt> || <tt>00111101 iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| CMP mem8, imm8 || <tt>80 /7 ii</tt> || <tt>10000000 oo111mmm iiiiiiii</tt> || 3+ || 2
|-
| CMP mem16, imm16 || <tt>81 /7 ii ii</tt> || <tt>10000001 oo111mmm iiiiiiii iiiiiiii</tt> || 4+ || 2
|-
| CMP mem16, simm8 || <tt>83 /7 ii ii</tt> || <tt>10000011 oo111mmm iiiiiiii iiiiiiii</tt> || 4+ || 2
|-
| CMP mem8, reg8 || <tt>38 /r</tt> || <tt>00111000 oorrrmmm</tt> || 2+ || 2
|-
| CMP mem16, reg16 || <tt>39 /r</tt> || <tt>00111001 oorrrmmm</tt> || 2+ || 2
|-
| CMP reg8, imm8 || <tt>80 /7 ii</tt> || <tt>10000000 11111mmm iiiiiiii</tt> || 3+ || 1
|-
| CMP reg16, imm16 || <tt>81 /7 ii ii</tt> || <tt>10000001 11111mmm iiiiiiii iiiiiiii</tt> || 4+ || 1
|-
| CMP reg16, simm8 || <tt>83 /7 ii ii</tt> || <tt>10000011 11111mmm iiiiiiii iiiiiiii</tt> || 4+ || 1
|-
| CMP reg8, mem8 || <tt>3A /r</tt> || <tt>00111010 oorrrmmm</tt> || 2+ || 2
|-
| CMP reg16, mem16 || <tt>3B /r</tt> || <tt>00111011 oorrrmmm</tt> || 2+ || 2
|-
| CMP reg8, reg8 || <tt>38 /r</tt> || <tt>001110.0 11rrrmmm</tt> || 2 || 1
|-
| CMP reg16, reg16 || <tt>39 /r</tt> || <tt>001110.1 11rrrmmm</tt> || 2 || 1
|}
----
{{Anchor|CMPSB}}
=== CMPSB ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| CMPSB || <tt>A6</tt> || <tt>10100110</tt> || 1 || 6
|}
----
{{Anchor|CMPSW}}
=== CMPSW ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| CMPSW || <tt>A7</tt> || <tt>10100111</tt> || 1 || 6
|}
----
{{Anchor|CS}}
=== CS ===
----
{{Anchor|CWD}}
=== CWD ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| CWD || <tt>99</tt> || <tt>10011001</tt> || 1 || 1
|}
----
{{Anchor|DAA}}
=== DAA ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| DAA || <tt>27</tt> || <tt>00100111</tt> || 1 || 10
|}
----
{{Anchor|DAS}}
=== DAS ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| DAS || <tt>2F</tt> || <tt>00101111</tt> || 1 || 10
|}
----
{{Anchor|DEC}}
=== DEC ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| DEC mem8 || <tt>FE /1</tt> || <tt>11111110 oo001mmm</tt> || 2+ || 3
|-
| DEC mem16 || <tt>FF /1</tt> || <tt>11111111 oo001mmm</tt> || 2+ || 3
|-
| DEC reg8 || <tt>FE /1</tt> || <tt>11111110 11001mmm</tt> || 2+ || 1
|-
| DEC reg16 || <tt>4x</tt> || <tt>01001rrr</tt> || 1 || 1
|}
----
{{Anchor|DIV}}
=== DIV ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| DIV mem8 || <tt>F6 /6</tt> || <tt>11110110 oo110mmm</tt> || 2+ || 16
|-
| DIV mem16 || <tt>F7 /6</tt> || <tt>11111111 oo110mmm</tt> || 2+ || 24
|-
| DIV reg8 || <tt>F6 /6</tt> || <tt>11111110 11110mmm</tt> || 2+ || 15
|-
| DIV reg16 || <tt>F7 /6</tt> || <tt>11111111 11110mmm</tt> || 2+ || 23
|}
----
{{Anchor|DS}}
=== DS ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| DS || <tt>3E</tt> || <tt>00111110</tt> || 1 || 1
|}
----
{{Anchor|ENTER}}
=== ENTER ===
----
{{Anchor|ES}}
=== ES ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| ES || <tt>26</tt> || <tt>00100110</tt> || 1 || 1
|}
----
{{Anchor|HLT}}
=== HLT ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| HLT || <tt>F4</tt> || <tt>11110100</tt> || 1 || 9
|}
----
{{Anchor|IDIV}}
=== IDIV ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| IDIV mem8 || <tt>F6 /7</tt> || <tt>11110110 oo111mmm</tt> || 2+ || 18
|-
| IDIV mem16 || <tt>F7 /7</tt> || <tt>11111111 oo111mmm</tt> || 2+ || 25
|-
| IDIV reg8 || <tt>F6 /7</tt> || <tt>11111110 11111mmm</tt> || 2+ || 17
|-
| IDIV reg16 || <tt>F7 /7</tt> || <tt>11111111 11111mmm</tt> || 2+ || 24
|}
----
{{Anchor|IMUL}}
=== IMUL ===
----
{{Anchor|IN}}
=== IN ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| IN AL, DX || <tt>EC</tt> || <tt>11101100</tt> || 1 || 6
|-
| IN AX, DX || <tt>ED</tt> || <tt>11101101</tt> || 1 || 6
|-
| IN AL, imm8 || <tt>E4 ii</tt> || <tt>11100100 iiiiiiii</tt> || 2 || 6
|-
| IN AX, imm8 || <tt>E5 ii</tt> || <tt>11100101 iiiiiiii</tt> || 2 || 6
|}
----
{{Anchor|INC}}
=== INC ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| INC mem8 || <tt>FE /0</tt> || <tt>11111110 oo000mmm</tt> || 2+ || 3
|-
| INC mem16 || <tt>FF /0</tt> || <tt>11111111 oo000mmm</tt> || 2+ || 3
|-
| INC reg8 || <tt>FE /0</tt> || <tt>11111110 11000mmm</tt> || 2+ || 1
|-
| INC reg16 || <tt>4x</tt> || <tt>01000rrr</tt> || 1 || 1
|}
----
{{Anchor|INSB}}
=== INSB ===
----
{{Anchor|INSW}}
=== INSW ===
----
{{Anchor|INT}}
=== INT ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| INT 3 || <tt>CC</tt> || <tt>11001100</tt> || 1 || 9
|-
| INT imm8 || <tt>CD ii</tt> || <tt>11001101 iiiiiiii</tt> || 2 || 10
|}
----
{{Anchor|INTO}}
=== INTO ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| INTO || <tt>CE</tt> || <tt>11001110</tt> || 1 || 6 (13 if OF = 1)
|}
----
{{Anchor|IRET}}
=== IRET ===
----
{{Anchor|JA}}
=== JA ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JA rel8 || <tt>77 ii</tt> || <tt>01110111 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JBE}}
=== JBE ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JA rel8 || <tt>76 ii</tt> || <tt>01110110 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JC}}
=== JC/JB ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JC rel8 || <tt>72 ii</tt> || <tt>01110010 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JCXZ}}
=== JCXZ ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JCXZ rel8 || <tt>E3 ii</tt> || <tt>11100011 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JG}}
=== JG ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JG rel8 || <tt>7F ii</tt> || <tt>01111111 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JGE}}
=== JGE ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JGE rel8 || <tt>7D ii</tt> || <tt>01111101 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JL}}
=== JL ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JL rel8 || <tt>7C ii</tt> || <tt>01111100 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JLE}}
=== JLE ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JLE rel8 || <tt>7E ii</tt> || <tt>01111110 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JMP}}
=== JMP ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JMP ptr16:16 || <tt>EA oo oo ss ss</tt> || <tt>11101010 oooooooo oooooooo ssssssss ssssssss</tt> || 5 || 7
|-
| JMP mem16 || <tt>FF /4</tt> || <tt>11111111 oo100mmm</tt> || 2+ || 5
|-
| JMP mem16:16 || <tt>FF /5</tt> || <tt>11111111 oo101mmm</tt> || 2+ || 10
|-
| JMP reg16 || <tt>FF /4</tt> || <tt>11111111 11100mmm</tt> || 2 || 4
|-
| JMP rel8 || <tt>EB ii</tt> || <tt>11101011 iiiiiiii</tt> || 2 || 4
|-
| JMP rel16 || <tt>E9 ii ii</tt> || <tt>11101001 iiiiiiii iiiiiiii</tt> || 3 || 4
|}
----
{{Anchor|JNC}}
=== JNC/JAE ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JNC rel8 || <tt>73 ii</tt> || <tt>01110011 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JNO}}
=== JNO ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JNO rel8 || <tt>71 ii</tt> || <tt>01110001 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JNP}}
=== JNP ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JNP rel8 || <tt>7B ii</tt> || <tt>01111011 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JNS}}
=== JNS ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JNS rel8 || <tt>79 ii</tt> || <tt>01111001 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JNZ}}
=== JNZ/JNE ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JNZ rel8 || <tt>75 ii</tt> || <tt>01110101 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JO}}
=== JO ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JO rel8 || <tt>70 ii</tt> || <tt>01110000 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JP}}
=== JP ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JP rel8 || <tt>7A ii</tt> || <tt>01111010 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JS}}
=== JS ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JS rel8 || <tt>78 ii</tt> || <tt>01111000 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JZ}}
=== JZ/JE ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JZ rel8 || <tt>74 ii</tt> || <tt>01110100 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|LAHF}}
=== LAHF ===
----
{{Anchor|LDS}}
=== LDS ===
----
{{Anchor|LEA}}
=== LEA ===
----
{{Anchor|LEAVE}}
=== LEAVE ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| LEAVE || <tt>C9</tt> || <tt>11001001</tt> || 1 || 2
|}
----
{{Anchor|LES}}
=== LES ===
----
{{Anchor|LOCK}}
=== LOCK ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| LOCK || <tt>F0</tt> || <tt>11110000</tt> || 1 || 1
|}
----
{{Anchor|LODSB}}
=== LODSB ===
----
{{Anchor|LODSW}}
=== LODSW ===
----
{{Anchor|LOOP}}
=== LOOP ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| LOOP rel8 || <tt>E2 ii</tt> || <tt>11100010 iiiiiiii</tt> || 2 || 2 (5 if branch taken)
|}
----
{{Anchor|LOOPE}}
=== LOOPE ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| LOOPE rel8 || <tt>E1 ii</tt> || <tt>11100001 iiiiiiii</tt> || 2 || 3 (6 if branch taken)
|}
----
{{Anchor|LOOPNE}}
=== LOOPNE ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| LOOPNE rel8 || <tt>E0 ii</tt> || <tt>11100000 iiiiiiii</tt> || 2 || 3 (6 if branch taken)
|}
----
{{Anchor|MOV}}
=== MOV ===
----
{{Anchor|MOVSB}}
=== MOVSB ===
----
{{Anchor|MOVSW}}
=== MOVSW ===
----
{{Anchor|MUL}}
=== MUL ===
----
{{Anchor|NEG}}
=== NEG ===
----
{{Anchor|NOP}}
=== NOP ===
----
{{Anchor|NOT}}
=== NOT ===
----
{{Anchor|OR}}
=== OR ===
----
{{Anchor|OUT}}
=== OUT ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| OUT AL, DX || <tt>EE</tt> || <tt>11101110</tt> || 1 || 6
|-
| OUT AX, DX || <tt>EF</tt> || <tt>11101111</tt> || 1 || 6
|-
| OUT AL, imm8 || <tt>E6 ii</tt> || <tt>11100110 iiiiiiii</tt> || 2 || 6
|-
| OUT AX, imm8 || <tt>E7 ii</tt> || <tt>11100111 iiiiiiii</tt> || 2 || 6
|}
----
{{Anchor|OUTSB}}
=== OUTSB ===
----
{{Anchor|OUTSW}}
=== OUTSW ===
----
{{Anchor|POLL}}
=== POLL ===
----
{{Anchor|POP}}
=== POP ===
----
{{Anchor|POPA}}
=== POPA ===
----
{{Anchor|POPF}}
=== POPF ===
----
{{Anchor|PUSH}}
=== PUSH ===
----
{{Anchor|PUSHA}}
=== PUSHA ===
----
{{Anchor|PUSHF}}
=== PUSHF ===
----
{{Anchor|RCL}}
=== RCL ===
----
{{Anchor|RCR}}
=== RCR ===
----
{{Anchor|REP}}
=== REP/REPE/REPZ ===
----
{{Anchor|REPNE}}
=== REPNE/REPNZ ===
----
{{Anchor|RET}}
=== RET ===
----
{{Anchor|RETF}}
=== RETF ===
----
{{Anchor|ROL}}
=== ROL ===
----
{{Anchor|ROR}}
=== ROR ===
----
{{Anchor|SAHF}}
=== SAHF ===
----
{{Anchor|SAR}}
=== SAR ===
----
{{Anchor|SBB}}
=== SBB ===
----
{{Anchor|SCASB}}
=== SCASB ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| SCASB || <tt>AE</tt> || <tt>10101110</tt> || 1 || 4
|}
----
{{Anchor|SCASW}}
=== SCASW ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| SCASW || <tt>AF</tt> || <tt>10101111</tt> || 1 || 4
|}
----
{{Anchor|SHL}}
=== SHL ===
----
{{Anchor|SHR}}
=== SHR ===
----
{{Anchor|SS}}
=== SS ===
----
{{Anchor|STC}}
=== STC ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| STC || <tt>F9</tt> || <tt>11111001</tt> || 1 || 4
|}
----
{{Anchor|STD}}
=== STD ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| STD || <tt>FD</tt> || <tt>11111101</tt> || 1 || 4
|}
----
{{Anchor|STI}}
=== STI ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| STI || <tt>FB</tt> || <tt>11111011</tt> || 1 || 4
|}
----
{{Anchor|STOSB}}
=== STOSB ===
----
{{Anchor|STOSW}}
=== STOSW ===
----
{{Anchor|SUB}}
=== SUB ===
----
{{Anchor|TEST}}
=== TEST ===
----
{{Anchor|XCHG}}
=== XCHG ===
----
{{Anchor|XLAT}}
=== XLAT ===
----
{{Anchor|XOR}}
=== XOR ===
----
0fc3f709d1e009091103c2ec39eebc30be5b11e9
453
452
2024-12-27T21:28:18Z
Asie
351
/* Official instructions */
wikitext
text/x-wiki
__NOTOC__
Note that this page is a work in progress.
{| class="wikitable" style="text-align: center"
|+ Official V30MZ (80186) Instructions
|-
| [[#AAA|AAA]] || [[#AAD|AAD]] || [[#AAM|AAM]] || [[#AAS|AAS]] || [[#ADC|ADC]] || [[#ADD|ADD]] || [[#AND|AND]] || [[#BOUND|BOUND]] || [[#CALL|CALL]] || [[#CBW|CBW]] || [[#CLC|CLC]]
|-
| [[#CLD|CLD]] || [[#CLI|CLI]] || [[#CMC|CMC]] || [[#CMP|CMP]] || [[#CMPSB|CMPSB]] || [[#CMPSW|CMPSW]] || [[#CS|CS]] || [[#CWD|CWD]] || [[#DAA|DAA]] || [[#DAS|DAS]] || [[#DEC|DEC]]
|-
| [[#DIV|DIV]] || [[#DS|DS]] || [[#ENTER|ENTER]] || [[#ES|ES]] || [[#HLT|HLT]] || [[#IDIV|IDIV]] || [[#IMUL|IMUL]] || [[#IN|IN]] || [[#INC|INC]] || [[#INSB|INSB]] || [[#INSW|INSW]]
|-
| [[#INT|INT]] || [[#INTO|INTO]] || [[#IRET|IRET]] || [[#JA|JA]] || [[#JBE|JBE]] || [[#JC|JC]] || [[#JCXZ|JCXZ]] || [[#JG|JG]] || [[#JGE|JGE]] || [[#JL|JL]] || [[#JLE|JLE]]
|-
| [[#JMP|JMP]] || [[#JNC|JNC]] || [[#JNO|JNO]] || [[#JNP|JNP]] || [[#JNS|JNS]] || [[#JNZ|JNZ]] || [[#JO|JO]] || [[#JP|JP]] || [[#JS|JS]] || [[#JZ|JZ]] || [[#LAHF|LAHF]]
|-
| [[#LDS|LDS]] || [[#LEA|LEA]] || [[#LEAVE|LEAVE]] || [[#LES|LES]] || [[#LOCK|LOCK]] || [[#LODSB|LODSB]] || [[#LODSW|LODSW]] || [[#LOOP|LOOP]] || [[#LOOPE|LOOPE]] || [[#LOOPNE|LOOPNE]] || [[#MOV|MOV]]
|-
| [[#MOVSB|MOVSB]] || [[#MOVSW|MOVSW]] || [[#MUL|MUL]] || [[#NEG|NEG]] || [[#NOP|NOP]] || [[#NOT|NOT]] || [[#OR|OR]] || [[#OUT|OUT]] || [[#OUTSB|OUTSB]] || [[#OUTSW|OUTSW]] || [[#POLL|POLL]]
|-
| [[#POP|POP]] || [[#POPA|POPA]] || [[#POPF|POPF]] || [[#PUSH|PUSH]] || [[#PUSHA|PUSHA]] || [[#PUSHF|PUSHF]] || [[#RCL|RCL]] || [[#RCR|RCR]] || [[#REP|REP]] || [[#REPNE|REPNE]] || [[#RET|RET]]
|-
| [[#RETF|RETF]] || [[#ROL|ROL]] || [[#ROR|ROR]] || [[#SAHF|SAHF]] || [[#SAR|SAR]] || [[#SBB|SBB]] || [[#SCASB|SCASB]] || [[#SCASW|SCASW]] || [[#SHL|SHL]] || [[#SHR|SHR]] || [[#SS|SS]]
|-
| [[#STC|STC]] || [[#STD|STD]] || [[#STI|STI]] || [[#STOSB|STOSB]] || [[#STOSW|STOSW]] || [[#SUB|SUB]] || [[#TEST|TEST]] || [[#XCHG|XCHG]] || [[#XLAT|XLAT]] || [[#XOR|XOR]]
|}
{| class="mw-collapsible mw-collapsed wikitable sortable" style="width: 340px;"
|+ style="white-space:nowrap; border:1px solid; padding:3px; border-color:rgb(162, 169, 177); background-color:rgb(234, 236, 240);" | Intel <-> NEC mnemonic translation table
!Intel
!NEC
|-
| [[#AAA|AAA]]
| [[#AAA|ADJBA]]
|-
| [[#AAD|AAD]]
| [[#AAD|CVTDB]]
|-
| [[#AAM|AAM]]
| [[#AAM|CVTBD]]
|-
| [[#AAS|AAS]]
| [[#AAS|ADJBS]]
|-
| [[#ADC|ADC]]
| [[#ADC|ADDC]]
|-
| [[#ADD|ADD]]
| [[#ADD|ADD]]
|-
| [[#AND|AND]]
| [[#AND|AND]]
|-
| [[#BOUND|BOUND]]
| [[#BOUND|CHKIND]]
|-
| [[#CALL|CALL]]
| [[#CALL|CALL]]
|-
| [[#CBW|CBW]]
| [[#CBW|CVTBW]]
|-
| [[#CLC|CLC]]
| [[#CLC|CLR1 CY]]
|-
| [[#CLD|CLD]]
| [[#CLD|CLR1 DIR]]
|-
| [[#CLI|CLI]]
| [[#CLI|DI]]
|-
| [[#CMC|CMC]]
| [[#CMC|NOT1 CY]]
|-
| [[#CMP|CMP]]
| [[#CMP|CMP]]
|-
| [[#CMPSB|CMPSB]]
| [[#CMPSB|CMPBKB]]
|-
| [[#CMPSW|CMPSW]]
| [[#CMPSW|CMPBKW]]
|-
| [[#CS|CS]]
| [[#CS|PS]]
|-
| [[#CWD|CWD]]
| [[#CWD|CVTWL]]
|-
| [[#DAA|DAA]]
| [[#DAA|ADJ4A]]
|-
| [[#DAS|DAS]]
| [[#DAS|ADJ4S]]
|-
| [[#DEC|DEC]]
| [[#DEC|DEC]]
|-
| [[#DIV|DIV]]
| [[#DIV|DIVU]]
|-
| [[#DS|DS]]
| [[#DS|DS0]]
|-
| [[#ENTER|ENTER]]
| [[#ENTER|PREPARE]]
|-
| [[#ES|ES]]
| [[#ES|DS1]]
|-
| [[#HLT|HLT]]
| [[#HLT|HALT]]
|-
| [[#IDIV|IDIV]]
| [[#IDIV|DIV]]
|-
| [[#IMUL|IMUL]]
| [[#IMUL|MUL]]
|-
| [[#IN|IN]]
| [[#IN|IN]]
|-
| [[#INC|INC]]
| [[#INC|INC]]
|-
| [[#INSB|INSB]]
| [[#INSB|INMB]]
|-
| [[#INSW|INSW]]
| [[#INSW|INMW]]
|-
| [[#INT|INT]]
| [[#INT|BRK]]
|-
| [[#INTO|INTO]]
| [[#INTO|BRKV]]
|-
| [[#IRET|IRET]]
| [[#IRET|RETI]]
|-
| [[#JA|JA]]
| [[#JA|BH]]
|-
| [[#JBE|JBE]]
| [[#JBE|BNH]]
|-
| [[#JC|JC/JB]]
| [[#JC|BC/BL]]
|-
| [[#JCXZ|JCXZ]]
| [[#JCXZ|BCWZ]]
|-
| [[#JG|JG]]
| [[#JG|BGT]]
|-
| [[#JGE|JGE]]
| [[#JGE|BGE]]
|-
| [[#JL|JL]]
| [[#JL|BLT]]
|-
| [[#JLE|JLE]]
| [[#JLE|BLE]]
|-
| [[#JMP|JMP]]
| [[#JMP|BR]]
|-
| [[#JNC|JNC/JAE]]
| [[#JNC|BNC/BNL]]
|-
| [[#JNO|JNO]]
| [[#JNO|BNV]]
|-
| [[#JNP|JNP]]
| [[#JNP|BPO]]
|-
| [[#JNS|JNS]]
| [[#JNS|BP]]
|-
| [[#JNZ|JNZ/JNE]]
| [[#JNZ|BNZ/BNE]]
|-
| [[#JO|JO]]
| [[#JO|BV]]
|-
| [[#JP|JP]]
| [[#JP|BPE]]
|-
| [[#JS|JS]]
| [[#JS|BN]]
|-
| [[#JZ|JZ/JE]]
| [[#JZ|BZ/BE]]
|-
| [[#LAHF|LAHF]]
| [[#LAHF|MOV]]
|-
| [[#LDS|LDS]]
| [[#LDS|MOV]]
|-
| [[#LEA|LEA]]
| [[#LEA|LDEA]]
|-
| [[#LEAVE|LEAVE]]
| [[#LEAVE|DISPOSE]]
|-
| [[#LES|LES]]
| [[#LES|MOV]]
|-
| [[#LOCK|LOCK]]
| [[#LOCK|BUSLOCK]]
|-
| [[#LODSB|LODSB]]
| [[#LODSB|LDMB]]
|-
| [[#LODSW|LODSW]]
| [[#LODSW|LDMW]]
|-
| [[#LOOP|LOOP]]
| [[#LOOP|DBNZ]]
|-
| [[#LOOPE|LOOPE]]
| [[#LOOPE|DBNZE]]
|-
| [[#LOOPNE|LOOPNE]]
| [[#LOOPNE|DBNZNE]]
|-
| [[#MOV|MOV]]
| [[#MOV|MOV]]
|-
| [[#MOVSB|MOVSB]]
| [[#MOVSB|MOVBKB]]
|-
| [[#MOVSW|MOVSW]]
| [[#MOVSW|MOVBKW]]
|-
| [[#MUL|MUL]]
| [[#MUL|MULU]]
|-
| [[#NEG|NEG]]
| [[#NEG|NEG]]
|-
| [[#NOP|NOP]]
| [[#NOP|NOP]]
|-
| [[#NOT|NOT]]
| [[#NOT|NOT]]
|-
| [[#OR|OR]]
| [[#OR|OR]]
|-
| [[#OUT|OUT]]
| [[#OUT|OUT]]
|-
| [[#OUTSB|OUTSB]]
| [[#OUTSB|OUTM]]
|-
| [[#OUTSW|OUTSW]]
| [[#OUTSW|OUTM]]
|-
| [[#POLL|POLL]]
| [[#POLL|POLL]]
|-
| [[#POP|POP]]
| [[#POP|POP]]
|-
| [[#POPA|POPA]]
| [[#POPA|POP]]
|-
| [[#POPF|POPF]]
| [[#POPF|POP]]
|-
| [[#PUSH|PUSH]]
| [[#PUSH|PUSH]]
|-
| [[#PUSHA|PUSHA]]
| [[#PUSHA|PUSH]]
|-
| [[#PUSHF|PUSHF]]
| [[#PUSHF|PUSH]]
|-
| [[#RCL|RCL]]
| [[#RCL|ROLC]]
|-
| [[#RCR|RCR]]
| [[#RCR|RORC]]
|-
| [[#REP|REP/REPE/REPZ]]
| [[#REP|REP/REPE/REPZ]]
|-
| [[#REPNE|REPNE/REPNZ]]
| [[#REPNE|REPNE/REPNZ]]
|-
| [[#RET|RET]]
| [[#RET|RET]]
|-
| [[#RETF|RETF]]
| [[#RETF|RET]]
|-
| [[#ROL|ROL]]
| [[#ROL|ROL]]
|-
| [[#ROR|ROR]]
| [[#ROR|ROR]]
|-
| [[#SAHF|SAHF]]
| [[#SAHF|MOV]]
|-
| [[#SAR|SAR]]
| [[#SAR|SHRA]]
|-
| [[#SBB|SBB]]
| [[#SBB|SUBC]]
|-
| [[#SCASB|SCASB]]
| [[#SCASB|CMPMB]]
|-
| [[#SCASW|SCASW]]
| [[#SCASW|CMPMW]]
|-
| [[#SHL|SHL]]
| [[#SHL|SHL]]
|-
| [[#SHR|SHR]]
| [[#SHR|SHR]]
|-
| [[#SS|SS]]
| [[#SS|SS]]
|-
| [[#STC|STC]]
| [[#STC|SET1 CY]]
|-
| [[#STD|STD]]
| [[#STD|SET1 DIR]]
|-
| [[#STI|STI]]
| [[#STI|EI]]
|-
| [[#STOSB|STOSB]]
| [[#STOSB|STMB]]
|-
| [[#STOSW|STOSW]]
| [[#STOSW|STMW]]
|-
| [[#SUB|SUB]]
| [[#SUB|SUB]]
|-
| [[#TEST|TEST]]
| [[#TEST|TEST]]
|-
| [[#XCHG|XCHG]]
| [[#XCHG|XCH]]
|-
| [[#XLAT|XLAT]]
| [[#XLAT|TRANS]]
|-
| [[#XOR|XOR]]
| [[#XOR|XOR]]
|}
== Official instructions by type ==
{| class="wikitable sortable" style="text-align: center"
!Type
!colspan=16 class="unsortable" | Instructions
|-
| style="text-align:left;" | Memory
| style="" | [[#MOV|MOV]]
| style="" | [[#XCHG|XCHG]]
| style="" | [[#XLAT|XLAT]]
| style="" | [[#LEA|LEA]]
| style="border-right:none;" | [[#LDS|LDS]]
| style="border-left:none;" | [[#LES|LES]]
| style="border-right:none;" | [[#IN|IN]]
| style="border-left:none;" | [[#OUT|OUT]]
| colspan="8" |
|-
| style="text-align:left;" | Ports
| style="border-right:none;" | [[#IN|IN]]
| style="border-left:none;" | [[#OUT|OUT]]
| style="border-right:none;" | [[#INSB|INSB]]
| style="border-left:none;" | [[#OUTSB|OUTSB]]
| style="border-right:none;" | [[#INSW|INSW]]
| style="border-left:none;" | [[#OUTSW|OUTSW]]
| colspan="10" |
|-
| style="text-align:left;" | Arithmetic
| style="border-right:none;" | [[#ADD|ADD]]
| style="border-left:none;" | [[#SUB|SUB]]
| style="border-right:none;" | [[#ADC|ADC]]
| style="border-left:none;" | [[#SBB|SBB]]
| style="border-right:none;" | [[#INC|INC]]
| style="border-left:none;" | [[#DEC|DEC]]
| style="border-right:none;" | [[#MUL|MUL]]
| style="border-left:none;" | [[#DIV|DIV]]
| style="border-right:none;" | [[#IMUL|IMUL]]
| style="border-left:none;" | [[#IDIV|IDIV]]
| style="" | [[#CMP|CMP]]
| style="" | [[#NEG|NEG]]
| colspan="4" |
|-
| style="text-align:left;" | Numeric
| style="" | [[#CBW|CBW]]
| style="" | [[#CWD|CWD]]
| style="" | [[#AAA|AAA]]
| style="" | [[#AAS|AAS]]
| style="" | [[#AAM|AAM]]
| style="" | [[#AAD|AAD]]
| style="" | [[#DAA|DAA]]
| style="" | [[#DAS|DAS]]
| colspan="8" |
|-
| style="text-align:left;" | Shift
| style="border-right:none;" | [[#ROL|ROL]]
| style="border-left:none;" | [[#ROR|ROR]]
| style="border-right:none;" | [[#RCL|RCL]]
| style="border-left:none;" | [[#RCR|RCR]]
| style="border-right:none;" | [[#SHL|SHL]]
| style="border-left:none;" | [[#SHR|SHR]]
| style="" | [[#SAR|SAR]]
| colspan="9" |
|-
| style="text-align:left;" | Bitwise
| style="" | [[#AND|AND]]
| style="" | [[#OR|OR]]
| style="" | [[#XOR|XOR]]
| style="" | [[#NOT|NOT]]
| style="" | [[#TEST|TEST]]
| colspan="11" |
|-
| style="text-align:left;" | Branch
| style="border-right:none;" | [[#JC|JC]]
| style="border-left:none;" | [[#JNC|JNC]]
| style="border-right:none;" | [[#JZ|JZ]]
| style="border-left:none;" | [[#JNZ|JNZ]]
| style="border-right:none;" | [[#JBE|JBE]]
| style="border-left:none;" | [[#JA|JA]]
| style="border-right:none;" | [[#JO|JO]]
| style="border-left:none;" | [[#JNO|JNO]]
| style="border-right:none;" | [[#JP|JP]]
| style="border-left:none;" | [[#JNP|JNP]]
| style="border-right:none;" | [[#JS|JS]]
| style="border-left:none;" | [[#JNS|JNS]]
| style="border-right:none;" | [[#JL|JL]]
| style="border-left:none;" | [[#JGE|JGE]]
| style="border-right:none;" | [[#JLE|JLE]]
| style="border-left:none;" | [[#JG|JG]]
|-
| style="text-align:left;" | Jump
| style="" | [[#JMP|JMP]]
| style="border-right:none;" | [[#CALL|CALL]]
| style="border-left:none;border-right:none;" | [[#RET|RET]]
| style="border-left:none;" | [[#RETF|RETF]]
| colspan="12" |
|-
| style="text-align:left;" | Loop
| style="" | [[#LOOP|LOOP]]
| style="" | [[#LOOPE|LOOPE]]
| style="" | [[#LOOPNE|LOOPNE]]
| colspan="13" |
|-
| style="text-align:left;" | Interrupt
| style="border-right:none;" | [[#INT|INT]]
| style="border-left:none;" | [[#IRET|IRET]]
| style="" | [[#INTO|INTO]]
| style="" | [[#HLT|HLT]]
| style="" | [[#BOUND|BOUND]]
| colspan="11" |
|-
| style="text-align:left;" | Stack
| style="border-right:none;" | [[#PUSH|PUSH]]
| style="border-left:none;" | [[#POP|POP]]
| style="border-right:none;" | [[#PUSHA|PUSHA]]
| style="border-left:none;" | [[#POPA|POPA]]
| style="border-right:none;" | [[#PUSHF|PUSHF]]
| style="border-left:none;" | [[#POPF|POPF]]
| colspan="10" |
|-
| style="text-align:left;" | Flags
| style="border-right:none;" | [[#CLC|CLC]]
| style="border-left:none;" | [[#STC|STC]]
| style="border-right:none;" | [[#CLD|CLD]]
| style="border-left:none;" | [[#STD|STD]]
| style="border-right:none;" | [[#CLI|CLI]]
| style="border-left:none;" | [[#STI|STI]]
| style="" | [[#CMC|CMC]]
| style="border-right:none;" | [[#LAHF|LAHF]]
| style="border-left:none;" | [[#SAHF|SAHF]]
| colspan="7" |
|-
| style="text-align:left;" | Prefix
| style="" | [[#CS|CS]]
| style="" | [[#DS|DS]]
| style="" | [[#ES|ES]]
| style="" | [[#SS|SS]]
| colspan="12" |
|-
| style="text-align:left;" | String
| style="border-right:none;" | [[#REP|REP]]
| style="border-left:none;border-right:none;" | [[#REP|REPE]]
| style="border-left:none;" | [[#REPNE|REPNE]]
| style="" | [[#MOVSB|MOVSB]]
| style="" | [[#MOVSW|MOVSW]]
| style="border-right:none;" | [[#LODSB|LODSB]]
| style="border-left:none;" | [[#STOSB|STOSB]]
| style="border-right:none;" | [[#LODSW|LODSW]]
| style="border-left:none;" | [[#STOSW|STOSW]]
| style="" | [[#CMPSB|CMPSB]]
| style="" | [[#SCASB|SCASB]]
| style="" | [[#CMPSW|CMPSW]]
| style="" | [[#SCASW|SCASW]]
| colspan="3" |
|-
| style="text-align:left;" | Other
| style="" | [[#NOP|NOP]]
| style="border-right:none;" | [[#ENTER|ENTER]]
| style="border-left:none;" | [[#LEAVE|LEAVE]]
| style="" | [[#LOCK|LOCK]]
| style="" | [[#POLL|POLL]]
| colspan="11" |
|}
== Instruction encoding ==
=== ModR/M byte ===
The ModR/M byte is used in most addressing modes which reference a memory location. This byte consists of three bitfield values:
* <tt>oo</tt> - M'''o'''de;
* <tt>rrr</tt> - Two possible functions:
** '''R'''egister (for addressing modes which require both a register and a register/memory operand),
** Opcode extension (for some opcodes' addressing modes which do not have such a requirement);
* <tt>mmm</tt> - Register/'''M'''emory.
The ''Mode'' and ''Register/Memory'' bitfields can refer to a memory location or to a register, as shown in the table below. In some addressing modes, the ''Register'' field also refers to a register; it is always interpreted as if ''Mode'' was equal to <tt>11</tt>.
{| class="wikitable" style="text-align: center"
! R/M \ Mode
! <tt>00</tt>
! <tt>01</tt>
! <tt>10</tt>
! <tt>11</tt> ''(byte)''
! <tt>11</tt> ''(word)''
|-
| <tt>000</tt>
| DS:[BX + SI]
| DS:[BX + SI + disp8]
| DS:[BX + SI + disp16]
| AL
| AX
|-
| <tt>001</tt>
| DS:[BX + DI]
| DS:[BX + DI + disp8]
| DS:[BX + DI + disp16]
| CL
| CX
|-
| <tt>010</tt>
| SS:[BP + SI]
| SS:[BP + SI + disp8]
| SS:[BP + SI + disp16]
| DL
| DX
|-
| <tt>011</tt>
| SS:[BP + DI]
| SS:[BP + DI + disp8]
| SS:[BP + DI + disp16]
| BL
| BX
|-
| <tt>100</tt>
| DS:[SI]
| DS:[SI + disp8]
| DS:[SI + disp16]
| AH
| SP
|-
| <tt>101</tt>
| DS:[DI]
| DS:[DI + disp8]
| DS:[DI + disp16]
| CH
| BP
|-
| <tt>110</tt>
| ''DS:[disp16]''
| SS:[BP + disp8]
| SS:[BP + disp16]
| DH
| SI
|-
| <tt>111</tt>
| DS:[BX]
| DS:[BX + disp8]
| DS:[BX + disp16]
| BH
| DI
|}
Displacements are either 8-bit (disp8) or 16-bit (disp16) signed values and they always immediately follow the ModR/M byte. Note that (<tt>oo</tt> = <tt>00</tt>, <tt>mmm</tt> = <tt>110</tt>) is a special case, in which the ''disp16'' value is used directly as a near pointer.
The instruction encoding lists below refer to this byte as <tt>oorrrmmm</tt> (binary), <tt>/r</tt> (hexadecimal) or <tt>/0</tt> (hexademical, <tt>rrr</tt> used as function <tt>0</tt>).
== Official instructions ==
{{Anchor|AAA}}
=== AAA ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| AAA || <tt>37</tt> || <tt>00110111</tt> || 1 || 9
|}
----
{{Anchor|AAD}}
=== AAD ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| AAD imm8 || <tt>B5 ii</tt> || <tt>11010100 iiiiiiii</tt> || 2 || 6
|}
----
{{Anchor|AAM}}
=== AAM ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| AAM imm8 || <tt>B4 ii</tt> || <tt>11010100 iiiiiiii</tt> || 2 || 17
|}
----
{{Anchor|AAS}}
=== AAS ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| AAS || <tt>3F</tt> || <tt>00111111</tt> || 1 || 9
|}
----
{{Anchor|ADC}}
=== ADC ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| ADC AL, imm || <tt>14 ii</tt> || <tt>00010100 iiiiiiii</tt> || 2 || 1
|-
| ADC AX, imm || <tt>15 ii ii</tt> || <tt>00010101 iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| ADC mem8, imm8 || <tt>80 /2 ii</tt> || <tt>10000000 oo010mmm iiiiiiii</tt> || 3+ || 3
|-
| ADC mem16, imm16 || <tt>81 /2 ii ii</tt> || <tt>10000001 oo010mmm iiiiiiii iiiiiiii</tt> || 4+ || 3
|-
| ADC mem16, simm8 || <tt>83 /2 ii ii</tt> || <tt>10000011 oo010mmm iiiiiiii iiiiiiii</tt> || 4+ || 3
|-
| ADC mem8, reg8 || <tt>10 /r</tt> || <tt>00010000 oorrrmmm</tt> || 2+ || 3
|-
| ADC mem16, reg16 || <tt>11 /r</tt> || <tt>00010001 oorrrmmm</tt> || 2+ || 3
|-
| ADC reg8, imm8 || <tt>80 /2 ii</tt> || <tt>10000000 11010mmm iiiiiiii</tt> || 3+ || 1
|-
| ADC reg16, imm16 || <tt>81 /2 ii ii</tt> || <tt>10000001 11010mmm iiiiiiii iiiiiiii</tt> || 4+ || 1
|-
| ADC reg16, simm8 || <tt>83 /2 ii ii</tt> || <tt>10000011 11010mmm iiiiiiii iiiiiiii</tt> || 4+ || 1
|-
| ADC reg8, mem8 || <tt>12 /r</tt> || <tt>00010010 oorrrmmm</tt> || 2+ || 2
|-
| ADC reg16, mem16 || <tt>13 /r</tt> || <tt>00010011 oorrrmmm</tt> || 2+ || 2
|-
| ADC reg8, reg8 || <tt>10 /r</tt> || <tt>000100.0 11rrrmmm</tt> || 2 || 1
|-
| ADC reg16, reg16 || <tt>11 /r</tt> || <tt>000100.1 11rrrmmm</tt> || 2 || 1
|}
----
{{Anchor|ADD}}
=== ADD ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| ADD AL, imm || <tt>04 ii</tt> || <tt>00000100 iiiiiiii</tt> || 2 || 1
|-
| ADD AX, imm || <tt>05 ii ii</tt> || <tt>00000101 iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| ADD mem8, imm8 || <tt>80 /0 ii</tt> || <tt>10000000 oo000mmm iiiiiiii</tt> || 3+ || 3
|-
| ADD mem16, imm16 || <tt>81 /0 ii ii</tt> || <tt>10000001 oo000mmm iiiiiiii iiiiiiii</tt> || 4+ || 3
|-
| ADD mem16, simm8 || <tt>83 /0 ii ii</tt> || <tt>10000011 oo000mmm iiiiiiii iiiiiiii</tt> || 4+ || 3
|-
| ADD mem8, reg8 || <tt>00 /r</tt> || <tt>00000000 oorrrmmm</tt> || 2+ || 3
|-
| ADD mem16, reg16 || <tt>01 /r</tt> || <tt>00000001 oorrrmmm</tt> || 2+ || 3
|-
| ADD reg8, imm8 || <tt>80 /0 ii</tt> || <tt>10000000 11000mmm iiiiiiii</tt> || 3+ || 1
|-
| ADD reg16, imm16 || <tt>81 /0 ii ii</tt> || <tt>10000001 11000mmm iiiiiiii iiiiiiii</tt> || 4+ || 1
|-
| ADD reg16, simm8 || <tt>83 /0 ii ii</tt> || <tt>10000011 11000mmm iiiiiiii iiiiiiii</tt> || 4+ || 1
|-
| ADD reg8, mem8 || <tt>02 /r</tt> || <tt>00000010 oorrrmmm</tt> || 2+ || 2
|-
| ADD reg16, mem16 || <tt>03 /r</tt> || <tt>00000011 oorrrmmm</tt> || 2+ || 2
|-
| ADD reg8, reg8 || <tt>00 /r</tt> || <tt>000000.0 11rrrmmm</tt> || 2 || 1
|-
| ADD reg16, reg16 || <tt>01 /r</tt> || <tt>000000.1 11rrrmmm</tt> || 2 || 1
|}
----
{{Anchor|AND}}
=== AND ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| AND AL, imm || <tt>24 ii</tt> || <tt>00100100 iiiiiiii</tt> || 2 || 1
|-
| AND AX, imm || <tt>25 ii ii</tt> || <tt>00100101 iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| AND mem8, imm8 || <tt>80 /4 ii</tt> || <tt>10000000 oo100mmm iiiiiiii</tt> || 3+ || 3
|-
| AND mem16, imm16 || <tt>81 /4 ii ii</tt> || <tt>10000001 oo100mmm iiiiiiii iiiiiiii</tt> || 4+ || 3
|-
| AND mem16, simm8 || <tt>83 /4 ii ii</tt> || <tt>10000011 oo100mmm iiiiiiii iiiiiiii</tt> || 4+ || 3
|-
| AND mem8, reg8 || <tt>20 /r</tt> || <tt>00100000 oorrrmmm</tt> || 2+ || 3
|-
| AND mem16, reg16 || <tt>21 /r</tt> || <tt>00100001 oorrrmmm</tt> || 2+ || 3
|-
| AND reg8, imm8 || <tt>80 /4 ii</tt> || <tt>10000000 11100mmm iiiiiiii</tt> || 3+ || 1
|-
| AND reg16, imm16 || <tt>81 /4 ii ii</tt> || <tt>10000001 11100mmm iiiiiiii iiiiiiii</tt> || 4+ || 1
|-
| AND reg16, simm8 || <tt>83 /4 ii ii</tt> || <tt>10000011 11100mmm iiiiiiii iiiiiiii</tt> || 4+ || 1
|-
| AND reg8, mem8 || <tt>22 /r</tt> || <tt>00100010 oorrrmmm</tt> || 2+ || 2
|-
| AND reg16, mem16 || <tt>23 /r</tt> || <tt>00100011 oorrrmmm</tt> || 2+ || 2
|-
| AND reg8, reg8 || <tt>20 /r</tt> || <tt>001000.0 11rrrmmm</tt> || 2 || 1
|-
| AND reg16, reg16 || <tt>21 /r</tt> || <tt>001000.1 11rrrmmm</tt> || 2 || 1
|}
----
{{Anchor|BOUND}}
=== BOUND ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| BOUND reg16, mem16:16 || <tt>62 /r</tt> || <tt>01100010 oorrrmmm</tt> || 2+ || 13 (20 if condition met)
|}
----
{{Anchor|CALL}}
=== CALL ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| CALL ptr16:16 || <tt>CA oo oo ss ss</tt> || <tt>10011010 oooooooo oooooooo ssssssss ssssssss</tt> || 5 || 10
|-
| CALL mem16 || <tt>FF /2</tt> || <tt>11111111 oo010mmm</tt> || 2+ || 6
|-
| CALL mem16:16 || <tt>FF /3</tt> || <tt>11111111 oo011mmm</tt> || 2+ || 12
|-
| CALL reg16 || <tt>FF /2</tt> || <tt>11111111 11010mmm</tt> || 2 || 5
|-
| CALL rel16 || <tt>E8 ii ii</tt> || <tt>11101000 iiiiiiii iiiiiiii</tt> || 3 || 5
|}
----
{{Anchor|CBW}}
=== CBW ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| CBW || <tt>98</tt> || <tt>10011000</tt> || 1 || 1
|}
----
{{Anchor|CLC}}
=== CLC ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| CLC || <tt>F8</tt> || <tt>11111000</tt> || 1 || 4
|}
----
{{Anchor|CLD}}
=== CLD ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| CLD || <tt>FC</tt> || <tt>11111100</tt> || 1 || 4
|}
----
{{Anchor|CLI}}
=== CLI ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| CLI || <tt>FA</tt> || <tt>11111010</tt> || 1 || 4
|}
----
{{Anchor|CMC}}
=== CMC ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| CMC || <tt>F5</tt> || <tt>11110101</tt> || 1 || 4
|}
----
{{Anchor|CMP}}
=== CMP ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| CMP AL, imm || <tt>3C ii</tt> || <tt>00111100 iiiiiiii</tt> || 2 || 1
|-
| CMP AX, imm || <tt>3D ii ii</tt> || <tt>00111101 iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| CMP mem8, imm8 || <tt>80 /7 ii</tt> || <tt>10000000 oo111mmm iiiiiiii</tt> || 3+ || 2
|-
| CMP mem16, imm16 || <tt>81 /7 ii ii</tt> || <tt>10000001 oo111mmm iiiiiiii iiiiiiii</tt> || 4+ || 2
|-
| CMP mem16, simm8 || <tt>83 /7 ii ii</tt> || <tt>10000011 oo111mmm iiiiiiii iiiiiiii</tt> || 4+ || 2
|-
| CMP mem8, reg8 || <tt>38 /r</tt> || <tt>00111000 oorrrmmm</tt> || 2+ || 2
|-
| CMP mem16, reg16 || <tt>39 /r</tt> || <tt>00111001 oorrrmmm</tt> || 2+ || 2
|-
| CMP reg8, imm8 || <tt>80 /7 ii</tt> || <tt>10000000 11111mmm iiiiiiii</tt> || 3+ || 1
|-
| CMP reg16, imm16 || <tt>81 /7 ii ii</tt> || <tt>10000001 11111mmm iiiiiiii iiiiiiii</tt> || 4+ || 1
|-
| CMP reg16, simm8 || <tt>83 /7 ii ii</tt> || <tt>10000011 11111mmm iiiiiiii iiiiiiii</tt> || 4+ || 1
|-
| CMP reg8, mem8 || <tt>3A /r</tt> || <tt>00111010 oorrrmmm</tt> || 2+ || 2
|-
| CMP reg16, mem16 || <tt>3B /r</tt> || <tt>00111011 oorrrmmm</tt> || 2+ || 2
|-
| CMP reg8, reg8 || <tt>38 /r</tt> || <tt>001110.0 11rrrmmm</tt> || 2 || 1
|-
| CMP reg16, reg16 || <tt>39 /r</tt> || <tt>001110.1 11rrrmmm</tt> || 2 || 1
|}
----
{{Anchor|CMPSB}}
=== CMPSB ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| CMPSB || <tt>A6</tt> || <tt>10100110</tt> || 1 || 6
|}
----
{{Anchor|CMPSW}}
=== CMPSW ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| CMPSW || <tt>A7</tt> || <tt>10100111</tt> || 1 || 6
|}
----
{{Anchor|CS}}
=== CS ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| CS || <tt>2E</tt> || <tt>00101110</tt> || 1 || 1
|}
----
{{Anchor|CWD}}
=== CWD ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| CWD || <tt>99</tt> || <tt>10011001</tt> || 1 || 1
|}
----
{{Anchor|DAA}}
=== DAA ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| DAA || <tt>27</tt> || <tt>00100111</tt> || 1 || 10
|}
----
{{Anchor|DAS}}
=== DAS ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| DAS || <tt>2F</tt> || <tt>00101111</tt> || 1 || 10
|}
----
{{Anchor|DEC}}
=== DEC ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| DEC mem8 || <tt>FE /1</tt> || <tt>11111110 oo001mmm</tt> || 2+ || 3
|-
| DEC mem16 || <tt>FF /1</tt> || <tt>11111111 oo001mmm</tt> || 2+ || 3
|-
| DEC reg8 || <tt>FE /1</tt> || <tt>11111110 11001mmm</tt> || 2+ || 1
|-
| DEC reg16 || <tt>4x</tt> || <tt>01001rrr</tt> || 1 || 1
|}
----
{{Anchor|DIV}}
=== DIV ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| DIV mem8 || <tt>F6 /6</tt> || <tt>11110110 oo110mmm</tt> || 2+ || 16
|-
| DIV mem16 || <tt>F7 /6</tt> || <tt>11111111 oo110mmm</tt> || 2+ || 24
|-
| DIV reg8 || <tt>F6 /6</tt> || <tt>11111110 11110mmm</tt> || 2+ || 15
|-
| DIV reg16 || <tt>F7 /6</tt> || <tt>11111111 11110mmm</tt> || 2+ || 23
|}
----
{{Anchor|DS}}
=== DS ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| DS || <tt>3E</tt> || <tt>00111110</tt> || 1 || 1
|}
----
{{Anchor|ENTER}}
=== ENTER ===
----
{{Anchor|ES}}
=== ES ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| ES || <tt>26</tt> || <tt>00100110</tt> || 1 || 1
|}
----
{{Anchor|HLT}}
=== HLT ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| HLT || <tt>F4</tt> || <tt>11110100</tt> || 1 || 9
|}
----
{{Anchor|IDIV}}
=== IDIV ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| IDIV mem8 || <tt>F6 /7</tt> || <tt>11110110 oo111mmm</tt> || 2+ || 18
|-
| IDIV mem16 || <tt>F7 /7</tt> || <tt>11111111 oo111mmm</tt> || 2+ || 25
|-
| IDIV reg8 || <tt>F6 /7</tt> || <tt>11111110 11111mmm</tt> || 2+ || 17
|-
| IDIV reg16 || <tt>F7 /7</tt> || <tt>11111111 11111mmm</tt> || 2+ || 24
|}
----
{{Anchor|IMUL}}
=== IMUL ===
----
{{Anchor|IN}}
=== IN ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| IN AL, DX || <tt>EC</tt> || <tt>11101100</tt> || 1 || 6
|-
| IN AX, DX || <tt>ED</tt> || <tt>11101101</tt> || 1 || 6
|-
| IN AL, imm8 || <tt>E4 ii</tt> || <tt>11100100 iiiiiiii</tt> || 2 || 6
|-
| IN AX, imm8 || <tt>E5 ii</tt> || <tt>11100101 iiiiiiii</tt> || 2 || 6
|}
----
{{Anchor|INC}}
=== INC ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| INC mem8 || <tt>FE /0</tt> || <tt>11111110 oo000mmm</tt> || 2+ || 3
|-
| INC mem16 || <tt>FF /0</tt> || <tt>11111111 oo000mmm</tt> || 2+ || 3
|-
| INC reg8 || <tt>FE /0</tt> || <tt>11111110 11000mmm</tt> || 2+ || 1
|-
| INC reg16 || <tt>4x</tt> || <tt>01000rrr</tt> || 1 || 1
|}
----
{{Anchor|INSB}}
=== INSB ===
----
{{Anchor|INSW}}
=== INSW ===
----
{{Anchor|INT}}
=== INT ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| INT 3 || <tt>CC</tt> || <tt>11001100</tt> || 1 || 9
|-
| INT imm8 || <tt>CD ii</tt> || <tt>11001101 iiiiiiii</tt> || 2 || 10
|}
----
{{Anchor|INTO}}
=== INTO ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| INTO || <tt>CE</tt> || <tt>11001110</tt> || 1 || 6 (13 if OF = 1)
|}
----
{{Anchor|IRET}}
=== IRET ===
----
{{Anchor|JA}}
=== JA ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JA rel8 || <tt>77 ii</tt> || <tt>01110111 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JBE}}
=== JBE ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JA rel8 || <tt>76 ii</tt> || <tt>01110110 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JC}}
=== JC/JB ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JC rel8 || <tt>72 ii</tt> || <tt>01110010 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JCXZ}}
=== JCXZ ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JCXZ rel8 || <tt>E3 ii</tt> || <tt>11100011 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JG}}
=== JG ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JG rel8 || <tt>7F ii</tt> || <tt>01111111 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JGE}}
=== JGE ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JGE rel8 || <tt>7D ii</tt> || <tt>01111101 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JL}}
=== JL ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JL rel8 || <tt>7C ii</tt> || <tt>01111100 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JLE}}
=== JLE ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JLE rel8 || <tt>7E ii</tt> || <tt>01111110 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JMP}}
=== JMP ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JMP ptr16:16 || <tt>EA oo oo ss ss</tt> || <tt>11101010 oooooooo oooooooo ssssssss ssssssss</tt> || 5 || 7
|-
| JMP mem16 || <tt>FF /4</tt> || <tt>11111111 oo100mmm</tt> || 2+ || 5
|-
| JMP mem16:16 || <tt>FF /5</tt> || <tt>11111111 oo101mmm</tt> || 2+ || 10
|-
| JMP reg16 || <tt>FF /4</tt> || <tt>11111111 11100mmm</tt> || 2 || 4
|-
| JMP rel8 || <tt>EB ii</tt> || <tt>11101011 iiiiiiii</tt> || 2 || 4
|-
| JMP rel16 || <tt>E9 ii ii</tt> || <tt>11101001 iiiiiiii iiiiiiii</tt> || 3 || 4
|}
----
{{Anchor|JNC}}
=== JNC/JAE ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JNC rel8 || <tt>73 ii</tt> || <tt>01110011 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JNO}}
=== JNO ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JNO rel8 || <tt>71 ii</tt> || <tt>01110001 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JNP}}
=== JNP ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JNP rel8 || <tt>7B ii</tt> || <tt>01111011 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JNS}}
=== JNS ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JNS rel8 || <tt>79 ii</tt> || <tt>01111001 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JNZ}}
=== JNZ/JNE ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JNZ rel8 || <tt>75 ii</tt> || <tt>01110101 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JO}}
=== JO ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JO rel8 || <tt>70 ii</tt> || <tt>01110000 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JP}}
=== JP ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JP rel8 || <tt>7A ii</tt> || <tt>01111010 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JS}}
=== JS ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JS rel8 || <tt>78 ii</tt> || <tt>01111000 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JZ}}
=== JZ/JE ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JZ rel8 || <tt>74 ii</tt> || <tt>01110100 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|LAHF}}
=== LAHF ===
----
{{Anchor|LDS}}
=== LDS ===
----
{{Anchor|LEA}}
=== LEA ===
----
{{Anchor|LEAVE}}
=== LEAVE ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| LEAVE || <tt>C9</tt> || <tt>11001001</tt> || 1 || 2
|}
----
{{Anchor|LES}}
=== LES ===
----
{{Anchor|LOCK}}
=== LOCK ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| LOCK || <tt>F0</tt> || <tt>11110000</tt> || 1 || 1
|}
----
{{Anchor|LODSB}}
=== LODSB ===
----
{{Anchor|LODSW}}
=== LODSW ===
----
{{Anchor|LOOP}}
=== LOOP ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| LOOP rel8 || <tt>E2 ii</tt> || <tt>11100010 iiiiiiii</tt> || 2 || 2 (5 if branch taken)
|}
----
{{Anchor|LOOPE}}
=== LOOPE ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| LOOPE rel8 || <tt>E1 ii</tt> || <tt>11100001 iiiiiiii</tt> || 2 || 3 (6 if branch taken)
|}
----
{{Anchor|LOOPNE}}
=== LOOPNE ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| LOOPNE rel8 || <tt>E0 ii</tt> || <tt>11100000 iiiiiiii</tt> || 2 || 3 (6 if branch taken)
|}
----
{{Anchor|MOV}}
=== MOV ===
----
{{Anchor|MOVSB}}
=== MOVSB ===
----
{{Anchor|MOVSW}}
=== MOVSW ===
----
{{Anchor|MUL}}
=== MUL ===
----
{{Anchor|NEG}}
=== NEG ===
----
{{Anchor|NOP}}
=== NOP ===
----
{{Anchor|NOT}}
=== NOT ===
----
{{Anchor|OR}}
=== OR ===
----
{{Anchor|OUT}}
=== OUT ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| OUT AL, DX || <tt>EE</tt> || <tt>11101110</tt> || 1 || 6
|-
| OUT AX, DX || <tt>EF</tt> || <tt>11101111</tt> || 1 || 6
|-
| OUT AL, imm8 || <tt>E6 ii</tt> || <tt>11100110 iiiiiiii</tt> || 2 || 6
|-
| OUT AX, imm8 || <tt>E7 ii</tt> || <tt>11100111 iiiiiiii</tt> || 2 || 6
|}
----
{{Anchor|OUTSB}}
=== OUTSB ===
----
{{Anchor|OUTSW}}
=== OUTSW ===
----
{{Anchor|POLL}}
=== POLL ===
----
{{Anchor|POP}}
=== POP ===
----
{{Anchor|POPA}}
=== POPA ===
----
{{Anchor|POPF}}
=== POPF ===
----
{{Anchor|PUSH}}
=== PUSH ===
----
{{Anchor|PUSHA}}
=== PUSHA ===
----
{{Anchor|PUSHF}}
=== PUSHF ===
----
{{Anchor|RCL}}
=== RCL ===
----
{{Anchor|RCR}}
=== RCR ===
----
{{Anchor|REP}}
=== REP/REPE/REPZ ===
----
{{Anchor|REPNE}}
=== REPNE/REPNZ ===
----
{{Anchor|RET}}
=== RET ===
----
{{Anchor|RETF}}
=== RETF ===
----
{{Anchor|ROL}}
=== ROL ===
----
{{Anchor|ROR}}
=== ROR ===
----
{{Anchor|SAHF}}
=== SAHF ===
----
{{Anchor|SAR}}
=== SAR ===
----
{{Anchor|SBB}}
=== SBB ===
----
{{Anchor|SCASB}}
=== SCASB ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| SCASB || <tt>AE</tt> || <tt>10101110</tt> || 1 || 4
|}
----
{{Anchor|SCASW}}
=== SCASW ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| SCASW || <tt>AF</tt> || <tt>10101111</tt> || 1 || 4
|}
----
{{Anchor|SHL}}
=== SHL ===
----
{{Anchor|SHR}}
=== SHR ===
----
{{Anchor|SS}}
=== SS ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| SS || <tt>36</tt> || <tt>00110110</tt> || 1 || 1
|}
----
{{Anchor|STC}}
=== STC ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| STC || <tt>F9</tt> || <tt>11111001</tt> || 1 || 4
|}
----
{{Anchor|STD}}
=== STD ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| STD || <tt>FD</tt> || <tt>11111101</tt> || 1 || 4
|}
----
{{Anchor|STI}}
=== STI ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| STI || <tt>FB</tt> || <tt>11111011</tt> || 1 || 4
|}
----
{{Anchor|STOSB}}
=== STOSB ===
----
{{Anchor|STOSW}}
=== STOSW ===
----
{{Anchor|SUB}}
=== SUB ===
----
{{Anchor|TEST}}
=== TEST ===
----
{{Anchor|XCHG}}
=== XCHG ===
----
{{Anchor|XLAT}}
=== XLAT ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| XLAT || <tt>D7</tt> || <tt>11010111</tt> || 1 || 5
|}
----
{{Anchor|XOR}}
=== XOR ===
----
3486fbd16e89d919b14b7eb2964f8bab160e71ef
454
453
2024-12-27T21:31:55Z
Asie
351
/* Official instructions */
wikitext
text/x-wiki
__NOTOC__
Note that this page is a work in progress.
{| class="wikitable" style="text-align: center"
|+ Official V30MZ (80186) Instructions
|-
| [[#AAA|AAA]] || [[#AAD|AAD]] || [[#AAM|AAM]] || [[#AAS|AAS]] || [[#ADC|ADC]] || [[#ADD|ADD]] || [[#AND|AND]] || [[#BOUND|BOUND]] || [[#CALL|CALL]] || [[#CBW|CBW]] || [[#CLC|CLC]]
|-
| [[#CLD|CLD]] || [[#CLI|CLI]] || [[#CMC|CMC]] || [[#CMP|CMP]] || [[#CMPSB|CMPSB]] || [[#CMPSW|CMPSW]] || [[#CS|CS]] || [[#CWD|CWD]] || [[#DAA|DAA]] || [[#DAS|DAS]] || [[#DEC|DEC]]
|-
| [[#DIV|DIV]] || [[#DS|DS]] || [[#ENTER|ENTER]] || [[#ES|ES]] || [[#HLT|HLT]] || [[#IDIV|IDIV]] || [[#IMUL|IMUL]] || [[#IN|IN]] || [[#INC|INC]] || [[#INSB|INSB]] || [[#INSW|INSW]]
|-
| [[#INT|INT]] || [[#INTO|INTO]] || [[#IRET|IRET]] || [[#JA|JA]] || [[#JBE|JBE]] || [[#JC|JC]] || [[#JCXZ|JCXZ]] || [[#JG|JG]] || [[#JGE|JGE]] || [[#JL|JL]] || [[#JLE|JLE]]
|-
| [[#JMP|JMP]] || [[#JNC|JNC]] || [[#JNO|JNO]] || [[#JNP|JNP]] || [[#JNS|JNS]] || [[#JNZ|JNZ]] || [[#JO|JO]] || [[#JP|JP]] || [[#JS|JS]] || [[#JZ|JZ]] || [[#LAHF|LAHF]]
|-
| [[#LDS|LDS]] || [[#LEA|LEA]] || [[#LEAVE|LEAVE]] || [[#LES|LES]] || [[#LOCK|LOCK]] || [[#LODSB|LODSB]] || [[#LODSW|LODSW]] || [[#LOOP|LOOP]] || [[#LOOPE|LOOPE]] || [[#LOOPNE|LOOPNE]] || [[#MOV|MOV]]
|-
| [[#MOVSB|MOVSB]] || [[#MOVSW|MOVSW]] || [[#MUL|MUL]] || [[#NEG|NEG]] || [[#NOP|NOP]] || [[#NOT|NOT]] || [[#OR|OR]] || [[#OUT|OUT]] || [[#OUTSB|OUTSB]] || [[#OUTSW|OUTSW]] || [[#POLL|POLL]]
|-
| [[#POP|POP]] || [[#POPA|POPA]] || [[#POPF|POPF]] || [[#PUSH|PUSH]] || [[#PUSHA|PUSHA]] || [[#PUSHF|PUSHF]] || [[#RCL|RCL]] || [[#RCR|RCR]] || [[#REP|REP]] || [[#REPNE|REPNE]] || [[#RET|RET]]
|-
| [[#RETF|RETF]] || [[#ROL|ROL]] || [[#ROR|ROR]] || [[#SAHF|SAHF]] || [[#SAR|SAR]] || [[#SBB|SBB]] || [[#SCASB|SCASB]] || [[#SCASW|SCASW]] || [[#SHL|SHL]] || [[#SHR|SHR]] || [[#SS|SS]]
|-
| [[#STC|STC]] || [[#STD|STD]] || [[#STI|STI]] || [[#STOSB|STOSB]] || [[#STOSW|STOSW]] || [[#SUB|SUB]] || [[#TEST|TEST]] || [[#XCHG|XCHG]] || [[#XLAT|XLAT]] || [[#XOR|XOR]]
|}
{| class="mw-collapsible mw-collapsed wikitable sortable" style="width: 340px;"
|+ style="white-space:nowrap; border:1px solid; padding:3px; border-color:rgb(162, 169, 177); background-color:rgb(234, 236, 240);" | Intel <-> NEC mnemonic translation table
!Intel
!NEC
|-
| [[#AAA|AAA]]
| [[#AAA|ADJBA]]
|-
| [[#AAD|AAD]]
| [[#AAD|CVTDB]]
|-
| [[#AAM|AAM]]
| [[#AAM|CVTBD]]
|-
| [[#AAS|AAS]]
| [[#AAS|ADJBS]]
|-
| [[#ADC|ADC]]
| [[#ADC|ADDC]]
|-
| [[#ADD|ADD]]
| [[#ADD|ADD]]
|-
| [[#AND|AND]]
| [[#AND|AND]]
|-
| [[#BOUND|BOUND]]
| [[#BOUND|CHKIND]]
|-
| [[#CALL|CALL]]
| [[#CALL|CALL]]
|-
| [[#CBW|CBW]]
| [[#CBW|CVTBW]]
|-
| [[#CLC|CLC]]
| [[#CLC|CLR1 CY]]
|-
| [[#CLD|CLD]]
| [[#CLD|CLR1 DIR]]
|-
| [[#CLI|CLI]]
| [[#CLI|DI]]
|-
| [[#CMC|CMC]]
| [[#CMC|NOT1 CY]]
|-
| [[#CMP|CMP]]
| [[#CMP|CMP]]
|-
| [[#CMPSB|CMPSB]]
| [[#CMPSB|CMPBKB]]
|-
| [[#CMPSW|CMPSW]]
| [[#CMPSW|CMPBKW]]
|-
| [[#CS|CS]]
| [[#CS|PS]]
|-
| [[#CWD|CWD]]
| [[#CWD|CVTWL]]
|-
| [[#DAA|DAA]]
| [[#DAA|ADJ4A]]
|-
| [[#DAS|DAS]]
| [[#DAS|ADJ4S]]
|-
| [[#DEC|DEC]]
| [[#DEC|DEC]]
|-
| [[#DIV|DIV]]
| [[#DIV|DIVU]]
|-
| [[#DS|DS]]
| [[#DS|DS0]]
|-
| [[#ENTER|ENTER]]
| [[#ENTER|PREPARE]]
|-
| [[#ES|ES]]
| [[#ES|DS1]]
|-
| [[#HLT|HLT]]
| [[#HLT|HALT]]
|-
| [[#IDIV|IDIV]]
| [[#IDIV|DIV]]
|-
| [[#IMUL|IMUL]]
| [[#IMUL|MUL]]
|-
| [[#IN|IN]]
| [[#IN|IN]]
|-
| [[#INC|INC]]
| [[#INC|INC]]
|-
| [[#INSB|INSB]]
| [[#INSB|INMB]]
|-
| [[#INSW|INSW]]
| [[#INSW|INMW]]
|-
| [[#INT|INT]]
| [[#INT|BRK]]
|-
| [[#INTO|INTO]]
| [[#INTO|BRKV]]
|-
| [[#IRET|IRET]]
| [[#IRET|RETI]]
|-
| [[#JA|JA]]
| [[#JA|BH]]
|-
| [[#JBE|JBE]]
| [[#JBE|BNH]]
|-
| [[#JC|JC/JB]]
| [[#JC|BC/BL]]
|-
| [[#JCXZ|JCXZ]]
| [[#JCXZ|BCWZ]]
|-
| [[#JG|JG]]
| [[#JG|BGT]]
|-
| [[#JGE|JGE]]
| [[#JGE|BGE]]
|-
| [[#JL|JL]]
| [[#JL|BLT]]
|-
| [[#JLE|JLE]]
| [[#JLE|BLE]]
|-
| [[#JMP|JMP]]
| [[#JMP|BR]]
|-
| [[#JNC|JNC/JAE]]
| [[#JNC|BNC/BNL]]
|-
| [[#JNO|JNO]]
| [[#JNO|BNV]]
|-
| [[#JNP|JNP]]
| [[#JNP|BPO]]
|-
| [[#JNS|JNS]]
| [[#JNS|BP]]
|-
| [[#JNZ|JNZ/JNE]]
| [[#JNZ|BNZ/BNE]]
|-
| [[#JO|JO]]
| [[#JO|BV]]
|-
| [[#JP|JP]]
| [[#JP|BPE]]
|-
| [[#JS|JS]]
| [[#JS|BN]]
|-
| [[#JZ|JZ/JE]]
| [[#JZ|BZ/BE]]
|-
| [[#LAHF|LAHF]]
| [[#LAHF|MOV]]
|-
| [[#LDS|LDS]]
| [[#LDS|MOV]]
|-
| [[#LEA|LEA]]
| [[#LEA|LDEA]]
|-
| [[#LEAVE|LEAVE]]
| [[#LEAVE|DISPOSE]]
|-
| [[#LES|LES]]
| [[#LES|MOV]]
|-
| [[#LOCK|LOCK]]
| [[#LOCK|BUSLOCK]]
|-
| [[#LODSB|LODSB]]
| [[#LODSB|LDMB]]
|-
| [[#LODSW|LODSW]]
| [[#LODSW|LDMW]]
|-
| [[#LOOP|LOOP]]
| [[#LOOP|DBNZ]]
|-
| [[#LOOPE|LOOPE]]
| [[#LOOPE|DBNZE]]
|-
| [[#LOOPNE|LOOPNE]]
| [[#LOOPNE|DBNZNE]]
|-
| [[#MOV|MOV]]
| [[#MOV|MOV]]
|-
| [[#MOVSB|MOVSB]]
| [[#MOVSB|MOVBKB]]
|-
| [[#MOVSW|MOVSW]]
| [[#MOVSW|MOVBKW]]
|-
| [[#MUL|MUL]]
| [[#MUL|MULU]]
|-
| [[#NEG|NEG]]
| [[#NEG|NEG]]
|-
| [[#NOP|NOP]]
| [[#NOP|NOP]]
|-
| [[#NOT|NOT]]
| [[#NOT|NOT]]
|-
| [[#OR|OR]]
| [[#OR|OR]]
|-
| [[#OUT|OUT]]
| [[#OUT|OUT]]
|-
| [[#OUTSB|OUTSB]]
| [[#OUTSB|OUTM]]
|-
| [[#OUTSW|OUTSW]]
| [[#OUTSW|OUTM]]
|-
| [[#POLL|POLL]]
| [[#POLL|POLL]]
|-
| [[#POP|POP]]
| [[#POP|POP]]
|-
| [[#POPA|POPA]]
| [[#POPA|POP]]
|-
| [[#POPF|POPF]]
| [[#POPF|POP]]
|-
| [[#PUSH|PUSH]]
| [[#PUSH|PUSH]]
|-
| [[#PUSHA|PUSHA]]
| [[#PUSHA|PUSH]]
|-
| [[#PUSHF|PUSHF]]
| [[#PUSHF|PUSH]]
|-
| [[#RCL|RCL]]
| [[#RCL|ROLC]]
|-
| [[#RCR|RCR]]
| [[#RCR|RORC]]
|-
| [[#REP|REP/REPE/REPZ]]
| [[#REP|REP/REPE/REPZ]]
|-
| [[#REPNE|REPNE/REPNZ]]
| [[#REPNE|REPNE/REPNZ]]
|-
| [[#RET|RET]]
| [[#RET|RET]]
|-
| [[#RETF|RETF]]
| [[#RETF|RET]]
|-
| [[#ROL|ROL]]
| [[#ROL|ROL]]
|-
| [[#ROR|ROR]]
| [[#ROR|ROR]]
|-
| [[#SAHF|SAHF]]
| [[#SAHF|MOV]]
|-
| [[#SAR|SAR]]
| [[#SAR|SHRA]]
|-
| [[#SBB|SBB]]
| [[#SBB|SUBC]]
|-
| [[#SCASB|SCASB]]
| [[#SCASB|CMPMB]]
|-
| [[#SCASW|SCASW]]
| [[#SCASW|CMPMW]]
|-
| [[#SHL|SHL]]
| [[#SHL|SHL]]
|-
| [[#SHR|SHR]]
| [[#SHR|SHR]]
|-
| [[#SS|SS]]
| [[#SS|SS]]
|-
| [[#STC|STC]]
| [[#STC|SET1 CY]]
|-
| [[#STD|STD]]
| [[#STD|SET1 DIR]]
|-
| [[#STI|STI]]
| [[#STI|EI]]
|-
| [[#STOSB|STOSB]]
| [[#STOSB|STMB]]
|-
| [[#STOSW|STOSW]]
| [[#STOSW|STMW]]
|-
| [[#SUB|SUB]]
| [[#SUB|SUB]]
|-
| [[#TEST|TEST]]
| [[#TEST|TEST]]
|-
| [[#XCHG|XCHG]]
| [[#XCHG|XCH]]
|-
| [[#XLAT|XLAT]]
| [[#XLAT|TRANS]]
|-
| [[#XOR|XOR]]
| [[#XOR|XOR]]
|}
== Official instructions by type ==
{| class="wikitable sortable" style="text-align: center"
!Type
!colspan=16 class="unsortable" | Instructions
|-
| style="text-align:left;" | Memory
| style="" | [[#MOV|MOV]]
| style="" | [[#XCHG|XCHG]]
| style="" | [[#XLAT|XLAT]]
| style="" | [[#LEA|LEA]]
| style="border-right:none;" | [[#LDS|LDS]]
| style="border-left:none;" | [[#LES|LES]]
| style="border-right:none;" | [[#IN|IN]]
| style="border-left:none;" | [[#OUT|OUT]]
| colspan="8" |
|-
| style="text-align:left;" | Ports
| style="border-right:none;" | [[#IN|IN]]
| style="border-left:none;" | [[#OUT|OUT]]
| style="border-right:none;" | [[#INSB|INSB]]
| style="border-left:none;" | [[#OUTSB|OUTSB]]
| style="border-right:none;" | [[#INSW|INSW]]
| style="border-left:none;" | [[#OUTSW|OUTSW]]
| colspan="10" |
|-
| style="text-align:left;" | Arithmetic
| style="border-right:none;" | [[#ADD|ADD]]
| style="border-left:none;" | [[#SUB|SUB]]
| style="border-right:none;" | [[#ADC|ADC]]
| style="border-left:none;" | [[#SBB|SBB]]
| style="border-right:none;" | [[#INC|INC]]
| style="border-left:none;" | [[#DEC|DEC]]
| style="border-right:none;" | [[#MUL|MUL]]
| style="border-left:none;" | [[#DIV|DIV]]
| style="border-right:none;" | [[#IMUL|IMUL]]
| style="border-left:none;" | [[#IDIV|IDIV]]
| style="" | [[#CMP|CMP]]
| style="" | [[#NEG|NEG]]
| colspan="4" |
|-
| style="text-align:left;" | Numeric
| style="" | [[#CBW|CBW]]
| style="" | [[#CWD|CWD]]
| style="" | [[#AAA|AAA]]
| style="" | [[#AAS|AAS]]
| style="" | [[#AAM|AAM]]
| style="" | [[#AAD|AAD]]
| style="" | [[#DAA|DAA]]
| style="" | [[#DAS|DAS]]
| colspan="8" |
|-
| style="text-align:left;" | Shift
| style="border-right:none;" | [[#ROL|ROL]]
| style="border-left:none;" | [[#ROR|ROR]]
| style="border-right:none;" | [[#RCL|RCL]]
| style="border-left:none;" | [[#RCR|RCR]]
| style="border-right:none;" | [[#SHL|SHL]]
| style="border-left:none;" | [[#SHR|SHR]]
| style="" | [[#SAR|SAR]]
| colspan="9" |
|-
| style="text-align:left;" | Bitwise
| style="" | [[#AND|AND]]
| style="" | [[#OR|OR]]
| style="" | [[#XOR|XOR]]
| style="" | [[#NOT|NOT]]
| style="" | [[#TEST|TEST]]
| colspan="11" |
|-
| style="text-align:left;" | Branch
| style="border-right:none;" | [[#JC|JC]]
| style="border-left:none;" | [[#JNC|JNC]]
| style="border-right:none;" | [[#JZ|JZ]]
| style="border-left:none;" | [[#JNZ|JNZ]]
| style="border-right:none;" | [[#JBE|JBE]]
| style="border-left:none;" | [[#JA|JA]]
| style="border-right:none;" | [[#JO|JO]]
| style="border-left:none;" | [[#JNO|JNO]]
| style="border-right:none;" | [[#JP|JP]]
| style="border-left:none;" | [[#JNP|JNP]]
| style="border-right:none;" | [[#JS|JS]]
| style="border-left:none;" | [[#JNS|JNS]]
| style="border-right:none;" | [[#JL|JL]]
| style="border-left:none;" | [[#JGE|JGE]]
| style="border-right:none;" | [[#JLE|JLE]]
| style="border-left:none;" | [[#JG|JG]]
|-
| style="text-align:left;" | Jump
| style="" | [[#JMP|JMP]]
| style="border-right:none;" | [[#CALL|CALL]]
| style="border-left:none;border-right:none;" | [[#RET|RET]]
| style="border-left:none;" | [[#RETF|RETF]]
| colspan="12" |
|-
| style="text-align:left;" | Loop
| style="" | [[#LOOP|LOOP]]
| style="" | [[#LOOPE|LOOPE]]
| style="" | [[#LOOPNE|LOOPNE]]
| colspan="13" |
|-
| style="text-align:left;" | Interrupt
| style="border-right:none;" | [[#INT|INT]]
| style="border-left:none;" | [[#IRET|IRET]]
| style="" | [[#INTO|INTO]]
| style="" | [[#HLT|HLT]]
| style="" | [[#BOUND|BOUND]]
| colspan="11" |
|-
| style="text-align:left;" | Stack
| style="border-right:none;" | [[#PUSH|PUSH]]
| style="border-left:none;" | [[#POP|POP]]
| style="border-right:none;" | [[#PUSHA|PUSHA]]
| style="border-left:none;" | [[#POPA|POPA]]
| style="border-right:none;" | [[#PUSHF|PUSHF]]
| style="border-left:none;" | [[#POPF|POPF]]
| colspan="10" |
|-
| style="text-align:left;" | Flags
| style="border-right:none;" | [[#CLC|CLC]]
| style="border-left:none;" | [[#STC|STC]]
| style="border-right:none;" | [[#CLD|CLD]]
| style="border-left:none;" | [[#STD|STD]]
| style="border-right:none;" | [[#CLI|CLI]]
| style="border-left:none;" | [[#STI|STI]]
| style="" | [[#CMC|CMC]]
| style="border-right:none;" | [[#LAHF|LAHF]]
| style="border-left:none;" | [[#SAHF|SAHF]]
| colspan="7" |
|-
| style="text-align:left;" | Prefix
| style="" | [[#CS|CS]]
| style="" | [[#DS|DS]]
| style="" | [[#ES|ES]]
| style="" | [[#SS|SS]]
| colspan="12" |
|-
| style="text-align:left;" | String
| style="border-right:none;" | [[#REP|REP]]
| style="border-left:none;border-right:none;" | [[#REP|REPE]]
| style="border-left:none;" | [[#REPNE|REPNE]]
| style="" | [[#MOVSB|MOVSB]]
| style="" | [[#MOVSW|MOVSW]]
| style="border-right:none;" | [[#LODSB|LODSB]]
| style="border-left:none;" | [[#STOSB|STOSB]]
| style="border-right:none;" | [[#LODSW|LODSW]]
| style="border-left:none;" | [[#STOSW|STOSW]]
| style="" | [[#CMPSB|CMPSB]]
| style="" | [[#SCASB|SCASB]]
| style="" | [[#CMPSW|CMPSW]]
| style="" | [[#SCASW|SCASW]]
| colspan="3" |
|-
| style="text-align:left;" | Other
| style="" | [[#NOP|NOP]]
| style="border-right:none;" | [[#ENTER|ENTER]]
| style="border-left:none;" | [[#LEAVE|LEAVE]]
| style="" | [[#LOCK|LOCK]]
| style="" | [[#POLL|POLL]]
| colspan="11" |
|}
== Instruction encoding ==
=== ModR/M byte ===
The ModR/M byte is used in most addressing modes which reference a memory location. This byte consists of three bitfield values:
* <tt>oo</tt> - M'''o'''de;
* <tt>rrr</tt> - Two possible functions:
** '''R'''egister (for addressing modes which require both a register and a register/memory operand),
** Opcode extension (for some opcodes' addressing modes which do not have such a requirement);
* <tt>mmm</tt> - Register/'''M'''emory.
The ''Mode'' and ''Register/Memory'' bitfields can refer to a memory location or to a register, as shown in the table below. In some addressing modes, the ''Register'' field also refers to a register; it is always interpreted as if ''Mode'' was equal to <tt>11</tt>.
{| class="wikitable" style="text-align: center"
! R/M \ Mode
! <tt>00</tt>
! <tt>01</tt>
! <tt>10</tt>
! <tt>11</tt> ''(byte)''
! <tt>11</tt> ''(word)''
|-
| <tt>000</tt>
| DS:[BX + SI]
| DS:[BX + SI + disp8]
| DS:[BX + SI + disp16]
| AL
| AX
|-
| <tt>001</tt>
| DS:[BX + DI]
| DS:[BX + DI + disp8]
| DS:[BX + DI + disp16]
| CL
| CX
|-
| <tt>010</tt>
| SS:[BP + SI]
| SS:[BP + SI + disp8]
| SS:[BP + SI + disp16]
| DL
| DX
|-
| <tt>011</tt>
| SS:[BP + DI]
| SS:[BP + DI + disp8]
| SS:[BP + DI + disp16]
| BL
| BX
|-
| <tt>100</tt>
| DS:[SI]
| DS:[SI + disp8]
| DS:[SI + disp16]
| AH
| SP
|-
| <tt>101</tt>
| DS:[DI]
| DS:[DI + disp8]
| DS:[DI + disp16]
| CH
| BP
|-
| <tt>110</tt>
| ''DS:[disp16]''
| SS:[BP + disp8]
| SS:[BP + disp16]
| DH
| SI
|-
| <tt>111</tt>
| DS:[BX]
| DS:[BX + disp8]
| DS:[BX + disp16]
| BH
| DI
|}
Displacements are either 8-bit (disp8) or 16-bit (disp16) signed values and they always immediately follow the ModR/M byte. Note that (<tt>oo</tt> = <tt>00</tt>, <tt>mmm</tt> = <tt>110</tt>) is a special case, in which the ''disp16'' value is used directly as a near pointer.
The instruction encoding lists below refer to this byte as <tt>oorrrmmm</tt> (binary), <tt>/r</tt> (hexadecimal) or <tt>/0</tt> (hexademical, <tt>rrr</tt> used as function <tt>0</tt>).
== Official instructions ==
{{Anchor|AAA}}
=== AAA ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| AAA || <tt>37</tt> || <tt>00110111</tt> || 1 || 9
|}
----
{{Anchor|AAD}}
=== AAD ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| AAD imm8 || <tt>B5 ii</tt> || <tt>11010100 iiiiiiii</tt> || 2 || 6
|}
----
{{Anchor|AAM}}
=== AAM ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| AAM imm8 || <tt>B4 ii</tt> || <tt>11010100 iiiiiiii</tt> || 2 || 17
|}
----
{{Anchor|AAS}}
=== AAS ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| AAS || <tt>3F</tt> || <tt>00111111</tt> || 1 || 9
|}
----
{{Anchor|ADC}}
=== ADC ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| ADC AL, imm || <tt>14 ii</tt> || <tt>00010100 iiiiiiii</tt> || 2 || 1
|-
| ADC AX, imm || <tt>15 ii ii</tt> || <tt>00010101 iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| ADC mem8, imm8 || <tt>80 /2 ii</tt> || <tt>10000000 oo010mmm iiiiiiii</tt> || 3+ || 3
|-
| ADC mem16, imm16 || <tt>81 /2 ii ii</tt> || <tt>10000001 oo010mmm iiiiiiii iiiiiiii</tt> || 4+ || 3
|-
| ADC mem16, simm8 || <tt>83 /2 ii ii</tt> || <tt>10000011 oo010mmm iiiiiiii iiiiiiii</tt> || 4+ || 3
|-
| ADC mem8, reg8 || <tt>10 /r</tt> || <tt>00010000 oorrrmmm</tt> || 2+ || 3
|-
| ADC mem16, reg16 || <tt>11 /r</tt> || <tt>00010001 oorrrmmm</tt> || 2+ || 3
|-
| ADC reg8, imm8 || <tt>80 /2 ii</tt> || <tt>10000000 11010mmm iiiiiiii</tt> || 3+ || 1
|-
| ADC reg16, imm16 || <tt>81 /2 ii ii</tt> || <tt>10000001 11010mmm iiiiiiii iiiiiiii</tt> || 4+ || 1
|-
| ADC reg16, simm8 || <tt>83 /2 ii ii</tt> || <tt>10000011 11010mmm iiiiiiii iiiiiiii</tt> || 4+ || 1
|-
| ADC reg8, mem8 || <tt>12 /r</tt> || <tt>00010010 oorrrmmm</tt> || 2+ || 2
|-
| ADC reg16, mem16 || <tt>13 /r</tt> || <tt>00010011 oorrrmmm</tt> || 2+ || 2
|-
| ADC reg8, reg8 || <tt>10 /r</tt> || <tt>000100.0 11rrrmmm</tt> || 2 || 1
|-
| ADC reg16, reg16 || <tt>11 /r</tt> || <tt>000100.1 11rrrmmm</tt> || 2 || 1
|}
----
{{Anchor|ADD}}
=== ADD ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| ADD AL, imm || <tt>04 ii</tt> || <tt>00000100 iiiiiiii</tt> || 2 || 1
|-
| ADD AX, imm || <tt>05 ii ii</tt> || <tt>00000101 iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| ADD mem8, imm8 || <tt>80 /0 ii</tt> || <tt>10000000 oo000mmm iiiiiiii</tt> || 3+ || 3
|-
| ADD mem16, imm16 || <tt>81 /0 ii ii</tt> || <tt>10000001 oo000mmm iiiiiiii iiiiiiii</tt> || 4+ || 3
|-
| ADD mem16, simm8 || <tt>83 /0 ii ii</tt> || <tt>10000011 oo000mmm iiiiiiii iiiiiiii</tt> || 4+ || 3
|-
| ADD mem8, reg8 || <tt>00 /r</tt> || <tt>00000000 oorrrmmm</tt> || 2+ || 3
|-
| ADD mem16, reg16 || <tt>01 /r</tt> || <tt>00000001 oorrrmmm</tt> || 2+ || 3
|-
| ADD reg8, imm8 || <tt>80 /0 ii</tt> || <tt>10000000 11000mmm iiiiiiii</tt> || 3+ || 1
|-
| ADD reg16, imm16 || <tt>81 /0 ii ii</tt> || <tt>10000001 11000mmm iiiiiiii iiiiiiii</tt> || 4+ || 1
|-
| ADD reg16, simm8 || <tt>83 /0 ii ii</tt> || <tt>10000011 11000mmm iiiiiiii iiiiiiii</tt> || 4+ || 1
|-
| ADD reg8, mem8 || <tt>02 /r</tt> || <tt>00000010 oorrrmmm</tt> || 2+ || 2
|-
| ADD reg16, mem16 || <tt>03 /r</tt> || <tt>00000011 oorrrmmm</tt> || 2+ || 2
|-
| ADD reg8, reg8 || <tt>00 /r</tt> || <tt>000000.0 11rrrmmm</tt> || 2 || 1
|-
| ADD reg16, reg16 || <tt>01 /r</tt> || <tt>000000.1 11rrrmmm</tt> || 2 || 1
|}
----
{{Anchor|AND}}
=== AND ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| AND AL, imm || <tt>24 ii</tt> || <tt>00100100 iiiiiiii</tt> || 2 || 1
|-
| AND AX, imm || <tt>25 ii ii</tt> || <tt>00100101 iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| AND mem8, imm8 || <tt>80 /4 ii</tt> || <tt>10000000 oo100mmm iiiiiiii</tt> || 3+ || 3
|-
| AND mem16, imm16 || <tt>81 /4 ii ii</tt> || <tt>10000001 oo100mmm iiiiiiii iiiiiiii</tt> || 4+ || 3
|-
| AND mem16, simm8 || <tt>83 /4 ii ii</tt> || <tt>10000011 oo100mmm iiiiiiii iiiiiiii</tt> || 4+ || 3
|-
| AND mem8, reg8 || <tt>20 /r</tt> || <tt>00100000 oorrrmmm</tt> || 2+ || 3
|-
| AND mem16, reg16 || <tt>21 /r</tt> || <tt>00100001 oorrrmmm</tt> || 2+ || 3
|-
| AND reg8, imm8 || <tt>80 /4 ii</tt> || <tt>10000000 11100mmm iiiiiiii</tt> || 3+ || 1
|-
| AND reg16, imm16 || <tt>81 /4 ii ii</tt> || <tt>10000001 11100mmm iiiiiiii iiiiiiii</tt> || 4+ || 1
|-
| AND reg16, simm8 || <tt>83 /4 ii ii</tt> || <tt>10000011 11100mmm iiiiiiii iiiiiiii</tt> || 4+ || 1
|-
| AND reg8, mem8 || <tt>22 /r</tt> || <tt>00100010 oorrrmmm</tt> || 2+ || 2
|-
| AND reg16, mem16 || <tt>23 /r</tt> || <tt>00100011 oorrrmmm</tt> || 2+ || 2
|-
| AND reg8, reg8 || <tt>20 /r</tt> || <tt>001000.0 11rrrmmm</tt> || 2 || 1
|-
| AND reg16, reg16 || <tt>21 /r</tt> || <tt>001000.1 11rrrmmm</tt> || 2 || 1
|}
----
{{Anchor|BOUND}}
=== BOUND ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| BOUND reg16, mem16:16 || <tt>62 /r</tt> || <tt>01100010 oorrrmmm</tt> || 2+ || 13 (20 if condition met)
|}
----
{{Anchor|CALL}}
=== CALL ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| CALL ptr16:16 || <tt>CA oo oo ss ss</tt> || <tt>10011010 oooooooo oooooooo ssssssss ssssssss</tt> || 5 || 10
|-
| CALL mem16 || <tt>FF /2</tt> || <tt>11111111 oo010mmm</tt> || 2+ || 6
|-
| CALL mem16:16 || <tt>FF /3</tt> || <tt>11111111 oo011mmm</tt> || 2+ || 12
|-
| CALL reg16 || <tt>FF /2</tt> || <tt>11111111 11010mmm</tt> || 2 || 5
|-
| CALL rel16 || <tt>E8 ii ii</tt> || <tt>11101000 iiiiiiii iiiiiiii</tt> || 3 || 5
|}
----
{{Anchor|CBW}}
=== CBW ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| CBW || <tt>98</tt> || <tt>10011000</tt> || 1 || 1
|}
----
{{Anchor|CLC}}
=== CLC ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| CLC || <tt>F8</tt> || <tt>11111000</tt> || 1 || 4
|}
----
{{Anchor|CLD}}
=== CLD ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| CLD || <tt>FC</tt> || <tt>11111100</tt> || 1 || 4
|}
----
{{Anchor|CLI}}
=== CLI ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| CLI || <tt>FA</tt> || <tt>11111010</tt> || 1 || 4
|}
----
{{Anchor|CMC}}
=== CMC ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| CMC || <tt>F5</tt> || <tt>11110101</tt> || 1 || 4
|}
----
{{Anchor|CMP}}
=== CMP ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| CMP AL, imm || <tt>3C ii</tt> || <tt>00111100 iiiiiiii</tt> || 2 || 1
|-
| CMP AX, imm || <tt>3D ii ii</tt> || <tt>00111101 iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| CMP mem8, imm8 || <tt>80 /7 ii</tt> || <tt>10000000 oo111mmm iiiiiiii</tt> || 3+ || 2
|-
| CMP mem16, imm16 || <tt>81 /7 ii ii</tt> || <tt>10000001 oo111mmm iiiiiiii iiiiiiii</tt> || 4+ || 2
|-
| CMP mem16, simm8 || <tt>83 /7 ii ii</tt> || <tt>10000011 oo111mmm iiiiiiii iiiiiiii</tt> || 4+ || 2
|-
| CMP mem8, reg8 || <tt>38 /r</tt> || <tt>00111000 oorrrmmm</tt> || 2+ || 2
|-
| CMP mem16, reg16 || <tt>39 /r</tt> || <tt>00111001 oorrrmmm</tt> || 2+ || 2
|-
| CMP reg8, imm8 || <tt>80 /7 ii</tt> || <tt>10000000 11111mmm iiiiiiii</tt> || 3+ || 1
|-
| CMP reg16, imm16 || <tt>81 /7 ii ii</tt> || <tt>10000001 11111mmm iiiiiiii iiiiiiii</tt> || 4+ || 1
|-
| CMP reg16, simm8 || <tt>83 /7 ii ii</tt> || <tt>10000011 11111mmm iiiiiiii iiiiiiii</tt> || 4+ || 1
|-
| CMP reg8, mem8 || <tt>3A /r</tt> || <tt>00111010 oorrrmmm</tt> || 2+ || 2
|-
| CMP reg16, mem16 || <tt>3B /r</tt> || <tt>00111011 oorrrmmm</tt> || 2+ || 2
|-
| CMP reg8, reg8 || <tt>38 /r</tt> || <tt>001110.0 11rrrmmm</tt> || 2 || 1
|-
| CMP reg16, reg16 || <tt>39 /r</tt> || <tt>001110.1 11rrrmmm</tt> || 2 || 1
|}
----
{{Anchor|CMPSB}}
=== CMPSB ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| CMPSB || <tt>A6</tt> || <tt>10100110</tt> || 1 || 6
|}
----
{{Anchor|CMPSW}}
=== CMPSW ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| CMPSW || <tt>A7</tt> || <tt>10100111</tt> || 1 || 6
|}
----
{{Anchor|CS}}
=== CS ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| CS || <tt>2E</tt> || <tt>00101110</tt> || 1 || 1
|}
----
{{Anchor|CWD}}
=== CWD ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| CWD || <tt>99</tt> || <tt>10011001</tt> || 1 || 1
|}
----
{{Anchor|DAA}}
=== DAA ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| DAA || <tt>27</tt> || <tt>00100111</tt> || 1 || 10
|}
----
{{Anchor|DAS}}
=== DAS ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| DAS || <tt>2F</tt> || <tt>00101111</tt> || 1 || 10
|}
----
{{Anchor|DEC}}
=== DEC ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| DEC mem8 || <tt>FE /1</tt> || <tt>11111110 oo001mmm</tt> || 2+ || 3
|-
| DEC mem16 || <tt>FF /1</tt> || <tt>11111111 oo001mmm</tt> || 2+ || 3
|-
| DEC reg8 || <tt>FE /1</tt> || <tt>11111110 11001mmm</tt> || 2+ || 1
|-
| DEC reg16 || <tt>4x</tt> || <tt>01001rrr</tt> || 1 || 1
|}
----
{{Anchor|DIV}}
=== DIV ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| DIV mem8 || <tt>F6 /6</tt> || <tt>11110110 oo110mmm</tt> || 2+ || 16
|-
| DIV mem16 || <tt>F7 /6</tt> || <tt>11111111 oo110mmm</tt> || 2+ || 24
|-
| DIV reg8 || <tt>F6 /6</tt> || <tt>11111110 11110mmm</tt> || 2+ || 15
|-
| DIV reg16 || <tt>F7 /6</tt> || <tt>11111111 11110mmm</tt> || 2+ || 23
|}
----
{{Anchor|DS}}
=== DS ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| DS || <tt>3E</tt> || <tt>00111110</tt> || 1 || 1
|}
----
{{Anchor|ENTER}}
=== ENTER ===
----
{{Anchor|ES}}
=== ES ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| ES || <tt>26</tt> || <tt>00100110</tt> || 1 || 1
|}
----
{{Anchor|HLT}}
=== HLT ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| HLT || <tt>F4</tt> || <tt>11110100</tt> || 1 || 9
|}
----
{{Anchor|IDIV}}
=== IDIV ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| IDIV mem8 || <tt>F6 /7</tt> || <tt>11110110 oo111mmm</tt> || 2+ || 18
|-
| IDIV mem16 || <tt>F7 /7</tt> || <tt>11111111 oo111mmm</tt> || 2+ || 25
|-
| IDIV reg8 || <tt>F6 /7</tt> || <tt>11111110 11111mmm</tt> || 2+ || 17
|-
| IDIV reg16 || <tt>F7 /7</tt> || <tt>11111111 11111mmm</tt> || 2+ || 24
|}
----
{{Anchor|IMUL}}
=== IMUL ===
----
{{Anchor|IN}}
=== IN ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| IN AL, DX || <tt>EC</tt> || <tt>11101100</tt> || 1 || 6
|-
| IN AX, DX || <tt>ED</tt> || <tt>11101101</tt> || 1 || 6
|-
| IN AL, imm8 || <tt>E4 ii</tt> || <tt>11100100 iiiiiiii</tt> || 2 || 6
|-
| IN AX, imm8 || <tt>E5 ii</tt> || <tt>11100101 iiiiiiii</tt> || 2 || 6
|}
----
{{Anchor|INC}}
=== INC ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| INC mem8 || <tt>FE /0</tt> || <tt>11111110 oo000mmm</tt> || 2+ || 3
|-
| INC mem16 || <tt>FF /0</tt> || <tt>11111111 oo000mmm</tt> || 2+ || 3
|-
| INC reg8 || <tt>FE /0</tt> || <tt>11111110 11000mmm</tt> || 2+ || 1
|-
| INC reg16 || <tt>4x</tt> || <tt>01000rrr</tt> || 1 || 1
|}
----
{{Anchor|INSB}}
=== INSB ===
----
{{Anchor|INSW}}
=== INSW ===
----
{{Anchor|INT}}
=== INT ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| INT 3 || <tt>CC</tt> || <tt>11001100</tt> || 1 || 9
|-
| INT imm8 || <tt>CD ii</tt> || <tt>11001101 iiiiiiii</tt> || 2 || 10
|}
----
{{Anchor|INTO}}
=== INTO ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| INTO || <tt>CE</tt> || <tt>11001110</tt> || 1 || 6 (13 if OF = 1)
|}
----
{{Anchor|IRET}}
=== IRET ===
----
{{Anchor|JA}}
=== JA ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JA rel8 || <tt>77 ii</tt> || <tt>01110111 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JBE}}
=== JBE ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JA rel8 || <tt>76 ii</tt> || <tt>01110110 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JC}}
=== JC/JB ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JC rel8 || <tt>72 ii</tt> || <tt>01110010 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JCXZ}}
=== JCXZ ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JCXZ rel8 || <tt>E3 ii</tt> || <tt>11100011 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JG}}
=== JG ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JG rel8 || <tt>7F ii</tt> || <tt>01111111 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JGE}}
=== JGE ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JGE rel8 || <tt>7D ii</tt> || <tt>01111101 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JL}}
=== JL ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JL rel8 || <tt>7C ii</tt> || <tt>01111100 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JLE}}
=== JLE ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JLE rel8 || <tt>7E ii</tt> || <tt>01111110 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JMP}}
=== JMP ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JMP ptr16:16 || <tt>EA oo oo ss ss</tt> || <tt>11101010 oooooooo oooooooo ssssssss ssssssss</tt> || 5 || 7
|-
| JMP mem16 || <tt>FF /4</tt> || <tt>11111111 oo100mmm</tt> || 2+ || 5
|-
| JMP mem16:16 || <tt>FF /5</tt> || <tt>11111111 oo101mmm</tt> || 2+ || 10
|-
| JMP reg16 || <tt>FF /4</tt> || <tt>11111111 11100mmm</tt> || 2 || 4
|-
| JMP rel8 || <tt>EB ii</tt> || <tt>11101011 iiiiiiii</tt> || 2 || 4
|-
| JMP rel16 || <tt>E9 ii ii</tt> || <tt>11101001 iiiiiiii iiiiiiii</tt> || 3 || 4
|}
----
{{Anchor|JNC}}
=== JNC/JAE ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JNC rel8 || <tt>73 ii</tt> || <tt>01110011 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JNO}}
=== JNO ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JNO rel8 || <tt>71 ii</tt> || <tt>01110001 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JNP}}
=== JNP ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JNP rel8 || <tt>7B ii</tt> || <tt>01111011 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JNS}}
=== JNS ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JNS rel8 || <tt>79 ii</tt> || <tt>01111001 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JNZ}}
=== JNZ/JNE ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JNZ rel8 || <tt>75 ii</tt> || <tt>01110101 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JO}}
=== JO ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JO rel8 || <tt>70 ii</tt> || <tt>01110000 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JP}}
=== JP ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JP rel8 || <tt>7A ii</tt> || <tt>01111010 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JS}}
=== JS ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JS rel8 || <tt>78 ii</tt> || <tt>01111000 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JZ}}
=== JZ/JE ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JZ rel8 || <tt>74 ii</tt> || <tt>01110100 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|LAHF}}
=== LAHF ===
----
{{Anchor|LDS}}
=== LDS ===
----
{{Anchor|LEA}}
=== LEA ===
----
{{Anchor|LEAVE}}
=== LEAVE ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| LEAVE || <tt>C9</tt> || <tt>11001001</tt> || 1 || 2
|}
----
{{Anchor|LES}}
=== LES ===
----
{{Anchor|LOCK}}
=== LOCK ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| LOCK || <tt>F0</tt> || <tt>11110000</tt> || 1 || 1
|}
----
{{Anchor|LODSB}}
=== LODSB ===
----
{{Anchor|LODSW}}
=== LODSW ===
----
{{Anchor|LOOP}}
=== LOOP ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| LOOP rel8 || <tt>E2 ii</tt> || <tt>11100010 iiiiiiii</tt> || 2 || 2 (5 if branch taken)
|}
----
{{Anchor|LOOPE}}
=== LOOPE ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| LOOPE rel8 || <tt>E1 ii</tt> || <tt>11100001 iiiiiiii</tt> || 2 || 3 (6 if branch taken)
|}
----
{{Anchor|LOOPNE}}
=== LOOPNE ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| LOOPNE rel8 || <tt>E0 ii</tt> || <tt>11100000 iiiiiiii</tt> || 2 || 3 (6 if branch taken)
|}
----
{{Anchor|MOV}}
=== MOV ===
----
{{Anchor|MOVSB}}
=== MOVSB ===
----
{{Anchor|MOVSW}}
=== MOVSW ===
----
{{Anchor|MUL}}
=== MUL ===
----
{{Anchor|NEG}}
=== NEG ===
----
{{Anchor|NOP}}
=== NOP ===
----
{{Anchor|NOT}}
=== NOT ===
----
{{Anchor|OR}}
=== OR ===
----
{{Anchor|OUT}}
=== OUT ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| OUT AL, DX || <tt>EE</tt> || <tt>11101110</tt> || 1 || 6
|-
| OUT AX, DX || <tt>EF</tt> || <tt>11101111</tt> || 1 || 6
|-
| OUT AL, imm8 || <tt>E6 ii</tt> || <tt>11100110 iiiiiiii</tt> || 2 || 6
|-
| OUT AX, imm8 || <tt>E7 ii</tt> || <tt>11100111 iiiiiiii</tt> || 2 || 6
|}
----
{{Anchor|OUTSB}}
=== OUTSB ===
----
{{Anchor|OUTSW}}
=== OUTSW ===
----
{{Anchor|POLL}}
=== POLL ===
----
{{Anchor|POP}}
=== POP ===
----
{{Anchor|POPA}}
=== POPA ===
----
{{Anchor|POPF}}
=== POPF ===
----
{{Anchor|PUSH}}
=== PUSH ===
----
{{Anchor|PUSHA}}
=== PUSHA ===
----
{{Anchor|PUSHF}}
=== PUSHF ===
----
{{Anchor|RCL}}
=== RCL ===
----
{{Anchor|RCR}}
=== RCR ===
----
{{Anchor|REP}}
=== REP/REPE/REPZ ===
----
{{Anchor|REPNE}}
=== REPNE/REPNZ ===
----
{{Anchor|RET}}
=== RET ===
----
{{Anchor|RETF}}
=== RETF ===
----
{{Anchor|ROL}}
=== ROL ===
----
{{Anchor|ROR}}
=== ROR ===
----
{{Anchor|SAHF}}
=== SAHF ===
----
{{Anchor|SAR}}
=== SAR ===
----
{{Anchor|SBB}}
=== SBB ===
----
{{Anchor|SCASB}}
=== SCASB ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| SCASB || <tt>AE</tt> || <tt>10101110</tt> || 1 || 4
|}
----
{{Anchor|SCASW}}
=== SCASW ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| SCASW || <tt>AF</tt> || <tt>10101111</tt> || 1 || 4
|}
----
{{Anchor|SHL}}
=== SHL ===
----
{{Anchor|SHR}}
=== SHR ===
----
{{Anchor|SS}}
=== SS ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| SS || <tt>36</tt> || <tt>00110110</tt> || 1 || 1
|}
----
{{Anchor|STC}}
=== STC ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| STC || <tt>F9</tt> || <tt>11111001</tt> || 1 || 4
|}
----
{{Anchor|STD}}
=== STD ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| STD || <tt>FD</tt> || <tt>11111101</tt> || 1 || 4
|}
----
{{Anchor|STI}}
=== STI ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| STI || <tt>FB</tt> || <tt>11111011</tt> || 1 || 4
|}
----
{{Anchor|STOSB}}
=== STOSB ===
----
{{Anchor|STOSW}}
=== STOSW ===
----
{{Anchor|SUB}}
=== SUB ===
----
{{Anchor|TEST}}
=== TEST ===
----
{{Anchor|XCHG}}
=== XCHG ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| XCHG AX, reg16<br/>XCHG reg16, AX || <tt>9x</tt> || <tt>10010rrr</tt> || 1 || 3
|-
| XCHG mem8, reg8<br/>XCHG reg8, mem8 || <tt>86 /r</tt> || <tt>10000110 oorrrmmm</tt> || 2+ || 5
|-
| XCHG mem16, reg16<br/>XCHG reg16, mem16 || <tt>87 /r</tt> || <tt>10000111 oorrrmmm</tt> || 2+ || 5
|-
| XCHG reg8, reg8 || <tt>86 /r</tt> || <tt>10000110 11rrrmmm</tt> || 2+ || 3
|-
| XCHG reg16, reg16 || <tt>87 /r</tt> || <tt>10000111 11rrrmmm</tt> || 2+ || 3
|}
----
{{Anchor|XLAT}}
=== XLAT ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| XLAT || <tt>D7</tt> || <tt>11010111</tt> || 1 || 5
|}
----
{{Anchor|XOR}}
=== XOR ===
----
cd5169d8c63f06b0060b0662b1ae05573762a5e8
455
454
2024-12-27T21:50:41Z
Asie
351
wikitext
text/x-wiki
__NOTOC__
Note that this page is a work in progress.
{| class="wikitable" style="text-align: center"
|+ Official V30MZ (80186) Instructions
|-
| [[#AAA|AAA]] || [[#AAD|AAD]] || [[#AAM|AAM]] || [[#AAS|AAS]] || [[#ADC|ADC]] || [[#ADD|ADD]] || [[#AND|AND]] || [[#BOUND|BOUND]] || [[#CALL|CALL]] || [[#CBW|CBW]] || [[#CLC|CLC]]
|-
| [[#CLD|CLD]] || [[#CLI|CLI]] || [[#CMC|CMC]] || [[#CMP|CMP]] || [[#CMPSB|CMPSB]] || [[#CMPSW|CMPSW]] || [[#CS|CS]] || [[#CWD|CWD]] || [[#DAA|DAA]] || [[#DAS|DAS]] || [[#DEC|DEC]]
|-
| [[#DIV|DIV]] || [[#DS|DS]] || [[#ENTER|ENTER]] || [[#ES|ES]] || [[#HLT|HLT]] || [[#IDIV|IDIV]] || [[#IMUL|IMUL]] || [[#IN|IN]] || [[#INC|INC]] || [[#INSB|INSB]] || [[#INSW|INSW]]
|-
| [[#INT|INT]] || [[#INTO|INTO]] || [[#IRET|IRET]] || [[#JA|JA]] || [[#JBE|JBE]] || [[#JC|JC]] || [[#JCXZ|JCXZ]] || [[#JG|JG]] || [[#JGE|JGE]] || [[#JL|JL]] || [[#JLE|JLE]]
|-
| [[#JMP|JMP]] || [[#JNC|JNC]] || [[#JNO|JNO]] || [[#JNP|JNP]] || [[#JNS|JNS]] || [[#JNZ|JNZ]] || [[#JO|JO]] || [[#JP|JP]] || [[#JS|JS]] || [[#JZ|JZ]] || [[#LAHF|LAHF]]
|-
| [[#LDS|LDS]] || [[#LEA|LEA]] || [[#LEAVE|LEAVE]] || [[#LES|LES]] || [[#LOCK|LOCK]] || [[#LODSB|LODSB]] || [[#LODSW|LODSW]] || [[#LOOP|LOOP]] || [[#LOOPE|LOOPE]] || [[#LOOPNE|LOOPNE]] || [[#MOV|MOV]]
|-
| [[#MOVSB|MOVSB]] || [[#MOVSW|MOVSW]] || [[#MUL|MUL]] || [[#NEG|NEG]] || [[#NOP|NOP]] || [[#NOT|NOT]] || [[#OR|OR]] || [[#OUT|OUT]] || [[#OUTSB|OUTSB]] || [[#OUTSW|OUTSW]] || [[#POLL|POLL]]
|-
| [[#POP|POP]] || [[#POPA|POPA]] || [[#POPF|POPF]] || [[#PUSH|PUSH]] || [[#PUSHA|PUSHA]] || [[#PUSHF|PUSHF]] || [[#RCL|RCL]] || [[#RCR|RCR]] || [[#REP|REP]] || [[#REPNE|REPNE]] || [[#RET|RET]]
|-
| [[#RETF|RETF]] || [[#ROL|ROL]] || [[#ROR|ROR]] || [[#SAHF|SAHF]] || [[#SAR|SAR]] || [[#SBB|SBB]] || [[#SCASB|SCASB]] || [[#SCASW|SCASW]] || [[#SHL|SHL]] || [[#SHR|SHR]] || [[#SS|SS]]
|-
| [[#STC|STC]] || [[#STD|STD]] || [[#STI|STI]] || [[#STOSB|STOSB]] || [[#STOSW|STOSW]] || [[#SUB|SUB]] || [[#TEST|TEST]] || [[#XCHG|XCHG]] || [[#XLAT|XLAT]] || [[#XOR|XOR]]
|}
{| class="mw-collapsible mw-collapsed wikitable sortable" style="width: 340px;"
|+ style="white-space:nowrap; border:1px solid; padding:3px; border-color:rgb(162, 169, 177); background-color:rgb(234, 236, 240);" | Intel <-> NEC mnemonic translation table
!Intel
!NEC
|-
| [[#AAA|AAA]]
| [[#AAA|ADJBA]]
|-
| [[#AAD|AAD]]
| [[#AAD|CVTDB]]
|-
| [[#AAM|AAM]]
| [[#AAM|CVTBD]]
|-
| [[#AAS|AAS]]
| [[#AAS|ADJBS]]
|-
| [[#ADC|ADC]]
| [[#ADC|ADDC]]
|-
| [[#ADD|ADD]]
| [[#ADD|ADD]]
|-
| [[#AND|AND]]
| [[#AND|AND]]
|-
| [[#BOUND|BOUND]]
| [[#BOUND|CHKIND]]
|-
| [[#CALL|CALL]]
| [[#CALL|CALL]]
|-
| [[#CBW|CBW]]
| [[#CBW|CVTBW]]
|-
| [[#CLC|CLC]]
| [[#CLC|CLR1 CY]]
|-
| [[#CLD|CLD]]
| [[#CLD|CLR1 DIR]]
|-
| [[#CLI|CLI]]
| [[#CLI|DI]]
|-
| [[#CMC|CMC]]
| [[#CMC|NOT1 CY]]
|-
| [[#CMP|CMP]]
| [[#CMP|CMP]]
|-
| [[#CMPSB|CMPSB]]
| [[#CMPSB|CMPBKB]]
|-
| [[#CMPSW|CMPSW]]
| [[#CMPSW|CMPBKW]]
|-
| [[#CS|CS]]
| [[#CS|PS]]
|-
| [[#CWD|CWD]]
| [[#CWD|CVTWL]]
|-
| [[#DAA|DAA]]
| [[#DAA|ADJ4A]]
|-
| [[#DAS|DAS]]
| [[#DAS|ADJ4S]]
|-
| [[#DEC|DEC]]
| [[#DEC|DEC]]
|-
| [[#DIV|DIV]]
| [[#DIV|DIVU]]
|-
| [[#DS|DS]]
| [[#DS|DS0]]
|-
| [[#ENTER|ENTER]]
| [[#ENTER|PREPARE]]
|-
| [[#ES|ES]]
| [[#ES|DS1]]
|-
| [[#HLT|HLT]]
| [[#HLT|HALT]]
|-
| [[#IDIV|IDIV]]
| [[#IDIV|DIV]]
|-
| [[#IMUL|IMUL]]
| [[#IMUL|MUL]]
|-
| [[#IN|IN]]
| [[#IN|IN]]
|-
| [[#INC|INC]]
| [[#INC|INC]]
|-
| [[#INSB|INSB]]
| [[#INSB|INMB]]
|-
| [[#INSW|INSW]]
| [[#INSW|INMW]]
|-
| [[#INT|INT]]
| [[#INT|BRK]]
|-
| [[#INTO|INTO]]
| [[#INTO|BRKV]]
|-
| [[#IRET|IRET]]
| [[#IRET|RETI]]
|-
| [[#JA|JA]]
| [[#JA|BH]]
|-
| [[#JBE|JBE]]
| [[#JBE|BNH]]
|-
| [[#JC|JC/JB]]
| [[#JC|BC/BL]]
|-
| [[#JCXZ|JCXZ]]
| [[#JCXZ|BCWZ]]
|-
| [[#JG|JG]]
| [[#JG|BGT]]
|-
| [[#JGE|JGE]]
| [[#JGE|BGE]]
|-
| [[#JL|JL]]
| [[#JL|BLT]]
|-
| [[#JLE|JLE]]
| [[#JLE|BLE]]
|-
| [[#JMP|JMP]]
| [[#JMP|BR]]
|-
| [[#JNC|JNC/JAE]]
| [[#JNC|BNC/BNL]]
|-
| [[#JNO|JNO]]
| [[#JNO|BNV]]
|-
| [[#JNP|JNP]]
| [[#JNP|BPO]]
|-
| [[#JNS|JNS]]
| [[#JNS|BP]]
|-
| [[#JNZ|JNZ/JNE]]
| [[#JNZ|BNZ/BNE]]
|-
| [[#JO|JO]]
| [[#JO|BV]]
|-
| [[#JP|JP]]
| [[#JP|BPE]]
|-
| [[#JS|JS]]
| [[#JS|BN]]
|-
| [[#JZ|JZ/JE]]
| [[#JZ|BZ/BE]]
|-
| [[#LAHF|LAHF]]
| [[#LAHF|MOV]]
|-
| [[#LDS|LDS]]
| [[#LDS|MOV]]
|-
| [[#LEA|LEA]]
| [[#LEA|LDEA]]
|-
| [[#LEAVE|LEAVE]]
| [[#LEAVE|DISPOSE]]
|-
| [[#LES|LES]]
| [[#LES|MOV]]
|-
| [[#LOCK|LOCK]]
| [[#LOCK|BUSLOCK]]
|-
| [[#LODSB|LODSB]]
| [[#LODSB|LDMB]]
|-
| [[#LODSW|LODSW]]
| [[#LODSW|LDMW]]
|-
| [[#LOOP|LOOP]]
| [[#LOOP|DBNZ]]
|-
| [[#LOOPE|LOOPE]]
| [[#LOOPE|DBNZE]]
|-
| [[#LOOPNE|LOOPNE]]
| [[#LOOPNE|DBNZNE]]
|-
| [[#MOV|MOV]]
| [[#MOV|MOV]]
|-
| [[#MOVSB|MOVSB]]
| [[#MOVSB|MOVBKB]]
|-
| [[#MOVSW|MOVSW]]
| [[#MOVSW|MOVBKW]]
|-
| [[#MUL|MUL]]
| [[#MUL|MULU]]
|-
| [[#NEG|NEG]]
| [[#NEG|NEG]]
|-
| [[#NOP|NOP]]
| [[#NOP|NOP]]
|-
| [[#NOT|NOT]]
| [[#NOT|NOT]]
|-
| [[#OR|OR]]
| [[#OR|OR]]
|-
| [[#OUT|OUT]]
| [[#OUT|OUT]]
|-
| [[#OUTSB|OUTSB]]
| [[#OUTSB|OUTM]]
|-
| [[#OUTSW|OUTSW]]
| [[#OUTSW|OUTM]]
|-
| [[#POLL|POLL]]
| [[#POLL|POLL]]
|-
| [[#POP|POP]]
| [[#POP|POP]]
|-
| [[#POPA|POPA]]
| [[#POPA|POP]]
|-
| [[#POPF|POPF]]
| [[#POPF|POP]]
|-
| [[#PUSH|PUSH]]
| [[#PUSH|PUSH]]
|-
| [[#PUSHA|PUSHA]]
| [[#PUSHA|PUSH]]
|-
| [[#PUSHF|PUSHF]]
| [[#PUSHF|PUSH]]
|-
| [[#RCL|RCL]]
| [[#RCL|ROLC]]
|-
| [[#RCR|RCR]]
| [[#RCR|RORC]]
|-
| [[#REP|REP/REPE/REPZ]]
| [[#REP|REP/REPE/REPZ]]
|-
| [[#REPNE|REPNE/REPNZ]]
| [[#REPNE|REPNE/REPNZ]]
|-
| [[#RET|RET]]
| [[#RET|RET]]
|-
| [[#RETF|RETF]]
| [[#RETF|RET]]
|-
| [[#ROL|ROL]]
| [[#ROL|ROL]]
|-
| [[#ROR|ROR]]
| [[#ROR|ROR]]
|-
| [[#SAHF|SAHF]]
| [[#SAHF|MOV]]
|-
| [[#SAR|SAR]]
| [[#SAR|SHRA]]
|-
| [[#SBB|SBB]]
| [[#SBB|SUBC]]
|-
| [[#SCASB|SCASB]]
| [[#SCASB|CMPMB]]
|-
| [[#SCASW|SCASW]]
| [[#SCASW|CMPMW]]
|-
| [[#SHL|SHL]]
| [[#SHL|SHL]]
|-
| [[#SHR|SHR]]
| [[#SHR|SHR]]
|-
| [[#SS|SS]]
| [[#SS|SS]]
|-
| [[#STC|STC]]
| [[#STC|SET1 CY]]
|-
| [[#STD|STD]]
| [[#STD|SET1 DIR]]
|-
| [[#STI|STI]]
| [[#STI|EI]]
|-
| [[#STOSB|STOSB]]
| [[#STOSB|STMB]]
|-
| [[#STOSW|STOSW]]
| [[#STOSW|STMW]]
|-
| [[#SUB|SUB]]
| [[#SUB|SUB]]
|-
| [[#TEST|TEST]]
| [[#TEST|TEST]]
|-
| [[#XCHG|XCHG]]
| [[#XCHG|XCH]]
|-
| [[#XLAT|XLAT]]
| [[#XLAT|TRANS]]
|-
| [[#XOR|XOR]]
| [[#XOR|XOR]]
|}
== Official instructions by type ==
{| class="wikitable sortable" style="text-align: center"
!Type
!colspan=16 class="unsortable" | Instructions
|-
| style="text-align:left;" | Memory
| style="" | [[#MOV|MOV]]
| style="" | [[#XCHG|XCHG]]
| style="" | [[#XLAT|XLAT]]
| style="" | [[#LEA|LEA]]
| style="border-right:none;" | [[#LDS|LDS]]
| style="border-left:none;" | [[#LES|LES]]
| style="border-right:none;" | [[#IN|IN]]
| style="border-left:none;" | [[#OUT|OUT]]
| colspan="8" |
|-
| style="text-align:left;" | Ports
| style="border-right:none;" | [[#IN|IN]]
| style="border-left:none;" | [[#OUT|OUT]]
| style="border-right:none;" | [[#INSB|INSB]]
| style="border-left:none;" | [[#OUTSB|OUTSB]]
| style="border-right:none;" | [[#INSW|INSW]]
| style="border-left:none;" | [[#OUTSW|OUTSW]]
| colspan="10" |
|-
| style="text-align:left;" | Arithmetic
| style="border-right:none;" | [[#ADD|ADD]]
| style="border-left:none;" | [[#SUB|SUB]]
| style="border-right:none;" | [[#ADC|ADC]]
| style="border-left:none;" | [[#SBB|SBB]]
| style="border-right:none;" | [[#INC|INC]]
| style="border-left:none;" | [[#DEC|DEC]]
| style="border-right:none;" | [[#MUL|MUL]]
| style="border-left:none;" | [[#DIV|DIV]]
| style="border-right:none;" | [[#IMUL|IMUL]]
| style="border-left:none;" | [[#IDIV|IDIV]]
| style="" | [[#CMP|CMP]]
| style="" | [[#NEG|NEG]]
| colspan="4" |
|-
| style="text-align:left;" | Numeric
| style="" | [[#CBW|CBW]]
| style="" | [[#CWD|CWD]]
| style="" | [[#AAA|AAA]]
| style="" | [[#AAS|AAS]]
| style="" | [[#AAM|AAM]]
| style="" | [[#AAD|AAD]]
| style="" | [[#DAA|DAA]]
| style="" | [[#DAS|DAS]]
| colspan="8" |
|-
| style="text-align:left;" | Shift
| style="border-right:none;" | [[#ROL|ROL]]
| style="border-left:none;" | [[#ROR|ROR]]
| style="border-right:none;" | [[#RCL|RCL]]
| style="border-left:none;" | [[#RCR|RCR]]
| style="border-right:none;" | [[#SHL|SHL]]
| style="border-left:none;" | [[#SHR|SHR]]
| style="" | [[#SAR|SAR]]
| colspan="9" |
|-
| style="text-align:left;" | Bitwise
| style="" | [[#AND|AND]]
| style="" | [[#OR|OR]]
| style="" | [[#XOR|XOR]]
| style="" | [[#NOT|NOT]]
| style="" | [[#TEST|TEST]]
| colspan="11" |
|-
| style="text-align:left;" | Branch
| style="border-right:none;" | [[#JC|JC]]
| style="border-left:none;" | [[#JNC|JNC]]
| style="border-right:none;" | [[#JZ|JZ]]
| style="border-left:none;" | [[#JNZ|JNZ]]
| style="border-right:none;" | [[#JBE|JBE]]
| style="border-left:none;" | [[#JA|JA]]
| style="border-right:none;" | [[#JO|JO]]
| style="border-left:none;" | [[#JNO|JNO]]
| style="border-right:none;" | [[#JP|JP]]
| style="border-left:none;" | [[#JNP|JNP]]
| style="border-right:none;" | [[#JS|JS]]
| style="border-left:none;" | [[#JNS|JNS]]
| style="border-right:none;" | [[#JL|JL]]
| style="border-left:none;" | [[#JGE|JGE]]
| style="border-right:none;" | [[#JLE|JLE]]
| style="border-left:none;" | [[#JG|JG]]
|-
| style="text-align:left;" | Jump
| style="" | [[#JMP|JMP]]
| style="border-right:none;" | [[#CALL|CALL]]
| style="border-left:none;border-right:none;" | [[#RET|RET]]
| style="border-left:none;" | [[#RETF|RETF]]
| colspan="12" |
|-
| style="text-align:left;" | Loop
| style="" | [[#LOOP|LOOP]]
| style="" | [[#LOOPE|LOOPE]]
| style="" | [[#LOOPNE|LOOPNE]]
| colspan="13" |
|-
| style="text-align:left;" | Interrupt
| style="border-right:none;" | [[#INT|INT]]
| style="border-left:none;" | [[#IRET|IRET]]
| style="" | [[#INTO|INTO]]
| style="" | [[#HLT|HLT]]
| style="" | [[#BOUND|BOUND]]
| colspan="11" |
|-
| style="text-align:left;" | Stack
| style="border-right:none;" | [[#PUSH|PUSH]]
| style="border-left:none;" | [[#POP|POP]]
| style="border-right:none;" | [[#PUSHA|PUSHA]]
| style="border-left:none;" | [[#POPA|POPA]]
| style="border-right:none;" | [[#PUSHF|PUSHF]]
| style="border-left:none;" | [[#POPF|POPF]]
| colspan="10" |
|-
| style="text-align:left;" | Flags
| style="border-right:none;" | [[#CLC|CLC]]
| style="border-left:none;" | [[#STC|STC]]
| style="border-right:none;" | [[#CLD|CLD]]
| style="border-left:none;" | [[#STD|STD]]
| style="border-right:none;" | [[#CLI|CLI]]
| style="border-left:none;" | [[#STI|STI]]
| style="" | [[#CMC|CMC]]
| style="border-right:none;" | [[#LAHF|LAHF]]
| style="border-left:none;" | [[#SAHF|SAHF]]
| colspan="7" |
|-
| style="text-align:left;" | Prefix
| style="" | [[#CS|CS]]
| style="" | [[#DS|DS]]
| style="" | [[#ES|ES]]
| style="" | [[#SS|SS]]
| colspan="12" |
|-
| style="text-align:left;" | String
| style="border-right:none;" | [[#REP|REP]]
| style="border-left:none;border-right:none;" | [[#REP|REPE]]
| style="border-left:none;" | [[#REPNE|REPNE]]
| style="" | [[#MOVSB|MOVSB]]
| style="" | [[#MOVSW|MOVSW]]
| style="border-right:none;" | [[#LODSB|LODSB]]
| style="border-left:none;" | [[#STOSB|STOSB]]
| style="border-right:none;" | [[#LODSW|LODSW]]
| style="border-left:none;" | [[#STOSW|STOSW]]
| style="" | [[#CMPSB|CMPSB]]
| style="" | [[#SCASB|SCASB]]
| style="" | [[#CMPSW|CMPSW]]
| style="" | [[#SCASW|SCASW]]
| colspan="3" |
|-
| style="text-align:left;" | Other
| style="" | [[#NOP|NOP]]
| style="border-right:none;" | [[#ENTER|ENTER]]
| style="border-left:none;" | [[#LEAVE|LEAVE]]
| style="" | [[#LOCK|LOCK]]
| style="" | [[#POLL|POLL]]
| colspan="11" |
|}
== Instruction encoding ==
=== ModR/M byte ===
The ModR/M byte is used in most addressing modes which reference a memory location. This byte consists of three bitfield values:
* <tt>oo</tt> - M'''o'''de;
* <tt>rrr</tt> - Two possible functions:
** '''R'''egister (for addressing modes which require both a register and a register/memory operand),
** Opcode extension (for some opcodes' addressing modes which do not have such a requirement);
* <tt>mmm</tt> - Register/'''M'''emory.
The ''Mode'' and ''Register/Memory'' bitfields can refer to a memory location or to a register, as shown in the table below. In some addressing modes, the ''Register'' field also refers to a register; it is always interpreted as if ''Mode'' was equal to <tt>11</tt>.
{| class="wikitable" style="text-align: center"
! R/M \ Mode
! <tt>00</tt>
! <tt>01</tt>
! <tt>10</tt>
! <tt>11</tt> ''(byte)''
! <tt>11</tt> ''(word)''
|-
| <tt>000</tt>
| DS:[BX + SI]
| DS:[BX + SI + disp8]
| DS:[BX + SI + disp16]
| AL
| AX
|-
| <tt>001</tt>
| DS:[BX + DI]
| DS:[BX + DI + disp8]
| DS:[BX + DI + disp16]
| CL
| CX
|-
| <tt>010</tt>
| SS:[BP + SI]
| SS:[BP + SI + disp8]
| SS:[BP + SI + disp16]
| DL
| DX
|-
| <tt>011</tt>
| SS:[BP + DI]
| SS:[BP + DI + disp8]
| SS:[BP + DI + disp16]
| BL
| BX
|-
| <tt>100</tt>
| DS:[SI]
| DS:[SI + disp8]
| DS:[SI + disp16]
| AH
| SP
|-
| <tt>101</tt>
| DS:[DI]
| DS:[DI + disp8]
| DS:[DI + disp16]
| CH
| BP
|-
| <tt>110</tt>
| ''DS:[disp16]''
| SS:[BP + disp8]
| SS:[BP + disp16]
| DH
| SI
|-
| <tt>111</tt>
| DS:[BX]
| DS:[BX + disp8]
| DS:[BX + disp16]
| BH
| DI
|}
Displacements are either 8-bit (disp8) or 16-bit (disp16) signed values and they always immediately follow the ModR/M byte. Note that (<tt>oo</tt> = <tt>00</tt>, <tt>mmm</tt> = <tt>110</tt>) is a special case, in which the ''disp16'' value is used directly as a near pointer.
The instruction encoding lists below refer to this byte as <tt>oorrrmmm</tt> (binary), <tt>/r</tt> (hexadecimal) or <tt>/0</tt> (hexademical, <tt>rrr</tt> used as function <tt>0</tt>).
== Official instructions ==
{{Anchor|AAA}}
=== AAA ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| AAA || <tt>37</tt> || <tt>00110111</tt> || 1 || 9
|}
----
{{Anchor|AAD}}
=== AAD ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| AAD imm8 || <tt>B5 ii</tt> || <tt>11010100 iiiiiiii</tt> || 2 || 6
|}
----
{{Anchor|AAM}}
=== AAM ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| AAM imm8 || <tt>B4 ii</tt> || <tt>11010100 iiiiiiii</tt> || 2 || 17
|}
----
{{Anchor|AAS}}
=== AAS ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| AAS || <tt>3F</tt> || <tt>00111111</tt> || 1 || 9
|}
----
{{Anchor|ADC}}
=== ADC ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| ADC AL, imm || <tt>14 ii</tt> || <tt>00010100 iiiiiiii</tt> || 2 || 1
|-
| ADC AX, imm || <tt>15 ii ii</tt> || <tt>00010101 iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| ADC mem8, imm8 || <tt>80 /2 ii</tt> || <tt>10000000 oo010mmm iiiiiiii</tt> || 3+ || 3
|-
| ADC mem16, imm16 || <tt>81 /2 ii ii</tt> || <tt>10000001 oo010mmm iiiiiiii iiiiiiii</tt> || 4+ || 3
|-
| ADC mem16, simm8 || <tt>83 /2 ii ii</tt> || <tt>10000011 oo010mmm iiiiiiii iiiiiiii</tt> || 4+ || 3
|-
| ADC mem8, reg8 || <tt>10 /r</tt> || <tt>00010000 oorrrmmm</tt> || 2+ || 3
|-
| ADC mem16, reg16 || <tt>11 /r</tt> || <tt>00010001 oorrrmmm</tt> || 2+ || 3
|-
| ADC reg8, imm8 || <tt>80 /2 ii</tt> || <tt>10000000 11010mmm iiiiiiii</tt> || 3+ || 1
|-
| ADC reg16, imm16 || <tt>81 /2 ii ii</tt> || <tt>10000001 11010mmm iiiiiiii iiiiiiii</tt> || 4+ || 1
|-
| ADC reg16, simm8 || <tt>83 /2 ii ii</tt> || <tt>10000011 11010mmm iiiiiiii iiiiiiii</tt> || 4+ || 1
|-
| ADC reg8, mem8 || <tt>12 /r</tt> || <tt>00010010 oorrrmmm</tt> || 2+ || 2
|-
| ADC reg16, mem16 || <tt>13 /r</tt> || <tt>00010011 oorrrmmm</tt> || 2+ || 2
|-
| ADC reg8, reg8 || <tt>10 /r</tt> || <tt>000100.0 11rrrmmm</tt> || 2 || 1
|-
| ADC reg16, reg16 || <tt>11 /r</tt> || <tt>000100.1 11rrrmmm</tt> || 2 || 1
|}
----
{{Anchor|ADD}}
=== ADD ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| ADD AL, imm || <tt>04 ii</tt> || <tt>00000100 iiiiiiii</tt> || 2 || 1
|-
| ADD AX, imm || <tt>05 ii ii</tt> || <tt>00000101 iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| ADD mem8, imm8 || <tt>80 /0 ii</tt> || <tt>10000000 oo000mmm iiiiiiii</tt> || 3+ || 3
|-
| ADD mem16, imm16 || <tt>81 /0 ii ii</tt> || <tt>10000001 oo000mmm iiiiiiii iiiiiiii</tt> || 4+ || 3
|-
| ADD mem16, simm8 || <tt>83 /0 ii ii</tt> || <tt>10000011 oo000mmm iiiiiiii iiiiiiii</tt> || 4+ || 3
|-
| ADD mem8, reg8 || <tt>00 /r</tt> || <tt>00000000 oorrrmmm</tt> || 2+ || 3
|-
| ADD mem16, reg16 || <tt>01 /r</tt> || <tt>00000001 oorrrmmm</tt> || 2+ || 3
|-
| ADD reg8, imm8 || <tt>80 /0 ii</tt> || <tt>10000000 11000mmm iiiiiiii</tt> || 3+ || 1
|-
| ADD reg16, imm16 || <tt>81 /0 ii ii</tt> || <tt>10000001 11000mmm iiiiiiii iiiiiiii</tt> || 4+ || 1
|-
| ADD reg16, simm8 || <tt>83 /0 ii ii</tt> || <tt>10000011 11000mmm iiiiiiii iiiiiiii</tt> || 4+ || 1
|-
| ADD reg8, mem8 || <tt>02 /r</tt> || <tt>00000010 oorrrmmm</tt> || 2+ || 2
|-
| ADD reg16, mem16 || <tt>03 /r</tt> || <tt>00000011 oorrrmmm</tt> || 2+ || 2
|-
| ADD reg8, reg8 || <tt>00 /r</tt> || <tt>000000.0 11rrrmmm</tt> || 2 || 1
|-
| ADD reg16, reg16 || <tt>01 /r</tt> || <tt>000000.1 11rrrmmm</tt> || 2 || 1
|}
----
{{Anchor|AND}}
=== AND ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| AND AL, imm || <tt>24 ii</tt> || <tt>00100100 iiiiiiii</tt> || 2 || 1
|-
| AND AX, imm || <tt>25 ii ii</tt> || <tt>00100101 iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| AND mem8, imm8 || <tt>80 /4 ii</tt> || <tt>10000000 oo100mmm iiiiiiii</tt> || 3+ || 3
|-
| AND mem16, imm16 || <tt>81 /4 ii ii</tt> || <tt>10000001 oo100mmm iiiiiiii iiiiiiii</tt> || 4+ || 3
|-
| AND mem16, simm8 || <tt>83 /4 ii ii</tt> || <tt>10000011 oo100mmm iiiiiiii iiiiiiii</tt> || 4+ || 3
|-
| AND mem8, reg8 || <tt>20 /r</tt> || <tt>00100000 oorrrmmm</tt> || 2+ || 3
|-
| AND mem16, reg16 || <tt>21 /r</tt> || <tt>00100001 oorrrmmm</tt> || 2+ || 3
|-
| AND reg8, imm8 || <tt>80 /4 ii</tt> || <tt>10000000 11100mmm iiiiiiii</tt> || 3+ || 1
|-
| AND reg16, imm16 || <tt>81 /4 ii ii</tt> || <tt>10000001 11100mmm iiiiiiii iiiiiiii</tt> || 4+ || 1
|-
| AND reg16, simm8 || <tt>83 /4 ii ii</tt> || <tt>10000011 11100mmm iiiiiiii iiiiiiii</tt> || 4+ || 1
|-
| AND reg8, mem8 || <tt>22 /r</tt> || <tt>00100010 oorrrmmm</tt> || 2+ || 2
|-
| AND reg16, mem16 || <tt>23 /r</tt> || <tt>00100011 oorrrmmm</tt> || 2+ || 2
|-
| AND reg8, reg8 || <tt>20 /r</tt> || <tt>001000.0 11rrrmmm</tt> || 2 || 1
|-
| AND reg16, reg16 || <tt>21 /r</tt> || <tt>001000.1 11rrrmmm</tt> || 2 || 1
|}
----
{{Anchor|BOUND}}
=== BOUND ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| BOUND reg16, mem16:16 || <tt>62 /r</tt> || <tt>01100010 oorrrmmm</tt> || 2+ || 13 (20 if condition met)
|}
----
{{Anchor|CALL}}
=== CALL ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| CALL ptr16:16 || <tt>CA oo oo ss ss</tt> || <tt>10011010 oooooooo oooooooo ssssssss ssssssss</tt> || 5 || 10
|-
| CALL mem16 || <tt>FF /2</tt> || <tt>11111111 oo010mmm</tt> || 2+ || 6
|-
| CALL mem16:16 || <tt>FF /3</tt> || <tt>11111111 oo011mmm</tt> || 2+ || 12
|-
| CALL reg16 || <tt>FF /2</tt> || <tt>11111111 11010mmm</tt> || 2 || 5
|-
| CALL rel16 || <tt>E8 ii ii</tt> || <tt>11101000 iiiiiiii iiiiiiii</tt> || 3 || 5
|}
----
{{Anchor|CBW}}
=== CBW ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| CBW || <tt>98</tt> || <tt>10011000</tt> || 1 || 1
|}
----
{{Anchor|CLC}}
=== CLC ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| CLC || <tt>F8</tt> || <tt>11111000</tt> || 1 || 4
|}
----
{{Anchor|CLD}}
=== CLD ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| CLD || <tt>FC</tt> || <tt>11111100</tt> || 1 || 4
|}
----
{{Anchor|CLI}}
=== CLI ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| CLI || <tt>FA</tt> || <tt>11111010</tt> || 1 || 4
|}
----
{{Anchor|CMC}}
=== CMC ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| CMC || <tt>F5</tt> || <tt>11110101</tt> || 1 || 4
|}
----
{{Anchor|CMP}}
=== CMP ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| CMP AL, imm || <tt>3C ii</tt> || <tt>00111100 iiiiiiii</tt> || 2 || 1
|-
| CMP AX, imm || <tt>3D ii ii</tt> || <tt>00111101 iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| CMP mem8, imm8 || <tt>80 /7 ii</tt> || <tt>10000000 oo111mmm iiiiiiii</tt> || 3+ || 2
|-
| CMP mem16, imm16 || <tt>81 /7 ii ii</tt> || <tt>10000001 oo111mmm iiiiiiii iiiiiiii</tt> || 4+ || 2
|-
| CMP mem16, simm8 || <tt>83 /7 ii ii</tt> || <tt>10000011 oo111mmm iiiiiiii iiiiiiii</tt> || 4+ || 2
|-
| CMP mem8, reg8 || <tt>38 /r</tt> || <tt>00111000 oorrrmmm</tt> || 2+ || 2
|-
| CMP mem16, reg16 || <tt>39 /r</tt> || <tt>00111001 oorrrmmm</tt> || 2+ || 2
|-
| CMP reg8, imm8 || <tt>80 /7 ii</tt> || <tt>10000000 11111mmm iiiiiiii</tt> || 3+ || 1
|-
| CMP reg16, imm16 || <tt>81 /7 ii ii</tt> || <tt>10000001 11111mmm iiiiiiii iiiiiiii</tt> || 4+ || 1
|-
| CMP reg16, simm8 || <tt>83 /7 ii ii</tt> || <tt>10000011 11111mmm iiiiiiii iiiiiiii</tt> || 4+ || 1
|-
| CMP reg8, mem8 || <tt>3A /r</tt> || <tt>00111010 oorrrmmm</tt> || 2+ || 2
|-
| CMP reg16, mem16 || <tt>3B /r</tt> || <tt>00111011 oorrrmmm</tt> || 2+ || 2
|-
| CMP reg8, reg8 || <tt>38 /r</tt> || <tt>001110.0 11rrrmmm</tt> || 2 || 1
|-
| CMP reg16, reg16 || <tt>39 /r</tt> || <tt>001110.1 11rrrmmm</tt> || 2 || 1
|}
----
{{Anchor|CMPSB}}
=== CMPSB ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| CMPSB || <tt>A6</tt> || <tt>10100110</tt> || 1 || 6
|}
----
{{Anchor|CMPSW}}
=== CMPSW ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| CMPSW || <tt>A7</tt> || <tt>10100111</tt> || 1 || 6
|}
----
{{Anchor|CS}}
=== CS ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| CS || <tt>2E</tt> || <tt>00101110</tt> || 1 || 1
|}
----
{{Anchor|CWD}}
=== CWD ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| CWD || <tt>99</tt> || <tt>10011001</tt> || 1 || 1
|}
----
{{Anchor|DAA}}
=== DAA ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| DAA || <tt>27</tt> || <tt>00100111</tt> || 1 || 10
|}
----
{{Anchor|DAS}}
=== DAS ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| DAS || <tt>2F</tt> || <tt>00101111</tt> || 1 || 10
|}
----
{{Anchor|DEC}}
=== DEC ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| DEC mem8 || <tt>FE /1</tt> || <tt>11111110 oo001mmm</tt> || 2+ || 3
|-
| DEC mem16 || <tt>FF /1</tt> || <tt>11111111 oo001mmm</tt> || 2+ || 3
|-
| DEC reg8 || <tt>FE /1</tt> || <tt>11111110 11001mmm</tt> || 2+ || 1
|-
| DEC reg16 || <tt>4x</tt> || <tt>01001rrr</tt> || 1 || 1
|}
----
{{Anchor|DIV}}
=== DIV ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| DIV mem8 || <tt>F6 /6</tt> || <tt>11110110 oo110mmm</tt> || 2+ || 16
|-
| DIV mem16 || <tt>F7 /6</tt> || <tt>11111111 oo110mmm</tt> || 2+ || 24
|-
| DIV reg8 || <tt>F6 /6</tt> || <tt>11111110 11110mmm</tt> || 2+ || 15
|-
| DIV reg16 || <tt>F7 /6</tt> || <tt>11111111 11110mmm</tt> || 2+ || 23
|}
----
{{Anchor|DS}}
=== DS ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| DS || <tt>3E</tt> || <tt>00111110</tt> || 1 || 1
|}
----
{{Anchor|ENTER}}
=== ENTER ===
----
{{Anchor|ES}}
=== ES ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| ES || <tt>26</tt> || <tt>00100110</tt> || 1 || 1
|}
----
{{Anchor|HLT}}
=== HLT ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| HLT || <tt>F4</tt> || <tt>11110100</tt> || 1 || 9
|}
----
{{Anchor|IDIV}}
=== IDIV ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| IDIV mem8 || <tt>F6 /7</tt> || <tt>11110110 oo111mmm</tt> || 2+ || 18
|-
| IDIV mem16 || <tt>F7 /7</tt> || <tt>11111111 oo111mmm</tt> || 2+ || 25
|-
| IDIV reg8 || <tt>F6 /7</tt> || <tt>11111110 11111mmm</tt> || 2+ || 17
|-
| IDIV reg16 || <tt>F7 /7</tt> || <tt>11111111 11111mmm</tt> || 2+ || 24
|}
----
{{Anchor|IMUL}}
=== IMUL ===
----
{{Anchor|IN}}
=== IN ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| IN AL, DX || <tt>EC</tt> || <tt>11101100</tt> || 1 || 6
|-
| IN AX, DX || <tt>ED</tt> || <tt>11101101</tt> || 1 || 6
|-
| IN AL, imm8 || <tt>E4 ii</tt> || <tt>11100100 iiiiiiii</tt> || 2 || 6
|-
| IN AX, imm8 || <tt>E5 ii</tt> || <tt>11100101 iiiiiiii</tt> || 2 || 6
|}
----
{{Anchor|INC}}
=== INC ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| INC mem8 || <tt>FE /0</tt> || <tt>11111110 oo000mmm</tt> || 2+ || 3
|-
| INC mem16 || <tt>FF /0</tt> || <tt>11111111 oo000mmm</tt> || 2+ || 3
|-
| INC reg8 || <tt>FE /0</tt> || <tt>11111110 11000mmm</tt> || 2+ || 1
|-
| INC reg16 || <tt>4x</tt> || <tt>01000rrr</tt> || 1 || 1
|}
----
{{Anchor|INSB}}
{{Anchor|INSW}}
=== INSB/INSW ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| INSB || <tt>6C</tt> || <tt>01101100</tt> || 1 || 6
|-
| INSW || <tt>6D</tt> || <tt>01101101</tt> || 1 || 6
|}
----
{{Anchor|INT}}
=== INT ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| INT 3 || <tt>CC</tt> || <tt>11001100</tt> || 1 || 9
|-
| INT imm8 || <tt>CD ii</tt> || <tt>11001101 iiiiiiii</tt> || 2 || 10
|}
----
{{Anchor|INTO}}
=== INTO ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| INTO || <tt>CE</tt> || <tt>11001110</tt> || 1 || 6 (13 if OF = 1)
|}
----
{{Anchor|IRET}}
=== IRET ===
----
{{Anchor|JA}}
=== JA ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JA rel8 || <tt>77 ii</tt> || <tt>01110111 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JBE}}
=== JBE ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JA rel8 || <tt>76 ii</tt> || <tt>01110110 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JC}}
=== JC/JB ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JC rel8 || <tt>72 ii</tt> || <tt>01110010 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JCXZ}}
=== JCXZ ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JCXZ rel8 || <tt>E3 ii</tt> || <tt>11100011 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JG}}
=== JG ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JG rel8 || <tt>7F ii</tt> || <tt>01111111 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JGE}}
=== JGE ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JGE rel8 || <tt>7D ii</tt> || <tt>01111101 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JL}}
=== JL ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JL rel8 || <tt>7C ii</tt> || <tt>01111100 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JLE}}
=== JLE ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JLE rel8 || <tt>7E ii</tt> || <tt>01111110 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JMP}}
=== JMP ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JMP ptr16:16 || <tt>EA oo oo ss ss</tt> || <tt>11101010 oooooooo oooooooo ssssssss ssssssss</tt> || 5 || 7
|-
| JMP mem16 || <tt>FF /4</tt> || <tt>11111111 oo100mmm</tt> || 2+ || 5
|-
| JMP mem16:16 || <tt>FF /5</tt> || <tt>11111111 oo101mmm</tt> || 2+ || 10
|-
| JMP reg16 || <tt>FF /4</tt> || <tt>11111111 11100mmm</tt> || 2 || 4
|-
| JMP rel8 || <tt>EB ii</tt> || <tt>11101011 iiiiiiii</tt> || 2 || 4
|-
| JMP rel16 || <tt>E9 ii ii</tt> || <tt>11101001 iiiiiiii iiiiiiii</tt> || 3 || 4
|}
----
{{Anchor|JNC}}
=== JNC/JAE ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JNC rel8 || <tt>73 ii</tt> || <tt>01110011 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JNO}}
=== JNO ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JNO rel8 || <tt>71 ii</tt> || <tt>01110001 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JNP}}
=== JNP ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JNP rel8 || <tt>7B ii</tt> || <tt>01111011 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JNS}}
=== JNS ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JNS rel8 || <tt>79 ii</tt> || <tt>01111001 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JNZ}}
=== JNZ/JNE ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JNZ rel8 || <tt>75 ii</tt> || <tt>01110101 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JO}}
=== JO ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JO rel8 || <tt>70 ii</tt> || <tt>01110000 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JP}}
=== JP ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JP rel8 || <tt>7A ii</tt> || <tt>01111010 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JS}}
=== JS ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JS rel8 || <tt>78 ii</tt> || <tt>01111000 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JZ}}
=== JZ/JE ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JZ rel8 || <tt>74 ii</tt> || <tt>01110100 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|LAHF}}
=== LAHF ===
----
{{Anchor|LDS}}
=== LDS ===
----
{{Anchor|LEA}}
=== LEA ===
----
{{Anchor|LEAVE}}
=== LEAVE ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| LEAVE || <tt>C9</tt> || <tt>11001001</tt> || 1 || 2
|}
----
{{Anchor|LES}}
=== LES ===
----
{{Anchor|LOCK}}
=== LOCK ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| LOCK || <tt>F0</tt> || <tt>11110000</tt> || 1 || 1
|}
----
{{Anchor|LODSB}}
=== LODSB ===
----
{{Anchor|LODSW}}
=== LODSW ===
----
{{Anchor|LOOP}}
=== LOOP ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| LOOP rel8 || <tt>E2 ii</tt> || <tt>11100010 iiiiiiii</tt> || 2 || 2 (5 if branch taken)
|}
----
{{Anchor|LOOPE}}
=== LOOPE ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| LOOPE rel8 || <tt>E1 ii</tt> || <tt>11100001 iiiiiiii</tt> || 2 || 3 (6 if branch taken)
|}
----
{{Anchor|LOOPNE}}
=== LOOPNE ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| LOOPNE rel8 || <tt>E0 ii</tt> || <tt>11100000 iiiiiiii</tt> || 2 || 3 (6 if branch taken)
|}
----
{{Anchor|MOV}}
=== MOV ===
----
{{Anchor|MOVSB}}
=== MOVSB ===
----
{{Anchor|MOVSW}}
=== MOVSW ===
----
{{Anchor|MUL}}
=== MUL ===
----
{{Anchor|NEG}}
=== NEG ===
----
{{Anchor|NOP}}
=== NOP ===
----
{{Anchor|NOT}}
=== NOT ===
----
{{Anchor|OR}}
=== OR ===
----
{{Anchor|OUT}}
=== OUT ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| OUT AL, DX || <tt>EE</tt> || <tt>11101110</tt> || 1 || 6
|-
| OUT AX, DX || <tt>EF</tt> || <tt>11101111</tt> || 1 || 6
|-
| OUT AL, imm8 || <tt>E6 ii</tt> || <tt>11100110 iiiiiiii</tt> || 2 || 6
|-
| OUT AX, imm8 || <tt>E7 ii</tt> || <tt>11100111 iiiiiiii</tt> || 2 || 6
|}
----
{{Anchor|OUTSB}}
{{Anchor|OUTSW}}
=== OUTSB/OUTSW ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| OUTSB || <tt>6E</tt> || <tt>01101110</tt> || 1 || 6
|-
| OUTSW || <tt>6F</tt> || <tt>01101111</tt> || 1 || 6
|}
----
{{Anchor|POLL}}
=== POLL ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| POLL || <tt>6E</tt> || <tt>01101110</tt> || 1 || 9<ref>On the WonderSwan implementation, POLLB is always held low; on other implementations, POLL will wait for POLLB to be held low in 9-cycle intervals.</ref>
|}
----
{{Anchor|POP}}
=== POP ===
----
{{Anchor|POPA}}
=== POPA ===
----
{{Anchor|POPF}}
=== POPF ===
----
{{Anchor|PUSH}}
=== PUSH ===
----
{{Anchor|PUSHA}}
=== PUSHA ===
----
{{Anchor|PUSHF}}
=== PUSHF ===
----
{{Anchor|RCL}}
=== RCL ===
----
{{Anchor|RCR}}
=== RCR ===
----
{{Anchor|REP}}
=== REP/REPE/REPZ ===
----
{{Anchor|REPNE}}
=== REPNE/REPNZ ===
----
{{Anchor|RET}}
=== RET ===
----
{{Anchor|RETF}}
=== RETF ===
----
{{Anchor|ROL}}
=== ROL ===
----
{{Anchor|ROR}}
=== ROR ===
----
{{Anchor|SAHF}}
=== SAHF ===
----
{{Anchor|SAR}}
=== SAR ===
----
{{Anchor|SBB}}
=== SBB ===
----
{{Anchor|SCASB}}
=== SCASB ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| SCASB || <tt>AE</tt> || <tt>10101110</tt> || 1 || 4
|}
----
{{Anchor|SCASW}}
=== SCASW ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| SCASW || <tt>AF</tt> || <tt>10101111</tt> || 1 || 4
|}
----
{{Anchor|SHL}}
=== SHL ===
----
{{Anchor|SHR}}
=== SHR ===
----
{{Anchor|SS}}
=== SS ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| SS || <tt>36</tt> || <tt>00110110</tt> || 1 || 1
|}
----
{{Anchor|STC}}
=== STC ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| STC || <tt>F9</tt> || <tt>11111001</tt> || 1 || 4
|}
----
{{Anchor|STD}}
=== STD ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| STD || <tt>FD</tt> || <tt>11111101</tt> || 1 || 4
|}
----
{{Anchor|STI}}
=== STI ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| STI || <tt>FB</tt> || <tt>11111011</tt> || 1 || 4
|}
----
{{Anchor|STOSB}}
=== STOSB ===
----
{{Anchor|STOSW}}
=== STOSW ===
----
{{Anchor|SUB}}
=== SUB ===
----
{{Anchor|TEST}}
=== TEST ===
----
{{Anchor|XCHG}}
=== XCHG ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| XCHG AX, reg16<br/>XCHG reg16, AX || <tt>9x</tt> || <tt>10010rrr</tt> || 1 || 3
|-
| XCHG mem8, reg8<br/>XCHG reg8, mem8 || <tt>86 /r</tt> || <tt>10000110 oorrrmmm</tt> || 2+ || 5
|-
| XCHG mem16, reg16<br/>XCHG reg16, mem16 || <tt>87 /r</tt> || <tt>10000111 oorrrmmm</tt> || 2+ || 5
|-
| XCHG reg8, reg8 || <tt>86 /r</tt> || <tt>10000110 11rrrmmm</tt> || 2+ || 3
|-
| XCHG reg16, reg16 || <tt>87 /r</tt> || <tt>10000111 11rrrmmm</tt> || 2+ || 3
|}
----
{{Anchor|XLAT}}
=== XLAT ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| XLAT || <tt>D7</tt> || <tt>11010111</tt> || 1 || 5
|}
----
{{Anchor|XOR}}
=== XOR ===
----
== Notes ==
<references />
d237c1644321c82f0a1c37bdf9c9f961d4087d34
456
455
2024-12-27T21:53:37Z
Asie
351
wikitext
text/x-wiki
__NOTOC__
Note that this page is a work in progress.
{| class="wikitable" style="text-align: center"
|+ Official V30MZ (80186) Instructions
|-
| [[#AAA|AAA]] || [[#AAD|AAD]] || [[#AAM|AAM]] || [[#AAS|AAS]] || [[#ADC|ADC]] || [[#ADD|ADD]] || [[#AND|AND]] || [[#BOUND|BOUND]] || [[#CALL|CALL]] || [[#CBW|CBW]] || [[#CLC|CLC]]
|-
| [[#CLD|CLD]] || [[#CLI|CLI]] || [[#CMC|CMC]] || [[#CMP|CMP]] || [[#CMPSB|CMPSB]] || [[#CMPSW|CMPSW]] || [[#CS|CS]] || [[#CWD|CWD]] || [[#DAA|DAA]] || [[#DAS|DAS]] || [[#DEC|DEC]]
|-
| [[#DIV|DIV]] || [[#DS|DS]] || [[#ENTER|ENTER]] || [[#ES|ES]] || [[#HLT|HLT]] || [[#IDIV|IDIV]] || [[#IMUL|IMUL]] || [[#IN|IN]] || [[#INC|INC]] || [[#INSB|INSB]] || [[#INSW|INSW]]
|-
| [[#INT|INT]] || [[#INTO|INTO]] || [[#IRET|IRET]] || [[#JA|JA]] || [[#JBE|JBE]] || [[#JC|JC]] || [[#JCXZ|JCXZ]] || [[#JG|JG]] || [[#JGE|JGE]] || [[#JL|JL]] || [[#JLE|JLE]]
|-
| [[#JMP|JMP]] || [[#JNC|JNC]] || [[#JNO|JNO]] || [[#JNP|JNP]] || [[#JNS|JNS]] || [[#JNZ|JNZ]] || [[#JO|JO]] || [[#JP|JP]] || [[#JS|JS]] || [[#JZ|JZ]] || [[#LAHF|LAHF]]
|-
| [[#LDS|LDS]] || [[#LEA|LEA]] || [[#LEAVE|LEAVE]] || [[#LES|LES]] || [[#LOCK|LOCK]] || [[#LODSB|LODSB]] || [[#LODSW|LODSW]] || [[#LOOP|LOOP]] || [[#LOOPE|LOOPE]] || [[#LOOPNE|LOOPNE]] || [[#MOV|MOV]]
|-
| [[#MOVSB|MOVSB]] || [[#MOVSW|MOVSW]] || [[#MUL|MUL]] || [[#NEG|NEG]] || [[#NOP|NOP]] || [[#NOT|NOT]] || [[#OR|OR]] || [[#OUT|OUT]] || [[#OUTSB|OUTSB]] || [[#OUTSW|OUTSW]] || [[#POLL|POLL]]
|-
| [[#POP|POP]] || [[#POPA|POPA]] || [[#POPF|POPF]] || [[#PUSH|PUSH]] || [[#PUSHA|PUSHA]] || [[#PUSHF|PUSHF]] || [[#RCL|RCL]] || [[#RCR|RCR]] || [[#REP|REP]] || [[#REPNE|REPNE]] || [[#RET|RET]]
|-
| [[#RETF|RETF]] || [[#ROL|ROL]] || [[#ROR|ROR]] || [[#SAHF|SAHF]] || [[#SAR|SAR]] || [[#SBB|SBB]] || [[#SCASB|SCASB]] || [[#SCASW|SCASW]] || [[#SHL|SHL]] || [[#SHR|SHR]] || [[#SS|SS]]
|-
| [[#STC|STC]] || [[#STD|STD]] || [[#STI|STI]] || [[#STOSB|STOSB]] || [[#STOSW|STOSW]] || [[#SUB|SUB]] || [[#TEST|TEST]] || [[#XCHG|XCHG]] || [[#XLAT|XLAT]] || [[#XOR|XOR]]
|}
{| class="mw-collapsible mw-collapsed wikitable sortable" style="width: 340px;"
|+ style="white-space:nowrap; border:1px solid; padding:3px; border-color:rgb(162, 169, 177); background-color:rgb(234, 236, 240);" | Intel <-> NEC mnemonic translation table
!Intel
!NEC
|-
| [[#AAA|AAA]]
| [[#AAA|ADJBA]]
|-
| [[#AAD|AAD]]
| [[#AAD|CVTDB]]
|-
| [[#AAM|AAM]]
| [[#AAM|CVTBD]]
|-
| [[#AAS|AAS]]
| [[#AAS|ADJBS]]
|-
| [[#ADC|ADC]]
| [[#ADC|ADDC]]
|-
| [[#ADD|ADD]]
| [[#ADD|ADD]]
|-
| [[#AND|AND]]
| [[#AND|AND]]
|-
| [[#BOUND|BOUND]]
| [[#BOUND|CHKIND]]
|-
| [[#CALL|CALL]]
| [[#CALL|CALL]]
|-
| [[#CBW|CBW]]
| [[#CBW|CVTBW]]
|-
| [[#CLC|CLC]]
| [[#CLC|CLR1 CY]]
|-
| [[#CLD|CLD]]
| [[#CLD|CLR1 DIR]]
|-
| [[#CLI|CLI]]
| [[#CLI|DI]]
|-
| [[#CMC|CMC]]
| [[#CMC|NOT1 CY]]
|-
| [[#CMP|CMP]]
| [[#CMP|CMP]]
|-
| [[#CMPSB|CMPSB]]
| [[#CMPSB|CMPBKB]]
|-
| [[#CMPSW|CMPSW]]
| [[#CMPSW|CMPBKW]]
|-
| [[#CS|CS]]
| [[#CS|PS]]
|-
| [[#CWD|CWD]]
| [[#CWD|CVTWL]]
|-
| [[#DAA|DAA]]
| [[#DAA|ADJ4A]]
|-
| [[#DAS|DAS]]
| [[#DAS|ADJ4S]]
|-
| [[#DEC|DEC]]
| [[#DEC|DEC]]
|-
| [[#DIV|DIV]]
| [[#DIV|DIVU]]
|-
| [[#DS|DS]]
| [[#DS|DS0]]
|-
| [[#ENTER|ENTER]]
| [[#ENTER|PREPARE]]
|-
| [[#ES|ES]]
| [[#ES|DS1]]
|-
| [[#HLT|HLT]]
| [[#HLT|HALT]]
|-
| [[#IDIV|IDIV]]
| [[#IDIV|DIV]]
|-
| [[#IMUL|IMUL]]
| [[#IMUL|MUL]]
|-
| [[#IN|IN]]
| [[#IN|IN]]
|-
| [[#INC|INC]]
| [[#INC|INC]]
|-
| [[#INSB|INSB]]
| [[#INSB|INMB]]
|-
| [[#INSW|INSW]]
| [[#INSW|INMW]]
|-
| [[#INT|INT]]
| [[#INT|BRK]]
|-
| [[#INTO|INTO]]
| [[#INTO|BRKV]]
|-
| [[#IRET|IRET]]
| [[#IRET|RETI]]
|-
| [[#JA|JA]]
| [[#JA|BH]]
|-
| [[#JBE|JBE]]
| [[#JBE|BNH]]
|-
| [[#JC|JC/JB]]
| [[#JC|BC/BL]]
|-
| [[#JCXZ|JCXZ]]
| [[#JCXZ|BCWZ]]
|-
| [[#JG|JG]]
| [[#JG|BGT]]
|-
| [[#JGE|JGE]]
| [[#JGE|BGE]]
|-
| [[#JL|JL]]
| [[#JL|BLT]]
|-
| [[#JLE|JLE]]
| [[#JLE|BLE]]
|-
| [[#JMP|JMP]]
| [[#JMP|BR]]
|-
| [[#JNC|JNC/JAE]]
| [[#JNC|BNC/BNL]]
|-
| [[#JNO|JNO]]
| [[#JNO|BNV]]
|-
| [[#JNP|JNP]]
| [[#JNP|BPO]]
|-
| [[#JNS|JNS]]
| [[#JNS|BP]]
|-
| [[#JNZ|JNZ/JNE]]
| [[#JNZ|BNZ/BNE]]
|-
| [[#JO|JO]]
| [[#JO|BV]]
|-
| [[#JP|JP]]
| [[#JP|BPE]]
|-
| [[#JS|JS]]
| [[#JS|BN]]
|-
| [[#JZ|JZ/JE]]
| [[#JZ|BZ/BE]]
|-
| [[#LAHF|LAHF]]
| [[#LAHF|MOV]]
|-
| [[#LDS|LDS]]
| [[#LDS|MOV]]
|-
| [[#LEA|LEA]]
| [[#LEA|LDEA]]
|-
| [[#LEAVE|LEAVE]]
| [[#LEAVE|DISPOSE]]
|-
| [[#LES|LES]]
| [[#LES|MOV]]
|-
| [[#LOCK|LOCK]]
| [[#LOCK|BUSLOCK]]
|-
| [[#LODSB|LODSB]]
| [[#LODSB|LDMB]]
|-
| [[#LODSW|LODSW]]
| [[#LODSW|LDMW]]
|-
| [[#LOOP|LOOP]]
| [[#LOOP|DBNZ]]
|-
| [[#LOOPE|LOOPE]]
| [[#LOOPE|DBNZE]]
|-
| [[#LOOPNE|LOOPNE]]
| [[#LOOPNE|DBNZNE]]
|-
| [[#MOV|MOV]]
| [[#MOV|MOV]]
|-
| [[#MOVSB|MOVSB]]
| [[#MOVSB|MOVBKB]]
|-
| [[#MOVSW|MOVSW]]
| [[#MOVSW|MOVBKW]]
|-
| [[#MUL|MUL]]
| [[#MUL|MULU]]
|-
| [[#NEG|NEG]]
| [[#NEG|NEG]]
|-
| [[#NOP|NOP]]
| [[#NOP|NOP]]
|-
| [[#NOT|NOT]]
| [[#NOT|NOT]]
|-
| [[#OR|OR]]
| [[#OR|OR]]
|-
| [[#OUT|OUT]]
| [[#OUT|OUT]]
|-
| [[#OUTSB|OUTSB]]
| [[#OUTSB|OUTM]]
|-
| [[#OUTSW|OUTSW]]
| [[#OUTSW|OUTM]]
|-
| [[#POLL|POLL]]
| [[#POLL|POLL]]
|-
| [[#POP|POP]]
| [[#POP|POP]]
|-
| [[#POPA|POPA]]
| [[#POPA|POP]]
|-
| [[#POPF|POPF]]
| [[#POPF|POP]]
|-
| [[#PUSH|PUSH]]
| [[#PUSH|PUSH]]
|-
| [[#PUSHA|PUSHA]]
| [[#PUSHA|PUSH]]
|-
| [[#PUSHF|PUSHF]]
| [[#PUSHF|PUSH]]
|-
| [[#RCL|RCL]]
| [[#RCL|ROLC]]
|-
| [[#RCR|RCR]]
| [[#RCR|RORC]]
|-
| [[#REP|REP/REPE/REPZ]]
| [[#REP|REP/REPE/REPZ]]
|-
| [[#REPNE|REPNE/REPNZ]]
| [[#REPNE|REPNE/REPNZ]]
|-
| [[#RET|RET]]
| [[#RET|RET]]
|-
| [[#RETF|RETF]]
| [[#RETF|RET]]
|-
| [[#ROL|ROL]]
| [[#ROL|ROL]]
|-
| [[#ROR|ROR]]
| [[#ROR|ROR]]
|-
| [[#SAHF|SAHF]]
| [[#SAHF|MOV]]
|-
| [[#SAR|SAR]]
| [[#SAR|SHRA]]
|-
| [[#SBB|SBB]]
| [[#SBB|SUBC]]
|-
| [[#SCASB|SCASB]]
| [[#SCASB|CMPMB]]
|-
| [[#SCASW|SCASW]]
| [[#SCASW|CMPMW]]
|-
| [[#SHL|SHL]]
| [[#SHL|SHL]]
|-
| [[#SHR|SHR]]
| [[#SHR|SHR]]
|-
| [[#SS|SS]]
| [[#SS|SS]]
|-
| [[#STC|STC]]
| [[#STC|SET1 CY]]
|-
| [[#STD|STD]]
| [[#STD|SET1 DIR]]
|-
| [[#STI|STI]]
| [[#STI|EI]]
|-
| [[#STOSB|STOSB]]
| [[#STOSB|STMB]]
|-
| [[#STOSW|STOSW]]
| [[#STOSW|STMW]]
|-
| [[#SUB|SUB]]
| [[#SUB|SUB]]
|-
| [[#TEST|TEST]]
| [[#TEST|TEST]]
|-
| [[#XCHG|XCHG]]
| [[#XCHG|XCH]]
|-
| [[#XLAT|XLAT]]
| [[#XLAT|TRANS]]
|-
| [[#XOR|XOR]]
| [[#XOR|XOR]]
|}
== Official instructions by type ==
{| class="wikitable sortable" style="text-align: center"
!Type
!colspan=16 class="unsortable" | Instructions
|-
| style="text-align:left;" | Memory
| style="" | [[#MOV|MOV]]
| style="" | [[#XCHG|XCHG]]
| style="" | [[#XLAT|XLAT]]
| style="" | [[#LEA|LEA]]
| style="border-right:none;" | [[#LDS|LDS]]
| style="border-left:none;" | [[#LES|LES]]
| style="border-right:none;" | [[#IN|IN]]
| style="border-left:none;" | [[#OUT|OUT]]
| colspan="8" |
|-
| style="text-align:left;" | Ports
| style="border-right:none;" | [[#IN|IN]]
| style="border-left:none;" | [[#OUT|OUT]]
| style="border-right:none;" | [[#INSB|INSB]]
| style="border-left:none;" | [[#OUTSB|OUTSB]]
| style="border-right:none;" | [[#INSW|INSW]]
| style="border-left:none;" | [[#OUTSW|OUTSW]]
| colspan="10" |
|-
| style="text-align:left;" | Arithmetic
| style="border-right:none;" | [[#ADD|ADD]]
| style="border-left:none;" | [[#SUB|SUB]]
| style="border-right:none;" | [[#ADC|ADC]]
| style="border-left:none;" | [[#SBB|SBB]]
| style="border-right:none;" | [[#INC|INC]]
| style="border-left:none;" | [[#DEC|DEC]]
| style="border-right:none;" | [[#MUL|MUL]]
| style="border-left:none;" | [[#DIV|DIV]]
| style="border-right:none;" | [[#IMUL|IMUL]]
| style="border-left:none;" | [[#IDIV|IDIV]]
| style="" | [[#CMP|CMP]]
| style="" | [[#NEG|NEG]]
| colspan="4" |
|-
| style="text-align:left;" | Numeric
| style="" | [[#CBW|CBW]]
| style="" | [[#CWD|CWD]]
| style="" | [[#AAA|AAA]]
| style="" | [[#AAS|AAS]]
| style="" | [[#AAM|AAM]]
| style="" | [[#AAD|AAD]]
| style="" | [[#DAA|DAA]]
| style="" | [[#DAS|DAS]]
| colspan="8" |
|-
| style="text-align:left;" | Shift
| style="border-right:none;" | [[#ROL|ROL]]
| style="border-left:none;" | [[#ROR|ROR]]
| style="border-right:none;" | [[#RCL|RCL]]
| style="border-left:none;" | [[#RCR|RCR]]
| style="border-right:none;" | [[#SHL|SHL]]
| style="border-left:none;" | [[#SHR|SHR]]
| style="" | [[#SAR|SAR]]
| colspan="9" |
|-
| style="text-align:left;" | Bitwise
| style="" | [[#AND|AND]]
| style="" | [[#OR|OR]]
| style="" | [[#XOR|XOR]]
| style="" | [[#NOT|NOT]]
| style="" | [[#TEST|TEST]]
| colspan="11" |
|-
| style="text-align:left;" | Branch
| style="border-right:none;" | [[#JC|JC]]
| style="border-left:none;" | [[#JNC|JNC]]
| style="border-right:none;" | [[#JZ|JZ]]
| style="border-left:none;" | [[#JNZ|JNZ]]
| style="border-right:none;" | [[#JBE|JBE]]
| style="border-left:none;" | [[#JA|JA]]
| style="border-right:none;" | [[#JO|JO]]
| style="border-left:none;" | [[#JNO|JNO]]
| style="border-right:none;" | [[#JP|JP]]
| style="border-left:none;" | [[#JNP|JNP]]
| style="border-right:none;" | [[#JS|JS]]
| style="border-left:none;" | [[#JNS|JNS]]
| style="border-right:none;" | [[#JL|JL]]
| style="border-left:none;" | [[#JGE|JGE]]
| style="border-right:none;" | [[#JLE|JLE]]
| style="border-left:none;" | [[#JG|JG]]
|-
| style="text-align:left;" | Jump
| style="" | [[#JMP|JMP]]
| style="border-right:none;" | [[#CALL|CALL]]
| style="border-left:none;border-right:none;" | [[#RET|RET]]
| style="border-left:none;" | [[#RETF|RETF]]
| colspan="12" |
|-
| style="text-align:left;" | Loop
| style="" | [[#LOOP|LOOP]]
| style="" | [[#LOOPE|LOOPE]]
| style="" | [[#LOOPNE|LOOPNE]]
| colspan="13" |
|-
| style="text-align:left;" | Interrupt
| style="border-right:none;" | [[#INT|INT]]
| style="border-left:none;" | [[#IRET|IRET]]
| style="" | [[#INTO|INTO]]
| style="" | [[#HLT|HLT]]
| style="" | [[#BOUND|BOUND]]
| colspan="11" |
|-
| style="text-align:left;" | Stack
| style="border-right:none;" | [[#PUSH|PUSH]]
| style="border-left:none;" | [[#POP|POP]]
| style="border-right:none;" | [[#PUSHA|PUSHA]]
| style="border-left:none;" | [[#POPA|POPA]]
| style="border-right:none;" | [[#PUSHF|PUSHF]]
| style="border-left:none;" | [[#POPF|POPF]]
| colspan="10" |
|-
| style="text-align:left;" | Flags
| style="border-right:none;" | [[#CLC|CLC]]
| style="border-left:none;" | [[#STC|STC]]
| style="border-right:none;" | [[#CLD|CLD]]
| style="border-left:none;" | [[#STD|STD]]
| style="border-right:none;" | [[#CLI|CLI]]
| style="border-left:none;" | [[#STI|STI]]
| style="" | [[#CMC|CMC]]
| style="border-right:none;" | [[#LAHF|LAHF]]
| style="border-left:none;" | [[#SAHF|SAHF]]
| colspan="7" |
|-
| style="text-align:left;" | Prefix
| style="" | [[#CS|CS]]
| style="" | [[#DS|DS]]
| style="" | [[#ES|ES]]
| style="" | [[#SS|SS]]
| colspan="12" |
|-
| style="text-align:left;" | String
| style="border-right:none;" | [[#REP|REP]]
| style="border-left:none;border-right:none;" | [[#REP|REPE]]
| style="border-left:none;" | [[#REPNE|REPNE]]
| style="" | [[#MOVSB|MOVSB]]
| style="" | [[#MOVSW|MOVSW]]
| style="border-right:none;" | [[#LODSB|LODSB]]
| style="border-left:none;" | [[#STOSB|STOSB]]
| style="border-right:none;" | [[#LODSW|LODSW]]
| style="border-left:none;" | [[#STOSW|STOSW]]
| style="" | [[#CMPSB|CMPSB]]
| style="" | [[#SCASB|SCASB]]
| style="" | [[#CMPSW|CMPSW]]
| style="" | [[#SCASW|SCASW]]
| colspan="3" |
|-
| style="text-align:left;" | Other
| style="" | [[#NOP|NOP]]
| style="border-right:none;" | [[#ENTER|ENTER]]
| style="border-left:none;" | [[#LEAVE|LEAVE]]
| style="" | [[#LOCK|LOCK]]
| style="" | [[#POLL|POLL]]
| colspan="11" |
|}
== Instruction encoding ==
=== ModR/M byte ===
The ModR/M byte is used in most addressing modes which reference a memory location. This byte consists of three bitfield values:
* <tt>oo</tt> - M'''o'''de;
* <tt>rrr</tt> - Two possible functions:
** '''R'''egister (for addressing modes which require both a register and a register/memory operand),
** Opcode extension (for some opcodes' addressing modes which do not have such a requirement);
* <tt>mmm</tt> - Register/'''M'''emory.
The ''Mode'' and ''Register/Memory'' bitfields can refer to a memory location or to a register, as shown in the table below. In some addressing modes, the ''Register'' field also refers to a register; it is always interpreted as if ''Mode'' was equal to <tt>11</tt>.
{| class="wikitable" style="text-align: center"
! R/M \ Mode
! <tt>00</tt>
! <tt>01</tt>
! <tt>10</tt>
! <tt>11</tt> ''(byte)''
! <tt>11</tt> ''(word)''
|-
| <tt>000</tt>
| DS:[BX + SI]
| DS:[BX + SI + disp8]
| DS:[BX + SI + disp16]
| AL
| AX
|-
| <tt>001</tt>
| DS:[BX + DI]
| DS:[BX + DI + disp8]
| DS:[BX + DI + disp16]
| CL
| CX
|-
| <tt>010</tt>
| SS:[BP + SI]
| SS:[BP + SI + disp8]
| SS:[BP + SI + disp16]
| DL
| DX
|-
| <tt>011</tt>
| SS:[BP + DI]
| SS:[BP + DI + disp8]
| SS:[BP + DI + disp16]
| BL
| BX
|-
| <tt>100</tt>
| DS:[SI]
| DS:[SI + disp8]
| DS:[SI + disp16]
| AH
| SP
|-
| <tt>101</tt>
| DS:[DI]
| DS:[DI + disp8]
| DS:[DI + disp16]
| CH
| BP
|-
| <tt>110</tt>
| ''DS:[disp16]''
| SS:[BP + disp8]
| SS:[BP + disp16]
| DH
| SI
|-
| <tt>111</tt>
| DS:[BX]
| DS:[BX + disp8]
| DS:[BX + disp16]
| BH
| DI
|}
Displacements are either 8-bit (disp8) or 16-bit (disp16) signed values and they always immediately follow the ModR/M byte. Note that (<tt>oo</tt> = <tt>00</tt>, <tt>mmm</tt> = <tt>110</tt>) is a special case, in which the ''disp16'' value is used directly as a near pointer.
The instruction encoding lists below refer to this byte as <tt>oorrrmmm</tt> (binary), <tt>/r</tt> (hexadecimal) or <tt>/0</tt> (hexademical, <tt>rrr</tt> used as function <tt>0</tt>).
== Official instructions ==
{{Anchor|AAA}}
=== AAA ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| AAA || <tt>37</tt> || <tt>00110111</tt> || 1 || 9
|}
----
{{Anchor|AAD}}
=== AAD ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| AAD imm8 || <tt>B5 ii</tt> || <tt>11010100 iiiiiiii</tt> || 2 || 6
|}
----
{{Anchor|AAM}}
=== AAM ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| AAM imm8 || <tt>B4 ii</tt> || <tt>11010100 iiiiiiii</tt> || 2 || 17
|}
----
{{Anchor|AAS}}
=== AAS ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| AAS || <tt>3F</tt> || <tt>00111111</tt> || 1 || 9
|}
----
{{Anchor|ADC}}
=== ADC ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| ADC AL, imm || <tt>14 ii</tt> || <tt>00010100 iiiiiiii</tt> || 2 || 1
|-
| ADC AX, imm || <tt>15 ii ii</tt> || <tt>00010101 iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| ADC mem8, imm8 || <tt>80 /2 ii</tt> || <tt>10000000 oo010mmm iiiiiiii</tt> || 3+ || 3
|-
| ADC mem16, imm16 || <tt>81 /2 ii ii</tt> || <tt>10000001 oo010mmm iiiiiiii iiiiiiii</tt> || 4+ || 3
|-
| ADC mem16, simm8 || <tt>83 /2 ii ii</tt> || <tt>10000011 oo010mmm iiiiiiii iiiiiiii</tt> || 4+ || 3
|-
| ADC mem8, reg8 || <tt>10 /r</tt> || <tt>00010000 oorrrmmm</tt> || 2+ || 3
|-
| ADC mem16, reg16 || <tt>11 /r</tt> || <tt>00010001 oorrrmmm</tt> || 2+ || 3
|-
| ADC reg8, imm8 || <tt>80 /2 ii</tt> || <tt>10000000 11010mmm iiiiiiii</tt> || 3+ || 1
|-
| ADC reg16, imm16 || <tt>81 /2 ii ii</tt> || <tt>10000001 11010mmm iiiiiiii iiiiiiii</tt> || 4+ || 1
|-
| ADC reg16, simm8 || <tt>83 /2 ii ii</tt> || <tt>10000011 11010mmm iiiiiiii iiiiiiii</tt> || 4+ || 1
|-
| ADC reg8, mem8 || <tt>12 /r</tt> || <tt>00010010 oorrrmmm</tt> || 2+ || 2
|-
| ADC reg16, mem16 || <tt>13 /r</tt> || <tt>00010011 oorrrmmm</tt> || 2+ || 2
|-
| ADC reg8, reg8 || <tt>10 /r</tt> || <tt>000100.0 11rrrmmm</tt> || 2 || 1
|-
| ADC reg16, reg16 || <tt>11 /r</tt> || <tt>000100.1 11rrrmmm</tt> || 2 || 1
|}
----
{{Anchor|ADD}}
=== ADD ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| ADD AL, imm || <tt>04 ii</tt> || <tt>00000100 iiiiiiii</tt> || 2 || 1
|-
| ADD AX, imm || <tt>05 ii ii</tt> || <tt>00000101 iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| ADD mem8, imm8 || <tt>80 /0 ii</tt> || <tt>10000000 oo000mmm iiiiiiii</tt> || 3+ || 3
|-
| ADD mem16, imm16 || <tt>81 /0 ii ii</tt> || <tt>10000001 oo000mmm iiiiiiii iiiiiiii</tt> || 4+ || 3
|-
| ADD mem16, simm8 || <tt>83 /0 ii ii</tt> || <tt>10000011 oo000mmm iiiiiiii iiiiiiii</tt> || 4+ || 3
|-
| ADD mem8, reg8 || <tt>00 /r</tt> || <tt>00000000 oorrrmmm</tt> || 2+ || 3
|-
| ADD mem16, reg16 || <tt>01 /r</tt> || <tt>00000001 oorrrmmm</tt> || 2+ || 3
|-
| ADD reg8, imm8 || <tt>80 /0 ii</tt> || <tt>10000000 11000mmm iiiiiiii</tt> || 3+ || 1
|-
| ADD reg16, imm16 || <tt>81 /0 ii ii</tt> || <tt>10000001 11000mmm iiiiiiii iiiiiiii</tt> || 4+ || 1
|-
| ADD reg16, simm8 || <tt>83 /0 ii ii</tt> || <tt>10000011 11000mmm iiiiiiii iiiiiiii</tt> || 4+ || 1
|-
| ADD reg8, mem8 || <tt>02 /r</tt> || <tt>00000010 oorrrmmm</tt> || 2+ || 2
|-
| ADD reg16, mem16 || <tt>03 /r</tt> || <tt>00000011 oorrrmmm</tt> || 2+ || 2
|-
| ADD reg8, reg8 || <tt>00 /r</tt> || <tt>000000.0 11rrrmmm</tt> || 2 || 1
|-
| ADD reg16, reg16 || <tt>01 /r</tt> || <tt>000000.1 11rrrmmm</tt> || 2 || 1
|}
----
{{Anchor|AND}}
=== AND ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| AND AL, imm || <tt>24 ii</tt> || <tt>00100100 iiiiiiii</tt> || 2 || 1
|-
| AND AX, imm || <tt>25 ii ii</tt> || <tt>00100101 iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| AND mem8, imm8 || <tt>80 /4 ii</tt> || <tt>10000000 oo100mmm iiiiiiii</tt> || 3+ || 3
|-
| AND mem16, imm16 || <tt>81 /4 ii ii</tt> || <tt>10000001 oo100mmm iiiiiiii iiiiiiii</tt> || 4+ || 3
|-
| AND mem16, simm8 || <tt>83 /4 ii ii</tt> || <tt>10000011 oo100mmm iiiiiiii iiiiiiii</tt> || 4+ || 3
|-
| AND mem8, reg8 || <tt>20 /r</tt> || <tt>00100000 oorrrmmm</tt> || 2+ || 3
|-
| AND mem16, reg16 || <tt>21 /r</tt> || <tt>00100001 oorrrmmm</tt> || 2+ || 3
|-
| AND reg8, imm8 || <tt>80 /4 ii</tt> || <tt>10000000 11100mmm iiiiiiii</tt> || 3+ || 1
|-
| AND reg16, imm16 || <tt>81 /4 ii ii</tt> || <tt>10000001 11100mmm iiiiiiii iiiiiiii</tt> || 4+ || 1
|-
| AND reg16, simm8 || <tt>83 /4 ii ii</tt> || <tt>10000011 11100mmm iiiiiiii iiiiiiii</tt> || 4+ || 1
|-
| AND reg8, mem8 || <tt>22 /r</tt> || <tt>00100010 oorrrmmm</tt> || 2+ || 2
|-
| AND reg16, mem16 || <tt>23 /r</tt> || <tt>00100011 oorrrmmm</tt> || 2+ || 2
|-
| AND reg8, reg8 || <tt>20 /r</tt> || <tt>001000.0 11rrrmmm</tt> || 2 || 1
|-
| AND reg16, reg16 || <tt>21 /r</tt> || <tt>001000.1 11rrrmmm</tt> || 2 || 1
|}
----
{{Anchor|BOUND}}
=== BOUND ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| BOUND reg16, mem16:16 || <tt>62 /r</tt> || <tt>01100010 oorrrmmm</tt> || 2+ || 13 (20 if condition met)
|}
----
{{Anchor|CALL}}
=== CALL ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| CALL ptr16:16 || <tt>CA oo oo ss ss</tt> || <tt>10011010 oooooooo oooooooo ssssssss ssssssss</tt> || 5 || 10
|-
| CALL mem16 || <tt>FF /2</tt> || <tt>11111111 oo010mmm</tt> || 2+ || 6
|-
| CALL mem16:16 || <tt>FF /3</tt> || <tt>11111111 oo011mmm</tt> || 2+ || 12
|-
| CALL reg16 || <tt>FF /2</tt> || <tt>11111111 11010mmm</tt> || 2 || 5
|-
| CALL rel16 || <tt>E8 ii ii</tt> || <tt>11101000 iiiiiiii iiiiiiii</tt> || 3 || 5
|}
----
{{Anchor|CBW}}
=== CBW ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| CBW || <tt>98</tt> || <tt>10011000</tt> || 1 || 1
|}
----
{{Anchor|CLC}}
=== CLC ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| CLC || <tt>F8</tt> || <tt>11111000</tt> || 1 || 4
|}
----
{{Anchor|CLD}}
=== CLD ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| CLD || <tt>FC</tt> || <tt>11111100</tt> || 1 || 4
|}
----
{{Anchor|CLI}}
=== CLI ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| CLI || <tt>FA</tt> || <tt>11111010</tt> || 1 || 4
|}
----
{{Anchor|CMC}}
=== CMC ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| CMC || <tt>F5</tt> || <tt>11110101</tt> || 1 || 4
|}
----
{{Anchor|CMP}}
=== CMP ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| CMP AL, imm || <tt>3C ii</tt> || <tt>00111100 iiiiiiii</tt> || 2 || 1
|-
| CMP AX, imm || <tt>3D ii ii</tt> || <tt>00111101 iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| CMP mem8, imm8 || <tt>80 /7 ii</tt> || <tt>10000000 oo111mmm iiiiiiii</tt> || 3+ || 2
|-
| CMP mem16, imm16 || <tt>81 /7 ii ii</tt> || <tt>10000001 oo111mmm iiiiiiii iiiiiiii</tt> || 4+ || 2
|-
| CMP mem16, simm8 || <tt>83 /7 ii ii</tt> || <tt>10000011 oo111mmm iiiiiiii iiiiiiii</tt> || 4+ || 2
|-
| CMP mem8, reg8 || <tt>38 /r</tt> || <tt>00111000 oorrrmmm</tt> || 2+ || 2
|-
| CMP mem16, reg16 || <tt>39 /r</tt> || <tt>00111001 oorrrmmm</tt> || 2+ || 2
|-
| CMP reg8, imm8 || <tt>80 /7 ii</tt> || <tt>10000000 11111mmm iiiiiiii</tt> || 3+ || 1
|-
| CMP reg16, imm16 || <tt>81 /7 ii ii</tt> || <tt>10000001 11111mmm iiiiiiii iiiiiiii</tt> || 4+ || 1
|-
| CMP reg16, simm8 || <tt>83 /7 ii ii</tt> || <tt>10000011 11111mmm iiiiiiii iiiiiiii</tt> || 4+ || 1
|-
| CMP reg8, mem8 || <tt>3A /r</tt> || <tt>00111010 oorrrmmm</tt> || 2+ || 2
|-
| CMP reg16, mem16 || <tt>3B /r</tt> || <tt>00111011 oorrrmmm</tt> || 2+ || 2
|-
| CMP reg8, reg8 || <tt>38 /r</tt> || <tt>001110.0 11rrrmmm</tt> || 2 || 1
|-
| CMP reg16, reg16 || <tt>39 /r</tt> || <tt>001110.1 11rrrmmm</tt> || 2 || 1
|}
----
{{Anchor|CMPSB}}
{{Anchor|CMPSW}}
=== CMPSB/CMPSW ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| CMPSB || <tt>A6</tt> || <tt>10100110</tt> || 1 || 6
|-
| CMPSW || <tt>A7</tt> || <tt>10100111</tt> || 1 || 6
|}
----
{{Anchor|CS}}
=== CS ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| CS || <tt>2E</tt> || <tt>00101110</tt> || 1 || 1
|}
----
{{Anchor|CWD}}
=== CWD ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| CWD || <tt>99</tt> || <tt>10011001</tt> || 1 || 1
|}
----
{{Anchor|DAA}}
=== DAA ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| DAA || <tt>27</tt> || <tt>00100111</tt> || 1 || 10
|}
----
{{Anchor|DAS}}
=== DAS ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| DAS || <tt>2F</tt> || <tt>00101111</tt> || 1 || 10
|}
----
{{Anchor|DEC}}
=== DEC ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| DEC mem8 || <tt>FE /1</tt> || <tt>11111110 oo001mmm</tt> || 2+ || 3
|-
| DEC mem16 || <tt>FF /1</tt> || <tt>11111111 oo001mmm</tt> || 2+ || 3
|-
| DEC reg8 || <tt>FE /1</tt> || <tt>11111110 11001mmm</tt> || 2+ || 1
|-
| DEC reg16 || <tt>4x</tt> || <tt>01001rrr</tt> || 1 || 1
|}
----
{{Anchor|DIV}}
=== DIV ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| DIV mem8 || <tt>F6 /6</tt> || <tt>11110110 oo110mmm</tt> || 2+ || 16
|-
| DIV mem16 || <tt>F7 /6</tt> || <tt>11111111 oo110mmm</tt> || 2+ || 24
|-
| DIV reg8 || <tt>F6 /6</tt> || <tt>11111110 11110mmm</tt> || 2+ || 15
|-
| DIV reg16 || <tt>F7 /6</tt> || <tt>11111111 11110mmm</tt> || 2+ || 23
|}
----
{{Anchor|DS}}
=== DS ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| DS || <tt>3E</tt> || <tt>00111110</tt> || 1 || 1
|}
----
{{Anchor|ENTER}}
=== ENTER ===
----
{{Anchor|ES}}
=== ES ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| ES || <tt>26</tt> || <tt>00100110</tt> || 1 || 1
|}
----
{{Anchor|HLT}}
=== HLT ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| HLT || <tt>F4</tt> || <tt>11110100</tt> || 1 || 9
|}
----
{{Anchor|IDIV}}
=== IDIV ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| IDIV mem8 || <tt>F6 /7</tt> || <tt>11110110 oo111mmm</tt> || 2+ || 18
|-
| IDIV mem16 || <tt>F7 /7</tt> || <tt>11111111 oo111mmm</tt> || 2+ || 25
|-
| IDIV reg8 || <tt>F6 /7</tt> || <tt>11111110 11111mmm</tt> || 2+ || 17
|-
| IDIV reg16 || <tt>F7 /7</tt> || <tt>11111111 11111mmm</tt> || 2+ || 24
|}
----
{{Anchor|IMUL}}
=== IMUL ===
----
{{Anchor|IN}}
=== IN ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| IN AL, DX || <tt>EC</tt> || <tt>11101100</tt> || 1 || 6
|-
| IN AX, DX || <tt>ED</tt> || <tt>11101101</tt> || 1 || 6
|-
| IN AL, imm8 || <tt>E4 ii</tt> || <tt>11100100 iiiiiiii</tt> || 2 || 6
|-
| IN AX, imm8 || <tt>E5 ii</tt> || <tt>11100101 iiiiiiii</tt> || 2 || 6
|}
----
{{Anchor|INC}}
=== INC ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| INC mem8 || <tt>FE /0</tt> || <tt>11111110 oo000mmm</tt> || 2+ || 3
|-
| INC mem16 || <tt>FF /0</tt> || <tt>11111111 oo000mmm</tt> || 2+ || 3
|-
| INC reg8 || <tt>FE /0</tt> || <tt>11111110 11000mmm</tt> || 2+ || 1
|-
| INC reg16 || <tt>4x</tt> || <tt>01000rrr</tt> || 1 || 1
|}
----
{{Anchor|INSB}}
{{Anchor|INSW}}
=== INSB/INSW ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| INSB || <tt>6C</tt> || <tt>01101100</tt> || 1 || 6
|-
| INSW || <tt>6D</tt> || <tt>01101101</tt> || 1 || 6
|}
----
{{Anchor|INT}}
=== INT ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| INT 3 || <tt>CC</tt> || <tt>11001100</tt> || 1 || 9
|-
| INT imm8 || <tt>CD ii</tt> || <tt>11001101 iiiiiiii</tt> || 2 || 10
|}
----
{{Anchor|INTO}}
=== INTO ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| INTO || <tt>CE</tt> || <tt>11001110</tt> || 1 || 6 (13 if OF = 1)
|}
----
{{Anchor|IRET}}
=== IRET ===
----
{{Anchor|JA}}
=== JA ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JA rel8 || <tt>77 ii</tt> || <tt>01110111 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JBE}}
=== JBE ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JA rel8 || <tt>76 ii</tt> || <tt>01110110 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JC}}
=== JC/JB ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JC rel8 || <tt>72 ii</tt> || <tt>01110010 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JCXZ}}
=== JCXZ ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JCXZ rel8 || <tt>E3 ii</tt> || <tt>11100011 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JG}}
=== JG ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JG rel8 || <tt>7F ii</tt> || <tt>01111111 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JGE}}
=== JGE ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JGE rel8 || <tt>7D ii</tt> || <tt>01111101 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JL}}
=== JL ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JL rel8 || <tt>7C ii</tt> || <tt>01111100 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JLE}}
=== JLE ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JLE rel8 || <tt>7E ii</tt> || <tt>01111110 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JMP}}
=== JMP ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JMP ptr16:16 || <tt>EA oo oo ss ss</tt> || <tt>11101010 oooooooo oooooooo ssssssss ssssssss</tt> || 5 || 7
|-
| JMP mem16 || <tt>FF /4</tt> || <tt>11111111 oo100mmm</tt> || 2+ || 5
|-
| JMP mem16:16 || <tt>FF /5</tt> || <tt>11111111 oo101mmm</tt> || 2+ || 10
|-
| JMP reg16 || <tt>FF /4</tt> || <tt>11111111 11100mmm</tt> || 2 || 4
|-
| JMP rel8 || <tt>EB ii</tt> || <tt>11101011 iiiiiiii</tt> || 2 || 4
|-
| JMP rel16 || <tt>E9 ii ii</tt> || <tt>11101001 iiiiiiii iiiiiiii</tt> || 3 || 4
|}
----
{{Anchor|JNC}}
=== JNC/JAE ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JNC rel8 || <tt>73 ii</tt> || <tt>01110011 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JNO}}
=== JNO ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JNO rel8 || <tt>71 ii</tt> || <tt>01110001 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JNP}}
=== JNP ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JNP rel8 || <tt>7B ii</tt> || <tt>01111011 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JNS}}
=== JNS ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JNS rel8 || <tt>79 ii</tt> || <tt>01111001 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JNZ}}
=== JNZ/JNE ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JNZ rel8 || <tt>75 ii</tt> || <tt>01110101 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JO}}
=== JO ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JO rel8 || <tt>70 ii</tt> || <tt>01110000 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JP}}
=== JP ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JP rel8 || <tt>7A ii</tt> || <tt>01111010 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JS}}
=== JS ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JS rel8 || <tt>78 ii</tt> || <tt>01111000 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JZ}}
=== JZ/JE ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JZ rel8 || <tt>74 ii</tt> || <tt>01110100 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|LAHF}}
=== LAHF ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| LAHF || <tt>9F</tt> || <tt>10011111</tt> || 1 || 2
|}
----
{{Anchor|LDS}}
=== LDS ===
----
{{Anchor|LEA}}
=== LEA ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| LEA reg16, mem16 || <tt>8D /r</tt> || <tt>10001101 oorrrmmm</tt> || 2+ || 1
|}
----
{{Anchor|LEAVE}}
=== LEAVE ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| LEAVE || <tt>C9</tt> || <tt>11001001</tt> || 1 || 2
|}
----
{{Anchor|LES}}
=== LES ===
----
{{Anchor|LOCK}}
=== LOCK ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| LOCK || <tt>F0</tt> || <tt>11110000</tt> || 1 || 1
|}
----
{{Anchor|LODSB}}
{{Anchor|LODSW}}
=== LODSB/LODSW ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| LODSB || <tt>AC</tt> || <tt>10101100</tt> || 1 || 3
|-
| LODSW || <tt>AD</tt> || <tt>10101101</tt> || 1 || 3
|}
----
{{Anchor|LOOP}}
=== LOOP ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| LOOP rel8 || <tt>E2 ii</tt> || <tt>11100010 iiiiiiii</tt> || 2 || 2 (5 if branch taken)
|}
----
{{Anchor|LOOPE}}
=== LOOPE ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| LOOPE rel8 || <tt>E1 ii</tt> || <tt>11100001 iiiiiiii</tt> || 2 || 3 (6 if branch taken)
|}
----
{{Anchor|LOOPNE}}
=== LOOPNE ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| LOOPNE rel8 || <tt>E0 ii</tt> || <tt>11100000 iiiiiiii</tt> || 2 || 3 (6 if branch taken)
|}
----
{{Anchor|MOV}}
=== MOV ===
----
{{Anchor|MOVSB}}
{{Anchor|MOVSW}}
=== MOVSB/MOVSW ===
----
{{Anchor|MUL}}
=== MUL ===
----
{{Anchor|NEG}}
=== NEG ===
----
{{Anchor|NOP}}
=== NOP ===
----
{{Anchor|NOT}}
=== NOT ===
----
{{Anchor|OR}}
=== OR ===
----
{{Anchor|OUT}}
=== OUT ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| OUT AL, DX || <tt>EE</tt> || <tt>11101110</tt> || 1 || 6
|-
| OUT AX, DX || <tt>EF</tt> || <tt>11101111</tt> || 1 || 6
|-
| OUT AL, imm8 || <tt>E6 ii</tt> || <tt>11100110 iiiiiiii</tt> || 2 || 6
|-
| OUT AX, imm8 || <tt>E7 ii</tt> || <tt>11100111 iiiiiiii</tt> || 2 || 6
|}
----
{{Anchor|OUTSB}}
{{Anchor|OUTSW}}
=== OUTSB/OUTSW ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| OUTSB || <tt>6E</tt> || <tt>01101110</tt> || 1 || 6
|-
| OUTSW || <tt>6F</tt> || <tt>01101111</tt> || 1 || 6
|}
----
{{Anchor|POLL}}
=== POLL ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| POLL || <tt>6E</tt> || <tt>01101110</tt> || 1 || 9<ref>On the WonderSwan implementation, POLLB is always held low; on other implementations, POLL will wait for POLLB to be held low in 9-cycle intervals.</ref>
|}
----
{{Anchor|POP}}
=== POP ===
----
{{Anchor|POPA}}
=== POPA ===
----
{{Anchor|POPF}}
=== POPF ===
----
{{Anchor|PUSH}}
=== PUSH ===
----
{{Anchor|PUSHA}}
=== PUSHA ===
----
{{Anchor|PUSHF}}
=== PUSHF ===
----
{{Anchor|RCL}}
=== RCL ===
----
{{Anchor|RCR}}
=== RCR ===
----
{{Anchor|REP}}
=== REP/REPE/REPZ ===
----
{{Anchor|REPNE}}
=== REPNE/REPNZ ===
----
{{Anchor|RET}}
=== RET ===
----
{{Anchor|RETF}}
=== RETF ===
----
{{Anchor|ROL}}
=== ROL ===
----
{{Anchor|ROR}}
=== ROR ===
----
{{Anchor|SAHF}}
=== SAHF ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| SAHF || <tt>9E</tt> || <tt>10011110</tt> || 1 || 4
|}
----
{{Anchor|SAR}}
=== SAR ===
----
{{Anchor|SBB}}
=== SBB ===
----
{{Anchor|SCASB}}
{{Anchor|SCASW}}
=== SCASB/SCASW ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| SCASB || <tt>AE</tt> || <tt>10101110</tt> || 1 || 4
|-
| SCASW || <tt>AF</tt> || <tt>10101111</tt> || 1 || 4
|}
----
{{Anchor|SHL}}
=== SHL ===
----
{{Anchor|SHR}}
=== SHR ===
----
{{Anchor|SS}}
=== SS ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| SS || <tt>36</tt> || <tt>00110110</tt> || 1 || 1
|}
----
{{Anchor|STC}}
=== STC ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| STC || <tt>F9</tt> || <tt>11111001</tt> || 1 || 4
|}
----
{{Anchor|STD}}
=== STD ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| STD || <tt>FD</tt> || <tt>11111101</tt> || 1 || 4
|}
----
{{Anchor|STI}}
=== STI ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| STI || <tt>FB</tt> || <tt>11111011</tt> || 1 || 4
|}
----
{{Anchor|STOSB}}
{{Anchor|STOSW}}
=== STOSB/STOSW ===
----
{{Anchor|SUB}}
=== SUB ===
----
{{Anchor|TEST}}
=== TEST ===
----
{{Anchor|XCHG}}
=== XCHG ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| XCHG AX, reg16<br/>XCHG reg16, AX || <tt>9x</tt> || <tt>10010rrr</tt> || 1 || 3
|-
| XCHG mem8, reg8<br/>XCHG reg8, mem8 || <tt>86 /r</tt> || <tt>10000110 oorrrmmm</tt> || 2+ || 5
|-
| XCHG mem16, reg16<br/>XCHG reg16, mem16 || <tt>87 /r</tt> || <tt>10000111 oorrrmmm</tt> || 2+ || 5
|-
| XCHG reg8, reg8 || <tt>86 /r</tt> || <tt>10000110 11rrrmmm</tt> || 2+ || 3
|-
| XCHG reg16, reg16 || <tt>87 /r</tt> || <tt>10000111 11rrrmmm</tt> || 2+ || 3
|}
----
{{Anchor|XLAT}}
=== XLAT ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| XLAT || <tt>D7</tt> || <tt>11010111</tt> || 1 || 5
|}
----
{{Anchor|XOR}}
=== XOR ===
----
== Notes ==
<references />
9c0d934326ecc4a44b841f82395fff965d16fdc7
457
456
2024-12-27T22:24:25Z
Asie
351
wikitext
text/x-wiki
__NOTOC__
Note that this page is a work in progress.
{| class="wikitable" style="text-align: center"
|+ Official V30MZ (80186) Instructions
|-
| [[#AAA|AAA]] || [[#AAD|AAD]] || [[#AAM|AAM]] || [[#AAS|AAS]] || [[#ADC|ADC]] || [[#ADD|ADD]] || [[#AND|AND]] || [[#BOUND|BOUND]] || [[#CALL|CALL]] || [[#CBW|CBW]] || [[#CLC|CLC]]
|-
| [[#CLD|CLD]] || [[#CLI|CLI]] || [[#CMC|CMC]] || [[#CMP|CMP]] || [[#CMPSB|CMPSB]] || [[#CMPSW|CMPSW]] || [[#CS|CS]] || [[#CWD|CWD]] || [[#DAA|DAA]] || [[#DAS|DAS]] || [[#DEC|DEC]]
|-
| [[#DIV|DIV]] || [[#DS|DS]] || [[#ENTER|ENTER]] || [[#ES|ES]] || [[#HLT|HLT]] || [[#IDIV|IDIV]] || [[#IMUL|IMUL]] || [[#IN|IN]] || [[#INC|INC]] || [[#INSB|INSB]] || [[#INSW|INSW]]
|-
| [[#INT|INT]] || [[#INTO|INTO]] || [[#IRET|IRET]] || [[#JA|JA]] || [[#JBE|JBE]] || [[#JC|JC]] || [[#JCXZ|JCXZ]] || [[#JG|JG]] || [[#JGE|JGE]] || [[#JL|JL]] || [[#JLE|JLE]]
|-
| [[#JMP|JMP]] || [[#JNC|JNC]] || [[#JNO|JNO]] || [[#JNP|JNP]] || [[#JNS|JNS]] || [[#JNZ|JNZ]] || [[#JO|JO]] || [[#JP|JP]] || [[#JS|JS]] || [[#JZ|JZ]] || [[#LAHF|LAHF]]
|-
| [[#LDS|LDS]] || [[#LEA|LEA]] || [[#LEAVE|LEAVE]] || [[#LES|LES]] || [[#LOCK|LOCK]] || [[#LODSB|LODSB]] || [[#LODSW|LODSW]] || [[#LOOP|LOOP]] || [[#LOOPE|LOOPE]] || [[#LOOPNE|LOOPNE]] || [[#MOV|MOV]]
|-
| [[#MOVSB|MOVSB]] || [[#MOVSW|MOVSW]] || [[#MUL|MUL]] || [[#NEG|NEG]] || [[#NOP|NOP]] || [[#NOT|NOT]] || [[#OR|OR]] || [[#OUT|OUT]] || [[#OUTSB|OUTSB]] || [[#OUTSW|OUTSW]] || [[#POLL|POLL]]
|-
| [[#POP|POP]] || [[#POPA|POPA]] || [[#POPF|POPF]] || [[#PUSH|PUSH]] || [[#PUSHA|PUSHA]] || [[#PUSHF|PUSHF]] || [[#RCL|RCL]] || [[#RCR|RCR]] || [[#REP|REP]] || [[#REPNE|REPNE]] || [[#RET|RET]]
|-
| [[#RETF|RETF]] || [[#ROL|ROL]] || [[#ROR|ROR]] || [[#SAHF|SAHF]] || [[#SAR|SAR]] || [[#SBB|SBB]] || [[#SCASB|SCASB]] || [[#SCASW|SCASW]] || [[#SHL|SHL]] || [[#SHR|SHR]] || [[#SS|SS]]
|-
| [[#STC|STC]] || [[#STD|STD]] || [[#STI|STI]] || [[#STOSB|STOSB]] || [[#STOSW|STOSW]] || [[#SUB|SUB]] || [[#TEST|TEST]] || [[#XCHG|XCHG]] || [[#XLAT|XLAT]] || [[#XOR|XOR]]
|}
{| class="mw-collapsible mw-collapsed wikitable sortable" style="width: 340px;"
|+ style="white-space:nowrap; border:1px solid; padding:3px; border-color:rgb(162, 169, 177); background-color:rgb(234, 236, 240);" | Intel <-> NEC mnemonic translation table
!Intel
!NEC
|-
| [[#AAA|AAA]]
| [[#AAA|ADJBA]]
|-
| [[#AAD|AAD]]
| [[#AAD|CVTDB]]
|-
| [[#AAM|AAM]]
| [[#AAM|CVTBD]]
|-
| [[#AAS|AAS]]
| [[#AAS|ADJBS]]
|-
| [[#ADC|ADC]]
| [[#ADC|ADDC]]
|-
| [[#ADD|ADD]]
| [[#ADD|ADD]]
|-
| [[#AND|AND]]
| [[#AND|AND]]
|-
| [[#BOUND|BOUND]]
| [[#BOUND|CHKIND]]
|-
| [[#CALL|CALL]]
| [[#CALL|CALL]]
|-
| [[#CBW|CBW]]
| [[#CBW|CVTBW]]
|-
| [[#CLC|CLC]]
| [[#CLC|CLR1 CY]]
|-
| [[#CLD|CLD]]
| [[#CLD|CLR1 DIR]]
|-
| [[#CLI|CLI]]
| [[#CLI|DI]]
|-
| [[#CMC|CMC]]
| [[#CMC|NOT1 CY]]
|-
| [[#CMP|CMP]]
| [[#CMP|CMP]]
|-
| [[#CMPSB|CMPSB]]
| [[#CMPSB|CMPBKB]]
|-
| [[#CMPSW|CMPSW]]
| [[#CMPSW|CMPBKW]]
|-
| [[#CS|CS]]
| [[#CS|PS]]
|-
| [[#CWD|CWD]]
| [[#CWD|CVTWL]]
|-
| [[#DAA|DAA]]
| [[#DAA|ADJ4A]]
|-
| [[#DAS|DAS]]
| [[#DAS|ADJ4S]]
|-
| [[#DEC|DEC]]
| [[#DEC|DEC]]
|-
| [[#DIV|DIV]]
| [[#DIV|DIVU]]
|-
| [[#DS|DS]]
| [[#DS|DS0]]
|-
| [[#ENTER|ENTER]]
| [[#ENTER|PREPARE]]
|-
| [[#ES|ES]]
| [[#ES|DS1]]
|-
| [[#HLT|HLT]]
| [[#HLT|HALT]]
|-
| [[#IDIV|IDIV]]
| [[#IDIV|DIV]]
|-
| [[#IMUL|IMUL]]
| [[#IMUL|MUL]]
|-
| [[#IN|IN]]
| [[#IN|IN]]
|-
| [[#INC|INC]]
| [[#INC|INC]]
|-
| [[#INSB|INSB]]
| [[#INSB|INMB]]
|-
| [[#INSW|INSW]]
| [[#INSW|INMW]]
|-
| [[#INT|INT]]
| [[#INT|BRK]]
|-
| [[#INTO|INTO]]
| [[#INTO|BRKV]]
|-
| [[#IRET|IRET]]
| [[#IRET|RETI]]
|-
| [[#JA|JA]]
| [[#JA|BH]]
|-
| [[#JBE|JBE]]
| [[#JBE|BNH]]
|-
| [[#JC|JC/JB]]
| [[#JC|BC/BL]]
|-
| [[#JCXZ|JCXZ]]
| [[#JCXZ|BCWZ]]
|-
| [[#JG|JG]]
| [[#JG|BGT]]
|-
| [[#JGE|JGE]]
| [[#JGE|BGE]]
|-
| [[#JL|JL]]
| [[#JL|BLT]]
|-
| [[#JLE|JLE]]
| [[#JLE|BLE]]
|-
| [[#JMP|JMP]]
| [[#JMP|BR]]
|-
| [[#JNC|JNC/JAE]]
| [[#JNC|BNC/BNL]]
|-
| [[#JNO|JNO]]
| [[#JNO|BNV]]
|-
| [[#JNP|JNP]]
| [[#JNP|BPO]]
|-
| [[#JNS|JNS]]
| [[#JNS|BP]]
|-
| [[#JNZ|JNZ/JNE]]
| [[#JNZ|BNZ/BNE]]
|-
| [[#JO|JO]]
| [[#JO|BV]]
|-
| [[#JP|JP]]
| [[#JP|BPE]]
|-
| [[#JS|JS]]
| [[#JS|BN]]
|-
| [[#JZ|JZ/JE]]
| [[#JZ|BZ/BE]]
|-
| [[#LAHF|LAHF]]
| [[#LAHF|MOV]]
|-
| [[#LDS|LDS]]
| [[#LDS|MOV]]
|-
| [[#LEA|LEA]]
| [[#LEA|LDEA]]
|-
| [[#LEAVE|LEAVE]]
| [[#LEAVE|DISPOSE]]
|-
| [[#LES|LES]]
| [[#LES|MOV]]
|-
| [[#LOCK|LOCK]]
| [[#LOCK|BUSLOCK]]
|-
| [[#LODSB|LODSB]]
| [[#LODSB|LDMB]]
|-
| [[#LODSW|LODSW]]
| [[#LODSW|LDMW]]
|-
| [[#LOOP|LOOP]]
| [[#LOOP|DBNZ]]
|-
| [[#LOOPE|LOOPE]]
| [[#LOOPE|DBNZE]]
|-
| [[#LOOPNE|LOOPNE]]
| [[#LOOPNE|DBNZNE]]
|-
| [[#MOV|MOV]]
| [[#MOV|MOV]]
|-
| [[#MOVSB|MOVSB]]
| [[#MOVSB|MOVBKB]]
|-
| [[#MOVSW|MOVSW]]
| [[#MOVSW|MOVBKW]]
|-
| [[#MUL|MUL]]
| [[#MUL|MULU]]
|-
| [[#NEG|NEG]]
| [[#NEG|NEG]]
|-
| [[#NOP|NOP]]
| [[#NOP|NOP]]
|-
| [[#NOT|NOT]]
| [[#NOT|NOT]]
|-
| [[#OR|OR]]
| [[#OR|OR]]
|-
| [[#OUT|OUT]]
| [[#OUT|OUT]]
|-
| [[#OUTSB|OUTSB]]
| [[#OUTSB|OUTM]]
|-
| [[#OUTSW|OUTSW]]
| [[#OUTSW|OUTM]]
|-
| [[#POLL|POLL]]
| [[#POLL|POLL]]
|-
| [[#POP|POP]]
| [[#POP|POP]]
|-
| [[#POPA|POPA]]
| [[#POPA|POP]]
|-
| [[#POPF|POPF]]
| [[#POPF|POP]]
|-
| [[#PUSH|PUSH]]
| [[#PUSH|PUSH]]
|-
| [[#PUSHA|PUSHA]]
| [[#PUSHA|PUSH]]
|-
| [[#PUSHF|PUSHF]]
| [[#PUSHF|PUSH]]
|-
| [[#RCL|RCL]]
| [[#RCL|ROLC]]
|-
| [[#RCR|RCR]]
| [[#RCR|RORC]]
|-
| [[#REP|REP/REPE/REPZ]]
| [[#REP|REP/REPE/REPZ]]
|-
| [[#REPNE|REPNE/REPNZ]]
| [[#REPNE|REPNE/REPNZ]]
|-
| [[#RET|RET]]
| [[#RET|RET]]
|-
| [[#RETF|RETF]]
| [[#RETF|RET]]
|-
| [[#ROL|ROL]]
| [[#ROL|ROL]]
|-
| [[#ROR|ROR]]
| [[#ROR|ROR]]
|-
| [[#SAHF|SAHF]]
| [[#SAHF|MOV]]
|-
| [[#SAR|SAR]]
| [[#SAR|SHRA]]
|-
| [[#SBB|SBB]]
| [[#SBB|SUBC]]
|-
| [[#SCASB|SCASB]]
| [[#SCASB|CMPMB]]
|-
| [[#SCASW|SCASW]]
| [[#SCASW|CMPMW]]
|-
| [[#SHL|SHL]]
| [[#SHL|SHL]]
|-
| [[#SHR|SHR]]
| [[#SHR|SHR]]
|-
| [[#SS|SS]]
| [[#SS|SS]]
|-
| [[#STC|STC]]
| [[#STC|SET1 CY]]
|-
| [[#STD|STD]]
| [[#STD|SET1 DIR]]
|-
| [[#STI|STI]]
| [[#STI|EI]]
|-
| [[#STOSB|STOSB]]
| [[#STOSB|STMB]]
|-
| [[#STOSW|STOSW]]
| [[#STOSW|STMW]]
|-
| [[#SUB|SUB]]
| [[#SUB|SUB]]
|-
| [[#TEST|TEST]]
| [[#TEST|TEST]]
|-
| [[#XCHG|XCHG]]
| [[#XCHG|XCH]]
|-
| [[#XLAT|XLAT]]
| [[#XLAT|TRANS]]
|-
| [[#XOR|XOR]]
| [[#XOR|XOR]]
|}
== Official instructions by type ==
{| class="wikitable sortable" style="text-align: center"
!Type
!colspan=16 class="unsortable" | Instructions
|-
| style="text-align:left;" | Memory
| style="" | [[#MOV|MOV]]
| style="" | [[#XCHG|XCHG]]
| style="" | [[#XLAT|XLAT]]
| style="" | [[#LEA|LEA]]
| style="border-right:none;" | [[#LDS|LDS]]
| style="border-left:none;" | [[#LES|LES]]
| style="border-right:none;" | [[#IN|IN]]
| style="border-left:none;" | [[#OUT|OUT]]
| colspan="8" |
|-
| style="text-align:left;" | Ports
| style="border-right:none;" | [[#IN|IN]]
| style="border-left:none;" | [[#OUT|OUT]]
| style="border-right:none;" | [[#INSB|INSB]]
| style="border-left:none;" | [[#OUTSB|OUTSB]]
| style="border-right:none;" | [[#INSW|INSW]]
| style="border-left:none;" | [[#OUTSW|OUTSW]]
| colspan="10" |
|-
| style="text-align:left;" | Arithmetic
| style="border-right:none;" | [[#ADD|ADD]]
| style="border-left:none;" | [[#SUB|SUB]]
| style="border-right:none;" | [[#ADC|ADC]]
| style="border-left:none;" | [[#SBB|SBB]]
| style="border-right:none;" | [[#INC|INC]]
| style="border-left:none;" | [[#DEC|DEC]]
| style="border-right:none;" | [[#MUL|MUL]]
| style="border-left:none;" | [[#DIV|DIV]]
| style="border-right:none;" | [[#IMUL|IMUL]]
| style="border-left:none;" | [[#IDIV|IDIV]]
| style="" | [[#CMP|CMP]]
| style="" | [[#NEG|NEG]]
| colspan="4" |
|-
| style="text-align:left;" | Numeric
| style="" | [[#CBW|CBW]]
| style="" | [[#CWD|CWD]]
| style="" | [[#AAA|AAA]]
| style="" | [[#AAS|AAS]]
| style="" | [[#AAM|AAM]]
| style="" | [[#AAD|AAD]]
| style="" | [[#DAA|DAA]]
| style="" | [[#DAS|DAS]]
| colspan="8" |
|-
| style="text-align:left;" | Shift
| style="border-right:none;" | [[#ROL|ROL]]
| style="border-left:none;" | [[#ROR|ROR]]
| style="border-right:none;" | [[#RCL|RCL]]
| style="border-left:none;" | [[#RCR|RCR]]
| style="border-right:none;" | [[#SHL|SHL]]
| style="border-left:none;" | [[#SHR|SHR]]
| style="" | [[#SAR|SAR]]
| colspan="9" |
|-
| style="text-align:left;" | Bitwise
| style="" | [[#AND|AND]]
| style="" | [[#OR|OR]]
| style="" | [[#XOR|XOR]]
| style="" | [[#NOT|NOT]]
| style="" | [[#TEST|TEST]]
| colspan="11" |
|-
| style="text-align:left;" | Branch
| style="border-right:none;" | [[#JC|JC]]
| style="border-left:none;" | [[#JNC|JNC]]
| style="border-right:none;" | [[#JZ|JZ]]
| style="border-left:none;" | [[#JNZ|JNZ]]
| style="border-right:none;" | [[#JBE|JBE]]
| style="border-left:none;" | [[#JA|JA]]
| style="border-right:none;" | [[#JO|JO]]
| style="border-left:none;" | [[#JNO|JNO]]
| style="border-right:none;" | [[#JP|JP]]
| style="border-left:none;" | [[#JNP|JNP]]
| style="border-right:none;" | [[#JS|JS]]
| style="border-left:none;" | [[#JNS|JNS]]
| style="border-right:none;" | [[#JL|JL]]
| style="border-left:none;" | [[#JGE|JGE]]
| style="border-right:none;" | [[#JLE|JLE]]
| style="border-left:none;" | [[#JG|JG]]
|-
| style="text-align:left;" | Jump
| style="" | [[#JMP|JMP]]
| style="border-right:none;" | [[#CALL|CALL]]
| style="border-left:none;border-right:none;" | [[#RET|RET]]
| style="border-left:none;" | [[#RETF|RETF]]
| colspan="12" |
|-
| style="text-align:left;" | Loop
| style="" | [[#LOOP|LOOP]]
| style="" | [[#LOOPE|LOOPE]]
| style="" | [[#LOOPNE|LOOPNE]]
| colspan="13" |
|-
| style="text-align:left;" | Interrupt
| style="border-right:none;" | [[#INT|INT]]
| style="border-left:none;" | [[#IRET|IRET]]
| style="" | [[#INTO|INTO]]
| style="" | [[#HLT|HLT]]
| style="" | [[#BOUND|BOUND]]
| colspan="11" |
|-
| style="text-align:left;" | Stack
| style="border-right:none;" | [[#PUSH|PUSH]]
| style="border-left:none;" | [[#POP|POP]]
| style="border-right:none;" | [[#PUSHA|PUSHA]]
| style="border-left:none;" | [[#POPA|POPA]]
| style="border-right:none;" | [[#PUSHF|PUSHF]]
| style="border-left:none;" | [[#POPF|POPF]]
| colspan="10" |
|-
| style="text-align:left;" | Flags
| style="border-right:none;" | [[#CLC|CLC]]
| style="border-left:none;" | [[#STC|STC]]
| style="border-right:none;" | [[#CLD|CLD]]
| style="border-left:none;" | [[#STD|STD]]
| style="border-right:none;" | [[#CLI|CLI]]
| style="border-left:none;" | [[#STI|STI]]
| style="" | [[#CMC|CMC]]
| style="border-right:none;" | [[#LAHF|LAHF]]
| style="border-left:none;" | [[#SAHF|SAHF]]
| colspan="7" |
|-
| style="text-align:left;" | Prefix
| style="" | [[#CS|CS]]
| style="" | [[#DS|DS]]
| style="" | [[#ES|ES]]
| style="" | [[#SS|SS]]
| colspan="12" |
|-
| style="text-align:left;" | String
| style="border-right:none;" | [[#REP|REP]]
| style="border-left:none;border-right:none;" | [[#REP|REPE]]
| style="border-left:none;" | [[#REPNE|REPNE]]
| style="" | [[#MOVSB|MOVSB]]
| style="" | [[#MOVSW|MOVSW]]
| style="border-right:none;" | [[#LODSB|LODSB]]
| style="border-left:none;" | [[#STOSB|STOSB]]
| style="border-right:none;" | [[#LODSW|LODSW]]
| style="border-left:none;" | [[#STOSW|STOSW]]
| style="" | [[#CMPSB|CMPSB]]
| style="" | [[#SCASB|SCASB]]
| style="" | [[#CMPSW|CMPSW]]
| style="" | [[#SCASW|SCASW]]
| colspan="3" |
|-
| style="text-align:left;" | Other
| style="" | [[#NOP|NOP]]
| style="border-right:none;" | [[#ENTER|ENTER]]
| style="border-left:none;" | [[#LEAVE|LEAVE]]
| style="" | [[#LOCK|LOCK]]
| style="" | [[#POLL|POLL]]
| colspan="11" |
|}
== Instruction encoding ==
=== ModR/M byte ===
The ModR/M byte is used in most addressing modes which reference a memory location. This byte consists of three bitfield values:
* <tt>oo</tt> - M'''o'''de;
* <tt>rrr</tt> - Two possible functions:
** '''R'''egister (for addressing modes which require both a register and a register/memory operand),
** Opcode extension (for some opcodes' addressing modes which do not have such a requirement);
* <tt>mmm</tt> - Register/'''M'''emory.
The ''Mode'' and ''Register/Memory'' bitfields can refer to a memory location or to a register, as shown in the table below. In some addressing modes, the ''Register'' field also refers to a register; it is always interpreted as if ''Mode'' was equal to <tt>11</tt>.
{| class="wikitable" style="text-align: center"
! R/M \ Mode
! <tt>00</tt>
! <tt>01</tt>
! <tt>10</tt>
! <tt>11</tt> ''(byte)''
! <tt>11</tt> ''(word)''
|-
| <tt>000</tt>
| DS:[BX + SI]
| DS:[BX + SI + disp8]
| DS:[BX + SI + disp16]
| AL
| AX
|-
| <tt>001</tt>
| DS:[BX + DI]
| DS:[BX + DI + disp8]
| DS:[BX + DI + disp16]
| CL
| CX
|-
| <tt>010</tt>
| SS:[BP + SI]
| SS:[BP + SI + disp8]
| SS:[BP + SI + disp16]
| DL
| DX
|-
| <tt>011</tt>
| SS:[BP + DI]
| SS:[BP + DI + disp8]
| SS:[BP + DI + disp16]
| BL
| BX
|-
| <tt>100</tt>
| DS:[SI]
| DS:[SI + disp8]
| DS:[SI + disp16]
| AH
| SP
|-
| <tt>101</tt>
| DS:[DI]
| DS:[DI + disp8]
| DS:[DI + disp16]
| CH
| BP
|-
| <tt>110</tt>
| ''DS:[disp16]''
| SS:[BP + disp8]
| SS:[BP + disp16]
| DH
| SI
|-
| <tt>111</tt>
| DS:[BX]
| DS:[BX + disp8]
| DS:[BX + disp16]
| BH
| DI
|}
Displacements are either 8-bit (disp8) or 16-bit (disp16) signed values and they always immediately follow the ModR/M byte. Note that (<tt>oo</tt> = <tt>00</tt>, <tt>mmm</tt> = <tt>110</tt>) is a special case, in which the ''disp16'' value is used directly as a near pointer.
The instruction encoding lists below refer to this byte as <tt>oorrrmmm</tt> (binary), <tt>/r</tt> (hexadecimal) or <tt>/0</tt> (hexademical, <tt>rrr</tt> used as function <tt>0</tt>).
== Official instructions ==
{{Anchor|AAA}}
=== AAA ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| AAA || <tt>37</tt> || <tt>00110111</tt> || 1 || 9
|}
----
{{Anchor|AAD}}
=== AAD ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| AAD imm8 || <tt>B5 ii</tt> || <tt>11010100 iiiiiiii</tt> || 2 || 6
|}
----
{{Anchor|AAM}}
=== AAM ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| AAM imm8 || <tt>B4 ii</tt> || <tt>11010100 iiiiiiii</tt> || 2 || 17
|}
----
{{Anchor|AAS}}
=== AAS ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| AAS || <tt>3F</tt> || <tt>00111111</tt> || 1 || 9
|}
----
{{Anchor|ADC}}
=== ADC ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| ADC AL, imm || <tt>14 ii</tt> || <tt>00010100 iiiiiiii</tt> || 2 || 1
|-
| ADC AX, imm || <tt>15 ii ii</tt> || <tt>00010101 iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| ADC mem8, imm8 || <tt>80 /2 ii</tt> || <tt>10000000 oo010mmm iiiiiiii</tt> || 3+ || 3
|-
| ADC mem16, imm16 || <tt>81 /2 ii ii</tt> || <tt>10000001 oo010mmm iiiiiiii iiiiiiii</tt> || 4+ || 3
|-
| ADC mem16, simm8 || <tt>83 /2 ii</tt> || <tt>10000011 oo010mmm iiiiiiii</tt> || 3+ || 3
|-
| ADC mem8, reg8 || <tt>10 /r</tt> || <tt>00010000 oorrrmmm</tt> || 2+ || 3
|-
| ADC mem16, reg16 || <tt>11 /r</tt> || <tt>00010001 oorrrmmm</tt> || 2+ || 3
|-
| ADC reg8, imm8 || <tt>80 /2 ii</tt> || <tt>10000000 11010mmm iiiiiiii</tt> || 3 || 1
|-
| ADC reg16, imm16 || <tt>81 /2 ii ii</tt> || <tt>10000001 11010mmm iiiiiiii iiiiiiii</tt> || 4 || 1
|-
| ADC reg16, simm8 || <tt>83 /2 ii</tt> || <tt>10000011 11010mmm iiiiiiii</tt> || 3 || 1
|-
| ADC reg8, mem8 || <tt>12 /r</tt> || <tt>00010010 oorrrmmm</tt> || 2+ || 2
|-
| ADC reg16, mem16 || <tt>13 /r</tt> || <tt>00010011 oorrrmmm</tt> || 2+ || 2
|-
| ADC reg8, reg8 || <tt>10 /r</tt> || <tt>000100.0 11rrrmmm</tt> || 2 || 1
|-
| ADC reg16, reg16 || <tt>11 /r</tt> || <tt>000100.1 11rrrmmm</tt> || 2 || 1
|}
----
{{Anchor|ADD}}
=== ADD ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| ADD AL, imm || <tt>04 ii</tt> || <tt>00000100 iiiiiiii</tt> || 2 || 1
|-
| ADD AX, imm || <tt>05 ii ii</tt> || <tt>00000101 iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| ADD mem8, imm8 || <tt>80 /0 ii</tt> || <tt>10000000 oo000mmm iiiiiiii</tt> || 3+ || 3
|-
| ADD mem16, imm16 || <tt>81 /0 ii ii</tt> || <tt>10000001 oo000mmm iiiiiiii iiiiiiii</tt> || 4+ || 3
|-
| ADD mem16, simm8 || <tt>83 /0 ii</tt> || <tt>10000011 oo000mmm iiiiiiii</tt> || 3+ || 3
|-
| ADD mem8, reg8 || <tt>00 /r</tt> || <tt>00000000 oorrrmmm</tt> || 2+ || 3
|-
| ADD mem16, reg16 || <tt>01 /r</tt> || <tt>00000001 oorrrmmm</tt> || 2+ || 3
|-
| ADD reg8, imm8 || <tt>80 /0 ii</tt> || <tt>10000000 11000mmm iiiiiiii</tt> || 3 || 1
|-
| ADD reg16, imm16 || <tt>81 /0 ii ii</tt> || <tt>10000001 11000mmm iiiiiiii iiiiiiii</tt> || 4 || 1
|-
| ADD reg16, simm8 || <tt>83 /0 ii</tt> || <tt>10000011 11000mmm iiiiiiii</tt> || 3 || 1
|-
| ADD reg8, mem8 || <tt>02 /r</tt> || <tt>00000010 oorrrmmm</tt> || 2+ || 2
|-
| ADD reg16, mem16 || <tt>03 /r</tt> || <tt>00000011 oorrrmmm</tt> || 2+ || 2
|-
| ADD reg8, reg8 || <tt>00 /r</tt> || <tt>000000.0 11rrrmmm</tt> || 2 || 1
|-
| ADD reg16, reg16 || <tt>01 /r</tt> || <tt>000000.1 11rrrmmm</tt> || 2 || 1
|}
----
{{Anchor|AND}}
=== AND ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| AND AL, imm || <tt>24 ii</tt> || <tt>00100100 iiiiiiii</tt> || 2 || 1
|-
| AND AX, imm || <tt>25 ii ii</tt> || <tt>00100101 iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| AND mem8, imm8 || <tt>80 /4 ii</tt> || <tt>10000000 oo100mmm iiiiiiii</tt> || 3+ || 3
|-
| AND mem16, imm16 || <tt>81 /4 ii ii</tt> || <tt>10000001 oo100mmm iiiiiiii iiiiiiii</tt> || 4+ || 3
|-
| AND mem16, simm8 || <tt>83 /4 ii</tt> || <tt>10000011 oo100mmm iiiiiiii</tt> || 3+ || 3
|-
| AND mem8, reg8 || <tt>20 /r</tt> || <tt>00100000 oorrrmmm</tt> || 2+ || 3
|-
| AND mem16, reg16 || <tt>21 /r</tt> || <tt>00100001 oorrrmmm</tt> || 2+ || 3
|-
| AND reg8, imm8 || <tt>80 /4 ii</tt> || <tt>10000000 11100mmm iiiiiiii</tt> || 3 || 1
|-
| AND reg16, imm16 || <tt>81 /4 ii ii</tt> || <tt>10000001 11100mmm iiiiiiii iiiiiiii</tt> || 4 || 1
|-
| AND reg16, simm8 || <tt>83 /4 ii</tt> || <tt>10000011 11100mmm iiiiiiii</tt> || 3 || 1
|-
| AND reg8, mem8 || <tt>22 /r</tt> || <tt>00100010 oorrrmmm</tt> || 2+ || 2
|-
| AND reg16, mem16 || <tt>23 /r</tt> || <tt>00100011 oorrrmmm</tt> || 2+ || 2
|-
| AND reg8, reg8 || <tt>20 /r</tt> || <tt>001000.0 11rrrmmm</tt> || 2 || 1
|-
| AND reg16, reg16 || <tt>21 /r</tt> || <tt>001000.1 11rrrmmm</tt> || 2 || 1
|}
----
{{Anchor|BOUND}}
=== BOUND ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| BOUND reg16, mem16:16 || <tt>62 /r</tt> || <tt>01100010 oorrrmmm</tt> || 2+ || 13 (20 if condition met)
|}
----
{{Anchor|CALL}}
=== CALL ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| CALL ptr16:16 || <tt>CA oo oo ss ss</tt> || <tt>10011010 oooooooo oooooooo ssssssss ssssssss</tt> || 5 || 10
|-
| CALL mem16 || <tt>FF /2</tt> || <tt>11111111 oo010mmm</tt> || 2+ || 6
|-
| CALL mem16:16 || <tt>FF /3</tt> || <tt>11111111 oo011mmm</tt> || 2+ || 12
|-
| CALL reg16 || <tt>FF /2</tt> || <tt>11111111 11010mmm</tt> || 2 || 5
|-
| CALL rel16 || <tt>E8 ii ii</tt> || <tt>11101000 iiiiiiii iiiiiiii</tt> || 3 || 5
|}
----
{{Anchor|CBW}}
=== CBW ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| CBW || <tt>98</tt> || <tt>10011000</tt> || 1 || 1
|}
----
{{Anchor|CLC}}
=== CLC ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| CLC || <tt>F8</tt> || <tt>11111000</tt> || 1 || 4
|}
----
{{Anchor|CLD}}
=== CLD ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| CLD || <tt>FC</tt> || <tt>11111100</tt> || 1 || 4
|}
----
{{Anchor|CLI}}
=== CLI ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| CLI || <tt>FA</tt> || <tt>11111010</tt> || 1 || 4
|}
----
{{Anchor|CMC}}
=== CMC ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| CMC || <tt>F5</tt> || <tt>11110101</tt> || 1 || 4
|}
----
{{Anchor|CMP}}
=== CMP ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| CMP AL, imm || <tt>3C ii</tt> || <tt>00111100 iiiiiiii</tt> || 2 || 1
|-
| CMP AX, imm || <tt>3D ii ii</tt> || <tt>00111101 iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| CMP mem8, imm8 || <tt>80 /7 ii</tt> || <tt>10000000 oo111mmm iiiiiiii</tt> || 3+ || 2
|-
| CMP mem16, imm16 || <tt>81 /7 ii ii</tt> || <tt>10000001 oo111mmm iiiiiiii iiiiiiii</tt> || 4+ || 2
|-
| CMP mem16, simm8 || <tt>83 /7 ii</tt> || <tt>10000011 oo111mmm iiiiiiii</tt> || 3+ || 2
|-
| CMP mem8, reg8 || <tt>38 /r</tt> || <tt>00111000 oorrrmmm</tt> || 2+ || 2
|-
| CMP mem16, reg16 || <tt>39 /r</tt> || <tt>00111001 oorrrmmm</tt> || 2+ || 2
|-
| CMP reg8, imm8 || <tt>80 /7 ii</tt> || <tt>10000000 11111mmm iiiiiiii</tt> || 3 || 1
|-
| CMP reg16, imm16 || <tt>81 /7 ii ii</tt> || <tt>10000001 11111mmm iiiiiiii iiiiiiii</tt> || 4 || 1
|-
| CMP reg16, simm8 || <tt>83 /7 ii</tt> || <tt>10000011 11111mmm iiiiiiii</tt> || 3 || 1
|-
| CMP reg8, mem8 || <tt>3A /r</tt> || <tt>00111010 oorrrmmm</tt> || 2+ || 2
|-
| CMP reg16, mem16 || <tt>3B /r</tt> || <tt>00111011 oorrrmmm</tt> || 2+ || 2
|-
| CMP reg8, reg8 || <tt>38 /r</tt> || <tt>001110.0 11rrrmmm</tt> || 2 || 1
|-
| CMP reg16, reg16 || <tt>39 /r</tt> || <tt>001110.1 11rrrmmm</tt> || 2 || 1
|}
----
{{Anchor|CMPSB}}
{{Anchor|CMPSW}}
=== CMPSB/CMPSW ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| CMPSB || <tt>A6</tt> || <tt>10100110</tt> || 1 || 6
|-
| CMPSW || <tt>A7</tt> || <tt>10100111</tt> || 1 || 6
|}
----
{{Anchor|CS}}
=== CS ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| CS || <tt>2E</tt> || <tt>00101110</tt> || 1 || 1
|}
----
{{Anchor|CWD}}
=== CWD ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| CWD || <tt>99</tt> || <tt>10011001</tt> || 1 || 1
|}
----
{{Anchor|DAA}}
=== DAA ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| DAA || <tt>27</tt> || <tt>00100111</tt> || 1 || 10
|}
----
{{Anchor|DAS}}
=== DAS ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| DAS || <tt>2F</tt> || <tt>00101111</tt> || 1 || 10
|}
----
{{Anchor|DEC}}
=== DEC ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| DEC mem8 || <tt>FE /1</tt> || <tt>11111110 oo001mmm</tt> || 2+ || 3
|-
| DEC mem16 || <tt>FF /1</tt> || <tt>11111111 oo001mmm</tt> || 2+ || 3
|-
| DEC reg8 || <tt>FE /1</tt> || <tt>11111110 11001mmm</tt> || 2+ || 1
|-
| DEC reg16 || <tt>4x</tt> || <tt>01001rrr</tt> || 1 || 1
|}
----
{{Anchor|DIV}}
=== DIV ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| DIV mem8 || <tt>F6 /6</tt> || <tt>11110110 oo110mmm</tt> || 2+ || 16
|-
| DIV mem16 || <tt>F7 /6</tt> || <tt>11111111 oo110mmm</tt> || 2+ || 24
|-
| DIV reg8 || <tt>F6 /6</tt> || <tt>11111110 11110mmm</tt> || 2+ || 15
|-
| DIV reg16 || <tt>F7 /6</tt> || <tt>11111111 11110mmm</tt> || 2+ || 23
|}
----
{{Anchor|DS}}
=== DS ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| DS || <tt>3E</tt> || <tt>00111110</tt> || 1 || 1
|}
----
{{Anchor|ENTER}}
=== ENTER ===
----
{{Anchor|ES}}
=== ES ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| ES || <tt>26</tt> || <tt>00100110</tt> || 1 || 1
|}
----
{{Anchor|HLT}}
=== HLT ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| HLT || <tt>F4</tt> || <tt>11110100</tt> || 1 || 9
|}
----
{{Anchor|IDIV}}
=== IDIV ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| IDIV mem8 || <tt>F6 /7</tt> || <tt>11110110 oo111mmm</tt> || 2+ || 18
|-
| IDIV mem16 || <tt>F7 /7</tt> || <tt>11111111 oo111mmm</tt> || 2+ || 25
|-
| IDIV reg8 || <tt>F6 /7</tt> || <tt>11111110 11111mmm</tt> || 2+ || 17
|-
| IDIV reg16 || <tt>F7 /7</tt> || <tt>11111111 11111mmm</tt> || 2+ || 24
|}
----
{{Anchor|IMUL}}
=== IMUL ===
----
{{Anchor|IN}}
=== IN ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| IN AL, DX || <tt>EC</tt> || <tt>11101100</tt> || 1 || 6
|-
| IN AX, DX || <tt>ED</tt> || <tt>11101101</tt> || 1 || 6
|-
| IN AL, imm8 || <tt>E4 ii</tt> || <tt>11100100 iiiiiiii</tt> || 2 || 6
|-
| IN AX, imm8 || <tt>E5 ii</tt> || <tt>11100101 iiiiiiii</tt> || 2 || 6
|}
----
{{Anchor|INC}}
=== INC ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| INC mem8 || <tt>FE /0</tt> || <tt>11111110 oo000mmm</tt> || 2+ || 3
|-
| INC mem16 || <tt>FF /0</tt> || <tt>11111111 oo000mmm</tt> || 2+ || 3
|-
| INC reg8 || <tt>FE /0</tt> || <tt>11111110 11000mmm</tt> || 2+ || 1
|-
| INC reg16 || <tt>4x</tt> || <tt>01000rrr</tt> || 1 || 1
|}
----
{{Anchor|INSB}}
{{Anchor|INSW}}
=== INSB/INSW ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| INSB || <tt>6C</tt> || <tt>01101100</tt> || 1 || 6
|-
| INSW || <tt>6D</tt> || <tt>01101101</tt> || 1 || 6
|}
----
{{Anchor|INT}}
=== INT ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| INT 3 || <tt>CC</tt> || <tt>11001100</tt> || 1 || 9
|-
| INT imm8 || <tt>CD ii</tt> || <tt>11001101 iiiiiiii</tt> || 2 || 10
|}
----
{{Anchor|INTO}}
=== INTO ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| INTO || <tt>CE</tt> || <tt>11001110</tt> || 1 || 6 (13 if OF = 1)
|}
----
{{Anchor|IRET}}
=== IRET ===
----
{{Anchor|JA}}
=== JA ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JA rel8 || <tt>77 ii</tt> || <tt>01110111 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JBE}}
=== JBE ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JA rel8 || <tt>76 ii</tt> || <tt>01110110 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JC}}
=== JC/JB ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JC rel8 || <tt>72 ii</tt> || <tt>01110010 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JCXZ}}
=== JCXZ ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JCXZ rel8 || <tt>E3 ii</tt> || <tt>11100011 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JG}}
=== JG ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JG rel8 || <tt>7F ii</tt> || <tt>01111111 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JGE}}
=== JGE ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JGE rel8 || <tt>7D ii</tt> || <tt>01111101 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JL}}
=== JL ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JL rel8 || <tt>7C ii</tt> || <tt>01111100 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JLE}}
=== JLE ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JLE rel8 || <tt>7E ii</tt> || <tt>01111110 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JMP}}
=== JMP ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JMP ptr16:16 || <tt>EA oo oo ss ss</tt> || <tt>11101010 oooooooo oooooooo ssssssss ssssssss</tt> || 5 || 7
|-
| JMP mem16 || <tt>FF /4</tt> || <tt>11111111 oo100mmm</tt> || 2+ || 5
|-
| JMP mem16:16 || <tt>FF /5</tt> || <tt>11111111 oo101mmm</tt> || 2+ || 10
|-
| JMP reg16 || <tt>FF /4</tt> || <tt>11111111 11100mmm</tt> || 2 || 4
|-
| JMP rel8 || <tt>EB ii</tt> || <tt>11101011 iiiiiiii</tt> || 2 || 4
|-
| JMP rel16 || <tt>E9 ii ii</tt> || <tt>11101001 iiiiiiii iiiiiiii</tt> || 3 || 4
|}
----
{{Anchor|JNC}}
=== JNC/JAE ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JNC rel8 || <tt>73 ii</tt> || <tt>01110011 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JNO}}
=== JNO ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JNO rel8 || <tt>71 ii</tt> || <tt>01110001 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JNP}}
=== JNP ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JNP rel8 || <tt>7B ii</tt> || <tt>01111011 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JNS}}
=== JNS ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JNS rel8 || <tt>79 ii</tt> || <tt>01111001 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JNZ}}
=== JNZ/JNE ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JNZ rel8 || <tt>75 ii</tt> || <tt>01110101 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JO}}
=== JO ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JO rel8 || <tt>70 ii</tt> || <tt>01110000 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JP}}
=== JP ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JP rel8 || <tt>7A ii</tt> || <tt>01111010 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JS}}
=== JS ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JS rel8 || <tt>78 ii</tt> || <tt>01111000 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JZ}}
=== JZ/JE ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JZ rel8 || <tt>74 ii</tt> || <tt>01110100 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|LAHF}}
=== LAHF ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| LAHF || <tt>9F</tt> || <tt>10011111</tt> || 1 || 2
|}
----
{{Anchor|LDS}}
=== LDS ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| LDS reg16, mem16 || <tt>C5 /r</tt> || <tt>11000101 oorrrmmm</tt> || 2+ || 6
|}
----
{{Anchor|LEA}}
=== LEA ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| LEA reg16, mem16 || <tt>8D /r</tt> || <tt>10001101 oorrrmmm</tt> || 2+ || 1
|}
----
{{Anchor|LEAVE}}
=== LEAVE ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| LEAVE || <tt>C9</tt> || <tt>11001001</tt> || 1 || 2
|}
----
{{Anchor|LES}}
=== LES ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| LES reg16, mem16 || <tt>C4 /r</tt> || <tt>11000100 oorrrmmm</tt> || 2+ || 6
|}
----
{{Anchor|LOCK}}
=== LOCK ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| LOCK || <tt>F0</tt> || <tt>11110000</tt> || 1 || 1
|}
----
{{Anchor|LODSB}}
{{Anchor|LODSW}}
=== LODSB/LODSW ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| LODSB || <tt>AC</tt> || <tt>10101100</tt> || 1 || 3
|-
| LODSW || <tt>AD</tt> || <tt>10101101</tt> || 1 || 3
|}
----
{{Anchor|LOOP}}
=== LOOP ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| LOOP rel8 || <tt>E2 ii</tt> || <tt>11100010 iiiiiiii</tt> || 2 || 2 (5 if branch taken)
|}
----
{{Anchor|LOOPE}}
=== LOOPE ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| LOOPE rel8 || <tt>E1 ii</tt> || <tt>11100001 iiiiiiii</tt> || 2 || 3 (6 if branch taken)
|}
----
{{Anchor|LOOPNE}}
=== LOOPNE ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| LOOPNE rel8 || <tt>E0 ii</tt> || <tt>11100000 iiiiiiii</tt> || 2 || 3 (6 if branch taken)
|}
----
{{Anchor|MOV}}
=== MOV ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| MOV AL, ptr16 || <tt>A0 ii ii</tt> || <tt>10100000 iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| MOV AX, ptr16 || <tt>A1 ii ii</tt> || <tt>10100001 iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| MOV mem8, imm8 || <tt>C6 /0 ii</tt> || <tt>11000110 oo000mmm iiiiiiii</tt> || 3+ || 1
|-
| MOV mem16, imm16 || <tt>C7 /0 ii ii</tt> || <tt>11000111 oo000mmm iiiiiiii iiiiiiii</tt> || 4+ || 1
|-
| MOV mem8, reg8 || <tt>84 /r</tt> || <tt>10001000 oorrrmmm</tt> || 2+ || 1
|-
| MOV mem16, reg16 || <tt>85 /r</tt> || <tt>10001001 oorrrmmm</tt> || 2+ || 1
|-
| MOV mem16, sreg16 || <tt>8C /r</tt> || <tt>10001100 oo0rrmmm</tt> || 2+ || 3
|-
| MOV ptr16, AL || <tt>A2 ii ii</tt> || <tt>10100010 iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| MOV ptr16, AX || <tt>A3 ii ii</tt> || <tt>10100011 iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| MOV reg8, imm8 || <tt>Bx ii</tt> || <tt>10110rrr iiiiiiii</tt> || 2 || 1
|-
| MOV reg8, imm8 || <tt>C6 /0 ii</tt> || <tt>11000110 11000mmm iiiiiiii</tt> || 3 || 1
|-
| MOV reg16, imm16 || <tt>Bx ii</tt> || <tt>10111rrr iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| MOV reg16, imm16 || <tt>C7 /0 ii ii</tt> || <tt>11000111 11000mmm iiiiiiii iiiiiiii</tt> || 4 || 1
|-
| MOV reg8, mem8 || <tt>8A /r</tt> || <tt>10001010 oorrrmmm</tt> || 2+ || 1
|-
| MOV reg16, mem16 || <tt>8B /r</tt> || <tt>10001011 oorrrmmm</tt> || 2+ || 1
|-
| MOV reg8, reg8 || <tt>88 /r</tt> || <tt>100010.0 11rrrmmm</tt> || 2 || 1
|-
| MOV reg16, reg16 || <tt>89 /r</tt> || <tt>100010.1 11rrrmmm</tt> || 2 || 1
|-
| MOV reg16, sreg16 || <tt>8C /r</tt> || <tt>10001100 110rrmmm</tt> || 2+ || 1
|-
| MOV sreg16, mem16 || <tt>8E /r</tt> || <tt>10001110 oo0rrmmm</tt> || 2+ || 3
|-
| MOV sreg16, reg16 || <tt>8E /r</tt> || <tt>10001110 110rrmmm</tt> || 2+ || 2
|}
----
{{Anchor|MOVSB}}
{{Anchor|MOVSW}}
=== MOVSB/MOVSW ===
----
{{Anchor|MUL}}
=== MUL ===
----
{{Anchor|NEG}}
=== NEG ===
----
{{Anchor|NOP}}
=== NOP ===
----
{{Anchor|NOT}}
=== NOT ===
----
{{Anchor|OR}}
=== OR ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| OR AL, imm || <tt>0C ii</tt> || <tt>00001100 iiiiiiii</tt> || 2 || 1
|-
| OR AX, imm || <tt>0D ii ii</tt> || <tt>00001101 iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| OR mem8, imm8 || <tt>80 /6 ii</tt> || <tt>10000000 oo001mmm iiiiiiii</tt> || 3+ || 3
|-
| OR mem16, imm16 || <tt>81 /6 ii ii</tt> || <tt>10000001 oo001mmm iiiiiiii iiiiiiii</tt> || 4+ || 3
|-
| OR mem16, simm8 || <tt>83 /6 ii</tt> || <tt>10000011 oo001mmm iiiiiiii</tt> || 3+ || 3
|-
| OR mem8, reg8 || <tt>08 /r</tt> || <tt>00001000 oorrrmmm</tt> || 2+ || 3
|-
| OR mem16, reg16 || <tt>09 /r</tt> || <tt>00001001 oorrrmmm</tt> || 2+ || 3
|-
| OR reg8, imm8 || <tt>80 /6 ii</tt> || <tt>10000000 11001mmm iiiiiiii</tt> || 3 || 1
|-
| OR reg16, imm16 || <tt>81 /6 ii ii</tt> || <tt>10000001 11001mmm iiiiiiii iiiiiiii</tt> || 4 || 1
|-
| OR reg16, simm8 || <tt>83 /6 ii</tt> || <tt>10000011 11001mmm iiiiiiii</tt> || 3 || 1
|-
| OR reg8, mem8 || <tt>0A /r</tt> || <tt>00001010 oorrrmmm</tt> || 2+ || 2
|-
| OR reg16, mem16 || <tt>0B /r</tt> || <tt>00001011 oorrrmmm</tt> || 2+ || 2
|-
| OR reg8, reg8 || <tt>08 /r</tt> || <tt>000010.0 11rrrmmm</tt> || 2 || 1
|-
| OR reg16, reg16 || <tt>09 /r</tt> || <tt>000010.1 11rrrmmm</tt> || 2 || 1
|}
----
{{Anchor|OUT}}
=== OUT ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| OUT AL, DX || <tt>EE</tt> || <tt>11101110</tt> || 1 || 6
|-
| OUT AX, DX || <tt>EF</tt> || <tt>11101111</tt> || 1 || 6
|-
| OUT AL, imm8 || <tt>E6 ii</tt> || <tt>11100110 iiiiiiii</tt> || 2 || 6
|-
| OUT AX, imm8 || <tt>E7 ii</tt> || <tt>11100111 iiiiiiii</tt> || 2 || 6
|}
----
{{Anchor|OUTSB}}
{{Anchor|OUTSW}}
=== OUTSB/OUTSW ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| OUTSB || <tt>6E</tt> || <tt>01101110</tt> || 1 || 6
|-
| OUTSW || <tt>6F</tt> || <tt>01101111</tt> || 1 || 6
|}
----
{{Anchor|POLL}}
=== POLL ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| POLL || <tt>6E</tt> || <tt>01101110</tt> || 1 || 9<ref>On the WonderSwan implementation, POLLB is always held low; on other implementations, POLL will wait for POLLB to be held low in 9-cycle intervals.</ref>
|}
----
{{Anchor|POP}}
=== POP ===
----
{{Anchor|POPA}}
=== POPA ===
----
{{Anchor|POPF}}
=== POPF ===
----
{{Anchor|PUSH}}
=== PUSH ===
----
{{Anchor|PUSHA}}
=== PUSHA ===
----
{{Anchor|PUSHF}}
=== PUSHF ===
----
{{Anchor|RCL}}
=== RCL ===
----
{{Anchor|RCR}}
=== RCR ===
----
{{Anchor|REP}}
=== REP/REPE/REPZ ===
----
{{Anchor|REPNE}}
=== REPNE/REPNZ ===
----
{{Anchor|RET}}
=== RET ===
----
{{Anchor|RETF}}
=== RETF ===
----
{{Anchor|ROL}}
=== ROL ===
----
{{Anchor|ROR}}
=== ROR ===
----
{{Anchor|SAHF}}
=== SAHF ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| SAHF || <tt>9E</tt> || <tt>10011110</tt> || 1 || 4
|}
----
{{Anchor|SAR}}
=== SAR ===
----
{{Anchor|SBB}}
=== SBB ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| SBB AL, imm || <tt>1C ii</tt> || <tt>00011100 iiiiiiii</tt> || 2 || 1
|-
| SBB AX, imm || <tt>1D ii ii</tt> || <tt>00011101 iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| SBB mem8, imm8 || <tt>80 /3 ii</tt> || <tt>10000000 oo011mmm iiiiiiii</tt> || 3+ || 3
|-
| SBB mem16, imm16 || <tt>81 /3 ii ii</tt> || <tt>10000001 oo011mmm iiiiiiii iiiiiiii</tt> || 4+ || 3
|-
| SBB mem16, simm8 || <tt>83 /3 ii</tt> || <tt>10000011 oo011mmm iiiiiiii</tt> || 3+ || 3
|-
| SBB mem8, reg8 || <tt>18 /r</tt> || <tt>00011000 oorrrmmm</tt> || 2+ || 3
|-
| SBB mem16, reg16 || <tt>19 /r</tt> || <tt>00011001 oorrrmmm</tt> || 2+ || 3
|-
| SBB reg8, imm8 || <tt>80 /3 ii</tt> || <tt>10000000 11011mmm iiiiiiii</tt> || 3 || 1
|-
| SBB reg16, imm16 || <tt>81 /3 ii ii</tt> || <tt>10000001 11011mmm iiiiiiii iiiiiiii</tt> || 4 || 1
|-
| SBB reg16, simm8 || <tt>83 /3 ii</tt> || <tt>10000011 11011mmm iiiiiiii</tt> || 3 || 1
|-
| SBB reg8, mem8 || <tt>1A /r</tt> || <tt>00011010 oorrrmmm</tt> || 2+ || 2
|-
| SBB reg16, mem16 || <tt>1B /r</tt> || <tt>00011011 oorrrmmm</tt> || 2+ || 2
|-
| SBB reg8, reg8 || <tt>18 /r</tt> || <tt>000110.0 11rrrmmm</tt> || 2 || 1
|-
| SBB reg16, reg16 || <tt>19 /r</tt> || <tt>000110.1 11rrrmmm</tt> || 2 || 1
|}
----
{{Anchor|SCASB}}
{{Anchor|SCASW}}
=== SCASB/SCASW ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| SCASB || <tt>AE</tt> || <tt>10101110</tt> || 1 || 4
|-
| SCASW || <tt>AF</tt> || <tt>10101111</tt> || 1 || 4
|}
----
{{Anchor|SHL}}
=== SHL ===
----
{{Anchor|SHR}}
=== SHR ===
----
{{Anchor|SS}}
=== SS ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| SS || <tt>36</tt> || <tt>00110110</tt> || 1 || 1
|}
----
{{Anchor|STC}}
=== STC ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| STC || <tt>F9</tt> || <tt>11111001</tt> || 1 || 4
|}
----
{{Anchor|STD}}
=== STD ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| STD || <tt>FD</tt> || <tt>11111101</tt> || 1 || 4
|}
----
{{Anchor|STI}}
=== STI ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| STI || <tt>FB</tt> || <tt>11111011</tt> || 1 || 4
|}
----
{{Anchor|STOSB}}
{{Anchor|STOSW}}
=== STOSB/STOSW ===
----
{{Anchor|SUB}}
=== SUB ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| SUB AL, imm || <tt>28 ii</tt> || <tt>00101100 iiiiiiii</tt> || 2 || 1
|-
| SUB AX, imm || <tt>29 ii ii</tt> || <tt>00101101 iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| SUB mem8, imm8 || <tt>80 /5 ii</tt> || <tt>10000000 oo101mmm iiiiiiii</tt> || 3+ || 3
|-
| SUB mem16, imm16 || <tt>81 /5 ii ii</tt> || <tt>10000001 oo101mmm iiiiiiii iiiiiiii</tt> || 4+ || 3
|-
| SUB mem16, simm8 || <tt>83 /5 ii</tt> || <tt>10000011 oo101mmm iiiiiiii</tt> || 3+ || 3
|-
| SUB mem8, reg8 || <tt>28 /r</tt> || <tt>00101000 oorrrmmm</tt> || 2+ || 3
|-
| SUB mem16, reg16 || <tt>29 /r</tt> || <tt>00101001 oorrrmmm</tt> || 2+ || 3
|-
| SUB reg8, imm8 || <tt>80 /5 ii</tt> || <tt>10000000 11101mmm iiiiiiii</tt> || 3 || 1
|-
| SUB reg16, imm16 || <tt>81 /5 ii ii</tt> || <tt>10000001 11101mmm iiiiiiii iiiiiiii</tt> || 4 || 1
|-
| SUB reg16, simm8 || <tt>83 /5 ii</tt> || <tt>10000011 11101mmm iiiiiiii</tt> || 3 || 1
|-
| SUB reg8, mem8 || <tt>2A /r</tt> || <tt>00101010 oorrrmmm</tt> || 2+ || 2
|-
| SUB reg16, mem16 || <tt>2B /r</tt> || <tt>00101011 oorrrmmm</tt> || 2+ || 2
|-
| SUB reg8, reg8 || <tt>28 /r</tt> || <tt>001010.0 11rrrmmm</tt> || 2 || 1
|-
| SUB reg16, reg16 || <tt>29 /r</tt> || <tt>001010.1 11rrrmmm</tt> || 2 || 1
|}
----
{{Anchor|TEST}}
=== TEST ===
----
{{Anchor|XCHG}}
=== XCHG ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| XCHG AX, reg16<br/>XCHG reg16, AX || <tt>9x</tt> || <tt>10010rrr</tt> || 1 || 3
|-
| XCHG mem8, reg8<br/>XCHG reg8, mem8 || <tt>86 /r</tt> || <tt>10000110 oorrrmmm</tt> || 2+ || 5
|-
| XCHG mem16, reg16<br/>XCHG reg16, mem16 || <tt>87 /r</tt> || <tt>10000111 oorrrmmm</tt> || 2+ || 5
|-
| XCHG reg8, reg8 || <tt>86 /r</tt> || <tt>10000110 11rrrmmm</tt> || 2+ || 3
|-
| XCHG reg16, reg16 || <tt>87 /r</tt> || <tt>10000111 11rrrmmm</tt> || 2+ || 3
|}
----
{{Anchor|XLAT}}
=== XLAT ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| XLAT || <tt>D7</tt> || <tt>11010111</tt> || 1 || 5
|}
----
{{Anchor|XOR}}
=== XOR ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| XOR AL, imm || <tt>34 ii</tt> || <tt>00110100 iiiiiiii</tt> || 2 || 1
|-
| XOR AX, imm || <tt>35 ii ii</tt> || <tt>00110101 iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| XOR mem8, imm8 || <tt>80 /6 ii</tt> || <tt>10000000 oo110mmm iiiiiiii</tt> || 3+ || 3
|-
| XOR mem16, imm16 || <tt>81 /6 ii ii</tt> || <tt>10000001 oo110mmm iiiiiiii iiiiiiii</tt> || 4+ || 3
|-
| XOR mem16, simm8 || <tt>83 /6 ii</tt> || <tt>10000011 oo110mmm iiiiiiii</tt> || 3+ || 3
|-
| XOR mem8, reg8 || <tt>30 /r</tt> || <tt>00110000 oorrrmmm</tt> || 2+ || 3
|-
| XOR mem16, reg16 || <tt>31 /r</tt> || <tt>00110001 oorrrmmm</tt> || 2+ || 3
|-
| XOR reg8, imm8 || <tt>80 /6 ii</tt> || <tt>10000000 11110mmm iiiiiiii</tt> || 3 || 1
|-
| XOR reg16, imm16 || <tt>81 /6 ii ii</tt> || <tt>10000001 11110mmm iiiiiiii iiiiiiii</tt> || 4 || 1
|-
| XOR reg16, simm8 || <tt>83 /6 ii</tt> || <tt>10000011 11110mmm iiiiiiii</tt> || 3 || 1
|-
| XOR reg8, mem8 || <tt>32 /r</tt> || <tt>00110010 oorrrmmm</tt> || 2+ || 2
|-
| XOR reg16, mem16 || <tt>33 /r</tt> || <tt>00110011 oorrrmmm</tt> || 2+ || 2
|-
| XOR reg8, reg8 || <tt>30 /r</tt> || <tt>001100.0 11rrrmmm</tt> || 2 || 1
|-
| XOR reg16, reg16 || <tt>31 /r</tt> || <tt>001100.1 11rrrmmm</tt> || 2 || 1
|}
----
== Notes ==
<references />
e49970d2ec9476f48b0e8cc43beb5062e7009131
458
457
2024-12-27T22:24:43Z
Asie
351
/* MOV */
wikitext
text/x-wiki
__NOTOC__
Note that this page is a work in progress.
{| class="wikitable" style="text-align: center"
|+ Official V30MZ (80186) Instructions
|-
| [[#AAA|AAA]] || [[#AAD|AAD]] || [[#AAM|AAM]] || [[#AAS|AAS]] || [[#ADC|ADC]] || [[#ADD|ADD]] || [[#AND|AND]] || [[#BOUND|BOUND]] || [[#CALL|CALL]] || [[#CBW|CBW]] || [[#CLC|CLC]]
|-
| [[#CLD|CLD]] || [[#CLI|CLI]] || [[#CMC|CMC]] || [[#CMP|CMP]] || [[#CMPSB|CMPSB]] || [[#CMPSW|CMPSW]] || [[#CS|CS]] || [[#CWD|CWD]] || [[#DAA|DAA]] || [[#DAS|DAS]] || [[#DEC|DEC]]
|-
| [[#DIV|DIV]] || [[#DS|DS]] || [[#ENTER|ENTER]] || [[#ES|ES]] || [[#HLT|HLT]] || [[#IDIV|IDIV]] || [[#IMUL|IMUL]] || [[#IN|IN]] || [[#INC|INC]] || [[#INSB|INSB]] || [[#INSW|INSW]]
|-
| [[#INT|INT]] || [[#INTO|INTO]] || [[#IRET|IRET]] || [[#JA|JA]] || [[#JBE|JBE]] || [[#JC|JC]] || [[#JCXZ|JCXZ]] || [[#JG|JG]] || [[#JGE|JGE]] || [[#JL|JL]] || [[#JLE|JLE]]
|-
| [[#JMP|JMP]] || [[#JNC|JNC]] || [[#JNO|JNO]] || [[#JNP|JNP]] || [[#JNS|JNS]] || [[#JNZ|JNZ]] || [[#JO|JO]] || [[#JP|JP]] || [[#JS|JS]] || [[#JZ|JZ]] || [[#LAHF|LAHF]]
|-
| [[#LDS|LDS]] || [[#LEA|LEA]] || [[#LEAVE|LEAVE]] || [[#LES|LES]] || [[#LOCK|LOCK]] || [[#LODSB|LODSB]] || [[#LODSW|LODSW]] || [[#LOOP|LOOP]] || [[#LOOPE|LOOPE]] || [[#LOOPNE|LOOPNE]] || [[#MOV|MOV]]
|-
| [[#MOVSB|MOVSB]] || [[#MOVSW|MOVSW]] || [[#MUL|MUL]] || [[#NEG|NEG]] || [[#NOP|NOP]] || [[#NOT|NOT]] || [[#OR|OR]] || [[#OUT|OUT]] || [[#OUTSB|OUTSB]] || [[#OUTSW|OUTSW]] || [[#POLL|POLL]]
|-
| [[#POP|POP]] || [[#POPA|POPA]] || [[#POPF|POPF]] || [[#PUSH|PUSH]] || [[#PUSHA|PUSHA]] || [[#PUSHF|PUSHF]] || [[#RCL|RCL]] || [[#RCR|RCR]] || [[#REP|REP]] || [[#REPNE|REPNE]] || [[#RET|RET]]
|-
| [[#RETF|RETF]] || [[#ROL|ROL]] || [[#ROR|ROR]] || [[#SAHF|SAHF]] || [[#SAR|SAR]] || [[#SBB|SBB]] || [[#SCASB|SCASB]] || [[#SCASW|SCASW]] || [[#SHL|SHL]] || [[#SHR|SHR]] || [[#SS|SS]]
|-
| [[#STC|STC]] || [[#STD|STD]] || [[#STI|STI]] || [[#STOSB|STOSB]] || [[#STOSW|STOSW]] || [[#SUB|SUB]] || [[#TEST|TEST]] || [[#XCHG|XCHG]] || [[#XLAT|XLAT]] || [[#XOR|XOR]]
|}
{| class="mw-collapsible mw-collapsed wikitable sortable" style="width: 340px;"
|+ style="white-space:nowrap; border:1px solid; padding:3px; border-color:rgb(162, 169, 177); background-color:rgb(234, 236, 240);" | Intel <-> NEC mnemonic translation table
!Intel
!NEC
|-
| [[#AAA|AAA]]
| [[#AAA|ADJBA]]
|-
| [[#AAD|AAD]]
| [[#AAD|CVTDB]]
|-
| [[#AAM|AAM]]
| [[#AAM|CVTBD]]
|-
| [[#AAS|AAS]]
| [[#AAS|ADJBS]]
|-
| [[#ADC|ADC]]
| [[#ADC|ADDC]]
|-
| [[#ADD|ADD]]
| [[#ADD|ADD]]
|-
| [[#AND|AND]]
| [[#AND|AND]]
|-
| [[#BOUND|BOUND]]
| [[#BOUND|CHKIND]]
|-
| [[#CALL|CALL]]
| [[#CALL|CALL]]
|-
| [[#CBW|CBW]]
| [[#CBW|CVTBW]]
|-
| [[#CLC|CLC]]
| [[#CLC|CLR1 CY]]
|-
| [[#CLD|CLD]]
| [[#CLD|CLR1 DIR]]
|-
| [[#CLI|CLI]]
| [[#CLI|DI]]
|-
| [[#CMC|CMC]]
| [[#CMC|NOT1 CY]]
|-
| [[#CMP|CMP]]
| [[#CMP|CMP]]
|-
| [[#CMPSB|CMPSB]]
| [[#CMPSB|CMPBKB]]
|-
| [[#CMPSW|CMPSW]]
| [[#CMPSW|CMPBKW]]
|-
| [[#CS|CS]]
| [[#CS|PS]]
|-
| [[#CWD|CWD]]
| [[#CWD|CVTWL]]
|-
| [[#DAA|DAA]]
| [[#DAA|ADJ4A]]
|-
| [[#DAS|DAS]]
| [[#DAS|ADJ4S]]
|-
| [[#DEC|DEC]]
| [[#DEC|DEC]]
|-
| [[#DIV|DIV]]
| [[#DIV|DIVU]]
|-
| [[#DS|DS]]
| [[#DS|DS0]]
|-
| [[#ENTER|ENTER]]
| [[#ENTER|PREPARE]]
|-
| [[#ES|ES]]
| [[#ES|DS1]]
|-
| [[#HLT|HLT]]
| [[#HLT|HALT]]
|-
| [[#IDIV|IDIV]]
| [[#IDIV|DIV]]
|-
| [[#IMUL|IMUL]]
| [[#IMUL|MUL]]
|-
| [[#IN|IN]]
| [[#IN|IN]]
|-
| [[#INC|INC]]
| [[#INC|INC]]
|-
| [[#INSB|INSB]]
| [[#INSB|INMB]]
|-
| [[#INSW|INSW]]
| [[#INSW|INMW]]
|-
| [[#INT|INT]]
| [[#INT|BRK]]
|-
| [[#INTO|INTO]]
| [[#INTO|BRKV]]
|-
| [[#IRET|IRET]]
| [[#IRET|RETI]]
|-
| [[#JA|JA]]
| [[#JA|BH]]
|-
| [[#JBE|JBE]]
| [[#JBE|BNH]]
|-
| [[#JC|JC/JB]]
| [[#JC|BC/BL]]
|-
| [[#JCXZ|JCXZ]]
| [[#JCXZ|BCWZ]]
|-
| [[#JG|JG]]
| [[#JG|BGT]]
|-
| [[#JGE|JGE]]
| [[#JGE|BGE]]
|-
| [[#JL|JL]]
| [[#JL|BLT]]
|-
| [[#JLE|JLE]]
| [[#JLE|BLE]]
|-
| [[#JMP|JMP]]
| [[#JMP|BR]]
|-
| [[#JNC|JNC/JAE]]
| [[#JNC|BNC/BNL]]
|-
| [[#JNO|JNO]]
| [[#JNO|BNV]]
|-
| [[#JNP|JNP]]
| [[#JNP|BPO]]
|-
| [[#JNS|JNS]]
| [[#JNS|BP]]
|-
| [[#JNZ|JNZ/JNE]]
| [[#JNZ|BNZ/BNE]]
|-
| [[#JO|JO]]
| [[#JO|BV]]
|-
| [[#JP|JP]]
| [[#JP|BPE]]
|-
| [[#JS|JS]]
| [[#JS|BN]]
|-
| [[#JZ|JZ/JE]]
| [[#JZ|BZ/BE]]
|-
| [[#LAHF|LAHF]]
| [[#LAHF|MOV]]
|-
| [[#LDS|LDS]]
| [[#LDS|MOV]]
|-
| [[#LEA|LEA]]
| [[#LEA|LDEA]]
|-
| [[#LEAVE|LEAVE]]
| [[#LEAVE|DISPOSE]]
|-
| [[#LES|LES]]
| [[#LES|MOV]]
|-
| [[#LOCK|LOCK]]
| [[#LOCK|BUSLOCK]]
|-
| [[#LODSB|LODSB]]
| [[#LODSB|LDMB]]
|-
| [[#LODSW|LODSW]]
| [[#LODSW|LDMW]]
|-
| [[#LOOP|LOOP]]
| [[#LOOP|DBNZ]]
|-
| [[#LOOPE|LOOPE]]
| [[#LOOPE|DBNZE]]
|-
| [[#LOOPNE|LOOPNE]]
| [[#LOOPNE|DBNZNE]]
|-
| [[#MOV|MOV]]
| [[#MOV|MOV]]
|-
| [[#MOVSB|MOVSB]]
| [[#MOVSB|MOVBKB]]
|-
| [[#MOVSW|MOVSW]]
| [[#MOVSW|MOVBKW]]
|-
| [[#MUL|MUL]]
| [[#MUL|MULU]]
|-
| [[#NEG|NEG]]
| [[#NEG|NEG]]
|-
| [[#NOP|NOP]]
| [[#NOP|NOP]]
|-
| [[#NOT|NOT]]
| [[#NOT|NOT]]
|-
| [[#OR|OR]]
| [[#OR|OR]]
|-
| [[#OUT|OUT]]
| [[#OUT|OUT]]
|-
| [[#OUTSB|OUTSB]]
| [[#OUTSB|OUTM]]
|-
| [[#OUTSW|OUTSW]]
| [[#OUTSW|OUTM]]
|-
| [[#POLL|POLL]]
| [[#POLL|POLL]]
|-
| [[#POP|POP]]
| [[#POP|POP]]
|-
| [[#POPA|POPA]]
| [[#POPA|POP]]
|-
| [[#POPF|POPF]]
| [[#POPF|POP]]
|-
| [[#PUSH|PUSH]]
| [[#PUSH|PUSH]]
|-
| [[#PUSHA|PUSHA]]
| [[#PUSHA|PUSH]]
|-
| [[#PUSHF|PUSHF]]
| [[#PUSHF|PUSH]]
|-
| [[#RCL|RCL]]
| [[#RCL|ROLC]]
|-
| [[#RCR|RCR]]
| [[#RCR|RORC]]
|-
| [[#REP|REP/REPE/REPZ]]
| [[#REP|REP/REPE/REPZ]]
|-
| [[#REPNE|REPNE/REPNZ]]
| [[#REPNE|REPNE/REPNZ]]
|-
| [[#RET|RET]]
| [[#RET|RET]]
|-
| [[#RETF|RETF]]
| [[#RETF|RET]]
|-
| [[#ROL|ROL]]
| [[#ROL|ROL]]
|-
| [[#ROR|ROR]]
| [[#ROR|ROR]]
|-
| [[#SAHF|SAHF]]
| [[#SAHF|MOV]]
|-
| [[#SAR|SAR]]
| [[#SAR|SHRA]]
|-
| [[#SBB|SBB]]
| [[#SBB|SUBC]]
|-
| [[#SCASB|SCASB]]
| [[#SCASB|CMPMB]]
|-
| [[#SCASW|SCASW]]
| [[#SCASW|CMPMW]]
|-
| [[#SHL|SHL]]
| [[#SHL|SHL]]
|-
| [[#SHR|SHR]]
| [[#SHR|SHR]]
|-
| [[#SS|SS]]
| [[#SS|SS]]
|-
| [[#STC|STC]]
| [[#STC|SET1 CY]]
|-
| [[#STD|STD]]
| [[#STD|SET1 DIR]]
|-
| [[#STI|STI]]
| [[#STI|EI]]
|-
| [[#STOSB|STOSB]]
| [[#STOSB|STMB]]
|-
| [[#STOSW|STOSW]]
| [[#STOSW|STMW]]
|-
| [[#SUB|SUB]]
| [[#SUB|SUB]]
|-
| [[#TEST|TEST]]
| [[#TEST|TEST]]
|-
| [[#XCHG|XCHG]]
| [[#XCHG|XCH]]
|-
| [[#XLAT|XLAT]]
| [[#XLAT|TRANS]]
|-
| [[#XOR|XOR]]
| [[#XOR|XOR]]
|}
== Official instructions by type ==
{| class="wikitable sortable" style="text-align: center"
!Type
!colspan=16 class="unsortable" | Instructions
|-
| style="text-align:left;" | Memory
| style="" | [[#MOV|MOV]]
| style="" | [[#XCHG|XCHG]]
| style="" | [[#XLAT|XLAT]]
| style="" | [[#LEA|LEA]]
| style="border-right:none;" | [[#LDS|LDS]]
| style="border-left:none;" | [[#LES|LES]]
| style="border-right:none;" | [[#IN|IN]]
| style="border-left:none;" | [[#OUT|OUT]]
| colspan="8" |
|-
| style="text-align:left;" | Ports
| style="border-right:none;" | [[#IN|IN]]
| style="border-left:none;" | [[#OUT|OUT]]
| style="border-right:none;" | [[#INSB|INSB]]
| style="border-left:none;" | [[#OUTSB|OUTSB]]
| style="border-right:none;" | [[#INSW|INSW]]
| style="border-left:none;" | [[#OUTSW|OUTSW]]
| colspan="10" |
|-
| style="text-align:left;" | Arithmetic
| style="border-right:none;" | [[#ADD|ADD]]
| style="border-left:none;" | [[#SUB|SUB]]
| style="border-right:none;" | [[#ADC|ADC]]
| style="border-left:none;" | [[#SBB|SBB]]
| style="border-right:none;" | [[#INC|INC]]
| style="border-left:none;" | [[#DEC|DEC]]
| style="border-right:none;" | [[#MUL|MUL]]
| style="border-left:none;" | [[#DIV|DIV]]
| style="border-right:none;" | [[#IMUL|IMUL]]
| style="border-left:none;" | [[#IDIV|IDIV]]
| style="" | [[#CMP|CMP]]
| style="" | [[#NEG|NEG]]
| colspan="4" |
|-
| style="text-align:left;" | Numeric
| style="" | [[#CBW|CBW]]
| style="" | [[#CWD|CWD]]
| style="" | [[#AAA|AAA]]
| style="" | [[#AAS|AAS]]
| style="" | [[#AAM|AAM]]
| style="" | [[#AAD|AAD]]
| style="" | [[#DAA|DAA]]
| style="" | [[#DAS|DAS]]
| colspan="8" |
|-
| style="text-align:left;" | Shift
| style="border-right:none;" | [[#ROL|ROL]]
| style="border-left:none;" | [[#ROR|ROR]]
| style="border-right:none;" | [[#RCL|RCL]]
| style="border-left:none;" | [[#RCR|RCR]]
| style="border-right:none;" | [[#SHL|SHL]]
| style="border-left:none;" | [[#SHR|SHR]]
| style="" | [[#SAR|SAR]]
| colspan="9" |
|-
| style="text-align:left;" | Bitwise
| style="" | [[#AND|AND]]
| style="" | [[#OR|OR]]
| style="" | [[#XOR|XOR]]
| style="" | [[#NOT|NOT]]
| style="" | [[#TEST|TEST]]
| colspan="11" |
|-
| style="text-align:left;" | Branch
| style="border-right:none;" | [[#JC|JC]]
| style="border-left:none;" | [[#JNC|JNC]]
| style="border-right:none;" | [[#JZ|JZ]]
| style="border-left:none;" | [[#JNZ|JNZ]]
| style="border-right:none;" | [[#JBE|JBE]]
| style="border-left:none;" | [[#JA|JA]]
| style="border-right:none;" | [[#JO|JO]]
| style="border-left:none;" | [[#JNO|JNO]]
| style="border-right:none;" | [[#JP|JP]]
| style="border-left:none;" | [[#JNP|JNP]]
| style="border-right:none;" | [[#JS|JS]]
| style="border-left:none;" | [[#JNS|JNS]]
| style="border-right:none;" | [[#JL|JL]]
| style="border-left:none;" | [[#JGE|JGE]]
| style="border-right:none;" | [[#JLE|JLE]]
| style="border-left:none;" | [[#JG|JG]]
|-
| style="text-align:left;" | Jump
| style="" | [[#JMP|JMP]]
| style="border-right:none;" | [[#CALL|CALL]]
| style="border-left:none;border-right:none;" | [[#RET|RET]]
| style="border-left:none;" | [[#RETF|RETF]]
| colspan="12" |
|-
| style="text-align:left;" | Loop
| style="" | [[#LOOP|LOOP]]
| style="" | [[#LOOPE|LOOPE]]
| style="" | [[#LOOPNE|LOOPNE]]
| colspan="13" |
|-
| style="text-align:left;" | Interrupt
| style="border-right:none;" | [[#INT|INT]]
| style="border-left:none;" | [[#IRET|IRET]]
| style="" | [[#INTO|INTO]]
| style="" | [[#HLT|HLT]]
| style="" | [[#BOUND|BOUND]]
| colspan="11" |
|-
| style="text-align:left;" | Stack
| style="border-right:none;" | [[#PUSH|PUSH]]
| style="border-left:none;" | [[#POP|POP]]
| style="border-right:none;" | [[#PUSHA|PUSHA]]
| style="border-left:none;" | [[#POPA|POPA]]
| style="border-right:none;" | [[#PUSHF|PUSHF]]
| style="border-left:none;" | [[#POPF|POPF]]
| colspan="10" |
|-
| style="text-align:left;" | Flags
| style="border-right:none;" | [[#CLC|CLC]]
| style="border-left:none;" | [[#STC|STC]]
| style="border-right:none;" | [[#CLD|CLD]]
| style="border-left:none;" | [[#STD|STD]]
| style="border-right:none;" | [[#CLI|CLI]]
| style="border-left:none;" | [[#STI|STI]]
| style="" | [[#CMC|CMC]]
| style="border-right:none;" | [[#LAHF|LAHF]]
| style="border-left:none;" | [[#SAHF|SAHF]]
| colspan="7" |
|-
| style="text-align:left;" | Prefix
| style="" | [[#CS|CS]]
| style="" | [[#DS|DS]]
| style="" | [[#ES|ES]]
| style="" | [[#SS|SS]]
| colspan="12" |
|-
| style="text-align:left;" | String
| style="border-right:none;" | [[#REP|REP]]
| style="border-left:none;border-right:none;" | [[#REP|REPE]]
| style="border-left:none;" | [[#REPNE|REPNE]]
| style="" | [[#MOVSB|MOVSB]]
| style="" | [[#MOVSW|MOVSW]]
| style="border-right:none;" | [[#LODSB|LODSB]]
| style="border-left:none;" | [[#STOSB|STOSB]]
| style="border-right:none;" | [[#LODSW|LODSW]]
| style="border-left:none;" | [[#STOSW|STOSW]]
| style="" | [[#CMPSB|CMPSB]]
| style="" | [[#SCASB|SCASB]]
| style="" | [[#CMPSW|CMPSW]]
| style="" | [[#SCASW|SCASW]]
| colspan="3" |
|-
| style="text-align:left;" | Other
| style="" | [[#NOP|NOP]]
| style="border-right:none;" | [[#ENTER|ENTER]]
| style="border-left:none;" | [[#LEAVE|LEAVE]]
| style="" | [[#LOCK|LOCK]]
| style="" | [[#POLL|POLL]]
| colspan="11" |
|}
== Instruction encoding ==
=== ModR/M byte ===
The ModR/M byte is used in most addressing modes which reference a memory location. This byte consists of three bitfield values:
* <tt>oo</tt> - M'''o'''de;
* <tt>rrr</tt> - Two possible functions:
** '''R'''egister (for addressing modes which require both a register and a register/memory operand),
** Opcode extension (for some opcodes' addressing modes which do not have such a requirement);
* <tt>mmm</tt> - Register/'''M'''emory.
The ''Mode'' and ''Register/Memory'' bitfields can refer to a memory location or to a register, as shown in the table below. In some addressing modes, the ''Register'' field also refers to a register; it is always interpreted as if ''Mode'' was equal to <tt>11</tt>.
{| class="wikitable" style="text-align: center"
! R/M \ Mode
! <tt>00</tt>
! <tt>01</tt>
! <tt>10</tt>
! <tt>11</tt> ''(byte)''
! <tt>11</tt> ''(word)''
|-
| <tt>000</tt>
| DS:[BX + SI]
| DS:[BX + SI + disp8]
| DS:[BX + SI + disp16]
| AL
| AX
|-
| <tt>001</tt>
| DS:[BX + DI]
| DS:[BX + DI + disp8]
| DS:[BX + DI + disp16]
| CL
| CX
|-
| <tt>010</tt>
| SS:[BP + SI]
| SS:[BP + SI + disp8]
| SS:[BP + SI + disp16]
| DL
| DX
|-
| <tt>011</tt>
| SS:[BP + DI]
| SS:[BP + DI + disp8]
| SS:[BP + DI + disp16]
| BL
| BX
|-
| <tt>100</tt>
| DS:[SI]
| DS:[SI + disp8]
| DS:[SI + disp16]
| AH
| SP
|-
| <tt>101</tt>
| DS:[DI]
| DS:[DI + disp8]
| DS:[DI + disp16]
| CH
| BP
|-
| <tt>110</tt>
| ''DS:[disp16]''
| SS:[BP + disp8]
| SS:[BP + disp16]
| DH
| SI
|-
| <tt>111</tt>
| DS:[BX]
| DS:[BX + disp8]
| DS:[BX + disp16]
| BH
| DI
|}
Displacements are either 8-bit (disp8) or 16-bit (disp16) signed values and they always immediately follow the ModR/M byte. Note that (<tt>oo</tt> = <tt>00</tt>, <tt>mmm</tt> = <tt>110</tt>) is a special case, in which the ''disp16'' value is used directly as a near pointer.
The instruction encoding lists below refer to this byte as <tt>oorrrmmm</tt> (binary), <tt>/r</tt> (hexadecimal) or <tt>/0</tt> (hexademical, <tt>rrr</tt> used as function <tt>0</tt>).
== Official instructions ==
{{Anchor|AAA}}
=== AAA ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| AAA || <tt>37</tt> || <tt>00110111</tt> || 1 || 9
|}
----
{{Anchor|AAD}}
=== AAD ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| AAD imm8 || <tt>B5 ii</tt> || <tt>11010100 iiiiiiii</tt> || 2 || 6
|}
----
{{Anchor|AAM}}
=== AAM ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| AAM imm8 || <tt>B4 ii</tt> || <tt>11010100 iiiiiiii</tt> || 2 || 17
|}
----
{{Anchor|AAS}}
=== AAS ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| AAS || <tt>3F</tt> || <tt>00111111</tt> || 1 || 9
|}
----
{{Anchor|ADC}}
=== ADC ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| ADC AL, imm || <tt>14 ii</tt> || <tt>00010100 iiiiiiii</tt> || 2 || 1
|-
| ADC AX, imm || <tt>15 ii ii</tt> || <tt>00010101 iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| ADC mem8, imm8 || <tt>80 /2 ii</tt> || <tt>10000000 oo010mmm iiiiiiii</tt> || 3+ || 3
|-
| ADC mem16, imm16 || <tt>81 /2 ii ii</tt> || <tt>10000001 oo010mmm iiiiiiii iiiiiiii</tt> || 4+ || 3
|-
| ADC mem16, simm8 || <tt>83 /2 ii</tt> || <tt>10000011 oo010mmm iiiiiiii</tt> || 3+ || 3
|-
| ADC mem8, reg8 || <tt>10 /r</tt> || <tt>00010000 oorrrmmm</tt> || 2+ || 3
|-
| ADC mem16, reg16 || <tt>11 /r</tt> || <tt>00010001 oorrrmmm</tt> || 2+ || 3
|-
| ADC reg8, imm8 || <tt>80 /2 ii</tt> || <tt>10000000 11010mmm iiiiiiii</tt> || 3 || 1
|-
| ADC reg16, imm16 || <tt>81 /2 ii ii</tt> || <tt>10000001 11010mmm iiiiiiii iiiiiiii</tt> || 4 || 1
|-
| ADC reg16, simm8 || <tt>83 /2 ii</tt> || <tt>10000011 11010mmm iiiiiiii</tt> || 3 || 1
|-
| ADC reg8, mem8 || <tt>12 /r</tt> || <tt>00010010 oorrrmmm</tt> || 2+ || 2
|-
| ADC reg16, mem16 || <tt>13 /r</tt> || <tt>00010011 oorrrmmm</tt> || 2+ || 2
|-
| ADC reg8, reg8 || <tt>10 /r</tt> || <tt>000100.0 11rrrmmm</tt> || 2 || 1
|-
| ADC reg16, reg16 || <tt>11 /r</tt> || <tt>000100.1 11rrrmmm</tt> || 2 || 1
|}
----
{{Anchor|ADD}}
=== ADD ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| ADD AL, imm || <tt>04 ii</tt> || <tt>00000100 iiiiiiii</tt> || 2 || 1
|-
| ADD AX, imm || <tt>05 ii ii</tt> || <tt>00000101 iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| ADD mem8, imm8 || <tt>80 /0 ii</tt> || <tt>10000000 oo000mmm iiiiiiii</tt> || 3+ || 3
|-
| ADD mem16, imm16 || <tt>81 /0 ii ii</tt> || <tt>10000001 oo000mmm iiiiiiii iiiiiiii</tt> || 4+ || 3
|-
| ADD mem16, simm8 || <tt>83 /0 ii</tt> || <tt>10000011 oo000mmm iiiiiiii</tt> || 3+ || 3
|-
| ADD mem8, reg8 || <tt>00 /r</tt> || <tt>00000000 oorrrmmm</tt> || 2+ || 3
|-
| ADD mem16, reg16 || <tt>01 /r</tt> || <tt>00000001 oorrrmmm</tt> || 2+ || 3
|-
| ADD reg8, imm8 || <tt>80 /0 ii</tt> || <tt>10000000 11000mmm iiiiiiii</tt> || 3 || 1
|-
| ADD reg16, imm16 || <tt>81 /0 ii ii</tt> || <tt>10000001 11000mmm iiiiiiii iiiiiiii</tt> || 4 || 1
|-
| ADD reg16, simm8 || <tt>83 /0 ii</tt> || <tt>10000011 11000mmm iiiiiiii</tt> || 3 || 1
|-
| ADD reg8, mem8 || <tt>02 /r</tt> || <tt>00000010 oorrrmmm</tt> || 2+ || 2
|-
| ADD reg16, mem16 || <tt>03 /r</tt> || <tt>00000011 oorrrmmm</tt> || 2+ || 2
|-
| ADD reg8, reg8 || <tt>00 /r</tt> || <tt>000000.0 11rrrmmm</tt> || 2 || 1
|-
| ADD reg16, reg16 || <tt>01 /r</tt> || <tt>000000.1 11rrrmmm</tt> || 2 || 1
|}
----
{{Anchor|AND}}
=== AND ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| AND AL, imm || <tt>24 ii</tt> || <tt>00100100 iiiiiiii</tt> || 2 || 1
|-
| AND AX, imm || <tt>25 ii ii</tt> || <tt>00100101 iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| AND mem8, imm8 || <tt>80 /4 ii</tt> || <tt>10000000 oo100mmm iiiiiiii</tt> || 3+ || 3
|-
| AND mem16, imm16 || <tt>81 /4 ii ii</tt> || <tt>10000001 oo100mmm iiiiiiii iiiiiiii</tt> || 4+ || 3
|-
| AND mem16, simm8 || <tt>83 /4 ii</tt> || <tt>10000011 oo100mmm iiiiiiii</tt> || 3+ || 3
|-
| AND mem8, reg8 || <tt>20 /r</tt> || <tt>00100000 oorrrmmm</tt> || 2+ || 3
|-
| AND mem16, reg16 || <tt>21 /r</tt> || <tt>00100001 oorrrmmm</tt> || 2+ || 3
|-
| AND reg8, imm8 || <tt>80 /4 ii</tt> || <tt>10000000 11100mmm iiiiiiii</tt> || 3 || 1
|-
| AND reg16, imm16 || <tt>81 /4 ii ii</tt> || <tt>10000001 11100mmm iiiiiiii iiiiiiii</tt> || 4 || 1
|-
| AND reg16, simm8 || <tt>83 /4 ii</tt> || <tt>10000011 11100mmm iiiiiiii</tt> || 3 || 1
|-
| AND reg8, mem8 || <tt>22 /r</tt> || <tt>00100010 oorrrmmm</tt> || 2+ || 2
|-
| AND reg16, mem16 || <tt>23 /r</tt> || <tt>00100011 oorrrmmm</tt> || 2+ || 2
|-
| AND reg8, reg8 || <tt>20 /r</tt> || <tt>001000.0 11rrrmmm</tt> || 2 || 1
|-
| AND reg16, reg16 || <tt>21 /r</tt> || <tt>001000.1 11rrrmmm</tt> || 2 || 1
|}
----
{{Anchor|BOUND}}
=== BOUND ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| BOUND reg16, mem16:16 || <tt>62 /r</tt> || <tt>01100010 oorrrmmm</tt> || 2+ || 13 (20 if condition met)
|}
----
{{Anchor|CALL}}
=== CALL ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| CALL ptr16:16 || <tt>CA oo oo ss ss</tt> || <tt>10011010 oooooooo oooooooo ssssssss ssssssss</tt> || 5 || 10
|-
| CALL mem16 || <tt>FF /2</tt> || <tt>11111111 oo010mmm</tt> || 2+ || 6
|-
| CALL mem16:16 || <tt>FF /3</tt> || <tt>11111111 oo011mmm</tt> || 2+ || 12
|-
| CALL reg16 || <tt>FF /2</tt> || <tt>11111111 11010mmm</tt> || 2 || 5
|-
| CALL rel16 || <tt>E8 ii ii</tt> || <tt>11101000 iiiiiiii iiiiiiii</tt> || 3 || 5
|}
----
{{Anchor|CBW}}
=== CBW ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| CBW || <tt>98</tt> || <tt>10011000</tt> || 1 || 1
|}
----
{{Anchor|CLC}}
=== CLC ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| CLC || <tt>F8</tt> || <tt>11111000</tt> || 1 || 4
|}
----
{{Anchor|CLD}}
=== CLD ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| CLD || <tt>FC</tt> || <tt>11111100</tt> || 1 || 4
|}
----
{{Anchor|CLI}}
=== CLI ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| CLI || <tt>FA</tt> || <tt>11111010</tt> || 1 || 4
|}
----
{{Anchor|CMC}}
=== CMC ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| CMC || <tt>F5</tt> || <tt>11110101</tt> || 1 || 4
|}
----
{{Anchor|CMP}}
=== CMP ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| CMP AL, imm || <tt>3C ii</tt> || <tt>00111100 iiiiiiii</tt> || 2 || 1
|-
| CMP AX, imm || <tt>3D ii ii</tt> || <tt>00111101 iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| CMP mem8, imm8 || <tt>80 /7 ii</tt> || <tt>10000000 oo111mmm iiiiiiii</tt> || 3+ || 2
|-
| CMP mem16, imm16 || <tt>81 /7 ii ii</tt> || <tt>10000001 oo111mmm iiiiiiii iiiiiiii</tt> || 4+ || 2
|-
| CMP mem16, simm8 || <tt>83 /7 ii</tt> || <tt>10000011 oo111mmm iiiiiiii</tt> || 3+ || 2
|-
| CMP mem8, reg8 || <tt>38 /r</tt> || <tt>00111000 oorrrmmm</tt> || 2+ || 2
|-
| CMP mem16, reg16 || <tt>39 /r</tt> || <tt>00111001 oorrrmmm</tt> || 2+ || 2
|-
| CMP reg8, imm8 || <tt>80 /7 ii</tt> || <tt>10000000 11111mmm iiiiiiii</tt> || 3 || 1
|-
| CMP reg16, imm16 || <tt>81 /7 ii ii</tt> || <tt>10000001 11111mmm iiiiiiii iiiiiiii</tt> || 4 || 1
|-
| CMP reg16, simm8 || <tt>83 /7 ii</tt> || <tt>10000011 11111mmm iiiiiiii</tt> || 3 || 1
|-
| CMP reg8, mem8 || <tt>3A /r</tt> || <tt>00111010 oorrrmmm</tt> || 2+ || 2
|-
| CMP reg16, mem16 || <tt>3B /r</tt> || <tt>00111011 oorrrmmm</tt> || 2+ || 2
|-
| CMP reg8, reg8 || <tt>38 /r</tt> || <tt>001110.0 11rrrmmm</tt> || 2 || 1
|-
| CMP reg16, reg16 || <tt>39 /r</tt> || <tt>001110.1 11rrrmmm</tt> || 2 || 1
|}
----
{{Anchor|CMPSB}}
{{Anchor|CMPSW}}
=== CMPSB/CMPSW ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| CMPSB || <tt>A6</tt> || <tt>10100110</tt> || 1 || 6
|-
| CMPSW || <tt>A7</tt> || <tt>10100111</tt> || 1 || 6
|}
----
{{Anchor|CS}}
=== CS ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| CS || <tt>2E</tt> || <tt>00101110</tt> || 1 || 1
|}
----
{{Anchor|CWD}}
=== CWD ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| CWD || <tt>99</tt> || <tt>10011001</tt> || 1 || 1
|}
----
{{Anchor|DAA}}
=== DAA ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| DAA || <tt>27</tt> || <tt>00100111</tt> || 1 || 10
|}
----
{{Anchor|DAS}}
=== DAS ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| DAS || <tt>2F</tt> || <tt>00101111</tt> || 1 || 10
|}
----
{{Anchor|DEC}}
=== DEC ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| DEC mem8 || <tt>FE /1</tt> || <tt>11111110 oo001mmm</tt> || 2+ || 3
|-
| DEC mem16 || <tt>FF /1</tt> || <tt>11111111 oo001mmm</tt> || 2+ || 3
|-
| DEC reg8 || <tt>FE /1</tt> || <tt>11111110 11001mmm</tt> || 2+ || 1
|-
| DEC reg16 || <tt>4x</tt> || <tt>01001rrr</tt> || 1 || 1
|}
----
{{Anchor|DIV}}
=== DIV ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| DIV mem8 || <tt>F6 /6</tt> || <tt>11110110 oo110mmm</tt> || 2+ || 16
|-
| DIV mem16 || <tt>F7 /6</tt> || <tt>11111111 oo110mmm</tt> || 2+ || 24
|-
| DIV reg8 || <tt>F6 /6</tt> || <tt>11111110 11110mmm</tt> || 2+ || 15
|-
| DIV reg16 || <tt>F7 /6</tt> || <tt>11111111 11110mmm</tt> || 2+ || 23
|}
----
{{Anchor|DS}}
=== DS ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| DS || <tt>3E</tt> || <tt>00111110</tt> || 1 || 1
|}
----
{{Anchor|ENTER}}
=== ENTER ===
----
{{Anchor|ES}}
=== ES ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| ES || <tt>26</tt> || <tt>00100110</tt> || 1 || 1
|}
----
{{Anchor|HLT}}
=== HLT ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| HLT || <tt>F4</tt> || <tt>11110100</tt> || 1 || 9
|}
----
{{Anchor|IDIV}}
=== IDIV ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| IDIV mem8 || <tt>F6 /7</tt> || <tt>11110110 oo111mmm</tt> || 2+ || 18
|-
| IDIV mem16 || <tt>F7 /7</tt> || <tt>11111111 oo111mmm</tt> || 2+ || 25
|-
| IDIV reg8 || <tt>F6 /7</tt> || <tt>11111110 11111mmm</tt> || 2+ || 17
|-
| IDIV reg16 || <tt>F7 /7</tt> || <tt>11111111 11111mmm</tt> || 2+ || 24
|}
----
{{Anchor|IMUL}}
=== IMUL ===
----
{{Anchor|IN}}
=== IN ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| IN AL, DX || <tt>EC</tt> || <tt>11101100</tt> || 1 || 6
|-
| IN AX, DX || <tt>ED</tt> || <tt>11101101</tt> || 1 || 6
|-
| IN AL, imm8 || <tt>E4 ii</tt> || <tt>11100100 iiiiiiii</tt> || 2 || 6
|-
| IN AX, imm8 || <tt>E5 ii</tt> || <tt>11100101 iiiiiiii</tt> || 2 || 6
|}
----
{{Anchor|INC}}
=== INC ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| INC mem8 || <tt>FE /0</tt> || <tt>11111110 oo000mmm</tt> || 2+ || 3
|-
| INC mem16 || <tt>FF /0</tt> || <tt>11111111 oo000mmm</tt> || 2+ || 3
|-
| INC reg8 || <tt>FE /0</tt> || <tt>11111110 11000mmm</tt> || 2+ || 1
|-
| INC reg16 || <tt>4x</tt> || <tt>01000rrr</tt> || 1 || 1
|}
----
{{Anchor|INSB}}
{{Anchor|INSW}}
=== INSB/INSW ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| INSB || <tt>6C</tt> || <tt>01101100</tt> || 1 || 6
|-
| INSW || <tt>6D</tt> || <tt>01101101</tt> || 1 || 6
|}
----
{{Anchor|INT}}
=== INT ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| INT 3 || <tt>CC</tt> || <tt>11001100</tt> || 1 || 9
|-
| INT imm8 || <tt>CD ii</tt> || <tt>11001101 iiiiiiii</tt> || 2 || 10
|}
----
{{Anchor|INTO}}
=== INTO ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| INTO || <tt>CE</tt> || <tt>11001110</tt> || 1 || 6 (13 if OF = 1)
|}
----
{{Anchor|IRET}}
=== IRET ===
----
{{Anchor|JA}}
=== JA ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JA rel8 || <tt>77 ii</tt> || <tt>01110111 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JBE}}
=== JBE ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JA rel8 || <tt>76 ii</tt> || <tt>01110110 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JC}}
=== JC/JB ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JC rel8 || <tt>72 ii</tt> || <tt>01110010 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JCXZ}}
=== JCXZ ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JCXZ rel8 || <tt>E3 ii</tt> || <tt>11100011 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JG}}
=== JG ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JG rel8 || <tt>7F ii</tt> || <tt>01111111 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JGE}}
=== JGE ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JGE rel8 || <tt>7D ii</tt> || <tt>01111101 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JL}}
=== JL ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JL rel8 || <tt>7C ii</tt> || <tt>01111100 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JLE}}
=== JLE ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JLE rel8 || <tt>7E ii</tt> || <tt>01111110 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JMP}}
=== JMP ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JMP ptr16:16 || <tt>EA oo oo ss ss</tt> || <tt>11101010 oooooooo oooooooo ssssssss ssssssss</tt> || 5 || 7
|-
| JMP mem16 || <tt>FF /4</tt> || <tt>11111111 oo100mmm</tt> || 2+ || 5
|-
| JMP mem16:16 || <tt>FF /5</tt> || <tt>11111111 oo101mmm</tt> || 2+ || 10
|-
| JMP reg16 || <tt>FF /4</tt> || <tt>11111111 11100mmm</tt> || 2 || 4
|-
| JMP rel8 || <tt>EB ii</tt> || <tt>11101011 iiiiiiii</tt> || 2 || 4
|-
| JMP rel16 || <tt>E9 ii ii</tt> || <tt>11101001 iiiiiiii iiiiiiii</tt> || 3 || 4
|}
----
{{Anchor|JNC}}
=== JNC/JAE ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JNC rel8 || <tt>73 ii</tt> || <tt>01110011 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JNO}}
=== JNO ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JNO rel8 || <tt>71 ii</tt> || <tt>01110001 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JNP}}
=== JNP ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JNP rel8 || <tt>7B ii</tt> || <tt>01111011 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JNS}}
=== JNS ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JNS rel8 || <tt>79 ii</tt> || <tt>01111001 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JNZ}}
=== JNZ/JNE ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JNZ rel8 || <tt>75 ii</tt> || <tt>01110101 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JO}}
=== JO ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JO rel8 || <tt>70 ii</tt> || <tt>01110000 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JP}}
=== JP ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JP rel8 || <tt>7A ii</tt> || <tt>01111010 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JS}}
=== JS ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JS rel8 || <tt>78 ii</tt> || <tt>01111000 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JZ}}
=== JZ/JE ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JZ rel8 || <tt>74 ii</tt> || <tt>01110100 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|LAHF}}
=== LAHF ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| LAHF || <tt>9F</tt> || <tt>10011111</tt> || 1 || 2
|}
----
{{Anchor|LDS}}
=== LDS ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| LDS reg16, mem16 || <tt>C5 /r</tt> || <tt>11000101 oorrrmmm</tt> || 2+ || 6
|}
----
{{Anchor|LEA}}
=== LEA ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| LEA reg16, mem16 || <tt>8D /r</tt> || <tt>10001101 oorrrmmm</tt> || 2+ || 1
|}
----
{{Anchor|LEAVE}}
=== LEAVE ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| LEAVE || <tt>C9</tt> || <tt>11001001</tt> || 1 || 2
|}
----
{{Anchor|LES}}
=== LES ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| LES reg16, mem16 || <tt>C4 /r</tt> || <tt>11000100 oorrrmmm</tt> || 2+ || 6
|}
----
{{Anchor|LOCK}}
=== LOCK ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| LOCK || <tt>F0</tt> || <tt>11110000</tt> || 1 || 1
|}
----
{{Anchor|LODSB}}
{{Anchor|LODSW}}
=== LODSB/LODSW ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| LODSB || <tt>AC</tt> || <tt>10101100</tt> || 1 || 3
|-
| LODSW || <tt>AD</tt> || <tt>10101101</tt> || 1 || 3
|}
----
{{Anchor|LOOP}}
=== LOOP ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| LOOP rel8 || <tt>E2 ii</tt> || <tt>11100010 iiiiiiii</tt> || 2 || 2 (5 if branch taken)
|}
----
{{Anchor|LOOPE}}
=== LOOPE ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| LOOPE rel8 || <tt>E1 ii</tt> || <tt>11100001 iiiiiiii</tt> || 2 || 3 (6 if branch taken)
|}
----
{{Anchor|LOOPNE}}
=== LOOPNE ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| LOOPNE rel8 || <tt>E0 ii</tt> || <tt>11100000 iiiiiiii</tt> || 2 || 3 (6 if branch taken)
|}
----
{{Anchor|MOV}}
=== MOV ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| MOV AL, ptr16 || <tt>A0 ii ii</tt> || <tt>10100000 iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| MOV AX, ptr16 || <tt>A1 ii ii</tt> || <tt>10100001 iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| MOV mem8, imm8 || <tt>C6 /0 ii</tt> || <tt>11000110 oo000mmm iiiiiiii</tt> || 3+ || 1
|-
| MOV mem16, imm16 || <tt>C7 /0 ii ii</tt> || <tt>11000111 oo000mmm iiiiiiii iiiiiiii</tt> || 4+ || 1
|-
| MOV mem8, reg8 || <tt>84 /r</tt> || <tt>10001000 oorrrmmm</tt> || 2+ || 1
|-
| MOV mem16, reg16 || <tt>85 /r</tt> || <tt>10001001 oorrrmmm</tt> || 2+ || 1
|-
| MOV mem16, sreg16 || <tt>8C /r</tt> || <tt>10001100 oo0rrmmm</tt> || 2+ || 3
|-
| MOV ptr16, AL || <tt>A2 ii ii</tt> || <tt>10100010 iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| MOV ptr16, AX || <tt>A3 ii ii</tt> || <tt>10100011 iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| MOV reg8, imm8 || <tt>Bx ii</tt> || <tt>10110rrr iiiiiiii</tt> || 2 || 1
|-
| MOV reg8, imm8 || <tt>C6 /0 ii</tt> || <tt>11000110 11000mmm iiiiiiii</tt> || 3 || 1
|-
| MOV reg16, imm16 || <tt>Bx ii</tt> || <tt>10111rrr iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| MOV reg16, imm16 || <tt>C7 /0 ii ii</tt> || <tt>11000111 11000mmm iiiiiiii iiiiiiii</tt> || 4 || 1
|-
| MOV reg8, mem8 || <tt>8A /r</tt> || <tt>10001010 oorrrmmm</tt> || 2+ || 1
|-
| MOV reg16, mem16 || <tt>8B /r</tt> || <tt>10001011 oorrrmmm</tt> || 2+ || 1
|-
| MOV reg8, reg8 || <tt>88 /r</tt> || <tt>100010.0 11rrrmmm</tt> || 2 || 1
|-
| MOV reg16, reg16 || <tt>89 /r</tt> || <tt>100010.1 11rrrmmm</tt> || 2 || 1
|-
| MOV reg16, sreg16 || <tt>8C /r</tt> || <tt>10001100 110rrmmm</tt> || 2 || 1
|-
| MOV sreg16, mem16 || <tt>8E /r</tt> || <tt>10001110 oo0rrmmm</tt> || 2 || 3
|-
| MOV sreg16, reg16 || <tt>8E /r</tt> || <tt>10001110 110rrmmm</tt> || 2+ || 2
|}
----
{{Anchor|MOVSB}}
{{Anchor|MOVSW}}
=== MOVSB/MOVSW ===
----
{{Anchor|MUL}}
=== MUL ===
----
{{Anchor|NEG}}
=== NEG ===
----
{{Anchor|NOP}}
=== NOP ===
----
{{Anchor|NOT}}
=== NOT ===
----
{{Anchor|OR}}
=== OR ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| OR AL, imm || <tt>0C ii</tt> || <tt>00001100 iiiiiiii</tt> || 2 || 1
|-
| OR AX, imm || <tt>0D ii ii</tt> || <tt>00001101 iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| OR mem8, imm8 || <tt>80 /6 ii</tt> || <tt>10000000 oo001mmm iiiiiiii</tt> || 3+ || 3
|-
| OR mem16, imm16 || <tt>81 /6 ii ii</tt> || <tt>10000001 oo001mmm iiiiiiii iiiiiiii</tt> || 4+ || 3
|-
| OR mem16, simm8 || <tt>83 /6 ii</tt> || <tt>10000011 oo001mmm iiiiiiii</tt> || 3+ || 3
|-
| OR mem8, reg8 || <tt>08 /r</tt> || <tt>00001000 oorrrmmm</tt> || 2+ || 3
|-
| OR mem16, reg16 || <tt>09 /r</tt> || <tt>00001001 oorrrmmm</tt> || 2+ || 3
|-
| OR reg8, imm8 || <tt>80 /6 ii</tt> || <tt>10000000 11001mmm iiiiiiii</tt> || 3 || 1
|-
| OR reg16, imm16 || <tt>81 /6 ii ii</tt> || <tt>10000001 11001mmm iiiiiiii iiiiiiii</tt> || 4 || 1
|-
| OR reg16, simm8 || <tt>83 /6 ii</tt> || <tt>10000011 11001mmm iiiiiiii</tt> || 3 || 1
|-
| OR reg8, mem8 || <tt>0A /r</tt> || <tt>00001010 oorrrmmm</tt> || 2+ || 2
|-
| OR reg16, mem16 || <tt>0B /r</tt> || <tt>00001011 oorrrmmm</tt> || 2+ || 2
|-
| OR reg8, reg8 || <tt>08 /r</tt> || <tt>000010.0 11rrrmmm</tt> || 2 || 1
|-
| OR reg16, reg16 || <tt>09 /r</tt> || <tt>000010.1 11rrrmmm</tt> || 2 || 1
|}
----
{{Anchor|OUT}}
=== OUT ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| OUT AL, DX || <tt>EE</tt> || <tt>11101110</tt> || 1 || 6
|-
| OUT AX, DX || <tt>EF</tt> || <tt>11101111</tt> || 1 || 6
|-
| OUT AL, imm8 || <tt>E6 ii</tt> || <tt>11100110 iiiiiiii</tt> || 2 || 6
|-
| OUT AX, imm8 || <tt>E7 ii</tt> || <tt>11100111 iiiiiiii</tt> || 2 || 6
|}
----
{{Anchor|OUTSB}}
{{Anchor|OUTSW}}
=== OUTSB/OUTSW ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| OUTSB || <tt>6E</tt> || <tt>01101110</tt> || 1 || 6
|-
| OUTSW || <tt>6F</tt> || <tt>01101111</tt> || 1 || 6
|}
----
{{Anchor|POLL}}
=== POLL ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| POLL || <tt>6E</tt> || <tt>01101110</tt> || 1 || 9<ref>On the WonderSwan implementation, POLLB is always held low; on other implementations, POLL will wait for POLLB to be held low in 9-cycle intervals.</ref>
|}
----
{{Anchor|POP}}
=== POP ===
----
{{Anchor|POPA}}
=== POPA ===
----
{{Anchor|POPF}}
=== POPF ===
----
{{Anchor|PUSH}}
=== PUSH ===
----
{{Anchor|PUSHA}}
=== PUSHA ===
----
{{Anchor|PUSHF}}
=== PUSHF ===
----
{{Anchor|RCL}}
=== RCL ===
----
{{Anchor|RCR}}
=== RCR ===
----
{{Anchor|REP}}
=== REP/REPE/REPZ ===
----
{{Anchor|REPNE}}
=== REPNE/REPNZ ===
----
{{Anchor|RET}}
=== RET ===
----
{{Anchor|RETF}}
=== RETF ===
----
{{Anchor|ROL}}
=== ROL ===
----
{{Anchor|ROR}}
=== ROR ===
----
{{Anchor|SAHF}}
=== SAHF ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| SAHF || <tt>9E</tt> || <tt>10011110</tt> || 1 || 4
|}
----
{{Anchor|SAR}}
=== SAR ===
----
{{Anchor|SBB}}
=== SBB ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| SBB AL, imm || <tt>1C ii</tt> || <tt>00011100 iiiiiiii</tt> || 2 || 1
|-
| SBB AX, imm || <tt>1D ii ii</tt> || <tt>00011101 iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| SBB mem8, imm8 || <tt>80 /3 ii</tt> || <tt>10000000 oo011mmm iiiiiiii</tt> || 3+ || 3
|-
| SBB mem16, imm16 || <tt>81 /3 ii ii</tt> || <tt>10000001 oo011mmm iiiiiiii iiiiiiii</tt> || 4+ || 3
|-
| SBB mem16, simm8 || <tt>83 /3 ii</tt> || <tt>10000011 oo011mmm iiiiiiii</tt> || 3+ || 3
|-
| SBB mem8, reg8 || <tt>18 /r</tt> || <tt>00011000 oorrrmmm</tt> || 2+ || 3
|-
| SBB mem16, reg16 || <tt>19 /r</tt> || <tt>00011001 oorrrmmm</tt> || 2+ || 3
|-
| SBB reg8, imm8 || <tt>80 /3 ii</tt> || <tt>10000000 11011mmm iiiiiiii</tt> || 3 || 1
|-
| SBB reg16, imm16 || <tt>81 /3 ii ii</tt> || <tt>10000001 11011mmm iiiiiiii iiiiiiii</tt> || 4 || 1
|-
| SBB reg16, simm8 || <tt>83 /3 ii</tt> || <tt>10000011 11011mmm iiiiiiii</tt> || 3 || 1
|-
| SBB reg8, mem8 || <tt>1A /r</tt> || <tt>00011010 oorrrmmm</tt> || 2+ || 2
|-
| SBB reg16, mem16 || <tt>1B /r</tt> || <tt>00011011 oorrrmmm</tt> || 2+ || 2
|-
| SBB reg8, reg8 || <tt>18 /r</tt> || <tt>000110.0 11rrrmmm</tt> || 2 || 1
|-
| SBB reg16, reg16 || <tt>19 /r</tt> || <tt>000110.1 11rrrmmm</tt> || 2 || 1
|}
----
{{Anchor|SCASB}}
{{Anchor|SCASW}}
=== SCASB/SCASW ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| SCASB || <tt>AE</tt> || <tt>10101110</tt> || 1 || 4
|-
| SCASW || <tt>AF</tt> || <tt>10101111</tt> || 1 || 4
|}
----
{{Anchor|SHL}}
=== SHL ===
----
{{Anchor|SHR}}
=== SHR ===
----
{{Anchor|SS}}
=== SS ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| SS || <tt>36</tt> || <tt>00110110</tt> || 1 || 1
|}
----
{{Anchor|STC}}
=== STC ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| STC || <tt>F9</tt> || <tt>11111001</tt> || 1 || 4
|}
----
{{Anchor|STD}}
=== STD ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| STD || <tt>FD</tt> || <tt>11111101</tt> || 1 || 4
|}
----
{{Anchor|STI}}
=== STI ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| STI || <tt>FB</tt> || <tt>11111011</tt> || 1 || 4
|}
----
{{Anchor|STOSB}}
{{Anchor|STOSW}}
=== STOSB/STOSW ===
----
{{Anchor|SUB}}
=== SUB ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| SUB AL, imm || <tt>28 ii</tt> || <tt>00101100 iiiiiiii</tt> || 2 || 1
|-
| SUB AX, imm || <tt>29 ii ii</tt> || <tt>00101101 iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| SUB mem8, imm8 || <tt>80 /5 ii</tt> || <tt>10000000 oo101mmm iiiiiiii</tt> || 3+ || 3
|-
| SUB mem16, imm16 || <tt>81 /5 ii ii</tt> || <tt>10000001 oo101mmm iiiiiiii iiiiiiii</tt> || 4+ || 3
|-
| SUB mem16, simm8 || <tt>83 /5 ii</tt> || <tt>10000011 oo101mmm iiiiiiii</tt> || 3+ || 3
|-
| SUB mem8, reg8 || <tt>28 /r</tt> || <tt>00101000 oorrrmmm</tt> || 2+ || 3
|-
| SUB mem16, reg16 || <tt>29 /r</tt> || <tt>00101001 oorrrmmm</tt> || 2+ || 3
|-
| SUB reg8, imm8 || <tt>80 /5 ii</tt> || <tt>10000000 11101mmm iiiiiiii</tt> || 3 || 1
|-
| SUB reg16, imm16 || <tt>81 /5 ii ii</tt> || <tt>10000001 11101mmm iiiiiiii iiiiiiii</tt> || 4 || 1
|-
| SUB reg16, simm8 || <tt>83 /5 ii</tt> || <tt>10000011 11101mmm iiiiiiii</tt> || 3 || 1
|-
| SUB reg8, mem8 || <tt>2A /r</tt> || <tt>00101010 oorrrmmm</tt> || 2+ || 2
|-
| SUB reg16, mem16 || <tt>2B /r</tt> || <tt>00101011 oorrrmmm</tt> || 2+ || 2
|-
| SUB reg8, reg8 || <tt>28 /r</tt> || <tt>001010.0 11rrrmmm</tt> || 2 || 1
|-
| SUB reg16, reg16 || <tt>29 /r</tt> || <tt>001010.1 11rrrmmm</tt> || 2 || 1
|}
----
{{Anchor|TEST}}
=== TEST ===
----
{{Anchor|XCHG}}
=== XCHG ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| XCHG AX, reg16<br/>XCHG reg16, AX || <tt>9x</tt> || <tt>10010rrr</tt> || 1 || 3
|-
| XCHG mem8, reg8<br/>XCHG reg8, mem8 || <tt>86 /r</tt> || <tt>10000110 oorrrmmm</tt> || 2+ || 5
|-
| XCHG mem16, reg16<br/>XCHG reg16, mem16 || <tt>87 /r</tt> || <tt>10000111 oorrrmmm</tt> || 2+ || 5
|-
| XCHG reg8, reg8 || <tt>86 /r</tt> || <tt>10000110 11rrrmmm</tt> || 2+ || 3
|-
| XCHG reg16, reg16 || <tt>87 /r</tt> || <tt>10000111 11rrrmmm</tt> || 2+ || 3
|}
----
{{Anchor|XLAT}}
=== XLAT ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| XLAT || <tt>D7</tt> || <tt>11010111</tt> || 1 || 5
|}
----
{{Anchor|XOR}}
=== XOR ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| XOR AL, imm || <tt>34 ii</tt> || <tt>00110100 iiiiiiii</tt> || 2 || 1
|-
| XOR AX, imm || <tt>35 ii ii</tt> || <tt>00110101 iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| XOR mem8, imm8 || <tt>80 /6 ii</tt> || <tt>10000000 oo110mmm iiiiiiii</tt> || 3+ || 3
|-
| XOR mem16, imm16 || <tt>81 /6 ii ii</tt> || <tt>10000001 oo110mmm iiiiiiii iiiiiiii</tt> || 4+ || 3
|-
| XOR mem16, simm8 || <tt>83 /6 ii</tt> || <tt>10000011 oo110mmm iiiiiiii</tt> || 3+ || 3
|-
| XOR mem8, reg8 || <tt>30 /r</tt> || <tt>00110000 oorrrmmm</tt> || 2+ || 3
|-
| XOR mem16, reg16 || <tt>31 /r</tt> || <tt>00110001 oorrrmmm</tt> || 2+ || 3
|-
| XOR reg8, imm8 || <tt>80 /6 ii</tt> || <tt>10000000 11110mmm iiiiiiii</tt> || 3 || 1
|-
| XOR reg16, imm16 || <tt>81 /6 ii ii</tt> || <tt>10000001 11110mmm iiiiiiii iiiiiiii</tt> || 4 || 1
|-
| XOR reg16, simm8 || <tt>83 /6 ii</tt> || <tt>10000011 11110mmm iiiiiiii</tt> || 3 || 1
|-
| XOR reg8, mem8 || <tt>32 /r</tt> || <tt>00110010 oorrrmmm</tt> || 2+ || 2
|-
| XOR reg16, mem16 || <tt>33 /r</tt> || <tt>00110011 oorrrmmm</tt> || 2+ || 2
|-
| XOR reg8, reg8 || <tt>30 /r</tt> || <tt>001100.0 11rrrmmm</tt> || 2 || 1
|-
| XOR reg16, reg16 || <tt>31 /r</tt> || <tt>001100.1 11rrrmmm</tt> || 2 || 1
|}
----
== Notes ==
<references />
7937618c29a2b8f55f9b72c0eda245dba2fba2f7
459
458
2024-12-27T22:41:24Z
Asie
351
wikitext
text/x-wiki
__NOTOC__
Note that this page is a work in progress.
{| class="wikitable" style="text-align: center"
|+ Official V30MZ (80186) Instructions
|-
| [[#AAA|AAA]] || [[#AAD|AAD]] || [[#AAM|AAM]] || [[#AAS|AAS]] || [[#ADC|ADC]] || [[#ADD|ADD]] || [[#AND|AND]] || [[#BOUND|BOUND]] || [[#CALL|CALL]] || [[#CBW|CBW]] || [[#CLC|CLC]]
|-
| [[#CLD|CLD]] || [[#CLI|CLI]] || [[#CMC|CMC]] || [[#CMP|CMP]] || [[#CMPSB|CMPSB]] || [[#CMPSW|CMPSW]] || [[#CS|CS]] || [[#CWD|CWD]] || [[#DAA|DAA]] || [[#DAS|DAS]] || [[#DEC|DEC]]
|-
| [[#DIV|DIV]] || [[#DS|DS]] || [[#ENTER|ENTER]] || [[#ES|ES]] || [[#HLT|HLT]] || [[#IDIV|IDIV]] || [[#IMUL|IMUL]] || [[#IN|IN]] || [[#INC|INC]] || [[#INSB|INSB]] || [[#INSW|INSW]]
|-
| [[#INT|INT]] || [[#INTO|INTO]] || [[#IRET|IRET]] || [[#JA|JA]] || [[#JBE|JBE]] || [[#JC|JC]] || [[#JCXZ|JCXZ]] || [[#JG|JG]] || [[#JGE|JGE]] || [[#JL|JL]] || [[#JLE|JLE]]
|-
| [[#JMP|JMP]] || [[#JNC|JNC]] || [[#JNO|JNO]] || [[#JNP|JNP]] || [[#JNS|JNS]] || [[#JNZ|JNZ]] || [[#JO|JO]] || [[#JP|JP]] || [[#JS|JS]] || [[#JZ|JZ]] || [[#LAHF|LAHF]]
|-
| [[#LDS|LDS]] || [[#LEA|LEA]] || [[#LEAVE|LEAVE]] || [[#LES|LES]] || [[#LOCK|LOCK]] || [[#LODSB|LODSB]] || [[#LODSW|LODSW]] || [[#LOOP|LOOP]] || [[#LOOPE|LOOPE]] || [[#LOOPNE|LOOPNE]] || [[#MOV|MOV]]
|-
| [[#MOVSB|MOVSB]] || [[#MOVSW|MOVSW]] || [[#MUL|MUL]] || [[#NEG|NEG]] || [[#NOP|NOP]] || [[#NOT|NOT]] || [[#OR|OR]] || [[#OUT|OUT]] || [[#OUTSB|OUTSB]] || [[#OUTSW|OUTSW]] || [[#POLL|POLL]]
|-
| [[#POP|POP]] || [[#POPA|POPA]] || [[#POPF|POPF]] || [[#PUSH|PUSH]] || [[#PUSHA|PUSHA]] || [[#PUSHF|PUSHF]] || [[#RCL|RCL]] || [[#RCR|RCR]] || [[#REP|REP]] || [[#REPNE|REPNE]] || [[#RET|RET]]
|-
| [[#RETF|RETF]] || [[#ROL|ROL]] || [[#ROR|ROR]] || [[#SAHF|SAHF]] || [[#SAR|SAR]] || [[#SBB|SBB]] || [[#SCASB|SCASB]] || [[#SCASW|SCASW]] || [[#SHL|SHL]] || [[#SHR|SHR]] || [[#SS|SS]]
|-
| [[#STC|STC]] || [[#STD|STD]] || [[#STI|STI]] || [[#STOSB|STOSB]] || [[#STOSW|STOSW]] || [[#SUB|SUB]] || [[#TEST|TEST]] || [[#XCHG|XCHG]] || [[#XLAT|XLAT]] || [[#XOR|XOR]]
|}
{| class="mw-collapsible mw-collapsed wikitable sortable" style="width: 340px;"
|+ style="white-space:nowrap; border:1px solid; padding:3px; border-color:rgb(162, 169, 177); background-color:rgb(234, 236, 240);" | Intel <-> NEC mnemonic translation table
!Intel
!NEC
|-
| [[#AAA|AAA]]
| [[#AAA|ADJBA]]
|-
| [[#AAD|AAD]]
| [[#AAD|CVTDB]]
|-
| [[#AAM|AAM]]
| [[#AAM|CVTBD]]
|-
| [[#AAS|AAS]]
| [[#AAS|ADJBS]]
|-
| [[#ADC|ADC]]
| [[#ADC|ADDC]]
|-
| [[#ADD|ADD]]
| [[#ADD|ADD]]
|-
| [[#AND|AND]]
| [[#AND|AND]]
|-
| [[#BOUND|BOUND]]
| [[#BOUND|CHKIND]]
|-
| [[#CALL|CALL]]
| [[#CALL|CALL]]
|-
| [[#CBW|CBW]]
| [[#CBW|CVTBW]]
|-
| [[#CLC|CLC]]
| [[#CLC|CLR1 CY]]
|-
| [[#CLD|CLD]]
| [[#CLD|CLR1 DIR]]
|-
| [[#CLI|CLI]]
| [[#CLI|DI]]
|-
| [[#CMC|CMC]]
| [[#CMC|NOT1 CY]]
|-
| [[#CMP|CMP]]
| [[#CMP|CMP]]
|-
| [[#CMPSB|CMPSB]]
| [[#CMPSB|CMPBKB]]
|-
| [[#CMPSW|CMPSW]]
| [[#CMPSW|CMPBKW]]
|-
| [[#CS|CS]]
| [[#CS|PS]]
|-
| [[#CWD|CWD]]
| [[#CWD|CVTWL]]
|-
| [[#DAA|DAA]]
| [[#DAA|ADJ4A]]
|-
| [[#DAS|DAS]]
| [[#DAS|ADJ4S]]
|-
| [[#DEC|DEC]]
| [[#DEC|DEC]]
|-
| [[#DIV|DIV]]
| [[#DIV|DIVU]]
|-
| [[#DS|DS]]
| [[#DS|DS0]]
|-
| [[#ENTER|ENTER]]
| [[#ENTER|PREPARE]]
|-
| [[#ES|ES]]
| [[#ES|DS1]]
|-
| [[#HLT|HLT]]
| [[#HLT|HALT]]
|-
| [[#IDIV|IDIV]]
| [[#IDIV|DIV]]
|-
| [[#IMUL|IMUL]]
| [[#IMUL|MUL]]
|-
| [[#IN|IN]]
| [[#IN|IN]]
|-
| [[#INC|INC]]
| [[#INC|INC]]
|-
| [[#INSB|INSB]]
| [[#INSB|INMB]]
|-
| [[#INSW|INSW]]
| [[#INSW|INMW]]
|-
| [[#INT|INT]]
| [[#INT|BRK]]
|-
| [[#INTO|INTO]]
| [[#INTO|BRKV]]
|-
| [[#IRET|IRET]]
| [[#IRET|RETI]]
|-
| [[#JA|JA]]
| [[#JA|BH]]
|-
| [[#JBE|JBE]]
| [[#JBE|BNH]]
|-
| [[#JC|JC/JB]]
| [[#JC|BC/BL]]
|-
| [[#JCXZ|JCXZ]]
| [[#JCXZ|BCWZ]]
|-
| [[#JG|JG]]
| [[#JG|BGT]]
|-
| [[#JGE|JGE]]
| [[#JGE|BGE]]
|-
| [[#JL|JL]]
| [[#JL|BLT]]
|-
| [[#JLE|JLE]]
| [[#JLE|BLE]]
|-
| [[#JMP|JMP]]
| [[#JMP|BR]]
|-
| [[#JNC|JNC/JAE]]
| [[#JNC|BNC/BNL]]
|-
| [[#JNO|JNO]]
| [[#JNO|BNV]]
|-
| [[#JNP|JNP]]
| [[#JNP|BPO]]
|-
| [[#JNS|JNS]]
| [[#JNS|BP]]
|-
| [[#JNZ|JNZ/JNE]]
| [[#JNZ|BNZ/BNE]]
|-
| [[#JO|JO]]
| [[#JO|BV]]
|-
| [[#JP|JP]]
| [[#JP|BPE]]
|-
| [[#JS|JS]]
| [[#JS|BN]]
|-
| [[#JZ|JZ/JE]]
| [[#JZ|BZ/BE]]
|-
| [[#LAHF|LAHF]]
| [[#LAHF|MOV]]
|-
| [[#LDS|LDS]]
| [[#LDS|MOV]]
|-
| [[#LEA|LEA]]
| [[#LEA|LDEA]]
|-
| [[#LEAVE|LEAVE]]
| [[#LEAVE|DISPOSE]]
|-
| [[#LES|LES]]
| [[#LES|MOV]]
|-
| [[#LOCK|LOCK]]
| [[#LOCK|BUSLOCK]]
|-
| [[#LODSB|LODSB]]
| [[#LODSB|LDMB]]
|-
| [[#LODSW|LODSW]]
| [[#LODSW|LDMW]]
|-
| [[#LOOP|LOOP]]
| [[#LOOP|DBNZ]]
|-
| [[#LOOPE|LOOPE]]
| [[#LOOPE|DBNZE]]
|-
| [[#LOOPNE|LOOPNE]]
| [[#LOOPNE|DBNZNE]]
|-
| [[#MOV|MOV]]
| [[#MOV|MOV]]
|-
| [[#MOVSB|MOVSB]]
| [[#MOVSB|MOVBKB]]
|-
| [[#MOVSW|MOVSW]]
| [[#MOVSW|MOVBKW]]
|-
| [[#MUL|MUL]]
| [[#MUL|MULU]]
|-
| [[#NEG|NEG]]
| [[#NEG|NEG]]
|-
| [[#NOP|NOP]]
| [[#NOP|NOP]]
|-
| [[#NOT|NOT]]
| [[#NOT|NOT]]
|-
| [[#OR|OR]]
| [[#OR|OR]]
|-
| [[#OUT|OUT]]
| [[#OUT|OUT]]
|-
| [[#OUTSB|OUTSB]]
| [[#OUTSB|OUTM]]
|-
| [[#OUTSW|OUTSW]]
| [[#OUTSW|OUTM]]
|-
| [[#POLL|POLL]]
| [[#POLL|POLL]]
|-
| [[#POP|POP]]
| [[#POP|POP]]
|-
| [[#POPA|POPA]]
| [[#POPA|POP]]
|-
| [[#POPF|POPF]]
| [[#POPF|POP]]
|-
| [[#PUSH|PUSH]]
| [[#PUSH|PUSH]]
|-
| [[#PUSHA|PUSHA]]
| [[#PUSHA|PUSH]]
|-
| [[#PUSHF|PUSHF]]
| [[#PUSHF|PUSH]]
|-
| [[#RCL|RCL]]
| [[#RCL|ROLC]]
|-
| [[#RCR|RCR]]
| [[#RCR|RORC]]
|-
| [[#REP|REP/REPE/REPZ]]
| [[#REP|REP/REPE/REPZ]]
|-
| [[#REPNE|REPNE/REPNZ]]
| [[#REPNE|REPNE/REPNZ]]
|-
| [[#RET|RET]]
| [[#RET|RET]]
|-
| [[#RETF|RETF]]
| [[#RETF|RET]]
|-
| [[#ROL|ROL]]
| [[#ROL|ROL]]
|-
| [[#ROR|ROR]]
| [[#ROR|ROR]]
|-
| [[#SAHF|SAHF]]
| [[#SAHF|MOV]]
|-
| [[#SAR|SAR]]
| [[#SAR|SHRA]]
|-
| [[#SBB|SBB]]
| [[#SBB|SUBC]]
|-
| [[#SCASB|SCASB]]
| [[#SCASB|CMPMB]]
|-
| [[#SCASW|SCASW]]
| [[#SCASW|CMPMW]]
|-
| [[#SHL|SHL]]
| [[#SHL|SHL]]
|-
| [[#SHR|SHR]]
| [[#SHR|SHR]]
|-
| [[#SS|SS]]
| [[#SS|SS]]
|-
| [[#STC|STC]]
| [[#STC|SET1 CY]]
|-
| [[#STD|STD]]
| [[#STD|SET1 DIR]]
|-
| [[#STI|STI]]
| [[#STI|EI]]
|-
| [[#STOSB|STOSB]]
| [[#STOSB|STMB]]
|-
| [[#STOSW|STOSW]]
| [[#STOSW|STMW]]
|-
| [[#SUB|SUB]]
| [[#SUB|SUB]]
|-
| [[#TEST|TEST]]
| [[#TEST|TEST]]
|-
| [[#XCHG|XCHG]]
| [[#XCHG|XCH]]
|-
| [[#XLAT|XLAT]]
| [[#XLAT|TRANS]]
|-
| [[#XOR|XOR]]
| [[#XOR|XOR]]
|}
== Official instructions by type ==
{| class="wikitable sortable" style="text-align: center"
!Type
!colspan=16 class="unsortable" | Instructions
|-
| style="text-align:left;" | Memory
| style="" | [[#MOV|MOV]]
| style="" | [[#XCHG|XCHG]]
| style="" | [[#XLAT|XLAT]]
| style="" | [[#LEA|LEA]]
| style="border-right:none;" | [[#LDS|LDS]]
| style="border-left:none;" | [[#LES|LES]]
| style="border-right:none;" | [[#IN|IN]]
| style="border-left:none;" | [[#OUT|OUT]]
| colspan="8" |
|-
| style="text-align:left;" | Ports
| style="border-right:none;" | [[#IN|IN]]
| style="border-left:none;" | [[#OUT|OUT]]
| style="border-right:none;" | [[#INSB|INSB]]
| style="border-left:none;" | [[#OUTSB|OUTSB]]
| style="border-right:none;" | [[#INSW|INSW]]
| style="border-left:none;" | [[#OUTSW|OUTSW]]
| colspan="10" |
|-
| style="text-align:left;" | Arithmetic
| style="border-right:none;" | [[#ADD|ADD]]
| style="border-left:none;" | [[#SUB|SUB]]
| style="border-right:none;" | [[#ADC|ADC]]
| style="border-left:none;" | [[#SBB|SBB]]
| style="border-right:none;" | [[#INC|INC]]
| style="border-left:none;" | [[#DEC|DEC]]
| style="border-right:none;" | [[#MUL|MUL]]
| style="border-left:none;" | [[#DIV|DIV]]
| style="border-right:none;" | [[#IMUL|IMUL]]
| style="border-left:none;" | [[#IDIV|IDIV]]
| style="" | [[#CMP|CMP]]
| style="" | [[#NEG|NEG]]
| colspan="4" |
|-
| style="text-align:left;" | Numeric
| style="" | [[#CBW|CBW]]
| style="" | [[#CWD|CWD]]
| style="" | [[#AAA|AAA]]
| style="" | [[#AAS|AAS]]
| style="" | [[#AAM|AAM]]
| style="" | [[#AAD|AAD]]
| style="" | [[#DAA|DAA]]
| style="" | [[#DAS|DAS]]
| colspan="8" |
|-
| style="text-align:left;" | Shift
| style="border-right:none;" | [[#ROL|ROL]]
| style="border-left:none;" | [[#ROR|ROR]]
| style="border-right:none;" | [[#RCL|RCL]]
| style="border-left:none;" | [[#RCR|RCR]]
| style="border-right:none;" | [[#SHL|SHL]]
| style="border-left:none;" | [[#SHR|SHR]]
| style="" | [[#SAR|SAR]]
| colspan="9" |
|-
| style="text-align:left;" | Bitwise
| style="" | [[#AND|AND]]
| style="" | [[#OR|OR]]
| style="" | [[#XOR|XOR]]
| style="" | [[#NOT|NOT]]
| style="" | [[#TEST|TEST]]
| colspan="11" |
|-
| style="text-align:left;" | Branch
| style="border-right:none;" | [[#JC|JC]]
| style="border-left:none;" | [[#JNC|JNC]]
| style="border-right:none;" | [[#JZ|JZ]]
| style="border-left:none;" | [[#JNZ|JNZ]]
| style="border-right:none;" | [[#JBE|JBE]]
| style="border-left:none;" | [[#JA|JA]]
| style="border-right:none;" | [[#JO|JO]]
| style="border-left:none;" | [[#JNO|JNO]]
| style="border-right:none;" | [[#JP|JP]]
| style="border-left:none;" | [[#JNP|JNP]]
| style="border-right:none;" | [[#JS|JS]]
| style="border-left:none;" | [[#JNS|JNS]]
| style="border-right:none;" | [[#JL|JL]]
| style="border-left:none;" | [[#JGE|JGE]]
| style="border-right:none;" | [[#JLE|JLE]]
| style="border-left:none;" | [[#JG|JG]]
|-
| style="text-align:left;" | Jump
| style="" | [[#JMP|JMP]]
| style="border-right:none;" | [[#CALL|CALL]]
| style="border-left:none;border-right:none;" | [[#RET|RET]]
| style="border-left:none;" | [[#RETF|RETF]]
| colspan="12" |
|-
| style="text-align:left;" | Loop
| style="" | [[#LOOP|LOOP]]
| style="" | [[#LOOPE|LOOPE]]
| style="" | [[#LOOPNE|LOOPNE]]
| colspan="13" |
|-
| style="text-align:left;" | Interrupt
| style="border-right:none;" | [[#INT|INT]]
| style="border-left:none;" | [[#IRET|IRET]]
| style="" | [[#INTO|INTO]]
| style="" | [[#HLT|HLT]]
| style="" | [[#BOUND|BOUND]]
| colspan="11" |
|-
| style="text-align:left;" | Stack
| style="border-right:none;" | [[#PUSH|PUSH]]
| style="border-left:none;" | [[#POP|POP]]
| style="border-right:none;" | [[#PUSHA|PUSHA]]
| style="border-left:none;" | [[#POPA|POPA]]
| style="border-right:none;" | [[#PUSHF|PUSHF]]
| style="border-left:none;" | [[#POPF|POPF]]
| colspan="10" |
|-
| style="text-align:left;" | Flags
| style="border-right:none;" | [[#CLC|CLC]]
| style="border-left:none;" | [[#STC|STC]]
| style="border-right:none;" | [[#CLD|CLD]]
| style="border-left:none;" | [[#STD|STD]]
| style="border-right:none;" | [[#CLI|CLI]]
| style="border-left:none;" | [[#STI|STI]]
| style="" | [[#CMC|CMC]]
| style="border-right:none;" | [[#LAHF|LAHF]]
| style="border-left:none;" | [[#SAHF|SAHF]]
| colspan="7" |
|-
| style="text-align:left;" | Prefix
| style="" | [[#CS|CS]]
| style="" | [[#DS|DS]]
| style="" | [[#ES|ES]]
| style="" | [[#SS|SS]]
| colspan="12" |
|-
| style="text-align:left;" | String
| style="border-right:none;" | [[#REP|REP]]
| style="border-left:none;border-right:none;" | [[#REP|REPE]]
| style="border-left:none;" | [[#REPNE|REPNE]]
| style="" | [[#MOVSB|MOVSB]]
| style="" | [[#MOVSW|MOVSW]]
| style="border-right:none;" | [[#LODSB|LODSB]]
| style="border-left:none;" | [[#STOSB|STOSB]]
| style="border-right:none;" | [[#LODSW|LODSW]]
| style="border-left:none;" | [[#STOSW|STOSW]]
| style="" | [[#CMPSB|CMPSB]]
| style="" | [[#SCASB|SCASB]]
| style="" | [[#CMPSW|CMPSW]]
| style="" | [[#SCASW|SCASW]]
| colspan="3" |
|-
| style="text-align:left;" | Other
| style="" | [[#NOP|NOP]]
| style="border-right:none;" | [[#ENTER|ENTER]]
| style="border-left:none;" | [[#LEAVE|LEAVE]]
| style="" | [[#LOCK|LOCK]]
| style="" | [[#POLL|POLL]]
| colspan="11" |
|}
== Instruction encoding ==
=== ModR/M byte ===
The ModR/M byte is used in most addressing modes which reference a memory location. This byte consists of three bitfield values:
* <tt>oo</tt> - M'''o'''de;
* <tt>rrr</tt> - Two possible functions:
** '''R'''egister (for addressing modes which require both a register and a register/memory operand),
** Opcode extension (for some opcodes' addressing modes which do not have such a requirement);
* <tt>mmm</tt> - Register/'''M'''emory.
The ''Mode'' and ''Register/Memory'' bitfields can refer to a memory location or to a register, as shown in the table below. In some addressing modes, the ''Register'' field also refers to a register; it is always interpreted as if ''Mode'' was equal to <tt>11</tt>.
{| class="wikitable" style="text-align: center"
! R/M \ Mode
! <tt>00</tt>
! <tt>01</tt>
! <tt>10</tt>
! <tt>11</tt> ''(byte)''
! <tt>11</tt> ''(word)''
|-
| <tt>000</tt>
| DS:[BX + SI]
| DS:[BX + SI + disp8]
| DS:[BX + SI + disp16]
| AL
| AX
|-
| <tt>001</tt>
| DS:[BX + DI]
| DS:[BX + DI + disp8]
| DS:[BX + DI + disp16]
| CL
| CX
|-
| <tt>010</tt>
| SS:[BP + SI]
| SS:[BP + SI + disp8]
| SS:[BP + SI + disp16]
| DL
| DX
|-
| <tt>011</tt>
| SS:[BP + DI]
| SS:[BP + DI + disp8]
| SS:[BP + DI + disp16]
| BL
| BX
|-
| <tt>100</tt>
| DS:[SI]
| DS:[SI + disp8]
| DS:[SI + disp16]
| AH
| SP
|-
| <tt>101</tt>
| DS:[DI]
| DS:[DI + disp8]
| DS:[DI + disp16]
| CH
| BP
|-
| <tt>110</tt>
| ''DS:[disp16]''
| SS:[BP + disp8]
| SS:[BP + disp16]
| DH
| SI
|-
| <tt>111</tt>
| DS:[BX]
| DS:[BX + disp8]
| DS:[BX + disp16]
| BH
| DI
|}
Displacements are either 8-bit (disp8) or 16-bit (disp16) signed values and they always immediately follow the ModR/M byte. Note that (<tt>oo</tt> = <tt>00</tt>, <tt>mmm</tt> = <tt>110</tt>) is a special case, in which the ''disp16'' value is used directly as a near pointer.
The instruction encoding lists below refer to this byte as <tt>oorrrmmm</tt> (binary), <tt>/r</tt> (hexadecimal) or <tt>/0</tt> (hexademical, <tt>rrr</tt> used as function <tt>0</tt>).
== Official instructions ==
{{Anchor|AAA}}
=== AAA ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| AAA || <tt>37</tt> || <tt>00110111</tt> || 1 || 9
|}
----
{{Anchor|AAD}}
=== AAD ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| AAD imm8 || <tt>B5 ii</tt> || <tt>11010100 iiiiiiii</tt> || 2 || 6
|}
----
{{Anchor|AAM}}
=== AAM ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| AAM imm8 || <tt>B4 ii</tt> || <tt>11010100 iiiiiiii</tt> || 2 || 17
|}
----
{{Anchor|AAS}}
=== AAS ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| AAS || <tt>3F</tt> || <tt>00111111</tt> || 1 || 9
|}
----
{{Anchor|ADC}}
=== ADC ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| ADC AL, imm || <tt>14 ii</tt> || <tt>00010100 iiiiiiii</tt> || 2 || 1
|-
| ADC AX, imm || <tt>15 ii ii</tt> || <tt>00010101 iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| ADC mem8, imm8 || <tt>80 /2 ii</tt> || <tt>10000000 oo010mmm iiiiiiii</tt> || 3+ || 3
|-
| ADC mem16, imm16 || <tt>81 /2 ii ii</tt> || <tt>10000001 oo010mmm iiiiiiii iiiiiiii</tt> || 4+ || 3
|-
| ADC mem16, simm8 || <tt>83 /2 ii</tt> || <tt>10000011 oo010mmm iiiiiiii</tt> || 3+ || 3
|-
| ADC mem8, reg8 || <tt>10 /r</tt> || <tt>00010000 oorrrmmm</tt> || 2+ || 3
|-
| ADC mem16, reg16 || <tt>11 /r</tt> || <tt>00010001 oorrrmmm</tt> || 2+ || 3
|-
| ADC reg8, imm8 || <tt>80 /2 ii</tt> || <tt>10000000 11010mmm iiiiiiii</tt> || 3 || 1
|-
| ADC reg16, imm16 || <tt>81 /2 ii ii</tt> || <tt>10000001 11010mmm iiiiiiii iiiiiiii</tt> || 4 || 1
|-
| ADC reg16, simm8 || <tt>83 /2 ii</tt> || <tt>10000011 11010mmm iiiiiiii</tt> || 3 || 1
|-
| ADC reg8, mem8 || <tt>12 /r</tt> || <tt>00010010 oorrrmmm</tt> || 2+ || 2
|-
| ADC reg16, mem16 || <tt>13 /r</tt> || <tt>00010011 oorrrmmm</tt> || 2+ || 2
|-
| ADC reg8, reg8 || <tt>10 /r</tt> || <tt>000100.0 11rrrmmm</tt> || 2 || 1
|-
| ADC reg16, reg16 || <tt>11 /r</tt> || <tt>000100.1 11rrrmmm</tt> || 2 || 1
|}
----
{{Anchor|ADD}}
=== ADD ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| ADD AL, imm || <tt>04 ii</tt> || <tt>00000100 iiiiiiii</tt> || 2 || 1
|-
| ADD AX, imm || <tt>05 ii ii</tt> || <tt>00000101 iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| ADD mem8, imm8 || <tt>80 /0 ii</tt> || <tt>10000000 oo000mmm iiiiiiii</tt> || 3+ || 3
|-
| ADD mem16, imm16 || <tt>81 /0 ii ii</tt> || <tt>10000001 oo000mmm iiiiiiii iiiiiiii</tt> || 4+ || 3
|-
| ADD mem16, simm8 || <tt>83 /0 ii</tt> || <tt>10000011 oo000mmm iiiiiiii</tt> || 3+ || 3
|-
| ADD mem8, reg8 || <tt>00 /r</tt> || <tt>00000000 oorrrmmm</tt> || 2+ || 3
|-
| ADD mem16, reg16 || <tt>01 /r</tt> || <tt>00000001 oorrrmmm</tt> || 2+ || 3
|-
| ADD reg8, imm8 || <tt>80 /0 ii</tt> || <tt>10000000 11000mmm iiiiiiii</tt> || 3 || 1
|-
| ADD reg16, imm16 || <tt>81 /0 ii ii</tt> || <tt>10000001 11000mmm iiiiiiii iiiiiiii</tt> || 4 || 1
|-
| ADD reg16, simm8 || <tt>83 /0 ii</tt> || <tt>10000011 11000mmm iiiiiiii</tt> || 3 || 1
|-
| ADD reg8, mem8 || <tt>02 /r</tt> || <tt>00000010 oorrrmmm</tt> || 2+ || 2
|-
| ADD reg16, mem16 || <tt>03 /r</tt> || <tt>00000011 oorrrmmm</tt> || 2+ || 2
|-
| ADD reg8, reg8 || <tt>00 /r</tt> || <tt>000000.0 11rrrmmm</tt> || 2 || 1
|-
| ADD reg16, reg16 || <tt>01 /r</tt> || <tt>000000.1 11rrrmmm</tt> || 2 || 1
|}
----
{{Anchor|AND}}
=== AND ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| AND AL, imm || <tt>24 ii</tt> || <tt>00100100 iiiiiiii</tt> || 2 || 1
|-
| AND AX, imm || <tt>25 ii ii</tt> || <tt>00100101 iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| AND mem8, imm8 || <tt>80 /4 ii</tt> || <tt>10000000 oo100mmm iiiiiiii</tt> || 3+ || 3
|-
| AND mem16, imm16 || <tt>81 /4 ii ii</tt> || <tt>10000001 oo100mmm iiiiiiii iiiiiiii</tt> || 4+ || 3
|-
| AND mem16, simm8 || <tt>83 /4 ii</tt> || <tt>10000011 oo100mmm iiiiiiii</tt> || 3+ || 3
|-
| AND mem8, reg8 || <tt>20 /r</tt> || <tt>00100000 oorrrmmm</tt> || 2+ || 3
|-
| AND mem16, reg16 || <tt>21 /r</tt> || <tt>00100001 oorrrmmm</tt> || 2+ || 3
|-
| AND reg8, imm8 || <tt>80 /4 ii</tt> || <tt>10000000 11100mmm iiiiiiii</tt> || 3 || 1
|-
| AND reg16, imm16 || <tt>81 /4 ii ii</tt> || <tt>10000001 11100mmm iiiiiiii iiiiiiii</tt> || 4 || 1
|-
| AND reg16, simm8 || <tt>83 /4 ii</tt> || <tt>10000011 11100mmm iiiiiiii</tt> || 3 || 1
|-
| AND reg8, mem8 || <tt>22 /r</tt> || <tt>00100010 oorrrmmm</tt> || 2+ || 2
|-
| AND reg16, mem16 || <tt>23 /r</tt> || <tt>00100011 oorrrmmm</tt> || 2+ || 2
|-
| AND reg8, reg8 || <tt>20 /r</tt> || <tt>001000.0 11rrrmmm</tt> || 2 || 1
|-
| AND reg16, reg16 || <tt>21 /r</tt> || <tt>001000.1 11rrrmmm</tt> || 2 || 1
|}
----
{{Anchor|BOUND}}
=== BOUND ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| BOUND reg16, mem16:16 || <tt>62 /r</tt> || <tt>01100010 oorrrmmm</tt> || 2+ || 13 (20 if condition met)
|}
----
{{Anchor|CALL}}
=== CALL ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| CALL ptr16:16 || <tt>CA oo oo ss ss</tt> || <tt>10011010 oooooooo oooooooo ssssssss ssssssss</tt> || 5 || 10
|-
| CALL mem16 || <tt>FF /2</tt> || <tt>11111111 oo010mmm</tt> || 2+ || 6
|-
| CALL mem16:16 || <tt>FF /3</tt> || <tt>11111111 oo011mmm</tt> || 2+ || 12
|-
| CALL reg16 || <tt>FF /2</tt> || <tt>11111111 11010mmm</tt> || 2 || 5
|-
| CALL rel16 || <tt>E8 ii ii</tt> || <tt>11101000 iiiiiiii iiiiiiii</tt> || 3 || 5
|}
----
{{Anchor|CBW}}
=== CBW ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| CBW || <tt>98</tt> || <tt>10011000</tt> || 1 || 1
|}
----
{{Anchor|CLC}}
=== CLC ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| CLC || <tt>F8</tt> || <tt>11111000</tt> || 1 || 4
|}
----
{{Anchor|CLD}}
=== CLD ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| CLD || <tt>FC</tt> || <tt>11111100</tt> || 1 || 4
|}
----
{{Anchor|CLI}}
=== CLI ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| CLI || <tt>FA</tt> || <tt>11111010</tt> || 1 || 4
|}
----
{{Anchor|CMC}}
=== CMC ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| CMC || <tt>F5</tt> || <tt>11110101</tt> || 1 || 4
|}
----
{{Anchor|CMP}}
=== CMP ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| CMP AL, imm || <tt>3C ii</tt> || <tt>00111100 iiiiiiii</tt> || 2 || 1
|-
| CMP AX, imm || <tt>3D ii ii</tt> || <tt>00111101 iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| CMP mem8, imm8 || <tt>80 /7 ii</tt> || <tt>10000000 oo111mmm iiiiiiii</tt> || 3+ || 2
|-
| CMP mem16, imm16 || <tt>81 /7 ii ii</tt> || <tt>10000001 oo111mmm iiiiiiii iiiiiiii</tt> || 4+ || 2
|-
| CMP mem16, simm8 || <tt>83 /7 ii</tt> || <tt>10000011 oo111mmm iiiiiiii</tt> || 3+ || 2
|-
| CMP mem8, reg8 || <tt>38 /r</tt> || <tt>00111000 oorrrmmm</tt> || 2+ || 2
|-
| CMP mem16, reg16 || <tt>39 /r</tt> || <tt>00111001 oorrrmmm</tt> || 2+ || 2
|-
| CMP reg8, imm8 || <tt>80 /7 ii</tt> || <tt>10000000 11111mmm iiiiiiii</tt> || 3 || 1
|-
| CMP reg16, imm16 || <tt>81 /7 ii ii</tt> || <tt>10000001 11111mmm iiiiiiii iiiiiiii</tt> || 4 || 1
|-
| CMP reg16, simm8 || <tt>83 /7 ii</tt> || <tt>10000011 11111mmm iiiiiiii</tt> || 3 || 1
|-
| CMP reg8, mem8 || <tt>3A /r</tt> || <tt>00111010 oorrrmmm</tt> || 2+ || 2
|-
| CMP reg16, mem16 || <tt>3B /r</tt> || <tt>00111011 oorrrmmm</tt> || 2+ || 2
|-
| CMP reg8, reg8 || <tt>38 /r</tt> || <tt>001110.0 11rrrmmm</tt> || 2 || 1
|-
| CMP reg16, reg16 || <tt>39 /r</tt> || <tt>001110.1 11rrrmmm</tt> || 2 || 1
|}
----
{{Anchor|CMPSB}}
{{Anchor|CMPSW}}
=== CMPSB/CMPSW ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| CMPSB || <tt>A6</tt> || <tt>10100110</tt> || 1 || 6
|-
| CMPSW || <tt>A7</tt> || <tt>10100111</tt> || 1 || 6
|}
----
{{Anchor|CS}}
=== CS ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| CS || <tt>2E</tt> || <tt>00101110</tt> || 1 || 1
|}
----
{{Anchor|CWD}}
=== CWD ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| CWD || <tt>99</tt> || <tt>10011001</tt> || 1 || 1
|}
----
{{Anchor|DAA}}
=== DAA ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| DAA || <tt>27</tt> || <tt>00100111</tt> || 1 || 10
|}
----
{{Anchor|DAS}}
=== DAS ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| DAS || <tt>2F</tt> || <tt>00101111</tt> || 1 || 10
|}
----
{{Anchor|DEC}}
=== DEC ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| DEC mem8 || <tt>FE /1</tt> || <tt>11111110 oo001mmm</tt> || 2+ || 3
|-
| DEC mem16 || <tt>FF /1</tt> || <tt>11111111 oo001mmm</tt> || 2+ || 3
|-
| DEC reg8 || <tt>FE /1</tt> || <tt>11111110 11001mmm</tt> || 2+ || 1
|-
| DEC reg16 || <tt>4x</tt> || <tt>01001rrr</tt> || 1 || 1
|}
----
{{Anchor|DIV}}
=== DIV ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| DIV mem8 || <tt>F6 /6</tt> || <tt>11110110 oo110mmm</tt> || 2+ || 16
|-
| DIV mem16 || <tt>F7 /6</tt> || <tt>11111111 oo110mmm</tt> || 2+ || 24
|-
| DIV reg8 || <tt>F6 /6</tt> || <tt>11111110 11110mmm</tt> || 2 || 15
|-
| DIV reg16 || <tt>F7 /6</tt> || <tt>11111111 11110mmm</tt> || 2 || 23
|}
----
{{Anchor|DS}}
=== DS ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| DS || <tt>3E</tt> || <tt>00111110</tt> || 1 || 1
|}
----
{{Anchor|ENTER}}
=== ENTER ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| ENTER imm16, imm8 || <tt>C8 ii ii jj</tt> || <tt>11001000 iiiiiiii iiiiiiii jjjjjjjj</tt> || 3 || 8 (imm8 = 0)<br/>14 (imm8 = 1)<br/>15 + imm8 * 4 (imm8 >= 2)
|}
----
{{Anchor|ES}}
=== ES ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| ES || <tt>26</tt> || <tt>00100110</tt> || 1 || 1
|}
----
{{Anchor|HLT}}
=== HLT ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| HLT || <tt>F4</tt> || <tt>11110100</tt> || 1 || 9
|}
----
{{Anchor|IDIV}}
=== IDIV ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| IDIV mem8 || <tt>F6 /7</tt> || <tt>11110110 oo111mmm</tt> || 2+ || 18
|-
| IDIV mem16 || <tt>F7 /7</tt> || <tt>11111111 oo111mmm</tt> || 2+ || 25
|-
| IDIV reg8 || <tt>F6 /7</tt> || <tt>11111110 11111mmm</tt> || 2 || 17
|-
| IDIV reg16 || <tt>F7 /7</tt> || <tt>11111111 11111mmm</tt> || 2 || 24
|}
----
{{Anchor|IMUL}}
=== IMUL ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| IMUL mem8 || <tt>F6 /5</tt> || <tt>11110110 oo101mmm</tt> || 2+ || 4
|-
| IMUL mem16 || <tt>F7 /5</tt> || <tt>11111111 oo101mmm</tt> || 2+ || 4
|-
| IMUL reg8 || <tt>F6 /5</tt> || <tt>11111110 11101mmm</tt> || 2 || 3
|-
| IMUL reg16 || <tt>F7 /5</tt> || <tt>11111111 11101mmm</tt> || 2 || 3
|-
| IMUL reg16, mem16, imm16 || <tt>69 /r ii ii</tt> || <tt>11111111 oorrrmmm iiiiiiii iiiiiiii</tt> || 4 || 4
|-
| IMUL reg16, mem16, simm8 || <tt>6B /r ii</tt> || <tt>11111111 oorrrmmm iiiiiiii</tt> || 3 || 4
|-
| IMUL reg16, reg16, imm16 || <tt>69 /r ii ii</tt> || <tt>11111111 11rrrmmm iiiiiiii iiiiiiii</tt> || 4 || 3
|-
| IMUL reg16, reg16, simm8 || <tt>6B /r ii</tt> || <tt>11111111 11rrrmmm iiiiiiii</tt> || 3 || 3
|}
----
{{Anchor|IN}}
=== IN ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| IN AL, DX || <tt>EC</tt> || <tt>11101100</tt> || 1 || 6
|-
| IN AX, DX || <tt>ED</tt> || <tt>11101101</tt> || 1 || 6
|-
| IN AL, imm8 || <tt>E4 ii</tt> || <tt>11100100 iiiiiiii</tt> || 2 || 6
|-
| IN AX, imm8 || <tt>E5 ii</tt> || <tt>11100101 iiiiiiii</tt> || 2 || 6
|}
----
{{Anchor|INC}}
=== INC ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| INC mem8 || <tt>FE /0</tt> || <tt>11111110 oo000mmm</tt> || 2+ || 3
|-
| INC mem16 || <tt>FF /0</tt> || <tt>11111111 oo000mmm</tt> || 2+ || 3
|-
| INC reg8 || <tt>FE /0</tt> || <tt>11111110 11000mmm</tt> || 2+ || 1
|-
| INC reg16 || <tt>4x</tt> || <tt>01000rrr</tt> || 1 || 1
|}
----
{{Anchor|INSB}}
{{Anchor|INSW}}
=== INSB/INSW ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| INSB || <tt>6C</tt> || <tt>01101100</tt> || 1 || 6
|-
| INSW || <tt>6D</tt> || <tt>01101101</tt> || 1 || 6
|}
----
{{Anchor|INT}}
=== INT ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| INT 3 || <tt>CC</tt> || <tt>11001100</tt> || 1 || 9
|-
| INT imm8 || <tt>CD ii</tt> || <tt>11001101 iiiiiiii</tt> || 2 || 10
|}
----
{{Anchor|INTO}}
=== INTO ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| INTO || <tt>CE</tt> || <tt>11001110</tt> || 1 || 6 (13 if OF = 1)
|}
----
{{Anchor|IRET}}
=== IRET ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| IRET || <tt>CF</tt> || <tt>11001111</tt> || 1 || 10
|}
----
{{Anchor|JA}}
=== JA ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JA rel8 || <tt>77 ii</tt> || <tt>01110111 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JBE}}
=== JBE ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JA rel8 || <tt>76 ii</tt> || <tt>01110110 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JC}}
=== JC/JB ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JC rel8 || <tt>72 ii</tt> || <tt>01110010 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JCXZ}}
=== JCXZ ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JCXZ rel8 || <tt>E3 ii</tt> || <tt>11100011 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JG}}
=== JG ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JG rel8 || <tt>7F ii</tt> || <tt>01111111 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JGE}}
=== JGE ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JGE rel8 || <tt>7D ii</tt> || <tt>01111101 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JL}}
=== JL ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JL rel8 || <tt>7C ii</tt> || <tt>01111100 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JLE}}
=== JLE ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JLE rel8 || <tt>7E ii</tt> || <tt>01111110 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JMP}}
=== JMP ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JMP ptr16:16 || <tt>EA oo oo ss ss</tt> || <tt>11101010 oooooooo oooooooo ssssssss ssssssss</tt> || 5 || 7
|-
| JMP mem16 || <tt>FF /4</tt> || <tt>11111111 oo100mmm</tt> || 2+ || 5
|-
| JMP mem16:16 || <tt>FF /5</tt> || <tt>11111111 oo101mmm</tt> || 2+ || 10
|-
| JMP reg16 || <tt>FF /4</tt> || <tt>11111111 11100mmm</tt> || 2 || 4
|-
| JMP rel8 || <tt>EB ii</tt> || <tt>11101011 iiiiiiii</tt> || 2 || 4
|-
| JMP rel16 || <tt>E9 ii ii</tt> || <tt>11101001 iiiiiiii iiiiiiii</tt> || 3 || 4
|}
----
{{Anchor|JNC}}
=== JNC/JAE ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JNC rel8 || <tt>73 ii</tt> || <tt>01110011 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JNO}}
=== JNO ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JNO rel8 || <tt>71 ii</tt> || <tt>01110001 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JNP}}
=== JNP ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JNP rel8 || <tt>7B ii</tt> || <tt>01111011 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JNS}}
=== JNS ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JNS rel8 || <tt>79 ii</tt> || <tt>01111001 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JNZ}}
=== JNZ/JNE ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JNZ rel8 || <tt>75 ii</tt> || <tt>01110101 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JO}}
=== JO ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JO rel8 || <tt>70 ii</tt> || <tt>01110000 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JP}}
=== JP ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JP rel8 || <tt>7A ii</tt> || <tt>01111010 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JS}}
=== JS ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JS rel8 || <tt>78 ii</tt> || <tt>01111000 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JZ}}
=== JZ/JE ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JZ rel8 || <tt>74 ii</tt> || <tt>01110100 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|LAHF}}
=== LAHF ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| LAHF || <tt>9F</tt> || <tt>10011111</tt> || 1 || 2
|}
----
{{Anchor|LDS}}
=== LDS ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| LDS reg16, mem16 || <tt>C5 /r</tt> || <tt>11000101 oorrrmmm</tt> || 2+ || 6
|}
----
{{Anchor|LEA}}
=== LEA ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| LEA reg16, mem16 || <tt>8D /r</tt> || <tt>10001101 oorrrmmm</tt> || 2+ || 1
|}
----
{{Anchor|LEAVE}}
=== LEAVE ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| LEAVE || <tt>C9</tt> || <tt>11001001</tt> || 1 || 2
|}
----
{{Anchor|LES}}
=== LES ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| LES reg16, mem16 || <tt>C4 /r</tt> || <tt>11000100 oorrrmmm</tt> || 2+ || 6
|}
----
{{Anchor|LOCK}}
=== LOCK ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| LOCK || <tt>F0</tt> || <tt>11110000</tt> || 1 || 1
|}
----
{{Anchor|LODSB}}
{{Anchor|LODSW}}
=== LODSB/LODSW ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| LODSB || <tt>AC</tt> || <tt>10101100</tt> || 1 || 3
|-
| LODSW || <tt>AD</tt> || <tt>10101101</tt> || 1 || 3
|}
----
{{Anchor|LOOP}}
=== LOOP ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| LOOP rel8 || <tt>E2 ii</tt> || <tt>11100010 iiiiiiii</tt> || 2 || 2 (5 if branch taken)
|}
----
{{Anchor|LOOPE}}
=== LOOPE ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| LOOPE rel8 || <tt>E1 ii</tt> || <tt>11100001 iiiiiiii</tt> || 2 || 3 (6 if branch taken)
|}
----
{{Anchor|LOOPNE}}
=== LOOPNE ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| LOOPNE rel8 || <tt>E0 ii</tt> || <tt>11100000 iiiiiiii</tt> || 2 || 3 (6 if branch taken)
|}
----
{{Anchor|MOV}}
=== MOV ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| MOV AL, ptr16 || <tt>A0 ii ii</tt> || <tt>10100000 iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| MOV AX, ptr16 || <tt>A1 ii ii</tt> || <tt>10100001 iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| MOV mem8, imm8 || <tt>C6 /0 ii</tt> || <tt>11000110 oo000mmm iiiiiiii</tt> || 3+ || 1
|-
| MOV mem16, imm16 || <tt>C7 /0 ii ii</tt> || <tt>11000111 oo000mmm iiiiiiii iiiiiiii</tt> || 4+ || 1
|-
| MOV mem8, reg8 || <tt>84 /r</tt> || <tt>10001000 oorrrmmm</tt> || 2+ || 1
|-
| MOV mem16, reg16 || <tt>85 /r</tt> || <tt>10001001 oorrrmmm</tt> || 2+ || 1
|-
| MOV mem16, sreg16 || <tt>8C /r</tt> || <tt>10001100 oo0rrmmm</tt> || 2+ || 3
|-
| MOV ptr16, AL || <tt>A2 ii ii</tt> || <tt>10100010 iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| MOV ptr16, AX || <tt>A3 ii ii</tt> || <tt>10100011 iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| MOV reg8, imm8 || <tt>Bx ii</tt> || <tt>10110rrr iiiiiiii</tt> || 2 || 1
|-
| MOV reg8, imm8 || <tt>C6 /0 ii</tt> || <tt>11000110 11000mmm iiiiiiii</tt> || 3 || 1
|-
| MOV reg16, imm16 || <tt>Bx ii</tt> || <tt>10111rrr iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| MOV reg16, imm16 || <tt>C7 /0 ii ii</tt> || <tt>11000111 11000mmm iiiiiiii iiiiiiii</tt> || 4 || 1
|-
| MOV reg8, mem8 || <tt>8A /r</tt> || <tt>10001010 oorrrmmm</tt> || 2+ || 1
|-
| MOV reg16, mem16 || <tt>8B /r</tt> || <tt>10001011 oorrrmmm</tt> || 2+ || 1
|-
| MOV reg8, reg8 || <tt>88 /r</tt> || <tt>100010.0 11rrrmmm</tt> || 2 || 1
|-
| MOV reg16, reg16 || <tt>89 /r</tt> || <tt>100010.1 11rrrmmm</tt> || 2 || 1
|-
| MOV reg16, sreg16 || <tt>8C /r</tt> || <tt>10001100 110rrmmm</tt> || 2 || 1
|-
| MOV sreg16, mem16 || <tt>8E /r</tt> || <tt>10001110 oo0rrmmm</tt> || 2 || 3
|-
| MOV sreg16, reg16 || <tt>8E /r</tt> || <tt>10001110 110rrmmm</tt> || 2+ || 2
|}
----
{{Anchor|MOVSB}}
{{Anchor|MOVSW}}
=== MOVSB/MOVSW ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| MOVSB || <tt>A4</tt> || <tt>10100100</tt> || 1 || 5
|-
| MOVSW || <tt>A5</tt> || <tt>10100101</tt> || 1 || 5
|}
----
{{Anchor|MUL}}
=== MUL ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| MUL mem8 || <tt>F6 /4</tt> || <tt>11110110 oo100mmm</tt> || 2+ || 4
|-
| MUL mem16 || <tt>F7 /4</tt> || <tt>11111111 oo100mmm</tt> || 2+ || 4
|-
| MUL reg8 || <tt>F6 /4</tt> || <tt>11111110 11100mmm</tt> || 2 || 3
|-
| MUL reg16 || <tt>F7 /4</tt> || <tt>11111111 11100mmm</tt> || 2 || 3
|}
----
{{Anchor|NEG}}
=== NEG ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| NEG mem8 || <tt>F6 /3</tt> || <tt>11110110 oo011mmm</tt> || 2+ || 3
|-
| NEG mem16 || <tt>F7 /3</tt> || <tt>11111111 oo011mmm</tt> || 2+ || 3
|-
| NEG reg8 || <tt>F6 /3</tt> || <tt>11111110 11011mmm</tt> || 2 || 1
|-
| NEG reg16 || <tt>F7 /3</tt> || <tt>11111111 11011mmm</tt> || 2 || 1
|}
----
{{Anchor|NOP}}
=== NOP ===
----
{{Anchor|NOT}}
=== NOT ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| NOT mem8 || <tt>F6 /2</tt> || <tt>11110110 oo010mmm</tt> || 2+ || 3
|-
| NOT mem16 || <tt>F7 /2</tt> || <tt>11111111 oo010mmm</tt> || 2+ || 3
|-
| NOT reg8 || <tt>F6 /2</tt> || <tt>11111110 11010mmm</tt> || 2 || 1
|-
| NOT reg16 || <tt>F7 /2</tt> || <tt>11111111 11010mmm</tt> || 2 || 1
|}
----
{{Anchor|OR}}
=== OR ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| OR AL, imm || <tt>0C ii</tt> || <tt>00001100 iiiiiiii</tt> || 2 || 1
|-
| OR AX, imm || <tt>0D ii ii</tt> || <tt>00001101 iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| OR mem8, imm8 || <tt>80 /6 ii</tt> || <tt>10000000 oo001mmm iiiiiiii</tt> || 3+ || 3
|-
| OR mem16, imm16 || <tt>81 /6 ii ii</tt> || <tt>10000001 oo001mmm iiiiiiii iiiiiiii</tt> || 4+ || 3
|-
| OR mem16, simm8 || <tt>83 /6 ii</tt> || <tt>10000011 oo001mmm iiiiiiii</tt> || 3+ || 3
|-
| OR mem8, reg8 || <tt>08 /r</tt> || <tt>00001000 oorrrmmm</tt> || 2+ || 3
|-
| OR mem16, reg16 || <tt>09 /r</tt> || <tt>00001001 oorrrmmm</tt> || 2+ || 3
|-
| OR reg8, imm8 || <tt>80 /6 ii</tt> || <tt>10000000 11001mmm iiiiiiii</tt> || 3 || 1
|-
| OR reg16, imm16 || <tt>81 /6 ii ii</tt> || <tt>10000001 11001mmm iiiiiiii iiiiiiii</tt> || 4 || 1
|-
| OR reg16, simm8 || <tt>83 /6 ii</tt> || <tt>10000011 11001mmm iiiiiiii</tt> || 3 || 1
|-
| OR reg8, mem8 || <tt>0A /r</tt> || <tt>00001010 oorrrmmm</tt> || 2+ || 2
|-
| OR reg16, mem16 || <tt>0B /r</tt> || <tt>00001011 oorrrmmm</tt> || 2+ || 2
|-
| OR reg8, reg8 || <tt>08 /r</tt> || <tt>000010.0 11rrrmmm</tt> || 2 || 1
|-
| OR reg16, reg16 || <tt>09 /r</tt> || <tt>000010.1 11rrrmmm</tt> || 2 || 1
|}
----
{{Anchor|OUT}}
=== OUT ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| OUT AL, DX || <tt>EE</tt> || <tt>11101110</tt> || 1 || 6
|-
| OUT AX, DX || <tt>EF</tt> || <tt>11101111</tt> || 1 || 6
|-
| OUT AL, imm8 || <tt>E6 ii</tt> || <tt>11100110 iiiiiiii</tt> || 2 || 6
|-
| OUT AX, imm8 || <tt>E7 ii</tt> || <tt>11100111 iiiiiiii</tt> || 2 || 6
|}
----
{{Anchor|OUTSB}}
{{Anchor|OUTSW}}
=== OUTSB/OUTSW ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| OUTSB || <tt>6E</tt> || <tt>01101110</tt> || 1 || 6
|-
| OUTSW || <tt>6F</tt> || <tt>01101111</tt> || 1 || 6
|}
----
{{Anchor|POLL}}
=== POLL ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| POLL || <tt>6E</tt> || <tt>01101110</tt> || 1 || 9<ref>On the WonderSwan implementation, POLLB is always held low; on other implementations, POLL will wait for POLLB to be held low in 9-cycle intervals.</ref>
|}
----
{{Anchor|POP}}
=== POP ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| POP mem16 || <tt>8F /0</tt> || <tt>10001111 oo000mmm</tt> || 2+ || 3
|-
| POP reg16 || <tt>5x</tt> || <tt>01011xxx</tt> || 1 || 1
|-
| POP reg16 || <tt>8F /0</tt> || <tt>10001111 11000mmm</tt> || 2 || 1
|-
| POP sreg16 || <tt>xx</tt> || <tt>000xx111</tt> || 1 || 3
|}
----
{{Anchor|POPA}}
=== POPA ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| POPA || <tt>61</tt> || <tt>01100001</tt> || 1 || 8
|}
----
{{Anchor|POPF}}
=== POPF ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| POPF || <tt>9D</tt> || <tt>10011101</tt> || 1 || 3
|}
----
{{Anchor|PUSH}}
=== PUSH ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| PUSH imm8 || <tt>6A ii</tt> || <tt>01101010 iiiiiiii</tt> || 2 || 1
|-
| PUSH imm16 || <tt>68 ii ii</tt> || <tt>01101000 iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| PUSH mem16 || <tt>FF /6</tt> || <tt>11111111 oo110mmm</tt> || 2+ || 2
|-
| PUSH reg16 || <tt>5x</tt> || <tt>01010xxx</tt> || 1 || 1
|-
| PUSH reg16 || <tt>FF /6</tt> || <tt>11111111 11110mmm</tt> || 2 || 1
|-
| PUSH sreg16 || <tt>xx</tt> || <tt>000xx110</tt> || 1 || 2
|}
----
{{Anchor|PUSHA}}
=== PUSHA ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| PUSHA || <tt>60</tt> || <tt>01100000</tt> || 1 || 9
|}
----
{{Anchor|PUSHF}}
=== PUSHF ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| PUSHF || <tt>9C</tt> || <tt>10011100</tt> || 1 || 2
|}
----
{{Anchor|RCL}}
=== RCL ===
----
{{Anchor|RCR}}
=== RCR ===
----
{{Anchor|REP}}
=== REP/REPE/REPZ ===
----
{{Anchor|REPNE}}
=== REPNE/REPNZ ===
----
{{Anchor|RET}}
=== RET ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| RET || <tt>C3</tt> || <tt>11000011</tt> || 1 || 6
|-
| RET imm16 || <tt>C2 ii ii</tt> || <tt>11000010 iiiiiiii iiiiiiii</tt> || 1 || 6
|}
----
{{Anchor|RETF}}
=== RETF ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| RETF || <tt>CB</tt> || <tt>11001011</tt> || 1 || 9
|-
| RETF imm16 || <tt>CA ii ii</tt> || <tt>11001010 iiiiiiii iiiiiiii</tt> || 1 || 8
|}
----
{{Anchor|ROL}}
=== ROL ===
----
{{Anchor|ROR}}
=== ROR ===
----
{{Anchor|SAHF}}
=== SAHF ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| SAHF || <tt>9E</tt> || <tt>10011110</tt> || 1 || 4
|}
----
{{Anchor|SAR}}
=== SAR ===
----
{{Anchor|SBB}}
=== SBB ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| SBB AL, imm || <tt>1C ii</tt> || <tt>00011100 iiiiiiii</tt> || 2 || 1
|-
| SBB AX, imm || <tt>1D ii ii</tt> || <tt>00011101 iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| SBB mem8, imm8 || <tt>80 /3 ii</tt> || <tt>10000000 oo011mmm iiiiiiii</tt> || 3+ || 3
|-
| SBB mem16, imm16 || <tt>81 /3 ii ii</tt> || <tt>10000001 oo011mmm iiiiiiii iiiiiiii</tt> || 4+ || 3
|-
| SBB mem16, simm8 || <tt>83 /3 ii</tt> || <tt>10000011 oo011mmm iiiiiiii</tt> || 3+ || 3
|-
| SBB mem8, reg8 || <tt>18 /r</tt> || <tt>00011000 oorrrmmm</tt> || 2+ || 3
|-
| SBB mem16, reg16 || <tt>19 /r</tt> || <tt>00011001 oorrrmmm</tt> || 2+ || 3
|-
| SBB reg8, imm8 || <tt>80 /3 ii</tt> || <tt>10000000 11011mmm iiiiiiii</tt> || 3 || 1
|-
| SBB reg16, imm16 || <tt>81 /3 ii ii</tt> || <tt>10000001 11011mmm iiiiiiii iiiiiiii</tt> || 4 || 1
|-
| SBB reg16, simm8 || <tt>83 /3 ii</tt> || <tt>10000011 11011mmm iiiiiiii</tt> || 3 || 1
|-
| SBB reg8, mem8 || <tt>1A /r</tt> || <tt>00011010 oorrrmmm</tt> || 2+ || 2
|-
| SBB reg16, mem16 || <tt>1B /r</tt> || <tt>00011011 oorrrmmm</tt> || 2+ || 2
|-
| SBB reg8, reg8 || <tt>18 /r</tt> || <tt>000110.0 11rrrmmm</tt> || 2 || 1
|-
| SBB reg16, reg16 || <tt>19 /r</tt> || <tt>000110.1 11rrrmmm</tt> || 2 || 1
|}
----
{{Anchor|SCASB}}
{{Anchor|SCASW}}
=== SCASB/SCASW ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| SCASB || <tt>AE</tt> || <tt>10101110</tt> || 1 || 4
|-
| SCASW || <tt>AF</tt> || <tt>10101111</tt> || 1 || 4
|}
----
{{Anchor|SHL}}
=== SHL ===
----
{{Anchor|SHR}}
=== SHR ===
----
{{Anchor|SS}}
=== SS ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| SS || <tt>36</tt> || <tt>00110110</tt> || 1 || 1
|}
----
{{Anchor|STC}}
=== STC ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| STC || <tt>F9</tt> || <tt>11111001</tt> || 1 || 4
|}
----
{{Anchor|STD}}
=== STD ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| STD || <tt>FD</tt> || <tt>11111101</tt> || 1 || 4
|}
----
{{Anchor|STI}}
=== STI ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| STI || <tt>FB</tt> || <tt>11111011</tt> || 1 || 4
|}
----
{{Anchor|STOSB}}
{{Anchor|STOSW}}
=== STOSB/STOSW ===
----
{{Anchor|SUB}}
=== SUB ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| SUB AL, imm || <tt>28 ii</tt> || <tt>00101100 iiiiiiii</tt> || 2 || 1
|-
| SUB AX, imm || <tt>29 ii ii</tt> || <tt>00101101 iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| SUB mem8, imm8 || <tt>80 /5 ii</tt> || <tt>10000000 oo101mmm iiiiiiii</tt> || 3+ || 3
|-
| SUB mem16, imm16 || <tt>81 /5 ii ii</tt> || <tt>10000001 oo101mmm iiiiiiii iiiiiiii</tt> || 4+ || 3
|-
| SUB mem16, simm8 || <tt>83 /5 ii</tt> || <tt>10000011 oo101mmm iiiiiiii</tt> || 3+ || 3
|-
| SUB mem8, reg8 || <tt>28 /r</tt> || <tt>00101000 oorrrmmm</tt> || 2+ || 3
|-
| SUB mem16, reg16 || <tt>29 /r</tt> || <tt>00101001 oorrrmmm</tt> || 2+ || 3
|-
| SUB reg8, imm8 || <tt>80 /5 ii</tt> || <tt>10000000 11101mmm iiiiiiii</tt> || 3 || 1
|-
| SUB reg16, imm16 || <tt>81 /5 ii ii</tt> || <tt>10000001 11101mmm iiiiiiii iiiiiiii</tt> || 4 || 1
|-
| SUB reg16, simm8 || <tt>83 /5 ii</tt> || <tt>10000011 11101mmm iiiiiiii</tt> || 3 || 1
|-
| SUB reg8, mem8 || <tt>2A /r</tt> || <tt>00101010 oorrrmmm</tt> || 2+ || 2
|-
| SUB reg16, mem16 || <tt>2B /r</tt> || <tt>00101011 oorrrmmm</tt> || 2+ || 2
|-
| SUB reg8, reg8 || <tt>28 /r</tt> || <tt>001010.0 11rrrmmm</tt> || 2 || 1
|-
| SUB reg16, reg16 || <tt>29 /r</tt> || <tt>001010.1 11rrrmmm</tt> || 2 || 1
|}
----
{{Anchor|TEST}}
=== TEST ===
----
{{Anchor|XCHG}}
=== XCHG ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| XCHG AX, reg16<br/>XCHG reg16, AX || <tt>9x</tt> || <tt>10010rrr</tt> || 1 || 3
|-
| XCHG mem8, reg8<br/>XCHG reg8, mem8 || <tt>86 /r</tt> || <tt>10000110 oorrrmmm</tt> || 2+ || 5
|-
| XCHG mem16, reg16<br/>XCHG reg16, mem16 || <tt>87 /r</tt> || <tt>10000111 oorrrmmm</tt> || 2+ || 5
|-
| XCHG reg8, reg8 || <tt>86 /r</tt> || <tt>10000110 11rrrmmm</tt> || 2+ || 3
|-
| XCHG reg16, reg16 || <tt>87 /r</tt> || <tt>10000111 11rrrmmm</tt> || 2+ || 3
|}
----
{{Anchor|XLAT}}
=== XLAT ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| XLAT || <tt>D7</tt> || <tt>11010111</tt> || 1 || 5
|}
----
{{Anchor|XOR}}
=== XOR ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| XOR AL, imm || <tt>34 ii</tt> || <tt>00110100 iiiiiiii</tt> || 2 || 1
|-
| XOR AX, imm || <tt>35 ii ii</tt> || <tt>00110101 iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| XOR mem8, imm8 || <tt>80 /6 ii</tt> || <tt>10000000 oo110mmm iiiiiiii</tt> || 3+ || 3
|-
| XOR mem16, imm16 || <tt>81 /6 ii ii</tt> || <tt>10000001 oo110mmm iiiiiiii iiiiiiii</tt> || 4+ || 3
|-
| XOR mem16, simm8 || <tt>83 /6 ii</tt> || <tt>10000011 oo110mmm iiiiiiii</tt> || 3+ || 3
|-
| XOR mem8, reg8 || <tt>30 /r</tt> || <tt>00110000 oorrrmmm</tt> || 2+ || 3
|-
| XOR mem16, reg16 || <tt>31 /r</tt> || <tt>00110001 oorrrmmm</tt> || 2+ || 3
|-
| XOR reg8, imm8 || <tt>80 /6 ii</tt> || <tt>10000000 11110mmm iiiiiiii</tt> || 3 || 1
|-
| XOR reg16, imm16 || <tt>81 /6 ii ii</tt> || <tt>10000001 11110mmm iiiiiiii iiiiiiii</tt> || 4 || 1
|-
| XOR reg16, simm8 || <tt>83 /6 ii</tt> || <tt>10000011 11110mmm iiiiiiii</tt> || 3 || 1
|-
| XOR reg8, mem8 || <tt>32 /r</tt> || <tt>00110010 oorrrmmm</tt> || 2+ || 2
|-
| XOR reg16, mem16 || <tt>33 /r</tt> || <tt>00110011 oorrrmmm</tt> || 2+ || 2
|-
| XOR reg8, reg8 || <tt>30 /r</tt> || <tt>001100.0 11rrrmmm</tt> || 2 || 1
|-
| XOR reg16, reg16 || <tt>31 /r</tt> || <tt>001100.1 11rrrmmm</tt> || 2 || 1
|}
----
== Notes ==
<references />
cc3a0f22b8f0018bc76f531c3eb0765f5274351f
460
459
2024-12-27T23:32:57Z
Asie
351
wikitext
text/x-wiki
__NOTOC__
Note that this page is a work in progress.
{| class="wikitable" style="text-align: center"
|+ Official V30MZ (80186) Instructions
|-
| [[#AAA|AAA]] || [[#AAD|AAD]] || [[#AAM|AAM]] || [[#AAS|AAS]] || [[#ADC|ADC]] || [[#ADD|ADD]] || [[#AND|AND]] || [[#BOUND|BOUND]] || [[#CALL|CALL]] || [[#CBW|CBW]] || [[#CLC|CLC]]
|-
| [[#CLD|CLD]] || [[#CLI|CLI]] || [[#CMC|CMC]] || [[#CMP|CMP]] || [[#CMPSB|CMPSB]] || [[#CMPSW|CMPSW]] || [[#CS|CS]] || [[#CWD|CWD]] || [[#DAA|DAA]] || [[#DAS|DAS]] || [[#DEC|DEC]]
|-
| [[#DIV|DIV]] || [[#DS|DS]] || [[#ENTER|ENTER]] || [[#ES|ES]] || [[#HLT|HLT]] || [[#IDIV|IDIV]] || [[#IMUL|IMUL]] || [[#IN|IN]] || [[#INC|INC]] || [[#INSB|INSB]] || [[#INSW|INSW]]
|-
| [[#INT|INT]] || [[#INTO|INTO]] || [[#IRET|IRET]] || [[#JA|JA]] || [[#JBE|JBE]] || [[#JC|JC]] || [[#JCXZ|JCXZ]] || [[#JG|JG]] || [[#JGE|JGE]] || [[#JL|JL]] || [[#JLE|JLE]]
|-
| [[#JMP|JMP]] || [[#JNC|JNC]] || [[#JNO|JNO]] || [[#JNP|JNP]] || [[#JNS|JNS]] || [[#JNZ|JNZ]] || [[#JO|JO]] || [[#JP|JP]] || [[#JS|JS]] || [[#JZ|JZ]] || [[#LAHF|LAHF]]
|-
| [[#LDS|LDS]] || [[#LEA|LEA]] || [[#LEAVE|LEAVE]] || [[#LES|LES]] || [[#LOCK|LOCK]] || [[#LODSB|LODSB]] || [[#LODSW|LODSW]] || [[#LOOP|LOOP]] || [[#LOOPE|LOOPE]] || [[#LOOPNE|LOOPNE]] || [[#MOV|MOV]]
|-
| [[#MOVSB|MOVSB]] || [[#MOVSW|MOVSW]] || [[#MUL|MUL]] || [[#NEG|NEG]] || [[#NOP|NOP]] || [[#NOT|NOT]] || [[#OR|OR]] || [[#OUT|OUT]] || [[#OUTSB|OUTSB]] || [[#OUTSW|OUTSW]] || [[#POLL|POLL]]
|-
| [[#POP|POP]] || [[#POPA|POPA]] || [[#POPF|POPF]] || [[#PUSH|PUSH]] || [[#PUSHA|PUSHA]] || [[#PUSHF|PUSHF]] || [[#RCL|RCL]] || [[#RCR|RCR]] || [[#REP|REP]] || [[#REPNE|REPNE]] || [[#RET|RET]]
|-
| [[#RETF|RETF]] || [[#ROL|ROL]] || [[#ROR|ROR]] || [[#SAHF|SAHF]] || [[#SAR|SAR]] || [[#SBB|SBB]] || [[#SCASB|SCASB]] || [[#SCASW|SCASW]] || [[#SHL|SHL]] || [[#SHR|SHR]] || [[#SS|SS]]
|-
| [[#STC|STC]] || [[#STD|STD]] || [[#STI|STI]] || [[#STOSB|STOSB]] || [[#STOSW|STOSW]] || [[#SUB|SUB]] || [[#TEST|TEST]] || [[#XCHG|XCHG]] || [[#XLAT|XLAT]] || [[#XOR|XOR]]
|}
{| class="mw-collapsible mw-collapsed wikitable sortable" style="width: 340px;"
|+ style="white-space:nowrap; border:1px solid; padding:3px; border-color:rgb(162, 169, 177); background-color:rgb(234, 236, 240);" | Intel <-> NEC mnemonic translation table
!Intel
!NEC
|-
| [[#AAA|AAA]]
| [[#AAA|ADJBA]]
|-
| [[#AAD|AAD]]
| [[#AAD|CVTDB]]
|-
| [[#AAM|AAM]]
| [[#AAM|CVTBD]]
|-
| [[#AAS|AAS]]
| [[#AAS|ADJBS]]
|-
| [[#ADC|ADC]]
| [[#ADC|ADDC]]
|-
| [[#ADD|ADD]]
| [[#ADD|ADD]]
|-
| [[#AND|AND]]
| [[#AND|AND]]
|-
| [[#BOUND|BOUND]]
| [[#BOUND|CHKIND]]
|-
| [[#CALL|CALL]]
| [[#CALL|CALL]]
|-
| [[#CBW|CBW]]
| [[#CBW|CVTBW]]
|-
| [[#CLC|CLC]]
| [[#CLC|CLR1 CY]]
|-
| [[#CLD|CLD]]
| [[#CLD|CLR1 DIR]]
|-
| [[#CLI|CLI]]
| [[#CLI|DI]]
|-
| [[#CMC|CMC]]
| [[#CMC|NOT1 CY]]
|-
| [[#CMP|CMP]]
| [[#CMP|CMP]]
|-
| [[#CMPSB|CMPSB]]
| [[#CMPSB|CMPBKB]]
|-
| [[#CMPSW|CMPSW]]
| [[#CMPSW|CMPBKW]]
|-
| [[#CS|CS]]
| [[#CS|PS]]
|-
| [[#CWD|CWD]]
| [[#CWD|CVTWL]]
|-
| [[#DAA|DAA]]
| [[#DAA|ADJ4A]]
|-
| [[#DAS|DAS]]
| [[#DAS|ADJ4S]]
|-
| [[#DEC|DEC]]
| [[#DEC|DEC]]
|-
| [[#DIV|DIV]]
| [[#DIV|DIVU]]
|-
| [[#DS|DS]]
| [[#DS|DS0]]
|-
| [[#ENTER|ENTER]]
| [[#ENTER|PREPARE]]
|-
| [[#ES|ES]]
| [[#ES|DS1]]
|-
| [[#HLT|HLT]]
| [[#HLT|HALT]]
|-
| [[#IDIV|IDIV]]
| [[#IDIV|DIV]]
|-
| [[#IMUL|IMUL]]
| [[#IMUL|MUL]]
|-
| [[#IN|IN]]
| [[#IN|IN]]
|-
| [[#INC|INC]]
| [[#INC|INC]]
|-
| [[#INSB|INSB]]
| [[#INSB|INMB]]
|-
| [[#INSW|INSW]]
| [[#INSW|INMW]]
|-
| [[#INT|INT]]
| [[#INT|BRK]]
|-
| [[#INTO|INTO]]
| [[#INTO|BRKV]]
|-
| [[#IRET|IRET]]
| [[#IRET|RETI]]
|-
| [[#JA|JA]]
| [[#JA|BH]]
|-
| [[#JBE|JBE]]
| [[#JBE|BNH]]
|-
| [[#JC|JC/JB]]
| [[#JC|BC/BL]]
|-
| [[#JCXZ|JCXZ]]
| [[#JCXZ|BCWZ]]
|-
| [[#JG|JG]]
| [[#JG|BGT]]
|-
| [[#JGE|JGE]]
| [[#JGE|BGE]]
|-
| [[#JL|JL]]
| [[#JL|BLT]]
|-
| [[#JLE|JLE]]
| [[#JLE|BLE]]
|-
| [[#JMP|JMP]]
| [[#JMP|BR]]
|-
| [[#JNC|JNC/JAE]]
| [[#JNC|BNC/BNL]]
|-
| [[#JNO|JNO]]
| [[#JNO|BNV]]
|-
| [[#JNP|JNP]]
| [[#JNP|BPO]]
|-
| [[#JNS|JNS]]
| [[#JNS|BP]]
|-
| [[#JNZ|JNZ/JNE]]
| [[#JNZ|BNZ/BNE]]
|-
| [[#JO|JO]]
| [[#JO|BV]]
|-
| [[#JP|JP]]
| [[#JP|BPE]]
|-
| [[#JS|JS]]
| [[#JS|BN]]
|-
| [[#JZ|JZ/JE]]
| [[#JZ|BZ/BE]]
|-
| [[#LAHF|LAHF]]
| [[#LAHF|MOV]]
|-
| [[#LDS|LDS]]
| [[#LDS|MOV]]
|-
| [[#LEA|LEA]]
| [[#LEA|LDEA]]
|-
| [[#LEAVE|LEAVE]]
| [[#LEAVE|DISPOSE]]
|-
| [[#LES|LES]]
| [[#LES|MOV]]
|-
| [[#LOCK|LOCK]]
| [[#LOCK|BUSLOCK]]
|-
| [[#LODSB|LODSB]]
| [[#LODSB|LDMB]]
|-
| [[#LODSW|LODSW]]
| [[#LODSW|LDMW]]
|-
| [[#LOOP|LOOP]]
| [[#LOOP|DBNZ]]
|-
| [[#LOOPE|LOOPE]]
| [[#LOOPE|DBNZE]]
|-
| [[#LOOPNE|LOOPNE]]
| [[#LOOPNE|DBNZNE]]
|-
| [[#MOV|MOV]]
| [[#MOV|MOV]]
|-
| [[#MOVSB|MOVSB]]
| [[#MOVSB|MOVBKB]]
|-
| [[#MOVSW|MOVSW]]
| [[#MOVSW|MOVBKW]]
|-
| [[#MUL|MUL]]
| [[#MUL|MULU]]
|-
| [[#NEG|NEG]]
| [[#NEG|NEG]]
|-
| [[#NOP|NOP]]
| [[#NOP|NOP]]
|-
| [[#NOT|NOT]]
| [[#NOT|NOT]]
|-
| [[#OR|OR]]
| [[#OR|OR]]
|-
| [[#OUT|OUT]]
| [[#OUT|OUT]]
|-
| [[#OUTSB|OUTSB]]
| [[#OUTSB|OUTM]]
|-
| [[#OUTSW|OUTSW]]
| [[#OUTSW|OUTM]]
|-
| [[#POLL|POLL]]
| [[#POLL|POLL]]
|-
| [[#POP|POP]]
| [[#POP|POP]]
|-
| [[#POPA|POPA]]
| [[#POPA|POP]]
|-
| [[#POPF|POPF]]
| [[#POPF|POP]]
|-
| [[#PUSH|PUSH]]
| [[#PUSH|PUSH]]
|-
| [[#PUSHA|PUSHA]]
| [[#PUSHA|PUSH]]
|-
| [[#PUSHF|PUSHF]]
| [[#PUSHF|PUSH]]
|-
| [[#RCL|RCL]]
| [[#RCL|ROLC]]
|-
| [[#RCR|RCR]]
| [[#RCR|RORC]]
|-
| [[#REP|REP/REPE/REPZ]]
| [[#REP|REP/REPE/REPZ]]
|-
| [[#REPNE|REPNE/REPNZ]]
| [[#REPNE|REPNE/REPNZ]]
|-
| [[#RET|RET]]
| [[#RET|RET]]
|-
| [[#RETF|RETF]]
| [[#RETF|RET]]
|-
| [[#ROL|ROL]]
| [[#ROL|ROL]]
|-
| [[#ROR|ROR]]
| [[#ROR|ROR]]
|-
| [[#SAHF|SAHF]]
| [[#SAHF|MOV]]
|-
| [[#SAR|SAR]]
| [[#SAR|SHRA]]
|-
| [[#SBB|SBB]]
| [[#SBB|SUBC]]
|-
| [[#SCASB|SCASB]]
| [[#SCASB|CMPMB]]
|-
| [[#SCASW|SCASW]]
| [[#SCASW|CMPMW]]
|-
| [[#SHL|SHL]]
| [[#SHL|SHL]]
|-
| [[#SHR|SHR]]
| [[#SHR|SHR]]
|-
| [[#SS|SS]]
| [[#SS|SS]]
|-
| [[#STC|STC]]
| [[#STC|SET1 CY]]
|-
| [[#STD|STD]]
| [[#STD|SET1 DIR]]
|-
| [[#STI|STI]]
| [[#STI|EI]]
|-
| [[#STOSB|STOSB]]
| [[#STOSB|STMB]]
|-
| [[#STOSW|STOSW]]
| [[#STOSW|STMW]]
|-
| [[#SUB|SUB]]
| [[#SUB|SUB]]
|-
| [[#TEST|TEST]]
| [[#TEST|TEST]]
|-
| [[#XCHG|XCHG]]
| [[#XCHG|XCH]]
|-
| [[#XLAT|XLAT]]
| [[#XLAT|TRANS]]
|-
| [[#XOR|XOR]]
| [[#XOR|XOR]]
|}
== Official instructions by type ==
{| class="wikitable sortable" style="text-align: center"
!Type
!colspan=16 class="unsortable" | Instructions
|-
| style="text-align:left;" | Memory
| style="" | [[#MOV|MOV]]
| style="" | [[#XCHG|XCHG]]
| style="" | [[#XLAT|XLAT]]
| style="" | [[#LEA|LEA]]
| style="border-right:none;" | [[#LDS|LDS]]
| style="border-left:none;" | [[#LES|LES]]
| style="border-right:none;" | [[#IN|IN]]
| style="border-left:none;" | [[#OUT|OUT]]
| colspan="8" |
|-
| style="text-align:left;" | Ports
| style="border-right:none;" | [[#IN|IN]]
| style="border-left:none;" | [[#OUT|OUT]]
| style="border-right:none;" | [[#INSB|INSB]]
| style="border-left:none;" | [[#OUTSB|OUTSB]]
| style="border-right:none;" | [[#INSW|INSW]]
| style="border-left:none;" | [[#OUTSW|OUTSW]]
| colspan="10" |
|-
| style="text-align:left;" | Arithmetic
| style="border-right:none;" | [[#ADD|ADD]]
| style="border-left:none;" | [[#SUB|SUB]]
| style="border-right:none;" | [[#ADC|ADC]]
| style="border-left:none;" | [[#SBB|SBB]]
| style="border-right:none;" | [[#INC|INC]]
| style="border-left:none;" | [[#DEC|DEC]]
| style="border-right:none;" | [[#MUL|MUL]]
| style="border-left:none;" | [[#DIV|DIV]]
| style="border-right:none;" | [[#IMUL|IMUL]]
| style="border-left:none;" | [[#IDIV|IDIV]]
| style="" | [[#CMP|CMP]]
| style="" | [[#NEG|NEG]]
| colspan="4" |
|-
| style="text-align:left;" | Numeric
| style="" | [[#CBW|CBW]]
| style="" | [[#CWD|CWD]]
| style="" | [[#AAA|AAA]]
| style="" | [[#AAS|AAS]]
| style="" | [[#AAM|AAM]]
| style="" | [[#AAD|AAD]]
| style="" | [[#DAA|DAA]]
| style="" | [[#DAS|DAS]]
| colspan="8" |
|-
| style="text-align:left;" | Shift
| style="border-right:none;" | [[#ROL|ROL]]
| style="border-left:none;" | [[#ROR|ROR]]
| style="border-right:none;" | [[#RCL|RCL]]
| style="border-left:none;" | [[#RCR|RCR]]
| style="border-right:none;" | [[#SHL|SHL]]
| style="border-left:none;" | [[#SHR|SHR]]
| style="" | [[#SAR|SAR]]
| colspan="9" |
|-
| style="text-align:left;" | Bitwise
| style="" | [[#AND|AND]]
| style="" | [[#OR|OR]]
| style="" | [[#XOR|XOR]]
| style="" | [[#NOT|NOT]]
| style="" | [[#TEST|TEST]]
| colspan="11" |
|-
| style="text-align:left;" | Branch
| style="border-right:none;" | [[#JC|JC]]
| style="border-left:none;" | [[#JNC|JNC]]
| style="border-right:none;" | [[#JZ|JZ]]
| style="border-left:none;" | [[#JNZ|JNZ]]
| style="border-right:none;" | [[#JBE|JBE]]
| style="border-left:none;" | [[#JA|JA]]
| style="border-right:none;" | [[#JO|JO]]
| style="border-left:none;" | [[#JNO|JNO]]
| style="border-right:none;" | [[#JP|JP]]
| style="border-left:none;" | [[#JNP|JNP]]
| style="border-right:none;" | [[#JS|JS]]
| style="border-left:none;" | [[#JNS|JNS]]
| style="border-right:none;" | [[#JL|JL]]
| style="border-left:none;" | [[#JGE|JGE]]
| style="border-right:none;" | [[#JLE|JLE]]
| style="border-left:none;" | [[#JG|JG]]
|-
| style="text-align:left;" | Jump
| style="" | [[#JMP|JMP]]
| style="border-right:none;" | [[#CALL|CALL]]
| style="border-left:none;border-right:none;" | [[#RET|RET]]
| style="border-left:none;" | [[#RETF|RETF]]
| colspan="12" |
|-
| style="text-align:left;" | Loop
| style="" | [[#LOOP|LOOP]]
| style="" | [[#LOOPE|LOOPE]]
| style="" | [[#LOOPNE|LOOPNE]]
| colspan="13" |
|-
| style="text-align:left;" | Interrupt
| style="border-right:none;" | [[#INT|INT]]
| style="border-left:none;" | [[#IRET|IRET]]
| style="" | [[#INTO|INTO]]
| style="" | [[#HLT|HLT]]
| style="" | [[#BOUND|BOUND]]
| colspan="11" |
|-
| style="text-align:left;" | Stack
| style="border-right:none;" | [[#PUSH|PUSH]]
| style="border-left:none;" | [[#POP|POP]]
| style="border-right:none;" | [[#PUSHA|PUSHA]]
| style="border-left:none;" | [[#POPA|POPA]]
| style="border-right:none;" | [[#PUSHF|PUSHF]]
| style="border-left:none;" | [[#POPF|POPF]]
| colspan="10" |
|-
| style="text-align:left;" | Flags
| style="border-right:none;" | [[#CLC|CLC]]
| style="border-left:none;" | [[#STC|STC]]
| style="border-right:none;" | [[#CLD|CLD]]
| style="border-left:none;" | [[#STD|STD]]
| style="border-right:none;" | [[#CLI|CLI]]
| style="border-left:none;" | [[#STI|STI]]
| style="" | [[#CMC|CMC]]
| style="border-right:none;" | [[#LAHF|LAHF]]
| style="border-left:none;" | [[#SAHF|SAHF]]
| colspan="7" |
|-
| style="text-align:left;" | Prefix
| style="" | [[#CS|CS]]
| style="" | [[#DS|DS]]
| style="" | [[#ES|ES]]
| style="" | [[#SS|SS]]
| colspan="12" |
|-
| style="text-align:left;" | String
| style="border-right:none;" | [[#REP|REP]]
| style="border-left:none;border-right:none;" | [[#REP|REPE]]
| style="border-left:none;" | [[#REPNE|REPNE]]
| style="" | [[#MOVSB|MOVSB]]
| style="" | [[#MOVSW|MOVSW]]
| style="border-right:none;" | [[#LODSB|LODSB]]
| style="border-left:none;" | [[#STOSB|STOSB]]
| style="border-right:none;" | [[#LODSW|LODSW]]
| style="border-left:none;" | [[#STOSW|STOSW]]
| style="" | [[#CMPSB|CMPSB]]
| style="" | [[#SCASB|SCASB]]
| style="" | [[#CMPSW|CMPSW]]
| style="" | [[#SCASW|SCASW]]
| colspan="3" |
|-
| style="text-align:left;" | Other
| style="" | [[#NOP|NOP]]
| style="border-right:none;" | [[#ENTER|ENTER]]
| style="border-left:none;" | [[#LEAVE|LEAVE]]
| style="" | [[#LOCK|LOCK]]
| style="" | [[#POLL|POLL]]
| colspan="11" |
|}
== Instruction encoding ==
=== ModR/M byte ===
The ModR/M byte is used in most addressing modes which reference a memory location. This byte consists of three bitfield values:
* <tt>oo</tt> - M'''o'''de;
* <tt>rrr</tt> - Two possible functions:
** '''R'''egister (for addressing modes which require both a register and a register/memory operand),
** Opcode extension (for some opcodes' addressing modes which do not have such a requirement);
* <tt>mmm</tt> - Register/'''M'''emory.
The ''Mode'' and ''Register/Memory'' bitfields can refer to a memory location or to a register, as shown in the table below. In some addressing modes, the ''Register'' field also refers to a register; it is always interpreted as if ''Mode'' was equal to <tt>11</tt>.
{| class="wikitable" style="text-align: center"
! R/M \ Mode
! <tt>00</tt>
! <tt>01</tt>
! <tt>10</tt>
! <tt>11</tt> ''(byte)''
! <tt>11</tt> ''(word)''
|-
| <tt>000</tt>
| DS:[BX + SI]
| DS:[BX + SI + disp8]
| DS:[BX + SI + disp16]
| AL
| AX
|-
| <tt>001</tt>
| DS:[BX + DI]
| DS:[BX + DI + disp8]
| DS:[BX + DI + disp16]
| CL
| CX
|-
| <tt>010</tt>
| SS:[BP + SI]
| SS:[BP + SI + disp8]
| SS:[BP + SI + disp16]
| DL
| DX
|-
| <tt>011</tt>
| SS:[BP + DI]
| SS:[BP + DI + disp8]
| SS:[BP + DI + disp16]
| BL
| BX
|-
| <tt>100</tt>
| DS:[SI]
| DS:[SI + disp8]
| DS:[SI + disp16]
| AH
| SP
|-
| <tt>101</tt>
| DS:[DI]
| DS:[DI + disp8]
| DS:[DI + disp16]
| CH
| BP
|-
| <tt>110</tt>
| ''DS:[disp16]''
| SS:[BP + disp8]
| SS:[BP + disp16]
| DH
| SI
|-
| <tt>111</tt>
| DS:[BX]
| DS:[BX + disp8]
| DS:[BX + disp16]
| BH
| DI
|}
Displacements are either 8-bit (disp8) or 16-bit (disp16) signed values and they always immediately follow the ModR/M byte. Note that (<tt>oo</tt> = <tt>00</tt>, <tt>mmm</tt> = <tt>110</tt>) is a special case, in which the ''disp16'' value is used directly as a near pointer.
The instruction encoding lists below refer to this byte as <tt>oorrrmmm</tt> (binary), <tt>/r</tt> (hexadecimal) or <tt>/0</tt> (hexademical, <tt>rrr</tt> used as function <tt>0</tt>).
== Official instructions ==
{{Anchor|AAA}}
=== AAA ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| AAA || <tt>37</tt> || <tt>00110111</tt> || 1 || 9
|}
----
{{Anchor|AAD}}
=== AAD ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| AAD imm8 || <tt>B5 ii</tt> || <tt>11010100 iiiiiiii</tt> || 2 || 6
|}
----
{{Anchor|AAM}}
=== AAM ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| AAM imm8 || <tt>B4 ii</tt> || <tt>11010100 iiiiiiii</tt> || 2 || 17
|}
----
{{Anchor|AAS}}
=== AAS ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| AAS || <tt>3F</tt> || <tt>00111111</tt> || 1 || 9
|}
----
{{Anchor|ADC}}
=== ADC ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| ADC AL, imm || <tt>14 ii</tt> || <tt>00010100 iiiiiiii</tt> || 2 || 1
|-
| ADC AX, imm || <tt>15 ii ii</tt> || <tt>00010101 iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| ADC mem8, imm8 || <tt>80 /2 ii</tt> || <tt>10000000 oo010mmm iiiiiiii</tt> || 3+ || 3
|-
| ADC mem16, imm16 || <tt>81 /2 ii ii</tt> || <tt>10000001 oo010mmm iiiiiiii iiiiiiii</tt> || 4+ || 3
|-
| ADC mem16, simm8 || <tt>83 /2 ii</tt> || <tt>10000011 oo010mmm iiiiiiii</tt> || 3+ || 3
|-
| ADC mem8, reg8 || <tt>10 /r</tt> || <tt>00010000 oorrrmmm</tt> || 2+ || 3
|-
| ADC mem16, reg16 || <tt>11 /r</tt> || <tt>00010001 oorrrmmm</tt> || 2+ || 3
|-
| ADC reg8, imm8 || <tt>80 /2 ii</tt> || <tt>10000000 11010mmm iiiiiiii</tt> || 3 || 1
|-
| ADC reg16, imm16 || <tt>81 /2 ii ii</tt> || <tt>10000001 11010mmm iiiiiiii iiiiiiii</tt> || 4 || 1
|-
| ADC reg16, simm8 || <tt>83 /2 ii</tt> || <tt>10000011 11010mmm iiiiiiii</tt> || 3 || 1
|-
| ADC reg8, mem8 || <tt>12 /r</tt> || <tt>00010010 oorrrmmm</tt> || 2+ || 2
|-
| ADC reg16, mem16 || <tt>13 /r</tt> || <tt>00010011 oorrrmmm</tt> || 2+ || 2
|-
| ADC reg8, reg8 || <tt>10 /r</tt> || <tt>000100.0 11rrrmmm</tt> || 2 || 1
|-
| ADC reg16, reg16 || <tt>11 /r</tt> || <tt>000100.1 11rrrmmm</tt> || 2 || 1
|}
----
{{Anchor|ADD}}
=== ADD ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| ADD AL, imm || <tt>04 ii</tt> || <tt>00000100 iiiiiiii</tt> || 2 || 1
|-
| ADD AX, imm || <tt>05 ii ii</tt> || <tt>00000101 iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| ADD mem8, imm8 || <tt>80 /0 ii</tt> || <tt>10000000 oo000mmm iiiiiiii</tt> || 3+ || 3
|-
| ADD mem16, imm16 || <tt>81 /0 ii ii</tt> || <tt>10000001 oo000mmm iiiiiiii iiiiiiii</tt> || 4+ || 3
|-
| ADD mem16, simm8 || <tt>83 /0 ii</tt> || <tt>10000011 oo000mmm iiiiiiii</tt> || 3+ || 3
|-
| ADD mem8, reg8 || <tt>00 /r</tt> || <tt>00000000 oorrrmmm</tt> || 2+ || 3
|-
| ADD mem16, reg16 || <tt>01 /r</tt> || <tt>00000001 oorrrmmm</tt> || 2+ || 3
|-
| ADD reg8, imm8 || <tt>80 /0 ii</tt> || <tt>10000000 11000mmm iiiiiiii</tt> || 3 || 1
|-
| ADD reg16, imm16 || <tt>81 /0 ii ii</tt> || <tt>10000001 11000mmm iiiiiiii iiiiiiii</tt> || 4 || 1
|-
| ADD reg16, simm8 || <tt>83 /0 ii</tt> || <tt>10000011 11000mmm iiiiiiii</tt> || 3 || 1
|-
| ADD reg8, mem8 || <tt>02 /r</tt> || <tt>00000010 oorrrmmm</tt> || 2+ || 2
|-
| ADD reg16, mem16 || <tt>03 /r</tt> || <tt>00000011 oorrrmmm</tt> || 2+ || 2
|-
| ADD reg8, reg8 || <tt>00 /r</tt> || <tt>000000.0 11rrrmmm</tt> || 2 || 1
|-
| ADD reg16, reg16 || <tt>01 /r</tt> || <tt>000000.1 11rrrmmm</tt> || 2 || 1
|}
----
{{Anchor|AND}}
=== AND ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| AND AL, imm || <tt>24 ii</tt> || <tt>00100100 iiiiiiii</tt> || 2 || 1
|-
| AND AX, imm || <tt>25 ii ii</tt> || <tt>00100101 iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| AND mem8, imm8 || <tt>80 /4 ii</tt> || <tt>10000000 oo100mmm iiiiiiii</tt> || 3+ || 3
|-
| AND mem16, imm16 || <tt>81 /4 ii ii</tt> || <tt>10000001 oo100mmm iiiiiiii iiiiiiii</tt> || 4+ || 3
|-
| AND mem16, simm8 || <tt>83 /4 ii</tt> || <tt>10000011 oo100mmm iiiiiiii</tt> || 3+ || 3
|-
| AND mem8, reg8 || <tt>20 /r</tt> || <tt>00100000 oorrrmmm</tt> || 2+ || 3
|-
| AND mem16, reg16 || <tt>21 /r</tt> || <tt>00100001 oorrrmmm</tt> || 2+ || 3
|-
| AND reg8, imm8 || <tt>80 /4 ii</tt> || <tt>10000000 11100mmm iiiiiiii</tt> || 3 || 1
|-
| AND reg16, imm16 || <tt>81 /4 ii ii</tt> || <tt>10000001 11100mmm iiiiiiii iiiiiiii</tt> || 4 || 1
|-
| AND reg16, simm8 || <tt>83 /4 ii</tt> || <tt>10000011 11100mmm iiiiiiii</tt> || 3 || 1
|-
| AND reg8, mem8 || <tt>22 /r</tt> || <tt>00100010 oorrrmmm</tt> || 2+ || 2
|-
| AND reg16, mem16 || <tt>23 /r</tt> || <tt>00100011 oorrrmmm</tt> || 2+ || 2
|-
| AND reg8, reg8 || <tt>20 /r</tt> || <tt>001000.0 11rrrmmm</tt> || 2 || 1
|-
| AND reg16, reg16 || <tt>21 /r</tt> || <tt>001000.1 11rrrmmm</tt> || 2 || 1
|}
----
{{Anchor|BOUND}}
=== BOUND ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| BOUND reg16, mem16:16 || <tt>62 /r</tt> || <tt>01100010 oorrrmmm</tt> || 2+ || 13 (20 if condition met)
|}
----
{{Anchor|CALL}}
=== CALL ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| CALL ptr16:16 || <tt>CA oo oo ss ss</tt> || <tt>10011010 oooooooo oooooooo ssssssss ssssssss</tt> || 5 || 10
|-
| CALL mem16 || <tt>FF /2</tt> || <tt>11111111 oo010mmm</tt> || 2+ || 6
|-
| CALL mem16:16 || <tt>FF /3</tt> || <tt>11111111 oo011mmm</tt> || 2+ || 12
|-
| CALL reg16 || <tt>FF /2</tt> || <tt>11111111 11010mmm</tt> || 2 || 5
|-
| CALL rel16 || <tt>E8 ii ii</tt> || <tt>11101000 iiiiiiii iiiiiiii</tt> || 3 || 5
|}
----
{{Anchor|CBW}}
=== CBW ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| CBW || <tt>98</tt> || <tt>10011000</tt> || 1 || 1
|}
----
{{Anchor|CLC}}
=== CLC ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| CLC || <tt>F8</tt> || <tt>11111000</tt> || 1 || 4
|}
----
{{Anchor|CLD}}
=== CLD ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| CLD || <tt>FC</tt> || <tt>11111100</tt> || 1 || 4
|}
----
{{Anchor|CLI}}
=== CLI ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| CLI || <tt>FA</tt> || <tt>11111010</tt> || 1 || 4
|}
----
{{Anchor|CMC}}
=== CMC ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| CMC || <tt>F5</tt> || <tt>11110101</tt> || 1 || 4
|}
----
{{Anchor|CMP}}
=== CMP ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| CMP AL, imm || <tt>3C ii</tt> || <tt>00111100 iiiiiiii</tt> || 2 || 1
|-
| CMP AX, imm || <tt>3D ii ii</tt> || <tt>00111101 iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| CMP mem8, imm8 || <tt>80 /7 ii</tt> || <tt>10000000 oo111mmm iiiiiiii</tt> || 3+ || 2
|-
| CMP mem16, imm16 || <tt>81 /7 ii ii</tt> || <tt>10000001 oo111mmm iiiiiiii iiiiiiii</tt> || 4+ || 2
|-
| CMP mem16, simm8 || <tt>83 /7 ii</tt> || <tt>10000011 oo111mmm iiiiiiii</tt> || 3+ || 2
|-
| CMP mem8, reg8 || <tt>38 /r</tt> || <tt>00111000 oorrrmmm</tt> || 2+ || 2
|-
| CMP mem16, reg16 || <tt>39 /r</tt> || <tt>00111001 oorrrmmm</tt> || 2+ || 2
|-
| CMP reg8, imm8 || <tt>80 /7 ii</tt> || <tt>10000000 11111mmm iiiiiiii</tt> || 3 || 1
|-
| CMP reg16, imm16 || <tt>81 /7 ii ii</tt> || <tt>10000001 11111mmm iiiiiiii iiiiiiii</tt> || 4 || 1
|-
| CMP reg16, simm8 || <tt>83 /7 ii</tt> || <tt>10000011 11111mmm iiiiiiii</tt> || 3 || 1
|-
| CMP reg8, mem8 || <tt>3A /r</tt> || <tt>00111010 oorrrmmm</tt> || 2+ || 2
|-
| CMP reg16, mem16 || <tt>3B /r</tt> || <tt>00111011 oorrrmmm</tt> || 2+ || 2
|-
| CMP reg8, reg8 || <tt>38 /r</tt> || <tt>001110.0 11rrrmmm</tt> || 2 || 1
|-
| CMP reg16, reg16 || <tt>39 /r</tt> || <tt>001110.1 11rrrmmm</tt> || 2 || 1
|}
----
{{Anchor|CMPSB}}
{{Anchor|CMPSW}}
=== CMPSB/CMPSW ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| CMPSB || <tt>A6</tt> || <tt>10100110</tt> || 1 || 6
|-
| CMPSW || <tt>A7</tt> || <tt>10100111</tt> || 1 || 6
|}
----
{{Anchor|CS}}
=== CS ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| CS || <tt>2E</tt> || <tt>00101110</tt> || 1 || 1
|}
----
{{Anchor|CWD}}
=== CWD ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| CWD || <tt>99</tt> || <tt>10011001</tt> || 1 || 1
|}
----
{{Anchor|DAA}}
=== DAA ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| DAA || <tt>27</tt> || <tt>00100111</tt> || 1 || 10
|}
----
{{Anchor|DAS}}
=== DAS ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| DAS || <tt>2F</tt> || <tt>00101111</tt> || 1 || 10
|}
----
{{Anchor|DEC}}
=== DEC ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| DEC mem8 || <tt>FE /1</tt> || <tt>11111110 oo001mmm</tt> || 2+ || 3
|-
| DEC mem16 || <tt>FF /1</tt> || <tt>11111111 oo001mmm</tt> || 2+ || 3
|-
| DEC reg8 || <tt>FE /1</tt> || <tt>11111110 11001mmm</tt> || 2+ || 1
|-
| DEC reg16 || <tt>4x</tt> || <tt>01001rrr</tt> || 1 || 1
|}
----
{{Anchor|DIV}}
=== DIV ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| DIV mem8 || <tt>F6 /6</tt> || <tt>11110110 oo110mmm</tt> || 2+ || 16
|-
| DIV mem16 || <tt>F7 /6</tt> || <tt>11111111 oo110mmm</tt> || 2+ || 24
|-
| DIV reg8 || <tt>F6 /6</tt> || <tt>11111110 11110mmm</tt> || 2 || 15
|-
| DIV reg16 || <tt>F7 /6</tt> || <tt>11111111 11110mmm</tt> || 2 || 23
|}
----
{{Anchor|DS}}
=== DS ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| DS || <tt>3E</tt> || <tt>00111110</tt> || 1 || 1
|}
----
{{Anchor|ENTER}}
=== ENTER ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| ENTER imm16, imm8 || <tt>C8 ii ii jj</tt> || <tt>11001000 iiiiiiii iiiiiiii jjjjjjjj</tt> || 3 || 8 (imm8 = 0)<br/>14 (imm8 = 1)<br/>15 + imm8 * 4 (imm8 >= 2)
|}
----
{{Anchor|ES}}
=== ES ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| ES || <tt>26</tt> || <tt>00100110</tt> || 1 || 1
|}
----
{{Anchor|HLT}}
=== HLT ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| HLT || <tt>F4</tt> || <tt>11110100</tt> || 1 || 9
|}
----
{{Anchor|IDIV}}
=== IDIV ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| IDIV mem8 || <tt>F6 /7</tt> || <tt>11110110 oo111mmm</tt> || 2+ || 18
|-
| IDIV mem16 || <tt>F7 /7</tt> || <tt>11111111 oo111mmm</tt> || 2+ || 25
|-
| IDIV reg8 || <tt>F6 /7</tt> || <tt>11111110 11111mmm</tt> || 2 || 17
|-
| IDIV reg16 || <tt>F7 /7</tt> || <tt>11111111 11111mmm</tt> || 2 || 24
|}
----
{{Anchor|IMUL}}
=== IMUL ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| IMUL mem8 || <tt>F6 /5</tt> || <tt>11110110 oo101mmm</tt> || 2+ || 4
|-
| IMUL mem16 || <tt>F7 /5</tt> || <tt>11111111 oo101mmm</tt> || 2+ || 4
|-
| IMUL reg8 || <tt>F6 /5</tt> || <tt>11111110 11101mmm</tt> || 2 || 3
|-
| IMUL reg16 || <tt>F7 /5</tt> || <tt>11111111 11101mmm</tt> || 2 || 3
|-
| IMUL reg16, mem16, imm16 || <tt>69 /r ii ii</tt> || <tt>11111111 oorrrmmm iiiiiiii iiiiiiii</tt> || 4 || 4
|-
| IMUL reg16, mem16, simm8 || <tt>6B /r ii</tt> || <tt>11111111 oorrrmmm iiiiiiii</tt> || 3 || 4
|-
| IMUL reg16, reg16, imm16 || <tt>69 /r ii ii</tt> || <tt>11111111 11rrrmmm iiiiiiii iiiiiiii</tt> || 4 || 3
|-
| IMUL reg16, reg16, simm8 || <tt>6B /r ii</tt> || <tt>11111111 11rrrmmm iiiiiiii</tt> || 3 || 3
|}
----
{{Anchor|IN}}
=== IN ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| IN AL, DX || <tt>EC</tt> || <tt>11101100</tt> || 1 || 6
|-
| IN AX, DX || <tt>ED</tt> || <tt>11101101</tt> || 1 || 6
|-
| IN AL, imm8 || <tt>E4 ii</tt> || <tt>11100100 iiiiiiii</tt> || 2 || 6
|-
| IN AX, imm8 || <tt>E5 ii</tt> || <tt>11100101 iiiiiiii</tt> || 2 || 6
|}
----
{{Anchor|INC}}
=== INC ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| INC mem8 || <tt>FE /0</tt> || <tt>11111110 oo000mmm</tt> || 2+ || 3
|-
| INC mem16 || <tt>FF /0</tt> || <tt>11111111 oo000mmm</tt> || 2+ || 3
|-
| INC reg8 || <tt>FE /0</tt> || <tt>11111110 11000mmm</tt> || 2+ || 1
|-
| INC reg16 || <tt>4x</tt> || <tt>01000rrr</tt> || 1 || 1
|}
----
{{Anchor|INSB}}
{{Anchor|INSW}}
=== INSB/INSW ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| INSB || <tt>6C</tt> || <tt>01101100</tt> || 1 || 6
|-
| INSW || <tt>6D</tt> || <tt>01101101</tt> || 1 || 6
|}
----
{{Anchor|INT}}
=== INT ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| INT 3 || <tt>CC</tt> || <tt>11001100</tt> || 1 || 9
|-
| INT imm8 || <tt>CD ii</tt> || <tt>11001101 iiiiiiii</tt> || 2 || 10
|}
----
{{Anchor|INTO}}
=== INTO ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| INTO || <tt>CE</tt> || <tt>11001110</tt> || 1 || 6 (13 if OF = 1)
|}
----
{{Anchor|IRET}}
=== IRET ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| IRET || <tt>CF</tt> || <tt>11001111</tt> || 1 || 10
|}
----
{{Anchor|JA}}
=== JA ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JA rel8 || <tt>77 ii</tt> || <tt>01110111 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JBE}}
=== JBE ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JA rel8 || <tt>76 ii</tt> || <tt>01110110 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JC}}
=== JC/JB ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JC rel8 || <tt>72 ii</tt> || <tt>01110010 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JCXZ}}
=== JCXZ ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JCXZ rel8 || <tt>E3 ii</tt> || <tt>11100011 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JG}}
=== JG ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JG rel8 || <tt>7F ii</tt> || <tt>01111111 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JGE}}
=== JGE ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JGE rel8 || <tt>7D ii</tt> || <tt>01111101 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JL}}
=== JL ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JL rel8 || <tt>7C ii</tt> || <tt>01111100 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JLE}}
=== JLE ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JLE rel8 || <tt>7E ii</tt> || <tt>01111110 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JMP}}
=== JMP ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JMP ptr16:16 || <tt>EA oo oo ss ss</tt> || <tt>11101010 oooooooo oooooooo ssssssss ssssssss</tt> || 5 || 7
|-
| JMP mem16 || <tt>FF /4</tt> || <tt>11111111 oo100mmm</tt> || 2+ || 5
|-
| JMP mem16:16 || <tt>FF /5</tt> || <tt>11111111 oo101mmm</tt> || 2+ || 10
|-
| JMP reg16 || <tt>FF /4</tt> || <tt>11111111 11100mmm</tt> || 2 || 4
|-
| JMP rel8 || <tt>EB ii</tt> || <tt>11101011 iiiiiiii</tt> || 2 || 4
|-
| JMP rel16 || <tt>E9 ii ii</tt> || <tt>11101001 iiiiiiii iiiiiiii</tt> || 3 || 4
|}
----
{{Anchor|JNC}}
=== JNC/JAE ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JNC rel8 || <tt>73 ii</tt> || <tt>01110011 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JNO}}
=== JNO ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JNO rel8 || <tt>71 ii</tt> || <tt>01110001 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JNP}}
=== JNP ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JNP rel8 || <tt>7B ii</tt> || <tt>01111011 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JNS}}
=== JNS ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JNS rel8 || <tt>79 ii</tt> || <tt>01111001 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JNZ}}
=== JNZ/JNE ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JNZ rel8 || <tt>75 ii</tt> || <tt>01110101 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JO}}
=== JO ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JO rel8 || <tt>70 ii</tt> || <tt>01110000 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JP}}
=== JP ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JP rel8 || <tt>7A ii</tt> || <tt>01111010 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JS}}
=== JS ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JS rel8 || <tt>78 ii</tt> || <tt>01111000 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JZ}}
=== JZ/JE ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JZ rel8 || <tt>74 ii</tt> || <tt>01110100 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|LAHF}}
=== LAHF ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| LAHF || <tt>9F</tt> || <tt>10011111</tt> || 1 || 2
|}
----
{{Anchor|LDS}}
=== LDS ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| LDS reg16, mem16 || <tt>C5 /r</tt> || <tt>11000101 oorrrmmm</tt> || 2+ || 6
|}
----
{{Anchor|LEA}}
=== LEA ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| LEA reg16, mem16 || <tt>8D /r</tt> || <tt>10001101 oorrrmmm</tt> || 2+ || 1
|}
----
{{Anchor|LEAVE}}
=== LEAVE ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| LEAVE || <tt>C9</tt> || <tt>11001001</tt> || 1 || 2
|}
----
{{Anchor|LES}}
=== LES ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| LES reg16, mem16 || <tt>C4 /r</tt> || <tt>11000100 oorrrmmm</tt> || 2+ || 6
|}
----
{{Anchor|LOCK}}
=== LOCK ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| LOCK || <tt>F0</tt> || <tt>11110000</tt> || 1 || 1
|}
----
{{Anchor|LODSB}}
{{Anchor|LODSW}}
=== LODSB/LODSW ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| LODSB || <tt>AC</tt> || <tt>10101100</tt> || 1 || 3
|-
| LODSW || <tt>AD</tt> || <tt>10101101</tt> || 1 || 3
|}
----
{{Anchor|LOOP}}
=== LOOP ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| LOOP rel8 || <tt>E2 ii</tt> || <tt>11100010 iiiiiiii</tt> || 2 || 2 (5 if branch taken)
|}
----
{{Anchor|LOOPE}}
=== LOOPE ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| LOOPE rel8 || <tt>E1 ii</tt> || <tt>11100001 iiiiiiii</tt> || 2 || 3 (6 if branch taken)
|}
----
{{Anchor|LOOPNE}}
=== LOOPNE ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| LOOPNE rel8 || <tt>E0 ii</tt> || <tt>11100000 iiiiiiii</tt> || 2 || 3 (6 if branch taken)
|}
----
{{Anchor|MOV}}
=== MOV ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| MOV AL, ptr16 || <tt>A0 ii ii</tt> || <tt>10100000 iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| MOV AX, ptr16 || <tt>A1 ii ii</tt> || <tt>10100001 iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| MOV mem8, imm8 || <tt>C6 /0 ii</tt> || <tt>11000110 oo000mmm iiiiiiii</tt> || 3+ || 1
|-
| MOV mem16, imm16 || <tt>C7 /0 ii ii</tt> || <tt>11000111 oo000mmm iiiiiiii iiiiiiii</tt> || 4+ || 1
|-
| MOV mem8, reg8 || <tt>84 /r</tt> || <tt>10001000 oorrrmmm</tt> || 2+ || 1
|-
| MOV mem16, reg16 || <tt>85 /r</tt> || <tt>10001001 oorrrmmm</tt> || 2+ || 1
|-
| MOV mem16, sreg16 || <tt>8C /r</tt> || <tt>10001100 oo0rrmmm</tt> || 2+ || 3
|-
| MOV ptr16, AL || <tt>A2 ii ii</tt> || <tt>10100010 iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| MOV ptr16, AX || <tt>A3 ii ii</tt> || <tt>10100011 iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| MOV reg8, imm8 || <tt>Bx ii</tt> || <tt>10110rrr iiiiiiii</tt> || 2 || 1
|-
| MOV reg8, imm8 || <tt>C6 /0 ii</tt> || <tt>11000110 11000mmm iiiiiiii</tt> || 3 || 1
|-
| MOV reg16, imm16 || <tt>Bx ii</tt> || <tt>10111rrr iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| MOV reg16, imm16 || <tt>C7 /0 ii ii</tt> || <tt>11000111 11000mmm iiiiiiii iiiiiiii</tt> || 4 || 1
|-
| MOV reg8, mem8 || <tt>8A /r</tt> || <tt>10001010 oorrrmmm</tt> || 2+ || 1
|-
| MOV reg16, mem16 || <tt>8B /r</tt> || <tt>10001011 oorrrmmm</tt> || 2+ || 1
|-
| MOV reg8, reg8 || <tt>88 /r</tt> || <tt>100010.0 11rrrmmm</tt> || 2 || 1
|-
| MOV reg16, reg16 || <tt>89 /r</tt> || <tt>100010.1 11rrrmmm</tt> || 2 || 1
|-
| MOV reg16, sreg16 || <tt>8C /r</tt> || <tt>10001100 110rrmmm</tt> || 2 || 1
|-
| MOV sreg16, mem16 || <tt>8E /r</tt> || <tt>10001110 oo0rrmmm</tt> || 2 || 3
|-
| MOV sreg16, reg16 || <tt>8E /r</tt> || <tt>10001110 110rrmmm</tt> || 2+ || 2
|}
----
{{Anchor|MOVSB}}
{{Anchor|MOVSW}}
=== MOVSB/MOVSW ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| MOVSB || <tt>A4</tt> || <tt>10100100</tt> || 1 || 5
|-
| MOVSW || <tt>A5</tt> || <tt>10100101</tt> || 1 || 5
|}
----
{{Anchor|MUL}}
=== MUL ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| MUL mem8 || <tt>F6 /4</tt> || <tt>11110110 oo100mmm</tt> || 2+ || 4
|-
| MUL mem16 || <tt>F7 /4</tt> || <tt>11111111 oo100mmm</tt> || 2+ || 4
|-
| MUL reg8 || <tt>F6 /4</tt> || <tt>11111110 11100mmm</tt> || 2 || 3
|-
| MUL reg16 || <tt>F7 /4</tt> || <tt>11111111 11100mmm</tt> || 2 || 3
|}
----
{{Anchor|NEG}}
=== NEG ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| NEG mem8 || <tt>F6 /3</tt> || <tt>11110110 oo011mmm</tt> || 2+ || 3
|-
| NEG mem16 || <tt>F7 /3</tt> || <tt>11111111 oo011mmm</tt> || 2+ || 3
|-
| NEG reg8 || <tt>F6 /3</tt> || <tt>11111110 11011mmm</tt> || 2 || 1
|-
| NEG reg16 || <tt>F7 /3</tt> || <tt>11111111 11011mmm</tt> || 2 || 1
|}
----
{{Anchor|NOP}}
=== NOP ===
----
{{Anchor|NOT}}
=== NOT ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| NOT mem8 || <tt>F6 /2</tt> || <tt>11110110 oo010mmm</tt> || 2+ || 3
|-
| NOT mem16 || <tt>F7 /2</tt> || <tt>11111111 oo010mmm</tt> || 2+ || 3
|-
| NOT reg8 || <tt>F6 /2</tt> || <tt>11111110 11010mmm</tt> || 2 || 1
|-
| NOT reg16 || <tt>F7 /2</tt> || <tt>11111111 11010mmm</tt> || 2 || 1
|}
----
{{Anchor|OR}}
=== OR ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| OR AL, imm || <tt>0C ii</tt> || <tt>00001100 iiiiiiii</tt> || 2 || 1
|-
| OR AX, imm || <tt>0D ii ii</tt> || <tt>00001101 iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| OR mem8, imm8 || <tt>80 /6 ii</tt> || <tt>10000000 oo001mmm iiiiiiii</tt> || 3+ || 3
|-
| OR mem16, imm16 || <tt>81 /6 ii ii</tt> || <tt>10000001 oo001mmm iiiiiiii iiiiiiii</tt> || 4+ || 3
|-
| OR mem16, simm8 || <tt>83 /6 ii</tt> || <tt>10000011 oo001mmm iiiiiiii</tt> || 3+ || 3
|-
| OR mem8, reg8 || <tt>08 /r</tt> || <tt>00001000 oorrrmmm</tt> || 2+ || 3
|-
| OR mem16, reg16 || <tt>09 /r</tt> || <tt>00001001 oorrrmmm</tt> || 2+ || 3
|-
| OR reg8, imm8 || <tt>80 /6 ii</tt> || <tt>10000000 11001mmm iiiiiiii</tt> || 3 || 1
|-
| OR reg16, imm16 || <tt>81 /6 ii ii</tt> || <tt>10000001 11001mmm iiiiiiii iiiiiiii</tt> || 4 || 1
|-
| OR reg16, simm8 || <tt>83 /6 ii</tt> || <tt>10000011 11001mmm iiiiiiii</tt> || 3 || 1
|-
| OR reg8, mem8 || <tt>0A /r</tt> || <tt>00001010 oorrrmmm</tt> || 2+ || 2
|-
| OR reg16, mem16 || <tt>0B /r</tt> || <tt>00001011 oorrrmmm</tt> || 2+ || 2
|-
| OR reg8, reg8 || <tt>08 /r</tt> || <tt>000010.0 11rrrmmm</tt> || 2 || 1
|-
| OR reg16, reg16 || <tt>09 /r</tt> || <tt>000010.1 11rrrmmm</tt> || 2 || 1
|}
----
{{Anchor|OUT}}
=== OUT ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| OUT AL, DX || <tt>EE</tt> || <tt>11101110</tt> || 1 || 6
|-
| OUT AX, DX || <tt>EF</tt> || <tt>11101111</tt> || 1 || 6
|-
| OUT AL, imm8 || <tt>E6 ii</tt> || <tt>11100110 iiiiiiii</tt> || 2 || 6
|-
| OUT AX, imm8 || <tt>E7 ii</tt> || <tt>11100111 iiiiiiii</tt> || 2 || 6
|}
----
{{Anchor|OUTSB}}
{{Anchor|OUTSW}}
=== OUTSB/OUTSW ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| OUTSB || <tt>6E</tt> || <tt>01101110</tt> || 1 || 6
|-
| OUTSW || <tt>6F</tt> || <tt>01101111</tt> || 1 || 6
|}
----
{{Anchor|POLL}}
=== POLL ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| POLL || <tt>6E</tt> || <tt>01101110</tt> || 1 || 9<ref>On the WonderSwan implementation, POLLB is always held low; on other implementations, POLL will wait for POLLB to be held low in 9-cycle intervals.</ref>
|}
----
{{Anchor|POP}}
=== POP ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| POP mem16 || <tt>8F /0</tt> || <tt>10001111 oo000mmm</tt> || 2+ || 3
|-
| POP reg16 || <tt>5x</tt> || <tt>01011xxx</tt> || 1 || 1
|-
| POP reg16 || <tt>8F /0</tt> || <tt>10001111 11000mmm</tt> || 2 || 1
|-
| POP sreg16 || <tt>xx</tt> || <tt>000xx111</tt> || 1 || 3
|}
----
{{Anchor|POPA}}
=== POPA ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| POPA || <tt>61</tt> || <tt>01100001</tt> || 1 || 8
|}
----
{{Anchor|POPF}}
=== POPF ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| POPF || <tt>9D</tt> || <tt>10011101</tt> || 1 || 3
|}
----
{{Anchor|PUSH}}
=== PUSH ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| PUSH imm8 || <tt>6A ii</tt> || <tt>01101010 iiiiiiii</tt> || 2 || 1
|-
| PUSH imm16 || <tt>68 ii ii</tt> || <tt>01101000 iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| PUSH mem16 || <tt>FF /6</tt> || <tt>11111111 oo110mmm</tt> || 2+ || 2
|-
| PUSH reg16 || <tt>5x</tt> || <tt>01010xxx</tt> || 1 || 1
|-
| PUSH reg16 || <tt>FF /6</tt> || <tt>11111111 11110mmm</tt> || 2 || 1
|-
| PUSH sreg16 || <tt>xx</tt> || <tt>000xx110</tt> || 1 || 2
|}
----
{{Anchor|PUSHA}}
=== PUSHA ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| PUSHA || <tt>60</tt> || <tt>01100000</tt> || 1 || 9
|}
----
{{Anchor|PUSHF}}
=== PUSHF ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| PUSHF || <tt>9C</tt> || <tt>10011100</tt> || 1 || 2
|}
----
{{Anchor|RCL}}
=== RCL ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| RCL mem8, 1 || <tt>D0 /2</tt> || <tt>11010000 oo010rm</tt> || 2+ || 3
|-
| RCL mem8, CL || <tt>D2 /2</tt> || <tt>11010010 oo010rm</tt> || 2+ || 5
|-
| RCL mem8, imm8 || <tt>C0 /2 ii</tt> || <tt>11000000 oo010rm</tt> || 3+ || 5
|-
| RCL mem16, 1 || <tt>D1 /2</tt> || <tt>11010001 oo010rm</tt> || 2+ || 3
|-
| RCL mem16, CL || <tt>D3 /2</tt> || <tt>11010011 oo010rm</tt> || 2+ || 5
|-
| RCL mem16, imm8 || <tt>C1 /2 ii</tt> || <tt>11000001 oo010rm</tt> || 3+ || 5
|-
| RCL reg8, 1 || <tt>D0 /2</tt> || <tt>11010000 11010rm</tt> || 2 || 1
|-
| RCL reg8, CL || <tt>D2 /2</tt> || <tt>11010010 11010rm</tt> || 2 || 3
|-
| RCL reg8, imm8 || <tt>C0 /2 ii</tt> || <tt>11000000 11010rm</tt> || 3 || 3
|-
| RCL reg16, 1 || <tt>D1 /2</tt> || <tt>11010001 11010rm</tt> || 2 || 1
|-
| RCL reg16, CL || <tt>D3 /2</tt> || <tt>11010011 11010rm</tt> || 2 || 3
|-
| RCL reg16, imm8 || <tt>C1 /2 ii</tt> || <tt>11000001 11010rm</tt> || 3 || 3
|}
----
{{Anchor|RCR}}
=== RCR ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| RCR mem8, 1 || <tt>D0 /3</tt> || <tt>11010000 oo011rm</tt> || 2+ || 3
|-
| RCR mem8, CL || <tt>D2 /3</tt> || <tt>11010010 oo011rm</tt> || 2+ || 5
|-
| RCR mem8, imm8 || <tt>C0 /3 ii</tt> || <tt>11000000 oo011rm</tt> || 3+ || 5
|-
| RCR mem16, 1 || <tt>D1 /3</tt> || <tt>11010001 oo011rm</tt> || 2+ || 3
|-
| RCR mem16, CL || <tt>D3 /3</tt> || <tt>11010011 oo011rm</tt> || 2+ || 5
|-
| RCR mem16, imm8 || <tt>C1 /3 ii</tt> || <tt>11000001 oo011rm</tt> || 3+ || 5
|-
| RCR reg8, 1 || <tt>D0 /3</tt> || <tt>11010000 11011rm</tt> || 2 || 1
|-
| RCR reg8, CL || <tt>D2 /3</tt> || <tt>11010010 11011rm</tt> || 2 || 3
|-
| RCR reg8, imm8 || <tt>C0 /3 ii</tt> || <tt>11000000 11011rm</tt> || 3 || 3
|-
| RCR reg16, 1 || <tt>D1 /3</tt> || <tt>11010001 11011rm</tt> || 2 || 1
|-
| RCR reg16, CL || <tt>D3 /3</tt> || <tt>11010011 11011rm</tt> || 2 || 3
|-
| RCR reg16, imm8 || <tt>C1 /3 ii</tt> || <tt>11000001 11011rm</tt> || 3 || 3
|}
----
{{Anchor|REP}}
=== REP/REPE/REPZ ===
----
{{Anchor|REPNE}}
=== REPNE/REPNZ ===
----
{{Anchor|RET}}
=== RET ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| RET || <tt>C3</tt> || <tt>11000011</tt> || 1 || 6
|-
| RET imm16 || <tt>C2 ii ii</tt> || <tt>11000010 iiiiiiii iiiiiiii</tt> || 1 || 6
|}
----
{{Anchor|RETF}}
=== RETF ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| RETF || <tt>CB</tt> || <tt>11001011</tt> || 1 || 9
|-
| RETF imm16 || <tt>CA ii ii</tt> || <tt>11001010 iiiiiiii iiiiiiii</tt> || 1 || 8
|}
----
{{Anchor|ROL}}
=== ROL ===
| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| ROL mem8, 1 || <tt>D0 /0</tt> || <tt>11010000 oo000rm</tt> || 2+ || 3
|-
| ROL mem8, CL || <tt>D2 /0</tt> || <tt>11010010 oo000rm</tt> || 2+ || 5
|-
| ROL mem8, imm8 || <tt>C0 /0 ii</tt> || <tt>11000000 oo000rm</tt> || 3+ || 5
|-
| ROL mem16, 1 || <tt>D1 /0</tt> || <tt>11010001 oo000rm</tt> || 2+ || 3
|-
| ROL mem16, CL || <tt>D3 /0</tt> || <tt>11010011 oo000rm</tt> || 2+ || 5
|-
| ROL mem16, imm8 || <tt>C1 /0 ii</tt> || <tt>11000001 oo000rm</tt> || 3+ || 5
|-
| ROL reg8, 1 || <tt>D0 /0</tt> || <tt>11010000 11000rm</tt> || 2 || 1
|-
| ROL reg8, CL || <tt>D2 /0</tt> || <tt>11010010 11000rm</tt> || 2 || 3
|-
| ROL reg8, imm8 || <tt>C0 /0 ii</tt> || <tt>11000000 11000rm</tt> || 3 || 3
|-
| ROL reg16, 1 || <tt>D1 /0</tt> || <tt>11010001 11000rm</tt> || 2 || 1
|-
| ROL reg16, CL || <tt>D3 /0</tt> || <tt>11010011 11000rm</tt> || 2 || 3
|-
| ROL reg16, imm8 || <tt>C1 /0 ii</tt> || <tt>11000001 11000rm</tt> || 3 || 3
|}
----
{{Anchor|ROR}}
=== ROR ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| ROR mem8, 1 || <tt>D0 /1</tt> || <tt>11010000 oo001rm</tt> || 2+ || 3
|-
| ROR mem8, CL || <tt>D2 /1</tt> || <tt>11010010 oo001rm</tt> || 2+ || 5
|-
| ROR mem8, imm8 || <tt>C0 /1 ii</tt> || <tt>11000000 oo001rm</tt> || 3+ || 5
|-
| ROR mem16, 1 || <tt>D1 /1</tt> || <tt>11010001 oo001rm</tt> || 2+ || 3
|-
| ROR mem16, CL || <tt>D3 /1</tt> || <tt>11010011 oo001rm</tt> || 2+ || 5
|-
| ROR mem16, imm8 || <tt>C1 /1 ii</tt> || <tt>11000001 oo001rm</tt> || 3+ || 5
|-
| ROR reg8, 1 || <tt>D0 /1</tt> || <tt>11010000 11001rm</tt> || 2 || 1
|-
| ROR reg8, CL || <tt>D2 /1</tt> || <tt>11010010 11001rm</tt> || 2 || 3
|-
| ROR reg8, imm8 || <tt>C0 /1 ii</tt> || <tt>11000000 11001rm</tt> || 3 || 3
|-
| ROR reg16, 1 || <tt>D1 /1</tt> || <tt>11010001 11001rm</tt> || 2 || 1
|-
| ROR reg16, CL || <tt>D3 /1</tt> || <tt>11010011 11001rm</tt> || 2 || 3
|-
| ROR reg16, imm8 || <tt>C1 /1 ii</tt> || <tt>11000001 11001rm</tt> || 3 || 3
|}
----
{{Anchor|SAHF}}
=== SAHF ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| SAHF || <tt>9E</tt> || <tt>10011110</tt> || 1 || 4
|}
----
{{Anchor|SAR}}
=== SAR ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| SAR mem8, 1 || <tt>D0 /7</tt> || <tt>11010000 oo111rm</tt> || 2+ || 3
|-
| SAR mem8, CL || <tt>D2 /7</tt> || <tt>11010010 oo111rm</tt> || 2+ || 5
|-
| SAR mem8, imm8 || <tt>C0 /7 ii</tt> || <tt>11000000 oo111rm</tt> || 3+ || 5
|-
| SAR mem16, 1 || <tt>D1 /7</tt> || <tt>11010001 oo111rm</tt> || 2+ || 3
|-
| SAR mem16, CL || <tt>D3 /7</tt> || <tt>11010011 oo111rm</tt> || 2+ || 5
|-
| SAR mem16, imm8 || <tt>C1 /7 ii</tt> || <tt>11000001 oo111rm</tt> || 3+ || 5
|-
| SAR reg8, 1 || <tt>D0 /7</tt> || <tt>11010000 11111rm</tt> || 2 || 1
|-
| SAR reg8, CL || <tt>D2 /7</tt> || <tt>11010010 11111rm</tt> || 2 || 3
|-
| SAR reg8, imm8 || <tt>C0 /7 ii</tt> || <tt>11000000 11111rm</tt> || 3 || 3
|-
| SAR reg16, 1 || <tt>D1 /7</tt> || <tt>11010001 11111rm</tt> || 2 || 1
|-
| SAR reg16, CL || <tt>D3 /7</tt> || <tt>11010011 11111rm</tt> || 2 || 3
|-
| SAR reg16, imm8 || <tt>C1 /7 ii</tt> || <tt>11000001 11111rm</tt> || 3 || 3
|}
----
{{Anchor|SBB}}
=== SBB ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| SBB AL, imm || <tt>1C ii</tt> || <tt>00011100 iiiiiiii</tt> || 2 || 1
|-
| SBB AX, imm || <tt>1D ii ii</tt> || <tt>00011101 iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| SBB mem8, imm8 || <tt>80 /3 ii</tt> || <tt>10000000 oo011mmm iiiiiiii</tt> || 3+ || 3
|-
| SBB mem16, imm16 || <tt>81 /3 ii ii</tt> || <tt>10000001 oo011mmm iiiiiiii iiiiiiii</tt> || 4+ || 3
|-
| SBB mem16, simm8 || <tt>83 /3 ii</tt> || <tt>10000011 oo011mmm iiiiiiii</tt> || 3+ || 3
|-
| SBB mem8, reg8 || <tt>18 /r</tt> || <tt>00011000 oorrrmmm</tt> || 2+ || 3
|-
| SBB mem16, reg16 || <tt>19 /r</tt> || <tt>00011001 oorrrmmm</tt> || 2+ || 3
|-
| SBB reg8, imm8 || <tt>80 /3 ii</tt> || <tt>10000000 11011mmm iiiiiiii</tt> || 3 || 1
|-
| SBB reg16, imm16 || <tt>81 /3 ii ii</tt> || <tt>10000001 11011mmm iiiiiiii iiiiiiii</tt> || 4 || 1
|-
| SBB reg16, simm8 || <tt>83 /3 ii</tt> || <tt>10000011 11011mmm iiiiiiii</tt> || 3 || 1
|-
| SBB reg8, mem8 || <tt>1A /r</tt> || <tt>00011010 oorrrmmm</tt> || 2+ || 2
|-
| SBB reg16, mem16 || <tt>1B /r</tt> || <tt>00011011 oorrrmmm</tt> || 2+ || 2
|-
| SBB reg8, reg8 || <tt>18 /r</tt> || <tt>000110.0 11rrrmmm</tt> || 2 || 1
|-
| SBB reg16, reg16 || <tt>19 /r</tt> || <tt>000110.1 11rrrmmm</tt> || 2 || 1
|}
----
{{Anchor|SCASB}}
{{Anchor|SCASW}}
=== SCASB/SCASW ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| SCASB || <tt>AE</tt> || <tt>10101110</tt> || 1 || 4
|-
| SCASW || <tt>AF</tt> || <tt>10101111</tt> || 1 || 4
|}
----
{{Anchor|SHL}}
=== SHL ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| SHL mem8, 1 || <tt>D0 /4</tt> || <tt>11010000 oo100rm</tt> || 2+ || 3
|-
| SHL mem8, CL || <tt>D2 /4</tt> || <tt>11010010 oo100rm</tt> || 2+ || 5
|-
| SHL mem8, imm8 || <tt>C0 /4 ii</tt> || <tt>11000000 oo100rm</tt> || 3+ || 5
|-
| SHL mem16, 1 || <tt>D1 /4</tt> || <tt>11010001 oo100rm</tt> || 2+ || 3
|-
| SHL mem16, CL || <tt>D3 /4</tt> || <tt>11010011 oo100rm</tt> || 2+ || 5
|-
| SHL mem16, imm8 || <tt>C1 /4 ii</tt> || <tt>11000001 oo100rm</tt> || 3+ || 5
|-
| SHL reg8, 1 || <tt>D0 /4</tt> || <tt>11010000 11100rm</tt> || 2 || 1
|-
| SHL reg8, CL || <tt>D2 /4</tt> || <tt>11010010 11100rm</tt> || 2 || 3
|-
| SHL reg8, imm8 || <tt>C0 /4 ii</tt> || <tt>11000000 11100rm</tt> || 3 || 3
|-
| SHL reg16, 1 || <tt>D1 /4</tt> || <tt>11010001 11100rm</tt> || 2 || 1
|-
| SHL reg16, CL || <tt>D3 /4</tt> || <tt>11010011 11100rm</tt> || 2 || 3
|-
| SHL reg16, imm8 || <tt>C1 /4 ii</tt> || <tt>11000001 11100rm</tt> || 3 || 3
|}
----
{{Anchor|SHR}}
=== SHR ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| SHR mem8, 1 || <tt>D0 /5</tt> || <tt>11010000 oo101rm</tt> || 2+ || 3
|-
| SHR mem8, CL || <tt>D2 /5</tt> || <tt>11010010 oo101rm</tt> || 2+ || 5
|-
| SHR mem8, imm8 || <tt>C0 /5 ii</tt> || <tt>11000000 oo101rm</tt> || 3+ || 5
|-
| SHR mem16, 1 || <tt>D1 /5</tt> || <tt>11010001 oo101rm</tt> || 2+ || 3
|-
| SHR mem16, CL || <tt>D3 /5</tt> || <tt>11010011 oo101rm</tt> || 2+ || 5
|-
| SHR mem16, imm8 || <tt>C1 /5 ii</tt> || <tt>11000001 oo101rm</tt> || 3+ || 5
|-
| SHR reg8, 1 || <tt>D0 /5</tt> || <tt>11010000 11101rm</tt> || 2 || 1
|-
| SHR reg8, CL || <tt>D2 /5</tt> || <tt>11010010 11101rm</tt> || 2 || 3
|-
| SHR reg8, imm8 || <tt>C0 /5 ii</tt> || <tt>11000000 11101rm</tt> || 3 || 3
|-
| SHR reg16, 1 || <tt>D1 /5</tt> || <tt>11010001 11101rm</tt> || 2 || 1
|-
| SHR reg16, CL || <tt>D3 /5</tt> || <tt>11010011 11101rm</tt> || 2 || 3
|-
| SHR reg16, imm8 || <tt>C1 /5 ii</tt> || <tt>11000001 11101rm</tt> || 3 || 3
|}
----
{{Anchor|SS}}
=== SS ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| SS || <tt>36</tt> || <tt>00110110</tt> || 1 || 1
|}
----
{{Anchor|STC}}
=== STC ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| STC || <tt>F9</tt> || <tt>11111001</tt> || 1 || 4
|}
----
{{Anchor|STD}}
=== STD ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| STD || <tt>FD</tt> || <tt>11111101</tt> || 1 || 4
|}
----
{{Anchor|STI}}
=== STI ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| STI || <tt>FB</tt> || <tt>11111011</tt> || 1 || 4
|}
----
{{Anchor|STOSB}}
{{Anchor|STOSW}}
=== STOSB/STOSW ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| STOSB || <tt>AA</tt> || <tt>10101010</tt> || 1 || 3
|-
| STOSW || <tt>AB</tt> || <tt>10101011</tt> || 1 || 3
|}
----
{{Anchor|SUB}}
=== SUB ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| SUB AL, imm || <tt>28 ii</tt> || <tt>00101100 iiiiiiii</tt> || 2 || 1
|-
| SUB AX, imm || <tt>29 ii ii</tt> || <tt>00101101 iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| SUB mem8, imm8 || <tt>80 /5 ii</tt> || <tt>10000000 oo101mmm iiiiiiii</tt> || 3+ || 3
|-
| SUB mem16, imm16 || <tt>81 /5 ii ii</tt> || <tt>10000001 oo101mmm iiiiiiii iiiiiiii</tt> || 4+ || 3
|-
| SUB mem16, simm8 || <tt>83 /5 ii</tt> || <tt>10000011 oo101mmm iiiiiiii</tt> || 3+ || 3
|-
| SUB mem8, reg8 || <tt>28 /r</tt> || <tt>00101000 oorrrmmm</tt> || 2+ || 3
|-
| SUB mem16, reg16 || <tt>29 /r</tt> || <tt>00101001 oorrrmmm</tt> || 2+ || 3
|-
| SUB reg8, imm8 || <tt>80 /5 ii</tt> || <tt>10000000 11101mmm iiiiiiii</tt> || 3 || 1
|-
| SUB reg16, imm16 || <tt>81 /5 ii ii</tt> || <tt>10000001 11101mmm iiiiiiii iiiiiiii</tt> || 4 || 1
|-
| SUB reg16, simm8 || <tt>83 /5 ii</tt> || <tt>10000011 11101mmm iiiiiiii</tt> || 3 || 1
|-
| SUB reg8, mem8 || <tt>2A /r</tt> || <tt>00101010 oorrrmmm</tt> || 2+ || 2
|-
| SUB reg16, mem16 || <tt>2B /r</tt> || <tt>00101011 oorrrmmm</tt> || 2+ || 2
|-
| SUB reg8, reg8 || <tt>28 /r</tt> || <tt>001010.0 11rrrmmm</tt> || 2 || 1
|-
| SUB reg16, reg16 || <tt>29 /r</tt> || <tt>001010.1 11rrrmmm</tt> || 2 || 1
|}
----
{{Anchor|TEST}}
=== TEST ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| TEST AL, imm || <tt>A8 ii</tt> || <tt>10101000 iiiiiiii</tt> || 2 || 1
|-
| TEST AX, imm || <tt>A9 ii ii</tt> || <tt>10101001 iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| TEST mem8, imm8 || <tt>F6 /0 ii</tt> || <tt>11110110 oo000mmm iiiiiiii</tt> || 3+ || 2
|-
| TEST mem16, imm16 || <tt>F7 /0 ii ii</tt> || <tt>11110111 oo000mmm iiiiiiii iiiiiiii</tt> || 4+ || 2
|-
| TEST mem8, reg8<br/>TEST reg8, mem8 || <tt>84 /r</tt> || <tt>10000100 oorrrmmm</tt> || 2+ || 2
|-
| TEST mem16, reg16<br/>TEST reg16, mem16 || <tt>85 /r</tt> || <tt>10000101 oorrrmmm</tt> || 2+ || 2
|-
| TEST reg8, imm8 || <tt>F6 /0 ii</tt> || <tt>11110110 11000mmm iiiiiiii</tt> || 3 || 1
|-
| TEST reg16, imm16 || <tt>F7 /0 ii ii</tt> || <tt>11110111 11000mmm iiiiiiii iiiiiiii</tt> || 4 || 1
|-
| TEST reg8, reg8 || <tt>84 /r</tt> || <tt>10000100 11rrrmmm</tt> || 2 || 1
|-
| TEST reg16, reg16 || <tt>85 /r</tt> || <tt>10000101 11rrrmmm</tt> || 2 || 1
|}
----
{{Anchor|XCHG}}
=== XCHG ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| XCHG AX, reg16<br/>XCHG reg16, AX || <tt>9x</tt> || <tt>10010rrr</tt> || 1 || 3
|-
| XCHG mem8, reg8<br/>XCHG reg8, mem8 || <tt>86 /r</tt> || <tt>10000110 oorrrmmm</tt> || 2+ || 5
|-
| XCHG mem16, reg16<br/>XCHG reg16, mem16 || <tt>87 /r</tt> || <tt>10000111 oorrrmmm</tt> || 2+ || 5
|-
| XCHG reg8, reg8 || <tt>86 /r</tt> || <tt>10000110 11rrrmmm</tt> || 2+ || 3
|-
| XCHG reg16, reg16 || <tt>87 /r</tt> || <tt>10000111 11rrrmmm</tt> || 2+ || 3
|}
----
{{Anchor|XLAT}}
=== XLAT ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| XLAT || <tt>D7</tt> || <tt>11010111</tt> || 1 || 5
|}
----
{{Anchor|XOR}}
=== XOR ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| XOR AL, imm || <tt>34 ii</tt> || <tt>00110100 iiiiiiii</tt> || 2 || 1
|-
| XOR AX, imm || <tt>35 ii ii</tt> || <tt>00110101 iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| XOR mem8, imm8 || <tt>80 /6 ii</tt> || <tt>10000000 oo110mmm iiiiiiii</tt> || 3+ || 3
|-
| XOR mem16, imm16 || <tt>81 /6 ii ii</tt> || <tt>10000001 oo110mmm iiiiiiii iiiiiiii</tt> || 4+ || 3
|-
| XOR mem16, simm8 || <tt>83 /6 ii</tt> || <tt>10000011 oo110mmm iiiiiiii</tt> || 3+ || 3
|-
| XOR mem8, reg8 || <tt>30 /r</tt> || <tt>00110000 oorrrmmm</tt> || 2+ || 3
|-
| XOR mem16, reg16 || <tt>31 /r</tt> || <tt>00110001 oorrrmmm</tt> || 2+ || 3
|-
| XOR reg8, imm8 || <tt>80 /6 ii</tt> || <tt>10000000 11110mmm iiiiiiii</tt> || 3 || 1
|-
| XOR reg16, imm16 || <tt>81 /6 ii ii</tt> || <tt>10000001 11110mmm iiiiiiii iiiiiiii</tt> || 4 || 1
|-
| XOR reg16, simm8 || <tt>83 /6 ii</tt> || <tt>10000011 11110mmm iiiiiiii</tt> || 3 || 1
|-
| XOR reg8, mem8 || <tt>32 /r</tt> || <tt>00110010 oorrrmmm</tt> || 2+ || 2
|-
| XOR reg16, mem16 || <tt>33 /r</tt> || <tt>00110011 oorrrmmm</tt> || 2+ || 2
|-
| XOR reg8, reg8 || <tt>30 /r</tt> || <tt>001100.0 11rrrmmm</tt> || 2 || 1
|-
| XOR reg16, reg16 || <tt>31 /r</tt> || <tt>001100.1 11rrrmmm</tt> || 2 || 1
|}
----
== Notes ==
<references />
c5e8333b5622ded24c20de76d80ade53e83e9a7f
461
460
2024-12-27T23:34:50Z
Asie
351
wikitext
text/x-wiki
__NOTOC__
Note that this page is a work in progress.
{| class="wikitable" style="text-align: center"
|+ Official V30MZ (80186) Instructions
|-
| [[#AAA|AAA]] || [[#AAD|AAD]] || [[#AAM|AAM]] || [[#AAS|AAS]] || [[#ADC|ADC]] || [[#ADD|ADD]] || [[#AND|AND]] || [[#BOUND|BOUND]] || [[#CALL|CALL]] || [[#CBW|CBW]] || [[#CLC|CLC]]
|-
| [[#CLD|CLD]] || [[#CLI|CLI]] || [[#CMC|CMC]] || [[#CMP|CMP]] || [[#CMPSB|CMPSB]] || [[#CMPSW|CMPSW]] || [[#CS|CS]] || [[#CWD|CWD]] || [[#DAA|DAA]] || [[#DAS|DAS]] || [[#DEC|DEC]]
|-
| [[#DIV|DIV]] || [[#DS|DS]] || [[#ENTER|ENTER]] || [[#ES|ES]] || [[#HLT|HLT]] || [[#IDIV|IDIV]] || [[#IMUL|IMUL]] || [[#IN|IN]] || [[#INC|INC]] || [[#INSB|INSB]] || [[#INSW|INSW]]
|-
| [[#INT|INT]] || [[#INTO|INTO]] || [[#IRET|IRET]] || [[#JA|JA]] || [[#JBE|JBE]] || [[#JC|JC]] || [[#JCXZ|JCXZ]] || [[#JG|JG]] || [[#JGE|JGE]] || [[#JL|JL]] || [[#JLE|JLE]]
|-
| [[#JMP|JMP]] || [[#JNC|JNC]] || [[#JNO|JNO]] || [[#JNP|JNP]] || [[#JNS|JNS]] || [[#JNZ|JNZ]] || [[#JO|JO]] || [[#JP|JP]] || [[#JS|JS]] || [[#JZ|JZ]] || [[#LAHF|LAHF]]
|-
| [[#LDS|LDS]] || [[#LEA|LEA]] || [[#LEAVE|LEAVE]] || [[#LES|LES]] || [[#LOCK|LOCK]] || [[#LODSB|LODSB]] || [[#LODSW|LODSW]] || [[#LOOP|LOOP]] || [[#LOOPE|LOOPE]] || [[#LOOPNE|LOOPNE]] || [[#MOV|MOV]]
|-
| [[#MOVSB|MOVSB]] || [[#MOVSW|MOVSW]] || [[#MUL|MUL]] || [[#NEG|NEG]] || [[#NOP|NOP]] || [[#NOT|NOT]] || [[#OR|OR]] || [[#OUT|OUT]] || [[#OUTSB|OUTSB]] || [[#OUTSW|OUTSW]] || [[#POLL|POLL]]
|-
| [[#POP|POP]] || [[#POPA|POPA]] || [[#POPF|POPF]] || [[#PUSH|PUSH]] || [[#PUSHA|PUSHA]] || [[#PUSHF|PUSHF]] || [[#RCL|RCL]] || [[#RCR|RCR]] || [[#REP|REP]] || [[#REPNE|REPNE]] || [[#RET|RET]]
|-
| [[#RETF|RETF]] || [[#ROL|ROL]] || [[#ROR|ROR]] || [[#SAHF|SAHF]] || [[#SAR|SAR]] || [[#SBB|SBB]] || [[#SCASB|SCASB]] || [[#SCASW|SCASW]] || [[#SHL|SHL]] || [[#SHR|SHR]] || [[#SS|SS]]
|-
| [[#STC|STC]] || [[#STD|STD]] || [[#STI|STI]] || [[#STOSB|STOSB]] || [[#STOSW|STOSW]] || [[#SUB|SUB]] || [[#TEST|TEST]] || [[#XCHG|XCHG]] || [[#XLAT|XLAT]] || [[#XOR|XOR]]
|}
{| class="mw-collapsible mw-collapsed wikitable sortable" style="width: 340px;"
|+ style="white-space:nowrap; border:1px solid; padding:3px; border-color:rgb(162, 169, 177); background-color:rgb(234, 236, 240);" | Intel <-> NEC mnemonic translation table
!Intel
!NEC
|-
| [[#AAA|AAA]]
| [[#AAA|ADJBA]]
|-
| [[#AAD|AAD]]
| [[#AAD|CVTDB]]
|-
| [[#AAM|AAM]]
| [[#AAM|CVTBD]]
|-
| [[#AAS|AAS]]
| [[#AAS|ADJBS]]
|-
| [[#ADC|ADC]]
| [[#ADC|ADDC]]
|-
| [[#ADD|ADD]]
| [[#ADD|ADD]]
|-
| [[#AND|AND]]
| [[#AND|AND]]
|-
| [[#BOUND|BOUND]]
| [[#BOUND|CHKIND]]
|-
| [[#CALL|CALL]]
| [[#CALL|CALL]]
|-
| [[#CBW|CBW]]
| [[#CBW|CVTBW]]
|-
| [[#CLC|CLC]]
| [[#CLC|CLR1 CY]]
|-
| [[#CLD|CLD]]
| [[#CLD|CLR1 DIR]]
|-
| [[#CLI|CLI]]
| [[#CLI|DI]]
|-
| [[#CMC|CMC]]
| [[#CMC|NOT1 CY]]
|-
| [[#CMP|CMP]]
| [[#CMP|CMP]]
|-
| [[#CMPSB|CMPSB]]
| [[#CMPSB|CMPBKB]]
|-
| [[#CMPSW|CMPSW]]
| [[#CMPSW|CMPBKW]]
|-
| [[#CS|CS]]
| [[#CS|PS]]
|-
| [[#CWD|CWD]]
| [[#CWD|CVTWL]]
|-
| [[#DAA|DAA]]
| [[#DAA|ADJ4A]]
|-
| [[#DAS|DAS]]
| [[#DAS|ADJ4S]]
|-
| [[#DEC|DEC]]
| [[#DEC|DEC]]
|-
| [[#DIV|DIV]]
| [[#DIV|DIVU]]
|-
| [[#DS|DS]]
| [[#DS|DS0]]
|-
| [[#ENTER|ENTER]]
| [[#ENTER|PREPARE]]
|-
| [[#ES|ES]]
| [[#ES|DS1]]
|-
| [[#HLT|HLT]]
| [[#HLT|HALT]]
|-
| [[#IDIV|IDIV]]
| [[#IDIV|DIV]]
|-
| [[#IMUL|IMUL]]
| [[#IMUL|MUL]]
|-
| [[#IN|IN]]
| [[#IN|IN]]
|-
| [[#INC|INC]]
| [[#INC|INC]]
|-
| [[#INSB|INSB]]
| [[#INSB|INMB]]
|-
| [[#INSW|INSW]]
| [[#INSW|INMW]]
|-
| [[#INT|INT]]
| [[#INT|BRK]]
|-
| [[#INTO|INTO]]
| [[#INTO|BRKV]]
|-
| [[#IRET|IRET]]
| [[#IRET|RETI]]
|-
| [[#JA|JA]]
| [[#JA|BH]]
|-
| [[#JBE|JBE]]
| [[#JBE|BNH]]
|-
| [[#JC|JC/JB]]
| [[#JC|BC/BL]]
|-
| [[#JCXZ|JCXZ]]
| [[#JCXZ|BCWZ]]
|-
| [[#JG|JG]]
| [[#JG|BGT]]
|-
| [[#JGE|JGE]]
| [[#JGE|BGE]]
|-
| [[#JL|JL]]
| [[#JL|BLT]]
|-
| [[#JLE|JLE]]
| [[#JLE|BLE]]
|-
| [[#JMP|JMP]]
| [[#JMP|BR]]
|-
| [[#JNC|JNC/JAE]]
| [[#JNC|BNC/BNL]]
|-
| [[#JNO|JNO]]
| [[#JNO|BNV]]
|-
| [[#JNP|JNP]]
| [[#JNP|BPO]]
|-
| [[#JNS|JNS]]
| [[#JNS|BP]]
|-
| [[#JNZ|JNZ/JNE]]
| [[#JNZ|BNZ/BNE]]
|-
| [[#JO|JO]]
| [[#JO|BV]]
|-
| [[#JP|JP]]
| [[#JP|BPE]]
|-
| [[#JS|JS]]
| [[#JS|BN]]
|-
| [[#JZ|JZ/JE]]
| [[#JZ|BZ/BE]]
|-
| [[#LAHF|LAHF]]
| [[#LAHF|MOV]]
|-
| [[#LDS|LDS]]
| [[#LDS|MOV]]
|-
| [[#LEA|LEA]]
| [[#LEA|LDEA]]
|-
| [[#LEAVE|LEAVE]]
| [[#LEAVE|DISPOSE]]
|-
| [[#LES|LES]]
| [[#LES|MOV]]
|-
| [[#LOCK|LOCK]]
| [[#LOCK|BUSLOCK]]
|-
| [[#LODSB|LODSB]]
| [[#LODSB|LDMB]]
|-
| [[#LODSW|LODSW]]
| [[#LODSW|LDMW]]
|-
| [[#LOOP|LOOP]]
| [[#LOOP|DBNZ]]
|-
| [[#LOOPE|LOOPE]]
| [[#LOOPE|DBNZE]]
|-
| [[#LOOPNE|LOOPNE]]
| [[#LOOPNE|DBNZNE]]
|-
| [[#MOV|MOV]]
| [[#MOV|MOV]]
|-
| [[#MOVSB|MOVSB]]
| [[#MOVSB|MOVBKB]]
|-
| [[#MOVSW|MOVSW]]
| [[#MOVSW|MOVBKW]]
|-
| [[#MUL|MUL]]
| [[#MUL|MULU]]
|-
| [[#NEG|NEG]]
| [[#NEG|NEG]]
|-
| [[#NOP|NOP]]
| [[#NOP|NOP]]
|-
| [[#NOT|NOT]]
| [[#NOT|NOT]]
|-
| [[#OR|OR]]
| [[#OR|OR]]
|-
| [[#OUT|OUT]]
| [[#OUT|OUT]]
|-
| [[#OUTSB|OUTSB]]
| [[#OUTSB|OUTM]]
|-
| [[#OUTSW|OUTSW]]
| [[#OUTSW|OUTM]]
|-
| [[#POLL|POLL]]
| [[#POLL|POLL]]
|-
| [[#POP|POP]]
| [[#POP|POP]]
|-
| [[#POPA|POPA]]
| [[#POPA|POP]]
|-
| [[#POPF|POPF]]
| [[#POPF|POP]]
|-
| [[#PUSH|PUSH]]
| [[#PUSH|PUSH]]
|-
| [[#PUSHA|PUSHA]]
| [[#PUSHA|PUSH]]
|-
| [[#PUSHF|PUSHF]]
| [[#PUSHF|PUSH]]
|-
| [[#RCL|RCL]]
| [[#RCL|ROLC]]
|-
| [[#RCR|RCR]]
| [[#RCR|RORC]]
|-
| [[#REP|REP/REPE/REPZ]]
| [[#REP|REP/REPE/REPZ]]
|-
| [[#REPNE|REPNE/REPNZ]]
| [[#REPNE|REPNE/REPNZ]]
|-
| [[#RET|RET]]
| [[#RET|RET]]
|-
| [[#RETF|RETF]]
| [[#RETF|RET]]
|-
| [[#ROL|ROL]]
| [[#ROL|ROL]]
|-
| [[#ROR|ROR]]
| [[#ROR|ROR]]
|-
| [[#SAHF|SAHF]]
| [[#SAHF|MOV]]
|-
| [[#SAR|SAR]]
| [[#SAR|SHRA]]
|-
| [[#SBB|SBB]]
| [[#SBB|SUBC]]
|-
| [[#SCASB|SCASB]]
| [[#SCASB|CMPMB]]
|-
| [[#SCASW|SCASW]]
| [[#SCASW|CMPMW]]
|-
| [[#SHL|SHL]]
| [[#SHL|SHL]]
|-
| [[#SHR|SHR]]
| [[#SHR|SHR]]
|-
| [[#SS|SS]]
| [[#SS|SS]]
|-
| [[#STC|STC]]
| [[#STC|SET1 CY]]
|-
| [[#STD|STD]]
| [[#STD|SET1 DIR]]
|-
| [[#STI|STI]]
| [[#STI|EI]]
|-
| [[#STOSB|STOSB]]
| [[#STOSB|STMB]]
|-
| [[#STOSW|STOSW]]
| [[#STOSW|STMW]]
|-
| [[#SUB|SUB]]
| [[#SUB|SUB]]
|-
| [[#TEST|TEST]]
| [[#TEST|TEST]]
|-
| [[#XCHG|XCHG]]
| [[#XCHG|XCH]]
|-
| [[#XLAT|XLAT]]
| [[#XLAT|TRANS]]
|-
| [[#XOR|XOR]]
| [[#XOR|XOR]]
|}
== Official instructions by type ==
{| class="wikitable sortable" style="text-align: center"
!Type
!colspan=16 class="unsortable" | Instructions
|-
| style="text-align:left;" | Memory
| style="" | [[#MOV|MOV]]
| style="" | [[#XCHG|XCHG]]
| style="" | [[#XLAT|XLAT]]
| style="" | [[#LEA|LEA]]
| style="border-right:none;" | [[#LDS|LDS]]
| style="border-left:none;" | [[#LES|LES]]
| style="border-right:none;" | [[#IN|IN]]
| style="border-left:none;" | [[#OUT|OUT]]
| colspan="8" |
|-
| style="text-align:left;" | Ports
| style="border-right:none;" | [[#IN|IN]]
| style="border-left:none;" | [[#OUT|OUT]]
| style="border-right:none;" | [[#INSB|INSB]]
| style="border-left:none;" | [[#OUTSB|OUTSB]]
| style="border-right:none;" | [[#INSW|INSW]]
| style="border-left:none;" | [[#OUTSW|OUTSW]]
| colspan="10" |
|-
| style="text-align:left;" | Arithmetic
| style="border-right:none;" | [[#ADD|ADD]]
| style="border-left:none;" | [[#SUB|SUB]]
| style="border-right:none;" | [[#ADC|ADC]]
| style="border-left:none;" | [[#SBB|SBB]]
| style="border-right:none;" | [[#INC|INC]]
| style="border-left:none;" | [[#DEC|DEC]]
| style="border-right:none;" | [[#MUL|MUL]]
| style="border-left:none;" | [[#DIV|DIV]]
| style="border-right:none;" | [[#IMUL|IMUL]]
| style="border-left:none;" | [[#IDIV|IDIV]]
| style="" | [[#CMP|CMP]]
| style="" | [[#NEG|NEG]]
| colspan="4" |
|-
| style="text-align:left;" | Numeric
| style="" | [[#CBW|CBW]]
| style="" | [[#CWD|CWD]]
| style="" | [[#AAA|AAA]]
| style="" | [[#AAS|AAS]]
| style="" | [[#AAM|AAM]]
| style="" | [[#AAD|AAD]]
| style="" | [[#DAA|DAA]]
| style="" | [[#DAS|DAS]]
| colspan="8" |
|-
| style="text-align:left;" | Shift
| style="border-right:none;" | [[#ROL|ROL]]
| style="border-left:none;" | [[#ROR|ROR]]
| style="border-right:none;" | [[#RCL|RCL]]
| style="border-left:none;" | [[#RCR|RCR]]
| style="border-right:none;" | [[#SHL|SHL]]
| style="border-left:none;" | [[#SHR|SHR]]
| style="" | [[#SAR|SAR]]
| colspan="9" |
|-
| style="text-align:left;" | Bitwise
| style="" | [[#AND|AND]]
| style="" | [[#OR|OR]]
| style="" | [[#XOR|XOR]]
| style="" | [[#NOT|NOT]]
| style="" | [[#TEST|TEST]]
| colspan="11" |
|-
| style="text-align:left;" | Branch
| style="border-right:none;" | [[#JC|JC]]
| style="border-left:none;" | [[#JNC|JNC]]
| style="border-right:none;" | [[#JZ|JZ]]
| style="border-left:none;" | [[#JNZ|JNZ]]
| style="border-right:none;" | [[#JBE|JBE]]
| style="border-left:none;" | [[#JA|JA]]
| style="border-right:none;" | [[#JO|JO]]
| style="border-left:none;" | [[#JNO|JNO]]
| style="border-right:none;" | [[#JP|JP]]
| style="border-left:none;" | [[#JNP|JNP]]
| style="border-right:none;" | [[#JS|JS]]
| style="border-left:none;" | [[#JNS|JNS]]
| style="border-right:none;" | [[#JL|JL]]
| style="border-left:none;" | [[#JGE|JGE]]
| style="border-right:none;" | [[#JLE|JLE]]
| style="border-left:none;" | [[#JG|JG]]
|-
| style="text-align:left;" | Jump
| style="" | [[#JMP|JMP]]
| style="border-right:none;" | [[#CALL|CALL]]
| style="border-left:none;border-right:none;" | [[#RET|RET]]
| style="border-left:none;" | [[#RETF|RETF]]
| colspan="12" |
|-
| style="text-align:left;" | Loop
| style="" | [[#LOOP|LOOP]]
| style="" | [[#LOOPE|LOOPE]]
| style="" | [[#LOOPNE|LOOPNE]]
| colspan="13" |
|-
| style="text-align:left;" | Interrupt
| style="border-right:none;" | [[#INT|INT]]
| style="border-left:none;" | [[#IRET|IRET]]
| style="" | [[#INTO|INTO]]
| style="" | [[#HLT|HLT]]
| style="" | [[#BOUND|BOUND]]
| colspan="11" |
|-
| style="text-align:left;" | Stack
| style="border-right:none;" | [[#PUSH|PUSH]]
| style="border-left:none;" | [[#POP|POP]]
| style="border-right:none;" | [[#PUSHA|PUSHA]]
| style="border-left:none;" | [[#POPA|POPA]]
| style="border-right:none;" | [[#PUSHF|PUSHF]]
| style="border-left:none;" | [[#POPF|POPF]]
| colspan="10" |
|-
| style="text-align:left;" | Flags
| style="border-right:none;" | [[#CLC|CLC]]
| style="border-left:none;" | [[#STC|STC]]
| style="border-right:none;" | [[#CLD|CLD]]
| style="border-left:none;" | [[#STD|STD]]
| style="border-right:none;" | [[#CLI|CLI]]
| style="border-left:none;" | [[#STI|STI]]
| style="" | [[#CMC|CMC]]
| style="border-right:none;" | [[#LAHF|LAHF]]
| style="border-left:none;" | [[#SAHF|SAHF]]
| colspan="7" |
|-
| style="text-align:left;" | Prefix
| style="" | [[#CS|CS]]
| style="" | [[#DS|DS]]
| style="" | [[#ES|ES]]
| style="" | [[#SS|SS]]
| colspan="12" |
|-
| style="text-align:left;" | String
| style="border-right:none;" | [[#REP|REP]]
| style="border-left:none;border-right:none;" | [[#REP|REPE]]
| style="border-left:none;" | [[#REPNE|REPNE]]
| style="" | [[#MOVSB|MOVSB]]
| style="" | [[#MOVSW|MOVSW]]
| style="border-right:none;" | [[#LODSB|LODSB]]
| style="border-left:none;" | [[#STOSB|STOSB]]
| style="border-right:none;" | [[#LODSW|LODSW]]
| style="border-left:none;" | [[#STOSW|STOSW]]
| style="" | [[#CMPSB|CMPSB]]
| style="" | [[#SCASB|SCASB]]
| style="" | [[#CMPSW|CMPSW]]
| style="" | [[#SCASW|SCASW]]
| colspan="3" |
|-
| style="text-align:left;" | Other
| style="" | [[#NOP|NOP]]
| style="border-right:none;" | [[#ENTER|ENTER]]
| style="border-left:none;" | [[#LEAVE|LEAVE]]
| style="" | [[#LOCK|LOCK]]
| style="" | [[#POLL|POLL]]
| colspan="11" |
|}
== Instruction encoding ==
=== ModR/M byte ===
The ModR/M byte is used in most addressing modes which reference a memory location. This byte consists of three bitfield values:
* <tt>oo</tt> - M'''o'''de;
* <tt>rrr</tt> - Two possible functions:
** '''R'''egister (for addressing modes which require both a register and a register/memory operand),
** Opcode extension (for some opcodes' addressing modes which do not have such a requirement);
* <tt>mmm</tt> - Register/'''M'''emory.
The ''Mode'' and ''Register/Memory'' bitfields can refer to a memory location or to a register, as shown in the table below. In some addressing modes, the ''Register'' field also refers to a register; it is always interpreted as if ''Mode'' was equal to <tt>11</tt>.
{| class="wikitable" style="text-align: center"
! R/M \ Mode
! <tt>00</tt>
! <tt>01</tt>
! <tt>10</tt>
! <tt>11</tt> ''(byte)''
! <tt>11</tt> ''(word)''
|-
| <tt>000</tt>
| DS:[BX + SI]
| DS:[BX + SI + disp8]
| DS:[BX + SI + disp16]
| AL
| AX
|-
| <tt>001</tt>
| DS:[BX + DI]
| DS:[BX + DI + disp8]
| DS:[BX + DI + disp16]
| CL
| CX
|-
| <tt>010</tt>
| SS:[BP + SI]
| SS:[BP + SI + disp8]
| SS:[BP + SI + disp16]
| DL
| DX
|-
| <tt>011</tt>
| SS:[BP + DI]
| SS:[BP + DI + disp8]
| SS:[BP + DI + disp16]
| BL
| BX
|-
| <tt>100</tt>
| DS:[SI]
| DS:[SI + disp8]
| DS:[SI + disp16]
| AH
| SP
|-
| <tt>101</tt>
| DS:[DI]
| DS:[DI + disp8]
| DS:[DI + disp16]
| CH
| BP
|-
| <tt>110</tt>
| ''DS:[disp16]''
| SS:[BP + disp8]
| SS:[BP + disp16]
| DH
| SI
|-
| <tt>111</tt>
| DS:[BX]
| DS:[BX + disp8]
| DS:[BX + disp16]
| BH
| DI
|}
Displacements are either 8-bit (disp8) or 16-bit (disp16) signed values and they always immediately follow the ModR/M byte. Note that (<tt>oo</tt> = <tt>00</tt>, <tt>mmm</tt> = <tt>110</tt>) is a special case, in which the ''disp16'' value is used directly as a near pointer.
The instruction encoding lists below refer to this byte as <tt>oorrrmmm</tt> (binary), <tt>/r</tt> (hexadecimal) or <tt>/0</tt> (hexademical, <tt>rrr</tt> used as function <tt>0</tt>).
== Official instructions ==
{{Anchor|AAA}}
=== AAA ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| AAA || <tt>37</tt> || <tt>00110111</tt> || 1 || 9
|}
----
{{Anchor|AAD}}
=== AAD ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| AAD imm8 || <tt>B5 ii</tt> || <tt>11010100 iiiiiiii</tt> || 2 || 6
|}
----
{{Anchor|AAM}}
=== AAM ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| AAM imm8 || <tt>B4 ii</tt> || <tt>11010100 iiiiiiii</tt> || 2 || 17
|}
----
{{Anchor|AAS}}
=== AAS ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| AAS || <tt>3F</tt> || <tt>00111111</tt> || 1 || 9
|}
----
{{Anchor|ADC}}
=== ADC ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| ADC AL, imm || <tt>14 ii</tt> || <tt>00010100 iiiiiiii</tt> || 2 || 1
|-
| ADC AX, imm || <tt>15 ii ii</tt> || <tt>00010101 iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| ADC mem8, imm8 || <tt>80 /2 ii</tt> || <tt>10000000 oo010mmm iiiiiiii</tt> || 3+ || 3
|-
| ADC mem16, imm16 || <tt>81 /2 ii ii</tt> || <tt>10000001 oo010mmm iiiiiiii iiiiiiii</tt> || 4+ || 3
|-
| ADC mem16, simm8 || <tt>83 /2 ii</tt> || <tt>10000011 oo010mmm iiiiiiii</tt> || 3+ || 3
|-
| ADC mem8, reg8 || <tt>10 /r</tt> || <tt>00010000 oorrrmmm</tt> || 2+ || 3
|-
| ADC mem16, reg16 || <tt>11 /r</tt> || <tt>00010001 oorrrmmm</tt> || 2+ || 3
|-
| ADC reg8, imm8 || <tt>80 /2 ii</tt> || <tt>10000000 11010mmm iiiiiiii</tt> || 3 || 1
|-
| ADC reg16, imm16 || <tt>81 /2 ii ii</tt> || <tt>10000001 11010mmm iiiiiiii iiiiiiii</tt> || 4 || 1
|-
| ADC reg16, simm8 || <tt>83 /2 ii</tt> || <tt>10000011 11010mmm iiiiiiii</tt> || 3 || 1
|-
| ADC reg8, mem8 || <tt>12 /r</tt> || <tt>00010010 oorrrmmm</tt> || 2+ || 2
|-
| ADC reg16, mem16 || <tt>13 /r</tt> || <tt>00010011 oorrrmmm</tt> || 2+ || 2
|-
| ADC reg8, reg8 || <tt>10 /r</tt> || <tt>000100.0 11rrrmmm</tt> || 2 || 1
|-
| ADC reg16, reg16 || <tt>11 /r</tt> || <tt>000100.1 11rrrmmm</tt> || 2 || 1
|}
----
{{Anchor|ADD}}
=== ADD ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| ADD AL, imm || <tt>04 ii</tt> || <tt>00000100 iiiiiiii</tt> || 2 || 1
|-
| ADD AX, imm || <tt>05 ii ii</tt> || <tt>00000101 iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| ADD mem8, imm8 || <tt>80 /0 ii</tt> || <tt>10000000 oo000mmm iiiiiiii</tt> || 3+ || 3
|-
| ADD mem16, imm16 || <tt>81 /0 ii ii</tt> || <tt>10000001 oo000mmm iiiiiiii iiiiiiii</tt> || 4+ || 3
|-
| ADD mem16, simm8 || <tt>83 /0 ii</tt> || <tt>10000011 oo000mmm iiiiiiii</tt> || 3+ || 3
|-
| ADD mem8, reg8 || <tt>00 /r</tt> || <tt>00000000 oorrrmmm</tt> || 2+ || 3
|-
| ADD mem16, reg16 || <tt>01 /r</tt> || <tt>00000001 oorrrmmm</tt> || 2+ || 3
|-
| ADD reg8, imm8 || <tt>80 /0 ii</tt> || <tt>10000000 11000mmm iiiiiiii</tt> || 3 || 1
|-
| ADD reg16, imm16 || <tt>81 /0 ii ii</tt> || <tt>10000001 11000mmm iiiiiiii iiiiiiii</tt> || 4 || 1
|-
| ADD reg16, simm8 || <tt>83 /0 ii</tt> || <tt>10000011 11000mmm iiiiiiii</tt> || 3 || 1
|-
| ADD reg8, mem8 || <tt>02 /r</tt> || <tt>00000010 oorrrmmm</tt> || 2+ || 2
|-
| ADD reg16, mem16 || <tt>03 /r</tt> || <tt>00000011 oorrrmmm</tt> || 2+ || 2
|-
| ADD reg8, reg8 || <tt>00 /r</tt> || <tt>000000.0 11rrrmmm</tt> || 2 || 1
|-
| ADD reg16, reg16 || <tt>01 /r</tt> || <tt>000000.1 11rrrmmm</tt> || 2 || 1
|}
----
{{Anchor|AND}}
=== AND ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| AND AL, imm || <tt>24 ii</tt> || <tt>00100100 iiiiiiii</tt> || 2 || 1
|-
| AND AX, imm || <tt>25 ii ii</tt> || <tt>00100101 iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| AND mem8, imm8 || <tt>80 /4 ii</tt> || <tt>10000000 oo100mmm iiiiiiii</tt> || 3+ || 3
|-
| AND mem16, imm16 || <tt>81 /4 ii ii</tt> || <tt>10000001 oo100mmm iiiiiiii iiiiiiii</tt> || 4+ || 3
|-
| AND mem16, simm8 || <tt>83 /4 ii</tt> || <tt>10000011 oo100mmm iiiiiiii</tt> || 3+ || 3
|-
| AND mem8, reg8 || <tt>20 /r</tt> || <tt>00100000 oorrrmmm</tt> || 2+ || 3
|-
| AND mem16, reg16 || <tt>21 /r</tt> || <tt>00100001 oorrrmmm</tt> || 2+ || 3
|-
| AND reg8, imm8 || <tt>80 /4 ii</tt> || <tt>10000000 11100mmm iiiiiiii</tt> || 3 || 1
|-
| AND reg16, imm16 || <tt>81 /4 ii ii</tt> || <tt>10000001 11100mmm iiiiiiii iiiiiiii</tt> || 4 || 1
|-
| AND reg16, simm8 || <tt>83 /4 ii</tt> || <tt>10000011 11100mmm iiiiiiii</tt> || 3 || 1
|-
| AND reg8, mem8 || <tt>22 /r</tt> || <tt>00100010 oorrrmmm</tt> || 2+ || 2
|-
| AND reg16, mem16 || <tt>23 /r</tt> || <tt>00100011 oorrrmmm</tt> || 2+ || 2
|-
| AND reg8, reg8 || <tt>20 /r</tt> || <tt>001000.0 11rrrmmm</tt> || 2 || 1
|-
| AND reg16, reg16 || <tt>21 /r</tt> || <tt>001000.1 11rrrmmm</tt> || 2 || 1
|}
----
{{Anchor|BOUND}}
=== BOUND ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| BOUND reg16, mem16:16 || <tt>62 /r</tt> || <tt>01100010 oorrrmmm</tt> || 2+ || 13 (20 if condition met)
|}
----
{{Anchor|CALL}}
=== CALL ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| CALL ptr16:16 || <tt>CA oo oo ss ss</tt> || <tt>10011010 oooooooo oooooooo ssssssss ssssssss</tt> || 5 || 10
|-
| CALL mem16 || <tt>FF /2</tt> || <tt>11111111 oo010mmm</tt> || 2+ || 6
|-
| CALL mem16:16 || <tt>FF /3</tt> || <tt>11111111 oo011mmm</tt> || 2+ || 12
|-
| CALL reg16 || <tt>FF /2</tt> || <tt>11111111 11010mmm</tt> || 2 || 5
|-
| CALL rel16 || <tt>E8 ii ii</tt> || <tt>11101000 iiiiiiii iiiiiiii</tt> || 3 || 5
|}
----
{{Anchor|CBW}}
=== CBW ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| CBW || <tt>98</tt> || <tt>10011000</tt> || 1 || 1
|}
----
{{Anchor|CLC}}
=== CLC ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| CLC || <tt>F8</tt> || <tt>11111000</tt> || 1 || 4
|}
----
{{Anchor|CLD}}
=== CLD ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| CLD || <tt>FC</tt> || <tt>11111100</tt> || 1 || 4
|}
----
{{Anchor|CLI}}
=== CLI ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| CLI || <tt>FA</tt> || <tt>11111010</tt> || 1 || 4
|}
----
{{Anchor|CMC}}
=== CMC ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| CMC || <tt>F5</tt> || <tt>11110101</tt> || 1 || 4
|}
----
{{Anchor|CMP}}
=== CMP ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| CMP AL, imm || <tt>3C ii</tt> || <tt>00111100 iiiiiiii</tt> || 2 || 1
|-
| CMP AX, imm || <tt>3D ii ii</tt> || <tt>00111101 iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| CMP mem8, imm8 || <tt>80 /7 ii</tt> || <tt>10000000 oo111mmm iiiiiiii</tt> || 3+ || 2
|-
| CMP mem16, imm16 || <tt>81 /7 ii ii</tt> || <tt>10000001 oo111mmm iiiiiiii iiiiiiii</tt> || 4+ || 2
|-
| CMP mem16, simm8 || <tt>83 /7 ii</tt> || <tt>10000011 oo111mmm iiiiiiii</tt> || 3+ || 2
|-
| CMP mem8, reg8 || <tt>38 /r</tt> || <tt>00111000 oorrrmmm</tt> || 2+ || 2
|-
| CMP mem16, reg16 || <tt>39 /r</tt> || <tt>00111001 oorrrmmm</tt> || 2+ || 2
|-
| CMP reg8, imm8 || <tt>80 /7 ii</tt> || <tt>10000000 11111mmm iiiiiiii</tt> || 3 || 1
|-
| CMP reg16, imm16 || <tt>81 /7 ii ii</tt> || <tt>10000001 11111mmm iiiiiiii iiiiiiii</tt> || 4 || 1
|-
| CMP reg16, simm8 || <tt>83 /7 ii</tt> || <tt>10000011 11111mmm iiiiiiii</tt> || 3 || 1
|-
| CMP reg8, mem8 || <tt>3A /r</tt> || <tt>00111010 oorrrmmm</tt> || 2+ || 2
|-
| CMP reg16, mem16 || <tt>3B /r</tt> || <tt>00111011 oorrrmmm</tt> || 2+ || 2
|-
| CMP reg8, reg8 || <tt>38 /r</tt> || <tt>001110.0 11rrrmmm</tt> || 2 || 1
|-
| CMP reg16, reg16 || <tt>39 /r</tt> || <tt>001110.1 11rrrmmm</tt> || 2 || 1
|}
----
{{Anchor|CMPSB}}
{{Anchor|CMPSW}}
=== CMPSB/CMPSW ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| CMPSB || <tt>A6</tt> || <tt>10100110</tt> || 1 || 6
|-
| CMPSW || <tt>A7</tt> || <tt>10100111</tt> || 1 || 6
|}
----
{{Anchor|CS}}
=== CS ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| CS || <tt>2E</tt> || <tt>00101110</tt> || 1 || 1
|}
----
{{Anchor|CWD}}
=== CWD ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| CWD || <tt>99</tt> || <tt>10011001</tt> || 1 || 1
|}
----
{{Anchor|DAA}}
=== DAA ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| DAA || <tt>27</tt> || <tt>00100111</tt> || 1 || 10
|}
----
{{Anchor|DAS}}
=== DAS ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| DAS || <tt>2F</tt> || <tt>00101111</tt> || 1 || 10
|}
----
{{Anchor|DEC}}
=== DEC ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| DEC mem8 || <tt>FE /1</tt> || <tt>11111110 oo001mmm</tt> || 2+ || 3
|-
| DEC mem16 || <tt>FF /1</tt> || <tt>11111111 oo001mmm</tt> || 2+ || 3
|-
| DEC reg8 || <tt>FE /1</tt> || <tt>11111110 11001mmm</tt> || 2+ || 1
|-
| DEC reg16 || <tt>4x</tt> || <tt>01001rrr</tt> || 1 || 1
|}
----
{{Anchor|DIV}}
=== DIV ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| DIV mem8 || <tt>F6 /6</tt> || <tt>11110110 oo110mmm</tt> || 2+ || 16
|-
| DIV mem16 || <tt>F7 /6</tt> || <tt>11111111 oo110mmm</tt> || 2+ || 24
|-
| DIV reg8 || <tt>F6 /6</tt> || <tt>11111110 11110mmm</tt> || 2 || 15
|-
| DIV reg16 || <tt>F7 /6</tt> || <tt>11111111 11110mmm</tt> || 2 || 23
|}
----
{{Anchor|DS}}
=== DS ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| DS || <tt>3E</tt> || <tt>00111110</tt> || 1 || 1
|}
----
{{Anchor|ENTER}}
=== ENTER ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| ENTER imm16, imm8 || <tt>C8 ii ii jj</tt> || <tt>11001000 iiiiiiii iiiiiiii jjjjjjjj</tt> || 3 || 8 (imm8 = 0)<br/>14 (imm8 = 1)<br/>15 + imm8 * 4 (imm8 >= 2)
|}
----
{{Anchor|ES}}
=== ES ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| ES || <tt>26</tt> || <tt>00100110</tt> || 1 || 1
|}
----
{{Anchor|HLT}}
=== HLT ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| HLT || <tt>F4</tt> || <tt>11110100</tt> || 1 || 9
|}
----
{{Anchor|IDIV}}
=== IDIV ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| IDIV mem8 || <tt>F6 /7</tt> || <tt>11110110 oo111mmm</tt> || 2+ || 18
|-
| IDIV mem16 || <tt>F7 /7</tt> || <tt>11111111 oo111mmm</tt> || 2+ || 25
|-
| IDIV reg8 || <tt>F6 /7</tt> || <tt>11111110 11111mmm</tt> || 2 || 17
|-
| IDIV reg16 || <tt>F7 /7</tt> || <tt>11111111 11111mmm</tt> || 2 || 24
|}
----
{{Anchor|IMUL}}
=== IMUL ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| IMUL mem8 || <tt>F6 /5</tt> || <tt>11110110 oo101mmm</tt> || 2+ || 4
|-
| IMUL mem16 || <tt>F7 /5</tt> || <tt>11111111 oo101mmm</tt> || 2+ || 4
|-
| IMUL reg8 || <tt>F6 /5</tt> || <tt>11111110 11101mmm</tt> || 2 || 3
|-
| IMUL reg16 || <tt>F7 /5</tt> || <tt>11111111 11101mmm</tt> || 2 || 3
|-
| IMUL reg16, mem16, imm16 || <tt>69 /r ii ii</tt> || <tt>11111111 oorrrmmm iiiiiiii iiiiiiii</tt> || 4 || 4
|-
| IMUL reg16, mem16, simm8 || <tt>6B /r ii</tt> || <tt>11111111 oorrrmmm iiiiiiii</tt> || 3 || 4
|-
| IMUL reg16, reg16, imm16 || <tt>69 /r ii ii</tt> || <tt>11111111 11rrrmmm iiiiiiii iiiiiiii</tt> || 4 || 3
|-
| IMUL reg16, reg16, simm8 || <tt>6B /r ii</tt> || <tt>11111111 11rrrmmm iiiiiiii</tt> || 3 || 3
|}
----
{{Anchor|IN}}
=== IN ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| IN AL, DX || <tt>EC</tt> || <tt>11101100</tt> || 1 || 6
|-
| IN AX, DX || <tt>ED</tt> || <tt>11101101</tt> || 1 || 6
|-
| IN AL, imm8 || <tt>E4 ii</tt> || <tt>11100100 iiiiiiii</tt> || 2 || 6
|-
| IN AX, imm8 || <tt>E5 ii</tt> || <tt>11100101 iiiiiiii</tt> || 2 || 6
|}
----
{{Anchor|INC}}
=== INC ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| INC mem8 || <tt>FE /0</tt> || <tt>11111110 oo000mmm</tt> || 2+ || 3
|-
| INC mem16 || <tt>FF /0</tt> || <tt>11111111 oo000mmm</tt> || 2+ || 3
|-
| INC reg8 || <tt>FE /0</tt> || <tt>11111110 11000mmm</tt> || 2+ || 1
|-
| INC reg16 || <tt>4x</tt> || <tt>01000rrr</tt> || 1 || 1
|}
----
{{Anchor|INSB}}
{{Anchor|INSW}}
=== INSB/INSW ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| INSB || <tt>6C</tt> || <tt>01101100</tt> || 1 || 6
|-
| INSW || <tt>6D</tt> || <tt>01101101</tt> || 1 || 6
|}
----
{{Anchor|INT}}
=== INT ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| INT 3 || <tt>CC</tt> || <tt>11001100</tt> || 1 || 9
|-
| INT imm8 || <tt>CD ii</tt> || <tt>11001101 iiiiiiii</tt> || 2 || 10
|}
----
{{Anchor|INTO}}
=== INTO ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| INTO || <tt>CE</tt> || <tt>11001110</tt> || 1 || 6 (13 if OF = 1)
|}
----
{{Anchor|IRET}}
=== IRET ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| IRET || <tt>CF</tt> || <tt>11001111</tt> || 1 || 10
|}
----
{{Anchor|JA}}
=== JA ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JA rel8 || <tt>77 ii</tt> || <tt>01110111 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JBE}}
=== JBE ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JA rel8 || <tt>76 ii</tt> || <tt>01110110 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JC}}
=== JC/JB ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JC rel8 || <tt>72 ii</tt> || <tt>01110010 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JCXZ}}
=== JCXZ ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JCXZ rel8 || <tt>E3 ii</tt> || <tt>11100011 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JG}}
=== JG ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JG rel8 || <tt>7F ii</tt> || <tt>01111111 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JGE}}
=== JGE ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JGE rel8 || <tt>7D ii</tt> || <tt>01111101 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JL}}
=== JL ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JL rel8 || <tt>7C ii</tt> || <tt>01111100 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JLE}}
=== JLE ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JLE rel8 || <tt>7E ii</tt> || <tt>01111110 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JMP}}
=== JMP ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JMP ptr16:16 || <tt>EA oo oo ss ss</tt> || <tt>11101010 oooooooo oooooooo ssssssss ssssssss</tt> || 5 || 7
|-
| JMP mem16 || <tt>FF /4</tt> || <tt>11111111 oo100mmm</tt> || 2+ || 5
|-
| JMP mem16:16 || <tt>FF /5</tt> || <tt>11111111 oo101mmm</tt> || 2+ || 10
|-
| JMP reg16 || <tt>FF /4</tt> || <tt>11111111 11100mmm</tt> || 2 || 4
|-
| JMP rel8 || <tt>EB ii</tt> || <tt>11101011 iiiiiiii</tt> || 2 || 4
|-
| JMP rel16 || <tt>E9 ii ii</tt> || <tt>11101001 iiiiiiii iiiiiiii</tt> || 3 || 4
|}
----
{{Anchor|JNC}}
=== JNC/JAE ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JNC rel8 || <tt>73 ii</tt> || <tt>01110011 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JNO}}
=== JNO ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JNO rel8 || <tt>71 ii</tt> || <tt>01110001 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JNP}}
=== JNP ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JNP rel8 || <tt>7B ii</tt> || <tt>01111011 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JNS}}
=== JNS ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JNS rel8 || <tt>79 ii</tt> || <tt>01111001 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JNZ}}
=== JNZ/JNE ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JNZ rel8 || <tt>75 ii</tt> || <tt>01110101 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JO}}
=== JO ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JO rel8 || <tt>70 ii</tt> || <tt>01110000 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JP}}
=== JP ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JP rel8 || <tt>7A ii</tt> || <tt>01111010 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JS}}
=== JS ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JS rel8 || <tt>78 ii</tt> || <tt>01111000 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JZ}}
=== JZ/JE ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JZ rel8 || <tt>74 ii</tt> || <tt>01110100 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|LAHF}}
=== LAHF ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| LAHF || <tt>9F</tt> || <tt>10011111</tt> || 1 || 2
|}
----
{{Anchor|LDS}}
=== LDS ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| LDS reg16, mem16 || <tt>C5 /r</tt> || <tt>11000101 oorrrmmm</tt> || 2+ || 6
|}
----
{{Anchor|LEA}}
=== LEA ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| LEA reg16, mem16 || <tt>8D /r</tt> || <tt>10001101 oorrrmmm</tt> || 2+ || 1
|}
----
{{Anchor|LEAVE}}
=== LEAVE ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| LEAVE || <tt>C9</tt> || <tt>11001001</tt> || 1 || 2
|}
----
{{Anchor|LES}}
=== LES ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| LES reg16, mem16 || <tt>C4 /r</tt> || <tt>11000100 oorrrmmm</tt> || 2+ || 6
|}
----
{{Anchor|LOCK}}
=== LOCK ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| LOCK || <tt>F0</tt> || <tt>11110000</tt> || 1 || 1
|}
----
{{Anchor|LODSB}}
{{Anchor|LODSW}}
=== LODSB/LODSW ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| LODSB || <tt>AC</tt> || <tt>10101100</tt> || 1 || 3
|-
| LODSW || <tt>AD</tt> || <tt>10101101</tt> || 1 || 3
|}
----
{{Anchor|LOOP}}
=== LOOP ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| LOOP rel8 || <tt>E2 ii</tt> || <tt>11100010 iiiiiiii</tt> || 2 || 2 (5 if branch taken)
|}
----
{{Anchor|LOOPE}}
=== LOOPE ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| LOOPE rel8 || <tt>E1 ii</tt> || <tt>11100001 iiiiiiii</tt> || 2 || 3 (6 if branch taken)
|}
----
{{Anchor|LOOPNE}}
=== LOOPNE ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| LOOPNE rel8 || <tt>E0 ii</tt> || <tt>11100000 iiiiiiii</tt> || 2 || 3 (6 if branch taken)
|}
----
{{Anchor|MOV}}
=== MOV ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| MOV AL, ptr16 || <tt>A0 ii ii</tt> || <tt>10100000 iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| MOV AX, ptr16 || <tt>A1 ii ii</tt> || <tt>10100001 iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| MOV mem8, imm8 || <tt>C6 /0 ii</tt> || <tt>11000110 oo000mmm iiiiiiii</tt> || 3+ || 1
|-
| MOV mem16, imm16 || <tt>C7 /0 ii ii</tt> || <tt>11000111 oo000mmm iiiiiiii iiiiiiii</tt> || 4+ || 1
|-
| MOV mem8, reg8 || <tt>84 /r</tt> || <tt>10001000 oorrrmmm</tt> || 2+ || 1
|-
| MOV mem16, reg16 || <tt>85 /r</tt> || <tt>10001001 oorrrmmm</tt> || 2+ || 1
|-
| MOV mem16, sreg16 || <tt>8C /r</tt> || <tt>10001100 oo0rrmmm</tt> || 2+ || 3
|-
| MOV ptr16, AL || <tt>A2 ii ii</tt> || <tt>10100010 iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| MOV ptr16, AX || <tt>A3 ii ii</tt> || <tt>10100011 iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| MOV reg8, imm8 || <tt>Bx ii</tt> || <tt>10110rrr iiiiiiii</tt> || 2 || 1
|-
| MOV reg8, imm8 || <tt>C6 /0 ii</tt> || <tt>11000110 11000mmm iiiiiiii</tt> || 3 || 1
|-
| MOV reg16, imm16 || <tt>Bx ii</tt> || <tt>10111rrr iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| MOV reg16, imm16 || <tt>C7 /0 ii ii</tt> || <tt>11000111 11000mmm iiiiiiii iiiiiiii</tt> || 4 || 1
|-
| MOV reg8, mem8 || <tt>8A /r</tt> || <tt>10001010 oorrrmmm</tt> || 2+ || 1
|-
| MOV reg16, mem16 || <tt>8B /r</tt> || <tt>10001011 oorrrmmm</tt> || 2+ || 1
|-
| MOV reg8, reg8 || <tt>88 /r</tt> || <tt>100010.0 11rrrmmm</tt> || 2 || 1
|-
| MOV reg16, reg16 || <tt>89 /r</tt> || <tt>100010.1 11rrrmmm</tt> || 2 || 1
|-
| MOV reg16, sreg16 || <tt>8C /r</tt> || <tt>10001100 110rrmmm</tt> || 2 || 1
|-
| MOV sreg16, mem16 || <tt>8E /r</tt> || <tt>10001110 oo0rrmmm</tt> || 2 || 3
|-
| MOV sreg16, reg16 || <tt>8E /r</tt> || <tt>10001110 110rrmmm</tt> || 2+ || 2
|}
----
{{Anchor|MOVSB}}
{{Anchor|MOVSW}}
=== MOVSB/MOVSW ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| MOVSB || <tt>A4</tt> || <tt>10100100</tt> || 1 || 5
|-
| MOVSW || <tt>A5</tt> || <tt>10100101</tt> || 1 || 5
|}
----
{{Anchor|MUL}}
=== MUL ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| MUL mem8 || <tt>F6 /4</tt> || <tt>11110110 oo100mmm</tt> || 2+ || 4
|-
| MUL mem16 || <tt>F7 /4</tt> || <tt>11111111 oo100mmm</tt> || 2+ || 4
|-
| MUL reg8 || <tt>F6 /4</tt> || <tt>11111110 11100mmm</tt> || 2 || 3
|-
| MUL reg16 || <tt>F7 /4</tt> || <tt>11111111 11100mmm</tt> || 2 || 3
|}
----
{{Anchor|NEG}}
=== NEG ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| NEG mem8 || <tt>F6 /3</tt> || <tt>11110110 oo011mmm</tt> || 2+ || 3
|-
| NEG mem16 || <tt>F7 /3</tt> || <tt>11111111 oo011mmm</tt> || 2+ || 3
|-
| NEG reg8 || <tt>F6 /3</tt> || <tt>11111110 11011mmm</tt> || 2 || 1
|-
| NEG reg16 || <tt>F7 /3</tt> || <tt>11111111 11011mmm</tt> || 2 || 1
|}
----
{{Anchor|NOP}}
=== NOP ===
----
{{Anchor|NOT}}
=== NOT ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| NOT mem8 || <tt>F6 /2</tt> || <tt>11110110 oo010mmm</tt> || 2+ || 3
|-
| NOT mem16 || <tt>F7 /2</tt> || <tt>11111111 oo010mmm</tt> || 2+ || 3
|-
| NOT reg8 || <tt>F6 /2</tt> || <tt>11111110 11010mmm</tt> || 2 || 1
|-
| NOT reg16 || <tt>F7 /2</tt> || <tt>11111111 11010mmm</tt> || 2 || 1
|}
----
{{Anchor|OR}}
=== OR ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| OR AL, imm || <tt>0C ii</tt> || <tt>00001100 iiiiiiii</tt> || 2 || 1
|-
| OR AX, imm || <tt>0D ii ii</tt> || <tt>00001101 iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| OR mem8, imm8 || <tt>80 /6 ii</tt> || <tt>10000000 oo001mmm iiiiiiii</tt> || 3+ || 3
|-
| OR mem16, imm16 || <tt>81 /6 ii ii</tt> || <tt>10000001 oo001mmm iiiiiiii iiiiiiii</tt> || 4+ || 3
|-
| OR mem16, simm8 || <tt>83 /6 ii</tt> || <tt>10000011 oo001mmm iiiiiiii</tt> || 3+ || 3
|-
| OR mem8, reg8 || <tt>08 /r</tt> || <tt>00001000 oorrrmmm</tt> || 2+ || 3
|-
| OR mem16, reg16 || <tt>09 /r</tt> || <tt>00001001 oorrrmmm</tt> || 2+ || 3
|-
| OR reg8, imm8 || <tt>80 /6 ii</tt> || <tt>10000000 11001mmm iiiiiiii</tt> || 3 || 1
|-
| OR reg16, imm16 || <tt>81 /6 ii ii</tt> || <tt>10000001 11001mmm iiiiiiii iiiiiiii</tt> || 4 || 1
|-
| OR reg16, simm8 || <tt>83 /6 ii</tt> || <tt>10000011 11001mmm iiiiiiii</tt> || 3 || 1
|-
| OR reg8, mem8 || <tt>0A /r</tt> || <tt>00001010 oorrrmmm</tt> || 2+ || 2
|-
| OR reg16, mem16 || <tt>0B /r</tt> || <tt>00001011 oorrrmmm</tt> || 2+ || 2
|-
| OR reg8, reg8 || <tt>08 /r</tt> || <tt>000010.0 11rrrmmm</tt> || 2 || 1
|-
| OR reg16, reg16 || <tt>09 /r</tt> || <tt>000010.1 11rrrmmm</tt> || 2 || 1
|}
----
{{Anchor|OUT}}
=== OUT ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| OUT AL, DX || <tt>EE</tt> || <tt>11101110</tt> || 1 || 6
|-
| OUT AX, DX || <tt>EF</tt> || <tt>11101111</tt> || 1 || 6
|-
| OUT AL, imm8 || <tt>E6 ii</tt> || <tt>11100110 iiiiiiii</tt> || 2 || 6
|-
| OUT AX, imm8 || <tt>E7 ii</tt> || <tt>11100111 iiiiiiii</tt> || 2 || 6
|}
----
{{Anchor|OUTSB}}
{{Anchor|OUTSW}}
=== OUTSB/OUTSW ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| OUTSB || <tt>6E</tt> || <tt>01101110</tt> || 1 || 6
|-
| OUTSW || <tt>6F</tt> || <tt>01101111</tt> || 1 || 6
|}
----
{{Anchor|POLL}}
=== POLL ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| POLL || <tt>6E</tt> || <tt>01101110</tt> || 1 || 9<ref>On the WonderSwan implementation, POLLB is always held low; on other implementations, POLL will wait for POLLB to be held low in 9-cycle intervals.</ref>
|}
----
{{Anchor|POP}}
=== POP ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| POP mem16 || <tt>8F /0</tt> || <tt>10001111 oo000mmm</tt> || 2+ || 3
|-
| POP reg16 || <tt>5x</tt> || <tt>01011xxx</tt> || 1 || 1
|-
| POP reg16 || <tt>8F /0</tt> || <tt>10001111 11000mmm</tt> || 2 || 1
|-
| POP sreg16 || <tt>xx</tt> || <tt>000xx111</tt> || 1 || 3
|}
----
{{Anchor|POPA}}
=== POPA ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| POPA || <tt>61</tt> || <tt>01100001</tt> || 1 || 8
|}
----
{{Anchor|POPF}}
=== POPF ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| POPF || <tt>9D</tt> || <tt>10011101</tt> || 1 || 3
|}
----
{{Anchor|PUSH}}
=== PUSH ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| PUSH imm8 || <tt>6A ii</tt> || <tt>01101010 iiiiiiii</tt> || 2 || 1
|-
| PUSH imm16 || <tt>68 ii ii</tt> || <tt>01101000 iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| PUSH mem16 || <tt>FF /6</tt> || <tt>11111111 oo110mmm</tt> || 2+ || 2
|-
| PUSH reg16 || <tt>5x</tt> || <tt>01010xxx</tt> || 1 || 1
|-
| PUSH reg16 || <tt>FF /6</tt> || <tt>11111111 11110mmm</tt> || 2 || 1
|-
| PUSH sreg16 || <tt>xx</tt> || <tt>000xx110</tt> || 1 || 2
|}
----
{{Anchor|PUSHA}}
=== PUSHA ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| PUSHA || <tt>60</tt> || <tt>01100000</tt> || 1 || 9
|}
----
{{Anchor|PUSHF}}
=== PUSHF ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| PUSHF || <tt>9C</tt> || <tt>10011100</tt> || 1 || 2
|}
----
{{Anchor|RCL}}
=== RCL ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| RCL mem8, 1 || <tt>D0 /2</tt> || <tt>11010000 oo010rm</tt> || 2+ || 3
|-
| RCL mem8, CL || <tt>D2 /2</tt> || <tt>11010010 oo010rm</tt> || 2+ || 5
|-
| RCL mem8, imm8 || <tt>C0 /2 ii</tt> || <tt>11000000 oo010rm</tt> || 3+ || 5
|-
| RCL mem16, 1 || <tt>D1 /2</tt> || <tt>11010001 oo010rm</tt> || 2+ || 3
|-
| RCL mem16, CL || <tt>D3 /2</tt> || <tt>11010011 oo010rm</tt> || 2+ || 5
|-
| RCL mem16, imm8 || <tt>C1 /2 ii</tt> || <tt>11000001 oo010rm</tt> || 3+ || 5
|-
| RCL reg8, 1 || <tt>D0 /2</tt> || <tt>11010000 11010rm</tt> || 2 || 1
|-
| RCL reg8, CL || <tt>D2 /2</tt> || <tt>11010010 11010rm</tt> || 2 || 3
|-
| RCL reg8, imm8 || <tt>C0 /2 ii</tt> || <tt>11000000 11010rm</tt> || 3 || 3
|-
| RCL reg16, 1 || <tt>D1 /2</tt> || <tt>11010001 11010rm</tt> || 2 || 1
|-
| RCL reg16, CL || <tt>D3 /2</tt> || <tt>11010011 11010rm</tt> || 2 || 3
|-
| RCL reg16, imm8 || <tt>C1 /2 ii</tt> || <tt>11000001 11010rm</tt> || 3 || 3
|}
----
{{Anchor|RCR}}
=== RCR ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| RCR mem8, 1 || <tt>D0 /3</tt> || <tt>11010000 oo011rm</tt> || 2+ || 3
|-
| RCR mem8, CL || <tt>D2 /3</tt> || <tt>11010010 oo011rm</tt> || 2+ || 5
|-
| RCR mem8, imm8 || <tt>C0 /3 ii</tt> || <tt>11000000 oo011rm</tt> || 3+ || 5
|-
| RCR mem16, 1 || <tt>D1 /3</tt> || <tt>11010001 oo011rm</tt> || 2+ || 3
|-
| RCR mem16, CL || <tt>D3 /3</tt> || <tt>11010011 oo011rm</tt> || 2+ || 5
|-
| RCR mem16, imm8 || <tt>C1 /3 ii</tt> || <tt>11000001 oo011rm</tt> || 3+ || 5
|-
| RCR reg8, 1 || <tt>D0 /3</tt> || <tt>11010000 11011rm</tt> || 2 || 1
|-
| RCR reg8, CL || <tt>D2 /3</tt> || <tt>11010010 11011rm</tt> || 2 || 3
|-
| RCR reg8, imm8 || <tt>C0 /3 ii</tt> || <tt>11000000 11011rm</tt> || 3 || 3
|-
| RCR reg16, 1 || <tt>D1 /3</tt> || <tt>11010001 11011rm</tt> || 2 || 1
|-
| RCR reg16, CL || <tt>D3 /3</tt> || <tt>11010011 11011rm</tt> || 2 || 3
|-
| RCR reg16, imm8 || <tt>C1 /3 ii</tt> || <tt>11000001 11011rm</tt> || 3 || 3
|}
----
{{Anchor|REP}}
=== REP/REPE/REPZ ===
----
{{Anchor|REPNE}}
=== REPNE/REPNZ ===
----
{{Anchor|RET}}
=== RET ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| RET || <tt>C3</tt> || <tt>11000011</tt> || 1 || 6
|-
| RET imm16 || <tt>C2 ii ii</tt> || <tt>11000010 iiiiiiii iiiiiiii</tt> || 1 || 6
|}
----
{{Anchor|RETF}}
=== RETF ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| RETF || <tt>CB</tt> || <tt>11001011</tt> || 1 || 9
|-
| RETF imm16 || <tt>CA ii ii</tt> || <tt>11001010 iiiiiiii iiiiiiii</tt> || 1 || 8
|}
----
{{Anchor|ROL}}
=== ROL ===
| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| ROL mem8, 1 || <tt>D0 /0</tt> || <tt>11010000 oo000rm</tt> || 2+ || 3
|-
| ROL mem8, CL || <tt>D2 /0</tt> || <tt>11010010 oo000rm</tt> || 2+ || 5
|-
| ROL mem8, imm8 || <tt>C0 /0 ii</tt> || <tt>11000000 oo000rm</tt> || 3+ || 5
|-
| ROL mem16, 1 || <tt>D1 /0</tt> || <tt>11010001 oo000rm</tt> || 2+ || 3
|-
| ROL mem16, CL || <tt>D3 /0</tt> || <tt>11010011 oo000rm</tt> || 2+ || 5
|-
| ROL mem16, imm8 || <tt>C1 /0 ii</tt> || <tt>11000001 oo000rm</tt> || 3+ || 5
|-
| ROL reg8, 1 || <tt>D0 /0</tt> || <tt>11010000 11000rm</tt> || 2 || 1
|-
| ROL reg8, CL || <tt>D2 /0</tt> || <tt>11010010 11000rm</tt> || 2 || 3
|-
| ROL reg8, imm8 || <tt>C0 /0 ii</tt> || <tt>11000000 11000rm</tt> || 3 || 3
|-
| ROL reg16, 1 || <tt>D1 /0</tt> || <tt>11010001 11000rm</tt> || 2 || 1
|-
| ROL reg16, CL || <tt>D3 /0</tt> || <tt>11010011 11000rm</tt> || 2 || 3
|-
| ROL reg16, imm8 || <tt>C1 /0 ii</tt> || <tt>11000001 11000rm</tt> || 3 || 3
|}
----
{{Anchor|ROR}}
=== ROR ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| ROR mem8, 1 || <tt>D0 /1</tt> || <tt>11010000 oo001rm</tt> || 2+ || 3
|-
| ROR mem8, CL || <tt>D2 /1</tt> || <tt>11010010 oo001rm</tt> || 2+ || 5
|-
| ROR mem8, imm8 || <tt>C0 /1 ii</tt> || <tt>11000000 oo001rm</tt> || 3+ || 5
|-
| ROR mem16, 1 || <tt>D1 /1</tt> || <tt>11010001 oo001rm</tt> || 2+ || 3
|-
| ROR mem16, CL || <tt>D3 /1</tt> || <tt>11010011 oo001rm</tt> || 2+ || 5
|-
| ROR mem16, imm8 || <tt>C1 /1 ii</tt> || <tt>11000001 oo001rm</tt> || 3+ || 5
|-
| ROR reg8, 1 || <tt>D0 /1</tt> || <tt>11010000 11001rm</tt> || 2 || 1
|-
| ROR reg8, CL || <tt>D2 /1</tt> || <tt>11010010 11001rm</tt> || 2 || 3
|-
| ROR reg8, imm8 || <tt>C0 /1 ii</tt> || <tt>11000000 11001rm</tt> || 3 || 3
|-
| ROR reg16, 1 || <tt>D1 /1</tt> || <tt>11010001 11001rm</tt> || 2 || 1
|-
| ROR reg16, CL || <tt>D3 /1</tt> || <tt>11010011 11001rm</tt> || 2 || 3
|-
| ROR reg16, imm8 || <tt>C1 /1 ii</tt> || <tt>11000001 11001rm</tt> || 3 || 3
|}
----
{{Anchor|SAHF}}
=== SAHF ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| SAHF || <tt>9E</tt> || <tt>10011110</tt> || 1 || 4
|}
----
{{Anchor|SAR}}
=== SAR ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| SAR mem8, 1 || <tt>D0 /7</tt> || <tt>11010000 oo111rm</tt> || 2+ || 3
|-
| SAR mem8, CL || <tt>D2 /7</tt> || <tt>11010010 oo111rm</tt> || 2+ || 5
|-
| SAR mem8, imm8 || <tt>C0 /7 ii</tt> || <tt>11000000 oo111rm</tt> || 3+ || 5
|-
| SAR mem16, 1 || <tt>D1 /7</tt> || <tt>11010001 oo111rm</tt> || 2+ || 3
|-
| SAR mem16, CL || <tt>D3 /7</tt> || <tt>11010011 oo111rm</tt> || 2+ || 5
|-
| SAR mem16, imm8 || <tt>C1 /7 ii</tt> || <tt>11000001 oo111rm</tt> || 3+ || 5
|-
| SAR reg8, 1 || <tt>D0 /7</tt> || <tt>11010000 11111rm</tt> || 2 || 1
|-
| SAR reg8, CL || <tt>D2 /7</tt> || <tt>11010010 11111rm</tt> || 2 || 3
|-
| SAR reg8, imm8 || <tt>C0 /7 ii</tt> || <tt>11000000 11111rm</tt> || 3 || 3
|-
| SAR reg16, 1 || <tt>D1 /7</tt> || <tt>11010001 11111rm</tt> || 2 || 1
|-
| SAR reg16, CL || <tt>D3 /7</tt> || <tt>11010011 11111rm</tt> || 2 || 3
|-
| SAR reg16, imm8 || <tt>C1 /7 ii</tt> || <tt>11000001 11111rm</tt> || 3 || 3
|}
----
{{Anchor|SBB}}
=== SBB ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| SBB AL, imm || <tt>1C ii</tt> || <tt>00011100 iiiiiiii</tt> || 2 || 1
|-
| SBB AX, imm || <tt>1D ii ii</tt> || <tt>00011101 iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| SBB mem8, imm8 || <tt>80 /3 ii</tt> || <tt>10000000 oo011mmm iiiiiiii</tt> || 3+ || 3
|-
| SBB mem16, imm16 || <tt>81 /3 ii ii</tt> || <tt>10000001 oo011mmm iiiiiiii iiiiiiii</tt> || 4+ || 3
|-
| SBB mem16, simm8 || <tt>83 /3 ii</tt> || <tt>10000011 oo011mmm iiiiiiii</tt> || 3+ || 3
|-
| SBB mem8, reg8 || <tt>18 /r</tt> || <tt>00011000 oorrrmmm</tt> || 2+ || 3
|-
| SBB mem16, reg16 || <tt>19 /r</tt> || <tt>00011001 oorrrmmm</tt> || 2+ || 3
|-
| SBB reg8, imm8 || <tt>80 /3 ii</tt> || <tt>10000000 11011mmm iiiiiiii</tt> || 3 || 1
|-
| SBB reg16, imm16 || <tt>81 /3 ii ii</tt> || <tt>10000001 11011mmm iiiiiiii iiiiiiii</tt> || 4 || 1
|-
| SBB reg16, simm8 || <tt>83 /3 ii</tt> || <tt>10000011 11011mmm iiiiiiii</tt> || 3 || 1
|-
| SBB reg8, mem8 || <tt>1A /r</tt> || <tt>00011010 oorrrmmm</tt> || 2+ || 2
|-
| SBB reg16, mem16 || <tt>1B /r</tt> || <tt>00011011 oorrrmmm</tt> || 2+ || 2
|-
| SBB reg8, reg8 || <tt>18 /r</tt> || <tt>000110.0 11rrrmmm</tt> || 2 || 1
|-
| SBB reg16, reg16 || <tt>19 /r</tt> || <tt>000110.1 11rrrmmm</tt> || 2 || 1
|}
----
{{Anchor|SCASB}}
{{Anchor|SCASW}}
=== SCASB/SCASW ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| SCASB || <tt>AE</tt> || <tt>10101110</tt> || 1 || 4
|-
| SCASW || <tt>AF</tt> || <tt>10101111</tt> || 1 || 4
|}
----
{{Anchor|SHL}}
=== SHL ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| SHL mem8, 1 || <tt>D0 /4</tt> || <tt>11010000 oo100rm</tt> || 2+ || 3
|-
| SHL mem8, CL || <tt>D2 /4</tt> || <tt>11010010 oo100rm</tt> || 2+ || 5
|-
| SHL mem8, imm8 || <tt>C0 /4 ii</tt> || <tt>11000000 oo100rm</tt> || 3+ || 5
|-
| SHL mem16, 1 || <tt>D1 /4</tt> || <tt>11010001 oo100rm</tt> || 2+ || 3
|-
| SHL mem16, CL || <tt>D3 /4</tt> || <tt>11010011 oo100rm</tt> || 2+ || 5
|-
| SHL mem16, imm8 || <tt>C1 /4 ii</tt> || <tt>11000001 oo100rm</tt> || 3+ || 5
|-
| SHL reg8, 1 || <tt>D0 /4</tt> || <tt>11010000 11100rm</tt> || 2 || 1
|-
| SHL reg8, CL || <tt>D2 /4</tt> || <tt>11010010 11100rm</tt> || 2 || 3
|-
| SHL reg8, imm8 || <tt>C0 /4 ii</tt> || <tt>11000000 11100rm</tt> || 3 || 3
|-
| SHL reg16, 1 || <tt>D1 /4</tt> || <tt>11010001 11100rm</tt> || 2 || 1
|-
| SHL reg16, CL || <tt>D3 /4</tt> || <tt>11010011 11100rm</tt> || 2 || 3
|-
| SHL reg16, imm8 || <tt>C1 /4 ii</tt> || <tt>11000001 11100rm</tt> || 3 || 3
|}
----
{{Anchor|SHR}}
=== SHR ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| SHR mem8, 1 || <tt>D0 /5</tt> || <tt>11010000 oo101rm</tt> || 2+ || 3
|-
| SHR mem8, CL || <tt>D2 /5</tt> || <tt>11010010 oo101rm</tt> || 2+ || 5
|-
| SHR mem8, imm8 || <tt>C0 /5 ii</tt> || <tt>11000000 oo101rm</tt> || 3+ || 5
|-
| SHR mem16, 1 || <tt>D1 /5</tt> || <tt>11010001 oo101rm</tt> || 2+ || 3
|-
| SHR mem16, CL || <tt>D3 /5</tt> || <tt>11010011 oo101rm</tt> || 2+ || 5
|-
| SHR mem16, imm8 || <tt>C1 /5 ii</tt> || <tt>11000001 oo101rm</tt> || 3+ || 5
|-
| SHR reg8, 1 || <tt>D0 /5</tt> || <tt>11010000 11101rm</tt> || 2 || 1
|-
| SHR reg8, CL || <tt>D2 /5</tt> || <tt>11010010 11101rm</tt> || 2 || 3
|-
| SHR reg8, imm8 || <tt>C0 /5 ii</tt> || <tt>11000000 11101rm</tt> || 3 || 3
|-
| SHR reg16, 1 || <tt>D1 /5</tt> || <tt>11010001 11101rm</tt> || 2 || 1
|-
| SHR reg16, CL || <tt>D3 /5</tt> || <tt>11010011 11101rm</tt> || 2 || 3
|-
| SHR reg16, imm8 || <tt>C1 /5 ii</tt> || <tt>11000001 11101rm</tt> || 3 || 3
|}
----
{{Anchor|SS}}
=== SS ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| SS || <tt>36</tt> || <tt>00110110</tt> || 1 || 1
|}
----
{{Anchor|STC}}
=== STC ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| STC || <tt>F9</tt> || <tt>11111001</tt> || 1 || 4
|}
----
{{Anchor|STD}}
=== STD ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| STD || <tt>FD</tt> || <tt>11111101</tt> || 1 || 4
|}
----
{{Anchor|STI}}
=== STI ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| STI || <tt>FB</tt> || <tt>11111011</tt> || 1 || 4
|}
----
{{Anchor|STOSB}}
{{Anchor|STOSW}}
=== STOSB/STOSW ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| STOSB || <tt>AA</tt> || <tt>10101010</tt> || 1 || 3
|-
| STOSW || <tt>AB</tt> || <tt>10101011</tt> || 1 || 3
|}
----
{{Anchor|SUB}}
=== SUB ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| SUB AL, imm || <tt>28 ii</tt> || <tt>00101100 iiiiiiii</tt> || 2 || 1
|-
| SUB AX, imm || <tt>29 ii ii</tt> || <tt>00101101 iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| SUB mem8, imm8 || <tt>80 /5 ii</tt> || <tt>10000000 oo101mmm iiiiiiii</tt> || 3+ || 3
|-
| SUB mem16, imm16 || <tt>81 /5 ii ii</tt> || <tt>10000001 oo101mmm iiiiiiii iiiiiiii</tt> || 4+ || 3
|-
| SUB mem16, simm8 || <tt>83 /5 ii</tt> || <tt>10000011 oo101mmm iiiiiiii</tt> || 3+ || 3
|-
| SUB mem8, reg8 || <tt>28 /r</tt> || <tt>00101000 oorrrmmm</tt> || 2+ || 3
|-
| SUB mem16, reg16 || <tt>29 /r</tt> || <tt>00101001 oorrrmmm</tt> || 2+ || 3
|-
| SUB reg8, imm8 || <tt>80 /5 ii</tt> || <tt>10000000 11101mmm iiiiiiii</tt> || 3 || 1
|-
| SUB reg16, imm16 || <tt>81 /5 ii ii</tt> || <tt>10000001 11101mmm iiiiiiii iiiiiiii</tt> || 4 || 1
|-
| SUB reg16, simm8 || <tt>83 /5 ii</tt> || <tt>10000011 11101mmm iiiiiiii</tt> || 3 || 1
|-
| SUB reg8, mem8 || <tt>2A /r</tt> || <tt>00101010 oorrrmmm</tt> || 2+ || 2
|-
| SUB reg16, mem16 || <tt>2B /r</tt> || <tt>00101011 oorrrmmm</tt> || 2+ || 2
|-
| SUB reg8, reg8 || <tt>28 /r</tt> || <tt>001010.0 11rrrmmm</tt> || 2 || 1
|-
| SUB reg16, reg16 || <tt>29 /r</tt> || <tt>001010.1 11rrrmmm</tt> || 2 || 1
|}
----
{{Anchor|TEST}}
=== TEST ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| TEST AL, imm || <tt>A8 ii</tt> || <tt>10101000 iiiiiiii</tt> || 2 || 1
|-
| TEST AX, imm || <tt>A9 ii ii</tt> || <tt>10101001 iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| TEST mem8, imm8 || <tt>F6 /0 ii</tt> || <tt>11110110 oo000mmm iiiiiiii</tt> || 3+ || 2
|-
| TEST mem16, imm16 || <tt>F7 /0 ii ii</tt> || <tt>11110111 oo000mmm iiiiiiii iiiiiiii</tt> || 4+ || 2
|-
| TEST mem8, reg8<br/>TEST reg8, mem8 || <tt>84 /r</tt> || <tt>10000100 oorrrmmm</tt> || 2+ || 2
|-
| TEST mem16, reg16<br/>TEST reg16, mem16 || <tt>85 /r</tt> || <tt>10000101 oorrrmmm</tt> || 2+ || 2
|-
| TEST reg8, imm8 || <tt>F6 /0 ii</tt> || <tt>11110110 11000mmm iiiiiiii</tt> || 3 || 1
|-
| TEST reg16, imm16 || <tt>F7 /0 ii ii</tt> || <tt>11110111 11000mmm iiiiiiii iiiiiiii</tt> || 4 || 1
|-
| TEST reg8, reg8 || <tt>84 /r</tt> || <tt>10000100 11rrrmmm</tt> || 2 || 1
|-
| TEST reg16, reg16 || <tt>85 /r</tt> || <tt>10000101 11rrrmmm</tt> || 2 || 1
|}
----
{{Anchor|XCHG}}
=== XCHG ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| XCHG AX, reg16<br/>XCHG reg16, AX || <tt>9x</tt> || <tt>10010rrr</tt> || 1 || 3
|-
| XCHG mem8, reg8<br/>XCHG reg8, mem8 || <tt>86 /r</tt> || <tt>10000110 oorrrmmm</tt> || 2+ || 5
|-
| XCHG mem16, reg16<br/>XCHG reg16, mem16 || <tt>87 /r</tt> || <tt>10000111 oorrrmmm</tt> || 2+ || 5
|-
| XCHG reg8, reg8 || <tt>86 /r</tt> || <tt>10000110 11rrrmmm</tt> || 2+ || 3
|-
| XCHG reg16, reg16 || <tt>87 /r</tt> || <tt>10000111 11rrrmmm</tt> || 2+ || 3
|}
----
{{Anchor|XLAT}}
=== XLAT ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| XLAT || <tt>D7</tt> || <tt>11010111</tt> || 1 || 5
|}
----
{{Anchor|XOR}}
=== XOR ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| XOR AL, imm || <tt>34 ii</tt> || <tt>00110100 iiiiiiii</tt> || 2 || 1
|-
| XOR AX, imm || <tt>35 ii ii</tt> || <tt>00110101 iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| XOR mem8, imm8 || <tt>80 /6 ii</tt> || <tt>10000000 oo110mmm iiiiiiii</tt> || 3+ || 3
|-
| XOR mem16, imm16 || <tt>81 /6 ii ii</tt> || <tt>10000001 oo110mmm iiiiiiii iiiiiiii</tt> || 4+ || 3
|-
| XOR mem16, simm8 || <tt>83 /6 ii</tt> || <tt>10000011 oo110mmm iiiiiiii</tt> || 3+ || 3
|-
| XOR mem8, reg8 || <tt>30 /r</tt> || <tt>00110000 oorrrmmm</tt> || 2+ || 3
|-
| XOR mem16, reg16 || <tt>31 /r</tt> || <tt>00110001 oorrrmmm</tt> || 2+ || 3
|-
| XOR reg8, imm8 || <tt>80 /6 ii</tt> || <tt>10000000 11110mmm iiiiiiii</tt> || 3 || 1
|-
| XOR reg16, imm16 || <tt>81 /6 ii ii</tt> || <tt>10000001 11110mmm iiiiiiii iiiiiiii</tt> || 4 || 1
|-
| XOR reg16, simm8 || <tt>83 /6 ii</tt> || <tt>10000011 11110mmm iiiiiiii</tt> || 3 || 1
|-
| XOR reg8, mem8 || <tt>32 /r</tt> || <tt>00110010 oorrrmmm</tt> || 2+ || 2
|-
| XOR reg16, mem16 || <tt>33 /r</tt> || <tt>00110011 oorrrmmm</tt> || 2+ || 2
|-
| XOR reg8, reg8 || <tt>30 /r</tt> || <tt>001100.0 11rrrmmm</tt> || 2 || 1
|-
| XOR reg16, reg16 || <tt>31 /r</tt> || <tt>001100.1 11rrrmmm</tt> || 2 || 1
|}
== Notes ==
<references />
587399df505ed661498a0898b5c38f0b73e748ac
462
461
2024-12-27T23:35:07Z
Asie
351
/* ROL */
wikitext
text/x-wiki
__NOTOC__
Note that this page is a work in progress.
{| class="wikitable" style="text-align: center"
|+ Official V30MZ (80186) Instructions
|-
| [[#AAA|AAA]] || [[#AAD|AAD]] || [[#AAM|AAM]] || [[#AAS|AAS]] || [[#ADC|ADC]] || [[#ADD|ADD]] || [[#AND|AND]] || [[#BOUND|BOUND]] || [[#CALL|CALL]] || [[#CBW|CBW]] || [[#CLC|CLC]]
|-
| [[#CLD|CLD]] || [[#CLI|CLI]] || [[#CMC|CMC]] || [[#CMP|CMP]] || [[#CMPSB|CMPSB]] || [[#CMPSW|CMPSW]] || [[#CS|CS]] || [[#CWD|CWD]] || [[#DAA|DAA]] || [[#DAS|DAS]] || [[#DEC|DEC]]
|-
| [[#DIV|DIV]] || [[#DS|DS]] || [[#ENTER|ENTER]] || [[#ES|ES]] || [[#HLT|HLT]] || [[#IDIV|IDIV]] || [[#IMUL|IMUL]] || [[#IN|IN]] || [[#INC|INC]] || [[#INSB|INSB]] || [[#INSW|INSW]]
|-
| [[#INT|INT]] || [[#INTO|INTO]] || [[#IRET|IRET]] || [[#JA|JA]] || [[#JBE|JBE]] || [[#JC|JC]] || [[#JCXZ|JCXZ]] || [[#JG|JG]] || [[#JGE|JGE]] || [[#JL|JL]] || [[#JLE|JLE]]
|-
| [[#JMP|JMP]] || [[#JNC|JNC]] || [[#JNO|JNO]] || [[#JNP|JNP]] || [[#JNS|JNS]] || [[#JNZ|JNZ]] || [[#JO|JO]] || [[#JP|JP]] || [[#JS|JS]] || [[#JZ|JZ]] || [[#LAHF|LAHF]]
|-
| [[#LDS|LDS]] || [[#LEA|LEA]] || [[#LEAVE|LEAVE]] || [[#LES|LES]] || [[#LOCK|LOCK]] || [[#LODSB|LODSB]] || [[#LODSW|LODSW]] || [[#LOOP|LOOP]] || [[#LOOPE|LOOPE]] || [[#LOOPNE|LOOPNE]] || [[#MOV|MOV]]
|-
| [[#MOVSB|MOVSB]] || [[#MOVSW|MOVSW]] || [[#MUL|MUL]] || [[#NEG|NEG]] || [[#NOP|NOP]] || [[#NOT|NOT]] || [[#OR|OR]] || [[#OUT|OUT]] || [[#OUTSB|OUTSB]] || [[#OUTSW|OUTSW]] || [[#POLL|POLL]]
|-
| [[#POP|POP]] || [[#POPA|POPA]] || [[#POPF|POPF]] || [[#PUSH|PUSH]] || [[#PUSHA|PUSHA]] || [[#PUSHF|PUSHF]] || [[#RCL|RCL]] || [[#RCR|RCR]] || [[#REP|REP]] || [[#REPNE|REPNE]] || [[#RET|RET]]
|-
| [[#RETF|RETF]] || [[#ROL|ROL]] || [[#ROR|ROR]] || [[#SAHF|SAHF]] || [[#SAR|SAR]] || [[#SBB|SBB]] || [[#SCASB|SCASB]] || [[#SCASW|SCASW]] || [[#SHL|SHL]] || [[#SHR|SHR]] || [[#SS|SS]]
|-
| [[#STC|STC]] || [[#STD|STD]] || [[#STI|STI]] || [[#STOSB|STOSB]] || [[#STOSW|STOSW]] || [[#SUB|SUB]] || [[#TEST|TEST]] || [[#XCHG|XCHG]] || [[#XLAT|XLAT]] || [[#XOR|XOR]]
|}
{| class="mw-collapsible mw-collapsed wikitable sortable" style="width: 340px;"
|+ style="white-space:nowrap; border:1px solid; padding:3px; border-color:rgb(162, 169, 177); background-color:rgb(234, 236, 240);" | Intel <-> NEC mnemonic translation table
!Intel
!NEC
|-
| [[#AAA|AAA]]
| [[#AAA|ADJBA]]
|-
| [[#AAD|AAD]]
| [[#AAD|CVTDB]]
|-
| [[#AAM|AAM]]
| [[#AAM|CVTBD]]
|-
| [[#AAS|AAS]]
| [[#AAS|ADJBS]]
|-
| [[#ADC|ADC]]
| [[#ADC|ADDC]]
|-
| [[#ADD|ADD]]
| [[#ADD|ADD]]
|-
| [[#AND|AND]]
| [[#AND|AND]]
|-
| [[#BOUND|BOUND]]
| [[#BOUND|CHKIND]]
|-
| [[#CALL|CALL]]
| [[#CALL|CALL]]
|-
| [[#CBW|CBW]]
| [[#CBW|CVTBW]]
|-
| [[#CLC|CLC]]
| [[#CLC|CLR1 CY]]
|-
| [[#CLD|CLD]]
| [[#CLD|CLR1 DIR]]
|-
| [[#CLI|CLI]]
| [[#CLI|DI]]
|-
| [[#CMC|CMC]]
| [[#CMC|NOT1 CY]]
|-
| [[#CMP|CMP]]
| [[#CMP|CMP]]
|-
| [[#CMPSB|CMPSB]]
| [[#CMPSB|CMPBKB]]
|-
| [[#CMPSW|CMPSW]]
| [[#CMPSW|CMPBKW]]
|-
| [[#CS|CS]]
| [[#CS|PS]]
|-
| [[#CWD|CWD]]
| [[#CWD|CVTWL]]
|-
| [[#DAA|DAA]]
| [[#DAA|ADJ4A]]
|-
| [[#DAS|DAS]]
| [[#DAS|ADJ4S]]
|-
| [[#DEC|DEC]]
| [[#DEC|DEC]]
|-
| [[#DIV|DIV]]
| [[#DIV|DIVU]]
|-
| [[#DS|DS]]
| [[#DS|DS0]]
|-
| [[#ENTER|ENTER]]
| [[#ENTER|PREPARE]]
|-
| [[#ES|ES]]
| [[#ES|DS1]]
|-
| [[#HLT|HLT]]
| [[#HLT|HALT]]
|-
| [[#IDIV|IDIV]]
| [[#IDIV|DIV]]
|-
| [[#IMUL|IMUL]]
| [[#IMUL|MUL]]
|-
| [[#IN|IN]]
| [[#IN|IN]]
|-
| [[#INC|INC]]
| [[#INC|INC]]
|-
| [[#INSB|INSB]]
| [[#INSB|INMB]]
|-
| [[#INSW|INSW]]
| [[#INSW|INMW]]
|-
| [[#INT|INT]]
| [[#INT|BRK]]
|-
| [[#INTO|INTO]]
| [[#INTO|BRKV]]
|-
| [[#IRET|IRET]]
| [[#IRET|RETI]]
|-
| [[#JA|JA]]
| [[#JA|BH]]
|-
| [[#JBE|JBE]]
| [[#JBE|BNH]]
|-
| [[#JC|JC/JB]]
| [[#JC|BC/BL]]
|-
| [[#JCXZ|JCXZ]]
| [[#JCXZ|BCWZ]]
|-
| [[#JG|JG]]
| [[#JG|BGT]]
|-
| [[#JGE|JGE]]
| [[#JGE|BGE]]
|-
| [[#JL|JL]]
| [[#JL|BLT]]
|-
| [[#JLE|JLE]]
| [[#JLE|BLE]]
|-
| [[#JMP|JMP]]
| [[#JMP|BR]]
|-
| [[#JNC|JNC/JAE]]
| [[#JNC|BNC/BNL]]
|-
| [[#JNO|JNO]]
| [[#JNO|BNV]]
|-
| [[#JNP|JNP]]
| [[#JNP|BPO]]
|-
| [[#JNS|JNS]]
| [[#JNS|BP]]
|-
| [[#JNZ|JNZ/JNE]]
| [[#JNZ|BNZ/BNE]]
|-
| [[#JO|JO]]
| [[#JO|BV]]
|-
| [[#JP|JP]]
| [[#JP|BPE]]
|-
| [[#JS|JS]]
| [[#JS|BN]]
|-
| [[#JZ|JZ/JE]]
| [[#JZ|BZ/BE]]
|-
| [[#LAHF|LAHF]]
| [[#LAHF|MOV]]
|-
| [[#LDS|LDS]]
| [[#LDS|MOV]]
|-
| [[#LEA|LEA]]
| [[#LEA|LDEA]]
|-
| [[#LEAVE|LEAVE]]
| [[#LEAVE|DISPOSE]]
|-
| [[#LES|LES]]
| [[#LES|MOV]]
|-
| [[#LOCK|LOCK]]
| [[#LOCK|BUSLOCK]]
|-
| [[#LODSB|LODSB]]
| [[#LODSB|LDMB]]
|-
| [[#LODSW|LODSW]]
| [[#LODSW|LDMW]]
|-
| [[#LOOP|LOOP]]
| [[#LOOP|DBNZ]]
|-
| [[#LOOPE|LOOPE]]
| [[#LOOPE|DBNZE]]
|-
| [[#LOOPNE|LOOPNE]]
| [[#LOOPNE|DBNZNE]]
|-
| [[#MOV|MOV]]
| [[#MOV|MOV]]
|-
| [[#MOVSB|MOVSB]]
| [[#MOVSB|MOVBKB]]
|-
| [[#MOVSW|MOVSW]]
| [[#MOVSW|MOVBKW]]
|-
| [[#MUL|MUL]]
| [[#MUL|MULU]]
|-
| [[#NEG|NEG]]
| [[#NEG|NEG]]
|-
| [[#NOP|NOP]]
| [[#NOP|NOP]]
|-
| [[#NOT|NOT]]
| [[#NOT|NOT]]
|-
| [[#OR|OR]]
| [[#OR|OR]]
|-
| [[#OUT|OUT]]
| [[#OUT|OUT]]
|-
| [[#OUTSB|OUTSB]]
| [[#OUTSB|OUTM]]
|-
| [[#OUTSW|OUTSW]]
| [[#OUTSW|OUTM]]
|-
| [[#POLL|POLL]]
| [[#POLL|POLL]]
|-
| [[#POP|POP]]
| [[#POP|POP]]
|-
| [[#POPA|POPA]]
| [[#POPA|POP]]
|-
| [[#POPF|POPF]]
| [[#POPF|POP]]
|-
| [[#PUSH|PUSH]]
| [[#PUSH|PUSH]]
|-
| [[#PUSHA|PUSHA]]
| [[#PUSHA|PUSH]]
|-
| [[#PUSHF|PUSHF]]
| [[#PUSHF|PUSH]]
|-
| [[#RCL|RCL]]
| [[#RCL|ROLC]]
|-
| [[#RCR|RCR]]
| [[#RCR|RORC]]
|-
| [[#REP|REP/REPE/REPZ]]
| [[#REP|REP/REPE/REPZ]]
|-
| [[#REPNE|REPNE/REPNZ]]
| [[#REPNE|REPNE/REPNZ]]
|-
| [[#RET|RET]]
| [[#RET|RET]]
|-
| [[#RETF|RETF]]
| [[#RETF|RET]]
|-
| [[#ROL|ROL]]
| [[#ROL|ROL]]
|-
| [[#ROR|ROR]]
| [[#ROR|ROR]]
|-
| [[#SAHF|SAHF]]
| [[#SAHF|MOV]]
|-
| [[#SAR|SAR]]
| [[#SAR|SHRA]]
|-
| [[#SBB|SBB]]
| [[#SBB|SUBC]]
|-
| [[#SCASB|SCASB]]
| [[#SCASB|CMPMB]]
|-
| [[#SCASW|SCASW]]
| [[#SCASW|CMPMW]]
|-
| [[#SHL|SHL]]
| [[#SHL|SHL]]
|-
| [[#SHR|SHR]]
| [[#SHR|SHR]]
|-
| [[#SS|SS]]
| [[#SS|SS]]
|-
| [[#STC|STC]]
| [[#STC|SET1 CY]]
|-
| [[#STD|STD]]
| [[#STD|SET1 DIR]]
|-
| [[#STI|STI]]
| [[#STI|EI]]
|-
| [[#STOSB|STOSB]]
| [[#STOSB|STMB]]
|-
| [[#STOSW|STOSW]]
| [[#STOSW|STMW]]
|-
| [[#SUB|SUB]]
| [[#SUB|SUB]]
|-
| [[#TEST|TEST]]
| [[#TEST|TEST]]
|-
| [[#XCHG|XCHG]]
| [[#XCHG|XCH]]
|-
| [[#XLAT|XLAT]]
| [[#XLAT|TRANS]]
|-
| [[#XOR|XOR]]
| [[#XOR|XOR]]
|}
== Official instructions by type ==
{| class="wikitable sortable" style="text-align: center"
!Type
!colspan=16 class="unsortable" | Instructions
|-
| style="text-align:left;" | Memory
| style="" | [[#MOV|MOV]]
| style="" | [[#XCHG|XCHG]]
| style="" | [[#XLAT|XLAT]]
| style="" | [[#LEA|LEA]]
| style="border-right:none;" | [[#LDS|LDS]]
| style="border-left:none;" | [[#LES|LES]]
| style="border-right:none;" | [[#IN|IN]]
| style="border-left:none;" | [[#OUT|OUT]]
| colspan="8" |
|-
| style="text-align:left;" | Ports
| style="border-right:none;" | [[#IN|IN]]
| style="border-left:none;" | [[#OUT|OUT]]
| style="border-right:none;" | [[#INSB|INSB]]
| style="border-left:none;" | [[#OUTSB|OUTSB]]
| style="border-right:none;" | [[#INSW|INSW]]
| style="border-left:none;" | [[#OUTSW|OUTSW]]
| colspan="10" |
|-
| style="text-align:left;" | Arithmetic
| style="border-right:none;" | [[#ADD|ADD]]
| style="border-left:none;" | [[#SUB|SUB]]
| style="border-right:none;" | [[#ADC|ADC]]
| style="border-left:none;" | [[#SBB|SBB]]
| style="border-right:none;" | [[#INC|INC]]
| style="border-left:none;" | [[#DEC|DEC]]
| style="border-right:none;" | [[#MUL|MUL]]
| style="border-left:none;" | [[#DIV|DIV]]
| style="border-right:none;" | [[#IMUL|IMUL]]
| style="border-left:none;" | [[#IDIV|IDIV]]
| style="" | [[#CMP|CMP]]
| style="" | [[#NEG|NEG]]
| colspan="4" |
|-
| style="text-align:left;" | Numeric
| style="" | [[#CBW|CBW]]
| style="" | [[#CWD|CWD]]
| style="" | [[#AAA|AAA]]
| style="" | [[#AAS|AAS]]
| style="" | [[#AAM|AAM]]
| style="" | [[#AAD|AAD]]
| style="" | [[#DAA|DAA]]
| style="" | [[#DAS|DAS]]
| colspan="8" |
|-
| style="text-align:left;" | Shift
| style="border-right:none;" | [[#ROL|ROL]]
| style="border-left:none;" | [[#ROR|ROR]]
| style="border-right:none;" | [[#RCL|RCL]]
| style="border-left:none;" | [[#RCR|RCR]]
| style="border-right:none;" | [[#SHL|SHL]]
| style="border-left:none;" | [[#SHR|SHR]]
| style="" | [[#SAR|SAR]]
| colspan="9" |
|-
| style="text-align:left;" | Bitwise
| style="" | [[#AND|AND]]
| style="" | [[#OR|OR]]
| style="" | [[#XOR|XOR]]
| style="" | [[#NOT|NOT]]
| style="" | [[#TEST|TEST]]
| colspan="11" |
|-
| style="text-align:left;" | Branch
| style="border-right:none;" | [[#JC|JC]]
| style="border-left:none;" | [[#JNC|JNC]]
| style="border-right:none;" | [[#JZ|JZ]]
| style="border-left:none;" | [[#JNZ|JNZ]]
| style="border-right:none;" | [[#JBE|JBE]]
| style="border-left:none;" | [[#JA|JA]]
| style="border-right:none;" | [[#JO|JO]]
| style="border-left:none;" | [[#JNO|JNO]]
| style="border-right:none;" | [[#JP|JP]]
| style="border-left:none;" | [[#JNP|JNP]]
| style="border-right:none;" | [[#JS|JS]]
| style="border-left:none;" | [[#JNS|JNS]]
| style="border-right:none;" | [[#JL|JL]]
| style="border-left:none;" | [[#JGE|JGE]]
| style="border-right:none;" | [[#JLE|JLE]]
| style="border-left:none;" | [[#JG|JG]]
|-
| style="text-align:left;" | Jump
| style="" | [[#JMP|JMP]]
| style="border-right:none;" | [[#CALL|CALL]]
| style="border-left:none;border-right:none;" | [[#RET|RET]]
| style="border-left:none;" | [[#RETF|RETF]]
| colspan="12" |
|-
| style="text-align:left;" | Loop
| style="" | [[#LOOP|LOOP]]
| style="" | [[#LOOPE|LOOPE]]
| style="" | [[#LOOPNE|LOOPNE]]
| colspan="13" |
|-
| style="text-align:left;" | Interrupt
| style="border-right:none;" | [[#INT|INT]]
| style="border-left:none;" | [[#IRET|IRET]]
| style="" | [[#INTO|INTO]]
| style="" | [[#HLT|HLT]]
| style="" | [[#BOUND|BOUND]]
| colspan="11" |
|-
| style="text-align:left;" | Stack
| style="border-right:none;" | [[#PUSH|PUSH]]
| style="border-left:none;" | [[#POP|POP]]
| style="border-right:none;" | [[#PUSHA|PUSHA]]
| style="border-left:none;" | [[#POPA|POPA]]
| style="border-right:none;" | [[#PUSHF|PUSHF]]
| style="border-left:none;" | [[#POPF|POPF]]
| colspan="10" |
|-
| style="text-align:left;" | Flags
| style="border-right:none;" | [[#CLC|CLC]]
| style="border-left:none;" | [[#STC|STC]]
| style="border-right:none;" | [[#CLD|CLD]]
| style="border-left:none;" | [[#STD|STD]]
| style="border-right:none;" | [[#CLI|CLI]]
| style="border-left:none;" | [[#STI|STI]]
| style="" | [[#CMC|CMC]]
| style="border-right:none;" | [[#LAHF|LAHF]]
| style="border-left:none;" | [[#SAHF|SAHF]]
| colspan="7" |
|-
| style="text-align:left;" | Prefix
| style="" | [[#CS|CS]]
| style="" | [[#DS|DS]]
| style="" | [[#ES|ES]]
| style="" | [[#SS|SS]]
| colspan="12" |
|-
| style="text-align:left;" | String
| style="border-right:none;" | [[#REP|REP]]
| style="border-left:none;border-right:none;" | [[#REP|REPE]]
| style="border-left:none;" | [[#REPNE|REPNE]]
| style="" | [[#MOVSB|MOVSB]]
| style="" | [[#MOVSW|MOVSW]]
| style="border-right:none;" | [[#LODSB|LODSB]]
| style="border-left:none;" | [[#STOSB|STOSB]]
| style="border-right:none;" | [[#LODSW|LODSW]]
| style="border-left:none;" | [[#STOSW|STOSW]]
| style="" | [[#CMPSB|CMPSB]]
| style="" | [[#SCASB|SCASB]]
| style="" | [[#CMPSW|CMPSW]]
| style="" | [[#SCASW|SCASW]]
| colspan="3" |
|-
| style="text-align:left;" | Other
| style="" | [[#NOP|NOP]]
| style="border-right:none;" | [[#ENTER|ENTER]]
| style="border-left:none;" | [[#LEAVE|LEAVE]]
| style="" | [[#LOCK|LOCK]]
| style="" | [[#POLL|POLL]]
| colspan="11" |
|}
== Instruction encoding ==
=== ModR/M byte ===
The ModR/M byte is used in most addressing modes which reference a memory location. This byte consists of three bitfield values:
* <tt>oo</tt> - M'''o'''de;
* <tt>rrr</tt> - Two possible functions:
** '''R'''egister (for addressing modes which require both a register and a register/memory operand),
** Opcode extension (for some opcodes' addressing modes which do not have such a requirement);
* <tt>mmm</tt> - Register/'''M'''emory.
The ''Mode'' and ''Register/Memory'' bitfields can refer to a memory location or to a register, as shown in the table below. In some addressing modes, the ''Register'' field also refers to a register; it is always interpreted as if ''Mode'' was equal to <tt>11</tt>.
{| class="wikitable" style="text-align: center"
! R/M \ Mode
! <tt>00</tt>
! <tt>01</tt>
! <tt>10</tt>
! <tt>11</tt> ''(byte)''
! <tt>11</tt> ''(word)''
|-
| <tt>000</tt>
| DS:[BX + SI]
| DS:[BX + SI + disp8]
| DS:[BX + SI + disp16]
| AL
| AX
|-
| <tt>001</tt>
| DS:[BX + DI]
| DS:[BX + DI + disp8]
| DS:[BX + DI + disp16]
| CL
| CX
|-
| <tt>010</tt>
| SS:[BP + SI]
| SS:[BP + SI + disp8]
| SS:[BP + SI + disp16]
| DL
| DX
|-
| <tt>011</tt>
| SS:[BP + DI]
| SS:[BP + DI + disp8]
| SS:[BP + DI + disp16]
| BL
| BX
|-
| <tt>100</tt>
| DS:[SI]
| DS:[SI + disp8]
| DS:[SI + disp16]
| AH
| SP
|-
| <tt>101</tt>
| DS:[DI]
| DS:[DI + disp8]
| DS:[DI + disp16]
| CH
| BP
|-
| <tt>110</tt>
| ''DS:[disp16]''
| SS:[BP + disp8]
| SS:[BP + disp16]
| DH
| SI
|-
| <tt>111</tt>
| DS:[BX]
| DS:[BX + disp8]
| DS:[BX + disp16]
| BH
| DI
|}
Displacements are either 8-bit (disp8) or 16-bit (disp16) signed values and they always immediately follow the ModR/M byte. Note that (<tt>oo</tt> = <tt>00</tt>, <tt>mmm</tt> = <tt>110</tt>) is a special case, in which the ''disp16'' value is used directly as a near pointer.
The instruction encoding lists below refer to this byte as <tt>oorrrmmm</tt> (binary), <tt>/r</tt> (hexadecimal) or <tt>/0</tt> (hexademical, <tt>rrr</tt> used as function <tt>0</tt>).
== Official instructions ==
{{Anchor|AAA}}
=== AAA ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| AAA || <tt>37</tt> || <tt>00110111</tt> || 1 || 9
|}
----
{{Anchor|AAD}}
=== AAD ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| AAD imm8 || <tt>B5 ii</tt> || <tt>11010100 iiiiiiii</tt> || 2 || 6
|}
----
{{Anchor|AAM}}
=== AAM ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| AAM imm8 || <tt>B4 ii</tt> || <tt>11010100 iiiiiiii</tt> || 2 || 17
|}
----
{{Anchor|AAS}}
=== AAS ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| AAS || <tt>3F</tt> || <tt>00111111</tt> || 1 || 9
|}
----
{{Anchor|ADC}}
=== ADC ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| ADC AL, imm || <tt>14 ii</tt> || <tt>00010100 iiiiiiii</tt> || 2 || 1
|-
| ADC AX, imm || <tt>15 ii ii</tt> || <tt>00010101 iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| ADC mem8, imm8 || <tt>80 /2 ii</tt> || <tt>10000000 oo010mmm iiiiiiii</tt> || 3+ || 3
|-
| ADC mem16, imm16 || <tt>81 /2 ii ii</tt> || <tt>10000001 oo010mmm iiiiiiii iiiiiiii</tt> || 4+ || 3
|-
| ADC mem16, simm8 || <tt>83 /2 ii</tt> || <tt>10000011 oo010mmm iiiiiiii</tt> || 3+ || 3
|-
| ADC mem8, reg8 || <tt>10 /r</tt> || <tt>00010000 oorrrmmm</tt> || 2+ || 3
|-
| ADC mem16, reg16 || <tt>11 /r</tt> || <tt>00010001 oorrrmmm</tt> || 2+ || 3
|-
| ADC reg8, imm8 || <tt>80 /2 ii</tt> || <tt>10000000 11010mmm iiiiiiii</tt> || 3 || 1
|-
| ADC reg16, imm16 || <tt>81 /2 ii ii</tt> || <tt>10000001 11010mmm iiiiiiii iiiiiiii</tt> || 4 || 1
|-
| ADC reg16, simm8 || <tt>83 /2 ii</tt> || <tt>10000011 11010mmm iiiiiiii</tt> || 3 || 1
|-
| ADC reg8, mem8 || <tt>12 /r</tt> || <tt>00010010 oorrrmmm</tt> || 2+ || 2
|-
| ADC reg16, mem16 || <tt>13 /r</tt> || <tt>00010011 oorrrmmm</tt> || 2+ || 2
|-
| ADC reg8, reg8 || <tt>10 /r</tt> || <tt>000100.0 11rrrmmm</tt> || 2 || 1
|-
| ADC reg16, reg16 || <tt>11 /r</tt> || <tt>000100.1 11rrrmmm</tt> || 2 || 1
|}
----
{{Anchor|ADD}}
=== ADD ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| ADD AL, imm || <tt>04 ii</tt> || <tt>00000100 iiiiiiii</tt> || 2 || 1
|-
| ADD AX, imm || <tt>05 ii ii</tt> || <tt>00000101 iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| ADD mem8, imm8 || <tt>80 /0 ii</tt> || <tt>10000000 oo000mmm iiiiiiii</tt> || 3+ || 3
|-
| ADD mem16, imm16 || <tt>81 /0 ii ii</tt> || <tt>10000001 oo000mmm iiiiiiii iiiiiiii</tt> || 4+ || 3
|-
| ADD mem16, simm8 || <tt>83 /0 ii</tt> || <tt>10000011 oo000mmm iiiiiiii</tt> || 3+ || 3
|-
| ADD mem8, reg8 || <tt>00 /r</tt> || <tt>00000000 oorrrmmm</tt> || 2+ || 3
|-
| ADD mem16, reg16 || <tt>01 /r</tt> || <tt>00000001 oorrrmmm</tt> || 2+ || 3
|-
| ADD reg8, imm8 || <tt>80 /0 ii</tt> || <tt>10000000 11000mmm iiiiiiii</tt> || 3 || 1
|-
| ADD reg16, imm16 || <tt>81 /0 ii ii</tt> || <tt>10000001 11000mmm iiiiiiii iiiiiiii</tt> || 4 || 1
|-
| ADD reg16, simm8 || <tt>83 /0 ii</tt> || <tt>10000011 11000mmm iiiiiiii</tt> || 3 || 1
|-
| ADD reg8, mem8 || <tt>02 /r</tt> || <tt>00000010 oorrrmmm</tt> || 2+ || 2
|-
| ADD reg16, mem16 || <tt>03 /r</tt> || <tt>00000011 oorrrmmm</tt> || 2+ || 2
|-
| ADD reg8, reg8 || <tt>00 /r</tt> || <tt>000000.0 11rrrmmm</tt> || 2 || 1
|-
| ADD reg16, reg16 || <tt>01 /r</tt> || <tt>000000.1 11rrrmmm</tt> || 2 || 1
|}
----
{{Anchor|AND}}
=== AND ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| AND AL, imm || <tt>24 ii</tt> || <tt>00100100 iiiiiiii</tt> || 2 || 1
|-
| AND AX, imm || <tt>25 ii ii</tt> || <tt>00100101 iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| AND mem8, imm8 || <tt>80 /4 ii</tt> || <tt>10000000 oo100mmm iiiiiiii</tt> || 3+ || 3
|-
| AND mem16, imm16 || <tt>81 /4 ii ii</tt> || <tt>10000001 oo100mmm iiiiiiii iiiiiiii</tt> || 4+ || 3
|-
| AND mem16, simm8 || <tt>83 /4 ii</tt> || <tt>10000011 oo100mmm iiiiiiii</tt> || 3+ || 3
|-
| AND mem8, reg8 || <tt>20 /r</tt> || <tt>00100000 oorrrmmm</tt> || 2+ || 3
|-
| AND mem16, reg16 || <tt>21 /r</tt> || <tt>00100001 oorrrmmm</tt> || 2+ || 3
|-
| AND reg8, imm8 || <tt>80 /4 ii</tt> || <tt>10000000 11100mmm iiiiiiii</tt> || 3 || 1
|-
| AND reg16, imm16 || <tt>81 /4 ii ii</tt> || <tt>10000001 11100mmm iiiiiiii iiiiiiii</tt> || 4 || 1
|-
| AND reg16, simm8 || <tt>83 /4 ii</tt> || <tt>10000011 11100mmm iiiiiiii</tt> || 3 || 1
|-
| AND reg8, mem8 || <tt>22 /r</tt> || <tt>00100010 oorrrmmm</tt> || 2+ || 2
|-
| AND reg16, mem16 || <tt>23 /r</tt> || <tt>00100011 oorrrmmm</tt> || 2+ || 2
|-
| AND reg8, reg8 || <tt>20 /r</tt> || <tt>001000.0 11rrrmmm</tt> || 2 || 1
|-
| AND reg16, reg16 || <tt>21 /r</tt> || <tt>001000.1 11rrrmmm</tt> || 2 || 1
|}
----
{{Anchor|BOUND}}
=== BOUND ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| BOUND reg16, mem16:16 || <tt>62 /r</tt> || <tt>01100010 oorrrmmm</tt> || 2+ || 13 (20 if condition met)
|}
----
{{Anchor|CALL}}
=== CALL ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| CALL ptr16:16 || <tt>CA oo oo ss ss</tt> || <tt>10011010 oooooooo oooooooo ssssssss ssssssss</tt> || 5 || 10
|-
| CALL mem16 || <tt>FF /2</tt> || <tt>11111111 oo010mmm</tt> || 2+ || 6
|-
| CALL mem16:16 || <tt>FF /3</tt> || <tt>11111111 oo011mmm</tt> || 2+ || 12
|-
| CALL reg16 || <tt>FF /2</tt> || <tt>11111111 11010mmm</tt> || 2 || 5
|-
| CALL rel16 || <tt>E8 ii ii</tt> || <tt>11101000 iiiiiiii iiiiiiii</tt> || 3 || 5
|}
----
{{Anchor|CBW}}
=== CBW ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| CBW || <tt>98</tt> || <tt>10011000</tt> || 1 || 1
|}
----
{{Anchor|CLC}}
=== CLC ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| CLC || <tt>F8</tt> || <tt>11111000</tt> || 1 || 4
|}
----
{{Anchor|CLD}}
=== CLD ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| CLD || <tt>FC</tt> || <tt>11111100</tt> || 1 || 4
|}
----
{{Anchor|CLI}}
=== CLI ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| CLI || <tt>FA</tt> || <tt>11111010</tt> || 1 || 4
|}
----
{{Anchor|CMC}}
=== CMC ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| CMC || <tt>F5</tt> || <tt>11110101</tt> || 1 || 4
|}
----
{{Anchor|CMP}}
=== CMP ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| CMP AL, imm || <tt>3C ii</tt> || <tt>00111100 iiiiiiii</tt> || 2 || 1
|-
| CMP AX, imm || <tt>3D ii ii</tt> || <tt>00111101 iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| CMP mem8, imm8 || <tt>80 /7 ii</tt> || <tt>10000000 oo111mmm iiiiiiii</tt> || 3+ || 2
|-
| CMP mem16, imm16 || <tt>81 /7 ii ii</tt> || <tt>10000001 oo111mmm iiiiiiii iiiiiiii</tt> || 4+ || 2
|-
| CMP mem16, simm8 || <tt>83 /7 ii</tt> || <tt>10000011 oo111mmm iiiiiiii</tt> || 3+ || 2
|-
| CMP mem8, reg8 || <tt>38 /r</tt> || <tt>00111000 oorrrmmm</tt> || 2+ || 2
|-
| CMP mem16, reg16 || <tt>39 /r</tt> || <tt>00111001 oorrrmmm</tt> || 2+ || 2
|-
| CMP reg8, imm8 || <tt>80 /7 ii</tt> || <tt>10000000 11111mmm iiiiiiii</tt> || 3 || 1
|-
| CMP reg16, imm16 || <tt>81 /7 ii ii</tt> || <tt>10000001 11111mmm iiiiiiii iiiiiiii</tt> || 4 || 1
|-
| CMP reg16, simm8 || <tt>83 /7 ii</tt> || <tt>10000011 11111mmm iiiiiiii</tt> || 3 || 1
|-
| CMP reg8, mem8 || <tt>3A /r</tt> || <tt>00111010 oorrrmmm</tt> || 2+ || 2
|-
| CMP reg16, mem16 || <tt>3B /r</tt> || <tt>00111011 oorrrmmm</tt> || 2+ || 2
|-
| CMP reg8, reg8 || <tt>38 /r</tt> || <tt>001110.0 11rrrmmm</tt> || 2 || 1
|-
| CMP reg16, reg16 || <tt>39 /r</tt> || <tt>001110.1 11rrrmmm</tt> || 2 || 1
|}
----
{{Anchor|CMPSB}}
{{Anchor|CMPSW}}
=== CMPSB/CMPSW ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| CMPSB || <tt>A6</tt> || <tt>10100110</tt> || 1 || 6
|-
| CMPSW || <tt>A7</tt> || <tt>10100111</tt> || 1 || 6
|}
----
{{Anchor|CS}}
=== CS ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| CS || <tt>2E</tt> || <tt>00101110</tt> || 1 || 1
|}
----
{{Anchor|CWD}}
=== CWD ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| CWD || <tt>99</tt> || <tt>10011001</tt> || 1 || 1
|}
----
{{Anchor|DAA}}
=== DAA ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| DAA || <tt>27</tt> || <tt>00100111</tt> || 1 || 10
|}
----
{{Anchor|DAS}}
=== DAS ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| DAS || <tt>2F</tt> || <tt>00101111</tt> || 1 || 10
|}
----
{{Anchor|DEC}}
=== DEC ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| DEC mem8 || <tt>FE /1</tt> || <tt>11111110 oo001mmm</tt> || 2+ || 3
|-
| DEC mem16 || <tt>FF /1</tt> || <tt>11111111 oo001mmm</tt> || 2+ || 3
|-
| DEC reg8 || <tt>FE /1</tt> || <tt>11111110 11001mmm</tt> || 2+ || 1
|-
| DEC reg16 || <tt>4x</tt> || <tt>01001rrr</tt> || 1 || 1
|}
----
{{Anchor|DIV}}
=== DIV ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| DIV mem8 || <tt>F6 /6</tt> || <tt>11110110 oo110mmm</tt> || 2+ || 16
|-
| DIV mem16 || <tt>F7 /6</tt> || <tt>11111111 oo110mmm</tt> || 2+ || 24
|-
| DIV reg8 || <tt>F6 /6</tt> || <tt>11111110 11110mmm</tt> || 2 || 15
|-
| DIV reg16 || <tt>F7 /6</tt> || <tt>11111111 11110mmm</tt> || 2 || 23
|}
----
{{Anchor|DS}}
=== DS ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| DS || <tt>3E</tt> || <tt>00111110</tt> || 1 || 1
|}
----
{{Anchor|ENTER}}
=== ENTER ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| ENTER imm16, imm8 || <tt>C8 ii ii jj</tt> || <tt>11001000 iiiiiiii iiiiiiii jjjjjjjj</tt> || 3 || 8 (imm8 = 0)<br/>14 (imm8 = 1)<br/>15 + imm8 * 4 (imm8 >= 2)
|}
----
{{Anchor|ES}}
=== ES ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| ES || <tt>26</tt> || <tt>00100110</tt> || 1 || 1
|}
----
{{Anchor|HLT}}
=== HLT ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| HLT || <tt>F4</tt> || <tt>11110100</tt> || 1 || 9
|}
----
{{Anchor|IDIV}}
=== IDIV ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| IDIV mem8 || <tt>F6 /7</tt> || <tt>11110110 oo111mmm</tt> || 2+ || 18
|-
| IDIV mem16 || <tt>F7 /7</tt> || <tt>11111111 oo111mmm</tt> || 2+ || 25
|-
| IDIV reg8 || <tt>F6 /7</tt> || <tt>11111110 11111mmm</tt> || 2 || 17
|-
| IDIV reg16 || <tt>F7 /7</tt> || <tt>11111111 11111mmm</tt> || 2 || 24
|}
----
{{Anchor|IMUL}}
=== IMUL ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| IMUL mem8 || <tt>F6 /5</tt> || <tt>11110110 oo101mmm</tt> || 2+ || 4
|-
| IMUL mem16 || <tt>F7 /5</tt> || <tt>11111111 oo101mmm</tt> || 2+ || 4
|-
| IMUL reg8 || <tt>F6 /5</tt> || <tt>11111110 11101mmm</tt> || 2 || 3
|-
| IMUL reg16 || <tt>F7 /5</tt> || <tt>11111111 11101mmm</tt> || 2 || 3
|-
| IMUL reg16, mem16, imm16 || <tt>69 /r ii ii</tt> || <tt>11111111 oorrrmmm iiiiiiii iiiiiiii</tt> || 4 || 4
|-
| IMUL reg16, mem16, simm8 || <tt>6B /r ii</tt> || <tt>11111111 oorrrmmm iiiiiiii</tt> || 3 || 4
|-
| IMUL reg16, reg16, imm16 || <tt>69 /r ii ii</tt> || <tt>11111111 11rrrmmm iiiiiiii iiiiiiii</tt> || 4 || 3
|-
| IMUL reg16, reg16, simm8 || <tt>6B /r ii</tt> || <tt>11111111 11rrrmmm iiiiiiii</tt> || 3 || 3
|}
----
{{Anchor|IN}}
=== IN ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| IN AL, DX || <tt>EC</tt> || <tt>11101100</tt> || 1 || 6
|-
| IN AX, DX || <tt>ED</tt> || <tt>11101101</tt> || 1 || 6
|-
| IN AL, imm8 || <tt>E4 ii</tt> || <tt>11100100 iiiiiiii</tt> || 2 || 6
|-
| IN AX, imm8 || <tt>E5 ii</tt> || <tt>11100101 iiiiiiii</tt> || 2 || 6
|}
----
{{Anchor|INC}}
=== INC ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| INC mem8 || <tt>FE /0</tt> || <tt>11111110 oo000mmm</tt> || 2+ || 3
|-
| INC mem16 || <tt>FF /0</tt> || <tt>11111111 oo000mmm</tt> || 2+ || 3
|-
| INC reg8 || <tt>FE /0</tt> || <tt>11111110 11000mmm</tt> || 2+ || 1
|-
| INC reg16 || <tt>4x</tt> || <tt>01000rrr</tt> || 1 || 1
|}
----
{{Anchor|INSB}}
{{Anchor|INSW}}
=== INSB/INSW ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| INSB || <tt>6C</tt> || <tt>01101100</tt> || 1 || 6
|-
| INSW || <tt>6D</tt> || <tt>01101101</tt> || 1 || 6
|}
----
{{Anchor|INT}}
=== INT ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| INT 3 || <tt>CC</tt> || <tt>11001100</tt> || 1 || 9
|-
| INT imm8 || <tt>CD ii</tt> || <tt>11001101 iiiiiiii</tt> || 2 || 10
|}
----
{{Anchor|INTO}}
=== INTO ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| INTO || <tt>CE</tt> || <tt>11001110</tt> || 1 || 6 (13 if OF = 1)
|}
----
{{Anchor|IRET}}
=== IRET ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| IRET || <tt>CF</tt> || <tt>11001111</tt> || 1 || 10
|}
----
{{Anchor|JA}}
=== JA ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JA rel8 || <tt>77 ii</tt> || <tt>01110111 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JBE}}
=== JBE ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JA rel8 || <tt>76 ii</tt> || <tt>01110110 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JC}}
=== JC/JB ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JC rel8 || <tt>72 ii</tt> || <tt>01110010 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JCXZ}}
=== JCXZ ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JCXZ rel8 || <tt>E3 ii</tt> || <tt>11100011 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JG}}
=== JG ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JG rel8 || <tt>7F ii</tt> || <tt>01111111 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JGE}}
=== JGE ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JGE rel8 || <tt>7D ii</tt> || <tt>01111101 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JL}}
=== JL ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JL rel8 || <tt>7C ii</tt> || <tt>01111100 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JLE}}
=== JLE ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JLE rel8 || <tt>7E ii</tt> || <tt>01111110 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JMP}}
=== JMP ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JMP ptr16:16 || <tt>EA oo oo ss ss</tt> || <tt>11101010 oooooooo oooooooo ssssssss ssssssss</tt> || 5 || 7
|-
| JMP mem16 || <tt>FF /4</tt> || <tt>11111111 oo100mmm</tt> || 2+ || 5
|-
| JMP mem16:16 || <tt>FF /5</tt> || <tt>11111111 oo101mmm</tt> || 2+ || 10
|-
| JMP reg16 || <tt>FF /4</tt> || <tt>11111111 11100mmm</tt> || 2 || 4
|-
| JMP rel8 || <tt>EB ii</tt> || <tt>11101011 iiiiiiii</tt> || 2 || 4
|-
| JMP rel16 || <tt>E9 ii ii</tt> || <tt>11101001 iiiiiiii iiiiiiii</tt> || 3 || 4
|}
----
{{Anchor|JNC}}
=== JNC/JAE ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JNC rel8 || <tt>73 ii</tt> || <tt>01110011 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JNO}}
=== JNO ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JNO rel8 || <tt>71 ii</tt> || <tt>01110001 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JNP}}
=== JNP ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JNP rel8 || <tt>7B ii</tt> || <tt>01111011 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JNS}}
=== JNS ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JNS rel8 || <tt>79 ii</tt> || <tt>01111001 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JNZ}}
=== JNZ/JNE ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JNZ rel8 || <tt>75 ii</tt> || <tt>01110101 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JO}}
=== JO ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JO rel8 || <tt>70 ii</tt> || <tt>01110000 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JP}}
=== JP ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JP rel8 || <tt>7A ii</tt> || <tt>01111010 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JS}}
=== JS ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JS rel8 || <tt>78 ii</tt> || <tt>01111000 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JZ}}
=== JZ/JE ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JZ rel8 || <tt>74 ii</tt> || <tt>01110100 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|LAHF}}
=== LAHF ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| LAHF || <tt>9F</tt> || <tt>10011111</tt> || 1 || 2
|}
----
{{Anchor|LDS}}
=== LDS ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| LDS reg16, mem16 || <tt>C5 /r</tt> || <tt>11000101 oorrrmmm</tt> || 2+ || 6
|}
----
{{Anchor|LEA}}
=== LEA ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| LEA reg16, mem16 || <tt>8D /r</tt> || <tt>10001101 oorrrmmm</tt> || 2+ || 1
|}
----
{{Anchor|LEAVE}}
=== LEAVE ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| LEAVE || <tt>C9</tt> || <tt>11001001</tt> || 1 || 2
|}
----
{{Anchor|LES}}
=== LES ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| LES reg16, mem16 || <tt>C4 /r</tt> || <tt>11000100 oorrrmmm</tt> || 2+ || 6
|}
----
{{Anchor|LOCK}}
=== LOCK ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| LOCK || <tt>F0</tt> || <tt>11110000</tt> || 1 || 1
|}
----
{{Anchor|LODSB}}
{{Anchor|LODSW}}
=== LODSB/LODSW ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| LODSB || <tt>AC</tt> || <tt>10101100</tt> || 1 || 3
|-
| LODSW || <tt>AD</tt> || <tt>10101101</tt> || 1 || 3
|}
----
{{Anchor|LOOP}}
=== LOOP ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| LOOP rel8 || <tt>E2 ii</tt> || <tt>11100010 iiiiiiii</tt> || 2 || 2 (5 if branch taken)
|}
----
{{Anchor|LOOPE}}
=== LOOPE ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| LOOPE rel8 || <tt>E1 ii</tt> || <tt>11100001 iiiiiiii</tt> || 2 || 3 (6 if branch taken)
|}
----
{{Anchor|LOOPNE}}
=== LOOPNE ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| LOOPNE rel8 || <tt>E0 ii</tt> || <tt>11100000 iiiiiiii</tt> || 2 || 3 (6 if branch taken)
|}
----
{{Anchor|MOV}}
=== MOV ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| MOV AL, ptr16 || <tt>A0 ii ii</tt> || <tt>10100000 iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| MOV AX, ptr16 || <tt>A1 ii ii</tt> || <tt>10100001 iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| MOV mem8, imm8 || <tt>C6 /0 ii</tt> || <tt>11000110 oo000mmm iiiiiiii</tt> || 3+ || 1
|-
| MOV mem16, imm16 || <tt>C7 /0 ii ii</tt> || <tt>11000111 oo000mmm iiiiiiii iiiiiiii</tt> || 4+ || 1
|-
| MOV mem8, reg8 || <tt>84 /r</tt> || <tt>10001000 oorrrmmm</tt> || 2+ || 1
|-
| MOV mem16, reg16 || <tt>85 /r</tt> || <tt>10001001 oorrrmmm</tt> || 2+ || 1
|-
| MOV mem16, sreg16 || <tt>8C /r</tt> || <tt>10001100 oo0rrmmm</tt> || 2+ || 3
|-
| MOV ptr16, AL || <tt>A2 ii ii</tt> || <tt>10100010 iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| MOV ptr16, AX || <tt>A3 ii ii</tt> || <tt>10100011 iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| MOV reg8, imm8 || <tt>Bx ii</tt> || <tt>10110rrr iiiiiiii</tt> || 2 || 1
|-
| MOV reg8, imm8 || <tt>C6 /0 ii</tt> || <tt>11000110 11000mmm iiiiiiii</tt> || 3 || 1
|-
| MOV reg16, imm16 || <tt>Bx ii</tt> || <tt>10111rrr iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| MOV reg16, imm16 || <tt>C7 /0 ii ii</tt> || <tt>11000111 11000mmm iiiiiiii iiiiiiii</tt> || 4 || 1
|-
| MOV reg8, mem8 || <tt>8A /r</tt> || <tt>10001010 oorrrmmm</tt> || 2+ || 1
|-
| MOV reg16, mem16 || <tt>8B /r</tt> || <tt>10001011 oorrrmmm</tt> || 2+ || 1
|-
| MOV reg8, reg8 || <tt>88 /r</tt> || <tt>100010.0 11rrrmmm</tt> || 2 || 1
|-
| MOV reg16, reg16 || <tt>89 /r</tt> || <tt>100010.1 11rrrmmm</tt> || 2 || 1
|-
| MOV reg16, sreg16 || <tt>8C /r</tt> || <tt>10001100 110rrmmm</tt> || 2 || 1
|-
| MOV sreg16, mem16 || <tt>8E /r</tt> || <tt>10001110 oo0rrmmm</tt> || 2 || 3
|-
| MOV sreg16, reg16 || <tt>8E /r</tt> || <tt>10001110 110rrmmm</tt> || 2+ || 2
|}
----
{{Anchor|MOVSB}}
{{Anchor|MOVSW}}
=== MOVSB/MOVSW ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| MOVSB || <tt>A4</tt> || <tt>10100100</tt> || 1 || 5
|-
| MOVSW || <tt>A5</tt> || <tt>10100101</tt> || 1 || 5
|}
----
{{Anchor|MUL}}
=== MUL ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| MUL mem8 || <tt>F6 /4</tt> || <tt>11110110 oo100mmm</tt> || 2+ || 4
|-
| MUL mem16 || <tt>F7 /4</tt> || <tt>11111111 oo100mmm</tt> || 2+ || 4
|-
| MUL reg8 || <tt>F6 /4</tt> || <tt>11111110 11100mmm</tt> || 2 || 3
|-
| MUL reg16 || <tt>F7 /4</tt> || <tt>11111111 11100mmm</tt> || 2 || 3
|}
----
{{Anchor|NEG}}
=== NEG ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| NEG mem8 || <tt>F6 /3</tt> || <tt>11110110 oo011mmm</tt> || 2+ || 3
|-
| NEG mem16 || <tt>F7 /3</tt> || <tt>11111111 oo011mmm</tt> || 2+ || 3
|-
| NEG reg8 || <tt>F6 /3</tt> || <tt>11111110 11011mmm</tt> || 2 || 1
|-
| NEG reg16 || <tt>F7 /3</tt> || <tt>11111111 11011mmm</tt> || 2 || 1
|}
----
{{Anchor|NOP}}
=== NOP ===
----
{{Anchor|NOT}}
=== NOT ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| NOT mem8 || <tt>F6 /2</tt> || <tt>11110110 oo010mmm</tt> || 2+ || 3
|-
| NOT mem16 || <tt>F7 /2</tt> || <tt>11111111 oo010mmm</tt> || 2+ || 3
|-
| NOT reg8 || <tt>F6 /2</tt> || <tt>11111110 11010mmm</tt> || 2 || 1
|-
| NOT reg16 || <tt>F7 /2</tt> || <tt>11111111 11010mmm</tt> || 2 || 1
|}
----
{{Anchor|OR}}
=== OR ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| OR AL, imm || <tt>0C ii</tt> || <tt>00001100 iiiiiiii</tt> || 2 || 1
|-
| OR AX, imm || <tt>0D ii ii</tt> || <tt>00001101 iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| OR mem8, imm8 || <tt>80 /6 ii</tt> || <tt>10000000 oo001mmm iiiiiiii</tt> || 3+ || 3
|-
| OR mem16, imm16 || <tt>81 /6 ii ii</tt> || <tt>10000001 oo001mmm iiiiiiii iiiiiiii</tt> || 4+ || 3
|-
| OR mem16, simm8 || <tt>83 /6 ii</tt> || <tt>10000011 oo001mmm iiiiiiii</tt> || 3+ || 3
|-
| OR mem8, reg8 || <tt>08 /r</tt> || <tt>00001000 oorrrmmm</tt> || 2+ || 3
|-
| OR mem16, reg16 || <tt>09 /r</tt> || <tt>00001001 oorrrmmm</tt> || 2+ || 3
|-
| OR reg8, imm8 || <tt>80 /6 ii</tt> || <tt>10000000 11001mmm iiiiiiii</tt> || 3 || 1
|-
| OR reg16, imm16 || <tt>81 /6 ii ii</tt> || <tt>10000001 11001mmm iiiiiiii iiiiiiii</tt> || 4 || 1
|-
| OR reg16, simm8 || <tt>83 /6 ii</tt> || <tt>10000011 11001mmm iiiiiiii</tt> || 3 || 1
|-
| OR reg8, mem8 || <tt>0A /r</tt> || <tt>00001010 oorrrmmm</tt> || 2+ || 2
|-
| OR reg16, mem16 || <tt>0B /r</tt> || <tt>00001011 oorrrmmm</tt> || 2+ || 2
|-
| OR reg8, reg8 || <tt>08 /r</tt> || <tt>000010.0 11rrrmmm</tt> || 2 || 1
|-
| OR reg16, reg16 || <tt>09 /r</tt> || <tt>000010.1 11rrrmmm</tt> || 2 || 1
|}
----
{{Anchor|OUT}}
=== OUT ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| OUT AL, DX || <tt>EE</tt> || <tt>11101110</tt> || 1 || 6
|-
| OUT AX, DX || <tt>EF</tt> || <tt>11101111</tt> || 1 || 6
|-
| OUT AL, imm8 || <tt>E6 ii</tt> || <tt>11100110 iiiiiiii</tt> || 2 || 6
|-
| OUT AX, imm8 || <tt>E7 ii</tt> || <tt>11100111 iiiiiiii</tt> || 2 || 6
|}
----
{{Anchor|OUTSB}}
{{Anchor|OUTSW}}
=== OUTSB/OUTSW ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| OUTSB || <tt>6E</tt> || <tt>01101110</tt> || 1 || 6
|-
| OUTSW || <tt>6F</tt> || <tt>01101111</tt> || 1 || 6
|}
----
{{Anchor|POLL}}
=== POLL ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| POLL || <tt>6E</tt> || <tt>01101110</tt> || 1 || 9<ref>On the WonderSwan implementation, POLLB is always held low; on other implementations, POLL will wait for POLLB to be held low in 9-cycle intervals.</ref>
|}
----
{{Anchor|POP}}
=== POP ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| POP mem16 || <tt>8F /0</tt> || <tt>10001111 oo000mmm</tt> || 2+ || 3
|-
| POP reg16 || <tt>5x</tt> || <tt>01011xxx</tt> || 1 || 1
|-
| POP reg16 || <tt>8F /0</tt> || <tt>10001111 11000mmm</tt> || 2 || 1
|-
| POP sreg16 || <tt>xx</tt> || <tt>000xx111</tt> || 1 || 3
|}
----
{{Anchor|POPA}}
=== POPA ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| POPA || <tt>61</tt> || <tt>01100001</tt> || 1 || 8
|}
----
{{Anchor|POPF}}
=== POPF ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| POPF || <tt>9D</tt> || <tt>10011101</tt> || 1 || 3
|}
----
{{Anchor|PUSH}}
=== PUSH ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| PUSH imm8 || <tt>6A ii</tt> || <tt>01101010 iiiiiiii</tt> || 2 || 1
|-
| PUSH imm16 || <tt>68 ii ii</tt> || <tt>01101000 iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| PUSH mem16 || <tt>FF /6</tt> || <tt>11111111 oo110mmm</tt> || 2+ || 2
|-
| PUSH reg16 || <tt>5x</tt> || <tt>01010xxx</tt> || 1 || 1
|-
| PUSH reg16 || <tt>FF /6</tt> || <tt>11111111 11110mmm</tt> || 2 || 1
|-
| PUSH sreg16 || <tt>xx</tt> || <tt>000xx110</tt> || 1 || 2
|}
----
{{Anchor|PUSHA}}
=== PUSHA ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| PUSHA || <tt>60</tt> || <tt>01100000</tt> || 1 || 9
|}
----
{{Anchor|PUSHF}}
=== PUSHF ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| PUSHF || <tt>9C</tt> || <tt>10011100</tt> || 1 || 2
|}
----
{{Anchor|RCL}}
=== RCL ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| RCL mem8, 1 || <tt>D0 /2</tt> || <tt>11010000 oo010rm</tt> || 2+ || 3
|-
| RCL mem8, CL || <tt>D2 /2</tt> || <tt>11010010 oo010rm</tt> || 2+ || 5
|-
| RCL mem8, imm8 || <tt>C0 /2 ii</tt> || <tt>11000000 oo010rm</tt> || 3+ || 5
|-
| RCL mem16, 1 || <tt>D1 /2</tt> || <tt>11010001 oo010rm</tt> || 2+ || 3
|-
| RCL mem16, CL || <tt>D3 /2</tt> || <tt>11010011 oo010rm</tt> || 2+ || 5
|-
| RCL mem16, imm8 || <tt>C1 /2 ii</tt> || <tt>11000001 oo010rm</tt> || 3+ || 5
|-
| RCL reg8, 1 || <tt>D0 /2</tt> || <tt>11010000 11010rm</tt> || 2 || 1
|-
| RCL reg8, CL || <tt>D2 /2</tt> || <tt>11010010 11010rm</tt> || 2 || 3
|-
| RCL reg8, imm8 || <tt>C0 /2 ii</tt> || <tt>11000000 11010rm</tt> || 3 || 3
|-
| RCL reg16, 1 || <tt>D1 /2</tt> || <tt>11010001 11010rm</tt> || 2 || 1
|-
| RCL reg16, CL || <tt>D3 /2</tt> || <tt>11010011 11010rm</tt> || 2 || 3
|-
| RCL reg16, imm8 || <tt>C1 /2 ii</tt> || <tt>11000001 11010rm</tt> || 3 || 3
|}
----
{{Anchor|RCR}}
=== RCR ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| RCR mem8, 1 || <tt>D0 /3</tt> || <tt>11010000 oo011rm</tt> || 2+ || 3
|-
| RCR mem8, CL || <tt>D2 /3</tt> || <tt>11010010 oo011rm</tt> || 2+ || 5
|-
| RCR mem8, imm8 || <tt>C0 /3 ii</tt> || <tt>11000000 oo011rm</tt> || 3+ || 5
|-
| RCR mem16, 1 || <tt>D1 /3</tt> || <tt>11010001 oo011rm</tt> || 2+ || 3
|-
| RCR mem16, CL || <tt>D3 /3</tt> || <tt>11010011 oo011rm</tt> || 2+ || 5
|-
| RCR mem16, imm8 || <tt>C1 /3 ii</tt> || <tt>11000001 oo011rm</tt> || 3+ || 5
|-
| RCR reg8, 1 || <tt>D0 /3</tt> || <tt>11010000 11011rm</tt> || 2 || 1
|-
| RCR reg8, CL || <tt>D2 /3</tt> || <tt>11010010 11011rm</tt> || 2 || 3
|-
| RCR reg8, imm8 || <tt>C0 /3 ii</tt> || <tt>11000000 11011rm</tt> || 3 || 3
|-
| RCR reg16, 1 || <tt>D1 /3</tt> || <tt>11010001 11011rm</tt> || 2 || 1
|-
| RCR reg16, CL || <tt>D3 /3</tt> || <tt>11010011 11011rm</tt> || 2 || 3
|-
| RCR reg16, imm8 || <tt>C1 /3 ii</tt> || <tt>11000001 11011rm</tt> || 3 || 3
|}
----
{{Anchor|REP}}
=== REP/REPE/REPZ ===
----
{{Anchor|REPNE}}
=== REPNE/REPNZ ===
----
{{Anchor|RET}}
=== RET ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| RET || <tt>C3</tt> || <tt>11000011</tt> || 1 || 6
|-
| RET imm16 || <tt>C2 ii ii</tt> || <tt>11000010 iiiiiiii iiiiiiii</tt> || 1 || 6
|}
----
{{Anchor|RETF}}
=== RETF ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| RETF || <tt>CB</tt> || <tt>11001011</tt> || 1 || 9
|-
| RETF imm16 || <tt>CA ii ii</tt> || <tt>11001010 iiiiiiii iiiiiiii</tt> || 1 || 8
|}
----
{{Anchor|ROL}}
=== ROL ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| ROL mem8, 1 || <tt>D0 /0</tt> || <tt>11010000 oo000rm</tt> || 2+ || 3
|-
| ROL mem8, CL || <tt>D2 /0</tt> || <tt>11010010 oo000rm</tt> || 2+ || 5
|-
| ROL mem8, imm8 || <tt>C0 /0 ii</tt> || <tt>11000000 oo000rm</tt> || 3+ || 5
|-
| ROL mem16, 1 || <tt>D1 /0</tt> || <tt>11010001 oo000rm</tt> || 2+ || 3
|-
| ROL mem16, CL || <tt>D3 /0</tt> || <tt>11010011 oo000rm</tt> || 2+ || 5
|-
| ROL mem16, imm8 || <tt>C1 /0 ii</tt> || <tt>11000001 oo000rm</tt> || 3+ || 5
|-
| ROL reg8, 1 || <tt>D0 /0</tt> || <tt>11010000 11000rm</tt> || 2 || 1
|-
| ROL reg8, CL || <tt>D2 /0</tt> || <tt>11010010 11000rm</tt> || 2 || 3
|-
| ROL reg8, imm8 || <tt>C0 /0 ii</tt> || <tt>11000000 11000rm</tt> || 3 || 3
|-
| ROL reg16, 1 || <tt>D1 /0</tt> || <tt>11010001 11000rm</tt> || 2 || 1
|-
| ROL reg16, CL || <tt>D3 /0</tt> || <tt>11010011 11000rm</tt> || 2 || 3
|-
| ROL reg16, imm8 || <tt>C1 /0 ii</tt> || <tt>11000001 11000rm</tt> || 3 || 3
|}
----
{{Anchor|ROR}}
=== ROR ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| ROR mem8, 1 || <tt>D0 /1</tt> || <tt>11010000 oo001rm</tt> || 2+ || 3
|-
| ROR mem8, CL || <tt>D2 /1</tt> || <tt>11010010 oo001rm</tt> || 2+ || 5
|-
| ROR mem8, imm8 || <tt>C0 /1 ii</tt> || <tt>11000000 oo001rm</tt> || 3+ || 5
|-
| ROR mem16, 1 || <tt>D1 /1</tt> || <tt>11010001 oo001rm</tt> || 2+ || 3
|-
| ROR mem16, CL || <tt>D3 /1</tt> || <tt>11010011 oo001rm</tt> || 2+ || 5
|-
| ROR mem16, imm8 || <tt>C1 /1 ii</tt> || <tt>11000001 oo001rm</tt> || 3+ || 5
|-
| ROR reg8, 1 || <tt>D0 /1</tt> || <tt>11010000 11001rm</tt> || 2 || 1
|-
| ROR reg8, CL || <tt>D2 /1</tt> || <tt>11010010 11001rm</tt> || 2 || 3
|-
| ROR reg8, imm8 || <tt>C0 /1 ii</tt> || <tt>11000000 11001rm</tt> || 3 || 3
|-
| ROR reg16, 1 || <tt>D1 /1</tt> || <tt>11010001 11001rm</tt> || 2 || 1
|-
| ROR reg16, CL || <tt>D3 /1</tt> || <tt>11010011 11001rm</tt> || 2 || 3
|-
| ROR reg16, imm8 || <tt>C1 /1 ii</tt> || <tt>11000001 11001rm</tt> || 3 || 3
|}
----
{{Anchor|SAHF}}
=== SAHF ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| SAHF || <tt>9E</tt> || <tt>10011110</tt> || 1 || 4
|}
----
{{Anchor|SAR}}
=== SAR ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| SAR mem8, 1 || <tt>D0 /7</tt> || <tt>11010000 oo111rm</tt> || 2+ || 3
|-
| SAR mem8, CL || <tt>D2 /7</tt> || <tt>11010010 oo111rm</tt> || 2+ || 5
|-
| SAR mem8, imm8 || <tt>C0 /7 ii</tt> || <tt>11000000 oo111rm</tt> || 3+ || 5
|-
| SAR mem16, 1 || <tt>D1 /7</tt> || <tt>11010001 oo111rm</tt> || 2+ || 3
|-
| SAR mem16, CL || <tt>D3 /7</tt> || <tt>11010011 oo111rm</tt> || 2+ || 5
|-
| SAR mem16, imm8 || <tt>C1 /7 ii</tt> || <tt>11000001 oo111rm</tt> || 3+ || 5
|-
| SAR reg8, 1 || <tt>D0 /7</tt> || <tt>11010000 11111rm</tt> || 2 || 1
|-
| SAR reg8, CL || <tt>D2 /7</tt> || <tt>11010010 11111rm</tt> || 2 || 3
|-
| SAR reg8, imm8 || <tt>C0 /7 ii</tt> || <tt>11000000 11111rm</tt> || 3 || 3
|-
| SAR reg16, 1 || <tt>D1 /7</tt> || <tt>11010001 11111rm</tt> || 2 || 1
|-
| SAR reg16, CL || <tt>D3 /7</tt> || <tt>11010011 11111rm</tt> || 2 || 3
|-
| SAR reg16, imm8 || <tt>C1 /7 ii</tt> || <tt>11000001 11111rm</tt> || 3 || 3
|}
----
{{Anchor|SBB}}
=== SBB ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| SBB AL, imm || <tt>1C ii</tt> || <tt>00011100 iiiiiiii</tt> || 2 || 1
|-
| SBB AX, imm || <tt>1D ii ii</tt> || <tt>00011101 iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| SBB mem8, imm8 || <tt>80 /3 ii</tt> || <tt>10000000 oo011mmm iiiiiiii</tt> || 3+ || 3
|-
| SBB mem16, imm16 || <tt>81 /3 ii ii</tt> || <tt>10000001 oo011mmm iiiiiiii iiiiiiii</tt> || 4+ || 3
|-
| SBB mem16, simm8 || <tt>83 /3 ii</tt> || <tt>10000011 oo011mmm iiiiiiii</tt> || 3+ || 3
|-
| SBB mem8, reg8 || <tt>18 /r</tt> || <tt>00011000 oorrrmmm</tt> || 2+ || 3
|-
| SBB mem16, reg16 || <tt>19 /r</tt> || <tt>00011001 oorrrmmm</tt> || 2+ || 3
|-
| SBB reg8, imm8 || <tt>80 /3 ii</tt> || <tt>10000000 11011mmm iiiiiiii</tt> || 3 || 1
|-
| SBB reg16, imm16 || <tt>81 /3 ii ii</tt> || <tt>10000001 11011mmm iiiiiiii iiiiiiii</tt> || 4 || 1
|-
| SBB reg16, simm8 || <tt>83 /3 ii</tt> || <tt>10000011 11011mmm iiiiiiii</tt> || 3 || 1
|-
| SBB reg8, mem8 || <tt>1A /r</tt> || <tt>00011010 oorrrmmm</tt> || 2+ || 2
|-
| SBB reg16, mem16 || <tt>1B /r</tt> || <tt>00011011 oorrrmmm</tt> || 2+ || 2
|-
| SBB reg8, reg8 || <tt>18 /r</tt> || <tt>000110.0 11rrrmmm</tt> || 2 || 1
|-
| SBB reg16, reg16 || <tt>19 /r</tt> || <tt>000110.1 11rrrmmm</tt> || 2 || 1
|}
----
{{Anchor|SCASB}}
{{Anchor|SCASW}}
=== SCASB/SCASW ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| SCASB || <tt>AE</tt> || <tt>10101110</tt> || 1 || 4
|-
| SCASW || <tt>AF</tt> || <tt>10101111</tt> || 1 || 4
|}
----
{{Anchor|SHL}}
=== SHL ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| SHL mem8, 1 || <tt>D0 /4</tt> || <tt>11010000 oo100rm</tt> || 2+ || 3
|-
| SHL mem8, CL || <tt>D2 /4</tt> || <tt>11010010 oo100rm</tt> || 2+ || 5
|-
| SHL mem8, imm8 || <tt>C0 /4 ii</tt> || <tt>11000000 oo100rm</tt> || 3+ || 5
|-
| SHL mem16, 1 || <tt>D1 /4</tt> || <tt>11010001 oo100rm</tt> || 2+ || 3
|-
| SHL mem16, CL || <tt>D3 /4</tt> || <tt>11010011 oo100rm</tt> || 2+ || 5
|-
| SHL mem16, imm8 || <tt>C1 /4 ii</tt> || <tt>11000001 oo100rm</tt> || 3+ || 5
|-
| SHL reg8, 1 || <tt>D0 /4</tt> || <tt>11010000 11100rm</tt> || 2 || 1
|-
| SHL reg8, CL || <tt>D2 /4</tt> || <tt>11010010 11100rm</tt> || 2 || 3
|-
| SHL reg8, imm8 || <tt>C0 /4 ii</tt> || <tt>11000000 11100rm</tt> || 3 || 3
|-
| SHL reg16, 1 || <tt>D1 /4</tt> || <tt>11010001 11100rm</tt> || 2 || 1
|-
| SHL reg16, CL || <tt>D3 /4</tt> || <tt>11010011 11100rm</tt> || 2 || 3
|-
| SHL reg16, imm8 || <tt>C1 /4 ii</tt> || <tt>11000001 11100rm</tt> || 3 || 3
|}
----
{{Anchor|SHR}}
=== SHR ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| SHR mem8, 1 || <tt>D0 /5</tt> || <tt>11010000 oo101rm</tt> || 2+ || 3
|-
| SHR mem8, CL || <tt>D2 /5</tt> || <tt>11010010 oo101rm</tt> || 2+ || 5
|-
| SHR mem8, imm8 || <tt>C0 /5 ii</tt> || <tt>11000000 oo101rm</tt> || 3+ || 5
|-
| SHR mem16, 1 || <tt>D1 /5</tt> || <tt>11010001 oo101rm</tt> || 2+ || 3
|-
| SHR mem16, CL || <tt>D3 /5</tt> || <tt>11010011 oo101rm</tt> || 2+ || 5
|-
| SHR mem16, imm8 || <tt>C1 /5 ii</tt> || <tt>11000001 oo101rm</tt> || 3+ || 5
|-
| SHR reg8, 1 || <tt>D0 /5</tt> || <tt>11010000 11101rm</tt> || 2 || 1
|-
| SHR reg8, CL || <tt>D2 /5</tt> || <tt>11010010 11101rm</tt> || 2 || 3
|-
| SHR reg8, imm8 || <tt>C0 /5 ii</tt> || <tt>11000000 11101rm</tt> || 3 || 3
|-
| SHR reg16, 1 || <tt>D1 /5</tt> || <tt>11010001 11101rm</tt> || 2 || 1
|-
| SHR reg16, CL || <tt>D3 /5</tt> || <tt>11010011 11101rm</tt> || 2 || 3
|-
| SHR reg16, imm8 || <tt>C1 /5 ii</tt> || <tt>11000001 11101rm</tt> || 3 || 3
|}
----
{{Anchor|SS}}
=== SS ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| SS || <tt>36</tt> || <tt>00110110</tt> || 1 || 1
|}
----
{{Anchor|STC}}
=== STC ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| STC || <tt>F9</tt> || <tt>11111001</tt> || 1 || 4
|}
----
{{Anchor|STD}}
=== STD ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| STD || <tt>FD</tt> || <tt>11111101</tt> || 1 || 4
|}
----
{{Anchor|STI}}
=== STI ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| STI || <tt>FB</tt> || <tt>11111011</tt> || 1 || 4
|}
----
{{Anchor|STOSB}}
{{Anchor|STOSW}}
=== STOSB/STOSW ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| STOSB || <tt>AA</tt> || <tt>10101010</tt> || 1 || 3
|-
| STOSW || <tt>AB</tt> || <tt>10101011</tt> || 1 || 3
|}
----
{{Anchor|SUB}}
=== SUB ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| SUB AL, imm || <tt>28 ii</tt> || <tt>00101100 iiiiiiii</tt> || 2 || 1
|-
| SUB AX, imm || <tt>29 ii ii</tt> || <tt>00101101 iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| SUB mem8, imm8 || <tt>80 /5 ii</tt> || <tt>10000000 oo101mmm iiiiiiii</tt> || 3+ || 3
|-
| SUB mem16, imm16 || <tt>81 /5 ii ii</tt> || <tt>10000001 oo101mmm iiiiiiii iiiiiiii</tt> || 4+ || 3
|-
| SUB mem16, simm8 || <tt>83 /5 ii</tt> || <tt>10000011 oo101mmm iiiiiiii</tt> || 3+ || 3
|-
| SUB mem8, reg8 || <tt>28 /r</tt> || <tt>00101000 oorrrmmm</tt> || 2+ || 3
|-
| SUB mem16, reg16 || <tt>29 /r</tt> || <tt>00101001 oorrrmmm</tt> || 2+ || 3
|-
| SUB reg8, imm8 || <tt>80 /5 ii</tt> || <tt>10000000 11101mmm iiiiiiii</tt> || 3 || 1
|-
| SUB reg16, imm16 || <tt>81 /5 ii ii</tt> || <tt>10000001 11101mmm iiiiiiii iiiiiiii</tt> || 4 || 1
|-
| SUB reg16, simm8 || <tt>83 /5 ii</tt> || <tt>10000011 11101mmm iiiiiiii</tt> || 3 || 1
|-
| SUB reg8, mem8 || <tt>2A /r</tt> || <tt>00101010 oorrrmmm</tt> || 2+ || 2
|-
| SUB reg16, mem16 || <tt>2B /r</tt> || <tt>00101011 oorrrmmm</tt> || 2+ || 2
|-
| SUB reg8, reg8 || <tt>28 /r</tt> || <tt>001010.0 11rrrmmm</tt> || 2 || 1
|-
| SUB reg16, reg16 || <tt>29 /r</tt> || <tt>001010.1 11rrrmmm</tt> || 2 || 1
|}
----
{{Anchor|TEST}}
=== TEST ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| TEST AL, imm || <tt>A8 ii</tt> || <tt>10101000 iiiiiiii</tt> || 2 || 1
|-
| TEST AX, imm || <tt>A9 ii ii</tt> || <tt>10101001 iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| TEST mem8, imm8 || <tt>F6 /0 ii</tt> || <tt>11110110 oo000mmm iiiiiiii</tt> || 3+ || 2
|-
| TEST mem16, imm16 || <tt>F7 /0 ii ii</tt> || <tt>11110111 oo000mmm iiiiiiii iiiiiiii</tt> || 4+ || 2
|-
| TEST mem8, reg8<br/>TEST reg8, mem8 || <tt>84 /r</tt> || <tt>10000100 oorrrmmm</tt> || 2+ || 2
|-
| TEST mem16, reg16<br/>TEST reg16, mem16 || <tt>85 /r</tt> || <tt>10000101 oorrrmmm</tt> || 2+ || 2
|-
| TEST reg8, imm8 || <tt>F6 /0 ii</tt> || <tt>11110110 11000mmm iiiiiiii</tt> || 3 || 1
|-
| TEST reg16, imm16 || <tt>F7 /0 ii ii</tt> || <tt>11110111 11000mmm iiiiiiii iiiiiiii</tt> || 4 || 1
|-
| TEST reg8, reg8 || <tt>84 /r</tt> || <tt>10000100 11rrrmmm</tt> || 2 || 1
|-
| TEST reg16, reg16 || <tt>85 /r</tt> || <tt>10000101 11rrrmmm</tt> || 2 || 1
|}
----
{{Anchor|XCHG}}
=== XCHG ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| XCHG AX, reg16<br/>XCHG reg16, AX || <tt>9x</tt> || <tt>10010rrr</tt> || 1 || 3
|-
| XCHG mem8, reg8<br/>XCHG reg8, mem8 || <tt>86 /r</tt> || <tt>10000110 oorrrmmm</tt> || 2+ || 5
|-
| XCHG mem16, reg16<br/>XCHG reg16, mem16 || <tt>87 /r</tt> || <tt>10000111 oorrrmmm</tt> || 2+ || 5
|-
| XCHG reg8, reg8 || <tt>86 /r</tt> || <tt>10000110 11rrrmmm</tt> || 2+ || 3
|-
| XCHG reg16, reg16 || <tt>87 /r</tt> || <tt>10000111 11rrrmmm</tt> || 2+ || 3
|}
----
{{Anchor|XLAT}}
=== XLAT ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| XLAT || <tt>D7</tt> || <tt>11010111</tt> || 1 || 5
|}
----
{{Anchor|XOR}}
=== XOR ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| XOR AL, imm || <tt>34 ii</tt> || <tt>00110100 iiiiiiii</tt> || 2 || 1
|-
| XOR AX, imm || <tt>35 ii ii</tt> || <tt>00110101 iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| XOR mem8, imm8 || <tt>80 /6 ii</tt> || <tt>10000000 oo110mmm iiiiiiii</tt> || 3+ || 3
|-
| XOR mem16, imm16 || <tt>81 /6 ii ii</tt> || <tt>10000001 oo110mmm iiiiiiii iiiiiiii</tt> || 4+ || 3
|-
| XOR mem16, simm8 || <tt>83 /6 ii</tt> || <tt>10000011 oo110mmm iiiiiiii</tt> || 3+ || 3
|-
| XOR mem8, reg8 || <tt>30 /r</tt> || <tt>00110000 oorrrmmm</tt> || 2+ || 3
|-
| XOR mem16, reg16 || <tt>31 /r</tt> || <tt>00110001 oorrrmmm</tt> || 2+ || 3
|-
| XOR reg8, imm8 || <tt>80 /6 ii</tt> || <tt>10000000 11110mmm iiiiiiii</tt> || 3 || 1
|-
| XOR reg16, imm16 || <tt>81 /6 ii ii</tt> || <tt>10000001 11110mmm iiiiiiii iiiiiiii</tt> || 4 || 1
|-
| XOR reg16, simm8 || <tt>83 /6 ii</tt> || <tt>10000011 11110mmm iiiiiiii</tt> || 3 || 1
|-
| XOR reg8, mem8 || <tt>32 /r</tt> || <tt>00110010 oorrrmmm</tt> || 2+ || 2
|-
| XOR reg16, mem16 || <tt>33 /r</tt> || <tt>00110011 oorrrmmm</tt> || 2+ || 2
|-
| XOR reg8, reg8 || <tt>30 /r</tt> || <tt>001100.0 11rrrmmm</tt> || 2 || 1
|-
| XOR reg16, reg16 || <tt>31 /r</tt> || <tt>001100.1 11rrrmmm</tt> || 2 || 1
|}
== Notes ==
<references />
4b6cddd836171a84484a3ab447af1334f252b21e
463
462
2024-12-27T23:37:02Z
Asie
351
wikitext
text/x-wiki
__NOTOC__
Note that this page is a work in progress.
{| class="wikitable" style="text-align: center"
|+ Official V30MZ (80186) Instructions
|-
| [[#AAA|AAA]] || [[#AAD|AAD]] || [[#AAM|AAM]] || [[#AAS|AAS]] || [[#ADC|ADC]] || [[#ADD|ADD]] || [[#AND|AND]] || [[#BOUND|BOUND]] || [[#CALL|CALL]] || [[#CBW|CBW]] || [[#CLC|CLC]]
|-
| [[#CLD|CLD]] || [[#CLI|CLI]] || [[#CMC|CMC]] || [[#CMP|CMP]] || [[#CMPSB|CMPSB]] || [[#CMPSW|CMPSW]] || [[#CS|CS]] || [[#CWD|CWD]] || [[#DAA|DAA]] || [[#DAS|DAS]] || [[#DEC|DEC]]
|-
| [[#DIV|DIV]] || [[#DS|DS]] || [[#ENTER|ENTER]] || [[#ES|ES]] || [[#HLT|HLT]] || [[#IDIV|IDIV]] || [[#IMUL|IMUL]] || [[#IN|IN]] || [[#INC|INC]] || [[#INSB|INSB]] || [[#INSW|INSW]]
|-
| [[#INT|INT]] || [[#INTO|INTO]] || [[#IRET|IRET]] || [[#JA|JA]] || [[#JBE|JBE]] || [[#JC|JC]] || [[#JCXZ|JCXZ]] || [[#JG|JG]] || [[#JGE|JGE]] || [[#JL|JL]] || [[#JLE|JLE]]
|-
| [[#JMP|JMP]] || [[#JNC|JNC]] || [[#JNO|JNO]] || [[#JNP|JNP]] || [[#JNS|JNS]] || [[#JNZ|JNZ]] || [[#JO|JO]] || [[#JP|JP]] || [[#JS|JS]] || [[#JZ|JZ]] || [[#LAHF|LAHF]]
|-
| [[#LDS|LDS]] || [[#LEA|LEA]] || [[#LEAVE|LEAVE]] || [[#LES|LES]] || [[#LOCK|LOCK]] || [[#LODSB|LODSB]] || [[#LODSW|LODSW]] || [[#LOOP|LOOP]] || [[#LOOPE|LOOPE]] || [[#LOOPNE|LOOPNE]] || [[#MOV|MOV]]
|-
| [[#MOVSB|MOVSB]] || [[#MOVSW|MOVSW]] || [[#MUL|MUL]] || [[#NEG|NEG]] || [[#NOP|NOP]] || [[#NOT|NOT]] || [[#OR|OR]] || [[#OUT|OUT]] || [[#OUTSB|OUTSB]] || [[#OUTSW|OUTSW]] || [[#POLL|POLL]]
|-
| [[#POP|POP]] || [[#POPA|POPA]] || [[#POPF|POPF]] || [[#PUSH|PUSH]] || [[#PUSHA|PUSHA]] || [[#PUSHF|PUSHF]] || [[#RCL|RCL]] || [[#RCR|RCR]] || [[#REP|REP]] || [[#REPNE|REPNE]] || [[#RET|RET]]
|-
| [[#RETF|RETF]] || [[#ROL|ROL]] || [[#ROR|ROR]] || [[#SAHF|SAHF]] || [[#SAR|SAR]] || [[#SBB|SBB]] || [[#SCASB|SCASB]] || [[#SCASW|SCASW]] || [[#SHL|SHL]] || [[#SHR|SHR]] || [[#SS|SS]]
|-
| [[#STC|STC]] || [[#STD|STD]] || [[#STI|STI]] || [[#STOSB|STOSB]] || [[#STOSW|STOSW]] || [[#SUB|SUB]] || [[#TEST|TEST]] || [[#XCHG|XCHG]] || [[#XLAT|XLAT]] || [[#XOR|XOR]]
|}
{| class="mw-collapsible mw-collapsed wikitable sortable" style="width: 340px;"
|+ style="white-space:nowrap; border:1px solid; padding:3px; border-color:rgb(162, 169, 177); background-color:rgb(234, 236, 240);" | Intel <-> NEC mnemonic translation table
!Intel
!NEC
|-
| [[#AAA|AAA]]
| [[#AAA|ADJBA]]
|-
| [[#AAD|AAD]]
| [[#AAD|CVTDB]]
|-
| [[#AAM|AAM]]
| [[#AAM|CVTBD]]
|-
| [[#AAS|AAS]]
| [[#AAS|ADJBS]]
|-
| [[#ADC|ADC]]
| [[#ADC|ADDC]]
|-
| [[#ADD|ADD]]
| [[#ADD|ADD]]
|-
| [[#AND|AND]]
| [[#AND|AND]]
|-
| [[#BOUND|BOUND]]
| [[#BOUND|CHKIND]]
|-
| [[#CALL|CALL]]
| [[#CALL|CALL]]
|-
| [[#CBW|CBW]]
| [[#CBW|CVTBW]]
|-
| [[#CLC|CLC]]
| [[#CLC|CLR1 CY]]
|-
| [[#CLD|CLD]]
| [[#CLD|CLR1 DIR]]
|-
| [[#CLI|CLI]]
| [[#CLI|DI]]
|-
| [[#CMC|CMC]]
| [[#CMC|NOT1 CY]]
|-
| [[#CMP|CMP]]
| [[#CMP|CMP]]
|-
| [[#CMPSB|CMPSB]]
| [[#CMPSB|CMPBKB]]
|-
| [[#CMPSW|CMPSW]]
| [[#CMPSW|CMPBKW]]
|-
| [[#CS|CS]]
| [[#CS|PS]]
|-
| [[#CWD|CWD]]
| [[#CWD|CVTWL]]
|-
| [[#DAA|DAA]]
| [[#DAA|ADJ4A]]
|-
| [[#DAS|DAS]]
| [[#DAS|ADJ4S]]
|-
| [[#DEC|DEC]]
| [[#DEC|DEC]]
|-
| [[#DIV|DIV]]
| [[#DIV|DIVU]]
|-
| [[#DS|DS]]
| [[#DS|DS0]]
|-
| [[#ENTER|ENTER]]
| [[#ENTER|PREPARE]]
|-
| [[#ES|ES]]
| [[#ES|DS1]]
|-
| [[#HLT|HLT]]
| [[#HLT|HALT]]
|-
| [[#IDIV|IDIV]]
| [[#IDIV|DIV]]
|-
| [[#IMUL|IMUL]]
| [[#IMUL|MUL]]
|-
| [[#IN|IN]]
| [[#IN|IN]]
|-
| [[#INC|INC]]
| [[#INC|INC]]
|-
| [[#INSB|INSB]]
| [[#INSB|INMB]]
|-
| [[#INSW|INSW]]
| [[#INSW|INMW]]
|-
| [[#INT|INT]]
| [[#INT|BRK]]
|-
| [[#INTO|INTO]]
| [[#INTO|BRKV]]
|-
| [[#IRET|IRET]]
| [[#IRET|RETI]]
|-
| [[#JA|JA]]
| [[#JA|BH]]
|-
| [[#JBE|JBE]]
| [[#JBE|BNH]]
|-
| [[#JC|JC/JB]]
| [[#JC|BC/BL]]
|-
| [[#JCXZ|JCXZ]]
| [[#JCXZ|BCWZ]]
|-
| [[#JG|JG]]
| [[#JG|BGT]]
|-
| [[#JGE|JGE]]
| [[#JGE|BGE]]
|-
| [[#JL|JL]]
| [[#JL|BLT]]
|-
| [[#JLE|JLE]]
| [[#JLE|BLE]]
|-
| [[#JMP|JMP]]
| [[#JMP|BR]]
|-
| [[#JNC|JNC/JAE]]
| [[#JNC|BNC/BNL]]
|-
| [[#JNO|JNO]]
| [[#JNO|BNV]]
|-
| [[#JNP|JNP]]
| [[#JNP|BPO]]
|-
| [[#JNS|JNS]]
| [[#JNS|BP]]
|-
| [[#JNZ|JNZ/JNE]]
| [[#JNZ|BNZ/BNE]]
|-
| [[#JO|JO]]
| [[#JO|BV]]
|-
| [[#JP|JP]]
| [[#JP|BPE]]
|-
| [[#JS|JS]]
| [[#JS|BN]]
|-
| [[#JZ|JZ/JE]]
| [[#JZ|BZ/BE]]
|-
| [[#LAHF|LAHF]]
| [[#LAHF|MOV]]
|-
| [[#LDS|LDS]]
| [[#LDS|MOV]]
|-
| [[#LEA|LEA]]
| [[#LEA|LDEA]]
|-
| [[#LEAVE|LEAVE]]
| [[#LEAVE|DISPOSE]]
|-
| [[#LES|LES]]
| [[#LES|MOV]]
|-
| [[#LOCK|LOCK]]
| [[#LOCK|BUSLOCK]]
|-
| [[#LODSB|LODSB]]
| [[#LODSB|LDMB]]
|-
| [[#LODSW|LODSW]]
| [[#LODSW|LDMW]]
|-
| [[#LOOP|LOOP]]
| [[#LOOP|DBNZ]]
|-
| [[#LOOPE|LOOPE]]
| [[#LOOPE|DBNZE]]
|-
| [[#LOOPNE|LOOPNE]]
| [[#LOOPNE|DBNZNE]]
|-
| [[#MOV|MOV]]
| [[#MOV|MOV]]
|-
| [[#MOVSB|MOVSB]]
| [[#MOVSB|MOVBKB]]
|-
| [[#MOVSW|MOVSW]]
| [[#MOVSW|MOVBKW]]
|-
| [[#MUL|MUL]]
| [[#MUL|MULU]]
|-
| [[#NEG|NEG]]
| [[#NEG|NEG]]
|-
| [[#NOP|NOP]]
| [[#NOP|NOP]]
|-
| [[#NOT|NOT]]
| [[#NOT|NOT]]
|-
| [[#OR|OR]]
| [[#OR|OR]]
|-
| [[#OUT|OUT]]
| [[#OUT|OUT]]
|-
| [[#OUTSB|OUTSB]]
| [[#OUTSB|OUTM]]
|-
| [[#OUTSW|OUTSW]]
| [[#OUTSW|OUTM]]
|-
| [[#POLL|POLL]]
| [[#POLL|POLL]]
|-
| [[#POP|POP]]
| [[#POP|POP]]
|-
| [[#POPA|POPA]]
| [[#POPA|POP]]
|-
| [[#POPF|POPF]]
| [[#POPF|POP]]
|-
| [[#PUSH|PUSH]]
| [[#PUSH|PUSH]]
|-
| [[#PUSHA|PUSHA]]
| [[#PUSHA|PUSH]]
|-
| [[#PUSHF|PUSHF]]
| [[#PUSHF|PUSH]]
|-
| [[#RCL|RCL]]
| [[#RCL|ROLC]]
|-
| [[#RCR|RCR]]
| [[#RCR|RORC]]
|-
| [[#REP|REP/REPE/REPZ]]
| [[#REP|REP/REPE/REPZ]]
|-
| [[#REPNE|REPNE/REPNZ]]
| [[#REPNE|REPNE/REPNZ]]
|-
| [[#RET|RET]]
| [[#RET|RET]]
|-
| [[#RETF|RETF]]
| [[#RETF|RET]]
|-
| [[#ROL|ROL]]
| [[#ROL|ROL]]
|-
| [[#ROR|ROR]]
| [[#ROR|ROR]]
|-
| [[#SAHF|SAHF]]
| [[#SAHF|MOV]]
|-
| [[#SAR|SAR]]
| [[#SAR|SHRA]]
|-
| [[#SBB|SBB]]
| [[#SBB|SUBC]]
|-
| [[#SCASB|SCASB]]
| [[#SCASB|CMPMB]]
|-
| [[#SCASW|SCASW]]
| [[#SCASW|CMPMW]]
|-
| [[#SHL|SHL]]
| [[#SHL|SHL]]
|-
| [[#SHR|SHR]]
| [[#SHR|SHR]]
|-
| [[#SS|SS]]
| [[#SS|SS]]
|-
| [[#STC|STC]]
| [[#STC|SET1 CY]]
|-
| [[#STD|STD]]
| [[#STD|SET1 DIR]]
|-
| [[#STI|STI]]
| [[#STI|EI]]
|-
| [[#STOSB|STOSB]]
| [[#STOSB|STMB]]
|-
| [[#STOSW|STOSW]]
| [[#STOSW|STMW]]
|-
| [[#SUB|SUB]]
| [[#SUB|SUB]]
|-
| [[#TEST|TEST]]
| [[#TEST|TEST]]
|-
| [[#XCHG|XCHG]]
| [[#XCHG|XCH]]
|-
| [[#XLAT|XLAT]]
| [[#XLAT|TRANS]]
|-
| [[#XOR|XOR]]
| [[#XOR|XOR]]
|}
== Official instructions by type ==
{| class="wikitable sortable" style="text-align: center"
!Type
!colspan=16 class="unsortable" | Instructions
|-
| style="text-align:left;" | Memory
| style="" | [[#MOV|MOV]]
| style="" | [[#XCHG|XCHG]]
| style="" | [[#XLAT|XLAT]]
| style="" | [[#LEA|LEA]]
| style="border-right:none;" | [[#LDS|LDS]]
| style="border-left:none;" | [[#LES|LES]]
| style="border-right:none;" | [[#IN|IN]]
| style="border-left:none;" | [[#OUT|OUT]]
| colspan="8" |
|-
| style="text-align:left;" | Ports
| style="border-right:none;" | [[#IN|IN]]
| style="border-left:none;" | [[#OUT|OUT]]
| style="border-right:none;" | [[#INSB|INSB]]
| style="border-left:none;" | [[#OUTSB|OUTSB]]
| style="border-right:none;" | [[#INSW|INSW]]
| style="border-left:none;" | [[#OUTSW|OUTSW]]
| colspan="10" |
|-
| style="text-align:left;" | Arithmetic
| style="border-right:none;" | [[#ADD|ADD]]
| style="border-left:none;" | [[#SUB|SUB]]
| style="border-right:none;" | [[#ADC|ADC]]
| style="border-left:none;" | [[#SBB|SBB]]
| style="border-right:none;" | [[#INC|INC]]
| style="border-left:none;" | [[#DEC|DEC]]
| style="border-right:none;" | [[#MUL|MUL]]
| style="border-left:none;" | [[#DIV|DIV]]
| style="border-right:none;" | [[#IMUL|IMUL]]
| style="border-left:none;" | [[#IDIV|IDIV]]
| style="" | [[#CMP|CMP]]
| style="" | [[#NEG|NEG]]
| colspan="4" |
|-
| style="text-align:left;" | Numeric
| style="" | [[#CBW|CBW]]
| style="" | [[#CWD|CWD]]
| style="" | [[#AAA|AAA]]
| style="" | [[#AAS|AAS]]
| style="" | [[#AAM|AAM]]
| style="" | [[#AAD|AAD]]
| style="" | [[#DAA|DAA]]
| style="" | [[#DAS|DAS]]
| colspan="8" |
|-
| style="text-align:left;" | Shift
| style="border-right:none;" | [[#ROL|ROL]]
| style="border-left:none;" | [[#ROR|ROR]]
| style="border-right:none;" | [[#RCL|RCL]]
| style="border-left:none;" | [[#RCR|RCR]]
| style="border-right:none;" | [[#SHL|SHL]]
| style="border-left:none;" | [[#SHR|SHR]]
| style="" | [[#SAR|SAR]]
| colspan="9" |
|-
| style="text-align:left;" | Bitwise
| style="" | [[#AND|AND]]
| style="" | [[#OR|OR]]
| style="" | [[#XOR|XOR]]
| style="" | [[#NOT|NOT]]
| style="" | [[#TEST|TEST]]
| colspan="11" |
|-
| style="text-align:left;" | Branch
| style="border-right:none;" | [[#JC|JC]]
| style="border-left:none;" | [[#JNC|JNC]]
| style="border-right:none;" | [[#JZ|JZ]]
| style="border-left:none;" | [[#JNZ|JNZ]]
| style="border-right:none;" | [[#JBE|JBE]]
| style="border-left:none;" | [[#JA|JA]]
| style="border-right:none;" | [[#JO|JO]]
| style="border-left:none;" | [[#JNO|JNO]]
| style="border-right:none;" | [[#JP|JP]]
| style="border-left:none;" | [[#JNP|JNP]]
| style="border-right:none;" | [[#JS|JS]]
| style="border-left:none;" | [[#JNS|JNS]]
| style="border-right:none;" | [[#JL|JL]]
| style="border-left:none;" | [[#JGE|JGE]]
| style="border-right:none;" | [[#JLE|JLE]]
| style="border-left:none;" | [[#JG|JG]]
|-
| style="text-align:left;" | Jump
| style="" | [[#JMP|JMP]]
| style="border-right:none;" | [[#CALL|CALL]]
| style="border-left:none;border-right:none;" | [[#RET|RET]]
| style="border-left:none;" | [[#RETF|RETF]]
| colspan="12" |
|-
| style="text-align:left;" | Loop
| style="" | [[#LOOP|LOOP]]
| style="" | [[#LOOPE|LOOPE]]
| style="" | [[#LOOPNE|LOOPNE]]
| colspan="13" |
|-
| style="text-align:left;" | Interrupt
| style="border-right:none;" | [[#INT|INT]]
| style="border-left:none;" | [[#IRET|IRET]]
| style="" | [[#INTO|INTO]]
| style="" | [[#HLT|HLT]]
| style="" | [[#BOUND|BOUND]]
| colspan="11" |
|-
| style="text-align:left;" | Stack
| style="border-right:none;" | [[#PUSH|PUSH]]
| style="border-left:none;" | [[#POP|POP]]
| style="border-right:none;" | [[#PUSHA|PUSHA]]
| style="border-left:none;" | [[#POPA|POPA]]
| style="border-right:none;" | [[#PUSHF|PUSHF]]
| style="border-left:none;" | [[#POPF|POPF]]
| colspan="10" |
|-
| style="text-align:left;" | Flags
| style="border-right:none;" | [[#CLC|CLC]]
| style="border-left:none;" | [[#STC|STC]]
| style="border-right:none;" | [[#CLD|CLD]]
| style="border-left:none;" | [[#STD|STD]]
| style="border-right:none;" | [[#CLI|CLI]]
| style="border-left:none;" | [[#STI|STI]]
| style="" | [[#CMC|CMC]]
| style="border-right:none;" | [[#LAHF|LAHF]]
| style="border-left:none;" | [[#SAHF|SAHF]]
| colspan="7" |
|-
| style="text-align:left;" | Prefix
| style="" | [[#CS|CS]]
| style="" | [[#DS|DS]]
| style="" | [[#ES|ES]]
| style="" | [[#SS|SS]]
| colspan="12" |
|-
| style="text-align:left;" | String
| style="border-right:none;" | [[#REP|REP]]
| style="border-left:none;border-right:none;" | [[#REP|REPE]]
| style="border-left:none;" | [[#REPNE|REPNE]]
| style="" | [[#MOVSB|MOVSB]]
| style="" | [[#MOVSW|MOVSW]]
| style="border-right:none;" | [[#LODSB|LODSB]]
| style="border-left:none;" | [[#STOSB|STOSB]]
| style="border-right:none;" | [[#LODSW|LODSW]]
| style="border-left:none;" | [[#STOSW|STOSW]]
| style="" | [[#CMPSB|CMPSB]]
| style="" | [[#SCASB|SCASB]]
| style="" | [[#CMPSW|CMPSW]]
| style="" | [[#SCASW|SCASW]]
| colspan="3" |
|-
| style="text-align:left;" | Other
| style="" | [[#NOP|NOP]]
| style="border-right:none;" | [[#ENTER|ENTER]]
| style="border-left:none;" | [[#LEAVE|LEAVE]]
| style="" | [[#LOCK|LOCK]]
| style="" | [[#POLL|POLL]]
| colspan="11" |
|}
== Instruction encoding ==
=== ModR/M byte ===
The ModR/M byte is used in most addressing modes which reference a memory location. This byte consists of three bitfield values:
* <tt>oo</tt> - M'''o'''de;
* <tt>rrr</tt> - Two possible functions:
** '''R'''egister (for addressing modes which require both a register and a register/memory operand),
** Opcode extension (for some opcodes' addressing modes which do not have such a requirement);
* <tt>mmm</tt> - Register/'''M'''emory.
The ''Mode'' and ''Register/Memory'' bitfields can refer to a memory location or to a register, as shown in the table below. In some addressing modes, the ''Register'' field also refers to a register; it is always interpreted as if ''Mode'' was equal to <tt>11</tt>.
{| class="wikitable" style="text-align: center"
! R/M \ Mode
! <tt>00</tt>
! <tt>01</tt>
! <tt>10</tt>
! <tt>11</tt> ''(byte)''
! <tt>11</tt> ''(word)''
|-
| <tt>000</tt>
| DS:[BX + SI]
| DS:[BX + SI + disp8]
| DS:[BX + SI + disp16]
| AL
| AX
|-
| <tt>001</tt>
| DS:[BX + DI]
| DS:[BX + DI + disp8]
| DS:[BX + DI + disp16]
| CL
| CX
|-
| <tt>010</tt>
| SS:[BP + SI]
| SS:[BP + SI + disp8]
| SS:[BP + SI + disp16]
| DL
| DX
|-
| <tt>011</tt>
| SS:[BP + DI]
| SS:[BP + DI + disp8]
| SS:[BP + DI + disp16]
| BL
| BX
|-
| <tt>100</tt>
| DS:[SI]
| DS:[SI + disp8]
| DS:[SI + disp16]
| AH
| SP
|-
| <tt>101</tt>
| DS:[DI]
| DS:[DI + disp8]
| DS:[DI + disp16]
| CH
| BP
|-
| <tt>110</tt>
| ''DS:[disp16]''
| SS:[BP + disp8]
| SS:[BP + disp16]
| DH
| SI
|-
| <tt>111</tt>
| DS:[BX]
| DS:[BX + disp8]
| DS:[BX + disp16]
| BH
| DI
|}
Displacements are either 8-bit (disp8) or 16-bit (disp16) signed values and they always immediately follow the ModR/M byte. Note that (<tt>oo</tt> = <tt>00</tt>, <tt>mmm</tt> = <tt>110</tt>) is a special case, in which the ''disp16'' value is used directly as a near pointer.
The instruction encoding lists below refer to this byte as <tt>oorrrmmm</tt> (binary), <tt>/r</tt> (hexadecimal) or <tt>/0</tt> (hexademical, <tt>rrr</tt> used as function <tt>0</tt>).
== Official instructions ==
{{Anchor|AAA}}
=== AAA ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| AAA || <tt>37</tt> || <tt>00110111</tt> || 1 || 9
|}
----
{{Anchor|AAD}}
=== AAD ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| AAD imm8 || <tt>B5 ii</tt> || <tt>11010100 iiiiiiii</tt> || 2 || 6
|}
----
{{Anchor|AAM}}
=== AAM ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| AAM imm8 || <tt>B4 ii</tt> || <tt>11010100 iiiiiiii</tt> || 2 || 17
|}
----
{{Anchor|AAS}}
=== AAS ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| AAS || <tt>3F</tt> || <tt>00111111</tt> || 1 || 9
|}
----
{{Anchor|ADC}}
=== ADC ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| ADC AL, imm || <tt>14 ii</tt> || <tt>00010100 iiiiiiii</tt> || 2 || 1
|-
| ADC AX, imm || <tt>15 ii ii</tt> || <tt>00010101 iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| ADC mem8, imm8 || <tt>80 /2 ii</tt> || <tt>10000000 oo010mmm iiiiiiii</tt> || 3+ || 3
|-
| ADC mem16, imm16 || <tt>81 /2 ii ii</tt> || <tt>10000001 oo010mmm iiiiiiii iiiiiiii</tt> || 4+ || 3
|-
| ADC mem16, simm8 || <tt>83 /2 ii</tt> || <tt>10000011 oo010mmm iiiiiiii</tt> || 3+ || 3
|-
| ADC mem8, reg8 || <tt>10 /r</tt> || <tt>00010000 oorrrmmm</tt> || 2+ || 3
|-
| ADC mem16, reg16 || <tt>11 /r</tt> || <tt>00010001 oorrrmmm</tt> || 2+ || 3
|-
| ADC reg8, imm8 || <tt>80 /2 ii</tt> || <tt>10000000 11010mmm iiiiiiii</tt> || 3 || 1
|-
| ADC reg16, imm16 || <tt>81 /2 ii ii</tt> || <tt>10000001 11010mmm iiiiiiii iiiiiiii</tt> || 4 || 1
|-
| ADC reg16, simm8 || <tt>83 /2 ii</tt> || <tt>10000011 11010mmm iiiiiiii</tt> || 3 || 1
|-
| ADC reg8, mem8 || <tt>12 /r</tt> || <tt>00010010 oorrrmmm</tt> || 2+ || 2
|-
| ADC reg16, mem16 || <tt>13 /r</tt> || <tt>00010011 oorrrmmm</tt> || 2+ || 2
|-
| ADC reg8, reg8 || <tt>10 /r</tt> || <tt>000100.0 11rrrmmm</tt> || 2 || 1
|-
| ADC reg16, reg16 || <tt>11 /r</tt> || <tt>000100.1 11rrrmmm</tt> || 2 || 1
|}
----
{{Anchor|ADD}}
=== ADD ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| ADD AL, imm || <tt>04 ii</tt> || <tt>00000100 iiiiiiii</tt> || 2 || 1
|-
| ADD AX, imm || <tt>05 ii ii</tt> || <tt>00000101 iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| ADD mem8, imm8 || <tt>80 /0 ii</tt> || <tt>10000000 oo000mmm iiiiiiii</tt> || 3+ || 3
|-
| ADD mem16, imm16 || <tt>81 /0 ii ii</tt> || <tt>10000001 oo000mmm iiiiiiii iiiiiiii</tt> || 4+ || 3
|-
| ADD mem16, simm8 || <tt>83 /0 ii</tt> || <tt>10000011 oo000mmm iiiiiiii</tt> || 3+ || 3
|-
| ADD mem8, reg8 || <tt>00 /r</tt> || <tt>00000000 oorrrmmm</tt> || 2+ || 3
|-
| ADD mem16, reg16 || <tt>01 /r</tt> || <tt>00000001 oorrrmmm</tt> || 2+ || 3
|-
| ADD reg8, imm8 || <tt>80 /0 ii</tt> || <tt>10000000 11000mmm iiiiiiii</tt> || 3 || 1
|-
| ADD reg16, imm16 || <tt>81 /0 ii ii</tt> || <tt>10000001 11000mmm iiiiiiii iiiiiiii</tt> || 4 || 1
|-
| ADD reg16, simm8 || <tt>83 /0 ii</tt> || <tt>10000011 11000mmm iiiiiiii</tt> || 3 || 1
|-
| ADD reg8, mem8 || <tt>02 /r</tt> || <tt>00000010 oorrrmmm</tt> || 2+ || 2
|-
| ADD reg16, mem16 || <tt>03 /r</tt> || <tt>00000011 oorrrmmm</tt> || 2+ || 2
|-
| ADD reg8, reg8 || <tt>00 /r</tt> || <tt>000000.0 11rrrmmm</tt> || 2 || 1
|-
| ADD reg16, reg16 || <tt>01 /r</tt> || <tt>000000.1 11rrrmmm</tt> || 2 || 1
|}
----
{{Anchor|AND}}
=== AND ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| AND AL, imm || <tt>24 ii</tt> || <tt>00100100 iiiiiiii</tt> || 2 || 1
|-
| AND AX, imm || <tt>25 ii ii</tt> || <tt>00100101 iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| AND mem8, imm8 || <tt>80 /4 ii</tt> || <tt>10000000 oo100mmm iiiiiiii</tt> || 3+ || 3
|-
| AND mem16, imm16 || <tt>81 /4 ii ii</tt> || <tt>10000001 oo100mmm iiiiiiii iiiiiiii</tt> || 4+ || 3
|-
| AND mem16, simm8 || <tt>83 /4 ii</tt> || <tt>10000011 oo100mmm iiiiiiii</tt> || 3+ || 3
|-
| AND mem8, reg8 || <tt>20 /r</tt> || <tt>00100000 oorrrmmm</tt> || 2+ || 3
|-
| AND mem16, reg16 || <tt>21 /r</tt> || <tt>00100001 oorrrmmm</tt> || 2+ || 3
|-
| AND reg8, imm8 || <tt>80 /4 ii</tt> || <tt>10000000 11100mmm iiiiiiii</tt> || 3 || 1
|-
| AND reg16, imm16 || <tt>81 /4 ii ii</tt> || <tt>10000001 11100mmm iiiiiiii iiiiiiii</tt> || 4 || 1
|-
| AND reg16, simm8 || <tt>83 /4 ii</tt> || <tt>10000011 11100mmm iiiiiiii</tt> || 3 || 1
|-
| AND reg8, mem8 || <tt>22 /r</tt> || <tt>00100010 oorrrmmm</tt> || 2+ || 2
|-
| AND reg16, mem16 || <tt>23 /r</tt> || <tt>00100011 oorrrmmm</tt> || 2+ || 2
|-
| AND reg8, reg8 || <tt>20 /r</tt> || <tt>001000.0 11rrrmmm</tt> || 2 || 1
|-
| AND reg16, reg16 || <tt>21 /r</tt> || <tt>001000.1 11rrrmmm</tt> || 2 || 1
|}
----
{{Anchor|BOUND}}
=== BOUND ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| BOUND reg16, mem16:16 || <tt>62 /r</tt> || <tt>01100010 oorrrmmm</tt> || 2+ || 13 (20 if condition met)
|}
----
{{Anchor|CALL}}
=== CALL ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| CALL ptr16:16 || <tt>CA oo oo ss ss</tt> || <tt>10011010 oooooooo oooooooo ssssssss ssssssss</tt> || 5 || 10
|-
| CALL mem16 || <tt>FF /2</tt> || <tt>11111111 oo010mmm</tt> || 2+ || 6
|-
| CALL mem16:16 || <tt>FF /3</tt> || <tt>11111111 oo011mmm</tt> || 2+ || 12
|-
| CALL reg16 || <tt>FF /2</tt> || <tt>11111111 11010mmm</tt> || 2 || 5
|-
| CALL rel16 || <tt>E8 ii ii</tt> || <tt>11101000 iiiiiiii iiiiiiii</tt> || 3 || 5
|}
----
{{Anchor|CBW}}
=== CBW ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| CBW || <tt>98</tt> || <tt>10011000</tt> || 1 || 1
|}
----
{{Anchor|CLC}}
=== CLC ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| CLC || <tt>F8</tt> || <tt>11111000</tt> || 1 || 4
|}
----
{{Anchor|CLD}}
=== CLD ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| CLD || <tt>FC</tt> || <tt>11111100</tt> || 1 || 4
|}
----
{{Anchor|CLI}}
=== CLI ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| CLI || <tt>FA</tt> || <tt>11111010</tt> || 1 || 4
|}
----
{{Anchor|CMC}}
=== CMC ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| CMC || <tt>F5</tt> || <tt>11110101</tt> || 1 || 4
|}
----
{{Anchor|CMP}}
=== CMP ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| CMP AL, imm || <tt>3C ii</tt> || <tt>00111100 iiiiiiii</tt> || 2 || 1
|-
| CMP AX, imm || <tt>3D ii ii</tt> || <tt>00111101 iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| CMP mem8, imm8 || <tt>80 /7 ii</tt> || <tt>10000000 oo111mmm iiiiiiii</tt> || 3+ || 2
|-
| CMP mem16, imm16 || <tt>81 /7 ii ii</tt> || <tt>10000001 oo111mmm iiiiiiii iiiiiiii</tt> || 4+ || 2
|-
| CMP mem16, simm8 || <tt>83 /7 ii</tt> || <tt>10000011 oo111mmm iiiiiiii</tt> || 3+ || 2
|-
| CMP mem8, reg8 || <tt>38 /r</tt> || <tt>00111000 oorrrmmm</tt> || 2+ || 2
|-
| CMP mem16, reg16 || <tt>39 /r</tt> || <tt>00111001 oorrrmmm</tt> || 2+ || 2
|-
| CMP reg8, imm8 || <tt>80 /7 ii</tt> || <tt>10000000 11111mmm iiiiiiii</tt> || 3 || 1
|-
| CMP reg16, imm16 || <tt>81 /7 ii ii</tt> || <tt>10000001 11111mmm iiiiiiii iiiiiiii</tt> || 4 || 1
|-
| CMP reg16, simm8 || <tt>83 /7 ii</tt> || <tt>10000011 11111mmm iiiiiiii</tt> || 3 || 1
|-
| CMP reg8, mem8 || <tt>3A /r</tt> || <tt>00111010 oorrrmmm</tt> || 2+ || 2
|-
| CMP reg16, mem16 || <tt>3B /r</tt> || <tt>00111011 oorrrmmm</tt> || 2+ || 2
|-
| CMP reg8, reg8 || <tt>38 /r</tt> || <tt>001110.0 11rrrmmm</tt> || 2 || 1
|-
| CMP reg16, reg16 || <tt>39 /r</tt> || <tt>001110.1 11rrrmmm</tt> || 2 || 1
|}
----
{{Anchor|CMPSB}}
{{Anchor|CMPSW}}
=== CMPSB/CMPSW ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| CMPSB || <tt>A6</tt> || <tt>10100110</tt> || 1 || 6
|-
| CMPSW || <tt>A7</tt> || <tt>10100111</tt> || 1 || 6
|}
----
{{Anchor|CS}}
=== CS ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| CS || <tt>2E</tt> || <tt>00101110</tt> || 1 || 1
|}
----
{{Anchor|CWD}}
=== CWD ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| CWD || <tt>99</tt> || <tt>10011001</tt> || 1 || 1
|}
----
{{Anchor|DAA}}
=== DAA ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| DAA || <tt>27</tt> || <tt>00100111</tt> || 1 || 10
|}
----
{{Anchor|DAS}}
=== DAS ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| DAS || <tt>2F</tt> || <tt>00101111</tt> || 1 || 10
|}
----
{{Anchor|DEC}}
=== DEC ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| DEC mem8 || <tt>FE /1</tt> || <tt>11111110 oo001mmm</tt> || 2+ || 3
|-
| DEC mem16 || <tt>FF /1</tt> || <tt>11111111 oo001mmm</tt> || 2+ || 3
|-
| DEC reg8 || <tt>FE /1</tt> || <tt>11111110 11001mmm</tt> || 2+ || 1
|-
| DEC reg16 || <tt>4x</tt> || <tt>01001rrr</tt> || 1 || 1
|}
----
{{Anchor|DIV}}
=== DIV ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| DIV mem8 || <tt>F6 /6</tt> || <tt>11110110 oo110mmm</tt> || 2+ || 16
|-
| DIV mem16 || <tt>F7 /6</tt> || <tt>11111111 oo110mmm</tt> || 2+ || 24
|-
| DIV reg8 || <tt>F6 /6</tt> || <tt>11111110 11110mmm</tt> || 2 || 15
|-
| DIV reg16 || <tt>F7 /6</tt> || <tt>11111111 11110mmm</tt> || 2 || 23
|}
----
{{Anchor|DS}}
=== DS ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| DS || <tt>3E</tt> || <tt>00111110</tt> || 1 || 1
|}
----
{{Anchor|ENTER}}
=== ENTER ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| ENTER imm16, imm8 || <tt>C8 ii ii jj</tt> || <tt>11001000 iiiiiiii iiiiiiii jjjjjjjj</tt> || 3 || 8 (imm8 = 0)<br/>14 (imm8 = 1)<br/>15 + imm8 * 4 (imm8 >= 2)
|}
----
{{Anchor|ES}}
=== ES ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| ES || <tt>26</tt> || <tt>00100110</tt> || 1 || 1
|}
----
{{Anchor|HLT}}
=== HLT ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| HLT || <tt>F4</tt> || <tt>11110100</tt> || 1 || 9
|}
----
{{Anchor|IDIV}}
=== IDIV ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| IDIV mem8 || <tt>F6 /7</tt> || <tt>11110110 oo111mmm</tt> || 2+ || 18
|-
| IDIV mem16 || <tt>F7 /7</tt> || <tt>11111111 oo111mmm</tt> || 2+ || 25
|-
| IDIV reg8 || <tt>F6 /7</tt> || <tt>11111110 11111mmm</tt> || 2 || 17
|-
| IDIV reg16 || <tt>F7 /7</tt> || <tt>11111111 11111mmm</tt> || 2 || 24
|}
----
{{Anchor|IMUL}}
=== IMUL ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| IMUL mem8 || <tt>F6 /5</tt> || <tt>11110110 oo101mmm</tt> || 2+ || 4
|-
| IMUL mem16 || <tt>F7 /5</tt> || <tt>11111111 oo101mmm</tt> || 2+ || 4
|-
| IMUL reg8 || <tt>F6 /5</tt> || <tt>11111110 11101mmm</tt> || 2 || 3
|-
| IMUL reg16 || <tt>F7 /5</tt> || <tt>11111111 11101mmm</tt> || 2 || 3
|-
| IMUL reg16, mem16, imm16 || <tt>69 /r ii ii</tt> || <tt>11111111 oorrrmmm iiiiiiii iiiiiiii</tt> || 4 || 4
|-
| IMUL reg16, mem16, simm8 || <tt>6B /r ii</tt> || <tt>11111111 oorrrmmm iiiiiiii</tt> || 3 || 4
|-
| IMUL reg16, reg16, imm16 || <tt>69 /r ii ii</tt> || <tt>11111111 11rrrmmm iiiiiiii iiiiiiii</tt> || 4 || 3
|-
| IMUL reg16, reg16, simm8 || <tt>6B /r ii</tt> || <tt>11111111 11rrrmmm iiiiiiii</tt> || 3 || 3
|}
----
{{Anchor|IN}}
=== IN ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| IN AL, DX || <tt>EC</tt> || <tt>11101100</tt> || 1 || 6
|-
| IN AX, DX || <tt>ED</tt> || <tt>11101101</tt> || 1 || 6
|-
| IN AL, imm8 || <tt>E4 ii</tt> || <tt>11100100 iiiiiiii</tt> || 2 || 6
|-
| IN AX, imm8 || <tt>E5 ii</tt> || <tt>11100101 iiiiiiii</tt> || 2 || 6
|}
----
{{Anchor|INC}}
=== INC ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| INC mem8 || <tt>FE /0</tt> || <tt>11111110 oo000mmm</tt> || 2+ || 3
|-
| INC mem16 || <tt>FF /0</tt> || <tt>11111111 oo000mmm</tt> || 2+ || 3
|-
| INC reg8 || <tt>FE /0</tt> || <tt>11111110 11000mmm</tt> || 2+ || 1
|-
| INC reg16 || <tt>4x</tt> || <tt>01000rrr</tt> || 1 || 1
|}
----
{{Anchor|INSB}}
{{Anchor|INSW}}
=== INSB/INSW ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| INSB || <tt>6C</tt> || <tt>01101100</tt> || 1 || 6
|-
| INSW || <tt>6D</tt> || <tt>01101101</tt> || 1 || 6
|}
----
{{Anchor|INT}}
=== INT ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| INT 3 || <tt>CC</tt> || <tt>11001100</tt> || 1 || 9
|-
| INT imm8 || <tt>CD ii</tt> || <tt>11001101 iiiiiiii</tt> || 2 || 10
|}
----
{{Anchor|INTO}}
=== INTO ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| INTO || <tt>CE</tt> || <tt>11001110</tt> || 1 || 6 (13 if OF = 1)
|}
----
{{Anchor|IRET}}
=== IRET ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| IRET || <tt>CF</tt> || <tt>11001111</tt> || 1 || 10
|}
----
{{Anchor|JA}}
=== JA ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JA rel8 || <tt>77 ii</tt> || <tt>01110111 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JBE}}
=== JBE ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JA rel8 || <tt>76 ii</tt> || <tt>01110110 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JC}}
=== JC/JB ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JC rel8 || <tt>72 ii</tt> || <tt>01110010 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JCXZ}}
=== JCXZ ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JCXZ rel8 || <tt>E3 ii</tt> || <tt>11100011 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JG}}
=== JG ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JG rel8 || <tt>7F ii</tt> || <tt>01111111 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JGE}}
=== JGE ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JGE rel8 || <tt>7D ii</tt> || <tt>01111101 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JL}}
=== JL ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JL rel8 || <tt>7C ii</tt> || <tt>01111100 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JLE}}
=== JLE ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JLE rel8 || <tt>7E ii</tt> || <tt>01111110 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JMP}}
=== JMP ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JMP ptr16:16 || <tt>EA oo oo ss ss</tt> || <tt>11101010 oooooooo oooooooo ssssssss ssssssss</tt> || 5 || 7
|-
| JMP mem16 || <tt>FF /4</tt> || <tt>11111111 oo100mmm</tt> || 2+ || 5
|-
| JMP mem16:16 || <tt>FF /5</tt> || <tt>11111111 oo101mmm</tt> || 2+ || 10
|-
| JMP reg16 || <tt>FF /4</tt> || <tt>11111111 11100mmm</tt> || 2 || 4
|-
| JMP rel8 || <tt>EB ii</tt> || <tt>11101011 iiiiiiii</tt> || 2 || 4
|-
| JMP rel16 || <tt>E9 ii ii</tt> || <tt>11101001 iiiiiiii iiiiiiii</tt> || 3 || 4
|}
----
{{Anchor|JNC}}
=== JNC/JAE ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JNC rel8 || <tt>73 ii</tt> || <tt>01110011 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JNO}}
=== JNO ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JNO rel8 || <tt>71 ii</tt> || <tt>01110001 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JNP}}
=== JNP ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JNP rel8 || <tt>7B ii</tt> || <tt>01111011 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JNS}}
=== JNS ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JNS rel8 || <tt>79 ii</tt> || <tt>01111001 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JNZ}}
=== JNZ/JNE ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JNZ rel8 || <tt>75 ii</tt> || <tt>01110101 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JO}}
=== JO ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JO rel8 || <tt>70 ii</tt> || <tt>01110000 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JP}}
=== JP ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JP rel8 || <tt>7A ii</tt> || <tt>01111010 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JS}}
=== JS ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JS rel8 || <tt>78 ii</tt> || <tt>01111000 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JZ}}
=== JZ/JE ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JZ rel8 || <tt>74 ii</tt> || <tt>01110100 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|LAHF}}
=== LAHF ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| LAHF || <tt>9F</tt> || <tt>10011111</tt> || 1 || 2
|}
----
{{Anchor|LDS}}
=== LDS ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| LDS reg16, mem16 || <tt>C5 /r</tt> || <tt>11000101 oorrrmmm</tt> || 2+ || 6
|}
----
{{Anchor|LEA}}
=== LEA ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| LEA reg16, mem16 || <tt>8D /r</tt> || <tt>10001101 oorrrmmm</tt> || 2+ || 1
|}
----
{{Anchor|LEAVE}}
=== LEAVE ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| LEAVE || <tt>C9</tt> || <tt>11001001</tt> || 1 || 2
|}
----
{{Anchor|LES}}
=== LES ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| LES reg16, mem16 || <tt>C4 /r</tt> || <tt>11000100 oorrrmmm</tt> || 2+ || 6
|}
----
{{Anchor|LOCK}}
=== LOCK ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| LOCK || <tt>F0</tt> || <tt>11110000</tt> || 1 || 1
|}
----
{{Anchor|LODSB}}
{{Anchor|LODSW}}
=== LODSB/LODSW ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| LODSB || <tt>AC</tt> || <tt>10101100</tt> || 1 || 3
|-
| LODSW || <tt>AD</tt> || <tt>10101101</tt> || 1 || 3
|}
----
{{Anchor|LOOP}}
=== LOOP ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| LOOP rel8 || <tt>E2 ii</tt> || <tt>11100010 iiiiiiii</tt> || 2 || 2 (5 if branch taken)
|}
----
{{Anchor|LOOPE}}
=== LOOPE ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| LOOPE rel8 || <tt>E1 ii</tt> || <tt>11100001 iiiiiiii</tt> || 2 || 3 (6 if branch taken)
|}
----
{{Anchor|LOOPNE}}
=== LOOPNE ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| LOOPNE rel8 || <tt>E0 ii</tt> || <tt>11100000 iiiiiiii</tt> || 2 || 3 (6 if branch taken)
|}
----
{{Anchor|MOV}}
=== MOV ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| MOV AL, ptr16 || <tt>A0 ii ii</tt> || <tt>10100000 iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| MOV AX, ptr16 || <tt>A1 ii ii</tt> || <tt>10100001 iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| MOV mem8, imm8 || <tt>C6 /0 ii</tt> || <tt>11000110 oo000mmm iiiiiiii</tt> || 3+ || 1
|-
| MOV mem16, imm16 || <tt>C7 /0 ii ii</tt> || <tt>11000111 oo000mmm iiiiiiii iiiiiiii</tt> || 4+ || 1
|-
| MOV mem8, reg8 || <tt>84 /r</tt> || <tt>10001000 oorrrmmm</tt> || 2+ || 1
|-
| MOV mem16, reg16 || <tt>85 /r</tt> || <tt>10001001 oorrrmmm</tt> || 2+ || 1
|-
| MOV mem16, sreg16 || <tt>8C /r</tt> || <tt>10001100 oo0rrmmm</tt> || 2+ || 3
|-
| MOV ptr16, AL || <tt>A2 ii ii</tt> || <tt>10100010 iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| MOV ptr16, AX || <tt>A3 ii ii</tt> || <tt>10100011 iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| MOV reg8, imm8 || <tt>Bx ii</tt> || <tt>10110rrr iiiiiiii</tt> || 2 || 1
|-
| MOV reg8, imm8 || <tt>C6 /0 ii</tt> || <tt>11000110 11000mmm iiiiiiii</tt> || 3 || 1
|-
| MOV reg16, imm16 || <tt>Bx ii</tt> || <tt>10111rrr iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| MOV reg16, imm16 || <tt>C7 /0 ii ii</tt> || <tt>11000111 11000mmm iiiiiiii iiiiiiii</tt> || 4 || 1
|-
| MOV reg8, mem8 || <tt>8A /r</tt> || <tt>10001010 oorrrmmm</tt> || 2+ || 1
|-
| MOV reg16, mem16 || <tt>8B /r</tt> || <tt>10001011 oorrrmmm</tt> || 2+ || 1
|-
| MOV reg8, reg8 || <tt>88 /r</tt> || <tt>100010.0 11rrrmmm</tt> || 2 || 1
|-
| MOV reg16, reg16 || <tt>89 /r</tt> || <tt>100010.1 11rrrmmm</tt> || 2 || 1
|-
| MOV reg16, sreg16 || <tt>8C /r</tt> || <tt>10001100 110rrmmm</tt> || 2 || 1
|-
| MOV sreg16, mem16 || <tt>8E /r</tt> || <tt>10001110 oo0rrmmm</tt> || 2 || 3
|-
| MOV sreg16, reg16 || <tt>8E /r</tt> || <tt>10001110 110rrmmm</tt> || 2+ || 2
|}
----
{{Anchor|MOVSB}}
{{Anchor|MOVSW}}
=== MOVSB/MOVSW ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| MOVSB || <tt>A4</tt> || <tt>10100100</tt> || 1 || 5
|-
| MOVSW || <tt>A5</tt> || <tt>10100101</tt> || 1 || 5
|}
----
{{Anchor|MUL}}
=== MUL ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| MUL mem8 || <tt>F6 /4</tt> || <tt>11110110 oo100mmm</tt> || 2+ || 4
|-
| MUL mem16 || <tt>F7 /4</tt> || <tt>11111111 oo100mmm</tt> || 2+ || 4
|-
| MUL reg8 || <tt>F6 /4</tt> || <tt>11111110 11100mmm</tt> || 2 || 3
|-
| MUL reg16 || <tt>F7 /4</tt> || <tt>11111111 11100mmm</tt> || 2 || 3
|}
----
{{Anchor|NEG}}
=== NEG ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| NEG mem8 || <tt>F6 /3</tt> || <tt>11110110 oo011mmm</tt> || 2+ || 3
|-
| NEG mem16 || <tt>F7 /3</tt> || <tt>11111111 oo011mmm</tt> || 2+ || 3
|-
| NEG reg8 || <tt>F6 /3</tt> || <tt>11111110 11011mmm</tt> || 2 || 1
|-
| NEG reg16 || <tt>F7 /3</tt> || <tt>11111111 11011mmm</tt> || 2 || 1
|}
----
{{Anchor|NOP}}
=== NOP ===
----
{{Anchor|NOT}}
=== NOT ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| NOT mem8 || <tt>F6 /2</tt> || <tt>11110110 oo010mmm</tt> || 2+ || 3
|-
| NOT mem16 || <tt>F7 /2</tt> || <tt>11111111 oo010mmm</tt> || 2+ || 3
|-
| NOT reg8 || <tt>F6 /2</tt> || <tt>11111110 11010mmm</tt> || 2 || 1
|-
| NOT reg16 || <tt>F7 /2</tt> || <tt>11111111 11010mmm</tt> || 2 || 1
|}
----
{{Anchor|OR}}
=== OR ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| OR AL, imm || <tt>0C ii</tt> || <tt>00001100 iiiiiiii</tt> || 2 || 1
|-
| OR AX, imm || <tt>0D ii ii</tt> || <tt>00001101 iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| OR mem8, imm8 || <tt>80 /6 ii</tt> || <tt>10000000 oo001mmm iiiiiiii</tt> || 3+ || 3
|-
| OR mem16, imm16 || <tt>81 /6 ii ii</tt> || <tt>10000001 oo001mmm iiiiiiii iiiiiiii</tt> || 4+ || 3
|-
| OR mem16, simm8 || <tt>83 /6 ii</tt> || <tt>10000011 oo001mmm iiiiiiii</tt> || 3+ || 3
|-
| OR mem8, reg8 || <tt>08 /r</tt> || <tt>00001000 oorrrmmm</tt> || 2+ || 3
|-
| OR mem16, reg16 || <tt>09 /r</tt> || <tt>00001001 oorrrmmm</tt> || 2+ || 3
|-
| OR reg8, imm8 || <tt>80 /6 ii</tt> || <tt>10000000 11001mmm iiiiiiii</tt> || 3 || 1
|-
| OR reg16, imm16 || <tt>81 /6 ii ii</tt> || <tt>10000001 11001mmm iiiiiiii iiiiiiii</tt> || 4 || 1
|-
| OR reg16, simm8 || <tt>83 /6 ii</tt> || <tt>10000011 11001mmm iiiiiiii</tt> || 3 || 1
|-
| OR reg8, mem8 || <tt>0A /r</tt> || <tt>00001010 oorrrmmm</tt> || 2+ || 2
|-
| OR reg16, mem16 || <tt>0B /r</tt> || <tt>00001011 oorrrmmm</tt> || 2+ || 2
|-
| OR reg8, reg8 || <tt>08 /r</tt> || <tt>000010.0 11rrrmmm</tt> || 2 || 1
|-
| OR reg16, reg16 || <tt>09 /r</tt> || <tt>000010.1 11rrrmmm</tt> || 2 || 1
|}
----
{{Anchor|OUT}}
=== OUT ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| OUT AL, DX || <tt>EE</tt> || <tt>11101110</tt> || 1 || 6
|-
| OUT AX, DX || <tt>EF</tt> || <tt>11101111</tt> || 1 || 6
|-
| OUT AL, imm8 || <tt>E6 ii</tt> || <tt>11100110 iiiiiiii</tt> || 2 || 6
|-
| OUT AX, imm8 || <tt>E7 ii</tt> || <tt>11100111 iiiiiiii</tt> || 2 || 6
|}
----
{{Anchor|OUTSB}}
{{Anchor|OUTSW}}
=== OUTSB/OUTSW ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| OUTSB || <tt>6E</tt> || <tt>01101110</tt> || 1 || 6
|-
| OUTSW || <tt>6F</tt> || <tt>01101111</tt> || 1 || 6
|}
----
{{Anchor|POLL}}
=== POLL ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| POLL || <tt>6E</tt> || <tt>01101110</tt> || 1 || 9<ref>On the WonderSwan implementation, POLLB is always held low; on other implementations, POLL will wait for POLLB to be held low in 9-cycle intervals.</ref>
|}
----
{{Anchor|POP}}
=== POP ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| POP mem16 || <tt>8F /0</tt> || <tt>10001111 oo000mmm</tt> || 2+ || 3
|-
| POP reg16 || <tt>5x</tt> || <tt>01011xxx</tt> || 1 || 1
|-
| POP reg16 || <tt>8F /0</tt> || <tt>10001111 11000mmm</tt> || 2 || 1
|-
| POP sreg16 || <tt>xx</tt> || <tt>000xx111</tt> || 1 || 3
|}
----
{{Anchor|POPA}}
=== POPA ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| POPA || <tt>61</tt> || <tt>01100001</tt> || 1 || 8
|}
----
{{Anchor|POPF}}
=== POPF ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| POPF || <tt>9D</tt> || <tt>10011101</tt> || 1 || 3
|}
----
{{Anchor|PUSH}}
=== PUSH ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| PUSH imm8 || <tt>6A ii</tt> || <tt>01101010 iiiiiiii</tt> || 2 || 1
|-
| PUSH imm16 || <tt>68 ii ii</tt> || <tt>01101000 iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| PUSH mem16 || <tt>FF /6</tt> || <tt>11111111 oo110mmm</tt> || 2+ || 2
|-
| PUSH reg16 || <tt>5x</tt> || <tt>01010xxx</tt> || 1 || 1
|-
| PUSH reg16 || <tt>FF /6</tt> || <tt>11111111 11110mmm</tt> || 2 || 1
|-
| PUSH sreg16 || <tt>xx</tt> || <tt>000xx110</tt> || 1 || 2
|}
----
{{Anchor|PUSHA}}
=== PUSHA ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| PUSHA || <tt>60</tt> || <tt>01100000</tt> || 1 || 9
|}
----
{{Anchor|PUSHF}}
=== PUSHF ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| PUSHF || <tt>9C</tt> || <tt>10011100</tt> || 1 || 2
|}
----
{{Anchor|RCL}}
=== RCL ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| RCL mem8, 1 || <tt>D0 /2</tt> || <tt>11010000 oo010rm</tt> || 2+ || 3
|-
| RCL mem8, CL || <tt>D2 /2</tt> || <tt>11010010 oo010rm</tt> || 2+ || 5
|-
| RCL mem8, imm8 || <tt>C0 /2 ii</tt> || <tt>11000000 oo010mmm iiiiiiii</tt> || 3+ || 5
|-
| RCL mem16, 1 || <tt>D1 /2</tt> || <tt>11010001 oo010rm</tt> || 2+ || 3
|-
| RCL mem16, CL || <tt>D3 /2</tt> || <tt>11010011 oo010rm</tt> || 2+ || 5
|-
| RCL mem16, imm8 || <tt>C1 /2 ii</tt> || <tt>11000001 oo010mmm iiiiiiii</tt> || 3+ || 5
|-
| RCL reg8, 1 || <tt>D0 /2</tt> || <tt>11010000 11010rm</tt> || 2 || 1
|-
| RCL reg8, CL || <tt>D2 /2</tt> || <tt>11010010 11010rm</tt> || 2 || 3
|-
| RCL reg8, imm8 || <tt>C0 /2 ii</tt> || <tt>11000000 11010mmm iiiiiiii</tt> || 3 || 3
|-
| RCL reg16, 1 || <tt>D1 /2</tt> || <tt>11010001 11010rm</tt> || 2 || 1
|-
| RCL reg16, CL || <tt>D3 /2</tt> || <tt>11010011 11010rm</tt> || 2 || 3
|-
| RCL reg16, imm8 || <tt>C1 /2 ii</tt> || <tt>11000001 11010mmm iiiiiiii</tt> || 3 || 3
|}
----
{{Anchor|RCR}}
=== RCR ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| RCR mem8, 1 || <tt>D0 /3</tt> || <tt>11010000 oo011rm</tt> || 2+ || 3
|-
| RCR mem8, CL || <tt>D2 /3</tt> || <tt>11010010 oo011rm</tt> || 2+ || 5
|-
| RCR mem8, imm8 || <tt>C0 /3 ii</tt> || <tt>11000000 oo011mmm iiiiiiii</tt> || 3+ || 5
|-
| RCR mem16, 1 || <tt>D1 /3</tt> || <tt>11010001 oo011rm</tt> || 2+ || 3
|-
| RCR mem16, CL || <tt>D3 /3</tt> || <tt>11010011 oo011rm</tt> || 2+ || 5
|-
| RCR mem16, imm8 || <tt>C1 /3 ii</tt> || <tt>11000001 oo011mmm iiiiiiii</tt> || 3+ || 5
|-
| RCR reg8, 1 || <tt>D0 /3</tt> || <tt>11010000 11011rm</tt> || 2 || 1
|-
| RCR reg8, CL || <tt>D2 /3</tt> || <tt>11010010 11011rm</tt> || 2 || 3
|-
| RCR reg8, imm8 || <tt>C0 /3 ii</tt> || <tt>11000000 11011mmm iiiiiiii</tt> || 3 || 3
|-
| RCR reg16, 1 || <tt>D1 /3</tt> || <tt>11010001 11011rm</tt> || 2 || 1
|-
| RCR reg16, CL || <tt>D3 /3</tt> || <tt>11010011 11011rm</tt> || 2 || 3
|-
| RCR reg16, imm8 || <tt>C1 /3 ii</tt> || <tt>11000001 11011mmm iiiiiiii</tt> || 3 || 3
|}
----
{{Anchor|REP}}
=== REP/REPE/REPZ ===
----
{{Anchor|REPNE}}
=== REPNE/REPNZ ===
----
{{Anchor|RET}}
=== RET ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| RET || <tt>C3</tt> || <tt>11000011</tt> || 1 || 6
|-
| RET imm16 || <tt>C2 ii ii</tt> || <tt>11000010 iiiiiiii iiiiiiii</tt> || 1 || 6
|}
----
{{Anchor|RETF}}
=== RETF ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| RETF || <tt>CB</tt> || <tt>11001011</tt> || 1 || 9
|-
| RETF imm16 || <tt>CA ii ii</tt> || <tt>11001010 iiiiiiii iiiiiiii</tt> || 1 || 8
|}
----
{{Anchor|ROL}}
=== ROL ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| ROL mem8, 1 || <tt>D0 /0</tt> || <tt>11010000 oo000rm</tt> || 2+ || 3
|-
| ROL mem8, CL || <tt>D2 /0</tt> || <tt>11010010 oo000rm</tt> || 2+ || 5
|-
| ROL mem8, imm8 || <tt>C0 /0 ii</tt> || <tt>11000000 oo000mmm iiiiiiii</tt> || 3+ || 5
|-
| ROL mem16, 1 || <tt>D1 /0</tt> || <tt>11010001 oo000rm</tt> || 2+ || 3
|-
| ROL mem16, CL || <tt>D3 /0</tt> || <tt>11010011 oo000rm</tt> || 2+ || 5
|-
| ROL mem16, imm8 || <tt>C1 /0 ii</tt> || <tt>11000001 oo000mmm iiiiiiii</tt> || 3+ || 5
|-
| ROL reg8, 1 || <tt>D0 /0</tt> || <tt>11010000 11000rm</tt> || 2 || 1
|-
| ROL reg8, CL || <tt>D2 /0</tt> || <tt>11010010 11000rm</tt> || 2 || 3
|-
| ROL reg8, imm8 || <tt>C0 /0 ii</tt> || <tt>11000000 11000mmm iiiiiiii</tt> || 3 || 3
|-
| ROL reg16, 1 || <tt>D1 /0</tt> || <tt>11010001 11000rm</tt> || 2 || 1
|-
| ROL reg16, CL || <tt>D3 /0</tt> || <tt>11010011 11000rm</tt> || 2 || 3
|-
| ROL reg16, imm8 || <tt>C1 /0 ii</tt> || <tt>11000001 11000mmm iiiiiiii</tt> || 3 || 3
|}
----
{{Anchor|ROR}}
=== ROR ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| ROR mem8, 1 || <tt>D0 /1</tt> || <tt>11010000 oo001rm</tt> || 2+ || 3
|-
| ROR mem8, CL || <tt>D2 /1</tt> || <tt>11010010 oo001rm</tt> || 2+ || 5
|-
| ROR mem8, imm8 || <tt>C0 /1 ii</tt> || <tt>11000000 oo001mmm iiiiiiii</tt> || 3+ || 5
|-
| ROR mem16, 1 || <tt>D1 /1</tt> || <tt>11010001 oo001rm</tt> || 2+ || 3
|-
| ROR mem16, CL || <tt>D3 /1</tt> || <tt>11010011 oo001rm</tt> || 2+ || 5
|-
| ROR mem16, imm8 || <tt>C1 /1 ii</tt> || <tt>11000001 oo001mmm iiiiiiii</tt> || 3+ || 5
|-
| ROR reg8, 1 || <tt>D0 /1</tt> || <tt>11010000 11001rm</tt> || 2 || 1
|-
| ROR reg8, CL || <tt>D2 /1</tt> || <tt>11010010 11001rm</tt> || 2 || 3
|-
| ROR reg8, imm8 || <tt>C0 /1 ii</tt> || <tt>11000000 11001mmm iiiiiiii</tt> || 3 || 3
|-
| ROR reg16, 1 || <tt>D1 /1</tt> || <tt>11010001 11001rm</tt> || 2 || 1
|-
| ROR reg16, CL || <tt>D3 /1</tt> || <tt>11010011 11001rm</tt> || 2 || 3
|-
| ROR reg16, imm8 || <tt>C1 /1 ii</tt> || <tt>11000001 11001mmm iiiiiiii</tt> || 3 || 3
|}
----
{{Anchor|SAHF}}
=== SAHF ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| SAHF || <tt>9E</tt> || <tt>10011110</tt> || 1 || 4
|}
----
{{Anchor|SAR}}
=== SAR ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| SAR mem8, 1 || <tt>D0 /7</tt> || <tt>11010000 oo111rm</tt> || 2+ || 3
|-
| SAR mem8, CL || <tt>D2 /7</tt> || <tt>11010010 oo111rm</tt> || 2+ || 5
|-
| SAR mem8, imm8 || <tt>C0 /7 ii</tt> || <tt>11000000 oo111mmm iiiiiiii</tt> || 3+ || 5
|-
| SAR mem16, 1 || <tt>D1 /7</tt> || <tt>11010001 oo111rm</tt> || 2+ || 3
|-
| SAR mem16, CL || <tt>D3 /7</tt> || <tt>11010011 oo111rm</tt> || 2+ || 5
|-
| SAR mem16, imm8 || <tt>C1 /7 ii</tt> || <tt>11000001 oo111mmm iiiiiiii</tt> || 3+ || 5
|-
| SAR reg8, 1 || <tt>D0 /7</tt> || <tt>11010000 11111rm</tt> || 2 || 1
|-
| SAR reg8, CL || <tt>D2 /7</tt> || <tt>11010010 11111rm</tt> || 2 || 3
|-
| SAR reg8, imm8 || <tt>C0 /7 ii</tt> || <tt>11000000 11111mmm iiiiiiii</tt> || 3 || 3
|-
| SAR reg16, 1 || <tt>D1 /7</tt> || <tt>11010001 11111rm</tt> || 2 || 1
|-
| SAR reg16, CL || <tt>D3 /7</tt> || <tt>11010011 11111rm</tt> || 2 || 3
|-
| SAR reg16, imm8 || <tt>C1 /7 ii</tt> || <tt>11000001 11111mmm iiiiiiii</tt> || 3 || 3
|}
----
{{Anchor|SBB}}
=== SBB ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| SBB AL, imm || <tt>1C ii</tt> || <tt>00011100 iiiiiiii</tt> || 2 || 1
|-
| SBB AX, imm || <tt>1D ii ii</tt> || <tt>00011101 iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| SBB mem8, imm8 || <tt>80 /3 ii</tt> || <tt>10000000 oo011mmm iiiiiiii</tt> || 3+ || 3
|-
| SBB mem16, imm16 || <tt>81 /3 ii ii</tt> || <tt>10000001 oo011mmm iiiiiiii iiiiiiii</tt> || 4+ || 3
|-
| SBB mem16, simm8 || <tt>83 /3 ii</tt> || <tt>10000011 oo011mmm iiiiiiii</tt> || 3+ || 3
|-
| SBB mem8, reg8 || <tt>18 /r</tt> || <tt>00011000 oorrrmmm</tt> || 2+ || 3
|-
| SBB mem16, reg16 || <tt>19 /r</tt> || <tt>00011001 oorrrmmm</tt> || 2+ || 3
|-
| SBB reg8, imm8 || <tt>80 /3 ii</tt> || <tt>10000000 11011mmm iiiiiiii</tt> || 3 || 1
|-
| SBB reg16, imm16 || <tt>81 /3 ii ii</tt> || <tt>10000001 11011mmm iiiiiiii iiiiiiii</tt> || 4 || 1
|-
| SBB reg16, simm8 || <tt>83 /3 ii</tt> || <tt>10000011 11011mmm iiiiiiii</tt> || 3 || 1
|-
| SBB reg8, mem8 || <tt>1A /r</tt> || <tt>00011010 oorrrmmm</tt> || 2+ || 2
|-
| SBB reg16, mem16 || <tt>1B /r</tt> || <tt>00011011 oorrrmmm</tt> || 2+ || 2
|-
| SBB reg8, reg8 || <tt>18 /r</tt> || <tt>000110.0 11rrrmmm</tt> || 2 || 1
|-
| SBB reg16, reg16 || <tt>19 /r</tt> || <tt>000110.1 11rrrmmm</tt> || 2 || 1
|}
----
{{Anchor|SCASB}}
{{Anchor|SCASW}}
=== SCASB/SCASW ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| SCASB || <tt>AE</tt> || <tt>10101110</tt> || 1 || 4
|-
| SCASW || <tt>AF</tt> || <tt>10101111</tt> || 1 || 4
|}
----
{{Anchor|SHL}}
=== SHL ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| SHL mem8, 1 || <tt>D0 /4</tt> || <tt>11010000 oo100rm</tt> || 2+ || 3
|-
| SHL mem8, CL || <tt>D2 /4</tt> || <tt>11010010 oo100rm</tt> || 2+ || 5
|-
| SHL mem8, imm8 || <tt>C0 /4 ii</tt> || <tt>11000000 oo100mmm iiiiiiii</tt> || 3+ || 5
|-
| SHL mem16, 1 || <tt>D1 /4</tt> || <tt>11010001 oo100rm</tt> || 2+ || 3
|-
| SHL mem16, CL || <tt>D3 /4</tt> || <tt>11010011 oo100rm</tt> || 2+ || 5
|-
| SHL mem16, imm8 || <tt>C1 /4 ii</tt> || <tt>11000001 oo100mmm iiiiiiii</tt> || 3+ || 5
|-
| SHL reg8, 1 || <tt>D0 /4</tt> || <tt>11010000 11100rm</tt> || 2 || 1
|-
| SHL reg8, CL || <tt>D2 /4</tt> || <tt>11010010 11100rm</tt> || 2 || 3
|-
| SHL reg8, imm8 || <tt>C0 /4 ii</tt> || <tt>11000000 11100mmm iiiiiiii</tt> || 3 || 3
|-
| SHL reg16, 1 || <tt>D1 /4</tt> || <tt>11010001 11100rm</tt> || 2 || 1
|-
| SHL reg16, CL || <tt>D3 /4</tt> || <tt>11010011 11100rm</tt> || 2 || 3
|-
| SHL reg16, imm8 || <tt>C1 /4 ii</tt> || <tt>11000001 11100mmm iiiiiiii</tt> || 3 || 3
|}
----
{{Anchor|SHR}}
=== SHR ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| SHR mem8, 1 || <tt>D0 /5</tt> || <tt>11010000 oo101rm</tt> || 2+ || 3
|-
| SHR mem8, CL || <tt>D2 /5</tt> || <tt>11010010 oo101rm</tt> || 2+ || 5
|-
| SHR mem8, imm8 || <tt>C0 /5 ii</tt> || <tt>11000000 oo101mmm iiiiiiii</tt> || 3+ || 5
|-
| SHR mem16, 1 || <tt>D1 /5</tt> || <tt>11010001 oo101rm</tt> || 2+ || 3
|-
| SHR mem16, CL || <tt>D3 /5</tt> || <tt>11010011 oo101rm</tt> || 2+ || 5
|-
| SHR mem16, imm8 || <tt>C1 /5 ii</tt> || <tt>11000001 oo101mmm iiiiiiii</tt> || 3+ || 5
|-
| SHR reg8, 1 || <tt>D0 /5</tt> || <tt>11010000 11101rm</tt> || 2 || 1
|-
| SHR reg8, CL || <tt>D2 /5</tt> || <tt>11010010 11101rm</tt> || 2 || 3
|-
| SHR reg8, imm8 || <tt>C0 /5 ii</tt> || <tt>11000000 11101mmm iiiiiiii</tt> || 3 || 3
|-
| SHR reg16, 1 || <tt>D1 /5</tt> || <tt>11010001 11101rm</tt> || 2 || 1
|-
| SHR reg16, CL || <tt>D3 /5</tt> || <tt>11010011 11101rm</tt> || 2 || 3
|-
| SHR reg16, imm8 || <tt>C1 /5 ii</tt> || <tt>11000001 11101mmm iiiiiiii</tt> || 3 || 3
|}
----
{{Anchor|SS}}
=== SS ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| SS || <tt>36</tt> || <tt>00110110</tt> || 1 || 1
|}
----
{{Anchor|STC}}
=== STC ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| STC || <tt>F9</tt> || <tt>11111001</tt> || 1 || 4
|}
----
{{Anchor|STD}}
=== STD ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| STD || <tt>FD</tt> || <tt>11111101</tt> || 1 || 4
|}
----
{{Anchor|STI}}
=== STI ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| STI || <tt>FB</tt> || <tt>11111011</tt> || 1 || 4
|}
----
{{Anchor|STOSB}}
{{Anchor|STOSW}}
=== STOSB/STOSW ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| STOSB || <tt>AA</tt> || <tt>10101010</tt> || 1 || 3
|-
| STOSW || <tt>AB</tt> || <tt>10101011</tt> || 1 || 3
|}
----
{{Anchor|SUB}}
=== SUB ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| SUB AL, imm || <tt>28 ii</tt> || <tt>00101100 iiiiiiii</tt> || 2 || 1
|-
| SUB AX, imm || <tt>29 ii ii</tt> || <tt>00101101 iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| SUB mem8, imm8 || <tt>80 /5 ii</tt> || <tt>10000000 oo101mmm iiiiiiii</tt> || 3+ || 3
|-
| SUB mem16, imm16 || <tt>81 /5 ii ii</tt> || <tt>10000001 oo101mmm iiiiiiii iiiiiiii</tt> || 4+ || 3
|-
| SUB mem16, simm8 || <tt>83 /5 ii</tt> || <tt>10000011 oo101mmm iiiiiiii</tt> || 3+ || 3
|-
| SUB mem8, reg8 || <tt>28 /r</tt> || <tt>00101000 oorrrmmm</tt> || 2+ || 3
|-
| SUB mem16, reg16 || <tt>29 /r</tt> || <tt>00101001 oorrrmmm</tt> || 2+ || 3
|-
| SUB reg8, imm8 || <tt>80 /5 ii</tt> || <tt>10000000 11101mmm iiiiiiii</tt> || 3 || 1
|-
| SUB reg16, imm16 || <tt>81 /5 ii ii</tt> || <tt>10000001 11101mmm iiiiiiii iiiiiiii</tt> || 4 || 1
|-
| SUB reg16, simm8 || <tt>83 /5 ii</tt> || <tt>10000011 11101mmm iiiiiiii</tt> || 3 || 1
|-
| SUB reg8, mem8 || <tt>2A /r</tt> || <tt>00101010 oorrrmmm</tt> || 2+ || 2
|-
| SUB reg16, mem16 || <tt>2B /r</tt> || <tt>00101011 oorrrmmm</tt> || 2+ || 2
|-
| SUB reg8, reg8 || <tt>28 /r</tt> || <tt>001010.0 11rrrmmm</tt> || 2 || 1
|-
| SUB reg16, reg16 || <tt>29 /r</tt> || <tt>001010.1 11rrrmmm</tt> || 2 || 1
|}
----
{{Anchor|TEST}}
=== TEST ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| TEST AL, imm || <tt>A8 ii</tt> || <tt>10101000 iiiiiiii</tt> || 2 || 1
|-
| TEST AX, imm || <tt>A9 ii ii</tt> || <tt>10101001 iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| TEST mem8, imm8 || <tt>F6 /0 ii</tt> || <tt>11110110 oo000mmm iiiiiiii</tt> || 3+ || 2
|-
| TEST mem16, imm16 || <tt>F7 /0 ii ii</tt> || <tt>11110111 oo000mmm iiiiiiii iiiiiiii</tt> || 4+ || 2
|-
| TEST mem8, reg8<br/>TEST reg8, mem8 || <tt>84 /r</tt> || <tt>10000100 oorrrmmm</tt> || 2+ || 2
|-
| TEST mem16, reg16<br/>TEST reg16, mem16 || <tt>85 /r</tt> || <tt>10000101 oorrrmmm</tt> || 2+ || 2
|-
| TEST reg8, imm8 || <tt>F6 /0 ii</tt> || <tt>11110110 11000mmm iiiiiiii</tt> || 3 || 1
|-
| TEST reg16, imm16 || <tt>F7 /0 ii ii</tt> || <tt>11110111 11000mmm iiiiiiii iiiiiiii</tt> || 4 || 1
|-
| TEST reg8, reg8 || <tt>84 /r</tt> || <tt>10000100 11rrrmmm</tt> || 2 || 1
|-
| TEST reg16, reg16 || <tt>85 /r</tt> || <tt>10000101 11rrrmmm</tt> || 2 || 1
|}
----
{{Anchor|XCHG}}
=== XCHG ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| XCHG AX, reg16<br/>XCHG reg16, AX || <tt>9x</tt> || <tt>10010rrr</tt> || 1 || 3
|-
| XCHG mem8, reg8<br/>XCHG reg8, mem8 || <tt>86 /r</tt> || <tt>10000110 oorrrmmm</tt> || 2+ || 5
|-
| XCHG mem16, reg16<br/>XCHG reg16, mem16 || <tt>87 /r</tt> || <tt>10000111 oorrrmmm</tt> || 2+ || 5
|-
| XCHG reg8, reg8 || <tt>86 /r</tt> || <tt>10000110 11rrrmmm</tt> || 2+ || 3
|-
| XCHG reg16, reg16 || <tt>87 /r</tt> || <tt>10000111 11rrrmmm</tt> || 2+ || 3
|}
----
{{Anchor|XLAT}}
=== XLAT ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| XLAT || <tt>D7</tt> || <tt>11010111</tt> || 1 || 5
|}
----
{{Anchor|XOR}}
=== XOR ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| XOR AL, imm || <tt>34 ii</tt> || <tt>00110100 iiiiiiii</tt> || 2 || 1
|-
| XOR AX, imm || <tt>35 ii ii</tt> || <tt>00110101 iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| XOR mem8, imm8 || <tt>80 /6 ii</tt> || <tt>10000000 oo110mmm iiiiiiii</tt> || 3+ || 3
|-
| XOR mem16, imm16 || <tt>81 /6 ii ii</tt> || <tt>10000001 oo110mmm iiiiiiii iiiiiiii</tt> || 4+ || 3
|-
| XOR mem16, simm8 || <tt>83 /6 ii</tt> || <tt>10000011 oo110mmm iiiiiiii</tt> || 3+ || 3
|-
| XOR mem8, reg8 || <tt>30 /r</tt> || <tt>00110000 oorrrmmm</tt> || 2+ || 3
|-
| XOR mem16, reg16 || <tt>31 /r</tt> || <tt>00110001 oorrrmmm</tt> || 2+ || 3
|-
| XOR reg8, imm8 || <tt>80 /6 ii</tt> || <tt>10000000 11110mmm iiiiiiii</tt> || 3 || 1
|-
| XOR reg16, imm16 || <tt>81 /6 ii ii</tt> || <tt>10000001 11110mmm iiiiiiii iiiiiiii</tt> || 4 || 1
|-
| XOR reg16, simm8 || <tt>83 /6 ii</tt> || <tt>10000011 11110mmm iiiiiiii</tt> || 3 || 1
|-
| XOR reg8, mem8 || <tt>32 /r</tt> || <tt>00110010 oorrrmmm</tt> || 2+ || 2
|-
| XOR reg16, mem16 || <tt>33 /r</tt> || <tt>00110011 oorrrmmm</tt> || 2+ || 2
|-
| XOR reg8, reg8 || <tt>30 /r</tt> || <tt>001100.0 11rrrmmm</tt> || 2 || 1
|-
| XOR reg16, reg16 || <tt>31 /r</tt> || <tt>001100.1 11rrrmmm</tt> || 2 || 1
|}
== Notes ==
<references />
dc4c05e02503ff017068fecc786f0ce947c5bf1b
464
463
2024-12-27T23:37:53Z
Asie
351
/* NOP */
wikitext
text/x-wiki
__NOTOC__
Note that this page is a work in progress.
{| class="wikitable" style="text-align: center"
|+ Official V30MZ (80186) Instructions
|-
| [[#AAA|AAA]] || [[#AAD|AAD]] || [[#AAM|AAM]] || [[#AAS|AAS]] || [[#ADC|ADC]] || [[#ADD|ADD]] || [[#AND|AND]] || [[#BOUND|BOUND]] || [[#CALL|CALL]] || [[#CBW|CBW]] || [[#CLC|CLC]]
|-
| [[#CLD|CLD]] || [[#CLI|CLI]] || [[#CMC|CMC]] || [[#CMP|CMP]] || [[#CMPSB|CMPSB]] || [[#CMPSW|CMPSW]] || [[#CS|CS]] || [[#CWD|CWD]] || [[#DAA|DAA]] || [[#DAS|DAS]] || [[#DEC|DEC]]
|-
| [[#DIV|DIV]] || [[#DS|DS]] || [[#ENTER|ENTER]] || [[#ES|ES]] || [[#HLT|HLT]] || [[#IDIV|IDIV]] || [[#IMUL|IMUL]] || [[#IN|IN]] || [[#INC|INC]] || [[#INSB|INSB]] || [[#INSW|INSW]]
|-
| [[#INT|INT]] || [[#INTO|INTO]] || [[#IRET|IRET]] || [[#JA|JA]] || [[#JBE|JBE]] || [[#JC|JC]] || [[#JCXZ|JCXZ]] || [[#JG|JG]] || [[#JGE|JGE]] || [[#JL|JL]] || [[#JLE|JLE]]
|-
| [[#JMP|JMP]] || [[#JNC|JNC]] || [[#JNO|JNO]] || [[#JNP|JNP]] || [[#JNS|JNS]] || [[#JNZ|JNZ]] || [[#JO|JO]] || [[#JP|JP]] || [[#JS|JS]] || [[#JZ|JZ]] || [[#LAHF|LAHF]]
|-
| [[#LDS|LDS]] || [[#LEA|LEA]] || [[#LEAVE|LEAVE]] || [[#LES|LES]] || [[#LOCK|LOCK]] || [[#LODSB|LODSB]] || [[#LODSW|LODSW]] || [[#LOOP|LOOP]] || [[#LOOPE|LOOPE]] || [[#LOOPNE|LOOPNE]] || [[#MOV|MOV]]
|-
| [[#MOVSB|MOVSB]] || [[#MOVSW|MOVSW]] || [[#MUL|MUL]] || [[#NEG|NEG]] || [[#NOP|NOP]] || [[#NOT|NOT]] || [[#OR|OR]] || [[#OUT|OUT]] || [[#OUTSB|OUTSB]] || [[#OUTSW|OUTSW]] || [[#POLL|POLL]]
|-
| [[#POP|POP]] || [[#POPA|POPA]] || [[#POPF|POPF]] || [[#PUSH|PUSH]] || [[#PUSHA|PUSHA]] || [[#PUSHF|PUSHF]] || [[#RCL|RCL]] || [[#RCR|RCR]] || [[#REP|REP]] || [[#REPNE|REPNE]] || [[#RET|RET]]
|-
| [[#RETF|RETF]] || [[#ROL|ROL]] || [[#ROR|ROR]] || [[#SAHF|SAHF]] || [[#SAR|SAR]] || [[#SBB|SBB]] || [[#SCASB|SCASB]] || [[#SCASW|SCASW]] || [[#SHL|SHL]] || [[#SHR|SHR]] || [[#SS|SS]]
|-
| [[#STC|STC]] || [[#STD|STD]] || [[#STI|STI]] || [[#STOSB|STOSB]] || [[#STOSW|STOSW]] || [[#SUB|SUB]] || [[#TEST|TEST]] || [[#XCHG|XCHG]] || [[#XLAT|XLAT]] || [[#XOR|XOR]]
|}
{| class="mw-collapsible mw-collapsed wikitable sortable" style="width: 340px;"
|+ style="white-space:nowrap; border:1px solid; padding:3px; border-color:rgb(162, 169, 177); background-color:rgb(234, 236, 240);" | Intel <-> NEC mnemonic translation table
!Intel
!NEC
|-
| [[#AAA|AAA]]
| [[#AAA|ADJBA]]
|-
| [[#AAD|AAD]]
| [[#AAD|CVTDB]]
|-
| [[#AAM|AAM]]
| [[#AAM|CVTBD]]
|-
| [[#AAS|AAS]]
| [[#AAS|ADJBS]]
|-
| [[#ADC|ADC]]
| [[#ADC|ADDC]]
|-
| [[#ADD|ADD]]
| [[#ADD|ADD]]
|-
| [[#AND|AND]]
| [[#AND|AND]]
|-
| [[#BOUND|BOUND]]
| [[#BOUND|CHKIND]]
|-
| [[#CALL|CALL]]
| [[#CALL|CALL]]
|-
| [[#CBW|CBW]]
| [[#CBW|CVTBW]]
|-
| [[#CLC|CLC]]
| [[#CLC|CLR1 CY]]
|-
| [[#CLD|CLD]]
| [[#CLD|CLR1 DIR]]
|-
| [[#CLI|CLI]]
| [[#CLI|DI]]
|-
| [[#CMC|CMC]]
| [[#CMC|NOT1 CY]]
|-
| [[#CMP|CMP]]
| [[#CMP|CMP]]
|-
| [[#CMPSB|CMPSB]]
| [[#CMPSB|CMPBKB]]
|-
| [[#CMPSW|CMPSW]]
| [[#CMPSW|CMPBKW]]
|-
| [[#CS|CS]]
| [[#CS|PS]]
|-
| [[#CWD|CWD]]
| [[#CWD|CVTWL]]
|-
| [[#DAA|DAA]]
| [[#DAA|ADJ4A]]
|-
| [[#DAS|DAS]]
| [[#DAS|ADJ4S]]
|-
| [[#DEC|DEC]]
| [[#DEC|DEC]]
|-
| [[#DIV|DIV]]
| [[#DIV|DIVU]]
|-
| [[#DS|DS]]
| [[#DS|DS0]]
|-
| [[#ENTER|ENTER]]
| [[#ENTER|PREPARE]]
|-
| [[#ES|ES]]
| [[#ES|DS1]]
|-
| [[#HLT|HLT]]
| [[#HLT|HALT]]
|-
| [[#IDIV|IDIV]]
| [[#IDIV|DIV]]
|-
| [[#IMUL|IMUL]]
| [[#IMUL|MUL]]
|-
| [[#IN|IN]]
| [[#IN|IN]]
|-
| [[#INC|INC]]
| [[#INC|INC]]
|-
| [[#INSB|INSB]]
| [[#INSB|INMB]]
|-
| [[#INSW|INSW]]
| [[#INSW|INMW]]
|-
| [[#INT|INT]]
| [[#INT|BRK]]
|-
| [[#INTO|INTO]]
| [[#INTO|BRKV]]
|-
| [[#IRET|IRET]]
| [[#IRET|RETI]]
|-
| [[#JA|JA]]
| [[#JA|BH]]
|-
| [[#JBE|JBE]]
| [[#JBE|BNH]]
|-
| [[#JC|JC/JB]]
| [[#JC|BC/BL]]
|-
| [[#JCXZ|JCXZ]]
| [[#JCXZ|BCWZ]]
|-
| [[#JG|JG]]
| [[#JG|BGT]]
|-
| [[#JGE|JGE]]
| [[#JGE|BGE]]
|-
| [[#JL|JL]]
| [[#JL|BLT]]
|-
| [[#JLE|JLE]]
| [[#JLE|BLE]]
|-
| [[#JMP|JMP]]
| [[#JMP|BR]]
|-
| [[#JNC|JNC/JAE]]
| [[#JNC|BNC/BNL]]
|-
| [[#JNO|JNO]]
| [[#JNO|BNV]]
|-
| [[#JNP|JNP]]
| [[#JNP|BPO]]
|-
| [[#JNS|JNS]]
| [[#JNS|BP]]
|-
| [[#JNZ|JNZ/JNE]]
| [[#JNZ|BNZ/BNE]]
|-
| [[#JO|JO]]
| [[#JO|BV]]
|-
| [[#JP|JP]]
| [[#JP|BPE]]
|-
| [[#JS|JS]]
| [[#JS|BN]]
|-
| [[#JZ|JZ/JE]]
| [[#JZ|BZ/BE]]
|-
| [[#LAHF|LAHF]]
| [[#LAHF|MOV]]
|-
| [[#LDS|LDS]]
| [[#LDS|MOV]]
|-
| [[#LEA|LEA]]
| [[#LEA|LDEA]]
|-
| [[#LEAVE|LEAVE]]
| [[#LEAVE|DISPOSE]]
|-
| [[#LES|LES]]
| [[#LES|MOV]]
|-
| [[#LOCK|LOCK]]
| [[#LOCK|BUSLOCK]]
|-
| [[#LODSB|LODSB]]
| [[#LODSB|LDMB]]
|-
| [[#LODSW|LODSW]]
| [[#LODSW|LDMW]]
|-
| [[#LOOP|LOOP]]
| [[#LOOP|DBNZ]]
|-
| [[#LOOPE|LOOPE]]
| [[#LOOPE|DBNZE]]
|-
| [[#LOOPNE|LOOPNE]]
| [[#LOOPNE|DBNZNE]]
|-
| [[#MOV|MOV]]
| [[#MOV|MOV]]
|-
| [[#MOVSB|MOVSB]]
| [[#MOVSB|MOVBKB]]
|-
| [[#MOVSW|MOVSW]]
| [[#MOVSW|MOVBKW]]
|-
| [[#MUL|MUL]]
| [[#MUL|MULU]]
|-
| [[#NEG|NEG]]
| [[#NEG|NEG]]
|-
| [[#NOP|NOP]]
| [[#NOP|NOP]]
|-
| [[#NOT|NOT]]
| [[#NOT|NOT]]
|-
| [[#OR|OR]]
| [[#OR|OR]]
|-
| [[#OUT|OUT]]
| [[#OUT|OUT]]
|-
| [[#OUTSB|OUTSB]]
| [[#OUTSB|OUTM]]
|-
| [[#OUTSW|OUTSW]]
| [[#OUTSW|OUTM]]
|-
| [[#POLL|POLL]]
| [[#POLL|POLL]]
|-
| [[#POP|POP]]
| [[#POP|POP]]
|-
| [[#POPA|POPA]]
| [[#POPA|POP]]
|-
| [[#POPF|POPF]]
| [[#POPF|POP]]
|-
| [[#PUSH|PUSH]]
| [[#PUSH|PUSH]]
|-
| [[#PUSHA|PUSHA]]
| [[#PUSHA|PUSH]]
|-
| [[#PUSHF|PUSHF]]
| [[#PUSHF|PUSH]]
|-
| [[#RCL|RCL]]
| [[#RCL|ROLC]]
|-
| [[#RCR|RCR]]
| [[#RCR|RORC]]
|-
| [[#REP|REP/REPE/REPZ]]
| [[#REP|REP/REPE/REPZ]]
|-
| [[#REPNE|REPNE/REPNZ]]
| [[#REPNE|REPNE/REPNZ]]
|-
| [[#RET|RET]]
| [[#RET|RET]]
|-
| [[#RETF|RETF]]
| [[#RETF|RET]]
|-
| [[#ROL|ROL]]
| [[#ROL|ROL]]
|-
| [[#ROR|ROR]]
| [[#ROR|ROR]]
|-
| [[#SAHF|SAHF]]
| [[#SAHF|MOV]]
|-
| [[#SAR|SAR]]
| [[#SAR|SHRA]]
|-
| [[#SBB|SBB]]
| [[#SBB|SUBC]]
|-
| [[#SCASB|SCASB]]
| [[#SCASB|CMPMB]]
|-
| [[#SCASW|SCASW]]
| [[#SCASW|CMPMW]]
|-
| [[#SHL|SHL]]
| [[#SHL|SHL]]
|-
| [[#SHR|SHR]]
| [[#SHR|SHR]]
|-
| [[#SS|SS]]
| [[#SS|SS]]
|-
| [[#STC|STC]]
| [[#STC|SET1 CY]]
|-
| [[#STD|STD]]
| [[#STD|SET1 DIR]]
|-
| [[#STI|STI]]
| [[#STI|EI]]
|-
| [[#STOSB|STOSB]]
| [[#STOSB|STMB]]
|-
| [[#STOSW|STOSW]]
| [[#STOSW|STMW]]
|-
| [[#SUB|SUB]]
| [[#SUB|SUB]]
|-
| [[#TEST|TEST]]
| [[#TEST|TEST]]
|-
| [[#XCHG|XCHG]]
| [[#XCHG|XCH]]
|-
| [[#XLAT|XLAT]]
| [[#XLAT|TRANS]]
|-
| [[#XOR|XOR]]
| [[#XOR|XOR]]
|}
== Official instructions by type ==
{| class="wikitable sortable" style="text-align: center"
!Type
!colspan=16 class="unsortable" | Instructions
|-
| style="text-align:left;" | Memory
| style="" | [[#MOV|MOV]]
| style="" | [[#XCHG|XCHG]]
| style="" | [[#XLAT|XLAT]]
| style="" | [[#LEA|LEA]]
| style="border-right:none;" | [[#LDS|LDS]]
| style="border-left:none;" | [[#LES|LES]]
| style="border-right:none;" | [[#IN|IN]]
| style="border-left:none;" | [[#OUT|OUT]]
| colspan="8" |
|-
| style="text-align:left;" | Ports
| style="border-right:none;" | [[#IN|IN]]
| style="border-left:none;" | [[#OUT|OUT]]
| style="border-right:none;" | [[#INSB|INSB]]
| style="border-left:none;" | [[#OUTSB|OUTSB]]
| style="border-right:none;" | [[#INSW|INSW]]
| style="border-left:none;" | [[#OUTSW|OUTSW]]
| colspan="10" |
|-
| style="text-align:left;" | Arithmetic
| style="border-right:none;" | [[#ADD|ADD]]
| style="border-left:none;" | [[#SUB|SUB]]
| style="border-right:none;" | [[#ADC|ADC]]
| style="border-left:none;" | [[#SBB|SBB]]
| style="border-right:none;" | [[#INC|INC]]
| style="border-left:none;" | [[#DEC|DEC]]
| style="border-right:none;" | [[#MUL|MUL]]
| style="border-left:none;" | [[#DIV|DIV]]
| style="border-right:none;" | [[#IMUL|IMUL]]
| style="border-left:none;" | [[#IDIV|IDIV]]
| style="" | [[#CMP|CMP]]
| style="" | [[#NEG|NEG]]
| colspan="4" |
|-
| style="text-align:left;" | Numeric
| style="" | [[#CBW|CBW]]
| style="" | [[#CWD|CWD]]
| style="" | [[#AAA|AAA]]
| style="" | [[#AAS|AAS]]
| style="" | [[#AAM|AAM]]
| style="" | [[#AAD|AAD]]
| style="" | [[#DAA|DAA]]
| style="" | [[#DAS|DAS]]
| colspan="8" |
|-
| style="text-align:left;" | Shift
| style="border-right:none;" | [[#ROL|ROL]]
| style="border-left:none;" | [[#ROR|ROR]]
| style="border-right:none;" | [[#RCL|RCL]]
| style="border-left:none;" | [[#RCR|RCR]]
| style="border-right:none;" | [[#SHL|SHL]]
| style="border-left:none;" | [[#SHR|SHR]]
| style="" | [[#SAR|SAR]]
| colspan="9" |
|-
| style="text-align:left;" | Bitwise
| style="" | [[#AND|AND]]
| style="" | [[#OR|OR]]
| style="" | [[#XOR|XOR]]
| style="" | [[#NOT|NOT]]
| style="" | [[#TEST|TEST]]
| colspan="11" |
|-
| style="text-align:left;" | Branch
| style="border-right:none;" | [[#JC|JC]]
| style="border-left:none;" | [[#JNC|JNC]]
| style="border-right:none;" | [[#JZ|JZ]]
| style="border-left:none;" | [[#JNZ|JNZ]]
| style="border-right:none;" | [[#JBE|JBE]]
| style="border-left:none;" | [[#JA|JA]]
| style="border-right:none;" | [[#JO|JO]]
| style="border-left:none;" | [[#JNO|JNO]]
| style="border-right:none;" | [[#JP|JP]]
| style="border-left:none;" | [[#JNP|JNP]]
| style="border-right:none;" | [[#JS|JS]]
| style="border-left:none;" | [[#JNS|JNS]]
| style="border-right:none;" | [[#JL|JL]]
| style="border-left:none;" | [[#JGE|JGE]]
| style="border-right:none;" | [[#JLE|JLE]]
| style="border-left:none;" | [[#JG|JG]]
|-
| style="text-align:left;" | Jump
| style="" | [[#JMP|JMP]]
| style="border-right:none;" | [[#CALL|CALL]]
| style="border-left:none;border-right:none;" | [[#RET|RET]]
| style="border-left:none;" | [[#RETF|RETF]]
| colspan="12" |
|-
| style="text-align:left;" | Loop
| style="" | [[#LOOP|LOOP]]
| style="" | [[#LOOPE|LOOPE]]
| style="" | [[#LOOPNE|LOOPNE]]
| colspan="13" |
|-
| style="text-align:left;" | Interrupt
| style="border-right:none;" | [[#INT|INT]]
| style="border-left:none;" | [[#IRET|IRET]]
| style="" | [[#INTO|INTO]]
| style="" | [[#HLT|HLT]]
| style="" | [[#BOUND|BOUND]]
| colspan="11" |
|-
| style="text-align:left;" | Stack
| style="border-right:none;" | [[#PUSH|PUSH]]
| style="border-left:none;" | [[#POP|POP]]
| style="border-right:none;" | [[#PUSHA|PUSHA]]
| style="border-left:none;" | [[#POPA|POPA]]
| style="border-right:none;" | [[#PUSHF|PUSHF]]
| style="border-left:none;" | [[#POPF|POPF]]
| colspan="10" |
|-
| style="text-align:left;" | Flags
| style="border-right:none;" | [[#CLC|CLC]]
| style="border-left:none;" | [[#STC|STC]]
| style="border-right:none;" | [[#CLD|CLD]]
| style="border-left:none;" | [[#STD|STD]]
| style="border-right:none;" | [[#CLI|CLI]]
| style="border-left:none;" | [[#STI|STI]]
| style="" | [[#CMC|CMC]]
| style="border-right:none;" | [[#LAHF|LAHF]]
| style="border-left:none;" | [[#SAHF|SAHF]]
| colspan="7" |
|-
| style="text-align:left;" | Prefix
| style="" | [[#CS|CS]]
| style="" | [[#DS|DS]]
| style="" | [[#ES|ES]]
| style="" | [[#SS|SS]]
| colspan="12" |
|-
| style="text-align:left;" | String
| style="border-right:none;" | [[#REP|REP]]
| style="border-left:none;border-right:none;" | [[#REP|REPE]]
| style="border-left:none;" | [[#REPNE|REPNE]]
| style="" | [[#MOVSB|MOVSB]]
| style="" | [[#MOVSW|MOVSW]]
| style="border-right:none;" | [[#LODSB|LODSB]]
| style="border-left:none;" | [[#STOSB|STOSB]]
| style="border-right:none;" | [[#LODSW|LODSW]]
| style="border-left:none;" | [[#STOSW|STOSW]]
| style="" | [[#CMPSB|CMPSB]]
| style="" | [[#SCASB|SCASB]]
| style="" | [[#CMPSW|CMPSW]]
| style="" | [[#SCASW|SCASW]]
| colspan="3" |
|-
| style="text-align:left;" | Other
| style="" | [[#NOP|NOP]]
| style="border-right:none;" | [[#ENTER|ENTER]]
| style="border-left:none;" | [[#LEAVE|LEAVE]]
| style="" | [[#LOCK|LOCK]]
| style="" | [[#POLL|POLL]]
| colspan="11" |
|}
== Instruction encoding ==
=== ModR/M byte ===
The ModR/M byte is used in most addressing modes which reference a memory location. This byte consists of three bitfield values:
* <tt>oo</tt> - M'''o'''de;
* <tt>rrr</tt> - Two possible functions:
** '''R'''egister (for addressing modes which require both a register and a register/memory operand),
** Opcode extension (for some opcodes' addressing modes which do not have such a requirement);
* <tt>mmm</tt> - Register/'''M'''emory.
The ''Mode'' and ''Register/Memory'' bitfields can refer to a memory location or to a register, as shown in the table below. In some addressing modes, the ''Register'' field also refers to a register; it is always interpreted as if ''Mode'' was equal to <tt>11</tt>.
{| class="wikitable" style="text-align: center"
! R/M \ Mode
! <tt>00</tt>
! <tt>01</tt>
! <tt>10</tt>
! <tt>11</tt> ''(byte)''
! <tt>11</tt> ''(word)''
|-
| <tt>000</tt>
| DS:[BX + SI]
| DS:[BX + SI + disp8]
| DS:[BX + SI + disp16]
| AL
| AX
|-
| <tt>001</tt>
| DS:[BX + DI]
| DS:[BX + DI + disp8]
| DS:[BX + DI + disp16]
| CL
| CX
|-
| <tt>010</tt>
| SS:[BP + SI]
| SS:[BP + SI + disp8]
| SS:[BP + SI + disp16]
| DL
| DX
|-
| <tt>011</tt>
| SS:[BP + DI]
| SS:[BP + DI + disp8]
| SS:[BP + DI + disp16]
| BL
| BX
|-
| <tt>100</tt>
| DS:[SI]
| DS:[SI + disp8]
| DS:[SI + disp16]
| AH
| SP
|-
| <tt>101</tt>
| DS:[DI]
| DS:[DI + disp8]
| DS:[DI + disp16]
| CH
| BP
|-
| <tt>110</tt>
| ''DS:[disp16]''
| SS:[BP + disp8]
| SS:[BP + disp16]
| DH
| SI
|-
| <tt>111</tt>
| DS:[BX]
| DS:[BX + disp8]
| DS:[BX + disp16]
| BH
| DI
|}
Displacements are either 8-bit (disp8) or 16-bit (disp16) signed values and they always immediately follow the ModR/M byte. Note that (<tt>oo</tt> = <tt>00</tt>, <tt>mmm</tt> = <tt>110</tt>) is a special case, in which the ''disp16'' value is used directly as a near pointer.
The instruction encoding lists below refer to this byte as <tt>oorrrmmm</tt> (binary), <tt>/r</tt> (hexadecimal) or <tt>/0</tt> (hexademical, <tt>rrr</tt> used as function <tt>0</tt>).
== Official instructions ==
{{Anchor|AAA}}
=== AAA ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| AAA || <tt>37</tt> || <tt>00110111</tt> || 1 || 9
|}
----
{{Anchor|AAD}}
=== AAD ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| AAD imm8 || <tt>B5 ii</tt> || <tt>11010100 iiiiiiii</tt> || 2 || 6
|}
----
{{Anchor|AAM}}
=== AAM ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| AAM imm8 || <tt>B4 ii</tt> || <tt>11010100 iiiiiiii</tt> || 2 || 17
|}
----
{{Anchor|AAS}}
=== AAS ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| AAS || <tt>3F</tt> || <tt>00111111</tt> || 1 || 9
|}
----
{{Anchor|ADC}}
=== ADC ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| ADC AL, imm || <tt>14 ii</tt> || <tt>00010100 iiiiiiii</tt> || 2 || 1
|-
| ADC AX, imm || <tt>15 ii ii</tt> || <tt>00010101 iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| ADC mem8, imm8 || <tt>80 /2 ii</tt> || <tt>10000000 oo010mmm iiiiiiii</tt> || 3+ || 3
|-
| ADC mem16, imm16 || <tt>81 /2 ii ii</tt> || <tt>10000001 oo010mmm iiiiiiii iiiiiiii</tt> || 4+ || 3
|-
| ADC mem16, simm8 || <tt>83 /2 ii</tt> || <tt>10000011 oo010mmm iiiiiiii</tt> || 3+ || 3
|-
| ADC mem8, reg8 || <tt>10 /r</tt> || <tt>00010000 oorrrmmm</tt> || 2+ || 3
|-
| ADC mem16, reg16 || <tt>11 /r</tt> || <tt>00010001 oorrrmmm</tt> || 2+ || 3
|-
| ADC reg8, imm8 || <tt>80 /2 ii</tt> || <tt>10000000 11010mmm iiiiiiii</tt> || 3 || 1
|-
| ADC reg16, imm16 || <tt>81 /2 ii ii</tt> || <tt>10000001 11010mmm iiiiiiii iiiiiiii</tt> || 4 || 1
|-
| ADC reg16, simm8 || <tt>83 /2 ii</tt> || <tt>10000011 11010mmm iiiiiiii</tt> || 3 || 1
|-
| ADC reg8, mem8 || <tt>12 /r</tt> || <tt>00010010 oorrrmmm</tt> || 2+ || 2
|-
| ADC reg16, mem16 || <tt>13 /r</tt> || <tt>00010011 oorrrmmm</tt> || 2+ || 2
|-
| ADC reg8, reg8 || <tt>10 /r</tt> || <tt>000100.0 11rrrmmm</tt> || 2 || 1
|-
| ADC reg16, reg16 || <tt>11 /r</tt> || <tt>000100.1 11rrrmmm</tt> || 2 || 1
|}
----
{{Anchor|ADD}}
=== ADD ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| ADD AL, imm || <tt>04 ii</tt> || <tt>00000100 iiiiiiii</tt> || 2 || 1
|-
| ADD AX, imm || <tt>05 ii ii</tt> || <tt>00000101 iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| ADD mem8, imm8 || <tt>80 /0 ii</tt> || <tt>10000000 oo000mmm iiiiiiii</tt> || 3+ || 3
|-
| ADD mem16, imm16 || <tt>81 /0 ii ii</tt> || <tt>10000001 oo000mmm iiiiiiii iiiiiiii</tt> || 4+ || 3
|-
| ADD mem16, simm8 || <tt>83 /0 ii</tt> || <tt>10000011 oo000mmm iiiiiiii</tt> || 3+ || 3
|-
| ADD mem8, reg8 || <tt>00 /r</tt> || <tt>00000000 oorrrmmm</tt> || 2+ || 3
|-
| ADD mem16, reg16 || <tt>01 /r</tt> || <tt>00000001 oorrrmmm</tt> || 2+ || 3
|-
| ADD reg8, imm8 || <tt>80 /0 ii</tt> || <tt>10000000 11000mmm iiiiiiii</tt> || 3 || 1
|-
| ADD reg16, imm16 || <tt>81 /0 ii ii</tt> || <tt>10000001 11000mmm iiiiiiii iiiiiiii</tt> || 4 || 1
|-
| ADD reg16, simm8 || <tt>83 /0 ii</tt> || <tt>10000011 11000mmm iiiiiiii</tt> || 3 || 1
|-
| ADD reg8, mem8 || <tt>02 /r</tt> || <tt>00000010 oorrrmmm</tt> || 2+ || 2
|-
| ADD reg16, mem16 || <tt>03 /r</tt> || <tt>00000011 oorrrmmm</tt> || 2+ || 2
|-
| ADD reg8, reg8 || <tt>00 /r</tt> || <tt>000000.0 11rrrmmm</tt> || 2 || 1
|-
| ADD reg16, reg16 || <tt>01 /r</tt> || <tt>000000.1 11rrrmmm</tt> || 2 || 1
|}
----
{{Anchor|AND}}
=== AND ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| AND AL, imm || <tt>24 ii</tt> || <tt>00100100 iiiiiiii</tt> || 2 || 1
|-
| AND AX, imm || <tt>25 ii ii</tt> || <tt>00100101 iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| AND mem8, imm8 || <tt>80 /4 ii</tt> || <tt>10000000 oo100mmm iiiiiiii</tt> || 3+ || 3
|-
| AND mem16, imm16 || <tt>81 /4 ii ii</tt> || <tt>10000001 oo100mmm iiiiiiii iiiiiiii</tt> || 4+ || 3
|-
| AND mem16, simm8 || <tt>83 /4 ii</tt> || <tt>10000011 oo100mmm iiiiiiii</tt> || 3+ || 3
|-
| AND mem8, reg8 || <tt>20 /r</tt> || <tt>00100000 oorrrmmm</tt> || 2+ || 3
|-
| AND mem16, reg16 || <tt>21 /r</tt> || <tt>00100001 oorrrmmm</tt> || 2+ || 3
|-
| AND reg8, imm8 || <tt>80 /4 ii</tt> || <tt>10000000 11100mmm iiiiiiii</tt> || 3 || 1
|-
| AND reg16, imm16 || <tt>81 /4 ii ii</tt> || <tt>10000001 11100mmm iiiiiiii iiiiiiii</tt> || 4 || 1
|-
| AND reg16, simm8 || <tt>83 /4 ii</tt> || <tt>10000011 11100mmm iiiiiiii</tt> || 3 || 1
|-
| AND reg8, mem8 || <tt>22 /r</tt> || <tt>00100010 oorrrmmm</tt> || 2+ || 2
|-
| AND reg16, mem16 || <tt>23 /r</tt> || <tt>00100011 oorrrmmm</tt> || 2+ || 2
|-
| AND reg8, reg8 || <tt>20 /r</tt> || <tt>001000.0 11rrrmmm</tt> || 2 || 1
|-
| AND reg16, reg16 || <tt>21 /r</tt> || <tt>001000.1 11rrrmmm</tt> || 2 || 1
|}
----
{{Anchor|BOUND}}
=== BOUND ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| BOUND reg16, mem16:16 || <tt>62 /r</tt> || <tt>01100010 oorrrmmm</tt> || 2+ || 13 (20 if condition met)
|}
----
{{Anchor|CALL}}
=== CALL ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| CALL ptr16:16 || <tt>CA oo oo ss ss</tt> || <tt>10011010 oooooooo oooooooo ssssssss ssssssss</tt> || 5 || 10
|-
| CALL mem16 || <tt>FF /2</tt> || <tt>11111111 oo010mmm</tt> || 2+ || 6
|-
| CALL mem16:16 || <tt>FF /3</tt> || <tt>11111111 oo011mmm</tt> || 2+ || 12
|-
| CALL reg16 || <tt>FF /2</tt> || <tt>11111111 11010mmm</tt> || 2 || 5
|-
| CALL rel16 || <tt>E8 ii ii</tt> || <tt>11101000 iiiiiiii iiiiiiii</tt> || 3 || 5
|}
----
{{Anchor|CBW}}
=== CBW ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| CBW || <tt>98</tt> || <tt>10011000</tt> || 1 || 1
|}
----
{{Anchor|CLC}}
=== CLC ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| CLC || <tt>F8</tt> || <tt>11111000</tt> || 1 || 4
|}
----
{{Anchor|CLD}}
=== CLD ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| CLD || <tt>FC</tt> || <tt>11111100</tt> || 1 || 4
|}
----
{{Anchor|CLI}}
=== CLI ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| CLI || <tt>FA</tt> || <tt>11111010</tt> || 1 || 4
|}
----
{{Anchor|CMC}}
=== CMC ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| CMC || <tt>F5</tt> || <tt>11110101</tt> || 1 || 4
|}
----
{{Anchor|CMP}}
=== CMP ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| CMP AL, imm || <tt>3C ii</tt> || <tt>00111100 iiiiiiii</tt> || 2 || 1
|-
| CMP AX, imm || <tt>3D ii ii</tt> || <tt>00111101 iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| CMP mem8, imm8 || <tt>80 /7 ii</tt> || <tt>10000000 oo111mmm iiiiiiii</tt> || 3+ || 2
|-
| CMP mem16, imm16 || <tt>81 /7 ii ii</tt> || <tt>10000001 oo111mmm iiiiiiii iiiiiiii</tt> || 4+ || 2
|-
| CMP mem16, simm8 || <tt>83 /7 ii</tt> || <tt>10000011 oo111mmm iiiiiiii</tt> || 3+ || 2
|-
| CMP mem8, reg8 || <tt>38 /r</tt> || <tt>00111000 oorrrmmm</tt> || 2+ || 2
|-
| CMP mem16, reg16 || <tt>39 /r</tt> || <tt>00111001 oorrrmmm</tt> || 2+ || 2
|-
| CMP reg8, imm8 || <tt>80 /7 ii</tt> || <tt>10000000 11111mmm iiiiiiii</tt> || 3 || 1
|-
| CMP reg16, imm16 || <tt>81 /7 ii ii</tt> || <tt>10000001 11111mmm iiiiiiii iiiiiiii</tt> || 4 || 1
|-
| CMP reg16, simm8 || <tt>83 /7 ii</tt> || <tt>10000011 11111mmm iiiiiiii</tt> || 3 || 1
|-
| CMP reg8, mem8 || <tt>3A /r</tt> || <tt>00111010 oorrrmmm</tt> || 2+ || 2
|-
| CMP reg16, mem16 || <tt>3B /r</tt> || <tt>00111011 oorrrmmm</tt> || 2+ || 2
|-
| CMP reg8, reg8 || <tt>38 /r</tt> || <tt>001110.0 11rrrmmm</tt> || 2 || 1
|-
| CMP reg16, reg16 || <tt>39 /r</tt> || <tt>001110.1 11rrrmmm</tt> || 2 || 1
|}
----
{{Anchor|CMPSB}}
{{Anchor|CMPSW}}
=== CMPSB/CMPSW ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| CMPSB || <tt>A6</tt> || <tt>10100110</tt> || 1 || 6
|-
| CMPSW || <tt>A7</tt> || <tt>10100111</tt> || 1 || 6
|}
----
{{Anchor|CS}}
=== CS ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| CS || <tt>2E</tt> || <tt>00101110</tt> || 1 || 1
|}
----
{{Anchor|CWD}}
=== CWD ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| CWD || <tt>99</tt> || <tt>10011001</tt> || 1 || 1
|}
----
{{Anchor|DAA}}
=== DAA ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| DAA || <tt>27</tt> || <tt>00100111</tt> || 1 || 10
|}
----
{{Anchor|DAS}}
=== DAS ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| DAS || <tt>2F</tt> || <tt>00101111</tt> || 1 || 10
|}
----
{{Anchor|DEC}}
=== DEC ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| DEC mem8 || <tt>FE /1</tt> || <tt>11111110 oo001mmm</tt> || 2+ || 3
|-
| DEC mem16 || <tt>FF /1</tt> || <tt>11111111 oo001mmm</tt> || 2+ || 3
|-
| DEC reg8 || <tt>FE /1</tt> || <tt>11111110 11001mmm</tt> || 2+ || 1
|-
| DEC reg16 || <tt>4x</tt> || <tt>01001rrr</tt> || 1 || 1
|}
----
{{Anchor|DIV}}
=== DIV ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| DIV mem8 || <tt>F6 /6</tt> || <tt>11110110 oo110mmm</tt> || 2+ || 16
|-
| DIV mem16 || <tt>F7 /6</tt> || <tt>11111111 oo110mmm</tt> || 2+ || 24
|-
| DIV reg8 || <tt>F6 /6</tt> || <tt>11111110 11110mmm</tt> || 2 || 15
|-
| DIV reg16 || <tt>F7 /6</tt> || <tt>11111111 11110mmm</tt> || 2 || 23
|}
----
{{Anchor|DS}}
=== DS ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| DS || <tt>3E</tt> || <tt>00111110</tt> || 1 || 1
|}
----
{{Anchor|ENTER}}
=== ENTER ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| ENTER imm16, imm8 || <tt>C8 ii ii jj</tt> || <tt>11001000 iiiiiiii iiiiiiii jjjjjjjj</tt> || 3 || 8 (imm8 = 0)<br/>14 (imm8 = 1)<br/>15 + imm8 * 4 (imm8 >= 2)
|}
----
{{Anchor|ES}}
=== ES ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| ES || <tt>26</tt> || <tt>00100110</tt> || 1 || 1
|}
----
{{Anchor|HLT}}
=== HLT ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| HLT || <tt>F4</tt> || <tt>11110100</tt> || 1 || 9
|}
----
{{Anchor|IDIV}}
=== IDIV ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| IDIV mem8 || <tt>F6 /7</tt> || <tt>11110110 oo111mmm</tt> || 2+ || 18
|-
| IDIV mem16 || <tt>F7 /7</tt> || <tt>11111111 oo111mmm</tt> || 2+ || 25
|-
| IDIV reg8 || <tt>F6 /7</tt> || <tt>11111110 11111mmm</tt> || 2 || 17
|-
| IDIV reg16 || <tt>F7 /7</tt> || <tt>11111111 11111mmm</tt> || 2 || 24
|}
----
{{Anchor|IMUL}}
=== IMUL ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| IMUL mem8 || <tt>F6 /5</tt> || <tt>11110110 oo101mmm</tt> || 2+ || 4
|-
| IMUL mem16 || <tt>F7 /5</tt> || <tt>11111111 oo101mmm</tt> || 2+ || 4
|-
| IMUL reg8 || <tt>F6 /5</tt> || <tt>11111110 11101mmm</tt> || 2 || 3
|-
| IMUL reg16 || <tt>F7 /5</tt> || <tt>11111111 11101mmm</tt> || 2 || 3
|-
| IMUL reg16, mem16, imm16 || <tt>69 /r ii ii</tt> || <tt>11111111 oorrrmmm iiiiiiii iiiiiiii</tt> || 4 || 4
|-
| IMUL reg16, mem16, simm8 || <tt>6B /r ii</tt> || <tt>11111111 oorrrmmm iiiiiiii</tt> || 3 || 4
|-
| IMUL reg16, reg16, imm16 || <tt>69 /r ii ii</tt> || <tt>11111111 11rrrmmm iiiiiiii iiiiiiii</tt> || 4 || 3
|-
| IMUL reg16, reg16, simm8 || <tt>6B /r ii</tt> || <tt>11111111 11rrrmmm iiiiiiii</tt> || 3 || 3
|}
----
{{Anchor|IN}}
=== IN ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| IN AL, DX || <tt>EC</tt> || <tt>11101100</tt> || 1 || 6
|-
| IN AX, DX || <tt>ED</tt> || <tt>11101101</tt> || 1 || 6
|-
| IN AL, imm8 || <tt>E4 ii</tt> || <tt>11100100 iiiiiiii</tt> || 2 || 6
|-
| IN AX, imm8 || <tt>E5 ii</tt> || <tt>11100101 iiiiiiii</tt> || 2 || 6
|}
----
{{Anchor|INC}}
=== INC ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| INC mem8 || <tt>FE /0</tt> || <tt>11111110 oo000mmm</tt> || 2+ || 3
|-
| INC mem16 || <tt>FF /0</tt> || <tt>11111111 oo000mmm</tt> || 2+ || 3
|-
| INC reg8 || <tt>FE /0</tt> || <tt>11111110 11000mmm</tt> || 2+ || 1
|-
| INC reg16 || <tt>4x</tt> || <tt>01000rrr</tt> || 1 || 1
|}
----
{{Anchor|INSB}}
{{Anchor|INSW}}
=== INSB/INSW ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| INSB || <tt>6C</tt> || <tt>01101100</tt> || 1 || 6
|-
| INSW || <tt>6D</tt> || <tt>01101101</tt> || 1 || 6
|}
----
{{Anchor|INT}}
=== INT ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| INT 3 || <tt>CC</tt> || <tt>11001100</tt> || 1 || 9
|-
| INT imm8 || <tt>CD ii</tt> || <tt>11001101 iiiiiiii</tt> || 2 || 10
|}
----
{{Anchor|INTO}}
=== INTO ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| INTO || <tt>CE</tt> || <tt>11001110</tt> || 1 || 6 (13 if OF = 1)
|}
----
{{Anchor|IRET}}
=== IRET ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| IRET || <tt>CF</tt> || <tt>11001111</tt> || 1 || 10
|}
----
{{Anchor|JA}}
=== JA ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JA rel8 || <tt>77 ii</tt> || <tt>01110111 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JBE}}
=== JBE ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JA rel8 || <tt>76 ii</tt> || <tt>01110110 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JC}}
=== JC/JB ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JC rel8 || <tt>72 ii</tt> || <tt>01110010 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JCXZ}}
=== JCXZ ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JCXZ rel8 || <tt>E3 ii</tt> || <tt>11100011 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JG}}
=== JG ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JG rel8 || <tt>7F ii</tt> || <tt>01111111 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JGE}}
=== JGE ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JGE rel8 || <tt>7D ii</tt> || <tt>01111101 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JL}}
=== JL ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JL rel8 || <tt>7C ii</tt> || <tt>01111100 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JLE}}
=== JLE ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JLE rel8 || <tt>7E ii</tt> || <tt>01111110 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JMP}}
=== JMP ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JMP ptr16:16 || <tt>EA oo oo ss ss</tt> || <tt>11101010 oooooooo oooooooo ssssssss ssssssss</tt> || 5 || 7
|-
| JMP mem16 || <tt>FF /4</tt> || <tt>11111111 oo100mmm</tt> || 2+ || 5
|-
| JMP mem16:16 || <tt>FF /5</tt> || <tt>11111111 oo101mmm</tt> || 2+ || 10
|-
| JMP reg16 || <tt>FF /4</tt> || <tt>11111111 11100mmm</tt> || 2 || 4
|-
| JMP rel8 || <tt>EB ii</tt> || <tt>11101011 iiiiiiii</tt> || 2 || 4
|-
| JMP rel16 || <tt>E9 ii ii</tt> || <tt>11101001 iiiiiiii iiiiiiii</tt> || 3 || 4
|}
----
{{Anchor|JNC}}
=== JNC/JAE ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JNC rel8 || <tt>73 ii</tt> || <tt>01110011 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JNO}}
=== JNO ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JNO rel8 || <tt>71 ii</tt> || <tt>01110001 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JNP}}
=== JNP ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JNP rel8 || <tt>7B ii</tt> || <tt>01111011 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JNS}}
=== JNS ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JNS rel8 || <tt>79 ii</tt> || <tt>01111001 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JNZ}}
=== JNZ/JNE ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JNZ rel8 || <tt>75 ii</tt> || <tt>01110101 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JO}}
=== JO ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JO rel8 || <tt>70 ii</tt> || <tt>01110000 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JP}}
=== JP ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JP rel8 || <tt>7A ii</tt> || <tt>01111010 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JS}}
=== JS ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JS rel8 || <tt>78 ii</tt> || <tt>01111000 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JZ}}
=== JZ/JE ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JZ rel8 || <tt>74 ii</tt> || <tt>01110100 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|LAHF}}
=== LAHF ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| LAHF || <tt>9F</tt> || <tt>10011111</tt> || 1 || 2
|}
----
{{Anchor|LDS}}
=== LDS ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| LDS reg16, mem16 || <tt>C5 /r</tt> || <tt>11000101 oorrrmmm</tt> || 2+ || 6
|}
----
{{Anchor|LEA}}
=== LEA ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| LEA reg16, mem16 || <tt>8D /r</tt> || <tt>10001101 oorrrmmm</tt> || 2+ || 1
|}
----
{{Anchor|LEAVE}}
=== LEAVE ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| LEAVE || <tt>C9</tt> || <tt>11001001</tt> || 1 || 2
|}
----
{{Anchor|LES}}
=== LES ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| LES reg16, mem16 || <tt>C4 /r</tt> || <tt>11000100 oorrrmmm</tt> || 2+ || 6
|}
----
{{Anchor|LOCK}}
=== LOCK ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| LOCK || <tt>F0</tt> || <tt>11110000</tt> || 1 || 1
|}
----
{{Anchor|LODSB}}
{{Anchor|LODSW}}
=== LODSB/LODSW ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| LODSB || <tt>AC</tt> || <tt>10101100</tt> || 1 || 3
|-
| LODSW || <tt>AD</tt> || <tt>10101101</tt> || 1 || 3
|}
----
{{Anchor|LOOP}}
=== LOOP ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| LOOP rel8 || <tt>E2 ii</tt> || <tt>11100010 iiiiiiii</tt> || 2 || 2 (5 if branch taken)
|}
----
{{Anchor|LOOPE}}
=== LOOPE ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| LOOPE rel8 || <tt>E1 ii</tt> || <tt>11100001 iiiiiiii</tt> || 2 || 3 (6 if branch taken)
|}
----
{{Anchor|LOOPNE}}
=== LOOPNE ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| LOOPNE rel8 || <tt>E0 ii</tt> || <tt>11100000 iiiiiiii</tt> || 2 || 3 (6 if branch taken)
|}
----
{{Anchor|MOV}}
=== MOV ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| MOV AL, ptr16 || <tt>A0 ii ii</tt> || <tt>10100000 iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| MOV AX, ptr16 || <tt>A1 ii ii</tt> || <tt>10100001 iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| MOV mem8, imm8 || <tt>C6 /0 ii</tt> || <tt>11000110 oo000mmm iiiiiiii</tt> || 3+ || 1
|-
| MOV mem16, imm16 || <tt>C7 /0 ii ii</tt> || <tt>11000111 oo000mmm iiiiiiii iiiiiiii</tt> || 4+ || 1
|-
| MOV mem8, reg8 || <tt>84 /r</tt> || <tt>10001000 oorrrmmm</tt> || 2+ || 1
|-
| MOV mem16, reg16 || <tt>85 /r</tt> || <tt>10001001 oorrrmmm</tt> || 2+ || 1
|-
| MOV mem16, sreg16 || <tt>8C /r</tt> || <tt>10001100 oo0rrmmm</tt> || 2+ || 3
|-
| MOV ptr16, AL || <tt>A2 ii ii</tt> || <tt>10100010 iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| MOV ptr16, AX || <tt>A3 ii ii</tt> || <tt>10100011 iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| MOV reg8, imm8 || <tt>Bx ii</tt> || <tt>10110rrr iiiiiiii</tt> || 2 || 1
|-
| MOV reg8, imm8 || <tt>C6 /0 ii</tt> || <tt>11000110 11000mmm iiiiiiii</tt> || 3 || 1
|-
| MOV reg16, imm16 || <tt>Bx ii</tt> || <tt>10111rrr iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| MOV reg16, imm16 || <tt>C7 /0 ii ii</tt> || <tt>11000111 11000mmm iiiiiiii iiiiiiii</tt> || 4 || 1
|-
| MOV reg8, mem8 || <tt>8A /r</tt> || <tt>10001010 oorrrmmm</tt> || 2+ || 1
|-
| MOV reg16, mem16 || <tt>8B /r</tt> || <tt>10001011 oorrrmmm</tt> || 2+ || 1
|-
| MOV reg8, reg8 || <tt>88 /r</tt> || <tt>100010.0 11rrrmmm</tt> || 2 || 1
|-
| MOV reg16, reg16 || <tt>89 /r</tt> || <tt>100010.1 11rrrmmm</tt> || 2 || 1
|-
| MOV reg16, sreg16 || <tt>8C /r</tt> || <tt>10001100 110rrmmm</tt> || 2 || 1
|-
| MOV sreg16, mem16 || <tt>8E /r</tt> || <tt>10001110 oo0rrmmm</tt> || 2 || 3
|-
| MOV sreg16, reg16 || <tt>8E /r</tt> || <tt>10001110 110rrmmm</tt> || 2+ || 2
|}
----
{{Anchor|MOVSB}}
{{Anchor|MOVSW}}
=== MOVSB/MOVSW ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| MOVSB || <tt>A4</tt> || <tt>10100100</tt> || 1 || 5
|-
| MOVSW || <tt>A5</tt> || <tt>10100101</tt> || 1 || 5
|}
----
{{Anchor|MUL}}
=== MUL ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| MUL mem8 || <tt>F6 /4</tt> || <tt>11110110 oo100mmm</tt> || 2+ || 4
|-
| MUL mem16 || <tt>F7 /4</tt> || <tt>11111111 oo100mmm</tt> || 2+ || 4
|-
| MUL reg8 || <tt>F6 /4</tt> || <tt>11111110 11100mmm</tt> || 2 || 3
|-
| MUL reg16 || <tt>F7 /4</tt> || <tt>11111111 11100mmm</tt> || 2 || 3
|}
----
{{Anchor|NEG}}
=== NEG ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| NEG mem8 || <tt>F6 /3</tt> || <tt>11110110 oo011mmm</tt> || 2+ || 3
|-
| NEG mem16 || <tt>F7 /3</tt> || <tt>11111111 oo011mmm</tt> || 2+ || 3
|-
| NEG reg8 || <tt>F6 /3</tt> || <tt>11111110 11011mmm</tt> || 2 || 1
|-
| NEG reg16 || <tt>F7 /3</tt> || <tt>11111111 11011mmm</tt> || 2 || 1
|}
----
{{Anchor|NOP}}
=== NOP ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| NOP || <tt>90</tt> || <tt>10010000</tt> || 1 || 1
|}
----
{{Anchor|NOT}}
=== NOT ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| NOT mem8 || <tt>F6 /2</tt> || <tt>11110110 oo010mmm</tt> || 2+ || 3
|-
| NOT mem16 || <tt>F7 /2</tt> || <tt>11111111 oo010mmm</tt> || 2+ || 3
|-
| NOT reg8 || <tt>F6 /2</tt> || <tt>11111110 11010mmm</tt> || 2 || 1
|-
| NOT reg16 || <tt>F7 /2</tt> || <tt>11111111 11010mmm</tt> || 2 || 1
|}
----
{{Anchor|OR}}
=== OR ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| OR AL, imm || <tt>0C ii</tt> || <tt>00001100 iiiiiiii</tt> || 2 || 1
|-
| OR AX, imm || <tt>0D ii ii</tt> || <tt>00001101 iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| OR mem8, imm8 || <tt>80 /6 ii</tt> || <tt>10000000 oo001mmm iiiiiiii</tt> || 3+ || 3
|-
| OR mem16, imm16 || <tt>81 /6 ii ii</tt> || <tt>10000001 oo001mmm iiiiiiii iiiiiiii</tt> || 4+ || 3
|-
| OR mem16, simm8 || <tt>83 /6 ii</tt> || <tt>10000011 oo001mmm iiiiiiii</tt> || 3+ || 3
|-
| OR mem8, reg8 || <tt>08 /r</tt> || <tt>00001000 oorrrmmm</tt> || 2+ || 3
|-
| OR mem16, reg16 || <tt>09 /r</tt> || <tt>00001001 oorrrmmm</tt> || 2+ || 3
|-
| OR reg8, imm8 || <tt>80 /6 ii</tt> || <tt>10000000 11001mmm iiiiiiii</tt> || 3 || 1
|-
| OR reg16, imm16 || <tt>81 /6 ii ii</tt> || <tt>10000001 11001mmm iiiiiiii iiiiiiii</tt> || 4 || 1
|-
| OR reg16, simm8 || <tt>83 /6 ii</tt> || <tt>10000011 11001mmm iiiiiiii</tt> || 3 || 1
|-
| OR reg8, mem8 || <tt>0A /r</tt> || <tt>00001010 oorrrmmm</tt> || 2+ || 2
|-
| OR reg16, mem16 || <tt>0B /r</tt> || <tt>00001011 oorrrmmm</tt> || 2+ || 2
|-
| OR reg8, reg8 || <tt>08 /r</tt> || <tt>000010.0 11rrrmmm</tt> || 2 || 1
|-
| OR reg16, reg16 || <tt>09 /r</tt> || <tt>000010.1 11rrrmmm</tt> || 2 || 1
|}
----
{{Anchor|OUT}}
=== OUT ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| OUT AL, DX || <tt>EE</tt> || <tt>11101110</tt> || 1 || 6
|-
| OUT AX, DX || <tt>EF</tt> || <tt>11101111</tt> || 1 || 6
|-
| OUT AL, imm8 || <tt>E6 ii</tt> || <tt>11100110 iiiiiiii</tt> || 2 || 6
|-
| OUT AX, imm8 || <tt>E7 ii</tt> || <tt>11100111 iiiiiiii</tt> || 2 || 6
|}
----
{{Anchor|OUTSB}}
{{Anchor|OUTSW}}
=== OUTSB/OUTSW ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| OUTSB || <tt>6E</tt> || <tt>01101110</tt> || 1 || 6
|-
| OUTSW || <tt>6F</tt> || <tt>01101111</tt> || 1 || 6
|}
----
{{Anchor|POLL}}
=== POLL ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| POLL || <tt>6E</tt> || <tt>01101110</tt> || 1 || 9<ref>On the WonderSwan implementation, POLLB is always held low; on other implementations, POLL will wait for POLLB to be held low in 9-cycle intervals.</ref>
|}
----
{{Anchor|POP}}
=== POP ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| POP mem16 || <tt>8F /0</tt> || <tt>10001111 oo000mmm</tt> || 2+ || 3
|-
| POP reg16 || <tt>5x</tt> || <tt>01011xxx</tt> || 1 || 1
|-
| POP reg16 || <tt>8F /0</tt> || <tt>10001111 11000mmm</tt> || 2 || 1
|-
| POP sreg16 || <tt>xx</tt> || <tt>000xx111</tt> || 1 || 3
|}
----
{{Anchor|POPA}}
=== POPA ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| POPA || <tt>61</tt> || <tt>01100001</tt> || 1 || 8
|}
----
{{Anchor|POPF}}
=== POPF ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| POPF || <tt>9D</tt> || <tt>10011101</tt> || 1 || 3
|}
----
{{Anchor|PUSH}}
=== PUSH ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| PUSH imm8 || <tt>6A ii</tt> || <tt>01101010 iiiiiiii</tt> || 2 || 1
|-
| PUSH imm16 || <tt>68 ii ii</tt> || <tt>01101000 iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| PUSH mem16 || <tt>FF /6</tt> || <tt>11111111 oo110mmm</tt> || 2+ || 2
|-
| PUSH reg16 || <tt>5x</tt> || <tt>01010xxx</tt> || 1 || 1
|-
| PUSH reg16 || <tt>FF /6</tt> || <tt>11111111 11110mmm</tt> || 2 || 1
|-
| PUSH sreg16 || <tt>xx</tt> || <tt>000xx110</tt> || 1 || 2
|}
----
{{Anchor|PUSHA}}
=== PUSHA ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| PUSHA || <tt>60</tt> || <tt>01100000</tt> || 1 || 9
|}
----
{{Anchor|PUSHF}}
=== PUSHF ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| PUSHF || <tt>9C</tt> || <tt>10011100</tt> || 1 || 2
|}
----
{{Anchor|RCL}}
=== RCL ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| RCL mem8, 1 || <tt>D0 /2</tt> || <tt>11010000 oo010rm</tt> || 2+ || 3
|-
| RCL mem8, CL || <tt>D2 /2</tt> || <tt>11010010 oo010rm</tt> || 2+ || 5
|-
| RCL mem8, imm8 || <tt>C0 /2 ii</tt> || <tt>11000000 oo010mmm iiiiiiii</tt> || 3+ || 5
|-
| RCL mem16, 1 || <tt>D1 /2</tt> || <tt>11010001 oo010rm</tt> || 2+ || 3
|-
| RCL mem16, CL || <tt>D3 /2</tt> || <tt>11010011 oo010rm</tt> || 2+ || 5
|-
| RCL mem16, imm8 || <tt>C1 /2 ii</tt> || <tt>11000001 oo010mmm iiiiiiii</tt> || 3+ || 5
|-
| RCL reg8, 1 || <tt>D0 /2</tt> || <tt>11010000 11010rm</tt> || 2 || 1
|-
| RCL reg8, CL || <tt>D2 /2</tt> || <tt>11010010 11010rm</tt> || 2 || 3
|-
| RCL reg8, imm8 || <tt>C0 /2 ii</tt> || <tt>11000000 11010mmm iiiiiiii</tt> || 3 || 3
|-
| RCL reg16, 1 || <tt>D1 /2</tt> || <tt>11010001 11010rm</tt> || 2 || 1
|-
| RCL reg16, CL || <tt>D3 /2</tt> || <tt>11010011 11010rm</tt> || 2 || 3
|-
| RCL reg16, imm8 || <tt>C1 /2 ii</tt> || <tt>11000001 11010mmm iiiiiiii</tt> || 3 || 3
|}
----
{{Anchor|RCR}}
=== RCR ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| RCR mem8, 1 || <tt>D0 /3</tt> || <tt>11010000 oo011rm</tt> || 2+ || 3
|-
| RCR mem8, CL || <tt>D2 /3</tt> || <tt>11010010 oo011rm</tt> || 2+ || 5
|-
| RCR mem8, imm8 || <tt>C0 /3 ii</tt> || <tt>11000000 oo011mmm iiiiiiii</tt> || 3+ || 5
|-
| RCR mem16, 1 || <tt>D1 /3</tt> || <tt>11010001 oo011rm</tt> || 2+ || 3
|-
| RCR mem16, CL || <tt>D3 /3</tt> || <tt>11010011 oo011rm</tt> || 2+ || 5
|-
| RCR mem16, imm8 || <tt>C1 /3 ii</tt> || <tt>11000001 oo011mmm iiiiiiii</tt> || 3+ || 5
|-
| RCR reg8, 1 || <tt>D0 /3</tt> || <tt>11010000 11011rm</tt> || 2 || 1
|-
| RCR reg8, CL || <tt>D2 /3</tt> || <tt>11010010 11011rm</tt> || 2 || 3
|-
| RCR reg8, imm8 || <tt>C0 /3 ii</tt> || <tt>11000000 11011mmm iiiiiiii</tt> || 3 || 3
|-
| RCR reg16, 1 || <tt>D1 /3</tt> || <tt>11010001 11011rm</tt> || 2 || 1
|-
| RCR reg16, CL || <tt>D3 /3</tt> || <tt>11010011 11011rm</tt> || 2 || 3
|-
| RCR reg16, imm8 || <tt>C1 /3 ii</tt> || <tt>11000001 11011mmm iiiiiiii</tt> || 3 || 3
|}
----
{{Anchor|REP}}
=== REP/REPE/REPZ ===
----
{{Anchor|REPNE}}
=== REPNE/REPNZ ===
----
{{Anchor|RET}}
=== RET ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| RET || <tt>C3</tt> || <tt>11000011</tt> || 1 || 6
|-
| RET imm16 || <tt>C2 ii ii</tt> || <tt>11000010 iiiiiiii iiiiiiii</tt> || 1 || 6
|}
----
{{Anchor|RETF}}
=== RETF ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| RETF || <tt>CB</tt> || <tt>11001011</tt> || 1 || 9
|-
| RETF imm16 || <tt>CA ii ii</tt> || <tt>11001010 iiiiiiii iiiiiiii</tt> || 1 || 8
|}
----
{{Anchor|ROL}}
=== ROL ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| ROL mem8, 1 || <tt>D0 /0</tt> || <tt>11010000 oo000rm</tt> || 2+ || 3
|-
| ROL mem8, CL || <tt>D2 /0</tt> || <tt>11010010 oo000rm</tt> || 2+ || 5
|-
| ROL mem8, imm8 || <tt>C0 /0 ii</tt> || <tt>11000000 oo000mmm iiiiiiii</tt> || 3+ || 5
|-
| ROL mem16, 1 || <tt>D1 /0</tt> || <tt>11010001 oo000rm</tt> || 2+ || 3
|-
| ROL mem16, CL || <tt>D3 /0</tt> || <tt>11010011 oo000rm</tt> || 2+ || 5
|-
| ROL mem16, imm8 || <tt>C1 /0 ii</tt> || <tt>11000001 oo000mmm iiiiiiii</tt> || 3+ || 5
|-
| ROL reg8, 1 || <tt>D0 /0</tt> || <tt>11010000 11000rm</tt> || 2 || 1
|-
| ROL reg8, CL || <tt>D2 /0</tt> || <tt>11010010 11000rm</tt> || 2 || 3
|-
| ROL reg8, imm8 || <tt>C0 /0 ii</tt> || <tt>11000000 11000mmm iiiiiiii</tt> || 3 || 3
|-
| ROL reg16, 1 || <tt>D1 /0</tt> || <tt>11010001 11000rm</tt> || 2 || 1
|-
| ROL reg16, CL || <tt>D3 /0</tt> || <tt>11010011 11000rm</tt> || 2 || 3
|-
| ROL reg16, imm8 || <tt>C1 /0 ii</tt> || <tt>11000001 11000mmm iiiiiiii</tt> || 3 || 3
|}
----
{{Anchor|ROR}}
=== ROR ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| ROR mem8, 1 || <tt>D0 /1</tt> || <tt>11010000 oo001rm</tt> || 2+ || 3
|-
| ROR mem8, CL || <tt>D2 /1</tt> || <tt>11010010 oo001rm</tt> || 2+ || 5
|-
| ROR mem8, imm8 || <tt>C0 /1 ii</tt> || <tt>11000000 oo001mmm iiiiiiii</tt> || 3+ || 5
|-
| ROR mem16, 1 || <tt>D1 /1</tt> || <tt>11010001 oo001rm</tt> || 2+ || 3
|-
| ROR mem16, CL || <tt>D3 /1</tt> || <tt>11010011 oo001rm</tt> || 2+ || 5
|-
| ROR mem16, imm8 || <tt>C1 /1 ii</tt> || <tt>11000001 oo001mmm iiiiiiii</tt> || 3+ || 5
|-
| ROR reg8, 1 || <tt>D0 /1</tt> || <tt>11010000 11001rm</tt> || 2 || 1
|-
| ROR reg8, CL || <tt>D2 /1</tt> || <tt>11010010 11001rm</tt> || 2 || 3
|-
| ROR reg8, imm8 || <tt>C0 /1 ii</tt> || <tt>11000000 11001mmm iiiiiiii</tt> || 3 || 3
|-
| ROR reg16, 1 || <tt>D1 /1</tt> || <tt>11010001 11001rm</tt> || 2 || 1
|-
| ROR reg16, CL || <tt>D3 /1</tt> || <tt>11010011 11001rm</tt> || 2 || 3
|-
| ROR reg16, imm8 || <tt>C1 /1 ii</tt> || <tt>11000001 11001mmm iiiiiiii</tt> || 3 || 3
|}
----
{{Anchor|SAHF}}
=== SAHF ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| SAHF || <tt>9E</tt> || <tt>10011110</tt> || 1 || 4
|}
----
{{Anchor|SAR}}
=== SAR ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| SAR mem8, 1 || <tt>D0 /7</tt> || <tt>11010000 oo111rm</tt> || 2+ || 3
|-
| SAR mem8, CL || <tt>D2 /7</tt> || <tt>11010010 oo111rm</tt> || 2+ || 5
|-
| SAR mem8, imm8 || <tt>C0 /7 ii</tt> || <tt>11000000 oo111mmm iiiiiiii</tt> || 3+ || 5
|-
| SAR mem16, 1 || <tt>D1 /7</tt> || <tt>11010001 oo111rm</tt> || 2+ || 3
|-
| SAR mem16, CL || <tt>D3 /7</tt> || <tt>11010011 oo111rm</tt> || 2+ || 5
|-
| SAR mem16, imm8 || <tt>C1 /7 ii</tt> || <tt>11000001 oo111mmm iiiiiiii</tt> || 3+ || 5
|-
| SAR reg8, 1 || <tt>D0 /7</tt> || <tt>11010000 11111rm</tt> || 2 || 1
|-
| SAR reg8, CL || <tt>D2 /7</tt> || <tt>11010010 11111rm</tt> || 2 || 3
|-
| SAR reg8, imm8 || <tt>C0 /7 ii</tt> || <tt>11000000 11111mmm iiiiiiii</tt> || 3 || 3
|-
| SAR reg16, 1 || <tt>D1 /7</tt> || <tt>11010001 11111rm</tt> || 2 || 1
|-
| SAR reg16, CL || <tt>D3 /7</tt> || <tt>11010011 11111rm</tt> || 2 || 3
|-
| SAR reg16, imm8 || <tt>C1 /7 ii</tt> || <tt>11000001 11111mmm iiiiiiii</tt> || 3 || 3
|}
----
{{Anchor|SBB}}
=== SBB ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| SBB AL, imm || <tt>1C ii</tt> || <tt>00011100 iiiiiiii</tt> || 2 || 1
|-
| SBB AX, imm || <tt>1D ii ii</tt> || <tt>00011101 iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| SBB mem8, imm8 || <tt>80 /3 ii</tt> || <tt>10000000 oo011mmm iiiiiiii</tt> || 3+ || 3
|-
| SBB mem16, imm16 || <tt>81 /3 ii ii</tt> || <tt>10000001 oo011mmm iiiiiiii iiiiiiii</tt> || 4+ || 3
|-
| SBB mem16, simm8 || <tt>83 /3 ii</tt> || <tt>10000011 oo011mmm iiiiiiii</tt> || 3+ || 3
|-
| SBB mem8, reg8 || <tt>18 /r</tt> || <tt>00011000 oorrrmmm</tt> || 2+ || 3
|-
| SBB mem16, reg16 || <tt>19 /r</tt> || <tt>00011001 oorrrmmm</tt> || 2+ || 3
|-
| SBB reg8, imm8 || <tt>80 /3 ii</tt> || <tt>10000000 11011mmm iiiiiiii</tt> || 3 || 1
|-
| SBB reg16, imm16 || <tt>81 /3 ii ii</tt> || <tt>10000001 11011mmm iiiiiiii iiiiiiii</tt> || 4 || 1
|-
| SBB reg16, simm8 || <tt>83 /3 ii</tt> || <tt>10000011 11011mmm iiiiiiii</tt> || 3 || 1
|-
| SBB reg8, mem8 || <tt>1A /r</tt> || <tt>00011010 oorrrmmm</tt> || 2+ || 2
|-
| SBB reg16, mem16 || <tt>1B /r</tt> || <tt>00011011 oorrrmmm</tt> || 2+ || 2
|-
| SBB reg8, reg8 || <tt>18 /r</tt> || <tt>000110.0 11rrrmmm</tt> || 2 || 1
|-
| SBB reg16, reg16 || <tt>19 /r</tt> || <tt>000110.1 11rrrmmm</tt> || 2 || 1
|}
----
{{Anchor|SCASB}}
{{Anchor|SCASW}}
=== SCASB/SCASW ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| SCASB || <tt>AE</tt> || <tt>10101110</tt> || 1 || 4
|-
| SCASW || <tt>AF</tt> || <tt>10101111</tt> || 1 || 4
|}
----
{{Anchor|SHL}}
=== SHL ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| SHL mem8, 1 || <tt>D0 /4</tt> || <tt>11010000 oo100rm</tt> || 2+ || 3
|-
| SHL mem8, CL || <tt>D2 /4</tt> || <tt>11010010 oo100rm</tt> || 2+ || 5
|-
| SHL mem8, imm8 || <tt>C0 /4 ii</tt> || <tt>11000000 oo100mmm iiiiiiii</tt> || 3+ || 5
|-
| SHL mem16, 1 || <tt>D1 /4</tt> || <tt>11010001 oo100rm</tt> || 2+ || 3
|-
| SHL mem16, CL || <tt>D3 /4</tt> || <tt>11010011 oo100rm</tt> || 2+ || 5
|-
| SHL mem16, imm8 || <tt>C1 /4 ii</tt> || <tt>11000001 oo100mmm iiiiiiii</tt> || 3+ || 5
|-
| SHL reg8, 1 || <tt>D0 /4</tt> || <tt>11010000 11100rm</tt> || 2 || 1
|-
| SHL reg8, CL || <tt>D2 /4</tt> || <tt>11010010 11100rm</tt> || 2 || 3
|-
| SHL reg8, imm8 || <tt>C0 /4 ii</tt> || <tt>11000000 11100mmm iiiiiiii</tt> || 3 || 3
|-
| SHL reg16, 1 || <tt>D1 /4</tt> || <tt>11010001 11100rm</tt> || 2 || 1
|-
| SHL reg16, CL || <tt>D3 /4</tt> || <tt>11010011 11100rm</tt> || 2 || 3
|-
| SHL reg16, imm8 || <tt>C1 /4 ii</tt> || <tt>11000001 11100mmm iiiiiiii</tt> || 3 || 3
|}
----
{{Anchor|SHR}}
=== SHR ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| SHR mem8, 1 || <tt>D0 /5</tt> || <tt>11010000 oo101rm</tt> || 2+ || 3
|-
| SHR mem8, CL || <tt>D2 /5</tt> || <tt>11010010 oo101rm</tt> || 2+ || 5
|-
| SHR mem8, imm8 || <tt>C0 /5 ii</tt> || <tt>11000000 oo101mmm iiiiiiii</tt> || 3+ || 5
|-
| SHR mem16, 1 || <tt>D1 /5</tt> || <tt>11010001 oo101rm</tt> || 2+ || 3
|-
| SHR mem16, CL || <tt>D3 /5</tt> || <tt>11010011 oo101rm</tt> || 2+ || 5
|-
| SHR mem16, imm8 || <tt>C1 /5 ii</tt> || <tt>11000001 oo101mmm iiiiiiii</tt> || 3+ || 5
|-
| SHR reg8, 1 || <tt>D0 /5</tt> || <tt>11010000 11101rm</tt> || 2 || 1
|-
| SHR reg8, CL || <tt>D2 /5</tt> || <tt>11010010 11101rm</tt> || 2 || 3
|-
| SHR reg8, imm8 || <tt>C0 /5 ii</tt> || <tt>11000000 11101mmm iiiiiiii</tt> || 3 || 3
|-
| SHR reg16, 1 || <tt>D1 /5</tt> || <tt>11010001 11101rm</tt> || 2 || 1
|-
| SHR reg16, CL || <tt>D3 /5</tt> || <tt>11010011 11101rm</tt> || 2 || 3
|-
| SHR reg16, imm8 || <tt>C1 /5 ii</tt> || <tt>11000001 11101mmm iiiiiiii</tt> || 3 || 3
|}
----
{{Anchor|SS}}
=== SS ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| SS || <tt>36</tt> || <tt>00110110</tt> || 1 || 1
|}
----
{{Anchor|STC}}
=== STC ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| STC || <tt>F9</tt> || <tt>11111001</tt> || 1 || 4
|}
----
{{Anchor|STD}}
=== STD ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| STD || <tt>FD</tt> || <tt>11111101</tt> || 1 || 4
|}
----
{{Anchor|STI}}
=== STI ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| STI || <tt>FB</tt> || <tt>11111011</tt> || 1 || 4
|}
----
{{Anchor|STOSB}}
{{Anchor|STOSW}}
=== STOSB/STOSW ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| STOSB || <tt>AA</tt> || <tt>10101010</tt> || 1 || 3
|-
| STOSW || <tt>AB</tt> || <tt>10101011</tt> || 1 || 3
|}
----
{{Anchor|SUB}}
=== SUB ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| SUB AL, imm || <tt>28 ii</tt> || <tt>00101100 iiiiiiii</tt> || 2 || 1
|-
| SUB AX, imm || <tt>29 ii ii</tt> || <tt>00101101 iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| SUB mem8, imm8 || <tt>80 /5 ii</tt> || <tt>10000000 oo101mmm iiiiiiii</tt> || 3+ || 3
|-
| SUB mem16, imm16 || <tt>81 /5 ii ii</tt> || <tt>10000001 oo101mmm iiiiiiii iiiiiiii</tt> || 4+ || 3
|-
| SUB mem16, simm8 || <tt>83 /5 ii</tt> || <tt>10000011 oo101mmm iiiiiiii</tt> || 3+ || 3
|-
| SUB mem8, reg8 || <tt>28 /r</tt> || <tt>00101000 oorrrmmm</tt> || 2+ || 3
|-
| SUB mem16, reg16 || <tt>29 /r</tt> || <tt>00101001 oorrrmmm</tt> || 2+ || 3
|-
| SUB reg8, imm8 || <tt>80 /5 ii</tt> || <tt>10000000 11101mmm iiiiiiii</tt> || 3 || 1
|-
| SUB reg16, imm16 || <tt>81 /5 ii ii</tt> || <tt>10000001 11101mmm iiiiiiii iiiiiiii</tt> || 4 || 1
|-
| SUB reg16, simm8 || <tt>83 /5 ii</tt> || <tt>10000011 11101mmm iiiiiiii</tt> || 3 || 1
|-
| SUB reg8, mem8 || <tt>2A /r</tt> || <tt>00101010 oorrrmmm</tt> || 2+ || 2
|-
| SUB reg16, mem16 || <tt>2B /r</tt> || <tt>00101011 oorrrmmm</tt> || 2+ || 2
|-
| SUB reg8, reg8 || <tt>28 /r</tt> || <tt>001010.0 11rrrmmm</tt> || 2 || 1
|-
| SUB reg16, reg16 || <tt>29 /r</tt> || <tt>001010.1 11rrrmmm</tt> || 2 || 1
|}
----
{{Anchor|TEST}}
=== TEST ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| TEST AL, imm || <tt>A8 ii</tt> || <tt>10101000 iiiiiiii</tt> || 2 || 1
|-
| TEST AX, imm || <tt>A9 ii ii</tt> || <tt>10101001 iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| TEST mem8, imm8 || <tt>F6 /0 ii</tt> || <tt>11110110 oo000mmm iiiiiiii</tt> || 3+ || 2
|-
| TEST mem16, imm16 || <tt>F7 /0 ii ii</tt> || <tt>11110111 oo000mmm iiiiiiii iiiiiiii</tt> || 4+ || 2
|-
| TEST mem8, reg8<br/>TEST reg8, mem8 || <tt>84 /r</tt> || <tt>10000100 oorrrmmm</tt> || 2+ || 2
|-
| TEST mem16, reg16<br/>TEST reg16, mem16 || <tt>85 /r</tt> || <tt>10000101 oorrrmmm</tt> || 2+ || 2
|-
| TEST reg8, imm8 || <tt>F6 /0 ii</tt> || <tt>11110110 11000mmm iiiiiiii</tt> || 3 || 1
|-
| TEST reg16, imm16 || <tt>F7 /0 ii ii</tt> || <tt>11110111 11000mmm iiiiiiii iiiiiiii</tt> || 4 || 1
|-
| TEST reg8, reg8 || <tt>84 /r</tt> || <tt>10000100 11rrrmmm</tt> || 2 || 1
|-
| TEST reg16, reg16 || <tt>85 /r</tt> || <tt>10000101 11rrrmmm</tt> || 2 || 1
|}
----
{{Anchor|XCHG}}
=== XCHG ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| XCHG AX, reg16<br/>XCHG reg16, AX || <tt>9x</tt> || <tt>10010rrr</tt> || 1 || 3
|-
| XCHG mem8, reg8<br/>XCHG reg8, mem8 || <tt>86 /r</tt> || <tt>10000110 oorrrmmm</tt> || 2+ || 5
|-
| XCHG mem16, reg16<br/>XCHG reg16, mem16 || <tt>87 /r</tt> || <tt>10000111 oorrrmmm</tt> || 2+ || 5
|-
| XCHG reg8, reg8 || <tt>86 /r</tt> || <tt>10000110 11rrrmmm</tt> || 2+ || 3
|-
| XCHG reg16, reg16 || <tt>87 /r</tt> || <tt>10000111 11rrrmmm</tt> || 2+ || 3
|}
----
{{Anchor|XLAT}}
=== XLAT ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| XLAT || <tt>D7</tt> || <tt>11010111</tt> || 1 || 5
|}
----
{{Anchor|XOR}}
=== XOR ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| XOR AL, imm || <tt>34 ii</tt> || <tt>00110100 iiiiiiii</tt> || 2 || 1
|-
| XOR AX, imm || <tt>35 ii ii</tt> || <tt>00110101 iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| XOR mem8, imm8 || <tt>80 /6 ii</tt> || <tt>10000000 oo110mmm iiiiiiii</tt> || 3+ || 3
|-
| XOR mem16, imm16 || <tt>81 /6 ii ii</tt> || <tt>10000001 oo110mmm iiiiiiii iiiiiiii</tt> || 4+ || 3
|-
| XOR mem16, simm8 || <tt>83 /6 ii</tt> || <tt>10000011 oo110mmm iiiiiiii</tt> || 3+ || 3
|-
| XOR mem8, reg8 || <tt>30 /r</tt> || <tt>00110000 oorrrmmm</tt> || 2+ || 3
|-
| XOR mem16, reg16 || <tt>31 /r</tt> || <tt>00110001 oorrrmmm</tt> || 2+ || 3
|-
| XOR reg8, imm8 || <tt>80 /6 ii</tt> || <tt>10000000 11110mmm iiiiiiii</tt> || 3 || 1
|-
| XOR reg16, imm16 || <tt>81 /6 ii ii</tt> || <tt>10000001 11110mmm iiiiiiii iiiiiiii</tt> || 4 || 1
|-
| XOR reg16, simm8 || <tt>83 /6 ii</tt> || <tt>10000011 11110mmm iiiiiiii</tt> || 3 || 1
|-
| XOR reg8, mem8 || <tt>32 /r</tt> || <tt>00110010 oorrrmmm</tt> || 2+ || 2
|-
| XOR reg16, mem16 || <tt>33 /r</tt> || <tt>00110011 oorrrmmm</tt> || 2+ || 2
|-
| XOR reg8, reg8 || <tt>30 /r</tt> || <tt>001100.0 11rrrmmm</tt> || 2 || 1
|-
| XOR reg16, reg16 || <tt>31 /r</tt> || <tt>001100.1 11rrrmmm</tt> || 2 || 1
|}
== Notes ==
<references />
97f42dde991d8c6967d6c5b7cbea6b66c373d734
468
464
2024-12-28T11:02:48Z
Asie
351
/* Official instructions */
wikitext
text/x-wiki
__NOTOC__
Note that this page is a work in progress.
{| class="wikitable" style="text-align: center"
|+ Official V30MZ (80186) Instructions
|-
| [[#AAA|AAA]] || [[#AAD|AAD]] || [[#AAM|AAM]] || [[#AAS|AAS]] || [[#ADC|ADC]] || [[#ADD|ADD]] || [[#AND|AND]] || [[#BOUND|BOUND]] || [[#CALL|CALL]] || [[#CBW|CBW]] || [[#CLC|CLC]]
|-
| [[#CLD|CLD]] || [[#CLI|CLI]] || [[#CMC|CMC]] || [[#CMP|CMP]] || [[#CMPSB|CMPSB]] || [[#CMPSW|CMPSW]] || [[#CS|CS]] || [[#CWD|CWD]] || [[#DAA|DAA]] || [[#DAS|DAS]] || [[#DEC|DEC]]
|-
| [[#DIV|DIV]] || [[#DS|DS]] || [[#ENTER|ENTER]] || [[#ES|ES]] || [[#HLT|HLT]] || [[#IDIV|IDIV]] || [[#IMUL|IMUL]] || [[#IN|IN]] || [[#INC|INC]] || [[#INSB|INSB]] || [[#INSW|INSW]]
|-
| [[#INT|INT]] || [[#INTO|INTO]] || [[#IRET|IRET]] || [[#JA|JA]] || [[#JBE|JBE]] || [[#JC|JC]] || [[#JCXZ|JCXZ]] || [[#JG|JG]] || [[#JGE|JGE]] || [[#JL|JL]] || [[#JLE|JLE]]
|-
| [[#JMP|JMP]] || [[#JNC|JNC]] || [[#JNO|JNO]] || [[#JNP|JNP]] || [[#JNS|JNS]] || [[#JNZ|JNZ]] || [[#JO|JO]] || [[#JP|JP]] || [[#JS|JS]] || [[#JZ|JZ]] || [[#LAHF|LAHF]]
|-
| [[#LDS|LDS]] || [[#LEA|LEA]] || [[#LEAVE|LEAVE]] || [[#LES|LES]] || [[#LOCK|LOCK]] || [[#LODSB|LODSB]] || [[#LODSW|LODSW]] || [[#LOOP|LOOP]] || [[#LOOPE|LOOPE]] || [[#LOOPNE|LOOPNE]] || [[#MOV|MOV]]
|-
| [[#MOVSB|MOVSB]] || [[#MOVSW|MOVSW]] || [[#MUL|MUL]] || [[#NEG|NEG]] || [[#NOP|NOP]] || [[#NOT|NOT]] || [[#OR|OR]] || [[#OUT|OUT]] || [[#OUTSB|OUTSB]] || [[#OUTSW|OUTSW]] || [[#POLL|POLL]]
|-
| [[#POP|POP]] || [[#POPA|POPA]] || [[#POPF|POPF]] || [[#PUSH|PUSH]] || [[#PUSHA|PUSHA]] || [[#PUSHF|PUSHF]] || [[#RCL|RCL]] || [[#RCR|RCR]] || [[#REP|REP]] || [[#REPNE|REPNE]] || [[#RET|RET]]
|-
| [[#RETF|RETF]] || [[#ROL|ROL]] || [[#ROR|ROR]] || [[#SAHF|SAHF]] || [[#SAR|SAR]] || [[#SBB|SBB]] || [[#SCASB|SCASB]] || [[#SCASW|SCASW]] || [[#SHL|SHL]] || [[#SHR|SHR]] || [[#SS|SS]]
|-
| [[#STC|STC]] || [[#STD|STD]] || [[#STI|STI]] || [[#STOSB|STOSB]] || [[#STOSW|STOSW]] || [[#SUB|SUB]] || [[#TEST|TEST]] || [[#XCHG|XCHG]] || [[#XLAT|XLAT]] || [[#XOR|XOR]]
|}
{| class="mw-collapsible mw-collapsed wikitable sortable" style="width: 340px;"
|+ style="white-space:nowrap; border:1px solid; padding:3px; border-color:rgb(162, 169, 177); background-color:rgb(234, 236, 240);" | Intel <-> NEC mnemonic translation table
!Intel
!NEC
|-
| [[#AAA|AAA]]
| [[#AAA|ADJBA]]
|-
| [[#AAD|AAD]]
| [[#AAD|CVTDB]]
|-
| [[#AAM|AAM]]
| [[#AAM|CVTBD]]
|-
| [[#AAS|AAS]]
| [[#AAS|ADJBS]]
|-
| [[#ADC|ADC]]
| [[#ADC|ADDC]]
|-
| [[#ADD|ADD]]
| [[#ADD|ADD]]
|-
| [[#AND|AND]]
| [[#AND|AND]]
|-
| [[#BOUND|BOUND]]
| [[#BOUND|CHKIND]]
|-
| [[#CALL|CALL]]
| [[#CALL|CALL]]
|-
| [[#CBW|CBW]]
| [[#CBW|CVTBW]]
|-
| [[#CLC|CLC]]
| [[#CLC|CLR1 CY]]
|-
| [[#CLD|CLD]]
| [[#CLD|CLR1 DIR]]
|-
| [[#CLI|CLI]]
| [[#CLI|DI]]
|-
| [[#CMC|CMC]]
| [[#CMC|NOT1 CY]]
|-
| [[#CMP|CMP]]
| [[#CMP|CMP]]
|-
| [[#CMPSB|CMPSB]]
| [[#CMPSB|CMPBKB]]
|-
| [[#CMPSW|CMPSW]]
| [[#CMPSW|CMPBKW]]
|-
| [[#CS|CS]]
| [[#CS|PS]]
|-
| [[#CWD|CWD]]
| [[#CWD|CVTWL]]
|-
| [[#DAA|DAA]]
| [[#DAA|ADJ4A]]
|-
| [[#DAS|DAS]]
| [[#DAS|ADJ4S]]
|-
| [[#DEC|DEC]]
| [[#DEC|DEC]]
|-
| [[#DIV|DIV]]
| [[#DIV|DIVU]]
|-
| [[#DS|DS]]
| [[#DS|DS0]]
|-
| [[#ENTER|ENTER]]
| [[#ENTER|PREPARE]]
|-
| [[#ES|ES]]
| [[#ES|DS1]]
|-
| [[#HLT|HLT]]
| [[#HLT|HALT]]
|-
| [[#IDIV|IDIV]]
| [[#IDIV|DIV]]
|-
| [[#IMUL|IMUL]]
| [[#IMUL|MUL]]
|-
| [[#IN|IN]]
| [[#IN|IN]]
|-
| [[#INC|INC]]
| [[#INC|INC]]
|-
| [[#INSB|INSB]]
| [[#INSB|INMB]]
|-
| [[#INSW|INSW]]
| [[#INSW|INMW]]
|-
| [[#INT|INT]]
| [[#INT|BRK]]
|-
| [[#INTO|INTO]]
| [[#INTO|BRKV]]
|-
| [[#IRET|IRET]]
| [[#IRET|RETI]]
|-
| [[#JA|JA]]
| [[#JA|BH]]
|-
| [[#JBE|JBE]]
| [[#JBE|BNH]]
|-
| [[#JC|JC/JB]]
| [[#JC|BC/BL]]
|-
| [[#JCXZ|JCXZ]]
| [[#JCXZ|BCWZ]]
|-
| [[#JG|JG]]
| [[#JG|BGT]]
|-
| [[#JGE|JGE]]
| [[#JGE|BGE]]
|-
| [[#JL|JL]]
| [[#JL|BLT]]
|-
| [[#JLE|JLE]]
| [[#JLE|BLE]]
|-
| [[#JMP|JMP]]
| [[#JMP|BR]]
|-
| [[#JNC|JNC/JAE]]
| [[#JNC|BNC/BNL]]
|-
| [[#JNO|JNO]]
| [[#JNO|BNV]]
|-
| [[#JNP|JNP]]
| [[#JNP|BPO]]
|-
| [[#JNS|JNS]]
| [[#JNS|BP]]
|-
| [[#JNZ|JNZ/JNE]]
| [[#JNZ|BNZ/BNE]]
|-
| [[#JO|JO]]
| [[#JO|BV]]
|-
| [[#JP|JP]]
| [[#JP|BPE]]
|-
| [[#JS|JS]]
| [[#JS|BN]]
|-
| [[#JZ|JZ/JE]]
| [[#JZ|BZ/BE]]
|-
| [[#LAHF|LAHF]]
| [[#LAHF|MOV]]
|-
| [[#LDS|LDS]]
| [[#LDS|MOV]]
|-
| [[#LEA|LEA]]
| [[#LEA|LDEA]]
|-
| [[#LEAVE|LEAVE]]
| [[#LEAVE|DISPOSE]]
|-
| [[#LES|LES]]
| [[#LES|MOV]]
|-
| [[#LOCK|LOCK]]
| [[#LOCK|BUSLOCK]]
|-
| [[#LODSB|LODSB]]
| [[#LODSB|LDMB]]
|-
| [[#LODSW|LODSW]]
| [[#LODSW|LDMW]]
|-
| [[#LOOP|LOOP]]
| [[#LOOP|DBNZ]]
|-
| [[#LOOPE|LOOPE]]
| [[#LOOPE|DBNZE]]
|-
| [[#LOOPNE|LOOPNE]]
| [[#LOOPNE|DBNZNE]]
|-
| [[#MOV|MOV]]
| [[#MOV|MOV]]
|-
| [[#MOVSB|MOVSB]]
| [[#MOVSB|MOVBKB]]
|-
| [[#MOVSW|MOVSW]]
| [[#MOVSW|MOVBKW]]
|-
| [[#MUL|MUL]]
| [[#MUL|MULU]]
|-
| [[#NEG|NEG]]
| [[#NEG|NEG]]
|-
| [[#NOP|NOP]]
| [[#NOP|NOP]]
|-
| [[#NOT|NOT]]
| [[#NOT|NOT]]
|-
| [[#OR|OR]]
| [[#OR|OR]]
|-
| [[#OUT|OUT]]
| [[#OUT|OUT]]
|-
| [[#OUTSB|OUTSB]]
| [[#OUTSB|OUTM]]
|-
| [[#OUTSW|OUTSW]]
| [[#OUTSW|OUTM]]
|-
| [[#POLL|POLL]]
| [[#POLL|POLL]]
|-
| [[#POP|POP]]
| [[#POP|POP]]
|-
| [[#POPA|POPA]]
| [[#POPA|POP]]
|-
| [[#POPF|POPF]]
| [[#POPF|POP]]
|-
| [[#PUSH|PUSH]]
| [[#PUSH|PUSH]]
|-
| [[#PUSHA|PUSHA]]
| [[#PUSHA|PUSH]]
|-
| [[#PUSHF|PUSHF]]
| [[#PUSHF|PUSH]]
|-
| [[#RCL|RCL]]
| [[#RCL|ROLC]]
|-
| [[#RCR|RCR]]
| [[#RCR|RORC]]
|-
| [[#REP|REP/REPE/REPZ]]
| [[#REP|REP/REPE/REPZ]]
|-
| [[#REPNE|REPNE/REPNZ]]
| [[#REPNE|REPNE/REPNZ]]
|-
| [[#RET|RET]]
| [[#RET|RET]]
|-
| [[#RETF|RETF]]
| [[#RETF|RET]]
|-
| [[#ROL|ROL]]
| [[#ROL|ROL]]
|-
| [[#ROR|ROR]]
| [[#ROR|ROR]]
|-
| [[#SAHF|SAHF]]
| [[#SAHF|MOV]]
|-
| [[#SAR|SAR]]
| [[#SAR|SHRA]]
|-
| [[#SBB|SBB]]
| [[#SBB|SUBC]]
|-
| [[#SCASB|SCASB]]
| [[#SCASB|CMPMB]]
|-
| [[#SCASW|SCASW]]
| [[#SCASW|CMPMW]]
|-
| [[#SHL|SHL]]
| [[#SHL|SHL]]
|-
| [[#SHR|SHR]]
| [[#SHR|SHR]]
|-
| [[#SS|SS]]
| [[#SS|SS]]
|-
| [[#STC|STC]]
| [[#STC|SET1 CY]]
|-
| [[#STD|STD]]
| [[#STD|SET1 DIR]]
|-
| [[#STI|STI]]
| [[#STI|EI]]
|-
| [[#STOSB|STOSB]]
| [[#STOSB|STMB]]
|-
| [[#STOSW|STOSW]]
| [[#STOSW|STMW]]
|-
| [[#SUB|SUB]]
| [[#SUB|SUB]]
|-
| [[#TEST|TEST]]
| [[#TEST|TEST]]
|-
| [[#XCHG|XCHG]]
| [[#XCHG|XCH]]
|-
| [[#XLAT|XLAT]]
| [[#XLAT|TRANS]]
|-
| [[#XOR|XOR]]
| [[#XOR|XOR]]
|}
== Official instructions by type ==
{| class="wikitable sortable" style="text-align: center"
!Type
!colspan=16 class="unsortable" | Instructions
|-
| style="text-align:left;" | Memory
| style="" | [[#MOV|MOV]]
| style="" | [[#XCHG|XCHG]]
| style="" | [[#XLAT|XLAT]]
| style="" | [[#LEA|LEA]]
| style="border-right:none;" | [[#LDS|LDS]]
| style="border-left:none;" | [[#LES|LES]]
| style="border-right:none;" | [[#IN|IN]]
| style="border-left:none;" | [[#OUT|OUT]]
| colspan="8" |
|-
| style="text-align:left;" | Ports
| style="border-right:none;" | [[#IN|IN]]
| style="border-left:none;" | [[#OUT|OUT]]
| style="border-right:none;" | [[#INSB|INSB]]
| style="border-left:none;" | [[#OUTSB|OUTSB]]
| style="border-right:none;" | [[#INSW|INSW]]
| style="border-left:none;" | [[#OUTSW|OUTSW]]
| colspan="10" |
|-
| style="text-align:left;" | Arithmetic
| style="border-right:none;" | [[#ADD|ADD]]
| style="border-left:none;" | [[#SUB|SUB]]
| style="border-right:none;" | [[#ADC|ADC]]
| style="border-left:none;" | [[#SBB|SBB]]
| style="border-right:none;" | [[#INC|INC]]
| style="border-left:none;" | [[#DEC|DEC]]
| style="border-right:none;" | [[#MUL|MUL]]
| style="border-left:none;" | [[#DIV|DIV]]
| style="border-right:none;" | [[#IMUL|IMUL]]
| style="border-left:none;" | [[#IDIV|IDIV]]
| style="" | [[#CMP|CMP]]
| style="" | [[#NEG|NEG]]
| colspan="4" |
|-
| style="text-align:left;" | Numeric
| style="" | [[#CBW|CBW]]
| style="" | [[#CWD|CWD]]
| style="" | [[#AAA|AAA]]
| style="" | [[#AAS|AAS]]
| style="" | [[#AAM|AAM]]
| style="" | [[#AAD|AAD]]
| style="" | [[#DAA|DAA]]
| style="" | [[#DAS|DAS]]
| colspan="8" |
|-
| style="text-align:left;" | Shift
| style="border-right:none;" | [[#ROL|ROL]]
| style="border-left:none;" | [[#ROR|ROR]]
| style="border-right:none;" | [[#RCL|RCL]]
| style="border-left:none;" | [[#RCR|RCR]]
| style="border-right:none;" | [[#SHL|SHL]]
| style="border-left:none;" | [[#SHR|SHR]]
| style="" | [[#SAR|SAR]]
| colspan="9" |
|-
| style="text-align:left;" | Bitwise
| style="" | [[#AND|AND]]
| style="" | [[#OR|OR]]
| style="" | [[#XOR|XOR]]
| style="" | [[#NOT|NOT]]
| style="" | [[#TEST|TEST]]
| colspan="11" |
|-
| style="text-align:left;" | Branch
| style="border-right:none;" | [[#JC|JC]]
| style="border-left:none;" | [[#JNC|JNC]]
| style="border-right:none;" | [[#JZ|JZ]]
| style="border-left:none;" | [[#JNZ|JNZ]]
| style="border-right:none;" | [[#JBE|JBE]]
| style="border-left:none;" | [[#JA|JA]]
| style="border-right:none;" | [[#JO|JO]]
| style="border-left:none;" | [[#JNO|JNO]]
| style="border-right:none;" | [[#JP|JP]]
| style="border-left:none;" | [[#JNP|JNP]]
| style="border-right:none;" | [[#JS|JS]]
| style="border-left:none;" | [[#JNS|JNS]]
| style="border-right:none;" | [[#JL|JL]]
| style="border-left:none;" | [[#JGE|JGE]]
| style="border-right:none;" | [[#JLE|JLE]]
| style="border-left:none;" | [[#JG|JG]]
|-
| style="text-align:left;" | Jump
| style="" | [[#JMP|JMP]]
| style="border-right:none;" | [[#CALL|CALL]]
| style="border-left:none;border-right:none;" | [[#RET|RET]]
| style="border-left:none;" | [[#RETF|RETF]]
| colspan="12" |
|-
| style="text-align:left;" | Loop
| style="" | [[#LOOP|LOOP]]
| style="" | [[#LOOPE|LOOPE]]
| style="" | [[#LOOPNE|LOOPNE]]
| colspan="13" |
|-
| style="text-align:left;" | Interrupt
| style="border-right:none;" | [[#INT|INT]]
| style="border-left:none;" | [[#IRET|IRET]]
| style="" | [[#INTO|INTO]]
| style="" | [[#HLT|HLT]]
| style="" | [[#BOUND|BOUND]]
| colspan="11" |
|-
| style="text-align:left;" | Stack
| style="border-right:none;" | [[#PUSH|PUSH]]
| style="border-left:none;" | [[#POP|POP]]
| style="border-right:none;" | [[#PUSHA|PUSHA]]
| style="border-left:none;" | [[#POPA|POPA]]
| style="border-right:none;" | [[#PUSHF|PUSHF]]
| style="border-left:none;" | [[#POPF|POPF]]
| colspan="10" |
|-
| style="text-align:left;" | Flags
| style="border-right:none;" | [[#CLC|CLC]]
| style="border-left:none;" | [[#STC|STC]]
| style="border-right:none;" | [[#CLD|CLD]]
| style="border-left:none;" | [[#STD|STD]]
| style="border-right:none;" | [[#CLI|CLI]]
| style="border-left:none;" | [[#STI|STI]]
| style="" | [[#CMC|CMC]]
| style="border-right:none;" | [[#LAHF|LAHF]]
| style="border-left:none;" | [[#SAHF|SAHF]]
| colspan="7" |
|-
| style="text-align:left;" | Prefix
| style="" | [[#CS|CS]]
| style="" | [[#DS|DS]]
| style="" | [[#ES|ES]]
| style="" | [[#SS|SS]]
| colspan="12" |
|-
| style="text-align:left;" | String
| style="border-right:none;" | [[#REP|REP]]
| style="border-left:none;border-right:none;" | [[#REP|REPE]]
| style="border-left:none;" | [[#REPNE|REPNE]]
| style="" | [[#MOVSB|MOVSB]]
| style="" | [[#MOVSW|MOVSW]]
| style="border-right:none;" | [[#LODSB|LODSB]]
| style="border-left:none;" | [[#STOSB|STOSB]]
| style="border-right:none;" | [[#LODSW|LODSW]]
| style="border-left:none;" | [[#STOSW|STOSW]]
| style="" | [[#CMPSB|CMPSB]]
| style="" | [[#SCASB|SCASB]]
| style="" | [[#CMPSW|CMPSW]]
| style="" | [[#SCASW|SCASW]]
| colspan="3" |
|-
| style="text-align:left;" | Other
| style="" | [[#NOP|NOP]]
| style="border-right:none;" | [[#ENTER|ENTER]]
| style="border-left:none;" | [[#LEAVE|LEAVE]]
| style="" | [[#LOCK|LOCK]]
| style="" | [[#POLL|POLL]]
| colspan="11" |
|}
== Instruction encoding ==
=== ModR/M byte ===
The ModR/M byte is used in most addressing modes which reference a memory location. This byte consists of three bitfield values:
* <tt>oo</tt> - M'''o'''de;
* <tt>rrr</tt> - Two possible functions:
** '''R'''egister (for addressing modes which require both a register and a register/memory operand),
** Opcode extension (for some opcodes' addressing modes which do not have such a requirement);
* <tt>mmm</tt> - Register/'''M'''emory.
The ''Mode'' and ''Register/Memory'' bitfields can refer to a memory location or to a register, as shown in the table below. In some addressing modes, the ''Register'' field also refers to a register; it is always interpreted as if ''Mode'' was equal to <tt>11</tt>.
{| class="wikitable" style="text-align: center"
! R/M \ Mode
! <tt>00</tt>
! <tt>01</tt>
! <tt>10</tt>
! <tt>11</tt> ''(byte)''
! <tt>11</tt> ''(word)''
|-
| <tt>000</tt>
| DS:[BX + SI]
| DS:[BX + SI + disp8]
| DS:[BX + SI + disp16]
| AL
| AX
|-
| <tt>001</tt>
| DS:[BX + DI]
| DS:[BX + DI + disp8]
| DS:[BX + DI + disp16]
| CL
| CX
|-
| <tt>010</tt>
| SS:[BP + SI]
| SS:[BP + SI + disp8]
| SS:[BP + SI + disp16]
| DL
| DX
|-
| <tt>011</tt>
| SS:[BP + DI]
| SS:[BP + DI + disp8]
| SS:[BP + DI + disp16]
| BL
| BX
|-
| <tt>100</tt>
| DS:[SI]
| DS:[SI + disp8]
| DS:[SI + disp16]
| AH
| SP
|-
| <tt>101</tt>
| DS:[DI]
| DS:[DI + disp8]
| DS:[DI + disp16]
| CH
| BP
|-
| <tt>110</tt>
| ''DS:[disp16]''
| SS:[BP + disp8]
| SS:[BP + disp16]
| DH
| SI
|-
| <tt>111</tt>
| DS:[BX]
| DS:[BX + disp8]
| DS:[BX + disp16]
| BH
| DI
|}
Displacements are either 8-bit (disp8) or 16-bit (disp16) signed values and they always immediately follow the ModR/M byte. Note that (<tt>oo</tt> = <tt>00</tt>, <tt>mmm</tt> = <tt>110</tt>) is a special case, in which the ''disp16'' value is used directly as a near pointer.
The instruction encoding lists below refer to this byte as <tt>oorrrmmm</tt> (binary), <tt>/r</tt> (hexadecimal) or <tt>/0</tt> (hexademical, <tt>rrr</tt> used as function <tt>0</tt>).
== Official instructions ==
{{Anchor|AAA}}
=== AAA ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| AAA || <tt>37</tt> || <tt>00110111</tt> || 1 || 9
|}
----
{{Anchor|AAD}}
=== AAD ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| AAD imm8 || <tt>B5 ii</tt> || <tt>11010100 iiiiiiii</tt> || 2 || 6
|}
----
{{Anchor|AAM}}
=== AAM ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| AAM imm8 || <tt>B4 ii</tt> || <tt>11010100 iiiiiiii</tt> || 2 || 17
|}
----
{{Anchor|AAS}}
=== AAS ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| AAS || <tt>3F</tt> || <tt>00111111</tt> || 1 || 9
|}
----
{{Anchor|ADC}}
=== ADC ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| ADC AL, imm || <tt>14 ii</tt> || <tt>00010100 iiiiiiii</tt> || 2 || 1
|-
| ADC AX, imm || <tt>15 ii ii</tt> || <tt>00010101 iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| ADC mem8, imm8 || <tt>80 /2 ii</tt> || <tt>10000000 oo010mmm iiiiiiii</tt> || 3+ || 3
|-
| ADC mem16, imm16 || <tt>81 /2 ii ii</tt> || <tt>10000001 oo010mmm iiiiiiii iiiiiiii</tt> || 4+ || 3
|-
| ADC mem16, simm8 || <tt>83 /2 ii</tt> || <tt>10000011 oo010mmm iiiiiiii</tt> || 3+ || 3
|-
| ADC mem8, reg8 || <tt>10 /r</tt> || <tt>00010000 oorrrmmm</tt> || 2+ || 3
|-
| ADC mem16, reg16 || <tt>11 /r</tt> || <tt>00010001 oorrrmmm</tt> || 2+ || 3
|-
| ADC reg8, imm8 || <tt>80 /2 ii</tt> || <tt>10000000 11010mmm iiiiiiii</tt> || 3 || 1
|-
| ADC reg16, imm16 || <tt>81 /2 ii ii</tt> || <tt>10000001 11010mmm iiiiiiii iiiiiiii</tt> || 4 || 1
|-
| ADC reg16, simm8 || <tt>83 /2 ii</tt> || <tt>10000011 11010mmm iiiiiiii</tt> || 3 || 1
|-
| ADC reg8, mem8 || <tt>12 /r</tt> || <tt>00010010 oorrrmmm</tt> || 2+ || 2
|-
| ADC reg16, mem16 || <tt>13 /r</tt> || <tt>00010011 oorrrmmm</tt> || 2+ || 2
|-
| ADC reg8, reg8 || <tt>10 /r</tt> || <tt>000100.0 11rrrmmm</tt> || 2 || 1
|-
| ADC reg16, reg16 || <tt>11 /r</tt> || <tt>000100.1 11rrrmmm</tt> || 2 || 1
|}
----
{{Anchor|ADD}}
=== ADD ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| ADD AL, imm || <tt>04 ii</tt> || <tt>00000100 iiiiiiii</tt> || 2 || 1
|-
| ADD AX, imm || <tt>05 ii ii</tt> || <tt>00000101 iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| ADD mem8, imm8 || <tt>80 /0 ii</tt> || <tt>10000000 oo000mmm iiiiiiii</tt> || 3+ || 3
|-
| ADD mem16, imm16 || <tt>81 /0 ii ii</tt> || <tt>10000001 oo000mmm iiiiiiii iiiiiiii</tt> || 4+ || 3
|-
| ADD mem16, simm8 || <tt>83 /0 ii</tt> || <tt>10000011 oo000mmm iiiiiiii</tt> || 3+ || 3
|-
| ADD mem8, reg8 || <tt>00 /r</tt> || <tt>00000000 oorrrmmm</tt> || 2+ || 3
|-
| ADD mem16, reg16 || <tt>01 /r</tt> || <tt>00000001 oorrrmmm</tt> || 2+ || 3
|-
| ADD reg8, imm8 || <tt>80 /0 ii</tt> || <tt>10000000 11000mmm iiiiiiii</tt> || 3 || 1
|-
| ADD reg16, imm16 || <tt>81 /0 ii ii</tt> || <tt>10000001 11000mmm iiiiiiii iiiiiiii</tt> || 4 || 1
|-
| ADD reg16, simm8 || <tt>83 /0 ii</tt> || <tt>10000011 11000mmm iiiiiiii</tt> || 3 || 1
|-
| ADD reg8, mem8 || <tt>02 /r</tt> || <tt>00000010 oorrrmmm</tt> || 2+ || 2
|-
| ADD reg16, mem16 || <tt>03 /r</tt> || <tt>00000011 oorrrmmm</tt> || 2+ || 2
|-
| ADD reg8, reg8 || <tt>00 /r</tt> || <tt>000000.0 11rrrmmm</tt> || 2 || 1
|-
| ADD reg16, reg16 || <tt>01 /r</tt> || <tt>000000.1 11rrrmmm</tt> || 2 || 1
|}
----
{{Anchor|AND}}
=== AND ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| AND AL, imm || <tt>24 ii</tt> || <tt>00100100 iiiiiiii</tt> || 2 || 1
|-
| AND AX, imm || <tt>25 ii ii</tt> || <tt>00100101 iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| AND mem8, imm8 || <tt>80 /4 ii</tt> || <tt>10000000 oo100mmm iiiiiiii</tt> || 3+ || 3
|-
| AND mem16, imm16 || <tt>81 /4 ii ii</tt> || <tt>10000001 oo100mmm iiiiiiii iiiiiiii</tt> || 4+ || 3
|-
| AND mem16, simm8 || <tt>83 /4 ii</tt> || <tt>10000011 oo100mmm iiiiiiii</tt> || 3+ || 3
|-
| AND mem8, reg8 || <tt>20 /r</tt> || <tt>00100000 oorrrmmm</tt> || 2+ || 3
|-
| AND mem16, reg16 || <tt>21 /r</tt> || <tt>00100001 oorrrmmm</tt> || 2+ || 3
|-
| AND reg8, imm8 || <tt>80 /4 ii</tt> || <tt>10000000 11100mmm iiiiiiii</tt> || 3 || 1
|-
| AND reg16, imm16 || <tt>81 /4 ii ii</tt> || <tt>10000001 11100mmm iiiiiiii iiiiiiii</tt> || 4 || 1
|-
| AND reg16, simm8 || <tt>83 /4 ii</tt> || <tt>10000011 11100mmm iiiiiiii</tt> || 3 || 1
|-
| AND reg8, mem8 || <tt>22 /r</tt> || <tt>00100010 oorrrmmm</tt> || 2+ || 2
|-
| AND reg16, mem16 || <tt>23 /r</tt> || <tt>00100011 oorrrmmm</tt> || 2+ || 2
|-
| AND reg8, reg8 || <tt>20 /r</tt> || <tt>001000.0 11rrrmmm</tt> || 2 || 1
|-
| AND reg16, reg16 || <tt>21 /r</tt> || <tt>001000.1 11rrrmmm</tt> || 2 || 1
|}
----
{{Anchor|BOUND}}
=== BOUND ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| BOUND reg16, mem16:16 || <tt>62 /r</tt> || <tt>01100010 oorrrmmm</tt> || 2+ || 13 (20 if condition met)
|}
----
{{Anchor|CALL}}
=== CALL ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| CALL ptr16:16 || <tt>CA oo oo ss ss</tt> || <tt>10011010 oooooooo oooooooo ssssssss ssssssss</tt> || 5 || 10
|-
| CALL mem16 || <tt>FF /2</tt> || <tt>11111111 oo010mmm</tt> || 2+ || 6
|-
| CALL mem16:16 || <tt>FF /3</tt> || <tt>11111111 oo011mmm</tt> || 2+ || 12
|-
| CALL reg16 || <tt>FF /2</tt> || <tt>11111111 11010mmm</tt> || 2 || 5
|-
| CALL rel16 || <tt>E8 ii ii</tt> || <tt>11101000 iiiiiiii iiiiiiii</tt> || 3 || 5
|}
----
{{Anchor|CBW}}
=== CBW ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| CBW || <tt>98</tt> || <tt>10011000</tt> || 1 || 1
|}
----
{{Anchor|CLC}}
=== CLC ===
{| class="wikitable"
! Flag !! New value
|-
| [[NEC_V30MZ_flags#CF|CF - Carry]] || 0
|}
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| CLC || <tt>F8</tt> || <tt>11111000</tt> || 1 || 4
|}
----
{{Anchor|CLD}}
=== CLD ===
{| class="wikitable"
! Flag !! New value
|-
| [[NEC_V30MZ_flags#DF|DF - Direction]] || 0
|}
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| CLD || <tt>FC</tt> || <tt>11111100</tt> || 1 || 4
|}
----
{{Anchor|CLI}}
=== CLI ===
{| class="wikitable"
! Flag !! New value
|-
| [[NEC_V30MZ_flags#IF|IF - Interrupt]] || 0
|}
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| CLI || <tt>FA</tt> || <tt>11111010</tt> || 1 || 4
|}
----
{{Anchor|CMC}}
=== CMC ===
{| class="wikitable"
! Flag !! New value
|-
| [[NEC_V30MZ_flags#CF|CF - Carry]] || !CF
|}
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| CMC || <tt>F5</tt> || <tt>11110101</tt> || 1 || 4
|}
----
{{Anchor|CMP}}
=== CMP ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| CMP AL, imm || <tt>3C ii</tt> || <tt>00111100 iiiiiiii</tt> || 2 || 1
|-
| CMP AX, imm || <tt>3D ii ii</tt> || <tt>00111101 iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| CMP mem8, imm8 || <tt>80 /7 ii</tt> || <tt>10000000 oo111mmm iiiiiiii</tt> || 3+ || 2
|-
| CMP mem16, imm16 || <tt>81 /7 ii ii</tt> || <tt>10000001 oo111mmm iiiiiiii iiiiiiii</tt> || 4+ || 2
|-
| CMP mem16, simm8 || <tt>83 /7 ii</tt> || <tt>10000011 oo111mmm iiiiiiii</tt> || 3+ || 2
|-
| CMP mem8, reg8 || <tt>38 /r</tt> || <tt>00111000 oorrrmmm</tt> || 2+ || 2
|-
| CMP mem16, reg16 || <tt>39 /r</tt> || <tt>00111001 oorrrmmm</tt> || 2+ || 2
|-
| CMP reg8, imm8 || <tt>80 /7 ii</tt> || <tt>10000000 11111mmm iiiiiiii</tt> || 3 || 1
|-
| CMP reg16, imm16 || <tt>81 /7 ii ii</tt> || <tt>10000001 11111mmm iiiiiiii iiiiiiii</tt> || 4 || 1
|-
| CMP reg16, simm8 || <tt>83 /7 ii</tt> || <tt>10000011 11111mmm iiiiiiii</tt> || 3 || 1
|-
| CMP reg8, mem8 || <tt>3A /r</tt> || <tt>00111010 oorrrmmm</tt> || 2+ || 2
|-
| CMP reg16, mem16 || <tt>3B /r</tt> || <tt>00111011 oorrrmmm</tt> || 2+ || 2
|-
| CMP reg8, reg8 || <tt>38 /r</tt> || <tt>001110.0 11rrrmmm</tt> || 2 || 1
|-
| CMP reg16, reg16 || <tt>39 /r</tt> || <tt>001110.1 11rrrmmm</tt> || 2 || 1
|}
----
{{Anchor|CMPSB}}
{{Anchor|CMPSW}}
=== CMPSB/CMPSW ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| CMPSB || <tt>A6</tt> || <tt>10100110</tt> || 1 || 6
|-
| CMPSW || <tt>A7</tt> || <tt>10100111</tt> || 1 || 6
|}
----
{{Anchor|CS}}
=== CS ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| CS || <tt>2E</tt> || <tt>00101110</tt> || 1 || 1
|}
----
{{Anchor|CWD}}
=== CWD ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| CWD || <tt>99</tt> || <tt>10011001</tt> || 1 || 1
|}
----
{{Anchor|DAA}}
=== DAA ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| DAA || <tt>27</tt> || <tt>00100111</tt> || 1 || 10
|}
----
{{Anchor|DAS}}
=== DAS ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| DAS || <tt>2F</tt> || <tt>00101111</tt> || 1 || 10
|}
----
{{Anchor|DEC}}
=== DEC ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| DEC mem8 || <tt>FE /1</tt> || <tt>11111110 oo001mmm</tt> || 2+ || 3
|-
| DEC mem16 || <tt>FF /1</tt> || <tt>11111111 oo001mmm</tt> || 2+ || 3
|-
| DEC reg8 || <tt>FE /1</tt> || <tt>11111110 11001mmm</tt> || 2+ || 1
|-
| DEC reg16 || <tt>4x</tt> || <tt>01001rrr</tt> || 1 || 1
|}
----
{{Anchor|DIV}}
=== DIV ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| DIV mem8 || <tt>F6 /6</tt> || <tt>11110110 oo110mmm</tt> || 2+ || 16
|-
| DIV mem16 || <tt>F7 /6</tt> || <tt>11111111 oo110mmm</tt> || 2+ || 24
|-
| DIV reg8 || <tt>F6 /6</tt> || <tt>11111110 11110mmm</tt> || 2 || 15
|-
| DIV reg16 || <tt>F7 /6</tt> || <tt>11111111 11110mmm</tt> || 2 || 23
|}
----
{{Anchor|DS}}
=== DS ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| DS || <tt>3E</tt> || <tt>00111110</tt> || 1 || 1
|}
----
{{Anchor|ENTER}}
=== ENTER ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| ENTER imm16, imm8 || <tt>C8 ii ii jj</tt> || <tt>11001000 iiiiiiii iiiiiiii jjjjjjjj</tt> || 3 || 8 (imm8 = 0)<br/>14 (imm8 = 1)<br/>15 + imm8 * 4 (imm8 >= 2)
|}
----
{{Anchor|ES}}
=== ES ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| ES || <tt>26</tt> || <tt>00100110</tt> || 1 || 1
|}
----
{{Anchor|HLT}}
=== HLT ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| HLT || <tt>F4</tt> || <tt>11110100</tt> || 1 || 9
|}
----
{{Anchor|IDIV}}
=== IDIV ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| IDIV mem8 || <tt>F6 /7</tt> || <tt>11110110 oo111mmm</tt> || 2+ || 18
|-
| IDIV mem16 || <tt>F7 /7</tt> || <tt>11111111 oo111mmm</tt> || 2+ || 25
|-
| IDIV reg8 || <tt>F6 /7</tt> || <tt>11111110 11111mmm</tt> || 2 || 17
|-
| IDIV reg16 || <tt>F7 /7</tt> || <tt>11111111 11111mmm</tt> || 2 || 24
|}
----
{{Anchor|IMUL}}
=== IMUL ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| IMUL mem8 || <tt>F6 /5</tt> || <tt>11110110 oo101mmm</tt> || 2+ || 4
|-
| IMUL mem16 || <tt>F7 /5</tt> || <tt>11111111 oo101mmm</tt> || 2+ || 4
|-
| IMUL reg8 || <tt>F6 /5</tt> || <tt>11111110 11101mmm</tt> || 2 || 3
|-
| IMUL reg16 || <tt>F7 /5</tt> || <tt>11111111 11101mmm</tt> || 2 || 3
|-
| IMUL reg16, mem16, imm16 || <tt>69 /r ii ii</tt> || <tt>11111111 oorrrmmm iiiiiiii iiiiiiii</tt> || 4 || 4
|-
| IMUL reg16, mem16, simm8 || <tt>6B /r ii</tt> || <tt>11111111 oorrrmmm iiiiiiii</tt> || 3 || 4
|-
| IMUL reg16, reg16, imm16 || <tt>69 /r ii ii</tt> || <tt>11111111 11rrrmmm iiiiiiii iiiiiiii</tt> || 4 || 3
|-
| IMUL reg16, reg16, simm8 || <tt>6B /r ii</tt> || <tt>11111111 11rrrmmm iiiiiiii</tt> || 3 || 3
|}
----
{{Anchor|IN}}
=== IN ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| IN AL, DX || <tt>EC</tt> || <tt>11101100</tt> || 1 || 6
|-
| IN AX, DX || <tt>ED</tt> || <tt>11101101</tt> || 1 || 6
|-
| IN AL, imm8 || <tt>E4 ii</tt> || <tt>11100100 iiiiiiii</tt> || 2 || 6
|-
| IN AX, imm8 || <tt>E5 ii</tt> || <tt>11100101 iiiiiiii</tt> || 2 || 6
|}
----
{{Anchor|INC}}
=== INC ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| INC mem8 || <tt>FE /0</tt> || <tt>11111110 oo000mmm</tt> || 2+ || 3
|-
| INC mem16 || <tt>FF /0</tt> || <tt>11111111 oo000mmm</tt> || 2+ || 3
|-
| INC reg8 || <tt>FE /0</tt> || <tt>11111110 11000mmm</tt> || 2+ || 1
|-
| INC reg16 || <tt>4x</tt> || <tt>01000rrr</tt> || 1 || 1
|}
----
{{Anchor|INSB}}
{{Anchor|INSW}}
=== INSB/INSW ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| INSB || <tt>6C</tt> || <tt>01101100</tt> || 1 || 6
|-
| INSW || <tt>6D</tt> || <tt>01101101</tt> || 1 || 6
|}
----
{{Anchor|INT}}
=== INT ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| INT 3 || <tt>CC</tt> || <tt>11001100</tt> || 1 || 9
|-
| INT imm8 || <tt>CD ii</tt> || <tt>11001101 iiiiiiii</tt> || 2 || 10
|}
----
{{Anchor|INTO}}
=== INTO ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| INTO || <tt>CE</tt> || <tt>11001110</tt> || 1 || 6 (13 if OF = 1)
|}
----
{{Anchor|IRET}}
=== IRET ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| IRET || <tt>CF</tt> || <tt>11001111</tt> || 1 || 10
|}
----
{{Anchor|JA}}
=== JA ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JA rel8 || <tt>77 ii</tt> || <tt>01110111 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JBE}}
=== JBE ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JA rel8 || <tt>76 ii</tt> || <tt>01110110 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JC}}
=== JC/JB ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JC rel8 || <tt>72 ii</tt> || <tt>01110010 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JCXZ}}
=== JCXZ ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JCXZ rel8 || <tt>E3 ii</tt> || <tt>11100011 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JG}}
=== JG ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JG rel8 || <tt>7F ii</tt> || <tt>01111111 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JGE}}
=== JGE ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JGE rel8 || <tt>7D ii</tt> || <tt>01111101 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JL}}
=== JL ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JL rel8 || <tt>7C ii</tt> || <tt>01111100 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JLE}}
=== JLE ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JLE rel8 || <tt>7E ii</tt> || <tt>01111110 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JMP}}
=== JMP ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JMP ptr16:16 || <tt>EA oo oo ss ss</tt> || <tt>11101010 oooooooo oooooooo ssssssss ssssssss</tt> || 5 || 7
|-
| JMP mem16 || <tt>FF /4</tt> || <tt>11111111 oo100mmm</tt> || 2+ || 5
|-
| JMP mem16:16 || <tt>FF /5</tt> || <tt>11111111 oo101mmm</tt> || 2+ || 10
|-
| JMP reg16 || <tt>FF /4</tt> || <tt>11111111 11100mmm</tt> || 2 || 4
|-
| JMP rel8 || <tt>EB ii</tt> || <tt>11101011 iiiiiiii</tt> || 2 || 4
|-
| JMP rel16 || <tt>E9 ii ii</tt> || <tt>11101001 iiiiiiii iiiiiiii</tt> || 3 || 4
|}
----
{{Anchor|JNC}}
=== JNC/JAE ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JNC rel8 || <tt>73 ii</tt> || <tt>01110011 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JNO}}
=== JNO ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JNO rel8 || <tt>71 ii</tt> || <tt>01110001 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JNP}}
=== JNP ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JNP rel8 || <tt>7B ii</tt> || <tt>01111011 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JNS}}
=== JNS ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JNS rel8 || <tt>79 ii</tt> || <tt>01111001 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JNZ}}
=== JNZ/JNE ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JNZ rel8 || <tt>75 ii</tt> || <tt>01110101 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JO}}
=== JO ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JO rel8 || <tt>70 ii</tt> || <tt>01110000 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JP}}
=== JP ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JP rel8 || <tt>7A ii</tt> || <tt>01111010 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JS}}
=== JS ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JS rel8 || <tt>78 ii</tt> || <tt>01111000 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JZ}}
=== JZ/JE ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JZ rel8 || <tt>74 ii</tt> || <tt>01110100 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|LAHF}}
=== LAHF ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| LAHF || <tt>9F</tt> || <tt>10011111</tt> || 1 || 2
|}
----
{{Anchor|LDS}}
=== LDS ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| LDS reg16, mem16 || <tt>C5 /r</tt> || <tt>11000101 oorrrmmm</tt> || 2+ || 6
|}
----
{{Anchor|LEA}}
=== LEA ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| LEA reg16, mem16 || <tt>8D /r</tt> || <tt>10001101 oorrrmmm</tt> || 2+ || 1
|}
----
{{Anchor|LEAVE}}
=== LEAVE ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| LEAVE || <tt>C9</tt> || <tt>11001001</tt> || 1 || 2
|}
----
{{Anchor|LES}}
=== LES ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| LES reg16, mem16 || <tt>C4 /r</tt> || <tt>11000100 oorrrmmm</tt> || 2+ || 6
|}
----
{{Anchor|LOCK}}
=== LOCK ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| LOCK || <tt>F0</tt> || <tt>11110000</tt> || 1 || 1
|}
----
{{Anchor|LODSB}}
{{Anchor|LODSW}}
=== LODSB/LODSW ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| LODSB || <tt>AC</tt> || <tt>10101100</tt> || 1 || 3
|-
| LODSW || <tt>AD</tt> || <tt>10101101</tt> || 1 || 3
|}
----
{{Anchor|LOOP}}
=== LOOP ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| LOOP rel8 || <tt>E2 ii</tt> || <tt>11100010 iiiiiiii</tt> || 2 || 2 (5 if branch taken)
|}
----
{{Anchor|LOOPE}}
=== LOOPE ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| LOOPE rel8 || <tt>E1 ii</tt> || <tt>11100001 iiiiiiii</tt> || 2 || 3 (6 if branch taken)
|}
----
{{Anchor|LOOPNE}}
=== LOOPNE ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| LOOPNE rel8 || <tt>E0 ii</tt> || <tt>11100000 iiiiiiii</tt> || 2 || 3 (6 if branch taken)
|}
----
{{Anchor|MOV}}
=== MOV ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| MOV AL, ptr16 || <tt>A0 ii ii</tt> || <tt>10100000 iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| MOV AX, ptr16 || <tt>A1 ii ii</tt> || <tt>10100001 iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| MOV mem8, imm8 || <tt>C6 /0 ii</tt> || <tt>11000110 oo000mmm iiiiiiii</tt> || 3+ || 1
|-
| MOV mem16, imm16 || <tt>C7 /0 ii ii</tt> || <tt>11000111 oo000mmm iiiiiiii iiiiiiii</tt> || 4+ || 1
|-
| MOV mem8, reg8 || <tt>84 /r</tt> || <tt>10001000 oorrrmmm</tt> || 2+ || 1
|-
| MOV mem16, reg16 || <tt>85 /r</tt> || <tt>10001001 oorrrmmm</tt> || 2+ || 1
|-
| MOV mem16, sreg16 || <tt>8C /r</tt> || <tt>10001100 oo0rrmmm</tt> || 2+ || 3
|-
| MOV ptr16, AL || <tt>A2 ii ii</tt> || <tt>10100010 iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| MOV ptr16, AX || <tt>A3 ii ii</tt> || <tt>10100011 iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| MOV reg8, imm8 || <tt>Bx ii</tt> || <tt>10110rrr iiiiiiii</tt> || 2 || 1
|-
| MOV reg8, imm8 || <tt>C6 /0 ii</tt> || <tt>11000110 11000mmm iiiiiiii</tt> || 3 || 1
|-
| MOV reg16, imm16 || <tt>Bx ii</tt> || <tt>10111rrr iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| MOV reg16, imm16 || <tt>C7 /0 ii ii</tt> || <tt>11000111 11000mmm iiiiiiii iiiiiiii</tt> || 4 || 1
|-
| MOV reg8, mem8 || <tt>8A /r</tt> || <tt>10001010 oorrrmmm</tt> || 2+ || 1
|-
| MOV reg16, mem16 || <tt>8B /r</tt> || <tt>10001011 oorrrmmm</tt> || 2+ || 1
|-
| MOV reg8, reg8 || <tt>88 /r</tt> || <tt>100010.0 11rrrmmm</tt> || 2 || 1
|-
| MOV reg16, reg16 || <tt>89 /r</tt> || <tt>100010.1 11rrrmmm</tt> || 2 || 1
|-
| MOV reg16, sreg16 || <tt>8C /r</tt> || <tt>10001100 110rrmmm</tt> || 2 || 1
|-
| MOV sreg16, mem16 || <tt>8E /r</tt> || <tt>10001110 oo0rrmmm</tt> || 2 || 3
|-
| MOV sreg16, reg16 || <tt>8E /r</tt> || <tt>10001110 110rrmmm</tt> || 2+ || 2
|}
----
{{Anchor|MOVSB}}
{{Anchor|MOVSW}}
=== MOVSB/MOVSW ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| MOVSB || <tt>A4</tt> || <tt>10100100</tt> || 1 || 5
|-
| MOVSW || <tt>A5</tt> || <tt>10100101</tt> || 1 || 5
|}
----
{{Anchor|MUL}}
=== MUL ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| MUL mem8 || <tt>F6 /4</tt> || <tt>11110110 oo100mmm</tt> || 2+ || 4
|-
| MUL mem16 || <tt>F7 /4</tt> || <tt>11111111 oo100mmm</tt> || 2+ || 4
|-
| MUL reg8 || <tt>F6 /4</tt> || <tt>11111110 11100mmm</tt> || 2 || 3
|-
| MUL reg16 || <tt>F7 /4</tt> || <tt>11111111 11100mmm</tt> || 2 || 3
|}
----
{{Anchor|NEG}}
=== NEG ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| NEG mem8 || <tt>F6 /3</tt> || <tt>11110110 oo011mmm</tt> || 2+ || 3
|-
| NEG mem16 || <tt>F7 /3</tt> || <tt>11111111 oo011mmm</tt> || 2+ || 3
|-
| NEG reg8 || <tt>F6 /3</tt> || <tt>11111110 11011mmm</tt> || 2 || 1
|-
| NEG reg16 || <tt>F7 /3</tt> || <tt>11111111 11011mmm</tt> || 2 || 1
|}
----
{{Anchor|NOP}}
=== NOP ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| NOP || <tt>90</tt> || <tt>10010000</tt> || 1 || 1
|}
----
{{Anchor|NOT}}
=== NOT ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| NOT mem8 || <tt>F6 /2</tt> || <tt>11110110 oo010mmm</tt> || 2+ || 3
|-
| NOT mem16 || <tt>F7 /2</tt> || <tt>11111111 oo010mmm</tt> || 2+ || 3
|-
| NOT reg8 || <tt>F6 /2</tt> || <tt>11111110 11010mmm</tt> || 2 || 1
|-
| NOT reg16 || <tt>F7 /2</tt> || <tt>11111111 11010mmm</tt> || 2 || 1
|}
----
{{Anchor|OR}}
=== OR ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| OR AL, imm || <tt>0C ii</tt> || <tt>00001100 iiiiiiii</tt> || 2 || 1
|-
| OR AX, imm || <tt>0D ii ii</tt> || <tt>00001101 iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| OR mem8, imm8 || <tt>80 /6 ii</tt> || <tt>10000000 oo001mmm iiiiiiii</tt> || 3+ || 3
|-
| OR mem16, imm16 || <tt>81 /6 ii ii</tt> || <tt>10000001 oo001mmm iiiiiiii iiiiiiii</tt> || 4+ || 3
|-
| OR mem16, simm8 || <tt>83 /6 ii</tt> || <tt>10000011 oo001mmm iiiiiiii</tt> || 3+ || 3
|-
| OR mem8, reg8 || <tt>08 /r</tt> || <tt>00001000 oorrrmmm</tt> || 2+ || 3
|-
| OR mem16, reg16 || <tt>09 /r</tt> || <tt>00001001 oorrrmmm</tt> || 2+ || 3
|-
| OR reg8, imm8 || <tt>80 /6 ii</tt> || <tt>10000000 11001mmm iiiiiiii</tt> || 3 || 1
|-
| OR reg16, imm16 || <tt>81 /6 ii ii</tt> || <tt>10000001 11001mmm iiiiiiii iiiiiiii</tt> || 4 || 1
|-
| OR reg16, simm8 || <tt>83 /6 ii</tt> || <tt>10000011 11001mmm iiiiiiii</tt> || 3 || 1
|-
| OR reg8, mem8 || <tt>0A /r</tt> || <tt>00001010 oorrrmmm</tt> || 2+ || 2
|-
| OR reg16, mem16 || <tt>0B /r</tt> || <tt>00001011 oorrrmmm</tt> || 2+ || 2
|-
| OR reg8, reg8 || <tt>08 /r</tt> || <tt>000010.0 11rrrmmm</tt> || 2 || 1
|-
| OR reg16, reg16 || <tt>09 /r</tt> || <tt>000010.1 11rrrmmm</tt> || 2 || 1
|}
----
{{Anchor|OUT}}
=== OUT ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| OUT AL, DX || <tt>EE</tt> || <tt>11101110</tt> || 1 || 6
|-
| OUT AX, DX || <tt>EF</tt> || <tt>11101111</tt> || 1 || 6
|-
| OUT AL, imm8 || <tt>E6 ii</tt> || <tt>11100110 iiiiiiii</tt> || 2 || 6
|-
| OUT AX, imm8 || <tt>E7 ii</tt> || <tt>11100111 iiiiiiii</tt> || 2 || 6
|}
----
{{Anchor|OUTSB}}
{{Anchor|OUTSW}}
=== OUTSB/OUTSW ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| OUTSB || <tt>6E</tt> || <tt>01101110</tt> || 1 || 6
|-
| OUTSW || <tt>6F</tt> || <tt>01101111</tt> || 1 || 6
|}
----
{{Anchor|POLL}}
=== POLL ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| POLL || <tt>6E</tt> || <tt>01101110</tt> || 1 || 9<ref>On the WonderSwan implementation, POLLB is always held low; on other implementations, POLL will wait for POLLB to be held low in 9-cycle intervals.</ref>
|}
----
{{Anchor|POP}}
=== POP ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| POP mem16 || <tt>8F /0</tt> || <tt>10001111 oo000mmm</tt> || 2+ || 3
|-
| POP reg16 || <tt>5x</tt> || <tt>01011xxx</tt> || 1 || 1
|-
| POP reg16 || <tt>8F /0</tt> || <tt>10001111 11000mmm</tt> || 2 || 1
|-
| POP sreg16 || <tt>xx</tt> || <tt>000xx111</tt> || 1 || 3
|}
----
{{Anchor|POPA}}
=== POPA ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| POPA || <tt>61</tt> || <tt>01100001</tt> || 1 || 8
|}
----
{{Anchor|POPF}}
=== POPF ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| POPF || <tt>9D</tt> || <tt>10011101</tt> || 1 || 3
|}
----
{{Anchor|PUSH}}
=== PUSH ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| PUSH imm8 || <tt>6A ii</tt> || <tt>01101010 iiiiiiii</tt> || 2 || 1
|-
| PUSH imm16 || <tt>68 ii ii</tt> || <tt>01101000 iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| PUSH mem16 || <tt>FF /6</tt> || <tt>11111111 oo110mmm</tt> || 2+ || 2
|-
| PUSH reg16 || <tt>5x</tt> || <tt>01010xxx</tt> || 1 || 1
|-
| PUSH reg16 || <tt>FF /6</tt> || <tt>11111111 11110mmm</tt> || 2 || 1
|-
| PUSH sreg16 || <tt>xx</tt> || <tt>000xx110</tt> || 1 || 2
|}
----
{{Anchor|PUSHA}}
=== PUSHA ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| PUSHA || <tt>60</tt> || <tt>01100000</tt> || 1 || 9
|}
----
{{Anchor|PUSHF}}
=== PUSHF ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| PUSHF || <tt>9C</tt> || <tt>10011100</tt> || 1 || 2
|}
----
{{Anchor|RCL}}
=== RCL ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| RCL mem8, 1 || <tt>D0 /2</tt> || <tt>11010000 oo010rm</tt> || 2+ || 3
|-
| RCL mem8, CL || <tt>D2 /2</tt> || <tt>11010010 oo010rm</tt> || 2+ || 5
|-
| RCL mem8, imm8 || <tt>C0 /2 ii</tt> || <tt>11000000 oo010mmm iiiiiiii</tt> || 3+ || 5
|-
| RCL mem16, 1 || <tt>D1 /2</tt> || <tt>11010001 oo010rm</tt> || 2+ || 3
|-
| RCL mem16, CL || <tt>D3 /2</tt> || <tt>11010011 oo010rm</tt> || 2+ || 5
|-
| RCL mem16, imm8 || <tt>C1 /2 ii</tt> || <tt>11000001 oo010mmm iiiiiiii</tt> || 3+ || 5
|-
| RCL reg8, 1 || <tt>D0 /2</tt> || <tt>11010000 11010rm</tt> || 2 || 1
|-
| RCL reg8, CL || <tt>D2 /2</tt> || <tt>11010010 11010rm</tt> || 2 || 3
|-
| RCL reg8, imm8 || <tt>C0 /2 ii</tt> || <tt>11000000 11010mmm iiiiiiii</tt> || 3 || 3
|-
| RCL reg16, 1 || <tt>D1 /2</tt> || <tt>11010001 11010rm</tt> || 2 || 1
|-
| RCL reg16, CL || <tt>D3 /2</tt> || <tt>11010011 11010rm</tt> || 2 || 3
|-
| RCL reg16, imm8 || <tt>C1 /2 ii</tt> || <tt>11000001 11010mmm iiiiiiii</tt> || 3 || 3
|}
----
{{Anchor|RCR}}
=== RCR ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| RCR mem8, 1 || <tt>D0 /3</tt> || <tt>11010000 oo011rm</tt> || 2+ || 3
|-
| RCR mem8, CL || <tt>D2 /3</tt> || <tt>11010010 oo011rm</tt> || 2+ || 5
|-
| RCR mem8, imm8 || <tt>C0 /3 ii</tt> || <tt>11000000 oo011mmm iiiiiiii</tt> || 3+ || 5
|-
| RCR mem16, 1 || <tt>D1 /3</tt> || <tt>11010001 oo011rm</tt> || 2+ || 3
|-
| RCR mem16, CL || <tt>D3 /3</tt> || <tt>11010011 oo011rm</tt> || 2+ || 5
|-
| RCR mem16, imm8 || <tt>C1 /3 ii</tt> || <tt>11000001 oo011mmm iiiiiiii</tt> || 3+ || 5
|-
| RCR reg8, 1 || <tt>D0 /3</tt> || <tt>11010000 11011rm</tt> || 2 || 1
|-
| RCR reg8, CL || <tt>D2 /3</tt> || <tt>11010010 11011rm</tt> || 2 || 3
|-
| RCR reg8, imm8 || <tt>C0 /3 ii</tt> || <tt>11000000 11011mmm iiiiiiii</tt> || 3 || 3
|-
| RCR reg16, 1 || <tt>D1 /3</tt> || <tt>11010001 11011rm</tt> || 2 || 1
|-
| RCR reg16, CL || <tt>D3 /3</tt> || <tt>11010011 11011rm</tt> || 2 || 3
|-
| RCR reg16, imm8 || <tt>C1 /3 ii</tt> || <tt>11000001 11011mmm iiiiiiii</tt> || 3 || 3
|}
----
{{Anchor|REP}}
=== REP/REPE/REPZ ===
----
{{Anchor|REPNE}}
=== REPNE/REPNZ ===
----
{{Anchor|RET}}
=== RET ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| RET || <tt>C3</tt> || <tt>11000011</tt> || 1 || 6
|-
| RET imm16 || <tt>C2 ii ii</tt> || <tt>11000010 iiiiiiii iiiiiiii</tt> || 1 || 6
|}
----
{{Anchor|RETF}}
=== RETF ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| RETF || <tt>CB</tt> || <tt>11001011</tt> || 1 || 9
|-
| RETF imm16 || <tt>CA ii ii</tt> || <tt>11001010 iiiiiiii iiiiiiii</tt> || 1 || 8
|}
----
{{Anchor|ROL}}
=== ROL ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| ROL mem8, 1 || <tt>D0 /0</tt> || <tt>11010000 oo000rm</tt> || 2+ || 3
|-
| ROL mem8, CL || <tt>D2 /0</tt> || <tt>11010010 oo000rm</tt> || 2+ || 5
|-
| ROL mem8, imm8 || <tt>C0 /0 ii</tt> || <tt>11000000 oo000mmm iiiiiiii</tt> || 3+ || 5
|-
| ROL mem16, 1 || <tt>D1 /0</tt> || <tt>11010001 oo000rm</tt> || 2+ || 3
|-
| ROL mem16, CL || <tt>D3 /0</tt> || <tt>11010011 oo000rm</tt> || 2+ || 5
|-
| ROL mem16, imm8 || <tt>C1 /0 ii</tt> || <tt>11000001 oo000mmm iiiiiiii</tt> || 3+ || 5
|-
| ROL reg8, 1 || <tt>D0 /0</tt> || <tt>11010000 11000rm</tt> || 2 || 1
|-
| ROL reg8, CL || <tt>D2 /0</tt> || <tt>11010010 11000rm</tt> || 2 || 3
|-
| ROL reg8, imm8 || <tt>C0 /0 ii</tt> || <tt>11000000 11000mmm iiiiiiii</tt> || 3 || 3
|-
| ROL reg16, 1 || <tt>D1 /0</tt> || <tt>11010001 11000rm</tt> || 2 || 1
|-
| ROL reg16, CL || <tt>D3 /0</tt> || <tt>11010011 11000rm</tt> || 2 || 3
|-
| ROL reg16, imm8 || <tt>C1 /0 ii</tt> || <tt>11000001 11000mmm iiiiiiii</tt> || 3 || 3
|}
----
{{Anchor|ROR}}
=== ROR ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| ROR mem8, 1 || <tt>D0 /1</tt> || <tt>11010000 oo001rm</tt> || 2+ || 3
|-
| ROR mem8, CL || <tt>D2 /1</tt> || <tt>11010010 oo001rm</tt> || 2+ || 5
|-
| ROR mem8, imm8 || <tt>C0 /1 ii</tt> || <tt>11000000 oo001mmm iiiiiiii</tt> || 3+ || 5
|-
| ROR mem16, 1 || <tt>D1 /1</tt> || <tt>11010001 oo001rm</tt> || 2+ || 3
|-
| ROR mem16, CL || <tt>D3 /1</tt> || <tt>11010011 oo001rm</tt> || 2+ || 5
|-
| ROR mem16, imm8 || <tt>C1 /1 ii</tt> || <tt>11000001 oo001mmm iiiiiiii</tt> || 3+ || 5
|-
| ROR reg8, 1 || <tt>D0 /1</tt> || <tt>11010000 11001rm</tt> || 2 || 1
|-
| ROR reg8, CL || <tt>D2 /1</tt> || <tt>11010010 11001rm</tt> || 2 || 3
|-
| ROR reg8, imm8 || <tt>C0 /1 ii</tt> || <tt>11000000 11001mmm iiiiiiii</tt> || 3 || 3
|-
| ROR reg16, 1 || <tt>D1 /1</tt> || <tt>11010001 11001rm</tt> || 2 || 1
|-
| ROR reg16, CL || <tt>D3 /1</tt> || <tt>11010011 11001rm</tt> || 2 || 3
|-
| ROR reg16, imm8 || <tt>C1 /1 ii</tt> || <tt>11000001 11001mmm iiiiiiii</tt> || 3 || 3
|}
----
{{Anchor|SAHF}}
=== SAHF ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| SAHF || <tt>9E</tt> || <tt>10011110</tt> || 1 || 4
|}
----
{{Anchor|SAR}}
=== SAR ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| SAR mem8, 1 || <tt>D0 /7</tt> || <tt>11010000 oo111rm</tt> || 2+ || 3
|-
| SAR mem8, CL || <tt>D2 /7</tt> || <tt>11010010 oo111rm</tt> || 2+ || 5
|-
| SAR mem8, imm8 || <tt>C0 /7 ii</tt> || <tt>11000000 oo111mmm iiiiiiii</tt> || 3+ || 5
|-
| SAR mem16, 1 || <tt>D1 /7</tt> || <tt>11010001 oo111rm</tt> || 2+ || 3
|-
| SAR mem16, CL || <tt>D3 /7</tt> || <tt>11010011 oo111rm</tt> || 2+ || 5
|-
| SAR mem16, imm8 || <tt>C1 /7 ii</tt> || <tt>11000001 oo111mmm iiiiiiii</tt> || 3+ || 5
|-
| SAR reg8, 1 || <tt>D0 /7</tt> || <tt>11010000 11111rm</tt> || 2 || 1
|-
| SAR reg8, CL || <tt>D2 /7</tt> || <tt>11010010 11111rm</tt> || 2 || 3
|-
| SAR reg8, imm8 || <tt>C0 /7 ii</tt> || <tt>11000000 11111mmm iiiiiiii</tt> || 3 || 3
|-
| SAR reg16, 1 || <tt>D1 /7</tt> || <tt>11010001 11111rm</tt> || 2 || 1
|-
| SAR reg16, CL || <tt>D3 /7</tt> || <tt>11010011 11111rm</tt> || 2 || 3
|-
| SAR reg16, imm8 || <tt>C1 /7 ii</tt> || <tt>11000001 11111mmm iiiiiiii</tt> || 3 || 3
|}
----
{{Anchor|SBB}}
=== SBB ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| SBB AL, imm || <tt>1C ii</tt> || <tt>00011100 iiiiiiii</tt> || 2 || 1
|-
| SBB AX, imm || <tt>1D ii ii</tt> || <tt>00011101 iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| SBB mem8, imm8 || <tt>80 /3 ii</tt> || <tt>10000000 oo011mmm iiiiiiii</tt> || 3+ || 3
|-
| SBB mem16, imm16 || <tt>81 /3 ii ii</tt> || <tt>10000001 oo011mmm iiiiiiii iiiiiiii</tt> || 4+ || 3
|-
| SBB mem16, simm8 || <tt>83 /3 ii</tt> || <tt>10000011 oo011mmm iiiiiiii</tt> || 3+ || 3
|-
| SBB mem8, reg8 || <tt>18 /r</tt> || <tt>00011000 oorrrmmm</tt> || 2+ || 3
|-
| SBB mem16, reg16 || <tt>19 /r</tt> || <tt>00011001 oorrrmmm</tt> || 2+ || 3
|-
| SBB reg8, imm8 || <tt>80 /3 ii</tt> || <tt>10000000 11011mmm iiiiiiii</tt> || 3 || 1
|-
| SBB reg16, imm16 || <tt>81 /3 ii ii</tt> || <tt>10000001 11011mmm iiiiiiii iiiiiiii</tt> || 4 || 1
|-
| SBB reg16, simm8 || <tt>83 /3 ii</tt> || <tt>10000011 11011mmm iiiiiiii</tt> || 3 || 1
|-
| SBB reg8, mem8 || <tt>1A /r</tt> || <tt>00011010 oorrrmmm</tt> || 2+ || 2
|-
| SBB reg16, mem16 || <tt>1B /r</tt> || <tt>00011011 oorrrmmm</tt> || 2+ || 2
|-
| SBB reg8, reg8 || <tt>18 /r</tt> || <tt>000110.0 11rrrmmm</tt> || 2 || 1
|-
| SBB reg16, reg16 || <tt>19 /r</tt> || <tt>000110.1 11rrrmmm</tt> || 2 || 1
|}
----
{{Anchor|SCASB}}
{{Anchor|SCASW}}
=== SCASB/SCASW ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| SCASB || <tt>AE</tt> || <tt>10101110</tt> || 1 || 4
|-
| SCASW || <tt>AF</tt> || <tt>10101111</tt> || 1 || 4
|}
----
{{Anchor|SHL}}
=== SHL ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| SHL mem8, 1 || <tt>D0 /4</tt> || <tt>11010000 oo100rm</tt> || 2+ || 3
|-
| SHL mem8, CL || <tt>D2 /4</tt> || <tt>11010010 oo100rm</tt> || 2+ || 5
|-
| SHL mem8, imm8 || <tt>C0 /4 ii</tt> || <tt>11000000 oo100mmm iiiiiiii</tt> || 3+ || 5
|-
| SHL mem16, 1 || <tt>D1 /4</tt> || <tt>11010001 oo100rm</tt> || 2+ || 3
|-
| SHL mem16, CL || <tt>D3 /4</tt> || <tt>11010011 oo100rm</tt> || 2+ || 5
|-
| SHL mem16, imm8 || <tt>C1 /4 ii</tt> || <tt>11000001 oo100mmm iiiiiiii</tt> || 3+ || 5
|-
| SHL reg8, 1 || <tt>D0 /4</tt> || <tt>11010000 11100rm</tt> || 2 || 1
|-
| SHL reg8, CL || <tt>D2 /4</tt> || <tt>11010010 11100rm</tt> || 2 || 3
|-
| SHL reg8, imm8 || <tt>C0 /4 ii</tt> || <tt>11000000 11100mmm iiiiiiii</tt> || 3 || 3
|-
| SHL reg16, 1 || <tt>D1 /4</tt> || <tt>11010001 11100rm</tt> || 2 || 1
|-
| SHL reg16, CL || <tt>D3 /4</tt> || <tt>11010011 11100rm</tt> || 2 || 3
|-
| SHL reg16, imm8 || <tt>C1 /4 ii</tt> || <tt>11000001 11100mmm iiiiiiii</tt> || 3 || 3
|}
----
{{Anchor|SHR}}
=== SHR ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| SHR mem8, 1 || <tt>D0 /5</tt> || <tt>11010000 oo101rm</tt> || 2+ || 3
|-
| SHR mem8, CL || <tt>D2 /5</tt> || <tt>11010010 oo101rm</tt> || 2+ || 5
|-
| SHR mem8, imm8 || <tt>C0 /5 ii</tt> || <tt>11000000 oo101mmm iiiiiiii</tt> || 3+ || 5
|-
| SHR mem16, 1 || <tt>D1 /5</tt> || <tt>11010001 oo101rm</tt> || 2+ || 3
|-
| SHR mem16, CL || <tt>D3 /5</tt> || <tt>11010011 oo101rm</tt> || 2+ || 5
|-
| SHR mem16, imm8 || <tt>C1 /5 ii</tt> || <tt>11000001 oo101mmm iiiiiiii</tt> || 3+ || 5
|-
| SHR reg8, 1 || <tt>D0 /5</tt> || <tt>11010000 11101rm</tt> || 2 || 1
|-
| SHR reg8, CL || <tt>D2 /5</tt> || <tt>11010010 11101rm</tt> || 2 || 3
|-
| SHR reg8, imm8 || <tt>C0 /5 ii</tt> || <tt>11000000 11101mmm iiiiiiii</tt> || 3 || 3
|-
| SHR reg16, 1 || <tt>D1 /5</tt> || <tt>11010001 11101rm</tt> || 2 || 1
|-
| SHR reg16, CL || <tt>D3 /5</tt> || <tt>11010011 11101rm</tt> || 2 || 3
|-
| SHR reg16, imm8 || <tt>C1 /5 ii</tt> || <tt>11000001 11101mmm iiiiiiii</tt> || 3 || 3
|}
----
{{Anchor|SS}}
=== SS ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| SS || <tt>36</tt> || <tt>00110110</tt> || 1 || 1
|}
----
{{Anchor|STC}}
=== STC ===
{| class="wikitable"
! Flag !! New value
|-
| [[NEC_V30MZ_flags#CF|CF - Carry]] || 1
|}
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| STC || <tt>F9</tt> || <tt>11111001</tt> || 1 || 4
|}
----
{{Anchor|STD}}
=== STD ===
{| class="wikitable"
! Flag !! New value
|-
| [[NEC_V30MZ_flags#DF|DF - Direction]] || 1
|}
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| STD || <tt>FD</tt> || <tt>11111101</tt> || 1 || 4
|}
----
{{Anchor|STI}}
=== STI ===
{| class="wikitable"
! Flag !! New value
|-
| [[NEC_V30MZ_flags#IF|IF - Interrupt]] || 1
|}
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| STI || <tt>FB</tt> || <tt>11111011</tt> || 1 || 4
|}
----
{{Anchor|STOSB}}
{{Anchor|STOSW}}
=== STOSB/STOSW ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| STOSB || <tt>AA</tt> || <tt>10101010</tt> || 1 || 3
|-
| STOSW || <tt>AB</tt> || <tt>10101011</tt> || 1 || 3
|}
----
{{Anchor|SUB}}
=== SUB ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| SUB AL, imm || <tt>28 ii</tt> || <tt>00101100 iiiiiiii</tt> || 2 || 1
|-
| SUB AX, imm || <tt>29 ii ii</tt> || <tt>00101101 iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| SUB mem8, imm8 || <tt>80 /5 ii</tt> || <tt>10000000 oo101mmm iiiiiiii</tt> || 3+ || 3
|-
| SUB mem16, imm16 || <tt>81 /5 ii ii</tt> || <tt>10000001 oo101mmm iiiiiiii iiiiiiii</tt> || 4+ || 3
|-
| SUB mem16, simm8 || <tt>83 /5 ii</tt> || <tt>10000011 oo101mmm iiiiiiii</tt> || 3+ || 3
|-
| SUB mem8, reg8 || <tt>28 /r</tt> || <tt>00101000 oorrrmmm</tt> || 2+ || 3
|-
| SUB mem16, reg16 || <tt>29 /r</tt> || <tt>00101001 oorrrmmm</tt> || 2+ || 3
|-
| SUB reg8, imm8 || <tt>80 /5 ii</tt> || <tt>10000000 11101mmm iiiiiiii</tt> || 3 || 1
|-
| SUB reg16, imm16 || <tt>81 /5 ii ii</tt> || <tt>10000001 11101mmm iiiiiiii iiiiiiii</tt> || 4 || 1
|-
| SUB reg16, simm8 || <tt>83 /5 ii</tt> || <tt>10000011 11101mmm iiiiiiii</tt> || 3 || 1
|-
| SUB reg8, mem8 || <tt>2A /r</tt> || <tt>00101010 oorrrmmm</tt> || 2+ || 2
|-
| SUB reg16, mem16 || <tt>2B /r</tt> || <tt>00101011 oorrrmmm</tt> || 2+ || 2
|-
| SUB reg8, reg8 || <tt>28 /r</tt> || <tt>001010.0 11rrrmmm</tt> || 2 || 1
|-
| SUB reg16, reg16 || <tt>29 /r</tt> || <tt>001010.1 11rrrmmm</tt> || 2 || 1
|}
----
{{Anchor|TEST}}
=== TEST ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| TEST AL, imm || <tt>A8 ii</tt> || <tt>10101000 iiiiiiii</tt> || 2 || 1
|-
| TEST AX, imm || <tt>A9 ii ii</tt> || <tt>10101001 iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| TEST mem8, imm8 || <tt>F6 /0 ii</tt> || <tt>11110110 oo000mmm iiiiiiii</tt> || 3+ || 2
|-
| TEST mem16, imm16 || <tt>F7 /0 ii ii</tt> || <tt>11110111 oo000mmm iiiiiiii iiiiiiii</tt> || 4+ || 2
|-
| TEST mem8, reg8<br/>TEST reg8, mem8 || <tt>84 /r</tt> || <tt>10000100 oorrrmmm</tt> || 2+ || 2
|-
| TEST mem16, reg16<br/>TEST reg16, mem16 || <tt>85 /r</tt> || <tt>10000101 oorrrmmm</tt> || 2+ || 2
|-
| TEST reg8, imm8 || <tt>F6 /0 ii</tt> || <tt>11110110 11000mmm iiiiiiii</tt> || 3 || 1
|-
| TEST reg16, imm16 || <tt>F7 /0 ii ii</tt> || <tt>11110111 11000mmm iiiiiiii iiiiiiii</tt> || 4 || 1
|-
| TEST reg8, reg8 || <tt>84 /r</tt> || <tt>10000100 11rrrmmm</tt> || 2 || 1
|-
| TEST reg16, reg16 || <tt>85 /r</tt> || <tt>10000101 11rrrmmm</tt> || 2 || 1
|}
----
{{Anchor|XCHG}}
=== XCHG ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| XCHG AX, reg16<br/>XCHG reg16, AX || <tt>9x</tt> || <tt>10010rrr</tt> || 1 || 3
|-
| XCHG mem8, reg8<br/>XCHG reg8, mem8 || <tt>86 /r</tt> || <tt>10000110 oorrrmmm</tt> || 2+ || 5
|-
| XCHG mem16, reg16<br/>XCHG reg16, mem16 || <tt>87 /r</tt> || <tt>10000111 oorrrmmm</tt> || 2+ || 5
|-
| XCHG reg8, reg8 || <tt>86 /r</tt> || <tt>10000110 11rrrmmm</tt> || 2+ || 3
|-
| XCHG reg16, reg16 || <tt>87 /r</tt> || <tt>10000111 11rrrmmm</tt> || 2+ || 3
|}
----
{{Anchor|XLAT}}
=== XLAT ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| XLAT || <tt>D7</tt> || <tt>11010111</tt> || 1 || 5
|}
----
{{Anchor|XOR}}
=== XOR ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| XOR AL, imm || <tt>34 ii</tt> || <tt>00110100 iiiiiiii</tt> || 2 || 1
|-
| XOR AX, imm || <tt>35 ii ii</tt> || <tt>00110101 iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| XOR mem8, imm8 || <tt>80 /6 ii</tt> || <tt>10000000 oo110mmm iiiiiiii</tt> || 3+ || 3
|-
| XOR mem16, imm16 || <tt>81 /6 ii ii</tt> || <tt>10000001 oo110mmm iiiiiiii iiiiiiii</tt> || 4+ || 3
|-
| XOR mem16, simm8 || <tt>83 /6 ii</tt> || <tt>10000011 oo110mmm iiiiiiii</tt> || 3+ || 3
|-
| XOR mem8, reg8 || <tt>30 /r</tt> || <tt>00110000 oorrrmmm</tt> || 2+ || 3
|-
| XOR mem16, reg16 || <tt>31 /r</tt> || <tt>00110001 oorrrmmm</tt> || 2+ || 3
|-
| XOR reg8, imm8 || <tt>80 /6 ii</tt> || <tt>10000000 11110mmm iiiiiiii</tt> || 3 || 1
|-
| XOR reg16, imm16 || <tt>81 /6 ii ii</tt> || <tt>10000001 11110mmm iiiiiiii iiiiiiii</tt> || 4 || 1
|-
| XOR reg16, simm8 || <tt>83 /6 ii</tt> || <tt>10000011 11110mmm iiiiiiii</tt> || 3 || 1
|-
| XOR reg8, mem8 || <tt>32 /r</tt> || <tt>00110010 oorrrmmm</tt> || 2+ || 2
|-
| XOR reg16, mem16 || <tt>33 /r</tt> || <tt>00110011 oorrrmmm</tt> || 2+ || 2
|-
| XOR reg8, reg8 || <tt>30 /r</tt> || <tt>001100.0 11rrrmmm</tt> || 2 || 1
|-
| XOR reg16, reg16 || <tt>31 /r</tt> || <tt>001100.1 11rrrmmm</tt> || 2 || 1
|}
== Notes ==
<references />
e1dfb756a5671ab1b749ccc85242ebba19bdbd43
481
468
2024-12-31T10:12:53Z
Asie
351
/* RETF */ fix cycle counts
wikitext
text/x-wiki
__NOTOC__
Note that this page is a work in progress.
{| class="wikitable" style="text-align: center"
|+ Official V30MZ (80186) Instructions
|-
| [[#AAA|AAA]] || [[#AAD|AAD]] || [[#AAM|AAM]] || [[#AAS|AAS]] || [[#ADC|ADC]] || [[#ADD|ADD]] || [[#AND|AND]] || [[#BOUND|BOUND]] || [[#CALL|CALL]] || [[#CBW|CBW]] || [[#CLC|CLC]]
|-
| [[#CLD|CLD]] || [[#CLI|CLI]] || [[#CMC|CMC]] || [[#CMP|CMP]] || [[#CMPSB|CMPSB]] || [[#CMPSW|CMPSW]] || [[#CS|CS]] || [[#CWD|CWD]] || [[#DAA|DAA]] || [[#DAS|DAS]] || [[#DEC|DEC]]
|-
| [[#DIV|DIV]] || [[#DS|DS]] || [[#ENTER|ENTER]] || [[#ES|ES]] || [[#HLT|HLT]] || [[#IDIV|IDIV]] || [[#IMUL|IMUL]] || [[#IN|IN]] || [[#INC|INC]] || [[#INSB|INSB]] || [[#INSW|INSW]]
|-
| [[#INT|INT]] || [[#INTO|INTO]] || [[#IRET|IRET]] || [[#JA|JA]] || [[#JBE|JBE]] || [[#JC|JC]] || [[#JCXZ|JCXZ]] || [[#JG|JG]] || [[#JGE|JGE]] || [[#JL|JL]] || [[#JLE|JLE]]
|-
| [[#JMP|JMP]] || [[#JNC|JNC]] || [[#JNO|JNO]] || [[#JNP|JNP]] || [[#JNS|JNS]] || [[#JNZ|JNZ]] || [[#JO|JO]] || [[#JP|JP]] || [[#JS|JS]] || [[#JZ|JZ]] || [[#LAHF|LAHF]]
|-
| [[#LDS|LDS]] || [[#LEA|LEA]] || [[#LEAVE|LEAVE]] || [[#LES|LES]] || [[#LOCK|LOCK]] || [[#LODSB|LODSB]] || [[#LODSW|LODSW]] || [[#LOOP|LOOP]] || [[#LOOPE|LOOPE]] || [[#LOOPNE|LOOPNE]] || [[#MOV|MOV]]
|-
| [[#MOVSB|MOVSB]] || [[#MOVSW|MOVSW]] || [[#MUL|MUL]] || [[#NEG|NEG]] || [[#NOP|NOP]] || [[#NOT|NOT]] || [[#OR|OR]] || [[#OUT|OUT]] || [[#OUTSB|OUTSB]] || [[#OUTSW|OUTSW]] || [[#POLL|POLL]]
|-
| [[#POP|POP]] || [[#POPA|POPA]] || [[#POPF|POPF]] || [[#PUSH|PUSH]] || [[#PUSHA|PUSHA]] || [[#PUSHF|PUSHF]] || [[#RCL|RCL]] || [[#RCR|RCR]] || [[#REP|REP]] || [[#REPNE|REPNE]] || [[#RET|RET]]
|-
| [[#RETF|RETF]] || [[#ROL|ROL]] || [[#ROR|ROR]] || [[#SAHF|SAHF]] || [[#SAR|SAR]] || [[#SBB|SBB]] || [[#SCASB|SCASB]] || [[#SCASW|SCASW]] || [[#SHL|SHL]] || [[#SHR|SHR]] || [[#SS|SS]]
|-
| [[#STC|STC]] || [[#STD|STD]] || [[#STI|STI]] || [[#STOSB|STOSB]] || [[#STOSW|STOSW]] || [[#SUB|SUB]] || [[#TEST|TEST]] || [[#XCHG|XCHG]] || [[#XLAT|XLAT]] || [[#XOR|XOR]]
|}
{| class="mw-collapsible mw-collapsed wikitable sortable" style="width: 340px;"
|+ style="white-space:nowrap; border:1px solid; padding:3px; border-color:rgb(162, 169, 177); background-color:rgb(234, 236, 240);" | Intel <-> NEC mnemonic translation table
!Intel
!NEC
|-
| [[#AAA|AAA]]
| [[#AAA|ADJBA]]
|-
| [[#AAD|AAD]]
| [[#AAD|CVTDB]]
|-
| [[#AAM|AAM]]
| [[#AAM|CVTBD]]
|-
| [[#AAS|AAS]]
| [[#AAS|ADJBS]]
|-
| [[#ADC|ADC]]
| [[#ADC|ADDC]]
|-
| [[#ADD|ADD]]
| [[#ADD|ADD]]
|-
| [[#AND|AND]]
| [[#AND|AND]]
|-
| [[#BOUND|BOUND]]
| [[#BOUND|CHKIND]]
|-
| [[#CALL|CALL]]
| [[#CALL|CALL]]
|-
| [[#CBW|CBW]]
| [[#CBW|CVTBW]]
|-
| [[#CLC|CLC]]
| [[#CLC|CLR1 CY]]
|-
| [[#CLD|CLD]]
| [[#CLD|CLR1 DIR]]
|-
| [[#CLI|CLI]]
| [[#CLI|DI]]
|-
| [[#CMC|CMC]]
| [[#CMC|NOT1 CY]]
|-
| [[#CMP|CMP]]
| [[#CMP|CMP]]
|-
| [[#CMPSB|CMPSB]]
| [[#CMPSB|CMPBKB]]
|-
| [[#CMPSW|CMPSW]]
| [[#CMPSW|CMPBKW]]
|-
| [[#CS|CS]]
| [[#CS|PS]]
|-
| [[#CWD|CWD]]
| [[#CWD|CVTWL]]
|-
| [[#DAA|DAA]]
| [[#DAA|ADJ4A]]
|-
| [[#DAS|DAS]]
| [[#DAS|ADJ4S]]
|-
| [[#DEC|DEC]]
| [[#DEC|DEC]]
|-
| [[#DIV|DIV]]
| [[#DIV|DIVU]]
|-
| [[#DS|DS]]
| [[#DS|DS0]]
|-
| [[#ENTER|ENTER]]
| [[#ENTER|PREPARE]]
|-
| [[#ES|ES]]
| [[#ES|DS1]]
|-
| [[#HLT|HLT]]
| [[#HLT|HALT]]
|-
| [[#IDIV|IDIV]]
| [[#IDIV|DIV]]
|-
| [[#IMUL|IMUL]]
| [[#IMUL|MUL]]
|-
| [[#IN|IN]]
| [[#IN|IN]]
|-
| [[#INC|INC]]
| [[#INC|INC]]
|-
| [[#INSB|INSB]]
| [[#INSB|INMB]]
|-
| [[#INSW|INSW]]
| [[#INSW|INMW]]
|-
| [[#INT|INT]]
| [[#INT|BRK]]
|-
| [[#INTO|INTO]]
| [[#INTO|BRKV]]
|-
| [[#IRET|IRET]]
| [[#IRET|RETI]]
|-
| [[#JA|JA]]
| [[#JA|BH]]
|-
| [[#JBE|JBE]]
| [[#JBE|BNH]]
|-
| [[#JC|JC/JB]]
| [[#JC|BC/BL]]
|-
| [[#JCXZ|JCXZ]]
| [[#JCXZ|BCWZ]]
|-
| [[#JG|JG]]
| [[#JG|BGT]]
|-
| [[#JGE|JGE]]
| [[#JGE|BGE]]
|-
| [[#JL|JL]]
| [[#JL|BLT]]
|-
| [[#JLE|JLE]]
| [[#JLE|BLE]]
|-
| [[#JMP|JMP]]
| [[#JMP|BR]]
|-
| [[#JNC|JNC/JAE]]
| [[#JNC|BNC/BNL]]
|-
| [[#JNO|JNO]]
| [[#JNO|BNV]]
|-
| [[#JNP|JNP]]
| [[#JNP|BPO]]
|-
| [[#JNS|JNS]]
| [[#JNS|BP]]
|-
| [[#JNZ|JNZ/JNE]]
| [[#JNZ|BNZ/BNE]]
|-
| [[#JO|JO]]
| [[#JO|BV]]
|-
| [[#JP|JP]]
| [[#JP|BPE]]
|-
| [[#JS|JS]]
| [[#JS|BN]]
|-
| [[#JZ|JZ/JE]]
| [[#JZ|BZ/BE]]
|-
| [[#LAHF|LAHF]]
| [[#LAHF|MOV]]
|-
| [[#LDS|LDS]]
| [[#LDS|MOV]]
|-
| [[#LEA|LEA]]
| [[#LEA|LDEA]]
|-
| [[#LEAVE|LEAVE]]
| [[#LEAVE|DISPOSE]]
|-
| [[#LES|LES]]
| [[#LES|MOV]]
|-
| [[#LOCK|LOCK]]
| [[#LOCK|BUSLOCK]]
|-
| [[#LODSB|LODSB]]
| [[#LODSB|LDMB]]
|-
| [[#LODSW|LODSW]]
| [[#LODSW|LDMW]]
|-
| [[#LOOP|LOOP]]
| [[#LOOP|DBNZ]]
|-
| [[#LOOPE|LOOPE]]
| [[#LOOPE|DBNZE]]
|-
| [[#LOOPNE|LOOPNE]]
| [[#LOOPNE|DBNZNE]]
|-
| [[#MOV|MOV]]
| [[#MOV|MOV]]
|-
| [[#MOVSB|MOVSB]]
| [[#MOVSB|MOVBKB]]
|-
| [[#MOVSW|MOVSW]]
| [[#MOVSW|MOVBKW]]
|-
| [[#MUL|MUL]]
| [[#MUL|MULU]]
|-
| [[#NEG|NEG]]
| [[#NEG|NEG]]
|-
| [[#NOP|NOP]]
| [[#NOP|NOP]]
|-
| [[#NOT|NOT]]
| [[#NOT|NOT]]
|-
| [[#OR|OR]]
| [[#OR|OR]]
|-
| [[#OUT|OUT]]
| [[#OUT|OUT]]
|-
| [[#OUTSB|OUTSB]]
| [[#OUTSB|OUTM]]
|-
| [[#OUTSW|OUTSW]]
| [[#OUTSW|OUTM]]
|-
| [[#POLL|POLL]]
| [[#POLL|POLL]]
|-
| [[#POP|POP]]
| [[#POP|POP]]
|-
| [[#POPA|POPA]]
| [[#POPA|POP]]
|-
| [[#POPF|POPF]]
| [[#POPF|POP]]
|-
| [[#PUSH|PUSH]]
| [[#PUSH|PUSH]]
|-
| [[#PUSHA|PUSHA]]
| [[#PUSHA|PUSH]]
|-
| [[#PUSHF|PUSHF]]
| [[#PUSHF|PUSH]]
|-
| [[#RCL|RCL]]
| [[#RCL|ROLC]]
|-
| [[#RCR|RCR]]
| [[#RCR|RORC]]
|-
| [[#REP|REP/REPE/REPZ]]
| [[#REP|REP/REPE/REPZ]]
|-
| [[#REPNE|REPNE/REPNZ]]
| [[#REPNE|REPNE/REPNZ]]
|-
| [[#RET|RET]]
| [[#RET|RET]]
|-
| [[#RETF|RETF]]
| [[#RETF|RET]]
|-
| [[#ROL|ROL]]
| [[#ROL|ROL]]
|-
| [[#ROR|ROR]]
| [[#ROR|ROR]]
|-
| [[#SAHF|SAHF]]
| [[#SAHF|MOV]]
|-
| [[#SAR|SAR]]
| [[#SAR|SHRA]]
|-
| [[#SBB|SBB]]
| [[#SBB|SUBC]]
|-
| [[#SCASB|SCASB]]
| [[#SCASB|CMPMB]]
|-
| [[#SCASW|SCASW]]
| [[#SCASW|CMPMW]]
|-
| [[#SHL|SHL]]
| [[#SHL|SHL]]
|-
| [[#SHR|SHR]]
| [[#SHR|SHR]]
|-
| [[#SS|SS]]
| [[#SS|SS]]
|-
| [[#STC|STC]]
| [[#STC|SET1 CY]]
|-
| [[#STD|STD]]
| [[#STD|SET1 DIR]]
|-
| [[#STI|STI]]
| [[#STI|EI]]
|-
| [[#STOSB|STOSB]]
| [[#STOSB|STMB]]
|-
| [[#STOSW|STOSW]]
| [[#STOSW|STMW]]
|-
| [[#SUB|SUB]]
| [[#SUB|SUB]]
|-
| [[#TEST|TEST]]
| [[#TEST|TEST]]
|-
| [[#XCHG|XCHG]]
| [[#XCHG|XCH]]
|-
| [[#XLAT|XLAT]]
| [[#XLAT|TRANS]]
|-
| [[#XOR|XOR]]
| [[#XOR|XOR]]
|}
== Official instructions by type ==
{| class="wikitable sortable" style="text-align: center"
!Type
!colspan=16 class="unsortable" | Instructions
|-
| style="text-align:left;" | Memory
| style="" | [[#MOV|MOV]]
| style="" | [[#XCHG|XCHG]]
| style="" | [[#XLAT|XLAT]]
| style="" | [[#LEA|LEA]]
| style="border-right:none;" | [[#LDS|LDS]]
| style="border-left:none;" | [[#LES|LES]]
| style="border-right:none;" | [[#IN|IN]]
| style="border-left:none;" | [[#OUT|OUT]]
| colspan="8" |
|-
| style="text-align:left;" | Ports
| style="border-right:none;" | [[#IN|IN]]
| style="border-left:none;" | [[#OUT|OUT]]
| style="border-right:none;" | [[#INSB|INSB]]
| style="border-left:none;" | [[#OUTSB|OUTSB]]
| style="border-right:none;" | [[#INSW|INSW]]
| style="border-left:none;" | [[#OUTSW|OUTSW]]
| colspan="10" |
|-
| style="text-align:left;" | Arithmetic
| style="border-right:none;" | [[#ADD|ADD]]
| style="border-left:none;" | [[#SUB|SUB]]
| style="border-right:none;" | [[#ADC|ADC]]
| style="border-left:none;" | [[#SBB|SBB]]
| style="border-right:none;" | [[#INC|INC]]
| style="border-left:none;" | [[#DEC|DEC]]
| style="border-right:none;" | [[#MUL|MUL]]
| style="border-left:none;" | [[#DIV|DIV]]
| style="border-right:none;" | [[#IMUL|IMUL]]
| style="border-left:none;" | [[#IDIV|IDIV]]
| style="" | [[#CMP|CMP]]
| style="" | [[#NEG|NEG]]
| colspan="4" |
|-
| style="text-align:left;" | Numeric
| style="" | [[#CBW|CBW]]
| style="" | [[#CWD|CWD]]
| style="" | [[#AAA|AAA]]
| style="" | [[#AAS|AAS]]
| style="" | [[#AAM|AAM]]
| style="" | [[#AAD|AAD]]
| style="" | [[#DAA|DAA]]
| style="" | [[#DAS|DAS]]
| colspan="8" |
|-
| style="text-align:left;" | Shift
| style="border-right:none;" | [[#ROL|ROL]]
| style="border-left:none;" | [[#ROR|ROR]]
| style="border-right:none;" | [[#RCL|RCL]]
| style="border-left:none;" | [[#RCR|RCR]]
| style="border-right:none;" | [[#SHL|SHL]]
| style="border-left:none;" | [[#SHR|SHR]]
| style="" | [[#SAR|SAR]]
| colspan="9" |
|-
| style="text-align:left;" | Bitwise
| style="" | [[#AND|AND]]
| style="" | [[#OR|OR]]
| style="" | [[#XOR|XOR]]
| style="" | [[#NOT|NOT]]
| style="" | [[#TEST|TEST]]
| colspan="11" |
|-
| style="text-align:left;" | Branch
| style="border-right:none;" | [[#JC|JC]]
| style="border-left:none;" | [[#JNC|JNC]]
| style="border-right:none;" | [[#JZ|JZ]]
| style="border-left:none;" | [[#JNZ|JNZ]]
| style="border-right:none;" | [[#JBE|JBE]]
| style="border-left:none;" | [[#JA|JA]]
| style="border-right:none;" | [[#JO|JO]]
| style="border-left:none;" | [[#JNO|JNO]]
| style="border-right:none;" | [[#JP|JP]]
| style="border-left:none;" | [[#JNP|JNP]]
| style="border-right:none;" | [[#JS|JS]]
| style="border-left:none;" | [[#JNS|JNS]]
| style="border-right:none;" | [[#JL|JL]]
| style="border-left:none;" | [[#JGE|JGE]]
| style="border-right:none;" | [[#JLE|JLE]]
| style="border-left:none;" | [[#JG|JG]]
|-
| style="text-align:left;" | Jump
| style="" | [[#JMP|JMP]]
| style="border-right:none;" | [[#CALL|CALL]]
| style="border-left:none;border-right:none;" | [[#RET|RET]]
| style="border-left:none;" | [[#RETF|RETF]]
| colspan="12" |
|-
| style="text-align:left;" | Loop
| style="" | [[#LOOP|LOOP]]
| style="" | [[#LOOPE|LOOPE]]
| style="" | [[#LOOPNE|LOOPNE]]
| colspan="13" |
|-
| style="text-align:left;" | Interrupt
| style="border-right:none;" | [[#INT|INT]]
| style="border-left:none;" | [[#IRET|IRET]]
| style="" | [[#INTO|INTO]]
| style="" | [[#HLT|HLT]]
| style="" | [[#BOUND|BOUND]]
| colspan="11" |
|-
| style="text-align:left;" | Stack
| style="border-right:none;" | [[#PUSH|PUSH]]
| style="border-left:none;" | [[#POP|POP]]
| style="border-right:none;" | [[#PUSHA|PUSHA]]
| style="border-left:none;" | [[#POPA|POPA]]
| style="border-right:none;" | [[#PUSHF|PUSHF]]
| style="border-left:none;" | [[#POPF|POPF]]
| colspan="10" |
|-
| style="text-align:left;" | Flags
| style="border-right:none;" | [[#CLC|CLC]]
| style="border-left:none;" | [[#STC|STC]]
| style="border-right:none;" | [[#CLD|CLD]]
| style="border-left:none;" | [[#STD|STD]]
| style="border-right:none;" | [[#CLI|CLI]]
| style="border-left:none;" | [[#STI|STI]]
| style="" | [[#CMC|CMC]]
| style="border-right:none;" | [[#LAHF|LAHF]]
| style="border-left:none;" | [[#SAHF|SAHF]]
| colspan="7" |
|-
| style="text-align:left;" | Prefix
| style="" | [[#CS|CS]]
| style="" | [[#DS|DS]]
| style="" | [[#ES|ES]]
| style="" | [[#SS|SS]]
| colspan="12" |
|-
| style="text-align:left;" | String
| style="border-right:none;" | [[#REP|REP]]
| style="border-left:none;border-right:none;" | [[#REP|REPE]]
| style="border-left:none;" | [[#REPNE|REPNE]]
| style="" | [[#MOVSB|MOVSB]]
| style="" | [[#MOVSW|MOVSW]]
| style="border-right:none;" | [[#LODSB|LODSB]]
| style="border-left:none;" | [[#STOSB|STOSB]]
| style="border-right:none;" | [[#LODSW|LODSW]]
| style="border-left:none;" | [[#STOSW|STOSW]]
| style="" | [[#CMPSB|CMPSB]]
| style="" | [[#SCASB|SCASB]]
| style="" | [[#CMPSW|CMPSW]]
| style="" | [[#SCASW|SCASW]]
| colspan="3" |
|-
| style="text-align:left;" | Other
| style="" | [[#NOP|NOP]]
| style="border-right:none;" | [[#ENTER|ENTER]]
| style="border-left:none;" | [[#LEAVE|LEAVE]]
| style="" | [[#LOCK|LOCK]]
| style="" | [[#POLL|POLL]]
| colspan="11" |
|}
== Instruction encoding ==
=== ModR/M byte ===
The ModR/M byte is used in most addressing modes which reference a memory location. This byte consists of three bitfield values:
* <tt>oo</tt> - M'''o'''de;
* <tt>rrr</tt> - Two possible functions:
** '''R'''egister (for addressing modes which require both a register and a register/memory operand),
** Opcode extension (for some opcodes' addressing modes which do not have such a requirement);
* <tt>mmm</tt> - Register/'''M'''emory.
The ''Mode'' and ''Register/Memory'' bitfields can refer to a memory location or to a register, as shown in the table below. In some addressing modes, the ''Register'' field also refers to a register; it is always interpreted as if ''Mode'' was equal to <tt>11</tt>.
{| class="wikitable" style="text-align: center"
! R/M \ Mode
! <tt>00</tt>
! <tt>01</tt>
! <tt>10</tt>
! <tt>11</tt> ''(byte)''
! <tt>11</tt> ''(word)''
|-
| <tt>000</tt>
| DS:[BX + SI]
| DS:[BX + SI + disp8]
| DS:[BX + SI + disp16]
| AL
| AX
|-
| <tt>001</tt>
| DS:[BX + DI]
| DS:[BX + DI + disp8]
| DS:[BX + DI + disp16]
| CL
| CX
|-
| <tt>010</tt>
| SS:[BP + SI]
| SS:[BP + SI + disp8]
| SS:[BP + SI + disp16]
| DL
| DX
|-
| <tt>011</tt>
| SS:[BP + DI]
| SS:[BP + DI + disp8]
| SS:[BP + DI + disp16]
| BL
| BX
|-
| <tt>100</tt>
| DS:[SI]
| DS:[SI + disp8]
| DS:[SI + disp16]
| AH
| SP
|-
| <tt>101</tt>
| DS:[DI]
| DS:[DI + disp8]
| DS:[DI + disp16]
| CH
| BP
|-
| <tt>110</tt>
| ''DS:[disp16]''
| SS:[BP + disp8]
| SS:[BP + disp16]
| DH
| SI
|-
| <tt>111</tt>
| DS:[BX]
| DS:[BX + disp8]
| DS:[BX + disp16]
| BH
| DI
|}
Displacements are either 8-bit (disp8) or 16-bit (disp16) signed values and they always immediately follow the ModR/M byte. Note that (<tt>oo</tt> = <tt>00</tt>, <tt>mmm</tt> = <tt>110</tt>) is a special case, in which the ''disp16'' value is used directly as a near pointer.
The instruction encoding lists below refer to this byte as <tt>oorrrmmm</tt> (binary), <tt>/r</tt> (hexadecimal) or <tt>/0</tt> (hexademical, <tt>rrr</tt> used as function <tt>0</tt>).
== Official instructions ==
{{Anchor|AAA}}
=== AAA ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| AAA || <tt>37</tt> || <tt>00110111</tt> || 1 || 9
|}
----
{{Anchor|AAD}}
=== AAD ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| AAD imm8 || <tt>B5 ii</tt> || <tt>11010100 iiiiiiii</tt> || 2 || 6
|}
----
{{Anchor|AAM}}
=== AAM ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| AAM imm8 || <tt>B4 ii</tt> || <tt>11010100 iiiiiiii</tt> || 2 || 17
|}
----
{{Anchor|AAS}}
=== AAS ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| AAS || <tt>3F</tt> || <tt>00111111</tt> || 1 || 9
|}
----
{{Anchor|ADC}}
=== ADC ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| ADC AL, imm || <tt>14 ii</tt> || <tt>00010100 iiiiiiii</tt> || 2 || 1
|-
| ADC AX, imm || <tt>15 ii ii</tt> || <tt>00010101 iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| ADC mem8, imm8 || <tt>80 /2 ii</tt> || <tt>10000000 oo010mmm iiiiiiii</tt> || 3+ || 3
|-
| ADC mem16, imm16 || <tt>81 /2 ii ii</tt> || <tt>10000001 oo010mmm iiiiiiii iiiiiiii</tt> || 4+ || 3
|-
| ADC mem16, simm8 || <tt>83 /2 ii</tt> || <tt>10000011 oo010mmm iiiiiiii</tt> || 3+ || 3
|-
| ADC mem8, reg8 || <tt>10 /r</tt> || <tt>00010000 oorrrmmm</tt> || 2+ || 3
|-
| ADC mem16, reg16 || <tt>11 /r</tt> || <tt>00010001 oorrrmmm</tt> || 2+ || 3
|-
| ADC reg8, imm8 || <tt>80 /2 ii</tt> || <tt>10000000 11010mmm iiiiiiii</tt> || 3 || 1
|-
| ADC reg16, imm16 || <tt>81 /2 ii ii</tt> || <tt>10000001 11010mmm iiiiiiii iiiiiiii</tt> || 4 || 1
|-
| ADC reg16, simm8 || <tt>83 /2 ii</tt> || <tt>10000011 11010mmm iiiiiiii</tt> || 3 || 1
|-
| ADC reg8, mem8 || <tt>12 /r</tt> || <tt>00010010 oorrrmmm</tt> || 2+ || 2
|-
| ADC reg16, mem16 || <tt>13 /r</tt> || <tt>00010011 oorrrmmm</tt> || 2+ || 2
|-
| ADC reg8, reg8 || <tt>10 /r</tt> || <tt>000100.0 11rrrmmm</tt> || 2 || 1
|-
| ADC reg16, reg16 || <tt>11 /r</tt> || <tt>000100.1 11rrrmmm</tt> || 2 || 1
|}
----
{{Anchor|ADD}}
=== ADD ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| ADD AL, imm || <tt>04 ii</tt> || <tt>00000100 iiiiiiii</tt> || 2 || 1
|-
| ADD AX, imm || <tt>05 ii ii</tt> || <tt>00000101 iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| ADD mem8, imm8 || <tt>80 /0 ii</tt> || <tt>10000000 oo000mmm iiiiiiii</tt> || 3+ || 3
|-
| ADD mem16, imm16 || <tt>81 /0 ii ii</tt> || <tt>10000001 oo000mmm iiiiiiii iiiiiiii</tt> || 4+ || 3
|-
| ADD mem16, simm8 || <tt>83 /0 ii</tt> || <tt>10000011 oo000mmm iiiiiiii</tt> || 3+ || 3
|-
| ADD mem8, reg8 || <tt>00 /r</tt> || <tt>00000000 oorrrmmm</tt> || 2+ || 3
|-
| ADD mem16, reg16 || <tt>01 /r</tt> || <tt>00000001 oorrrmmm</tt> || 2+ || 3
|-
| ADD reg8, imm8 || <tt>80 /0 ii</tt> || <tt>10000000 11000mmm iiiiiiii</tt> || 3 || 1
|-
| ADD reg16, imm16 || <tt>81 /0 ii ii</tt> || <tt>10000001 11000mmm iiiiiiii iiiiiiii</tt> || 4 || 1
|-
| ADD reg16, simm8 || <tt>83 /0 ii</tt> || <tt>10000011 11000mmm iiiiiiii</tt> || 3 || 1
|-
| ADD reg8, mem8 || <tt>02 /r</tt> || <tt>00000010 oorrrmmm</tt> || 2+ || 2
|-
| ADD reg16, mem16 || <tt>03 /r</tt> || <tt>00000011 oorrrmmm</tt> || 2+ || 2
|-
| ADD reg8, reg8 || <tt>00 /r</tt> || <tt>000000.0 11rrrmmm</tt> || 2 || 1
|-
| ADD reg16, reg16 || <tt>01 /r</tt> || <tt>000000.1 11rrrmmm</tt> || 2 || 1
|}
----
{{Anchor|AND}}
=== AND ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| AND AL, imm || <tt>24 ii</tt> || <tt>00100100 iiiiiiii</tt> || 2 || 1
|-
| AND AX, imm || <tt>25 ii ii</tt> || <tt>00100101 iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| AND mem8, imm8 || <tt>80 /4 ii</tt> || <tt>10000000 oo100mmm iiiiiiii</tt> || 3+ || 3
|-
| AND mem16, imm16 || <tt>81 /4 ii ii</tt> || <tt>10000001 oo100mmm iiiiiiii iiiiiiii</tt> || 4+ || 3
|-
| AND mem16, simm8 || <tt>83 /4 ii</tt> || <tt>10000011 oo100mmm iiiiiiii</tt> || 3+ || 3
|-
| AND mem8, reg8 || <tt>20 /r</tt> || <tt>00100000 oorrrmmm</tt> || 2+ || 3
|-
| AND mem16, reg16 || <tt>21 /r</tt> || <tt>00100001 oorrrmmm</tt> || 2+ || 3
|-
| AND reg8, imm8 || <tt>80 /4 ii</tt> || <tt>10000000 11100mmm iiiiiiii</tt> || 3 || 1
|-
| AND reg16, imm16 || <tt>81 /4 ii ii</tt> || <tt>10000001 11100mmm iiiiiiii iiiiiiii</tt> || 4 || 1
|-
| AND reg16, simm8 || <tt>83 /4 ii</tt> || <tt>10000011 11100mmm iiiiiiii</tt> || 3 || 1
|-
| AND reg8, mem8 || <tt>22 /r</tt> || <tt>00100010 oorrrmmm</tt> || 2+ || 2
|-
| AND reg16, mem16 || <tt>23 /r</tt> || <tt>00100011 oorrrmmm</tt> || 2+ || 2
|-
| AND reg8, reg8 || <tt>20 /r</tt> || <tt>001000.0 11rrrmmm</tt> || 2 || 1
|-
| AND reg16, reg16 || <tt>21 /r</tt> || <tt>001000.1 11rrrmmm</tt> || 2 || 1
|}
----
{{Anchor|BOUND}}
=== BOUND ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| BOUND reg16, mem16:16 || <tt>62 /r</tt> || <tt>01100010 oorrrmmm</tt> || 2+ || 13 (20 if condition met)
|}
----
{{Anchor|CALL}}
=== CALL ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| CALL ptr16:16 || <tt>CA oo oo ss ss</tt> || <tt>10011010 oooooooo oooooooo ssssssss ssssssss</tt> || 5 || 10
|-
| CALL mem16 || <tt>FF /2</tt> || <tt>11111111 oo010mmm</tt> || 2+ || 6
|-
| CALL mem16:16 || <tt>FF /3</tt> || <tt>11111111 oo011mmm</tt> || 2+ || 12
|-
| CALL reg16 || <tt>FF /2</tt> || <tt>11111111 11010mmm</tt> || 2 || 5
|-
| CALL rel16 || <tt>E8 ii ii</tt> || <tt>11101000 iiiiiiii iiiiiiii</tt> || 3 || 5
|}
----
{{Anchor|CBW}}
=== CBW ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| CBW || <tt>98</tt> || <tt>10011000</tt> || 1 || 1
|}
----
{{Anchor|CLC}}
=== CLC ===
{| class="wikitable"
! Flag !! New value
|-
| [[NEC_V30MZ_flags#CF|CF - Carry]] || 0
|}
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| CLC || <tt>F8</tt> || <tt>11111000</tt> || 1 || 4
|}
----
{{Anchor|CLD}}
=== CLD ===
{| class="wikitable"
! Flag !! New value
|-
| [[NEC_V30MZ_flags#DF|DF - Direction]] || 0
|}
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| CLD || <tt>FC</tt> || <tt>11111100</tt> || 1 || 4
|}
----
{{Anchor|CLI}}
=== CLI ===
{| class="wikitable"
! Flag !! New value
|-
| [[NEC_V30MZ_flags#IF|IF - Interrupt]] || 0
|}
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| CLI || <tt>FA</tt> || <tt>11111010</tt> || 1 || 4
|}
----
{{Anchor|CMC}}
=== CMC ===
{| class="wikitable"
! Flag !! New value
|-
| [[NEC_V30MZ_flags#CF|CF - Carry]] || !CF
|}
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| CMC || <tt>F5</tt> || <tt>11110101</tt> || 1 || 4
|}
----
{{Anchor|CMP}}
=== CMP ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| CMP AL, imm || <tt>3C ii</tt> || <tt>00111100 iiiiiiii</tt> || 2 || 1
|-
| CMP AX, imm || <tt>3D ii ii</tt> || <tt>00111101 iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| CMP mem8, imm8 || <tt>80 /7 ii</tt> || <tt>10000000 oo111mmm iiiiiiii</tt> || 3+ || 2
|-
| CMP mem16, imm16 || <tt>81 /7 ii ii</tt> || <tt>10000001 oo111mmm iiiiiiii iiiiiiii</tt> || 4+ || 2
|-
| CMP mem16, simm8 || <tt>83 /7 ii</tt> || <tt>10000011 oo111mmm iiiiiiii</tt> || 3+ || 2
|-
| CMP mem8, reg8 || <tt>38 /r</tt> || <tt>00111000 oorrrmmm</tt> || 2+ || 2
|-
| CMP mem16, reg16 || <tt>39 /r</tt> || <tt>00111001 oorrrmmm</tt> || 2+ || 2
|-
| CMP reg8, imm8 || <tt>80 /7 ii</tt> || <tt>10000000 11111mmm iiiiiiii</tt> || 3 || 1
|-
| CMP reg16, imm16 || <tt>81 /7 ii ii</tt> || <tt>10000001 11111mmm iiiiiiii iiiiiiii</tt> || 4 || 1
|-
| CMP reg16, simm8 || <tt>83 /7 ii</tt> || <tt>10000011 11111mmm iiiiiiii</tt> || 3 || 1
|-
| CMP reg8, mem8 || <tt>3A /r</tt> || <tt>00111010 oorrrmmm</tt> || 2+ || 2
|-
| CMP reg16, mem16 || <tt>3B /r</tt> || <tt>00111011 oorrrmmm</tt> || 2+ || 2
|-
| CMP reg8, reg8 || <tt>38 /r</tt> || <tt>001110.0 11rrrmmm</tt> || 2 || 1
|-
| CMP reg16, reg16 || <tt>39 /r</tt> || <tt>001110.1 11rrrmmm</tt> || 2 || 1
|}
----
{{Anchor|CMPSB}}
{{Anchor|CMPSW}}
=== CMPSB/CMPSW ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| CMPSB || <tt>A6</tt> || <tt>10100110</tt> || 1 || 6
|-
| CMPSW || <tt>A7</tt> || <tt>10100111</tt> || 1 || 6
|}
----
{{Anchor|CS}}
=== CS ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| CS || <tt>2E</tt> || <tt>00101110</tt> || 1 || 1
|}
----
{{Anchor|CWD}}
=== CWD ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| CWD || <tt>99</tt> || <tt>10011001</tt> || 1 || 1
|}
----
{{Anchor|DAA}}
=== DAA ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| DAA || <tt>27</tt> || <tt>00100111</tt> || 1 || 10
|}
----
{{Anchor|DAS}}
=== DAS ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| DAS || <tt>2F</tt> || <tt>00101111</tt> || 1 || 10
|}
----
{{Anchor|DEC}}
=== DEC ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| DEC mem8 || <tt>FE /1</tt> || <tt>11111110 oo001mmm</tt> || 2+ || 3
|-
| DEC mem16 || <tt>FF /1</tt> || <tt>11111111 oo001mmm</tt> || 2+ || 3
|-
| DEC reg8 || <tt>FE /1</tt> || <tt>11111110 11001mmm</tt> || 2+ || 1
|-
| DEC reg16 || <tt>4x</tt> || <tt>01001rrr</tt> || 1 || 1
|}
----
{{Anchor|DIV}}
=== DIV ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| DIV mem8 || <tt>F6 /6</tt> || <tt>11110110 oo110mmm</tt> || 2+ || 16
|-
| DIV mem16 || <tt>F7 /6</tt> || <tt>11111111 oo110mmm</tt> || 2+ || 24
|-
| DIV reg8 || <tt>F6 /6</tt> || <tt>11111110 11110mmm</tt> || 2 || 15
|-
| DIV reg16 || <tt>F7 /6</tt> || <tt>11111111 11110mmm</tt> || 2 || 23
|}
----
{{Anchor|DS}}
=== DS ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| DS || <tt>3E</tt> || <tt>00111110</tt> || 1 || 1
|}
----
{{Anchor|ENTER}}
=== ENTER ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| ENTER imm16, imm8 || <tt>C8 ii ii jj</tt> || <tt>11001000 iiiiiiii iiiiiiii jjjjjjjj</tt> || 3 || 8 (imm8 = 0)<br/>14 (imm8 = 1)<br/>15 + imm8 * 4 (imm8 >= 2)
|}
----
{{Anchor|ES}}
=== ES ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| ES || <tt>26</tt> || <tt>00100110</tt> || 1 || 1
|}
----
{{Anchor|HLT}}
=== HLT ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| HLT || <tt>F4</tt> || <tt>11110100</tt> || 1 || 9
|}
----
{{Anchor|IDIV}}
=== IDIV ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| IDIV mem8 || <tt>F6 /7</tt> || <tt>11110110 oo111mmm</tt> || 2+ || 18
|-
| IDIV mem16 || <tt>F7 /7</tt> || <tt>11111111 oo111mmm</tt> || 2+ || 25
|-
| IDIV reg8 || <tt>F6 /7</tt> || <tt>11111110 11111mmm</tt> || 2 || 17
|-
| IDIV reg16 || <tt>F7 /7</tt> || <tt>11111111 11111mmm</tt> || 2 || 24
|}
----
{{Anchor|IMUL}}
=== IMUL ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| IMUL mem8 || <tt>F6 /5</tt> || <tt>11110110 oo101mmm</tt> || 2+ || 4
|-
| IMUL mem16 || <tt>F7 /5</tt> || <tt>11111111 oo101mmm</tt> || 2+ || 4
|-
| IMUL reg8 || <tt>F6 /5</tt> || <tt>11111110 11101mmm</tt> || 2 || 3
|-
| IMUL reg16 || <tt>F7 /5</tt> || <tt>11111111 11101mmm</tt> || 2 || 3
|-
| IMUL reg16, mem16, imm16 || <tt>69 /r ii ii</tt> || <tt>11111111 oorrrmmm iiiiiiii iiiiiiii</tt> || 4 || 4
|-
| IMUL reg16, mem16, simm8 || <tt>6B /r ii</tt> || <tt>11111111 oorrrmmm iiiiiiii</tt> || 3 || 4
|-
| IMUL reg16, reg16, imm16 || <tt>69 /r ii ii</tt> || <tt>11111111 11rrrmmm iiiiiiii iiiiiiii</tt> || 4 || 3
|-
| IMUL reg16, reg16, simm8 || <tt>6B /r ii</tt> || <tt>11111111 11rrrmmm iiiiiiii</tt> || 3 || 3
|}
----
{{Anchor|IN}}
=== IN ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| IN AL, DX || <tt>EC</tt> || <tt>11101100</tt> || 1 || 6
|-
| IN AX, DX || <tt>ED</tt> || <tt>11101101</tt> || 1 || 6
|-
| IN AL, imm8 || <tt>E4 ii</tt> || <tt>11100100 iiiiiiii</tt> || 2 || 6
|-
| IN AX, imm8 || <tt>E5 ii</tt> || <tt>11100101 iiiiiiii</tt> || 2 || 6
|}
----
{{Anchor|INC}}
=== INC ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| INC mem8 || <tt>FE /0</tt> || <tt>11111110 oo000mmm</tt> || 2+ || 3
|-
| INC mem16 || <tt>FF /0</tt> || <tt>11111111 oo000mmm</tt> || 2+ || 3
|-
| INC reg8 || <tt>FE /0</tt> || <tt>11111110 11000mmm</tt> || 2+ || 1
|-
| INC reg16 || <tt>4x</tt> || <tt>01000rrr</tt> || 1 || 1
|}
----
{{Anchor|INSB}}
{{Anchor|INSW}}
=== INSB/INSW ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| INSB || <tt>6C</tt> || <tt>01101100</tt> || 1 || 6
|-
| INSW || <tt>6D</tt> || <tt>01101101</tt> || 1 || 6
|}
----
{{Anchor|INT}}
=== INT ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| INT 3 || <tt>CC</tt> || <tt>11001100</tt> || 1 || 9
|-
| INT imm8 || <tt>CD ii</tt> || <tt>11001101 iiiiiiii</tt> || 2 || 10
|}
----
{{Anchor|INTO}}
=== INTO ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| INTO || <tt>CE</tt> || <tt>11001110</tt> || 1 || 6 (13 if OF = 1)
|}
----
{{Anchor|IRET}}
=== IRET ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| IRET || <tt>CF</tt> || <tt>11001111</tt> || 1 || 10
|}
----
{{Anchor|JA}}
=== JA ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JA rel8 || <tt>77 ii</tt> || <tt>01110111 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JBE}}
=== JBE ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JA rel8 || <tt>76 ii</tt> || <tt>01110110 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JC}}
=== JC/JB ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JC rel8 || <tt>72 ii</tt> || <tt>01110010 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JCXZ}}
=== JCXZ ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JCXZ rel8 || <tt>E3 ii</tt> || <tt>11100011 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JG}}
=== JG ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JG rel8 || <tt>7F ii</tt> || <tt>01111111 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JGE}}
=== JGE ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JGE rel8 || <tt>7D ii</tt> || <tt>01111101 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JL}}
=== JL ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JL rel8 || <tt>7C ii</tt> || <tt>01111100 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JLE}}
=== JLE ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JLE rel8 || <tt>7E ii</tt> || <tt>01111110 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JMP}}
=== JMP ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JMP ptr16:16 || <tt>EA oo oo ss ss</tt> || <tt>11101010 oooooooo oooooooo ssssssss ssssssss</tt> || 5 || 7
|-
| JMP mem16 || <tt>FF /4</tt> || <tt>11111111 oo100mmm</tt> || 2+ || 5
|-
| JMP mem16:16 || <tt>FF /5</tt> || <tt>11111111 oo101mmm</tt> || 2+ || 10
|-
| JMP reg16 || <tt>FF /4</tt> || <tt>11111111 11100mmm</tt> || 2 || 4
|-
| JMP rel8 || <tt>EB ii</tt> || <tt>11101011 iiiiiiii</tt> || 2 || 4
|-
| JMP rel16 || <tt>E9 ii ii</tt> || <tt>11101001 iiiiiiii iiiiiiii</tt> || 3 || 4
|}
----
{{Anchor|JNC}}
=== JNC/JAE ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JNC rel8 || <tt>73 ii</tt> || <tt>01110011 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JNO}}
=== JNO ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JNO rel8 || <tt>71 ii</tt> || <tt>01110001 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JNP}}
=== JNP ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JNP rel8 || <tt>7B ii</tt> || <tt>01111011 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JNS}}
=== JNS ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JNS rel8 || <tt>79 ii</tt> || <tt>01111001 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JNZ}}
=== JNZ/JNE ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JNZ rel8 || <tt>75 ii</tt> || <tt>01110101 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JO}}
=== JO ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JO rel8 || <tt>70 ii</tt> || <tt>01110000 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JP}}
=== JP ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JP rel8 || <tt>7A ii</tt> || <tt>01111010 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JS}}
=== JS ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JS rel8 || <tt>78 ii</tt> || <tt>01111000 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JZ}}
=== JZ/JE ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JZ rel8 || <tt>74 ii</tt> || <tt>01110100 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|LAHF}}
=== LAHF ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| LAHF || <tt>9F</tt> || <tt>10011111</tt> || 1 || 2
|}
----
{{Anchor|LDS}}
=== LDS ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| LDS reg16, mem16 || <tt>C5 /r</tt> || <tt>11000101 oorrrmmm</tt> || 2+ || 6
|}
----
{{Anchor|LEA}}
=== LEA ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| LEA reg16, mem16 || <tt>8D /r</tt> || <tt>10001101 oorrrmmm</tt> || 2+ || 1
|}
----
{{Anchor|LEAVE}}
=== LEAVE ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| LEAVE || <tt>C9</tt> || <tt>11001001</tt> || 1 || 2
|}
----
{{Anchor|LES}}
=== LES ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| LES reg16, mem16 || <tt>C4 /r</tt> || <tt>11000100 oorrrmmm</tt> || 2+ || 6
|}
----
{{Anchor|LOCK}}
=== LOCK ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| LOCK || <tt>F0</tt> || <tt>11110000</tt> || 1 || 1
|}
----
{{Anchor|LODSB}}
{{Anchor|LODSW}}
=== LODSB/LODSW ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| LODSB || <tt>AC</tt> || <tt>10101100</tt> || 1 || 3
|-
| LODSW || <tt>AD</tt> || <tt>10101101</tt> || 1 || 3
|}
----
{{Anchor|LOOP}}
=== LOOP ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| LOOP rel8 || <tt>E2 ii</tt> || <tt>11100010 iiiiiiii</tt> || 2 || 2 (5 if branch taken)
|}
----
{{Anchor|LOOPE}}
=== LOOPE ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| LOOPE rel8 || <tt>E1 ii</tt> || <tt>11100001 iiiiiiii</tt> || 2 || 3 (6 if branch taken)
|}
----
{{Anchor|LOOPNE}}
=== LOOPNE ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| LOOPNE rel8 || <tt>E0 ii</tt> || <tt>11100000 iiiiiiii</tt> || 2 || 3 (6 if branch taken)
|}
----
{{Anchor|MOV}}
=== MOV ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| MOV AL, ptr16 || <tt>A0 ii ii</tt> || <tt>10100000 iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| MOV AX, ptr16 || <tt>A1 ii ii</tt> || <tt>10100001 iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| MOV mem8, imm8 || <tt>C6 /0 ii</tt> || <tt>11000110 oo000mmm iiiiiiii</tt> || 3+ || 1
|-
| MOV mem16, imm16 || <tt>C7 /0 ii ii</tt> || <tt>11000111 oo000mmm iiiiiiii iiiiiiii</tt> || 4+ || 1
|-
| MOV mem8, reg8 || <tt>84 /r</tt> || <tt>10001000 oorrrmmm</tt> || 2+ || 1
|-
| MOV mem16, reg16 || <tt>85 /r</tt> || <tt>10001001 oorrrmmm</tt> || 2+ || 1
|-
| MOV mem16, sreg16 || <tt>8C /r</tt> || <tt>10001100 oo0rrmmm</tt> || 2+ || 3
|-
| MOV ptr16, AL || <tt>A2 ii ii</tt> || <tt>10100010 iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| MOV ptr16, AX || <tt>A3 ii ii</tt> || <tt>10100011 iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| MOV reg8, imm8 || <tt>Bx ii</tt> || <tt>10110rrr iiiiiiii</tt> || 2 || 1
|-
| MOV reg8, imm8 || <tt>C6 /0 ii</tt> || <tt>11000110 11000mmm iiiiiiii</tt> || 3 || 1
|-
| MOV reg16, imm16 || <tt>Bx ii</tt> || <tt>10111rrr iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| MOV reg16, imm16 || <tt>C7 /0 ii ii</tt> || <tt>11000111 11000mmm iiiiiiii iiiiiiii</tt> || 4 || 1
|-
| MOV reg8, mem8 || <tt>8A /r</tt> || <tt>10001010 oorrrmmm</tt> || 2+ || 1
|-
| MOV reg16, mem16 || <tt>8B /r</tt> || <tt>10001011 oorrrmmm</tt> || 2+ || 1
|-
| MOV reg8, reg8 || <tt>88 /r</tt> || <tt>100010.0 11rrrmmm</tt> || 2 || 1
|-
| MOV reg16, reg16 || <tt>89 /r</tt> || <tt>100010.1 11rrrmmm</tt> || 2 || 1
|-
| MOV reg16, sreg16 || <tt>8C /r</tt> || <tt>10001100 110rrmmm</tt> || 2 || 1
|-
| MOV sreg16, mem16 || <tt>8E /r</tt> || <tt>10001110 oo0rrmmm</tt> || 2 || 3
|-
| MOV sreg16, reg16 || <tt>8E /r</tt> || <tt>10001110 110rrmmm</tt> || 2+ || 2
|}
----
{{Anchor|MOVSB}}
{{Anchor|MOVSW}}
=== MOVSB/MOVSW ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| MOVSB || <tt>A4</tt> || <tt>10100100</tt> || 1 || 5
|-
| MOVSW || <tt>A5</tt> || <tt>10100101</tt> || 1 || 5
|}
----
{{Anchor|MUL}}
=== MUL ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| MUL mem8 || <tt>F6 /4</tt> || <tt>11110110 oo100mmm</tt> || 2+ || 4
|-
| MUL mem16 || <tt>F7 /4</tt> || <tt>11111111 oo100mmm</tt> || 2+ || 4
|-
| MUL reg8 || <tt>F6 /4</tt> || <tt>11111110 11100mmm</tt> || 2 || 3
|-
| MUL reg16 || <tt>F7 /4</tt> || <tt>11111111 11100mmm</tt> || 2 || 3
|}
----
{{Anchor|NEG}}
=== NEG ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| NEG mem8 || <tt>F6 /3</tt> || <tt>11110110 oo011mmm</tt> || 2+ || 3
|-
| NEG mem16 || <tt>F7 /3</tt> || <tt>11111111 oo011mmm</tt> || 2+ || 3
|-
| NEG reg8 || <tt>F6 /3</tt> || <tt>11111110 11011mmm</tt> || 2 || 1
|-
| NEG reg16 || <tt>F7 /3</tt> || <tt>11111111 11011mmm</tt> || 2 || 1
|}
----
{{Anchor|NOP}}
=== NOP ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| NOP || <tt>90</tt> || <tt>10010000</tt> || 1 || 1
|}
----
{{Anchor|NOT}}
=== NOT ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| NOT mem8 || <tt>F6 /2</tt> || <tt>11110110 oo010mmm</tt> || 2+ || 3
|-
| NOT mem16 || <tt>F7 /2</tt> || <tt>11111111 oo010mmm</tt> || 2+ || 3
|-
| NOT reg8 || <tt>F6 /2</tt> || <tt>11111110 11010mmm</tt> || 2 || 1
|-
| NOT reg16 || <tt>F7 /2</tt> || <tt>11111111 11010mmm</tt> || 2 || 1
|}
----
{{Anchor|OR}}
=== OR ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| OR AL, imm || <tt>0C ii</tt> || <tt>00001100 iiiiiiii</tt> || 2 || 1
|-
| OR AX, imm || <tt>0D ii ii</tt> || <tt>00001101 iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| OR mem8, imm8 || <tt>80 /6 ii</tt> || <tt>10000000 oo001mmm iiiiiiii</tt> || 3+ || 3
|-
| OR mem16, imm16 || <tt>81 /6 ii ii</tt> || <tt>10000001 oo001mmm iiiiiiii iiiiiiii</tt> || 4+ || 3
|-
| OR mem16, simm8 || <tt>83 /6 ii</tt> || <tt>10000011 oo001mmm iiiiiiii</tt> || 3+ || 3
|-
| OR mem8, reg8 || <tt>08 /r</tt> || <tt>00001000 oorrrmmm</tt> || 2+ || 3
|-
| OR mem16, reg16 || <tt>09 /r</tt> || <tt>00001001 oorrrmmm</tt> || 2+ || 3
|-
| OR reg8, imm8 || <tt>80 /6 ii</tt> || <tt>10000000 11001mmm iiiiiiii</tt> || 3 || 1
|-
| OR reg16, imm16 || <tt>81 /6 ii ii</tt> || <tt>10000001 11001mmm iiiiiiii iiiiiiii</tt> || 4 || 1
|-
| OR reg16, simm8 || <tt>83 /6 ii</tt> || <tt>10000011 11001mmm iiiiiiii</tt> || 3 || 1
|-
| OR reg8, mem8 || <tt>0A /r</tt> || <tt>00001010 oorrrmmm</tt> || 2+ || 2
|-
| OR reg16, mem16 || <tt>0B /r</tt> || <tt>00001011 oorrrmmm</tt> || 2+ || 2
|-
| OR reg8, reg8 || <tt>08 /r</tt> || <tt>000010.0 11rrrmmm</tt> || 2 || 1
|-
| OR reg16, reg16 || <tt>09 /r</tt> || <tt>000010.1 11rrrmmm</tt> || 2 || 1
|}
----
{{Anchor|OUT}}
=== OUT ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| OUT AL, DX || <tt>EE</tt> || <tt>11101110</tt> || 1 || 6
|-
| OUT AX, DX || <tt>EF</tt> || <tt>11101111</tt> || 1 || 6
|-
| OUT AL, imm8 || <tt>E6 ii</tt> || <tt>11100110 iiiiiiii</tt> || 2 || 6
|-
| OUT AX, imm8 || <tt>E7 ii</tt> || <tt>11100111 iiiiiiii</tt> || 2 || 6
|}
----
{{Anchor|OUTSB}}
{{Anchor|OUTSW}}
=== OUTSB/OUTSW ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| OUTSB || <tt>6E</tt> || <tt>01101110</tt> || 1 || 6
|-
| OUTSW || <tt>6F</tt> || <tt>01101111</tt> || 1 || 6
|}
----
{{Anchor|POLL}}
=== POLL ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| POLL || <tt>6E</tt> || <tt>01101110</tt> || 1 || 9<ref>On the WonderSwan implementation, POLLB is always held low; on other implementations, POLL will wait for POLLB to be held low in 9-cycle intervals.</ref>
|}
----
{{Anchor|POP}}
=== POP ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| POP mem16 || <tt>8F /0</tt> || <tt>10001111 oo000mmm</tt> || 2+ || 3
|-
| POP reg16 || <tt>5x</tt> || <tt>01011xxx</tt> || 1 || 1
|-
| POP reg16 || <tt>8F /0</tt> || <tt>10001111 11000mmm</tt> || 2 || 1
|-
| POP sreg16 || <tt>xx</tt> || <tt>000xx111</tt> || 1 || 3
|}
----
{{Anchor|POPA}}
=== POPA ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| POPA || <tt>61</tt> || <tt>01100001</tt> || 1 || 8
|}
----
{{Anchor|POPF}}
=== POPF ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| POPF || <tt>9D</tt> || <tt>10011101</tt> || 1 || 3
|}
----
{{Anchor|PUSH}}
=== PUSH ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| PUSH imm8 || <tt>6A ii</tt> || <tt>01101010 iiiiiiii</tt> || 2 || 1
|-
| PUSH imm16 || <tt>68 ii ii</tt> || <tt>01101000 iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| PUSH mem16 || <tt>FF /6</tt> || <tt>11111111 oo110mmm</tt> || 2+ || 2
|-
| PUSH reg16 || <tt>5x</tt> || <tt>01010xxx</tt> || 1 || 1
|-
| PUSH reg16 || <tt>FF /6</tt> || <tt>11111111 11110mmm</tt> || 2 || 1
|-
| PUSH sreg16 || <tt>xx</tt> || <tt>000xx110</tt> || 1 || 2
|}
----
{{Anchor|PUSHA}}
=== PUSHA ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| PUSHA || <tt>60</tt> || <tt>01100000</tt> || 1 || 9
|}
----
{{Anchor|PUSHF}}
=== PUSHF ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| PUSHF || <tt>9C</tt> || <tt>10011100</tt> || 1 || 2
|}
----
{{Anchor|RCL}}
=== RCL ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| RCL mem8, 1 || <tt>D0 /2</tt> || <tt>11010000 oo010rm</tt> || 2+ || 3
|-
| RCL mem8, CL || <tt>D2 /2</tt> || <tt>11010010 oo010rm</tt> || 2+ || 5
|-
| RCL mem8, imm8 || <tt>C0 /2 ii</tt> || <tt>11000000 oo010mmm iiiiiiii</tt> || 3+ || 5
|-
| RCL mem16, 1 || <tt>D1 /2</tt> || <tt>11010001 oo010rm</tt> || 2+ || 3
|-
| RCL mem16, CL || <tt>D3 /2</tt> || <tt>11010011 oo010rm</tt> || 2+ || 5
|-
| RCL mem16, imm8 || <tt>C1 /2 ii</tt> || <tt>11000001 oo010mmm iiiiiiii</tt> || 3+ || 5
|-
| RCL reg8, 1 || <tt>D0 /2</tt> || <tt>11010000 11010rm</tt> || 2 || 1
|-
| RCL reg8, CL || <tt>D2 /2</tt> || <tt>11010010 11010rm</tt> || 2 || 3
|-
| RCL reg8, imm8 || <tt>C0 /2 ii</tt> || <tt>11000000 11010mmm iiiiiiii</tt> || 3 || 3
|-
| RCL reg16, 1 || <tt>D1 /2</tt> || <tt>11010001 11010rm</tt> || 2 || 1
|-
| RCL reg16, CL || <tt>D3 /2</tt> || <tt>11010011 11010rm</tt> || 2 || 3
|-
| RCL reg16, imm8 || <tt>C1 /2 ii</tt> || <tt>11000001 11010mmm iiiiiiii</tt> || 3 || 3
|}
----
{{Anchor|RCR}}
=== RCR ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| RCR mem8, 1 || <tt>D0 /3</tt> || <tt>11010000 oo011rm</tt> || 2+ || 3
|-
| RCR mem8, CL || <tt>D2 /3</tt> || <tt>11010010 oo011rm</tt> || 2+ || 5
|-
| RCR mem8, imm8 || <tt>C0 /3 ii</tt> || <tt>11000000 oo011mmm iiiiiiii</tt> || 3+ || 5
|-
| RCR mem16, 1 || <tt>D1 /3</tt> || <tt>11010001 oo011rm</tt> || 2+ || 3
|-
| RCR mem16, CL || <tt>D3 /3</tt> || <tt>11010011 oo011rm</tt> || 2+ || 5
|-
| RCR mem16, imm8 || <tt>C1 /3 ii</tt> || <tt>11000001 oo011mmm iiiiiiii</tt> || 3+ || 5
|-
| RCR reg8, 1 || <tt>D0 /3</tt> || <tt>11010000 11011rm</tt> || 2 || 1
|-
| RCR reg8, CL || <tt>D2 /3</tt> || <tt>11010010 11011rm</tt> || 2 || 3
|-
| RCR reg8, imm8 || <tt>C0 /3 ii</tt> || <tt>11000000 11011mmm iiiiiiii</tt> || 3 || 3
|-
| RCR reg16, 1 || <tt>D1 /3</tt> || <tt>11010001 11011rm</tt> || 2 || 1
|-
| RCR reg16, CL || <tt>D3 /3</tt> || <tt>11010011 11011rm</tt> || 2 || 3
|-
| RCR reg16, imm8 || <tt>C1 /3 ii</tt> || <tt>11000001 11011mmm iiiiiiii</tt> || 3 || 3
|}
----
{{Anchor|REP}}
=== REP/REPE/REPZ ===
----
{{Anchor|REPNE}}
=== REPNE/REPNZ ===
----
{{Anchor|RET}}
=== RET ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| RET || <tt>C3</tt> || <tt>11000011</tt> || 1 || 6
|-
| RET imm16 || <tt>C2 ii ii</tt> || <tt>11000010 iiiiiiii iiiiiiii</tt> || 1 || 6
|}
----
{{Anchor|RETF}}
=== RETF ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| RETF || <tt>CB</tt> || <tt>11001011</tt> || 1 || 8
|-
| RETF imm16 || <tt>CA ii ii</tt> || <tt>11001010 iiiiiiii iiiiiiii</tt> || 1 || 9
|}
----
{{Anchor|ROL}}
=== ROL ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| ROL mem8, 1 || <tt>D0 /0</tt> || <tt>11010000 oo000rm</tt> || 2+ || 3
|-
| ROL mem8, CL || <tt>D2 /0</tt> || <tt>11010010 oo000rm</tt> || 2+ || 5
|-
| ROL mem8, imm8 || <tt>C0 /0 ii</tt> || <tt>11000000 oo000mmm iiiiiiii</tt> || 3+ || 5
|-
| ROL mem16, 1 || <tt>D1 /0</tt> || <tt>11010001 oo000rm</tt> || 2+ || 3
|-
| ROL mem16, CL || <tt>D3 /0</tt> || <tt>11010011 oo000rm</tt> || 2+ || 5
|-
| ROL mem16, imm8 || <tt>C1 /0 ii</tt> || <tt>11000001 oo000mmm iiiiiiii</tt> || 3+ || 5
|-
| ROL reg8, 1 || <tt>D0 /0</tt> || <tt>11010000 11000rm</tt> || 2 || 1
|-
| ROL reg8, CL || <tt>D2 /0</tt> || <tt>11010010 11000rm</tt> || 2 || 3
|-
| ROL reg8, imm8 || <tt>C0 /0 ii</tt> || <tt>11000000 11000mmm iiiiiiii</tt> || 3 || 3
|-
| ROL reg16, 1 || <tt>D1 /0</tt> || <tt>11010001 11000rm</tt> || 2 || 1
|-
| ROL reg16, CL || <tt>D3 /0</tt> || <tt>11010011 11000rm</tt> || 2 || 3
|-
| ROL reg16, imm8 || <tt>C1 /0 ii</tt> || <tt>11000001 11000mmm iiiiiiii</tt> || 3 || 3
|}
----
{{Anchor|ROR}}
=== ROR ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| ROR mem8, 1 || <tt>D0 /1</tt> || <tt>11010000 oo001rm</tt> || 2+ || 3
|-
| ROR mem8, CL || <tt>D2 /1</tt> || <tt>11010010 oo001rm</tt> || 2+ || 5
|-
| ROR mem8, imm8 || <tt>C0 /1 ii</tt> || <tt>11000000 oo001mmm iiiiiiii</tt> || 3+ || 5
|-
| ROR mem16, 1 || <tt>D1 /1</tt> || <tt>11010001 oo001rm</tt> || 2+ || 3
|-
| ROR mem16, CL || <tt>D3 /1</tt> || <tt>11010011 oo001rm</tt> || 2+ || 5
|-
| ROR mem16, imm8 || <tt>C1 /1 ii</tt> || <tt>11000001 oo001mmm iiiiiiii</tt> || 3+ || 5
|-
| ROR reg8, 1 || <tt>D0 /1</tt> || <tt>11010000 11001rm</tt> || 2 || 1
|-
| ROR reg8, CL || <tt>D2 /1</tt> || <tt>11010010 11001rm</tt> || 2 || 3
|-
| ROR reg8, imm8 || <tt>C0 /1 ii</tt> || <tt>11000000 11001mmm iiiiiiii</tt> || 3 || 3
|-
| ROR reg16, 1 || <tt>D1 /1</tt> || <tt>11010001 11001rm</tt> || 2 || 1
|-
| ROR reg16, CL || <tt>D3 /1</tt> || <tt>11010011 11001rm</tt> || 2 || 3
|-
| ROR reg16, imm8 || <tt>C1 /1 ii</tt> || <tt>11000001 11001mmm iiiiiiii</tt> || 3 || 3
|}
----
{{Anchor|SAHF}}
=== SAHF ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| SAHF || <tt>9E</tt> || <tt>10011110</tt> || 1 || 4
|}
----
{{Anchor|SAR}}
=== SAR ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| SAR mem8, 1 || <tt>D0 /7</tt> || <tt>11010000 oo111rm</tt> || 2+ || 3
|-
| SAR mem8, CL || <tt>D2 /7</tt> || <tt>11010010 oo111rm</tt> || 2+ || 5
|-
| SAR mem8, imm8 || <tt>C0 /7 ii</tt> || <tt>11000000 oo111mmm iiiiiiii</tt> || 3+ || 5
|-
| SAR mem16, 1 || <tt>D1 /7</tt> || <tt>11010001 oo111rm</tt> || 2+ || 3
|-
| SAR mem16, CL || <tt>D3 /7</tt> || <tt>11010011 oo111rm</tt> || 2+ || 5
|-
| SAR mem16, imm8 || <tt>C1 /7 ii</tt> || <tt>11000001 oo111mmm iiiiiiii</tt> || 3+ || 5
|-
| SAR reg8, 1 || <tt>D0 /7</tt> || <tt>11010000 11111rm</tt> || 2 || 1
|-
| SAR reg8, CL || <tt>D2 /7</tt> || <tt>11010010 11111rm</tt> || 2 || 3
|-
| SAR reg8, imm8 || <tt>C0 /7 ii</tt> || <tt>11000000 11111mmm iiiiiiii</tt> || 3 || 3
|-
| SAR reg16, 1 || <tt>D1 /7</tt> || <tt>11010001 11111rm</tt> || 2 || 1
|-
| SAR reg16, CL || <tt>D3 /7</tt> || <tt>11010011 11111rm</tt> || 2 || 3
|-
| SAR reg16, imm8 || <tt>C1 /7 ii</tt> || <tt>11000001 11111mmm iiiiiiii</tt> || 3 || 3
|}
----
{{Anchor|SBB}}
=== SBB ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| SBB AL, imm || <tt>1C ii</tt> || <tt>00011100 iiiiiiii</tt> || 2 || 1
|-
| SBB AX, imm || <tt>1D ii ii</tt> || <tt>00011101 iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| SBB mem8, imm8 || <tt>80 /3 ii</tt> || <tt>10000000 oo011mmm iiiiiiii</tt> || 3+ || 3
|-
| SBB mem16, imm16 || <tt>81 /3 ii ii</tt> || <tt>10000001 oo011mmm iiiiiiii iiiiiiii</tt> || 4+ || 3
|-
| SBB mem16, simm8 || <tt>83 /3 ii</tt> || <tt>10000011 oo011mmm iiiiiiii</tt> || 3+ || 3
|-
| SBB mem8, reg8 || <tt>18 /r</tt> || <tt>00011000 oorrrmmm</tt> || 2+ || 3
|-
| SBB mem16, reg16 || <tt>19 /r</tt> || <tt>00011001 oorrrmmm</tt> || 2+ || 3
|-
| SBB reg8, imm8 || <tt>80 /3 ii</tt> || <tt>10000000 11011mmm iiiiiiii</tt> || 3 || 1
|-
| SBB reg16, imm16 || <tt>81 /3 ii ii</tt> || <tt>10000001 11011mmm iiiiiiii iiiiiiii</tt> || 4 || 1
|-
| SBB reg16, simm8 || <tt>83 /3 ii</tt> || <tt>10000011 11011mmm iiiiiiii</tt> || 3 || 1
|-
| SBB reg8, mem8 || <tt>1A /r</tt> || <tt>00011010 oorrrmmm</tt> || 2+ || 2
|-
| SBB reg16, mem16 || <tt>1B /r</tt> || <tt>00011011 oorrrmmm</tt> || 2+ || 2
|-
| SBB reg8, reg8 || <tt>18 /r</tt> || <tt>000110.0 11rrrmmm</tt> || 2 || 1
|-
| SBB reg16, reg16 || <tt>19 /r</tt> || <tt>000110.1 11rrrmmm</tt> || 2 || 1
|}
----
{{Anchor|SCASB}}
{{Anchor|SCASW}}
=== SCASB/SCASW ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| SCASB || <tt>AE</tt> || <tt>10101110</tt> || 1 || 4
|-
| SCASW || <tt>AF</tt> || <tt>10101111</tt> || 1 || 4
|}
----
{{Anchor|SHL}}
=== SHL ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| SHL mem8, 1 || <tt>D0 /4</tt> || <tt>11010000 oo100rm</tt> || 2+ || 3
|-
| SHL mem8, CL || <tt>D2 /4</tt> || <tt>11010010 oo100rm</tt> || 2+ || 5
|-
| SHL mem8, imm8 || <tt>C0 /4 ii</tt> || <tt>11000000 oo100mmm iiiiiiii</tt> || 3+ || 5
|-
| SHL mem16, 1 || <tt>D1 /4</tt> || <tt>11010001 oo100rm</tt> || 2+ || 3
|-
| SHL mem16, CL || <tt>D3 /4</tt> || <tt>11010011 oo100rm</tt> || 2+ || 5
|-
| SHL mem16, imm8 || <tt>C1 /4 ii</tt> || <tt>11000001 oo100mmm iiiiiiii</tt> || 3+ || 5
|-
| SHL reg8, 1 || <tt>D0 /4</tt> || <tt>11010000 11100rm</tt> || 2 || 1
|-
| SHL reg8, CL || <tt>D2 /4</tt> || <tt>11010010 11100rm</tt> || 2 || 3
|-
| SHL reg8, imm8 || <tt>C0 /4 ii</tt> || <tt>11000000 11100mmm iiiiiiii</tt> || 3 || 3
|-
| SHL reg16, 1 || <tt>D1 /4</tt> || <tt>11010001 11100rm</tt> || 2 || 1
|-
| SHL reg16, CL || <tt>D3 /4</tt> || <tt>11010011 11100rm</tt> || 2 || 3
|-
| SHL reg16, imm8 || <tt>C1 /4 ii</tt> || <tt>11000001 11100mmm iiiiiiii</tt> || 3 || 3
|}
----
{{Anchor|SHR}}
=== SHR ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| SHR mem8, 1 || <tt>D0 /5</tt> || <tt>11010000 oo101rm</tt> || 2+ || 3
|-
| SHR mem8, CL || <tt>D2 /5</tt> || <tt>11010010 oo101rm</tt> || 2+ || 5
|-
| SHR mem8, imm8 || <tt>C0 /5 ii</tt> || <tt>11000000 oo101mmm iiiiiiii</tt> || 3+ || 5
|-
| SHR mem16, 1 || <tt>D1 /5</tt> || <tt>11010001 oo101rm</tt> || 2+ || 3
|-
| SHR mem16, CL || <tt>D3 /5</tt> || <tt>11010011 oo101rm</tt> || 2+ || 5
|-
| SHR mem16, imm8 || <tt>C1 /5 ii</tt> || <tt>11000001 oo101mmm iiiiiiii</tt> || 3+ || 5
|-
| SHR reg8, 1 || <tt>D0 /5</tt> || <tt>11010000 11101rm</tt> || 2 || 1
|-
| SHR reg8, CL || <tt>D2 /5</tt> || <tt>11010010 11101rm</tt> || 2 || 3
|-
| SHR reg8, imm8 || <tt>C0 /5 ii</tt> || <tt>11000000 11101mmm iiiiiiii</tt> || 3 || 3
|-
| SHR reg16, 1 || <tt>D1 /5</tt> || <tt>11010001 11101rm</tt> || 2 || 1
|-
| SHR reg16, CL || <tt>D3 /5</tt> || <tt>11010011 11101rm</tt> || 2 || 3
|-
| SHR reg16, imm8 || <tt>C1 /5 ii</tt> || <tt>11000001 11101mmm iiiiiiii</tt> || 3 || 3
|}
----
{{Anchor|SS}}
=== SS ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| SS || <tt>36</tt> || <tt>00110110</tt> || 1 || 1
|}
----
{{Anchor|STC}}
=== STC ===
{| class="wikitable"
! Flag !! New value
|-
| [[NEC_V30MZ_flags#CF|CF - Carry]] || 1
|}
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| STC || <tt>F9</tt> || <tt>11111001</tt> || 1 || 4
|}
----
{{Anchor|STD}}
=== STD ===
{| class="wikitable"
! Flag !! New value
|-
| [[NEC_V30MZ_flags#DF|DF - Direction]] || 1
|}
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| STD || <tt>FD</tt> || <tt>11111101</tt> || 1 || 4
|}
----
{{Anchor|STI}}
=== STI ===
{| class="wikitable"
! Flag !! New value
|-
| [[NEC_V30MZ_flags#IF|IF - Interrupt]] || 1
|}
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| STI || <tt>FB</tt> || <tt>11111011</tt> || 1 || 4
|}
----
{{Anchor|STOSB}}
{{Anchor|STOSW}}
=== STOSB/STOSW ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| STOSB || <tt>AA</tt> || <tt>10101010</tt> || 1 || 3
|-
| STOSW || <tt>AB</tt> || <tt>10101011</tt> || 1 || 3
|}
----
{{Anchor|SUB}}
=== SUB ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| SUB AL, imm || <tt>28 ii</tt> || <tt>00101100 iiiiiiii</tt> || 2 || 1
|-
| SUB AX, imm || <tt>29 ii ii</tt> || <tt>00101101 iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| SUB mem8, imm8 || <tt>80 /5 ii</tt> || <tt>10000000 oo101mmm iiiiiiii</tt> || 3+ || 3
|-
| SUB mem16, imm16 || <tt>81 /5 ii ii</tt> || <tt>10000001 oo101mmm iiiiiiii iiiiiiii</tt> || 4+ || 3
|-
| SUB mem16, simm8 || <tt>83 /5 ii</tt> || <tt>10000011 oo101mmm iiiiiiii</tt> || 3+ || 3
|-
| SUB mem8, reg8 || <tt>28 /r</tt> || <tt>00101000 oorrrmmm</tt> || 2+ || 3
|-
| SUB mem16, reg16 || <tt>29 /r</tt> || <tt>00101001 oorrrmmm</tt> || 2+ || 3
|-
| SUB reg8, imm8 || <tt>80 /5 ii</tt> || <tt>10000000 11101mmm iiiiiiii</tt> || 3 || 1
|-
| SUB reg16, imm16 || <tt>81 /5 ii ii</tt> || <tt>10000001 11101mmm iiiiiiii iiiiiiii</tt> || 4 || 1
|-
| SUB reg16, simm8 || <tt>83 /5 ii</tt> || <tt>10000011 11101mmm iiiiiiii</tt> || 3 || 1
|-
| SUB reg8, mem8 || <tt>2A /r</tt> || <tt>00101010 oorrrmmm</tt> || 2+ || 2
|-
| SUB reg16, mem16 || <tt>2B /r</tt> || <tt>00101011 oorrrmmm</tt> || 2+ || 2
|-
| SUB reg8, reg8 || <tt>28 /r</tt> || <tt>001010.0 11rrrmmm</tt> || 2 || 1
|-
| SUB reg16, reg16 || <tt>29 /r</tt> || <tt>001010.1 11rrrmmm</tt> || 2 || 1
|}
----
{{Anchor|TEST}}
=== TEST ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| TEST AL, imm || <tt>A8 ii</tt> || <tt>10101000 iiiiiiii</tt> || 2 || 1
|-
| TEST AX, imm || <tt>A9 ii ii</tt> || <tt>10101001 iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| TEST mem8, imm8 || <tt>F6 /0 ii</tt> || <tt>11110110 oo000mmm iiiiiiii</tt> || 3+ || 2
|-
| TEST mem16, imm16 || <tt>F7 /0 ii ii</tt> || <tt>11110111 oo000mmm iiiiiiii iiiiiiii</tt> || 4+ || 2
|-
| TEST mem8, reg8<br/>TEST reg8, mem8 || <tt>84 /r</tt> || <tt>10000100 oorrrmmm</tt> || 2+ || 2
|-
| TEST mem16, reg16<br/>TEST reg16, mem16 || <tt>85 /r</tt> || <tt>10000101 oorrrmmm</tt> || 2+ || 2
|-
| TEST reg8, imm8 || <tt>F6 /0 ii</tt> || <tt>11110110 11000mmm iiiiiiii</tt> || 3 || 1
|-
| TEST reg16, imm16 || <tt>F7 /0 ii ii</tt> || <tt>11110111 11000mmm iiiiiiii iiiiiiii</tt> || 4 || 1
|-
| TEST reg8, reg8 || <tt>84 /r</tt> || <tt>10000100 11rrrmmm</tt> || 2 || 1
|-
| TEST reg16, reg16 || <tt>85 /r</tt> || <tt>10000101 11rrrmmm</tt> || 2 || 1
|}
----
{{Anchor|XCHG}}
=== XCHG ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| XCHG AX, reg16<br/>XCHG reg16, AX || <tt>9x</tt> || <tt>10010rrr</tt> || 1 || 3
|-
| XCHG mem8, reg8<br/>XCHG reg8, mem8 || <tt>86 /r</tt> || <tt>10000110 oorrrmmm</tt> || 2+ || 5
|-
| XCHG mem16, reg16<br/>XCHG reg16, mem16 || <tt>87 /r</tt> || <tt>10000111 oorrrmmm</tt> || 2+ || 5
|-
| XCHG reg8, reg8 || <tt>86 /r</tt> || <tt>10000110 11rrrmmm</tt> || 2+ || 3
|-
| XCHG reg16, reg16 || <tt>87 /r</tt> || <tt>10000111 11rrrmmm</tt> || 2+ || 3
|}
----
{{Anchor|XLAT}}
=== XLAT ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| XLAT || <tt>D7</tt> || <tt>11010111</tt> || 1 || 5
|}
----
{{Anchor|XOR}}
=== XOR ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| XOR AL, imm || <tt>34 ii</tt> || <tt>00110100 iiiiiiii</tt> || 2 || 1
|-
| XOR AX, imm || <tt>35 ii ii</tt> || <tt>00110101 iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| XOR mem8, imm8 || <tt>80 /6 ii</tt> || <tt>10000000 oo110mmm iiiiiiii</tt> || 3+ || 3
|-
| XOR mem16, imm16 || <tt>81 /6 ii ii</tt> || <tt>10000001 oo110mmm iiiiiiii iiiiiiii</tt> || 4+ || 3
|-
| XOR mem16, simm8 || <tt>83 /6 ii</tt> || <tt>10000011 oo110mmm iiiiiiii</tt> || 3+ || 3
|-
| XOR mem8, reg8 || <tt>30 /r</tt> || <tt>00110000 oorrrmmm</tt> || 2+ || 3
|-
| XOR mem16, reg16 || <tt>31 /r</tt> || <tt>00110001 oorrrmmm</tt> || 2+ || 3
|-
| XOR reg8, imm8 || <tt>80 /6 ii</tt> || <tt>10000000 11110mmm iiiiiiii</tt> || 3 || 1
|-
| XOR reg16, imm16 || <tt>81 /6 ii ii</tt> || <tt>10000001 11110mmm iiiiiiii iiiiiiii</tt> || 4 || 1
|-
| XOR reg16, simm8 || <tt>83 /6 ii</tt> || <tt>10000011 11110mmm iiiiiiii</tt> || 3 || 1
|-
| XOR reg8, mem8 || <tt>32 /r</tt> || <tt>00110010 oorrrmmm</tt> || 2+ || 2
|-
| XOR reg16, mem16 || <tt>33 /r</tt> || <tt>00110011 oorrrmmm</tt> || 2+ || 2
|-
| XOR reg8, reg8 || <tt>30 /r</tt> || <tt>001100.0 11rrrmmm</tt> || 2 || 1
|-
| XOR reg16, reg16 || <tt>31 /r</tt> || <tt>001100.1 11rrrmmm</tt> || 2 || 1
|}
== Notes ==
<references />
06b6ef3f57b2d7965d19b924589b279cc88741f6
Accessory port pinout
0
43
465
188
2024-12-28T07:07:06Z
Asie
351
/* HDMI connector mapping */
wikitext
text/x-wiki
The WonderSwan accessory (EXT) port provides an [[UART]] serial port and I<sup>2</sup>S digital audio output.
== Pinout ==
(Female 8-pin port on peripheral)
<pre>
MISO_ _MOSI
\ /
+3V_ \ / _GND
______\ __\ __ /__ /______
| 04__03__02__01 |
| __|"" "" "" ""|__ |
| |__ __| |
'. |..__..__..__..| .'
\____05__06__07__08____/
_/ / \ \_
BCLK / \ /HDPN
_/ \_
LRCK SDAT
</pre>
{| class="wikitable"
|-
! Pin !! Group !! Description
|-
| 01 (GND)
| Power
| Ground
|-
| 02 (MOSI)
| rowspan="2" | [[UART]]
| WonderSwan -> Accessory
|-
| 03 (MISO)
| Accessory -> WonderSwan
|-
| 04 (+3V)
| Power
| 3.3 volt?
|-
| 05 (BCLK)
| rowspan="4" | I<sup>2</sup>S
| Bit clock
|-
| 06 (LRCK)
| Channel clock
|-
| 07 (SDAT)
| Bit data
|-
| 08 (/HDPN)
| Headphone detect
|}
== HDMI connector mapping ==
Luckily, it turns out that male HDMI connectors are somewhat electrically compatible with male EXT port connectors. This allows repurposing them as a replacement for a female EXT port connector.
* Note that using an HDMI plug may cause increased wear on the connector.
* In addition, an HDMI plug lacks the plastic sleeve which the original EXT port connector has, which leads to a loose connection.
** One solution is to 3D-print a sleeve to improve connection.
** Another solution is to include some type of LED/indicator in order to validate proper connection.
Due to the lack of availability of new EXT port connectors, this is a popular solution among DIY users and lower-end aftermarket accessories.
HDMI pins connect to EXT port pins as follows:
{| class="wikitable"
|-
! EXT !! HDMI
|-
| 01 (GND)
| 15 (SCL)
|-
| 02 (MOSI)
| 11 (TMDS Clock Shield)
|-
| 03 (MISO)
| 7 (TMDS Data 0 +)
|-
| 04 (+3V)
| 3 (TMDS Data 2 -)
|-
| 05 (BCLK)
| 4 (TMDS Data 1 +)
|-
| 06 (LRCK)
| 8 (TMDS Data 0 Shield)
|-
| 07 (SDAT)
| 12 (TMDS Clock -)
|-
| 08 (/HDPN)
| 16 (SDA)
|}
00bc2daa0684910a2004fe9635f745bebc27bd24
470
465
2024-12-28T15:07:54Z
Asie
351
wikitext
text/x-wiki
The WonderSwan accessory (EXT) port provides:
* 3.3V power delivery to the peripheral,
* an [[UART]] serial port,
* an I<sup>2</sup>S digital audio output.
Note that the UART uses inverted polarity.
== Pinout ==
(Female 8-pin port on peripheral)
<pre>
MISO_ _MOSI
\ /
+3V_ \ / _GND
______\ __\ __ /__ /______
| 04__03__02__01 |
| __|"" "" "" ""|__ |
| |__ __| |
'. |..__..__..__..| .'
\____05__06__07__08____/
_/ / \ \_
BCLK / \ /HDPN
_/ \_
LRCK SDAT
</pre>
{| class="wikitable"
|-
! Pin !! Group !! Description
|-
| 01 (GND)
| Power
| Ground
|-
| 02 (MOSI)
| rowspan="2" | [[UART]]
| WonderSwan -> Accessory
|-
| 03 (MISO)
| Accessory -> WonderSwan
|-
| 04 (+3V)
| Power
| 3.3 volt?
|-
| 05 (BCLK)
| rowspan="4" | I<sup>2</sup>S
| Bit clock
|-
| 06 (LRCK)
| Channel clock
|-
| 07 (SDAT)
| Bit data
|-
| 08 (/HDPN)
| Headphone detect
|}
== HDMI connector mapping ==
Luckily, it turns out that male HDMI connectors are somewhat electrically compatible with male EXT port connectors. This allows repurposing them as a replacement for a female EXT port connector.
* Note that using an HDMI plug may cause increased wear on the connector.
* In addition, an HDMI plug lacks the plastic sleeve which the original EXT port connector has, which leads to a loose connection.
** One solution is to 3D-print a sleeve to improve connection.
** Another solution is to include some type of LED/indicator in order to validate proper connection.
Due to the lack of availability of new EXT port connectors, this is a popular solution among DIY users and lower-end aftermarket accessories.
HDMI pins connect to EXT port pins as follows:
{| class="wikitable"
|-
! EXT !! HDMI
|-
| 01 (GND)
| 15 (SCL)
|-
| 02 (MOSI)
| 11 (TMDS Clock Shield)
|-
| 03 (MISO)
| 7 (TMDS Data 0 +)
|-
| 04 (+3V)
| 3 (TMDS Data 2 -)
|-
| 05 (BCLK)
| 4 (TMDS Data 1 +)
|-
| 06 (LRCK)
| 8 (TMDS Data 0 Shield)
|-
| 07 (SDAT)
| 12 (TMDS Clock -)
|-
| 08 (/HDPN)
| 16 (SDA)
|}
cfa9a96448909d312cac4b84db0a7e5a5400c78a
NEC V30MZ flags
0
56
466
342
2024-12-28T10:59:19Z
Asie
351
/* Status flags */ add anchors
wikitext
text/x-wiki
= NEC V30MZ flags =
== Layout ==
The V30MZ processor features a 16-bit flag register:
15 bit 8 7 bit 0
---- ---- ---- ----
m111 odit sz0a 0p1c
| |||| || | | |
| |||| || | | +- Carry (CF<sup>CY</sup>)
| |||| || | +--- Parity (PF<sup>P</sup>)
| |||| || +------ Auxillary Carry (AF<sup>AC</sup>)
| |||| |+-------- Zero (Z)
| |||| +--------- Sign (S)
| |||+------------ Single Step<sup>Break</sup> (TF<sup>BRK</sup>)
| ||+------------- Interrupt Enable (IF<sup>IE</sup>)
| |+-------------- Direction (DF<sup>DIR</sup>)
| +--------------- Overflow (OF<sup>V</sup>)
+-------------------- Mode (MD)
== Status flags ==
The following flags are typically modified by instructions:
{{Anchor|CF}}
=== Carry ===
Stores the carry/borrow state of the last arithmetic operation, or the bit shifted to it for shift/rotate operations.
{{Anchor|PF}}
=== Parity ===
Set to <tt>1</tt> if, after arithmetic and logical operations, the lower 8 bits of the result are even.
{{Anchor|AF}}
=== Auxillary Carry ===
Stores the carry state from the lower 4-bit nibble (bits 0-3) to the higher 4-bit nibble (bits 4-7), or the borrow state from the higher nibble to the lower nibble.
{{Anchor|ZF}}
=== Zero ===
Set to <tt>1</tt> if, after arithmetic and logical operations, the result is equal to zero.
{{Anchor|SF}}
=== Sign ===
Set to <tt>1</tt> if, after arithmetic and logical operations, the highest bit of the result is set.
{{Anchor|OF}}
=== Overflow ===
Set to <tt>1</tt> if an overflow occured as part of the arithmetic operation.
== Control flags ==
The following flags are typically modified by the developer:
=== Single step ===
If set to <tt>1</tt>, after every instruction, a software interrupt (vector 1) is generated.
Alternatively referred to as the ''trap flag''.
=== Interrupt enable ===
If set to <tt>1</tt>, enables maskable interrupt handling via the interrupt vector table; cleared to <tt>0</tt> as part of interrupt handling and restored by the <tt>IRET</tt> opcode.
=== Direction ===
If set to <tt>1</tt>, string instructions decrement pointers as part of their operation; if set to <tt>0</tt>, the pointers are to be incremented.
=== Mode ===
This flag does nothing on the NEC V30MZ. It was used to implement 8080 emulation mode in other V20/V30-family chips, but this functionality has been removed in the V30MZ.
838eab05e6fde77eb5a0d3c347b3af61bc58604d
467
466
2024-12-28T10:59:55Z
Asie
351
add remaining anchors
wikitext
text/x-wiki
= NEC V30MZ flags =
== Layout ==
The V30MZ processor features a 16-bit flag register:
15 bit 8 7 bit 0
---- ---- ---- ----
m111 odit sz0a 0p1c
| |||| || | | |
| |||| || | | +- Carry (CF<sup>CY</sup>)
| |||| || | +--- Parity (PF<sup>P</sup>)
| |||| || +------ Auxillary Carry (AF<sup>AC</sup>)
| |||| |+-------- Zero (ZF<sup>Z</sup>)
| |||| +--------- Sign (SF<sup>S</sup>)
| |||+------------ Single Step<sup>Break</sup> (TF<sup>BRK</sup>)
| ||+------------- Interrupt Enable (IF<sup>IE</sup>)
| |+-------------- Direction (DF<sup>DIR</sup>)
| +--------------- Overflow (OF<sup>V</sup>)
+-------------------- Mode (MD)
== Status flags ==
The following flags are typically modified by instructions:
{{Anchor|CF}}
=== Carry ===
Stores the carry/borrow state of the last arithmetic operation, or the bit shifted to it for shift/rotate operations.
{{Anchor|PF}}
=== Parity ===
Set to <tt>1</tt> if, after arithmetic and logical operations, the lower 8 bits of the result are even.
{{Anchor|AF}}
=== Auxillary Carry ===
Stores the carry state from the lower 4-bit nibble (bits 0-3) to the higher 4-bit nibble (bits 4-7), or the borrow state from the higher nibble to the lower nibble.
{{Anchor|ZF}}
=== Zero ===
Set to <tt>1</tt> if, after arithmetic and logical operations, the result is equal to zero.
{{Anchor|SF}}
=== Sign ===
Set to <tt>1</tt> if, after arithmetic and logical operations, the highest bit of the result is set.
{{Anchor|OF}}
=== Overflow ===
Set to <tt>1</tt> if an overflow occured as part of the arithmetic operation.
== Control flags ==
The following flags are typically modified by the developer:
{{Anchor|TF}}
=== Single step ===
If set to <tt>1</tt>, after every instruction, a software interrupt (vector 1) is generated.
Alternatively referred to as the ''trap flag''.
{{Anchor|IF}}
=== Interrupt enable ===
If set to <tt>1</tt>, enables maskable interrupt handling via the interrupt vector table; cleared to <tt>0</tt> as part of interrupt handling and restored by the <tt>IRET</tt> opcode.
{{Anchor|DF}}
=== Direction ===
If set to <tt>1</tt>, string instructions decrement pointers as part of their operation; if set to <tt>0</tt>, the pointers are to be incremented.
{{Anchor|MD}}
=== Mode ===
This flag does nothing on the NEC V30MZ. It was used to implement 8080 emulation mode in other V20/V30-family chips, but this functionality has been removed in the V30MZ.
8e17805122b4c7a13d0814513327918729424f4d
469
467
2024-12-28T11:04:14Z
Asie
351
wikitext
text/x-wiki
= NEC V30MZ flags =
== Layout ==
The V30MZ processor features a 16-bit flag register:
15 bit 8 7 bit 0
---- ---- ---- ----
m111 odit sz0a 0p1c
| |||| || | | |
| |||| || | | +- Carry (CF<sup>CY</sup>)
| |||| || | +--- Parity (PF<sup>P</sup>)
| |||| || +------ Auxillary Carry (AF<sup>AC</sup>)
| |||| |+-------- Zero (ZF<sup>Z</sup>)
| |||| +--------- Sign (SF<sup>S</sup>)
| |||+------------ Single Step<sup>Break</sup> (TF<sup>BRK</sup>)
| ||+------------- Interrupt Enable (IF<sup>IE</sup>)
| |+-------------- Direction (DF<sup>DIR</sup>)
| +--------------- Overflow (OF<sup>V</sup>)
+-------------------- Mode (MD)
== Status flags ==
The following flags are typically modified by instructions:
{{Anchor|CF}}
=== CF - Carry ===
Stores the carry/borrow state of the last arithmetic operation, or the bit shifted to it for shift/rotate operations.
{{Anchor|PF}}
=== PF - Parity ===
Set to <tt>1</tt> if, after arithmetic and logical operations, the lower 8 bits of the result are even.
{{Anchor|AF}}
=== AF - Auxillary Carry ===
Stores the carry state from the lower 4-bit nibble (bits 0-3) to the higher 4-bit nibble (bits 4-7), or the borrow state from the higher nibble to the lower nibble.
{{Anchor|ZF}}
=== ZF - Zero ===
Set to <tt>1</tt> if, after arithmetic and logical operations, the result is equal to zero.
{{Anchor|SF}}
=== SF - Sign ===
Set to <tt>1</tt> if, after arithmetic and logical operations, the highest bit of the result is set.
{{Anchor|OF}}
=== OF - Overflow ===
Set to <tt>1</tt> if an overflow occured as part of the arithmetic operation.
== Control flags ==
The following flags are typically modified by the developer:
{{Anchor|TF}}
=== TF - Single step ===
If set to <tt>1</tt>, after every instruction, a software interrupt (vector 1) is generated.
Alternatively referred to as the ''trap flag''.
{{Anchor|IF}}
=== IF - Interrupt enable ===
If set to <tt>1</tt>, enables maskable interrupt handling via the interrupt vector table; cleared to <tt>0</tt> as part of interrupt handling and restored by the <tt>IRET</tt> opcode.
{{Anchor|DF}}
=== DF - Direction ===
If set to <tt>1</tt>, string instructions decrement pointers as part of their operation; if set to <tt>0</tt>, the pointers are to be incremented.
{{Anchor|MD}}
=== MD - Mode ===
This flag does nothing on the NEC V30MZ. It was used to implement 8080 emulation mode in other V20/V30-family chips, but this functionality has been removed in the V30MZ.
3edea312d6c8869b4a8146d30d48f14ee4578d23
Cartridge connector
0
44
471
332
2024-12-28T15:47:24Z
Asie
351
/* Pinout */ oops
wikitext
text/x-wiki
== Memory access ==
Both the ROM and the SRAM chip use a standard asynchronous memory interface.
It is presumed that:
* the CPU sets the address lines before each memory access while '''/OE''' or '''/WE''' respectively are still high,
* for writes the CPU sets the data lines with the falling edge of '''/WE''' (TODO: only confirmed for I/O writes),
* for reads the CPU latches the data lines on the subsequent rising edge of '''/OE'''.
Memory may be accessed in 8-bit or 16-bit mode. SRAM reads/writes always happen in 8-bit mode, while ROM reads/writes can happen in 8-bit or 16-bit mode depending on [[ROM header|header]] configuration.
Note that in 16-bit mode, the output on address line '''A0''' is undetermined and should be ignored.
== Pinout ==
<pre>
Cartridge Console
(label side) (back)
____________
|====|
____ |--48| -- GND
... \ | -47| <- CLK
... | | -46| -> /IRQ (Interrupt request)
... | | -45| <- /SEL (Cartridge select)
... | | -44| <- /WR (Write enable)
... | | -43| <- /RD (Read enable)
... | | -42| <- M/IO (Memory/IO)
... | | -41| -> /MBC
... | | -40| <- /RESET
... | | -39| <> D13
... | | -38| <> D12
... | | -37| <> D11
... | | -36| <> D10
... | | -35| <> D9
... | | -34| <> D8
... | | -33| <- CPU A16
... | | -32| <- CPU A17
... | | -31| <- CPU A18
... | | -30| <- CPU A19
... | | -29| <- CPU A3
... | | -28| <- CPU A2
... | | -27| <- CPU A1
... | | -26| <- CPU A0
... | |--25| -- +3.3V
... | |--24| -- +3.3V
... | | -23| <> D0
... | | -22| <> D1
... | | -21| <> D2
... | | -20| <> D3
... | | -19| <> D4
... | | -18| <> D5
... | | -17| <> D6
... | | -16| <> D7
... | | -15| <> D14
... | | -14| <> D15
... | | -13| <- CPU A4
... | | -12| <- CPU A5
... | | -11| <- CPU A6
... | | -10| <- CPU A7
... | | -09| <- CPU A12
... | | -08| <- CPU A14
... | | -07| <- CPU A13
... | | -06| <- CPU A8
... | | -05| <- CPU A9
... | | -04| <- CPU A11
... | | -03| <- CPU A10
____/ | -02| <- CPU A15
|--01| -- GND
_______|====|
Cartridge Console
(label side) (back)
</pre>
== Mechanical details ==
{| class="wikitable"
|-
! Distance !! Length (in mm)
|-
| Distance pad to pad || 1.25
|-
| Left edge to first pad || 0.7
|-
| Last pad to right edge || 0.95
|-
| Bottom edge to longer pads (GND, Vcc) || 0.5
|-
| Bottom edge to shorter pads || 1
|}
== Signal descriptions ==
* '''/RESET''': Reset signal output from the console. On a mono WonderSwan, it stays low for about 18 milliseconds after power-up.
* '''/MBC''': Authentication handshake signal. A cartridge is required to communicate over this pin shortly after reset.
* '''M/IO''': Memory/IO bus selection. The cartridge bus allows both memory access (to physical addresses 0x10000-0xFFFFF) and I/O access (to ports 0xC0-0xFF):
** When Memory/IO is '''high''', pins A0-A19 specify the 20-bit linear memory address.
** When Memory/IO is '''low''', pins A0-A7 specify the 8-bit I/O port address, pins A8-A15 are low, pins A16-A19 are a copy of the I/O port address bits 4-7.
* '''/IRQ''': Cartridge interrupt. When this pin is pulled low, the console will trigger a maskable cartridge interrupt.
* '''CLK''': A clock provided by the console. This pin outputs a frequency of 384 KHz, derived from the 12.288 MHz system clock; on the WonderSwan Color, it can optionally be configured by software to provide a 6.144 MHz frequency instead.
== Timing requirements ==
The '''/OE''' or '''/WE''' signal appear to have a frequency of about 3.072 MHz, derived from the 12.288 MHz system clock. This leaves half this period, so about 162 ns, to handle one memory access.
TODO: Verify how using ROM/SRAM wait states affects this.
== Authentication handshake ==
Shortly after '''/RESET''' goes high, a handshake between the SoC and the cartridge is performed, in order:
* '''/MBC''' is held high. '''A0'''-'''A3''' are set to 0xA and '''A16'''-'''A19''' are set to 0x5.
* On a rising edge of '''CLK''', '''A0'''-'''A3''' are set to 0x5 and '''A16'''-'''A19''' are set to 0xA.
* The cartridge continues to hold '''/MBC''' high for three additional '''CLK''' rising edges. Note that the SoC appears to allow some variance in this number of cycles.
* For each subsequent rising edge of '''CLK''', the cartridge is expected to output the following binary sequence through its '''/MBC''' pin: <code>1000101000101000000111</code>.
* After this is finished, '''/MBC''' is expected to stay high indefinitely.
On a successful handshake, the [[SoC]] sets bit 7 of the System Control I/O port. The boot ROM will refuse to boot the cartridge if this bit is not set; on the WonderSwan Color, it will refuse to start the system at all.
An example public domain (CC0) VHDL implementation by trap15 is available [https://bitbucket.org/trap15/mbc-unlock here].
d14349724e9b2bb4cc0ca4be28027c2138dc568d
WonderWitch/FreyaBIOS/Text
0
53
474
389
2024-12-29T10:07:36Z
Asie
351
/* INT $13/AH=$07 - text_put_numeric */ fix text_put_numeric
wikitext
text/x-wiki
The Text interrupt provides a text output display using one of the WonderSwan's screens.
== Interrupts ==
=== INT $13/AH=$00 - text_screen_init ===
* AH = $00
Initializes a text window (see INT $13/AH=$01) with the following default settings:
* X, Y = 0, 0
* width, height = 28, 18
* starting tile = 512 - font tile count (in ASCII mode)
* starting tile = 512 - (width x height) (in Shift-JIS and mixed modes)
=== INT $13/AH=$01 - text_window_init ===
* AH = $01
* BL = X position on screen, in tiles
* BH = Y position on screen, in tiles
* CL = width, in tiles
* CH = height, in tiles
* DX = starting tile
Initializes a text window starting at <code>(BL, BH)</code> with a size of <code>CL x CH</code> tiles on the configured screen.
This requires the following number of tiles, starting at <code>DX</code>:
* font tile count (in ASCII mode)
* width x height (in Shift-JIS and mixed modes)
=== INT $13/AH=$02 - text_set_mode ===
* AH = $02
* BX = Text mode
Available modes:
* 0 = ASCII mode
* 1 = mixed (ASCII and Shift-JIS) mode
* 2 = Shift-JIS mode
=== INT $13/AH=$03 - text_get_mode ===
* AH = $03
Return:
* BX = Text mode
=== INT $13/AH=$04 - text_put_char ===
* AH = $04
* BL = X position in text window
* BH = Y position in text window
* CX = Character code
=== INT $13/AH=$05 - text_put_string ===
* AH = $05
* BL = X position in text window
* BH = Y position in text window
* DS:DX = String to print
Return:
* AX = Number of characters displayed
=== INT $13/AH=$06 - text_put_substring ===
* AH = $06
* BL = X position in text window
* BH = Y position in text window
* CX = Maximum length of string to print
* DS:DX = String to print
Return:
* AX = Number of characters displayed
=== INT $13/AH=$07 - text_put_numeric ===
* AH = $07
* BX =
** if flag bit 7 clear:
*** BL = X position in text window
*** BH = Y position in text window
** if flag bit 7 set:
*** DS:BX = Output buffer to write to
* CL = Width of area to write number in
* CH = Flags
* DX = Number
Return:
* AX = Number of characters displayed
Numeric output flags:
<pre>
7 bit 0
---- ----
o... slzx
| ||||
| |||+- 0 = output in decimal
| ||| 1 = output in hexadecimal
| ||+---- 0 = pad with spaces
| || 1 = pad with zeroes
| |+------- 0 = align to right
| | 1 = align to left
| +---------- 0 = number is unsigned
| 1 = number is signed
+----------------- 0 = output to text window (at BL, BH)
1 = output to buffer (DS:SI)
</pre>
=== INT $13/AH=$08 - text_fill_char ===
* AH = $08
* BL = X position in text window
* BH = Y position in text window
* CX = Length
* DX = Character code
Repeat the specified character code <code>CX</code> times.
=== INT $13/AH=$09 - text_set_palette ===
* AH = $09
* BX = Palette color (0-15).
Set the palette used by printed text.
=== INT $13/AH=$0A - text_get_palette ===
* AH = $0A
Return:
* AX = Palette color (0-15).
Retrieve the palette used by printed text.
=== INT $13/AH=$0B - text_set_ank_font ===
* AH = $0B
* BL = Starting character code.
* BH = Bit depth; 0 = 1bpp, 1 = 2bpp.
* CX = Number of tiles.
* DS:DX = Input buffer containing font data.
=== INT $13/AH=$0C - text_set_sjis_font ===
TODO
=== INT $13/AH=$0D - text_get_fontdata ===
* AH = $0D
* CX = Character code.
* DS:DX = Output buffer for the character's tile data.
=== INT $13/AH=$0E - text_set_screen ===
* AH = $0E
* AL = Screen ID (0, 1).
=== INT $13/AH=$0F - text_get_screen ===
* AH = $0F
Return:
* AL = Screen ID (0, 1).
=== INT $13/AH=$10 - cursor_display ===
* AH = $10
* AL = Cursor status (0 = disabled, 1 = enabled).
Controls the visibility of a blinking cursor on the text screen.
=== INT $13/AH=$11 - cursor_status ===
* AH = $11
Return:
* AX = Cursor status.
<pre>
7 bit 0
---- ----
.... ..ve
||
|+- 0 = disabled, 1 = enabled
+-- 0 = currently not visible, 1 = visible
</pre>
=== INT $13/AH=$12 - cursor_set_location ===
* AH = $12
* BL = X position
* BH = Y position
* CL = Width, in tiles
* CH = Height, in tiles
=== INT $13/AH=$13 - cursor_get_location ===
* AH = $13
Return:
* AL = X position
* AH = Y position
* DL = Width, in tiles
* DH = Height, in tiles
=== INT $13/AH=$14 - cursor_set_type ===
* AH = $14
* BL = Palette (0-15) used by cursor area when visible
* CL = Blinking rate, in frames (0 = always visible)
The defaults are as follows:
* Palette = 1
* Blinking rate = 30
=== INT $13/AH=$15 - cursor_get_type ===
* AH = $15
Return:
* AL = Palette (0-15) used by cursor area when visible
* AH = Blinking rate, in frames (0 = always visible)
c07329659e8de4ec29f4ee160eb252181341608c
475
474
2024-12-29T10:22:41Z
Asie
351
/* INT $13/AH=$07 - text_put_numeric */
wikitext
text/x-wiki
The Text interrupt provides a text output display using one of the WonderSwan's screens.
== Interrupts ==
=== INT $13/AH=$00 - text_screen_init ===
* AH = $00
Initializes a text window (see INT $13/AH=$01) with the following default settings:
* X, Y = 0, 0
* width, height = 28, 18
* starting tile = 512 - font tile count (in ASCII mode)
* starting tile = 512 - (width x height) (in Shift-JIS and mixed modes)
=== INT $13/AH=$01 - text_window_init ===
* AH = $01
* BL = X position on screen, in tiles
* BH = Y position on screen, in tiles
* CL = width, in tiles
* CH = height, in tiles
* DX = starting tile
Initializes a text window starting at <code>(BL, BH)</code> with a size of <code>CL x CH</code> tiles on the configured screen.
This requires the following number of tiles, starting at <code>DX</code>:
* font tile count (in ASCII mode)
* width x height (in Shift-JIS and mixed modes)
=== INT $13/AH=$02 - text_set_mode ===
* AH = $02
* BX = Text mode
Available modes:
* 0 = ASCII mode
* 1 = mixed (ASCII and Shift-JIS) mode
* 2 = Shift-JIS mode
=== INT $13/AH=$03 - text_get_mode ===
* AH = $03
Return:
* BX = Text mode
=== INT $13/AH=$04 - text_put_char ===
* AH = $04
* BL = X position in text window
* BH = Y position in text window
* CX = Character code
=== INT $13/AH=$05 - text_put_string ===
* AH = $05
* BL = X position in text window
* BH = Y position in text window
* DS:DX = String to print
Return:
* AX = Number of characters displayed
=== INT $13/AH=$06 - text_put_substring ===
* AH = $06
* BL = X position in text window
* BH = Y position in text window
* CX = Maximum length of string to print
* DS:DX = String to print
Return:
* AX = Number of characters displayed
=== INT $13/AH=$07 - text_put_numeric ===
* AH = $07
* BX =
** if flag bit 7 clear:
*** BL = X position in text window
*** BH = Y position in text window
** if flag bit 7 set:
*** DS:BX = Output buffer to write to
* CL = Width of area to write number in
* CH = Flags
* DX = Number
Return:
* AX = Number of characters displayed
Numeric output flags:
<pre>
7 bit 0
---- ----
o... slzx
| ||||
| |||+- 0 = output in decimal
| ||| 1 = output in hexadecimal (always pads with zeroes, aligns to right)
| ||+---- 0 = pad with spaces
| || 1 = pad with zeroes
| |+------- 0 = align to right
| | 1 = align to left (ignores padding)
| +---------- 0 = number is unsigned
| 1 = number is signed
+----------------- 0 = output to text window (at BL, BH)
1 = output to buffer (DS:SI)
</pre>
Errata:
- When padding a signed number with zeroes, the minus sign will be output after the zeroes; for example, calling text_put_numeric for the number <tt>-1234</tt> with a length of 8 and those flags will print <tt>000-1234</tt>, not <tt>-0001234</tt>.
=== INT $13/AH=$08 - text_fill_char ===
* AH = $08
* BL = X position in text window
* BH = Y position in text window
* CX = Length
* DX = Character code
Repeat the specified character code <code>CX</code> times.
=== INT $13/AH=$09 - text_set_palette ===
* AH = $09
* BX = Palette color (0-15).
Set the palette used by printed text.
=== INT $13/AH=$0A - text_get_palette ===
* AH = $0A
Return:
* AX = Palette color (0-15).
Retrieve the palette used by printed text.
=== INT $13/AH=$0B - text_set_ank_font ===
* AH = $0B
* BL = Starting character code.
* BH = Bit depth; 0 = 1bpp, 1 = 2bpp.
* CX = Number of tiles.
* DS:DX = Input buffer containing font data.
=== INT $13/AH=$0C - text_set_sjis_font ===
TODO
=== INT $13/AH=$0D - text_get_fontdata ===
* AH = $0D
* CX = Character code.
* DS:DX = Output buffer for the character's tile data.
=== INT $13/AH=$0E - text_set_screen ===
* AH = $0E
* AL = Screen ID (0, 1).
=== INT $13/AH=$0F - text_get_screen ===
* AH = $0F
Return:
* AL = Screen ID (0, 1).
=== INT $13/AH=$10 - cursor_display ===
* AH = $10
* AL = Cursor status (0 = disabled, 1 = enabled).
Controls the visibility of a blinking cursor on the text screen.
=== INT $13/AH=$11 - cursor_status ===
* AH = $11
Return:
* AX = Cursor status.
<pre>
7 bit 0
---- ----
.... ..ve
||
|+- 0 = disabled, 1 = enabled
+-- 0 = currently not visible, 1 = visible
</pre>
=== INT $13/AH=$12 - cursor_set_location ===
* AH = $12
* BL = X position
* BH = Y position
* CL = Width, in tiles
* CH = Height, in tiles
=== INT $13/AH=$13 - cursor_get_location ===
* AH = $13
Return:
* AL = X position
* AH = Y position
* DL = Width, in tiles
* DH = Height, in tiles
=== INT $13/AH=$14 - cursor_set_type ===
* AH = $14
* BL = Palette (0-15) used by cursor area when visible
* CL = Blinking rate, in frames (0 = always visible)
The defaults are as follows:
* Palette = 1
* Blinking rate = 30
=== INT $13/AH=$15 - cursor_get_type ===
* AH = $15
Return:
* AL = Palette (0-15) used by cursor area when visible
* AH = Blinking rate, in frames (0 = always visible)
c1651be778a2c04349e92ebd3ed553e3e7852703
476
475
2024-12-29T10:25:11Z
Asie
351
/* INT $13/AH=$07 - text_put_numeric */
wikitext
text/x-wiki
The Text interrupt provides a text output display using one of the WonderSwan's screens.
== Interrupts ==
=== INT $13/AH=$00 - text_screen_init ===
* AH = $00
Initializes a text window (see INT $13/AH=$01) with the following default settings:
* X, Y = 0, 0
* width, height = 28, 18
* starting tile = 512 - font tile count (in ASCII mode)
* starting tile = 512 - (width x height) (in Shift-JIS and mixed modes)
=== INT $13/AH=$01 - text_window_init ===
* AH = $01
* BL = X position on screen, in tiles
* BH = Y position on screen, in tiles
* CL = width, in tiles
* CH = height, in tiles
* DX = starting tile
Initializes a text window starting at <code>(BL, BH)</code> with a size of <code>CL x CH</code> tiles on the configured screen.
This requires the following number of tiles, starting at <code>DX</code>:
* font tile count (in ASCII mode)
* width x height (in Shift-JIS and mixed modes)
=== INT $13/AH=$02 - text_set_mode ===
* AH = $02
* BX = Text mode
Available modes:
* 0 = ASCII mode
* 1 = mixed (ASCII and Shift-JIS) mode
* 2 = Shift-JIS mode
=== INT $13/AH=$03 - text_get_mode ===
* AH = $03
Return:
* BX = Text mode
=== INT $13/AH=$04 - text_put_char ===
* AH = $04
* BL = X position in text window
* BH = Y position in text window
* CX = Character code
=== INT $13/AH=$05 - text_put_string ===
* AH = $05
* BL = X position in text window
* BH = Y position in text window
* DS:DX = String to print
Return:
* AX = Number of characters displayed
=== INT $13/AH=$06 - text_put_substring ===
* AH = $06
* BL = X position in text window
* BH = Y position in text window
* CX = Maximum length of string to print
* DS:DX = String to print
Return:
* AX = Number of characters displayed
=== INT $13/AH=$07 - text_put_numeric ===
* AH = $07
* BX =
** if flag bit 7 clear:
*** BL = X position in text window
*** BH = Y position in text window
** if flag bit 7 set:
*** DS:BX = Output buffer to write to
* CL = Width of area to write number in
* CH = Flags
* DX = Number
Return:
* AX = Number of characters displayed
Numeric output flags:
<pre>
7 bit 0
---- ----
o... slzx
| ||||
| |||+- 0 = output in decimal
| ||| 1 = output in hexadecimal (always pads with zeroes, aligns to right, assumes unsigned number)
| ||+---- 0 = pad with spaces
| || 1 = pad with zeroes
| |+------- 0 = align to right
| | 1 = align to left (ignores padding)
| +---------- 0 = number is unsigned
| 1 = number is signed
+----------------- 0 = output to text window (at BL, BH)
1 = output to buffer (DS:SI)
</pre>
Errata:
- When padding a signed number with zeroes, the minus sign will be output after the zeroes; for example, calling text_put_numeric for the number <tt>-1234</tt> with a length of 8 and those flags will print <tt>000-1234</tt>, not <tt>-0001234</tt>.
=== INT $13/AH=$08 - text_fill_char ===
* AH = $08
* BL = X position in text window
* BH = Y position in text window
* CX = Length
* DX = Character code
Repeat the specified character code <code>CX</code> times.
=== INT $13/AH=$09 - text_set_palette ===
* AH = $09
* BX = Palette color (0-15).
Set the palette used by printed text.
=== INT $13/AH=$0A - text_get_palette ===
* AH = $0A
Return:
* AX = Palette color (0-15).
Retrieve the palette used by printed text.
=== INT $13/AH=$0B - text_set_ank_font ===
* AH = $0B
* BL = Starting character code.
* BH = Bit depth; 0 = 1bpp, 1 = 2bpp.
* CX = Number of tiles.
* DS:DX = Input buffer containing font data.
=== INT $13/AH=$0C - text_set_sjis_font ===
TODO
=== INT $13/AH=$0D - text_get_fontdata ===
* AH = $0D
* CX = Character code.
* DS:DX = Output buffer for the character's tile data.
=== INT $13/AH=$0E - text_set_screen ===
* AH = $0E
* AL = Screen ID (0, 1).
=== INT $13/AH=$0F - text_get_screen ===
* AH = $0F
Return:
* AL = Screen ID (0, 1).
=== INT $13/AH=$10 - cursor_display ===
* AH = $10
* AL = Cursor status (0 = disabled, 1 = enabled).
Controls the visibility of a blinking cursor on the text screen.
=== INT $13/AH=$11 - cursor_status ===
* AH = $11
Return:
* AX = Cursor status.
<pre>
7 bit 0
---- ----
.... ..ve
||
|+- 0 = disabled, 1 = enabled
+-- 0 = currently not visible, 1 = visible
</pre>
=== INT $13/AH=$12 - cursor_set_location ===
* AH = $12
* BL = X position
* BH = Y position
* CL = Width, in tiles
* CH = Height, in tiles
=== INT $13/AH=$13 - cursor_get_location ===
* AH = $13
Return:
* AL = X position
* AH = Y position
* DL = Width, in tiles
* DH = Height, in tiles
=== INT $13/AH=$14 - cursor_set_type ===
* AH = $14
* BL = Palette (0-15) used by cursor area when visible
* CL = Blinking rate, in frames (0 = always visible)
The defaults are as follows:
* Palette = 1
* Blinking rate = 30
=== INT $13/AH=$15 - cursor_get_type ===
* AH = $15
Return:
* AL = Palette (0-15) used by cursor area when visible
* AH = Blinking rate, in frames (0 = always visible)
969218bdc097adb4ed3800e85d8634ebae8d05da
477
476
2024-12-29T13:33:30Z
Asie
351
/* INT $13/AH=$07 - text_put_numeric */
wikitext
text/x-wiki
The Text interrupt provides a text output display using one of the WonderSwan's screens.
== Interrupts ==
=== INT $13/AH=$00 - text_screen_init ===
* AH = $00
Initializes a text window (see INT $13/AH=$01) with the following default settings:
* X, Y = 0, 0
* width, height = 28, 18
* starting tile = 512 - font tile count (in ASCII mode)
* starting tile = 512 - (width x height) (in Shift-JIS and mixed modes)
=== INT $13/AH=$01 - text_window_init ===
* AH = $01
* BL = X position on screen, in tiles
* BH = Y position on screen, in tiles
* CL = width, in tiles
* CH = height, in tiles
* DX = starting tile
Initializes a text window starting at <code>(BL, BH)</code> with a size of <code>CL x CH</code> tiles on the configured screen.
This requires the following number of tiles, starting at <code>DX</code>:
* font tile count (in ASCII mode)
* width x height (in Shift-JIS and mixed modes)
=== INT $13/AH=$02 - text_set_mode ===
* AH = $02
* BX = Text mode
Available modes:
* 0 = ASCII mode
* 1 = mixed (ASCII and Shift-JIS) mode
* 2 = Shift-JIS mode
=== INT $13/AH=$03 - text_get_mode ===
* AH = $03
Return:
* BX = Text mode
=== INT $13/AH=$04 - text_put_char ===
* AH = $04
* BL = X position in text window
* BH = Y position in text window
* CX = Character code
=== INT $13/AH=$05 - text_put_string ===
* AH = $05
* BL = X position in text window
* BH = Y position in text window
* DS:DX = String to print
Return:
* AX = Number of characters displayed
=== INT $13/AH=$06 - text_put_substring ===
* AH = $06
* BL = X position in text window
* BH = Y position in text window
* CX = Maximum length of string to print
* DS:DX = String to print
Return:
* AX = Number of characters displayed
=== INT $13/AH=$07 - text_put_numeric ===
* AH = $07
* BX =
** if flag bit 7 clear:
*** BL = X position in text window
*** BH = Y position in text window
** if flag bit 7 set:
*** DS:BX = Output buffer to write to
* CL = Width of area to write number in
* CH = Flags
* DX = Number
Return:
* AX = Number of characters displayed
Numeric output flags:
<pre>
7 bit 0
---- ----
o... slzx
| ||||
| |||+- 0 = output in decimal
| ||| 1 = output in hexadecimal (always pads with zeroes, aligns to right, assumes unsigned number)
| ||+---- 0 = pad with spaces
| || 1 = pad with zeroes
| |+------- 0 = align to right
| | 1 = align to left (ignores padding)
| +---------- 0 = number is unsigned
| 1 = number is signed
+----------------- 0 = output to text window (at BL, BH)
1 = output to buffer (DS:BX)
</pre>
Errata:
- When padding a signed number with zeroes, the minus sign will be output after the zeroes; for example, calling text_put_numeric for the number <tt>-1234</tt> with a length of 8 and those flags will print <tt>000-1234</tt>, not <tt>-0001234</tt>.
=== INT $13/AH=$08 - text_fill_char ===
* AH = $08
* BL = X position in text window
* BH = Y position in text window
* CX = Length
* DX = Character code
Repeat the specified character code <code>CX</code> times.
=== INT $13/AH=$09 - text_set_palette ===
* AH = $09
* BX = Palette color (0-15).
Set the palette used by printed text.
=== INT $13/AH=$0A - text_get_palette ===
* AH = $0A
Return:
* AX = Palette color (0-15).
Retrieve the palette used by printed text.
=== INT $13/AH=$0B - text_set_ank_font ===
* AH = $0B
* BL = Starting character code.
* BH = Bit depth; 0 = 1bpp, 1 = 2bpp.
* CX = Number of tiles.
* DS:DX = Input buffer containing font data.
=== INT $13/AH=$0C - text_set_sjis_font ===
TODO
=== INT $13/AH=$0D - text_get_fontdata ===
* AH = $0D
* CX = Character code.
* DS:DX = Output buffer for the character's tile data.
=== INT $13/AH=$0E - text_set_screen ===
* AH = $0E
* AL = Screen ID (0, 1).
=== INT $13/AH=$0F - text_get_screen ===
* AH = $0F
Return:
* AL = Screen ID (0, 1).
=== INT $13/AH=$10 - cursor_display ===
* AH = $10
* AL = Cursor status (0 = disabled, 1 = enabled).
Controls the visibility of a blinking cursor on the text screen.
=== INT $13/AH=$11 - cursor_status ===
* AH = $11
Return:
* AX = Cursor status.
<pre>
7 bit 0
---- ----
.... ..ve
||
|+- 0 = disabled, 1 = enabled
+-- 0 = currently not visible, 1 = visible
</pre>
=== INT $13/AH=$12 - cursor_set_location ===
* AH = $12
* BL = X position
* BH = Y position
* CL = Width, in tiles
* CH = Height, in tiles
=== INT $13/AH=$13 - cursor_get_location ===
* AH = $13
Return:
* AL = X position
* AH = Y position
* DL = Width, in tiles
* DH = Height, in tiles
=== INT $13/AH=$14 - cursor_set_type ===
* AH = $14
* BL = Palette (0-15) used by cursor area when visible
* CL = Blinking rate, in frames (0 = always visible)
The defaults are as follows:
* Palette = 1
* Blinking rate = 30
=== INT $13/AH=$15 - cursor_get_type ===
* AH = $15
Return:
* AL = Palette (0-15) used by cursor area when visible
* AH = Blinking rate, in frames (0 = always visible)
66e1fbb910d0da30fbe48286212058a09c60202b
478
477
2024-12-29T13:49:33Z
Asie
351
/* INT $13/AH=$07 - text_put_numeric */
wikitext
text/x-wiki
The Text interrupt provides a text output display using one of the WonderSwan's screens.
== Interrupts ==
=== INT $13/AH=$00 - text_screen_init ===
* AH = $00
Initializes a text window (see INT $13/AH=$01) with the following default settings:
* X, Y = 0, 0
* width, height = 28, 18
* starting tile = 512 - font tile count (in ASCII mode)
* starting tile = 512 - (width x height) (in Shift-JIS and mixed modes)
=== INT $13/AH=$01 - text_window_init ===
* AH = $01
* BL = X position on screen, in tiles
* BH = Y position on screen, in tiles
* CL = width, in tiles
* CH = height, in tiles
* DX = starting tile
Initializes a text window starting at <code>(BL, BH)</code> with a size of <code>CL x CH</code> tiles on the configured screen.
This requires the following number of tiles, starting at <code>DX</code>:
* font tile count (in ASCII mode)
* width x height (in Shift-JIS and mixed modes)
=== INT $13/AH=$02 - text_set_mode ===
* AH = $02
* BX = Text mode
Available modes:
* 0 = ASCII mode
* 1 = mixed (ASCII and Shift-JIS) mode
* 2 = Shift-JIS mode
=== INT $13/AH=$03 - text_get_mode ===
* AH = $03
Return:
* BX = Text mode
=== INT $13/AH=$04 - text_put_char ===
* AH = $04
* BL = X position in text window
* BH = Y position in text window
* CX = Character code
=== INT $13/AH=$05 - text_put_string ===
* AH = $05
* BL = X position in text window
* BH = Y position in text window
* DS:DX = String to print
Return:
* AX = Number of characters displayed
=== INT $13/AH=$06 - text_put_substring ===
* AH = $06
* BL = X position in text window
* BH = Y position in text window
* CX = Maximum length of string to print
* DS:DX = String to print
Return:
* AX = Number of characters displayed
=== INT $13/AH=$07 - text_put_numeric ===
* AH = $07
* BX =
** if flag bit 7 clear:
*** BL = X position in text window
*** BH = Y position in text window
** if flag bit 7 set:
*** DS:BX = Output buffer to write to (at least [max(CL, length of number in characters) + 1] bytes)
* CL = Width of area to write number in
* CH = Flags
* DX = Number
Return:
* AX = Number of characters displayed
Numeric output flags:
<pre>
7 bit 0
---- ----
o... slzx
| ||||
| |||+- 0 = output in decimal
| ||| 1 = output in hexadecimal (always pads with zeroes, aligns to right, assumes unsigned number)
| ||+---- 0 = pad with spaces
| || 1 = pad with zeroes
| |+------- 0 = align to right
| | 1 = no align to right
| +---------- 0 = number is unsigned
| 1 = number is signed
+----------------- 0 = output to text window (at BL, BH)
1 = output to buffer (DS:BX)
</pre>
Errata:
- When padding a signed number with zeroes, the minus sign will be output after the zeroes; for example, calling text_put_numeric for the number <tt>-1234</tt> with a length of 8 and those flags will print <tt>000-1234</tt>, not <tt>-0001234</tt>.
- When writing to a buffer, the code always appends a NUL character (0) at the end; as such, the buffer should always be one byte larger than the maximum width.
=== INT $13/AH=$08 - text_fill_char ===
* AH = $08
* BL = X position in text window
* BH = Y position in text window
* CX = Length
* DX = Character code
Repeat the specified character code <code>CX</code> times.
=== INT $13/AH=$09 - text_set_palette ===
* AH = $09
* BX = Palette color (0-15).
Set the palette used by printed text.
=== INT $13/AH=$0A - text_get_palette ===
* AH = $0A
Return:
* AX = Palette color (0-15).
Retrieve the palette used by printed text.
=== INT $13/AH=$0B - text_set_ank_font ===
* AH = $0B
* BL = Starting character code.
* BH = Bit depth; 0 = 1bpp, 1 = 2bpp.
* CX = Number of tiles.
* DS:DX = Input buffer containing font data.
=== INT $13/AH=$0C - text_set_sjis_font ===
TODO
=== INT $13/AH=$0D - text_get_fontdata ===
* AH = $0D
* CX = Character code.
* DS:DX = Output buffer for the character's tile data.
=== INT $13/AH=$0E - text_set_screen ===
* AH = $0E
* AL = Screen ID (0, 1).
=== INT $13/AH=$0F - text_get_screen ===
* AH = $0F
Return:
* AL = Screen ID (0, 1).
=== INT $13/AH=$10 - cursor_display ===
* AH = $10
* AL = Cursor status (0 = disabled, 1 = enabled).
Controls the visibility of a blinking cursor on the text screen.
=== INT $13/AH=$11 - cursor_status ===
* AH = $11
Return:
* AX = Cursor status.
<pre>
7 bit 0
---- ----
.... ..ve
||
|+- 0 = disabled, 1 = enabled
+-- 0 = currently not visible, 1 = visible
</pre>
=== INT $13/AH=$12 - cursor_set_location ===
* AH = $12
* BL = X position
* BH = Y position
* CL = Width, in tiles
* CH = Height, in tiles
=== INT $13/AH=$13 - cursor_get_location ===
* AH = $13
Return:
* AL = X position
* AH = Y position
* DL = Width, in tiles
* DH = Height, in tiles
=== INT $13/AH=$14 - cursor_set_type ===
* AH = $14
* BL = Palette (0-15) used by cursor area when visible
* CL = Blinking rate, in frames (0 = always visible)
The defaults are as follows:
* Palette = 1
* Blinking rate = 30
=== INT $13/AH=$15 - cursor_get_type ===
* AH = $15
Return:
* AL = Palette (0-15) used by cursor area when visible
* AH = Blinking rate, in frames (0 = always visible)
99144513418d34c72e3ba1427eca11c3dce1ca73
479
478
2024-12-29T13:49:43Z
Asie
351
/* INT $13/AH=$07 - text_put_numeric */
wikitext
text/x-wiki
The Text interrupt provides a text output display using one of the WonderSwan's screens.
== Interrupts ==
=== INT $13/AH=$00 - text_screen_init ===
* AH = $00
Initializes a text window (see INT $13/AH=$01) with the following default settings:
* X, Y = 0, 0
* width, height = 28, 18
* starting tile = 512 - font tile count (in ASCII mode)
* starting tile = 512 - (width x height) (in Shift-JIS and mixed modes)
=== INT $13/AH=$01 - text_window_init ===
* AH = $01
* BL = X position on screen, in tiles
* BH = Y position on screen, in tiles
* CL = width, in tiles
* CH = height, in tiles
* DX = starting tile
Initializes a text window starting at <code>(BL, BH)</code> with a size of <code>CL x CH</code> tiles on the configured screen.
This requires the following number of tiles, starting at <code>DX</code>:
* font tile count (in ASCII mode)
* width x height (in Shift-JIS and mixed modes)
=== INT $13/AH=$02 - text_set_mode ===
* AH = $02
* BX = Text mode
Available modes:
* 0 = ASCII mode
* 1 = mixed (ASCII and Shift-JIS) mode
* 2 = Shift-JIS mode
=== INT $13/AH=$03 - text_get_mode ===
* AH = $03
Return:
* BX = Text mode
=== INT $13/AH=$04 - text_put_char ===
* AH = $04
* BL = X position in text window
* BH = Y position in text window
* CX = Character code
=== INT $13/AH=$05 - text_put_string ===
* AH = $05
* BL = X position in text window
* BH = Y position in text window
* DS:DX = String to print
Return:
* AX = Number of characters displayed
=== INT $13/AH=$06 - text_put_substring ===
* AH = $06
* BL = X position in text window
* BH = Y position in text window
* CX = Maximum length of string to print
* DS:DX = String to print
Return:
* AX = Number of characters displayed
=== INT $13/AH=$07 - text_put_numeric ===
* AH = $07
* BX =
** if flag bit 7 clear:
*** BL = X position in text window
*** BH = Y position in text window
** if flag bit 7 set:
*** DS:BX = Output buffer to write to (at least [max(CL, length of number in characters) + 1] bytes)
* CL = Width of area to write number in
* CH = Flags
* DX = Number
Return:
* AX = Number of characters displayed
Numeric output flags:
<pre>
7 bit 0
---- ----
o... slzx
| ||||
| |||+- 0 = output in decimal
| ||| 1 = output in hexadecimal (always pads with zeroes, aligns to right, assumes unsigned number)
| ||+---- 0 = pad with spaces
| || 1 = pad with zeroes
| |+------- 0 = align to right
| | 1 = no align to right
| +---------- 0 = number is unsigned
| 1 = number is signed
+----------------- 0 = output to text window (at BL, BH)
1 = output to buffer (DS:BX)
</pre>
Errata:
* When padding a signed number with zeroes, the minus sign will be output after the zeroes; for example, calling text_put_numeric for the number <tt>-1234</tt> with a length of 8 and those flags will print <tt>000-1234</tt>, not <tt>-0001234</tt>.
* When writing to a buffer, the code always appends a NUL character (0) at the end; as such, the buffer should always be one byte larger than the maximum width.
=== INT $13/AH=$08 - text_fill_char ===
* AH = $08
* BL = X position in text window
* BH = Y position in text window
* CX = Length
* DX = Character code
Repeat the specified character code <code>CX</code> times.
=== INT $13/AH=$09 - text_set_palette ===
* AH = $09
* BX = Palette color (0-15).
Set the palette used by printed text.
=== INT $13/AH=$0A - text_get_palette ===
* AH = $0A
Return:
* AX = Palette color (0-15).
Retrieve the palette used by printed text.
=== INT $13/AH=$0B - text_set_ank_font ===
* AH = $0B
* BL = Starting character code.
* BH = Bit depth; 0 = 1bpp, 1 = 2bpp.
* CX = Number of tiles.
* DS:DX = Input buffer containing font data.
=== INT $13/AH=$0C - text_set_sjis_font ===
TODO
=== INT $13/AH=$0D - text_get_fontdata ===
* AH = $0D
* CX = Character code.
* DS:DX = Output buffer for the character's tile data.
=== INT $13/AH=$0E - text_set_screen ===
* AH = $0E
* AL = Screen ID (0, 1).
=== INT $13/AH=$0F - text_get_screen ===
* AH = $0F
Return:
* AL = Screen ID (0, 1).
=== INT $13/AH=$10 - cursor_display ===
* AH = $10
* AL = Cursor status (0 = disabled, 1 = enabled).
Controls the visibility of a blinking cursor on the text screen.
=== INT $13/AH=$11 - cursor_status ===
* AH = $11
Return:
* AX = Cursor status.
<pre>
7 bit 0
---- ----
.... ..ve
||
|+- 0 = disabled, 1 = enabled
+-- 0 = currently not visible, 1 = visible
</pre>
=== INT $13/AH=$12 - cursor_set_location ===
* AH = $12
* BL = X position
* BH = Y position
* CL = Width, in tiles
* CH = Height, in tiles
=== INT $13/AH=$13 - cursor_get_location ===
* AH = $13
Return:
* AL = X position
* AH = Y position
* DL = Width, in tiles
* DH = Height, in tiles
=== INT $13/AH=$14 - cursor_set_type ===
* AH = $14
* BL = Palette (0-15) used by cursor area when visible
* CL = Blinking rate, in frames (0 = always visible)
The defaults are as follows:
* Palette = 1
* Blinking rate = 30
=== INT $13/AH=$15 - cursor_get_type ===
* AH = $15
Return:
* AL = Palette (0-15) used by cursor area when visible
* AH = Blinking rate, in frames (0 = always visible)
d551fb709329d840332e3a216e32e15bdd6108a0
WonderWitch/FreyaBIOS/Display
0
51
480
325
2024-12-29T15:58:05Z
Asie
351
/* INT $12/AH=$12 - sprite_set_data */
wikitext
text/x-wiki
The Display interrupt provides an abstraction layer and helpers for the WonderSwan's [[Display|display hardware]].
Note that features specific to the WonderSwan Color are implemented using [[WonderWitch/Libwwc|libwwc]], which is linked statically with the user program and thus not part of the BIOS call surface.
== Interrupts ==
=== INT $12/AH=$00 - display_control ===
* AH = $00
* BX = [[Display#Display Control|Display Control]] value
=== INT $12/AH=$01 - display_status ===
* AH = $01
Return:
* AX = [[Display#Display Control|Display Control]] value
=== INT $12/AH=$02 - font_set_monodata ===
* AH = $02
* BX = Starting tile
* CX = Tile count
* DS:DX = Input data buffer (<code>8 x Tile count</code> bytes)
Stores 1 bit-per-pixel tile data, which is expanded to 2 bits-per-pixel using the configured color.
=== INT $12/AH=$03 - font_set_colordata ===
* AH = $03
* BX = Starting tile
* CX = Tile count
* DS:DX = Input data buffer (<code>16 x Tile count</code> bytes)
Stores 2 bit-per-pixel tile data.
=== INT $12/AH=$04 - font_get_data ===
* AH = $04
* BX = Starting tile
* CX = Tile count
* DS:DX = Output data buffer (<code>16 x Tile count</code> bytes)
Retrieves 2 bit-per-pixel tile data.
=== INT $12/AH=$05 - font_set_color ===
* AH = $05
* BX = Color
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
.... .... .... bbff
||||
||++- Foreground color (0-3)
++--- Background color (0-3)
</pre>
Used by <code>font_set_monodata</code>.
=== INT $12/AH=$06 - font_get_color ===
* AH = $06
Return:
* AX = Color
=== INT $12/AH=$07 - screen_set_char ===
* AH = $07
* AL = Screen (0, 1)
* BL = Top-left tile X coordinate
* BH = Top-left tile Y coordinate
* CL = Width, in tiles
* CH = Height, in tiles
* DS:DX = Input tilemap buffer (<code>2 x Width x Height</code> bytes)
Places a rectangular tilemap on the specified screen.
=== INT $12/AH=$08 - screen_get_char ===
* AH = $08
* AL = Screen (0, 1)
* BL = Top-left tile X coordinate
* BH = Top-left tile Y coordinate
* CL = Width, in tiles
* CH = Height, in tiles
* DS:DX = Output tilemap buffer (<code>2 x Width x Height</code> bytes)
Retrieves a rectangular tilemap from the specified screen.
Special case: If CL/CH are equal to 0, <code>DS:DX</code> is ignored and instead <code>AX</code> is set to the tile at coordinates <code>(BL, BH)</code>.
=== INT $12/AH=$09 - screen_fill_char ===
* AH = $09
* AL = Screen (0, 1)
* BL = Top-left tile X coordinate
* BH = Top-left tile Y coordinate
* CL = Width, in tiles
* CH = Height, in tiles
* DX = Tile attribute
Fills a rectangular area with the specified tile attribute.
=== INT $12/AH=$0A - screen_fill_attr ===
* AH = $0A
* AL = Screen (0, 1)
* BL = Top-left tile X coordinate
* BH = Top-left tile Y coordinate
* CL = Width, in tiles
* CH = Height, in tiles
* DX = Tile data
* SI = Tile mask
Modifies each tile in the specified rectangular area as follows: <code>tile = ((tile & SI) | DX)</code>.
=== INT $12/AH=$0B - sprite_set_range ===
* AH = $0B
* BX = [[Display#Sprite Table First|Sprite Table First]]
* CX = [[Display#Sprite Table Count|Sprite Table Count]]
=== INT $12/AH=$0C - sprite_set_char ===
* AH = $0C
* BX = Sprite ID in table (0 - 127)
* CX = Sprite attribute
=== INT $12/AH=$0D - sprite_get_char ===
* AH = $0D
* BX = Sprite ID in table (0 - 127)
Return:
* AX = Sprite attribute
=== INT $12/AH=$0E - sprite_set_location ===
* AH = $0E
* BX = Sprite ID in table (0 - 127)
* DL = X coordinate
* DH = Y coordinate
Note that DL/DH are swapped relative to the order in which the sprite coordinate bytes are stored in memory.
=== INT $12/AH=$0F - sprite_get_location ===
* AH = $0F
* BX = Sprite ID in table (0 - 127)
Return:
* AL = X coordinate
* AH = Y coordinate
=== INT $12/AH=$10 - sprite_set_char_location ===
* AH = $10
* BX = Sprite ID in table (0 - 127)
* CX = Sprite attribute
* DL = X coordinate
* DH = Y coordinate
=== INT $12/AH=$11 - sprite_get_char_location ===
* AH = $11
* BX = Sprite ID in table (0 - 127)
Return:
* AX = Sprite attribute
* DL = X coordinate
* DH = Y coordinate
=== INT $12/AH=$12 - sprite_set_data ===
* AH = $12
* BX = Initial sprite ID in table (0 - 127)
* CX = Sprite count
* DS:DX = Input data buffer (<code>4 x Sprite count</code> bytes)
Note that, unlike per-sprite calls (sprite_set_location, etc.), each sprite's coordinates follow the hardware layout in memory: that is, the third byte is the Y coordinate, while the fourth byte is the X coordinate.
=== INT $12/AH=$13 - screen_set_scroll ===
* AH = $13
* AL = Screen (0, 1)
* BL = [[Display#Screen Scroll|Screen Scroll X]] value
* BH = [[Display#Screen Scroll|Screen Scroll Y]] value
=== INT $12/AH=$14 - screen_get_scroll ===
* AH = $14
* AL = Screen (0, 1)
Return:
* AL = [[Display#Screen Scroll|Screen Scroll X]] value
* AH = [[Display#Screen Scroll|Screen Scroll Y]] value
=== INT $12/AH=$15 - screen2_set_window ===
* AH = $15
* BL = [[Display#Screen 2 Window|Screen 2 Window Left]] value
* BH = [[Display#Screen 2 Window|Screen 2 Window Top]] value
* CL = Window width
* CH = Window height
=== INT $12/AH=$16 - screen2_get_window ===
* AH = $16
Return:
* AL = [[Display#Screen 2 Window|Screen 2 Window Left]] value
* AH = [[Display#Screen 2 Window|Screen 2 Window Top]] value
* DL = Window width
* DH = Window height
=== INT $12/AH=$17 - sprite_set_window ===
* AH = $17
* BL = [[Display#Sprite Window|Sprite Window Left]] value
* BH = [[Display#Sprite Window|Sprite Window Top]] value
* CL = Window width
* CH = Window height
=== INT $12/AH=$18 - sprite_get_window ===
* AH = $18
Return:
* AL = [[Display#Sprite Window|Sprite Window Left]] value
* AH = [[Display#Sprite Window|Sprite Window Top]] value
* DL = Window width
* DH = Window height
=== INT $12/AH=$19 - palette_set_color ===
* AH = $19
* BX = Palette index (0 - 15)
* CX = [[Display#LCD Mono Palette|LCD Mono Palette]] value
=== INT $12/AH=$1A - palette_get_color ===
* AH = $1A
* BX = Palette index (0 - 15)
Return:
* AX = [[Display#LCD Mono Palette|LCD Mono Palette]] value
=== INT $12/AH=$1B - lcd_set_color ===
* AH = $1B
* CX:BX = [[Display#LCD Mono Shade LUT|LCD Mono Shade LUT]] value
=== INT $12/AH=$1C - lcd_get_color ===
* AH = $1C
Return:
* DX:AX = [[Display#LCD Mono Shade LUT|LCD Mono Shade LUT]] value
=== INT $12/AH=$1D - lcd_set_segments ===
* AH = $1D
* BX = [[Display#LCD Icon Control|LCD Icon Control]] value
=== INT $12/AH=$1E - lcd_get_segments ===
* AH = $1E
Return:
* AX = [[Display#LCD Icon Control|LCD Icon Control]] value
=== INT $12/AH=$1F - lcd_set_sleep ===
=== INT $12/AH=$20 - lcd_get_sleep ===
=== INT $12/AH=$21 - screen_set_vram ===
* AH = $21
* AL = Screen (0, 1)
* BL = Internal RAM address, shifted right by 11
Note: This function is undocumented.
=== INT $12/AH=$22 - sprite_set_vram ===
* AH = $22
* BL = Internal RAM address, shifted right by 9
Note: This function is undocumented.
37a6c303b93197fe5f40581d452e3e84bfed9469
WonderWitch/Flash
0
67
482
404
2025-01-01T17:36:52Z
Asie
351
/* Sector layout */ validate sector protection settings on WW cart
wikitext
text/x-wiki
The WonderWitch cartridge features a 512KiB flash chip - the MBM29DL400TC. While the WonderSwan SoC pervents writes to the ROM area, it can be written to via the SRAM area using port $CE on the [[Bandai 2003]] mapper.
== Sector layout ==
{| class="wikitable"
! Bank
! Start
! End
! Size
! Protected
|-
| rowspan="6" style="text-align: center;" | 2
| $00000
| $0FFFF
| 64 KB
| rowspan="10" style="text-align: center;" | No
|-
| $10000
| $1FFFF
| 64 KB
|-
| $20000
| $2FFFF
| 64 KB
|-
| $30000
| $3FFFF
| 64 KB
|-
| $40000
| $4FFFF
| 64 KB
|-
| $50000
| $5FFFF
| 64 KB
|-
| rowspan="8" style="text-align: center;" | 1
| $60000
| $63FFF
| 16 KB
|-
| $64000
| $6BFFF
| 32 KB
|-
| $6C000
| $6DFFF
| 8 KB
|-
| $6E000
| $6FFFF
| 8 KB
|-
| $70000
| $71FFF
| 8 KB
| rowspan="4" style="text-align: center;" | Yes
|-
| $72000
| $73FFF
| 8 KB
|-
| $74000
| $7BFFF
| 32 KB
|-
| $7C000
| $7FFFF
| 16 KB
|}
Note that the MBM29DL400TC allows operating simultaneously in two banks: the first 384 KB can be programmed or erased while the last 128 KB remains readable, and vice versa.
== Commands ==
TODO
== Links ==
* [https://github.com/up-n-atom/WonderWitch/blob/main/Datasheets/MBM29DL400BC-12PFTN_to_MBM29DL400TC-90PFTN.pdf Datasheet]
ea9d2c33a29744c03c16b73afac63a66a9499b62
WSdev Wiki
0
1
483
399
2025-01-19T12:21:35Z
Asie
351
/* Cartridge components */
wikitext
text/x-wiki
'''WonderSwan Development Wiki'''
== Reference ==
=== General ===
* [[Memory map]]
* [[I/O port map]]
* [[ROM header]]
* [[NEC V30MZ]] - the WonderSwan CPU (80186-compatible)
* [[Timing]]
=== Console components ===
* [[SoC]]
** [[Display]]
** [[Sound]]
*** [[Hyper Voice]]<sup>(color)</sup>
** [[Keypad]]
** [[Timers]]
** [[Interrupts]]
** [[UART]]
** [[DMA]]<sup>(color)</sup>
* [[Boot ROM]]
* [[EEPROM|Internal EEPROM]]
** [[Splash animation]]<sup>(color)</sup>
=== Cartridge components ===
* [[Cartridge connector]]
* [[Mapper]]
** [[Bandai 2001]]
** [[Bandai 2003]]
** [[KARNAK]]
* Mapper-specific components
** [[EEPROM]] (2001)
** [[Real-Time Clock]] (2003)
* Cartridge-specific components
** [[WonderWitch/Flash|WonderWitch NOR flash]]
** [[Handy Sonar]]
** [[mama Mitte]]
=== Pinouts ===
* [[Cartridge connector#Pinout|Cartridge pinout]]
* [[Accessory port pinout]]
* [[2001 Mapper pinout]]
* [[2003 Mapper pinout]]
* [[KARNAK pinout]]
* [[GIZA pinout]]
* [[S-3511A pinout]]
=== Accessories ===
* [[WonderBeat 9480]] headphone adapter
* [[WonderBorg]] robot
* [[WonderGate]] mobile adapter
* [[WonderWave]] infrared adapter
=== WonderWitch ===
* [[WonderWitch]]
** [[WonderWitch/Flash|NOR flash]]
** [[WonderWitch/Memory map|Memory map]]
** [[WonderWitch/FreyaBIOS|FreyaBIOS]]
** [[WonderWitch/FreyaOS|FreyaOS]]
** [[WonderWitch/Filesystem|File system]]
** [[WonderWitch/Process|Process]]
** [[WonderWitch/IL|Indirect Library (IL)]]
** [[WonderWitch .fx files|.fx file format]]
== Links ==
* [https://wonderful.asie.pl/wiki/doku.php?id=wswan:index#guides Wonderful Toolchain Wiki] - gcc-ia16-based homebrew toolchain guides and documentation
* [https://github.com/WonderfulToolchain/awesome-wsdev awesome-wsdev] - curated documentation/tools/source code link list
== MediaWiki ==
* [https://www.mediawiki.org/wiki/Special:MyLanguage/Help:Contents User's Guide]
* [https://www.mediawiki.org/wiki/Special:MyLanguage/Manual:FAQ MediaWiki FAQ]
* [[:Category:Deletion requests|Deletion requests]]
38d0186907d622ff3c7c007501e81965a73db811
484
483
2025-01-19T12:22:23Z
Asie
351
/* Cartridge components */
wikitext
text/x-wiki
'''WonderSwan Development Wiki'''
== Reference ==
=== General ===
* [[Memory map]]
* [[I/O port map]]
* [[ROM header]]
* [[NEC V30MZ]] - the WonderSwan CPU (80186-compatible)
* [[Timing]]
=== Console components ===
* [[SoC]]
** [[Display]]
** [[Sound]]
*** [[Hyper Voice]]<sup>(color)</sup>
** [[Keypad]]
** [[Timers]]
** [[Interrupts]]
** [[UART]]
** [[DMA]]<sup>(color)</sup>
* [[Boot ROM]]
* [[EEPROM|Internal EEPROM]]
** [[Splash animation]]<sup>(color)</sup>
=== Cartridge components ===
* [[Cartridge connector]]
* [[Mapper]]
** [[Bandai 2001]]
** [[Bandai 2003]]
** [[KARNAK]]
* Mapper-specific components
** [[EEPROM]] (2001)
** [[Real-Time Clock]] (2003)
* Cartridge-specific components
** [[WonderWitch/Flash|WonderWitch NOR flash]]
** [[Handy Sonar]]
** [[mama Mitte]] (IR transceiver)
** [[Robot Works]] (IR transmitter)
=== Pinouts ===
* [[Cartridge connector#Pinout|Cartridge pinout]]
* [[Accessory port pinout]]
* [[2001 Mapper pinout]]
* [[2003 Mapper pinout]]
* [[KARNAK pinout]]
* [[GIZA pinout]]
* [[S-3511A pinout]]
=== Accessories ===
* [[WonderBeat 9480]] headphone adapter
* [[WonderBorg]] robot
* [[WonderGate]] mobile adapter
* [[WonderWave]] infrared adapter
=== WonderWitch ===
* [[WonderWitch]]
** [[WonderWitch/Flash|NOR flash]]
** [[WonderWitch/Memory map|Memory map]]
** [[WonderWitch/FreyaBIOS|FreyaBIOS]]
** [[WonderWitch/FreyaOS|FreyaOS]]
** [[WonderWitch/Filesystem|File system]]
** [[WonderWitch/Process|Process]]
** [[WonderWitch/IL|Indirect Library (IL)]]
** [[WonderWitch .fx files|.fx file format]]
== Links ==
* [https://wonderful.asie.pl/wiki/doku.php?id=wswan:index#guides Wonderful Toolchain Wiki] - gcc-ia16-based homebrew toolchain guides and documentation
* [https://github.com/WonderfulToolchain/awesome-wsdev awesome-wsdev] - curated documentation/tools/source code link list
== MediaWiki ==
* [https://www.mediawiki.org/wiki/Special:MyLanguage/Help:Contents User's Guide]
* [https://www.mediawiki.org/wiki/Special:MyLanguage/Manual:FAQ MediaWiki FAQ]
* [[:Category:Deletion requests|Deletion requests]]
c9184e5c98f16b75f2e19a7393e35393f66c87d1
Display
0
26
485
431
2025-01-21T14:32:39Z
Lidnariq
7
/* Icons */ describe all 13 icons
wikitext
text/x-wiki
The WonderSwan's display functionality generally consists of:
* a 224x144 display clocked at ~75.47 Hz by default, capable of displaying:
** up to sixteen distinct shades of gray
** 12-bit RGB444 color<sup>(color)</sup>
* two 32x32 background layers ("screens"), capable of displaying up to 512 (1024<sup>(color)</sup>) distinct tiles,
* a sprite layer, capable of displaying up to 128 8x8 sprites (up to 32 per line),
* six LCD icons to the bottom or right of the display, usable as additional indicators.
== Components ==
=== Tiles ===
The WonderSwan can display up to 512 distinct tiles at a time, with two bits of palette index information for every pixel.
The WonderSwan Color expands this to 1024 distinct tiles for background (with 512 remaining the limit for sprites), while also introducing modes with four bits of palette index information for every pixel.
==== 2 bits per pixel, planar ====
The tiles are stored in an interleaved planar format, with two bits total for every pixel. Odd bytes store the first plane (bit 0 of each pixel), while even bytes store the second plane (bit 1 of each pixel).
<pre>
tile data (16 bytes)
01 7C 01 FC 00 C0 18 D8 18 D8 00 C0 00 00 C0 00
||
\/
plane 0 plane 1
7 bit 0 7 bit 0 full tile
---- ---- ---- ----
.... ...1 = 01 .222 22.. = 7C .22222.1
.... ...1 = 01 2222 22.. = FC 222222.1
.... .... = 00 22.. .... = C0 22......
...1 1... = 18 22.2 2... = D8 --\ 22.33...
...1 1... = 18 22.2 2... = D8 --/ 22.33...
.... .... = 00 22.. .... = C0 22......
.... .... = 00 .... .... = 00 ........
11.. .... = C0 .... .... = 00 11......
</pre>
This matches the format used by the Game Boy.
==== 4 bits per pixel, planar ====
This mode is stored in a manner similar to the 2 bits per pixel mode, but with an additional two planes for bit 2 and bit 3 of each pixel's palette index, expanding the tile data to 32 bytes.
<pre>
tile data (32 bytes)
54 32 01 00 54 32 F1 00 54 32 01 F0 54 32 F1 F0 04 02 01 00 F8 04 02 01 00 F8 04 02 00 00 F8 04
||
\/
plane 0 plane 1 plane 2 plane 3
7 bit 0 7 bit 0 7 bit 0 7 bit 0 full tile
---- ---- ---- ---- ---- ---- ---- ----
.1.1 .1.. = 54 ..22 ..2. = 32 .... ...4 = 01 .... .... = 00 .123.124
.1.1 .1.. = 54 ..22 ..2. = 32 4444 ...4 = F1 .... .... = 00 4567.124
.1.1 .1.. = 54 ..22 ..2. = 32 .... ...4 = 01 8888 .... = F0 89AB.124
.1.1 .1.. = 54 ..22 ..2. = 32 4444 ...4 = F1 8888 .... = F0 --\ CDEF.124
.... .1.. = 04 .... ..2. = 02 .... ...4 = 01 .... .... = 00 --/ .....124
1111 1... = F8 .... .2.. = 04 .... ..4. = 02 .... ...8 = 01 11111248
.... .... = 00 2222 2... = F8 .... .4.. = 04 .... ..8. = 02 2222248.
.... .... = 00 .... .... = 00 4444 4... = F8 .... .8.. = 04 444448..
</pre>
This format matches the one used by the Sega Master System and Game Gear family of consoles.
==== 4 bits per pixel, packed ====
Unlike the previous two formats, in the packed format each byte stores the complete palette index of two pixels - the high four bits store the left pixel, while the low four bits store the right pixel. Four such bytes make up a row of eight pixels from left to right.
<pre>
tile data (32 bytes)
01 23 01 24 45 67 01 24 89 AB 01 24 CD EF 01 24 00 00 01 24 11 11 12 48 22 22 24 80 44 44 48 00
||
\/
byte 0 1 2 3
bits 7-4 3-0 7-4 3-0 7-4 3-0 7-4 3-0
pixel 0 1 2 3 4 5 6 7 full tile
--- --- --- --- --- --- --- ---
. 1 = 01 2 3 = 23 . 1 = 01 2 4 = 24 .123.124 = 01 23 01 24
4 5 = 45 6 7 = 67 . 1 = 01 2 4 = 24 4567.124 = 45 67 01 24
8 9 = 89 A B = AB . 1 = 01 2 4 = 24 89AB.124 = 89 AB 01 24
C D = CD E F = EF . 1 = 01 2 4 = 24 --\ CDEF.124 = CD EF 01 24
. . = 00 . . = 00 . 1 = 01 2 4 = 24 --/ .....124 = 00 00 01 24
1 1 = 11 1 1 = 11 1 2 = 12 4 8 = 48 11111248 = 11 11 12 48
2 2 = 22 2 2 = 22 2 4 = 24 8 . = 80 2222248. = 22 22 24 80
4 4 = 44 4 4 = 44 4 8 = 48 . . = 00 444448.. = 44 44 48 00
</pre>
This format matches the one used by the Mega Drive console.
=== Palettes ===
The display system provides sixteen different palettes that can be used to color or shade tiles.
* Palettes 0-7 can be used for the two screens only;
* Palettes 8-15 can be used for both screens and sprites.
==== Mono ====
In ''mono'' modes, palettes are stored in I/O ports 0x20 through 0x3F. Each palette contains four three-bit entries, which are pointers into a global, four-bit shade lookup table:
<pre>
Palette Global shade LUT
1 ===========> 2 ==========================> 5
^ (0, 2, 4, 6) ^ (1, 3, 5, 7, 9, 11, 13, 15) ^
| | |
Palette index Value Displayed shade
</pre>
The shade value corresponds to the darkness of the pixel: shade 0 is the brightest, while shade 15 is the darkest.
==== Color ====
In ''color'' modes, palettes are stored as 16-bit words in memory addresses 0xFE00 through 0xFFFF, without additional lookup tables:
<pre>
Address
15 bit 8 7 bit 0
---- ---- ---- ----
1111 111p pppi iii.
| |||| |||
| |||+-+++-- Index in palette (0-15)
+--+++------- Palette number (0-15)
Data
15 bit 8 7 bit 0
---- ---- ---- ----
.... rrrr gggg bbbb
|||| |||| ||||
|||| |||| ++++- Blue (0-15)
|||| ++++------ Green (0-15)
++++------------ Red (0-15)
</pre>
In 2 bits per pixel color modes, palette entries 4 through 15 are not used.
==== Transparency ====
In two bit per pixel modes:
* Palettes 0-3 and 8-11 are ''opaque''. For these, index zero is treated as opaque.
* Palettes 4-7 and 12-15 are ''translucent''. For these, index zero is treated as transparent. This means that the color/shade value set to it is ignored, and only three distinct colors/shades can be used for tiles.
In four bit per pixel modes, all palettes are ''translucent''. Index zero is always treated as transparent, and fifteen different colors/shades can be used for tiles.
=== Background color ===
The background color is displayed if no ''opaque'' pixel from screens or sprites is drawn. This color is set in I/O port ''0x01'':
* In mono modes, it is set to an entry in the shade lookup table (0-7),
* In color modes, it is set to an entry in the color palette (0-255). Note that this allows you to use the first color (color zero) of any palette, which is normally ignored and assumed to be ''transparent''.
=== Screens ===
A screen is a layout of tiles. Each cell in a screen controls one 8x8 tile.
The display system can show two distinct screens simultaneously. It also supports hardware flipping of tiles, both horizontally and vertically.
The size of each screen is fixed at 32x32 cells or 256x256 pixels, while each cell is stored as a two-byte word:
<pre>
Address
15 bit 8 7 bit 0
---- ---- ---- ----
0bbb byyy yyxx xxx.
||| |||| |||| |||
||| |||| ||++-+++-- X coordinate (0-31)
||| |+++--++-------- Y coordinate (0-31)
+++-+--------------- Base address (from I/O port)
Data
15 bit 8 7 bit 0
---- ---- ---- ----
vhbp pppt tttt tttt
|||| |||| |||| ||||
|||| |||+--++++-++++- Tile index (0-511)
|||+-+++------------- Palette (0-15)
||+------------------ Tile bank (0-1) - color only
|+------------------- Horizontal flip
+-------------------- Vertical flip
</pre>
In ''color'' modes, the tile bank selects between tiles 0-511 and 512-1023.
=== Sprites ===
The display system can show up to 128 sprites at once.
Sprites are always drawn in front of Screen 1, but they can be drawn in front of or behind Screen 2.
Sprites are stored in a sprite table in the console's internal RAM. It consists of up to 128 four-byte entries, of which any sequential slice can be displayed:
<pre>
(Byte 1) (Byte 0)
15 bit 8 7 bit 0
---- ---- ---- ----
vhPi pppt tttt tttt
|||| |||| |||| ||||
|||| |||+--++++-++++- Tile index (0-511) - only tile bank 0
|||| +++------------- Palette (0-7) - mapped to screen palettes 8-15
|||+----------------- Window location - 0 = inside, 1 = outside
||+------------------ Priority - 0 = behind Screen 2, 1 = in front of Screen 2
|+------------------- Horizontal flip
+-------------------- Vertical flip
(Byte 2)
7 bit 0
---- ----
yyyy yyyy
|||| ||||
++++-++++- Y coordinate
(Byte 3)
7 bit 0
---- ----
xxxx xxxx
|||| ||||
++++-++++- X coordinate
</pre>
There is a sprite limit of 32 per scanline. This means that for each scanline, only the first 32 sprites will be drawn. Note that this includes sprites obscured by windows or outside of visible X coordinates; this list is determined solely by the Y coordinate. Between sprites themselves, earlier sprites in the list are always drawn on top of later sprites in the list.
The sprite table is copied from the console's RAM to a SoC-internal buffer every frame on line <tt>144</tt>; one word for every clock of the line, totaling 256 words (512 bytes) for 256 clocks. This internal buffer is then used for reading sprite data on the next frame.
=== Visibility priority ===
For display components, the visibility priority is as follows:
* Sprite 0, high priority
* Sprite 127, high priority
* Screen 2
* Sprite 0, low priority
* Sprite 127, low priority
* Screen 1
* Background color
=== Windows ===
Screen 2 and sprites can optionally have their drawing restricted within or outside of their specific rectangular windows.
Note that for sprites, the window is enabled globally (for all sprites), but each sprite can individually decide if it's rendered inside or outside of it.
=== Icons ===
The WonderSwan features thirteen fixed LCD segments which are displayed to the right<sup>(color)</sup> or below<sup>(mono)</sup> the main display. These are:
* [[#LCD_Icon_Control_($15)|Six under control of software]]
** Large circle
** Medium circle
** Small circle
** Horizontal orientation
** Vertical orientation
** (Shooting) Star (Sleep)
* [[#LCD_Status_($1A)|Four software can query]]
** Speaker
** Volume A (small wave<sup>(mono)</sup>, center wave<sup>(color)</sup>)
** Volume B (big wave<sup>(mono)</sup>, outside two waves<sup>(color)</sup>)
** Headphones
* [[Interrupts#Interrupt_NMI_Control_($B7)|One that the software can infer]]
** Low battery
* Two that are entirely invisible to software
** Power on ("Egg", resembles the mono power switch)
** Cartridge
== Interrupts ==
The display circuit generates two interrupts of its own:
* Display Interrupt Line Match - when <code>Display Current Line</code> == <code>Display Interrupt Line</code>, at the beginning of said line.
* Display Vertical Blank - when <code>Display Current Line</code> == <code>144</code>, at the beginning of said line.
It also provides a timing source for the two Horizontal and Vertical Blank [[Timers]], which provide their own respective interrupts.
== I/O ports ==
{{Anchor|Display Control}}
=== Display Control ($00) ===
<pre>
7 bit 0
---- ----
..wo Ws21
|| ||||
|| |||+- Enable Screen 1 layer
|| ||+-- Enable Screen 2 layer
|| |+--- Enable Sprite layer
|| +---- Enable Sprite window
|+------ Screen 2 tiles are drawn (if window enabled):
| 0 = inside window,
| 1 = outside window.
+------- Enable Screen 2 window
</pre>
{{Anchor|Display Background}}
=== Display Background Color ($01) ===
<pre>
(mono) (color)
7 bit 0 7 bit 0
---- ---- ---- ----
.... .sss pppp iiii
||| |||| ||||
+++- Value |||| ++++- Index in palette (0-15)
(0-7) ++++------ Color palette (0-15)
</pre>
{{Anchor|Display Current Line}}
=== Display Current Line ($02 read) ===
The current line being drawn by the display.
Note that lines are sent to the display with a one-line delay. This matters for color palette or shade LUT manipulation; changing these values when <code>current line == 1</code> will actually affect line 0.
{{Anchor|Display Interrupt Line}}
=== Display Interrupt Line ($03) ===
The line to emit an interrupt on.
{{Anchor|Sprite Table Address}}
=== Sprite Table Address ($04) ===
<pre>
7 bit 0
---- ----
..Aa aaaa
|| ||||
|+-++++- Address (bits 9-13)
+------- Address (bit 14) - color only
</pre>
{{Anchor|Sprite Table First}}
=== Sprite Table First ($05) ===
<pre>
7 bit 0
---- ----
.iii iiii
||| ||||
+++-++++- Index of first sprite entry to draw (0-127)
</pre>
{{Anchor|Sprite Table Count}}
=== Sprite Table Count ($06) ===
<pre>
7 bit 0
---- ----
cccc cccc
|||| ||||
++++-++++- Count of sprite entries to draw (1-128)
</pre>
{{Anchor|Screen Address}}
=== Screen Address ($07) ===
<pre>
7 bit 0
---- ----
2222 1111
|||| ||||
|||| |+++- Screen 1 address (bits 11-13)
|||| +---- Screen 1 address (bit 14) - color only
|+++------ Screen 2 address (bits 11-13)
+--------- Screen 2 address (bit 14) - color only
</pre>
{{Anchor|Screen 2 Window}}
=== Screen 2 Window Left ($08) ===
=== Screen 2 Window Top ($09) ===
=== Screen 2 Window Right ($0A) ===
=== Screen 2 Window Bottom ($0B) ===
The X and Y coordinates of the Screen 2 window.
Note that all coordinates are inclusive; for example, for a 200x100 window in the top-left corner, the values should be set as follows:
* Left - 0,
* Top - 0,
* Right - 199,
* Bottom - 99.
{{Anchor|Sprite Window}}
=== Sprite Window Left ($0C) ===
=== Sprite Window Top ($0D) ===
=== Sprite Window Right ($0E) ===
=== Sprite Window Bottom ($0F) ===
The X and Y coordinates of the Sprite window.
Note that all coordinates are inclusive.
{{Anchor|Screen Scroll}}
=== Screen 1 Scroll X ($10) ===
=== Screen 1 Scroll Y ($11) ===
The X and Y coordinates that Screen 1 is scrolled by.
For example, setting Scroll X to 24 and Scroll Y to 8 will omit, in 8x8 tile units, the first three rows and the first two columns of the 32x32 screen.
=== Screen 2 Scroll X ($12) ===
=== Screen 2 Scroll Y ($13) ===
The X and Y coordinates that Screen 2 is scrolled by.
{{Anchor|LCD Control}}
=== LCD Control ($14) ===
<pre>
7 bit 0
---- ----
.... ..Ce
||
|+- LCD enable: 0 = sleep, 1 = enabled
+-- Contrast (WSC): 0 = low, 1 = high
</pre>
The enable bit controls whether or not the LCD screen is displaying graphics; if sleeping, it displays nothing (all white). Note that segments continue displaying regardless of this configuration.
Note that port $1A provides a separate LCD sleep bit; the display will be disabled in the same way if any of those bits are set to "sleep".
The contrast bit allows enabling a "high contrast" mode: this works by having the LCD drive two lines with data received from the SoC - so the first line of the LCD is driven by the first line from the SoC, then additionally by the second line from the SoC.
{{Anchor|LCD Icon Control}}
=== LCD Icon Control ($15) ===
<pre>
7 bit 0
---- ----
..32 1hvs
|| ||||
|| |||+- Sleep
|| ||+-- Vertical orientation
|| |+--- Horizontal orientation
|| +---- Aux 1 (Small circle)
|+------ Aux 2 (Medium circle)
+------- Aux 3 (Large circle)
</pre>
{{Anchor|LCD Mono Shade LUT}}
=== LCD Mono Shade LUT ($1C-$1F) ===
<pre>
$1C $1D $1E $1F
7 bit 0 7 bit 0 7 bit 0 7 bit 0
---- ---- ---- ---- ---- ---- ---- ----
1111 0000 3333 2222 5555 4444 7777 6666
</pre>
{{Anchor|LCD Mono Palette}}
=== LCD Mono Palette 0..15 ($20, $21 .. $3E, $3F) ===
The monochrome palette is laid out as sixteen words:
<pre>
N+1 N
15 bit 8 7 bit 0
---- ---- ---- ----
.333 .222 .111 .000
||| ||| ||| |||
||| ||| ||| +++- Shade LUT index for color 0
||| ||| +++------ Shade LUT index for color 1
||| +++------------ Shade LUT index for color 2
+++----------------- Shade LUT index for color 3
</pre>
== Internal I/O ports ==
These I/O ports are said to be internal and not intended for use by commercial games.
{{Anchor|LCD Final Line}}
=== LCD Final Line ($16) ===
The final line preceding line counter restart and the beginning of active display. By default, this is set to 158, which equals 159 total lines per frame.
It is said setting this register to an odd value on SwanCrystal has an adverse effect to the LCD panel,<ref>[http://daifukkat.su/docs/wsman/#REG_LCD_VTOTAL REG_LCD_VTOTAL - WSMan]</ref> but the exact mechanism is unknown. A starting point for research is that an even value, or odd total line count, is needed to balance positive and negative charges on the LCD.<ref>W.A. Steer. "[http://www.techmind.org/lcd/ LCD monitor technology and tests]". Techmind, 2011-12-03. Accessed 2024-11-19.</ref>
{{Anchor|LCD Back Porch Line}}
=== LCD Back Porch Line ($17, WSC only) ===
This port is available on the WonderSwan Color only - not the SwanCrystal!
The final line preceding the vertical back porch; by default, this should be set to 155.
The vertical back porch of the LCD is assumed to be 4 lines by some hardware, including IPS mods, as well as the official "TV Swan" capture device. Given that the first visible line is sent to the LCD on the display's line 1, this should be generally set to <code>LCD Final Line - 3</code>.
Conversely, it is said moving this value closer to vertical blank improves LCD visibility<ref>[http://daifukkat.su/docs/wsman/#REG_LCD_VSYNC REG_LCD_VSYNC - WSMan]</ref>, but the exact mechanism is unknown.
{{Anchor|LCD Status}}
=== LCD Status ($1A) ===
<pre>
7 bit 0
---- ----
...v vvhs
| ||||
| |||+- LCD sleep: 0 = no, 1 = sleep
| ||+-- Headphone segment
| ||
| || Volume segments:
| |+--- - Volume B (medium, high)
| +---- - Volume A (low, high)
+------ - Speaker
</pre>
The LCD sleep bit is writable. The remaining bits are read-only.
The volume and headphone segments are enabled when pressing the SOUND button, according to this algorithm:
* If headphones are plugged in, enable the Headphone segment.
* If headphones are not plugged in, enable the Speaker segment and the following Volume segments:
** Volume level 0: None
** Volume level 1: A
** Volume level 2: B
** Volume level 3: A, B
* Hide all visible segments after 128 frames from the last press.
TODO: This documents the WonderSwan Color. The specifics probably work differently on the mono WonderSwan.
=== TFT LCD Configuration ($70, $71, $72, $73, $74, $75, $76, $77 SwanCrystal only) ===
These eight bytes are read from internal EEPROM and configure unknown aspects of the console's TFT LCD panel.
They are only writable while the [[Boot ROM]] is unlocked - locking has the side effect of making them read-only.
== Notes ==
<references />
6a820be0cfa04404055c2db81678b51f21a2ae26
486
485
2025-01-21T16:04:24Z
Asie
351
segment -> icon
wikitext
text/x-wiki
The WonderSwan's display functionality generally consists of:
* a 224x144 display clocked at ~75.47 Hz by default, capable of displaying:
** up to sixteen distinct shades of gray
** 12-bit RGB444 color<sup>(color)</sup>
* two 32x32 background layers ("screens"), capable of displaying up to 512 (1024<sup>(color)</sup>) distinct tiles,
* a sprite layer, capable of displaying up to 128 8x8 sprites (up to 32 per line),
* six LCD icons to the bottom or right of the display, usable as additional indicators.
== Components ==
=== Tiles ===
The WonderSwan can display up to 512 distinct tiles at a time, with two bits of palette index information for every pixel.
The WonderSwan Color expands this to 1024 distinct tiles for background (with 512 remaining the limit for sprites), while also introducing modes with four bits of palette index information for every pixel.
==== 2 bits per pixel, planar ====
The tiles are stored in an interleaved planar format, with two bits total for every pixel. Odd bytes store the first plane (bit 0 of each pixel), while even bytes store the second plane (bit 1 of each pixel).
<pre>
tile data (16 bytes)
01 7C 01 FC 00 C0 18 D8 18 D8 00 C0 00 00 C0 00
||
\/
plane 0 plane 1
7 bit 0 7 bit 0 full tile
---- ---- ---- ----
.... ...1 = 01 .222 22.. = 7C .22222.1
.... ...1 = 01 2222 22.. = FC 222222.1
.... .... = 00 22.. .... = C0 22......
...1 1... = 18 22.2 2... = D8 --\ 22.33...
...1 1... = 18 22.2 2... = D8 --/ 22.33...
.... .... = 00 22.. .... = C0 22......
.... .... = 00 .... .... = 00 ........
11.. .... = C0 .... .... = 00 11......
</pre>
This matches the format used by the Game Boy.
==== 4 bits per pixel, planar ====
This mode is stored in a manner similar to the 2 bits per pixel mode, but with an additional two planes for bit 2 and bit 3 of each pixel's palette index, expanding the tile data to 32 bytes.
<pre>
tile data (32 bytes)
54 32 01 00 54 32 F1 00 54 32 01 F0 54 32 F1 F0 04 02 01 00 F8 04 02 01 00 F8 04 02 00 00 F8 04
||
\/
plane 0 plane 1 plane 2 plane 3
7 bit 0 7 bit 0 7 bit 0 7 bit 0 full tile
---- ---- ---- ---- ---- ---- ---- ----
.1.1 .1.. = 54 ..22 ..2. = 32 .... ...4 = 01 .... .... = 00 .123.124
.1.1 .1.. = 54 ..22 ..2. = 32 4444 ...4 = F1 .... .... = 00 4567.124
.1.1 .1.. = 54 ..22 ..2. = 32 .... ...4 = 01 8888 .... = F0 89AB.124
.1.1 .1.. = 54 ..22 ..2. = 32 4444 ...4 = F1 8888 .... = F0 --\ CDEF.124
.... .1.. = 04 .... ..2. = 02 .... ...4 = 01 .... .... = 00 --/ .....124
1111 1... = F8 .... .2.. = 04 .... ..4. = 02 .... ...8 = 01 11111248
.... .... = 00 2222 2... = F8 .... .4.. = 04 .... ..8. = 02 2222248.
.... .... = 00 .... .... = 00 4444 4... = F8 .... .8.. = 04 444448..
</pre>
This format matches the one used by the Sega Master System and Game Gear family of consoles.
==== 4 bits per pixel, packed ====
Unlike the previous two formats, in the packed format each byte stores the complete palette index of two pixels - the high four bits store the left pixel, while the low four bits store the right pixel. Four such bytes make up a row of eight pixels from left to right.
<pre>
tile data (32 bytes)
01 23 01 24 45 67 01 24 89 AB 01 24 CD EF 01 24 00 00 01 24 11 11 12 48 22 22 24 80 44 44 48 00
||
\/
byte 0 1 2 3
bits 7-4 3-0 7-4 3-0 7-4 3-0 7-4 3-0
pixel 0 1 2 3 4 5 6 7 full tile
--- --- --- --- --- --- --- ---
. 1 = 01 2 3 = 23 . 1 = 01 2 4 = 24 .123.124 = 01 23 01 24
4 5 = 45 6 7 = 67 . 1 = 01 2 4 = 24 4567.124 = 45 67 01 24
8 9 = 89 A B = AB . 1 = 01 2 4 = 24 89AB.124 = 89 AB 01 24
C D = CD E F = EF . 1 = 01 2 4 = 24 --\ CDEF.124 = CD EF 01 24
. . = 00 . . = 00 . 1 = 01 2 4 = 24 --/ .....124 = 00 00 01 24
1 1 = 11 1 1 = 11 1 2 = 12 4 8 = 48 11111248 = 11 11 12 48
2 2 = 22 2 2 = 22 2 4 = 24 8 . = 80 2222248. = 22 22 24 80
4 4 = 44 4 4 = 44 4 8 = 48 . . = 00 444448.. = 44 44 48 00
</pre>
This format matches the one used by the Mega Drive console.
=== Palettes ===
The display system provides sixteen different palettes that can be used to color or shade tiles.
* Palettes 0-7 can be used for the two screens only;
* Palettes 8-15 can be used for both screens and sprites.
==== Mono ====
In ''mono'' modes, palettes are stored in I/O ports 0x20 through 0x3F. Each palette contains four three-bit entries, which are pointers into a global, four-bit shade lookup table:
<pre>
Palette Global shade LUT
1 ===========> 2 ==========================> 5
^ (0, 2, 4, 6) ^ (1, 3, 5, 7, 9, 11, 13, 15) ^
| | |
Palette index Value Displayed shade
</pre>
The shade value corresponds to the darkness of the pixel: shade 0 is the brightest, while shade 15 is the darkest.
==== Color ====
In ''color'' modes, palettes are stored as 16-bit words in memory addresses 0xFE00 through 0xFFFF, without additional lookup tables:
<pre>
Address
15 bit 8 7 bit 0
---- ---- ---- ----
1111 111p pppi iii.
| |||| |||
| |||+-+++-- Index in palette (0-15)
+--+++------- Palette number (0-15)
Data
15 bit 8 7 bit 0
---- ---- ---- ----
.... rrrr gggg bbbb
|||| |||| ||||
|||| |||| ++++- Blue (0-15)
|||| ++++------ Green (0-15)
++++------------ Red (0-15)
</pre>
In 2 bits per pixel color modes, palette entries 4 through 15 are not used.
==== Transparency ====
In two bit per pixel modes:
* Palettes 0-3 and 8-11 are ''opaque''. For these, index zero is treated as opaque.
* Palettes 4-7 and 12-15 are ''translucent''. For these, index zero is treated as transparent. This means that the color/shade value set to it is ignored, and only three distinct colors/shades can be used for tiles.
In four bit per pixel modes, all palettes are ''translucent''. Index zero is always treated as transparent, and fifteen different colors/shades can be used for tiles.
=== Background color ===
The background color is displayed if no ''opaque'' pixel from screens or sprites is drawn. This color is set in I/O port ''0x01'':
* In mono modes, it is set to an entry in the shade lookup table (0-7),
* In color modes, it is set to an entry in the color palette (0-255). Note that this allows you to use the first color (color zero) of any palette, which is normally ignored and assumed to be ''transparent''.
=== Screens ===
A screen is a layout of tiles. Each cell in a screen controls one 8x8 tile.
The display system can show two distinct screens simultaneously. It also supports hardware flipping of tiles, both horizontally and vertically.
The size of each screen is fixed at 32x32 cells or 256x256 pixels, while each cell is stored as a two-byte word:
<pre>
Address
15 bit 8 7 bit 0
---- ---- ---- ----
0bbb byyy yyxx xxx.
||| |||| |||| |||
||| |||| ||++-+++-- X coordinate (0-31)
||| |+++--++-------- Y coordinate (0-31)
+++-+--------------- Base address (from I/O port)
Data
15 bit 8 7 bit 0
---- ---- ---- ----
vhbp pppt tttt tttt
|||| |||| |||| ||||
|||| |||+--++++-++++- Tile index (0-511)
|||+-+++------------- Palette (0-15)
||+------------------ Tile bank (0-1) - color only
|+------------------- Horizontal flip
+-------------------- Vertical flip
</pre>
In ''color'' modes, the tile bank selects between tiles 0-511 and 512-1023.
=== Sprites ===
The display system can show up to 128 sprites at once.
Sprites are always drawn in front of Screen 1, but they can be drawn in front of or behind Screen 2.
Sprites are stored in a sprite table in the console's internal RAM. It consists of up to 128 four-byte entries, of which any sequential slice can be displayed:
<pre>
(Byte 1) (Byte 0)
15 bit 8 7 bit 0
---- ---- ---- ----
vhPi pppt tttt tttt
|||| |||| |||| ||||
|||| |||+--++++-++++- Tile index (0-511) - only tile bank 0
|||| +++------------- Palette (0-7) - mapped to screen palettes 8-15
|||+----------------- Window location - 0 = inside, 1 = outside
||+------------------ Priority - 0 = behind Screen 2, 1 = in front of Screen 2
|+------------------- Horizontal flip
+-------------------- Vertical flip
(Byte 2)
7 bit 0
---- ----
yyyy yyyy
|||| ||||
++++-++++- Y coordinate
(Byte 3)
7 bit 0
---- ----
xxxx xxxx
|||| ||||
++++-++++- X coordinate
</pre>
There is a sprite limit of 32 per scanline. This means that for each scanline, only the first 32 sprites will be drawn. Note that this includes sprites obscured by windows or outside of visible X coordinates; this list is determined solely by the Y coordinate. Between sprites themselves, earlier sprites in the list are always drawn on top of later sprites in the list.
The sprite table is copied from the console's RAM to a SoC-internal buffer every frame on line <tt>144</tt>; one word for every clock of the line, totaling 256 words (512 bytes) for 256 clocks. This internal buffer is then used for reading sprite data on the next frame.
=== Visibility priority ===
For display components, the visibility priority is as follows:
* Sprite 0, high priority
* Sprite 127, high priority
* Screen 2
* Sprite 0, low priority
* Sprite 127, low priority
* Screen 1
* Background color
=== Windows ===
Screen 2 and sprites can optionally have their drawing restricted within or outside of their specific rectangular windows.
Note that for sprites, the window is enabled globally (for all sprites), but each sprite can individually decide if it's rendered inside or outside of it.
=== Icons ===
The WonderSwan features thirteen fixed LCD segments which are displayed to the right<sup>(color)</sup> or below<sup>(mono)</sup> the main display. These are:
* [[#LCD_Icon_Control_($15)|Six under control of software]]
** Large circle
** Medium circle
** Small circle
** Horizontal orientation
** Vertical orientation
** (Shooting) Star (Sleep)
* [[#LCD_Status_($1A)|Four software can query]]
** Speaker
** Volume A (small wave<sup>(mono)</sup>, center wave<sup>(color)</sup>)
** Volume B (big wave<sup>(mono)</sup>, outside two waves<sup>(color)</sup>)
** Headphones
* [[Interrupts#Interrupt_NMI_Control_($B7)|One that the software can infer]]
** Low battery
* Two that are entirely invisible to software
** Power on ("Egg", resembles the mono power switch)
** Cartridge
== Interrupts ==
The display circuit generates two interrupts of its own:
* Display Interrupt Line Match - when <code>Display Current Line</code> == <code>Display Interrupt Line</code>, at the beginning of said line.
* Display Vertical Blank - when <code>Display Current Line</code> == <code>144</code>, at the beginning of said line.
It also provides a timing source for the two Horizontal and Vertical Blank [[Timers]], which provide their own respective interrupts.
== I/O ports ==
{{Anchor|Display Control}}
=== Display Control ($00) ===
<pre>
7 bit 0
---- ----
..wo Ws21
|| ||||
|| |||+- Enable Screen 1 layer
|| ||+-- Enable Screen 2 layer
|| |+--- Enable Sprite layer
|| +---- Enable Sprite window
|+------ Screen 2 tiles are drawn (if window enabled):
| 0 = inside window,
| 1 = outside window.
+------- Enable Screen 2 window
</pre>
{{Anchor|Display Background}}
=== Display Background Color ($01) ===
<pre>
(mono) (color)
7 bit 0 7 bit 0
---- ---- ---- ----
.... .sss pppp iiii
||| |||| ||||
+++- Value |||| ++++- Index in palette (0-15)
(0-7) ++++------ Color palette (0-15)
</pre>
{{Anchor|Display Current Line}}
=== Display Current Line ($02 read) ===
The current line being drawn by the display.
Note that lines are sent to the display with a one-line delay. This matters for color palette or shade LUT manipulation; changing these values when <code>current line == 1</code> will actually affect line 0.
{{Anchor|Display Interrupt Line}}
=== Display Interrupt Line ($03) ===
The line to emit an interrupt on.
{{Anchor|Sprite Table Address}}
=== Sprite Table Address ($04) ===
<pre>
7 bit 0
---- ----
..Aa aaaa
|| ||||
|+-++++- Address (bits 9-13)
+------- Address (bit 14) - color only
</pre>
{{Anchor|Sprite Table First}}
=== Sprite Table First ($05) ===
<pre>
7 bit 0
---- ----
.iii iiii
||| ||||
+++-++++- Index of first sprite entry to draw (0-127)
</pre>
{{Anchor|Sprite Table Count}}
=== Sprite Table Count ($06) ===
<pre>
7 bit 0
---- ----
cccc cccc
|||| ||||
++++-++++- Count of sprite entries to draw (1-128)
</pre>
{{Anchor|Screen Address}}
=== Screen Address ($07) ===
<pre>
7 bit 0
---- ----
2222 1111
|||| ||||
|||| |+++- Screen 1 address (bits 11-13)
|||| +---- Screen 1 address (bit 14) - color only
|+++------ Screen 2 address (bits 11-13)
+--------- Screen 2 address (bit 14) - color only
</pre>
{{Anchor|Screen 2 Window}}
=== Screen 2 Window Left ($08) ===
=== Screen 2 Window Top ($09) ===
=== Screen 2 Window Right ($0A) ===
=== Screen 2 Window Bottom ($0B) ===
The X and Y coordinates of the Screen 2 window.
Note that all coordinates are inclusive; for example, for a 200x100 window in the top-left corner, the values should be set as follows:
* Left - 0,
* Top - 0,
* Right - 199,
* Bottom - 99.
{{Anchor|Sprite Window}}
=== Sprite Window Left ($0C) ===
=== Sprite Window Top ($0D) ===
=== Sprite Window Right ($0E) ===
=== Sprite Window Bottom ($0F) ===
The X and Y coordinates of the Sprite window.
Note that all coordinates are inclusive.
{{Anchor|Screen Scroll}}
=== Screen 1 Scroll X ($10) ===
=== Screen 1 Scroll Y ($11) ===
The X and Y coordinates that Screen 1 is scrolled by.
For example, setting Scroll X to 24 and Scroll Y to 8 will omit, in 8x8 tile units, the first three rows and the first two columns of the 32x32 screen.
=== Screen 2 Scroll X ($12) ===
=== Screen 2 Scroll Y ($13) ===
The X and Y coordinates that Screen 2 is scrolled by.
{{Anchor|LCD Control}}
=== LCD Control ($14) ===
<pre>
7 bit 0
---- ----
.... ..Ce
||
|+- LCD enable: 0 = sleep, 1 = enabled
+-- Contrast (WSC): 0 = low, 1 = high
</pre>
The enable bit controls whether or not the LCD screen is displaying graphics; if sleeping, it displays nothing (all white). Note that icon segments continue displaying regardless of this configuration.
Note that port $1A provides a separate LCD sleep bit; the display will be disabled in the same way if any of those bits are set to "sleep".
The contrast bit allows enabling a "high contrast" mode: this works by having the LCD drive two lines with data received from the SoC - so the first line of the LCD is driven by the first line from the SoC, then additionally by the second line from the SoC.
{{Anchor|LCD Icon Control}}
=== LCD Icon Control ($15) ===
<pre>
7 bit 0
---- ----
..32 1hvs
|| ||||
|| |||+- Sleep
|| ||+-- Vertical orientation
|| |+--- Horizontal orientation
|| +---- Aux 1 (Small circle)
|+------ Aux 2 (Medium circle)
+------- Aux 3 (Large circle)
</pre>
{{Anchor|LCD Mono Shade LUT}}
=== LCD Mono Shade LUT ($1C-$1F) ===
<pre>
$1C $1D $1E $1F
7 bit 0 7 bit 0 7 bit 0 7 bit 0
---- ---- ---- ---- ---- ---- ---- ----
1111 0000 3333 2222 5555 4444 7777 6666
</pre>
{{Anchor|LCD Mono Palette}}
=== LCD Mono Palette 0..15 ($20, $21 .. $3E, $3F) ===
The monochrome palette is laid out as sixteen words:
<pre>
N+1 N
15 bit 8 7 bit 0
---- ---- ---- ----
.333 .222 .111 .000
||| ||| ||| |||
||| ||| ||| +++- Shade LUT index for color 0
||| ||| +++------ Shade LUT index for color 1
||| +++------------ Shade LUT index for color 2
+++----------------- Shade LUT index for color 3
</pre>
== Internal I/O ports ==
These I/O ports are said to be internal and not intended for use by commercial games.
{{Anchor|LCD Final Line}}
=== LCD Final Line ($16) ===
The final line preceding line counter restart and the beginning of active display. By default, this is set to 158, which equals 159 total lines per frame.
It is said setting this register to an odd value on SwanCrystal has an adverse effect to the LCD panel,<ref>[http://daifukkat.su/docs/wsman/#REG_LCD_VTOTAL REG_LCD_VTOTAL - WSMan]</ref> but the exact mechanism is unknown. A starting point for research is that an even value, or odd total line count, is needed to balance positive and negative charges on the LCD.<ref>W.A. Steer. "[http://www.techmind.org/lcd/ LCD monitor technology and tests]". Techmind, 2011-12-03. Accessed 2024-11-19.</ref>
{{Anchor|LCD Back Porch Line}}
=== LCD Back Porch Line ($17, WSC only) ===
This port is available on the WonderSwan Color only - not the SwanCrystal!
The final line preceding the vertical back porch; by default, this should be set to 155.
The vertical back porch of the LCD is assumed to be 4 lines by some hardware, including IPS mods, as well as the official "TV Swan" capture device. Given that the first visible line is sent to the LCD on the display's line 1, this should be generally set to <code>LCD Final Line - 3</code>.
Conversely, it is said moving this value closer to vertical blank improves LCD visibility<ref>[http://daifukkat.su/docs/wsman/#REG_LCD_VSYNC REG_LCD_VSYNC - WSMan]</ref>, but the exact mechanism is unknown.
{{Anchor|LCD Status}}
=== LCD Status ($1A) ===
<pre>
7 bit 0
---- ----
...v vvhs
| ||||
| |||+- LCD sleep: 0 = no, 1 = sleep
| ||+-- Headphone icon
| ||
| || Volume icons:
| |+--- - Volume B (medium, high)
| +---- - Volume A (low, high)
+------ - Speaker
</pre>
The LCD sleep bit is writable. The remaining bits are read-only.
The volume and headphone icon are enabled when pressing the SOUND button, according to this algorithm:
* If headphones are plugged in, show the Headphone icon.
* If headphones are not plugged in, show the Speaker icon and the following Volume icons:
** Volume level 0: None
** Volume level 1: A
** Volume level 2: B
** Volume level 3: A, B
* Hide all visible icons after 128 frames from the last press.
TODO: This documents the WonderSwan Color. The specifics probably work differently on the mono WonderSwan.
=== TFT LCD Configuration ($70, $71, $72, $73, $74, $75, $76, $77 SwanCrystal only) ===
These eight bytes are read from internal EEPROM and configure unknown aspects of the console's TFT LCD panel.
They are only writable while the [[Boot ROM]] is unlocked - locking has the side effect of making them read-only.
== Notes ==
<references />
bc52ad31cae4bf25d90a0fc5cd0081a83abedfa4
488
486
2025-01-21T16:05:18Z
Asie
351
/* LCD Icon Control ($15) */ use "Etc" over "Aux" to match official terminology
wikitext
text/x-wiki
The WonderSwan's display functionality generally consists of:
* a 224x144 display clocked at ~75.47 Hz by default, capable of displaying:
** up to sixteen distinct shades of gray
** 12-bit RGB444 color<sup>(color)</sup>
* two 32x32 background layers ("screens"), capable of displaying up to 512 (1024<sup>(color)</sup>) distinct tiles,
* a sprite layer, capable of displaying up to 128 8x8 sprites (up to 32 per line),
* six LCD icons to the bottom or right of the display, usable as additional indicators.
== Components ==
=== Tiles ===
The WonderSwan can display up to 512 distinct tiles at a time, with two bits of palette index information for every pixel.
The WonderSwan Color expands this to 1024 distinct tiles for background (with 512 remaining the limit for sprites), while also introducing modes with four bits of palette index information for every pixel.
==== 2 bits per pixel, planar ====
The tiles are stored in an interleaved planar format, with two bits total for every pixel. Odd bytes store the first plane (bit 0 of each pixel), while even bytes store the second plane (bit 1 of each pixel).
<pre>
tile data (16 bytes)
01 7C 01 FC 00 C0 18 D8 18 D8 00 C0 00 00 C0 00
||
\/
plane 0 plane 1
7 bit 0 7 bit 0 full tile
---- ---- ---- ----
.... ...1 = 01 .222 22.. = 7C .22222.1
.... ...1 = 01 2222 22.. = FC 222222.1
.... .... = 00 22.. .... = C0 22......
...1 1... = 18 22.2 2... = D8 --\ 22.33...
...1 1... = 18 22.2 2... = D8 --/ 22.33...
.... .... = 00 22.. .... = C0 22......
.... .... = 00 .... .... = 00 ........
11.. .... = C0 .... .... = 00 11......
</pre>
This matches the format used by the Game Boy.
==== 4 bits per pixel, planar ====
This mode is stored in a manner similar to the 2 bits per pixel mode, but with an additional two planes for bit 2 and bit 3 of each pixel's palette index, expanding the tile data to 32 bytes.
<pre>
tile data (32 bytes)
54 32 01 00 54 32 F1 00 54 32 01 F0 54 32 F1 F0 04 02 01 00 F8 04 02 01 00 F8 04 02 00 00 F8 04
||
\/
plane 0 plane 1 plane 2 plane 3
7 bit 0 7 bit 0 7 bit 0 7 bit 0 full tile
---- ---- ---- ---- ---- ---- ---- ----
.1.1 .1.. = 54 ..22 ..2. = 32 .... ...4 = 01 .... .... = 00 .123.124
.1.1 .1.. = 54 ..22 ..2. = 32 4444 ...4 = F1 .... .... = 00 4567.124
.1.1 .1.. = 54 ..22 ..2. = 32 .... ...4 = 01 8888 .... = F0 89AB.124
.1.1 .1.. = 54 ..22 ..2. = 32 4444 ...4 = F1 8888 .... = F0 --\ CDEF.124
.... .1.. = 04 .... ..2. = 02 .... ...4 = 01 .... .... = 00 --/ .....124
1111 1... = F8 .... .2.. = 04 .... ..4. = 02 .... ...8 = 01 11111248
.... .... = 00 2222 2... = F8 .... .4.. = 04 .... ..8. = 02 2222248.
.... .... = 00 .... .... = 00 4444 4... = F8 .... .8.. = 04 444448..
</pre>
This format matches the one used by the Sega Master System and Game Gear family of consoles.
==== 4 bits per pixel, packed ====
Unlike the previous two formats, in the packed format each byte stores the complete palette index of two pixels - the high four bits store the left pixel, while the low four bits store the right pixel. Four such bytes make up a row of eight pixels from left to right.
<pre>
tile data (32 bytes)
01 23 01 24 45 67 01 24 89 AB 01 24 CD EF 01 24 00 00 01 24 11 11 12 48 22 22 24 80 44 44 48 00
||
\/
byte 0 1 2 3
bits 7-4 3-0 7-4 3-0 7-4 3-0 7-4 3-0
pixel 0 1 2 3 4 5 6 7 full tile
--- --- --- --- --- --- --- ---
. 1 = 01 2 3 = 23 . 1 = 01 2 4 = 24 .123.124 = 01 23 01 24
4 5 = 45 6 7 = 67 . 1 = 01 2 4 = 24 4567.124 = 45 67 01 24
8 9 = 89 A B = AB . 1 = 01 2 4 = 24 89AB.124 = 89 AB 01 24
C D = CD E F = EF . 1 = 01 2 4 = 24 --\ CDEF.124 = CD EF 01 24
. . = 00 . . = 00 . 1 = 01 2 4 = 24 --/ .....124 = 00 00 01 24
1 1 = 11 1 1 = 11 1 2 = 12 4 8 = 48 11111248 = 11 11 12 48
2 2 = 22 2 2 = 22 2 4 = 24 8 . = 80 2222248. = 22 22 24 80
4 4 = 44 4 4 = 44 4 8 = 48 . . = 00 444448.. = 44 44 48 00
</pre>
This format matches the one used by the Mega Drive console.
=== Palettes ===
The display system provides sixteen different palettes that can be used to color or shade tiles.
* Palettes 0-7 can be used for the two screens only;
* Palettes 8-15 can be used for both screens and sprites.
==== Mono ====
In ''mono'' modes, palettes are stored in I/O ports 0x20 through 0x3F. Each palette contains four three-bit entries, which are pointers into a global, four-bit shade lookup table:
<pre>
Palette Global shade LUT
1 ===========> 2 ==========================> 5
^ (0, 2, 4, 6) ^ (1, 3, 5, 7, 9, 11, 13, 15) ^
| | |
Palette index Value Displayed shade
</pre>
The shade value corresponds to the darkness of the pixel: shade 0 is the brightest, while shade 15 is the darkest.
==== Color ====
In ''color'' modes, palettes are stored as 16-bit words in memory addresses 0xFE00 through 0xFFFF, without additional lookup tables:
<pre>
Address
15 bit 8 7 bit 0
---- ---- ---- ----
1111 111p pppi iii.
| |||| |||
| |||+-+++-- Index in palette (0-15)
+--+++------- Palette number (0-15)
Data
15 bit 8 7 bit 0
---- ---- ---- ----
.... rrrr gggg bbbb
|||| |||| ||||
|||| |||| ++++- Blue (0-15)
|||| ++++------ Green (0-15)
++++------------ Red (0-15)
</pre>
In 2 bits per pixel color modes, palette entries 4 through 15 are not used.
==== Transparency ====
In two bit per pixel modes:
* Palettes 0-3 and 8-11 are ''opaque''. For these, index zero is treated as opaque.
* Palettes 4-7 and 12-15 are ''translucent''. For these, index zero is treated as transparent. This means that the color/shade value set to it is ignored, and only three distinct colors/shades can be used for tiles.
In four bit per pixel modes, all palettes are ''translucent''. Index zero is always treated as transparent, and fifteen different colors/shades can be used for tiles.
=== Background color ===
The background color is displayed if no ''opaque'' pixel from screens or sprites is drawn. This color is set in I/O port ''0x01'':
* In mono modes, it is set to an entry in the shade lookup table (0-7),
* In color modes, it is set to an entry in the color palette (0-255). Note that this allows you to use the first color (color zero) of any palette, which is normally ignored and assumed to be ''transparent''.
=== Screens ===
A screen is a layout of tiles. Each cell in a screen controls one 8x8 tile.
The display system can show two distinct screens simultaneously. It also supports hardware flipping of tiles, both horizontally and vertically.
The size of each screen is fixed at 32x32 cells or 256x256 pixels, while each cell is stored as a two-byte word:
<pre>
Address
15 bit 8 7 bit 0
---- ---- ---- ----
0bbb byyy yyxx xxx.
||| |||| |||| |||
||| |||| ||++-+++-- X coordinate (0-31)
||| |+++--++-------- Y coordinate (0-31)
+++-+--------------- Base address (from I/O port)
Data
15 bit 8 7 bit 0
---- ---- ---- ----
vhbp pppt tttt tttt
|||| |||| |||| ||||
|||| |||+--++++-++++- Tile index (0-511)
|||+-+++------------- Palette (0-15)
||+------------------ Tile bank (0-1) - color only
|+------------------- Horizontal flip
+-------------------- Vertical flip
</pre>
In ''color'' modes, the tile bank selects between tiles 0-511 and 512-1023.
=== Sprites ===
The display system can show up to 128 sprites at once.
Sprites are always drawn in front of Screen 1, but they can be drawn in front of or behind Screen 2.
Sprites are stored in a sprite table in the console's internal RAM. It consists of up to 128 four-byte entries, of which any sequential slice can be displayed:
<pre>
(Byte 1) (Byte 0)
15 bit 8 7 bit 0
---- ---- ---- ----
vhPi pppt tttt tttt
|||| |||| |||| ||||
|||| |||+--++++-++++- Tile index (0-511) - only tile bank 0
|||| +++------------- Palette (0-7) - mapped to screen palettes 8-15
|||+----------------- Window location - 0 = inside, 1 = outside
||+------------------ Priority - 0 = behind Screen 2, 1 = in front of Screen 2
|+------------------- Horizontal flip
+-------------------- Vertical flip
(Byte 2)
7 bit 0
---- ----
yyyy yyyy
|||| ||||
++++-++++- Y coordinate
(Byte 3)
7 bit 0
---- ----
xxxx xxxx
|||| ||||
++++-++++- X coordinate
</pre>
There is a sprite limit of 32 per scanline. This means that for each scanline, only the first 32 sprites will be drawn. Note that this includes sprites obscured by windows or outside of visible X coordinates; this list is determined solely by the Y coordinate. Between sprites themselves, earlier sprites in the list are always drawn on top of later sprites in the list.
The sprite table is copied from the console's RAM to a SoC-internal buffer every frame on line <tt>144</tt>; one word for every clock of the line, totaling 256 words (512 bytes) for 256 clocks. This internal buffer is then used for reading sprite data on the next frame.
=== Visibility priority ===
For display components, the visibility priority is as follows:
* Sprite 0, high priority
* Sprite 127, high priority
* Screen 2
* Sprite 0, low priority
* Sprite 127, low priority
* Screen 1
* Background color
=== Windows ===
Screen 2 and sprites can optionally have their drawing restricted within or outside of their specific rectangular windows.
Note that for sprites, the window is enabled globally (for all sprites), but each sprite can individually decide if it's rendered inside or outside of it.
=== Icons ===
The WonderSwan features thirteen fixed LCD segments which are displayed to the right<sup>(color)</sup> or below<sup>(mono)</sup> the main display. These are:
* [[#LCD_Icon_Control_($15)|Six under control of software]]
** Large circle
** Medium circle
** Small circle
** Horizontal orientation
** Vertical orientation
** (Shooting) Star (Sleep)
* [[#LCD_Status_($1A)|Four software can query]]
** Speaker
** Volume A (small wave<sup>(mono)</sup>, center wave<sup>(color)</sup>)
** Volume B (big wave<sup>(mono)</sup>, outside two waves<sup>(color)</sup>)
** Headphones
* [[Interrupts#Interrupt_NMI_Control_($B7)|One that the software can infer]]
** Low battery
* Two that are entirely invisible to software
** Power on ("Egg", resembles the mono power switch)
** Cartridge
== Interrupts ==
The display circuit generates two interrupts of its own:
* Display Interrupt Line Match - when <code>Display Current Line</code> == <code>Display Interrupt Line</code>, at the beginning of said line.
* Display Vertical Blank - when <code>Display Current Line</code> == <code>144</code>, at the beginning of said line.
It also provides a timing source for the two Horizontal and Vertical Blank [[Timers]], which provide their own respective interrupts.
== I/O ports ==
{{Anchor|Display Control}}
=== Display Control ($00) ===
<pre>
7 bit 0
---- ----
..wo Ws21
|| ||||
|| |||+- Enable Screen 1 layer
|| ||+-- Enable Screen 2 layer
|| |+--- Enable Sprite layer
|| +---- Enable Sprite window
|+------ Screen 2 tiles are drawn (if window enabled):
| 0 = inside window,
| 1 = outside window.
+------- Enable Screen 2 window
</pre>
{{Anchor|Display Background}}
=== Display Background Color ($01) ===
<pre>
(mono) (color)
7 bit 0 7 bit 0
---- ---- ---- ----
.... .sss pppp iiii
||| |||| ||||
+++- Value |||| ++++- Index in palette (0-15)
(0-7) ++++------ Color palette (0-15)
</pre>
{{Anchor|Display Current Line}}
=== Display Current Line ($02 read) ===
The current line being drawn by the display.
Note that lines are sent to the display with a one-line delay. This matters for color palette or shade LUT manipulation; changing these values when <code>current line == 1</code> will actually affect line 0.
{{Anchor|Display Interrupt Line}}
=== Display Interrupt Line ($03) ===
The line to emit an interrupt on.
{{Anchor|Sprite Table Address}}
=== Sprite Table Address ($04) ===
<pre>
7 bit 0
---- ----
..Aa aaaa
|| ||||
|+-++++- Address (bits 9-13)
+------- Address (bit 14) - color only
</pre>
{{Anchor|Sprite Table First}}
=== Sprite Table First ($05) ===
<pre>
7 bit 0
---- ----
.iii iiii
||| ||||
+++-++++- Index of first sprite entry to draw (0-127)
</pre>
{{Anchor|Sprite Table Count}}
=== Sprite Table Count ($06) ===
<pre>
7 bit 0
---- ----
cccc cccc
|||| ||||
++++-++++- Count of sprite entries to draw (1-128)
</pre>
{{Anchor|Screen Address}}
=== Screen Address ($07) ===
<pre>
7 bit 0
---- ----
2222 1111
|||| ||||
|||| |+++- Screen 1 address (bits 11-13)
|||| +---- Screen 1 address (bit 14) - color only
|+++------ Screen 2 address (bits 11-13)
+--------- Screen 2 address (bit 14) - color only
</pre>
{{Anchor|Screen 2 Window}}
=== Screen 2 Window Left ($08) ===
=== Screen 2 Window Top ($09) ===
=== Screen 2 Window Right ($0A) ===
=== Screen 2 Window Bottom ($0B) ===
The X and Y coordinates of the Screen 2 window.
Note that all coordinates are inclusive; for example, for a 200x100 window in the top-left corner, the values should be set as follows:
* Left - 0,
* Top - 0,
* Right - 199,
* Bottom - 99.
{{Anchor|Sprite Window}}
=== Sprite Window Left ($0C) ===
=== Sprite Window Top ($0D) ===
=== Sprite Window Right ($0E) ===
=== Sprite Window Bottom ($0F) ===
The X and Y coordinates of the Sprite window.
Note that all coordinates are inclusive.
{{Anchor|Screen Scroll}}
=== Screen 1 Scroll X ($10) ===
=== Screen 1 Scroll Y ($11) ===
The X and Y coordinates that Screen 1 is scrolled by.
For example, setting Scroll X to 24 and Scroll Y to 8 will omit, in 8x8 tile units, the first three rows and the first two columns of the 32x32 screen.
=== Screen 2 Scroll X ($12) ===
=== Screen 2 Scroll Y ($13) ===
The X and Y coordinates that Screen 2 is scrolled by.
{{Anchor|LCD Control}}
=== LCD Control ($14) ===
<pre>
7 bit 0
---- ----
.... ..Ce
||
|+- LCD enable: 0 = sleep, 1 = enabled
+-- Contrast (WSC): 0 = low, 1 = high
</pre>
The enable bit controls whether or not the LCD screen is displaying graphics; if sleeping, it displays nothing (all white). Note that icon segments continue displaying regardless of this configuration.
Note that port $1A provides a separate LCD sleep bit; the display will be disabled in the same way if any of those bits are set to "sleep".
The contrast bit allows enabling a "high contrast" mode: this works by having the LCD drive two lines with data received from the SoC - so the first line of the LCD is driven by the first line from the SoC, then additionally by the second line from the SoC.
{{Anchor|LCD Icon Control}}
=== LCD Icon Control ($15) ===
<pre>
7 bit 0
---- ----
..32 1hvs
|| ||||
|| |||+- Sleep
|| ||+-- Vertical orientation
|| |+--- Horizontal orientation
|| +---- Etc. 1 (Small circle)
|+------ Etc. 2 (Medium circle)
+------- Etc. 3 (Large circle)
</pre>
{{Anchor|LCD Mono Shade LUT}}
=== LCD Mono Shade LUT ($1C-$1F) ===
<pre>
$1C $1D $1E $1F
7 bit 0 7 bit 0 7 bit 0 7 bit 0
---- ---- ---- ---- ---- ---- ---- ----
1111 0000 3333 2222 5555 4444 7777 6666
</pre>
{{Anchor|LCD Mono Palette}}
=== LCD Mono Palette 0..15 ($20, $21 .. $3E, $3F) ===
The monochrome palette is laid out as sixteen words:
<pre>
N+1 N
15 bit 8 7 bit 0
---- ---- ---- ----
.333 .222 .111 .000
||| ||| ||| |||
||| ||| ||| +++- Shade LUT index for color 0
||| ||| +++------ Shade LUT index for color 1
||| +++------------ Shade LUT index for color 2
+++----------------- Shade LUT index for color 3
</pre>
== Internal I/O ports ==
These I/O ports are said to be internal and not intended for use by commercial games.
{{Anchor|LCD Final Line}}
=== LCD Final Line ($16) ===
The final line preceding line counter restart and the beginning of active display. By default, this is set to 158, which equals 159 total lines per frame.
It is said setting this register to an odd value on SwanCrystal has an adverse effect to the LCD panel,<ref>[http://daifukkat.su/docs/wsman/#REG_LCD_VTOTAL REG_LCD_VTOTAL - WSMan]</ref> but the exact mechanism is unknown. A starting point for research is that an even value, or odd total line count, is needed to balance positive and negative charges on the LCD.<ref>W.A. Steer. "[http://www.techmind.org/lcd/ LCD monitor technology and tests]". Techmind, 2011-12-03. Accessed 2024-11-19.</ref>
{{Anchor|LCD Back Porch Line}}
=== LCD Back Porch Line ($17, WSC only) ===
This port is available on the WonderSwan Color only - not the SwanCrystal!
The final line preceding the vertical back porch; by default, this should be set to 155.
The vertical back porch of the LCD is assumed to be 4 lines by some hardware, including IPS mods, as well as the official "TV Swan" capture device. Given that the first visible line is sent to the LCD on the display's line 1, this should be generally set to <code>LCD Final Line - 3</code>.
Conversely, it is said moving this value closer to vertical blank improves LCD visibility<ref>[http://daifukkat.su/docs/wsman/#REG_LCD_VSYNC REG_LCD_VSYNC - WSMan]</ref>, but the exact mechanism is unknown.
{{Anchor|LCD Status}}
=== LCD Status ($1A) ===
<pre>
7 bit 0
---- ----
...v vvhs
| ||||
| |||+- LCD sleep: 0 = no, 1 = sleep
| ||+-- Headphone icon
| ||
| || Volume icons:
| |+--- - Volume B (medium, high)
| +---- - Volume A (low, high)
+------ - Speaker
</pre>
The LCD sleep bit is writable. The remaining bits are read-only.
The volume and headphone icon are enabled when pressing the SOUND button, according to this algorithm:
* If headphones are plugged in, show the Headphone icon.
* If headphones are not plugged in, show the Speaker icon and the following Volume icons:
** Volume level 0: None
** Volume level 1: A
** Volume level 2: B
** Volume level 3: A, B
* Hide all visible icons after 128 frames from the last press.
TODO: This documents the WonderSwan Color. The specifics probably work differently on the mono WonderSwan.
=== TFT LCD Configuration ($70, $71, $72, $73, $74, $75, $76, $77 SwanCrystal only) ===
These eight bytes are read from internal EEPROM and configure unknown aspects of the console's TFT LCD panel.
They are only writable while the [[Boot ROM]] is unlocked - locking has the side effect of making them read-only.
== Notes ==
<references />
2abf15dfc20106eda1293e546c2fdc1842791e35
490
488
2025-01-21T16:09:33Z
Asie
351
wikitext
text/x-wiki
The WonderSwan's display functionality generally consists of:
* a 224x144 display clocked at ~75.47 Hz by default, capable of displaying:
** up to sixteen distinct shades of gray
** 12-bit RGB444 color<sup>(color)</sup>
* two 32x32 background layers ("screens"), capable of displaying up to 512 (1024<sup>(color)</sup>) distinct tiles,
* a sprite layer, capable of displaying up to 128 8x8 sprites (up to 32 per line),
* a bar of LCD icon segments to the bottom (WS) or right (WSC/SC) of the display, usable as additional indicators.
== Components ==
=== Tiles ===
The WonderSwan can display up to 512 distinct tiles at a time, with two bits of palette index information for every pixel.
The WonderSwan Color expands this to 1024 distinct tiles for background (with 512 remaining the limit for sprites), while also introducing modes with four bits of palette index information for every pixel.
==== 2 bits per pixel, planar ====
The tiles are stored in an interleaved planar format, with two bits total for every pixel. Odd bytes store the first plane (bit 0 of each pixel), while even bytes store the second plane (bit 1 of each pixel).
<pre>
tile data (16 bytes)
01 7C 01 FC 00 C0 18 D8 18 D8 00 C0 00 00 C0 00
||
\/
plane 0 plane 1
7 bit 0 7 bit 0 full tile
---- ---- ---- ----
.... ...1 = 01 .222 22.. = 7C .22222.1
.... ...1 = 01 2222 22.. = FC 222222.1
.... .... = 00 22.. .... = C0 22......
...1 1... = 18 22.2 2... = D8 --\ 22.33...
...1 1... = 18 22.2 2... = D8 --/ 22.33...
.... .... = 00 22.. .... = C0 22......
.... .... = 00 .... .... = 00 ........
11.. .... = C0 .... .... = 00 11......
</pre>
This matches the format used by the Game Boy.
==== 4 bits per pixel, planar ====
This mode is stored in a manner similar to the 2 bits per pixel mode, but with an additional two planes for bit 2 and bit 3 of each pixel's palette index, expanding the tile data to 32 bytes.
<pre>
tile data (32 bytes)
54 32 01 00 54 32 F1 00 54 32 01 F0 54 32 F1 F0 04 02 01 00 F8 04 02 01 00 F8 04 02 00 00 F8 04
||
\/
plane 0 plane 1 plane 2 plane 3
7 bit 0 7 bit 0 7 bit 0 7 bit 0 full tile
---- ---- ---- ---- ---- ---- ---- ----
.1.1 .1.. = 54 ..22 ..2. = 32 .... ...4 = 01 .... .... = 00 .123.124
.1.1 .1.. = 54 ..22 ..2. = 32 4444 ...4 = F1 .... .... = 00 4567.124
.1.1 .1.. = 54 ..22 ..2. = 32 .... ...4 = 01 8888 .... = F0 89AB.124
.1.1 .1.. = 54 ..22 ..2. = 32 4444 ...4 = F1 8888 .... = F0 --\ CDEF.124
.... .1.. = 04 .... ..2. = 02 .... ...4 = 01 .... .... = 00 --/ .....124
1111 1... = F8 .... .2.. = 04 .... ..4. = 02 .... ...8 = 01 11111248
.... .... = 00 2222 2... = F8 .... .4.. = 04 .... ..8. = 02 2222248.
.... .... = 00 .... .... = 00 4444 4... = F8 .... .8.. = 04 444448..
</pre>
This format matches the one used by the Sega Master System and Game Gear family of consoles.
==== 4 bits per pixel, packed ====
Unlike the previous two formats, in the packed format each byte stores the complete palette index of two pixels - the high four bits store the left pixel, while the low four bits store the right pixel. Four such bytes make up a row of eight pixels from left to right.
<pre>
tile data (32 bytes)
01 23 01 24 45 67 01 24 89 AB 01 24 CD EF 01 24 00 00 01 24 11 11 12 48 22 22 24 80 44 44 48 00
||
\/
byte 0 1 2 3
bits 7-4 3-0 7-4 3-0 7-4 3-0 7-4 3-0
pixel 0 1 2 3 4 5 6 7 full tile
--- --- --- --- --- --- --- ---
. 1 = 01 2 3 = 23 . 1 = 01 2 4 = 24 .123.124 = 01 23 01 24
4 5 = 45 6 7 = 67 . 1 = 01 2 4 = 24 4567.124 = 45 67 01 24
8 9 = 89 A B = AB . 1 = 01 2 4 = 24 89AB.124 = 89 AB 01 24
C D = CD E F = EF . 1 = 01 2 4 = 24 --\ CDEF.124 = CD EF 01 24
. . = 00 . . = 00 . 1 = 01 2 4 = 24 --/ .....124 = 00 00 01 24
1 1 = 11 1 1 = 11 1 2 = 12 4 8 = 48 11111248 = 11 11 12 48
2 2 = 22 2 2 = 22 2 4 = 24 8 . = 80 2222248. = 22 22 24 80
4 4 = 44 4 4 = 44 4 8 = 48 . . = 00 444448.. = 44 44 48 00
</pre>
This format matches the one used by the Mega Drive console.
=== Palettes ===
The display system provides sixteen different palettes that can be used to color or shade tiles.
* Palettes 0-7 can be used for the two screens only;
* Palettes 8-15 can be used for both screens and sprites.
==== Mono ====
In ''mono'' modes, palettes are stored in I/O ports 0x20 through 0x3F. Each palette contains four three-bit entries, which are pointers into a global, four-bit shade lookup table:
<pre>
Palette Global shade LUT
1 ===========> 2 ==========================> 5
^ (0, 2, 4, 6) ^ (1, 3, 5, 7, 9, 11, 13, 15) ^
| | |
Palette index Value Displayed shade
</pre>
The shade value corresponds to the darkness of the pixel: shade 0 is the brightest, while shade 15 is the darkest.
==== Color ====
In ''color'' modes, palettes are stored as 16-bit words in memory addresses 0xFE00 through 0xFFFF, without additional lookup tables:
<pre>
Address
15 bit 8 7 bit 0
---- ---- ---- ----
1111 111p pppi iii.
| |||| |||
| |||+-+++-- Index in palette (0-15)
+--+++------- Palette number (0-15)
Data
15 bit 8 7 bit 0
---- ---- ---- ----
.... rrrr gggg bbbb
|||| |||| ||||
|||| |||| ++++- Blue (0-15)
|||| ++++------ Green (0-15)
++++------------ Red (0-15)
</pre>
In 2 bits per pixel color modes, palette entries 4 through 15 are not used.
==== Transparency ====
In two bit per pixel modes:
* Palettes 0-3 and 8-11 are ''opaque''. For these, index zero is treated as opaque.
* Palettes 4-7 and 12-15 are ''translucent''. For these, index zero is treated as transparent. This means that the color/shade value set to it is ignored, and only three distinct colors/shades can be used for tiles.
In four bit per pixel modes, all palettes are ''translucent''. Index zero is always treated as transparent, and fifteen different colors/shades can be used for tiles.
=== Background color ===
The background color is displayed if no ''opaque'' pixel from screens or sprites is drawn. This color is set in I/O port ''0x01'':
* In mono modes, it is set to an entry in the shade lookup table (0-7),
* In color modes, it is set to an entry in the color palette (0-255). Note that this allows you to use the first color (color zero) of any palette, which is normally ignored and assumed to be ''transparent''.
=== Screens ===
A screen is a layout of tiles. Each cell in a screen controls one 8x8 tile.
The display system can show two distinct screens simultaneously. It also supports hardware flipping of tiles, both horizontally and vertically.
The size of each screen is fixed at 32x32 cells or 256x256 pixels, while each cell is stored as a two-byte word:
<pre>
Address
15 bit 8 7 bit 0
---- ---- ---- ----
0bbb byyy yyxx xxx.
||| |||| |||| |||
||| |||| ||++-+++-- X coordinate (0-31)
||| |+++--++-------- Y coordinate (0-31)
+++-+--------------- Base address (from I/O port)
Data
15 bit 8 7 bit 0
---- ---- ---- ----
vhbp pppt tttt tttt
|||| |||| |||| ||||
|||| |||+--++++-++++- Tile index (0-511)
|||+-+++------------- Palette (0-15)
||+------------------ Tile bank (0-1) - color only
|+------------------- Horizontal flip
+-------------------- Vertical flip
</pre>
In ''color'' modes, the tile bank selects between tiles 0-511 and 512-1023.
=== Sprites ===
The display system can show up to 128 sprites at once.
Sprites are always drawn in front of Screen 1, but they can be drawn in front of or behind Screen 2.
Sprites are stored in a sprite table in the console's internal RAM. It consists of up to 128 four-byte entries, of which any sequential slice can be displayed:
<pre>
(Byte 1) (Byte 0)
15 bit 8 7 bit 0
---- ---- ---- ----
vhPi pppt tttt tttt
|||| |||| |||| ||||
|||| |||+--++++-++++- Tile index (0-511) - only tile bank 0
|||| +++------------- Palette (0-7) - mapped to screen palettes 8-15
|||+----------------- Window location - 0 = inside, 1 = outside
||+------------------ Priority - 0 = behind Screen 2, 1 = in front of Screen 2
|+------------------- Horizontal flip
+-------------------- Vertical flip
(Byte 2)
7 bit 0
---- ----
yyyy yyyy
|||| ||||
++++-++++- Y coordinate
(Byte 3)
7 bit 0
---- ----
xxxx xxxx
|||| ||||
++++-++++- X coordinate
</pre>
There is a sprite limit of 32 per scanline. This means that for each scanline, only the first 32 sprites will be drawn. Note that this includes sprites obscured by windows or outside of visible X coordinates; this list is determined solely by the Y coordinate. Between sprites themselves, earlier sprites in the list are always drawn on top of later sprites in the list.
The sprite table is copied from the console's RAM to a SoC-internal buffer every frame on line <tt>144</tt>; one word for every clock of the line, totaling 256 words (512 bytes) for 256 clocks. This internal buffer is then used for reading sprite data on the next frame.
=== Visibility priority ===
For display components, the visibility priority is as follows:
* Sprite 0, high priority
* Sprite 127, high priority
* Screen 2
* Sprite 0, low priority
* Sprite 127, low priority
* Screen 1
* Background color
=== Windows ===
Screen 2 and sprites can optionally have their drawing restricted within or outside of their specific rectangular windows.
Note that for sprites, the window is enabled globally (for all sprites), but each sprite can individually decide if it's rendered inside or outside of it.
=== Icons ===
The WonderSwan features thirteen fixed LCD segments which are displayed to the right<sup>(color)</sup> or below<sup>(mono)</sup> the main display. These are:
* [[#LCD_Icon_Control_($15)|Six under control of software]]
** Large circle
** Medium circle
** Small circle
** Horizontal orientation
** Vertical orientation
** (Shooting) Star (Sleep)
* [[#LCD_Status_($1A)|Four software can query]]
** Speaker
** Volume A (small wave<sup>(mono)</sup>, center wave<sup>(color)</sup>)
** Volume B (big wave<sup>(mono)</sup>, outside two waves<sup>(color)</sup>)
** Headphones
* [[Interrupts#Interrupt_NMI_Control_($B7)|One that the software can infer]]
** Low battery
* Two that are entirely invisible to software
** Power on ("Egg", resembles the mono power switch)
** Cartridge
== Interrupts ==
The display circuit generates two interrupts of its own:
* Display Interrupt Line Match - when <code>Display Current Line</code> == <code>Display Interrupt Line</code>, at the beginning of said line.
* Display Vertical Blank - when <code>Display Current Line</code> == <code>144</code>, at the beginning of said line.
It also provides a timing source for the two Horizontal and Vertical Blank [[Timers]], which provide their own respective interrupts.
== I/O ports ==
{{Anchor|Display Control}}
=== Display Control ($00) ===
<pre>
7 bit 0
---- ----
..wo Ws21
|| ||||
|| |||+- Enable Screen 1 layer
|| ||+-- Enable Screen 2 layer
|| |+--- Enable Sprite layer
|| +---- Enable Sprite window
|+------ Screen 2 tiles are drawn (if window enabled):
| 0 = inside window,
| 1 = outside window.
+------- Enable Screen 2 window
</pre>
{{Anchor|Display Background}}
=== Display Background Color ($01) ===
<pre>
(mono) (color)
7 bit 0 7 bit 0
---- ---- ---- ----
.... .sss pppp iiii
||| |||| ||||
+++- Value |||| ++++- Index in palette (0-15)
(0-7) ++++------ Color palette (0-15)
</pre>
{{Anchor|Display Current Line}}
=== Display Current Line ($02 read) ===
The current line being drawn by the display.
Note that lines are sent to the display with a one-line delay. This matters for color palette or shade LUT manipulation; changing these values when <code>current line == 1</code> will actually affect line 0.
{{Anchor|Display Interrupt Line}}
=== Display Interrupt Line ($03) ===
The line to emit an interrupt on.
{{Anchor|Sprite Table Address}}
=== Sprite Table Address ($04) ===
<pre>
7 bit 0
---- ----
..Aa aaaa
|| ||||
|+-++++- Address (bits 9-13)
+------- Address (bit 14) - color only
</pre>
{{Anchor|Sprite Table First}}
=== Sprite Table First ($05) ===
<pre>
7 bit 0
---- ----
.iii iiii
||| ||||
+++-++++- Index of first sprite entry to draw (0-127)
</pre>
{{Anchor|Sprite Table Count}}
=== Sprite Table Count ($06) ===
<pre>
7 bit 0
---- ----
cccc cccc
|||| ||||
++++-++++- Count of sprite entries to draw (1-128)
</pre>
{{Anchor|Screen Address}}
=== Screen Address ($07) ===
<pre>
7 bit 0
---- ----
2222 1111
|||| ||||
|||| |+++- Screen 1 address (bits 11-13)
|||| +---- Screen 1 address (bit 14) - color only
|+++------ Screen 2 address (bits 11-13)
+--------- Screen 2 address (bit 14) - color only
</pre>
{{Anchor|Screen 2 Window}}
=== Screen 2 Window Left ($08) ===
=== Screen 2 Window Top ($09) ===
=== Screen 2 Window Right ($0A) ===
=== Screen 2 Window Bottom ($0B) ===
The X and Y coordinates of the Screen 2 window.
Note that all coordinates are inclusive; for example, for a 200x100 window in the top-left corner, the values should be set as follows:
* Left - 0,
* Top - 0,
* Right - 199,
* Bottom - 99.
{{Anchor|Sprite Window}}
=== Sprite Window Left ($0C) ===
=== Sprite Window Top ($0D) ===
=== Sprite Window Right ($0E) ===
=== Sprite Window Bottom ($0F) ===
The X and Y coordinates of the Sprite window.
Note that all coordinates are inclusive.
{{Anchor|Screen Scroll}}
=== Screen 1 Scroll X ($10) ===
=== Screen 1 Scroll Y ($11) ===
The X and Y coordinates that Screen 1 is scrolled by.
For example, setting Scroll X to 24 and Scroll Y to 8 will omit, in 8x8 tile units, the first three rows and the first two columns of the 32x32 screen.
=== Screen 2 Scroll X ($12) ===
=== Screen 2 Scroll Y ($13) ===
The X and Y coordinates that Screen 2 is scrolled by.
{{Anchor|LCD Control}}
=== LCD Control ($14) ===
<pre>
7 bit 0
---- ----
.... ..Ce
||
|+- LCD enable: 0 = sleep, 1 = enabled
+-- Contrast (WSC): 0 = low, 1 = high
</pre>
The enable bit controls whether or not the LCD screen is displaying graphics; if sleeping, it displays nothing (all white). Note that icon segments continue displaying regardless of this configuration.
Note that port $1A provides a separate LCD sleep bit; the display will be disabled in the same way if any of those bits are set to "sleep".
The contrast bit allows enabling a "high contrast" mode: this works by having the LCD drive two lines with data received from the SoC - so the first line of the LCD is driven by the first line from the SoC, then additionally by the second line from the SoC.
{{Anchor|LCD Icon Control}}
=== LCD Icon Control ($15) ===
<pre>
7 bit 0
---- ----
..32 1hvs
|| ||||
|| |||+- Sleep
|| ||+-- Vertical orientation
|| |+--- Horizontal orientation
|| +---- Etc. 1 (Small circle)
|+------ Etc. 2 (Medium circle)
+------- Etc. 3 (Large circle)
</pre>
{{Anchor|LCD Mono Shade LUT}}
=== LCD Mono Shade LUT ($1C-$1F) ===
<pre>
$1C $1D $1E $1F
7 bit 0 7 bit 0 7 bit 0 7 bit 0
---- ---- ---- ---- ---- ---- ---- ----
1111 0000 3333 2222 5555 4444 7777 6666
</pre>
{{Anchor|LCD Mono Palette}}
=== LCD Mono Palette 0..15 ($20, $21 .. $3E, $3F) ===
The monochrome palette is laid out as sixteen words:
<pre>
N+1 N
15 bit 8 7 bit 0
---- ---- ---- ----
.333 .222 .111 .000
||| ||| ||| |||
||| ||| ||| +++- Shade LUT index for color 0
||| ||| +++------ Shade LUT index for color 1
||| +++------------ Shade LUT index for color 2
+++----------------- Shade LUT index for color 3
</pre>
== Internal I/O ports ==
These I/O ports are said to be internal and not intended for use by commercial games.
{{Anchor|LCD Final Line}}
=== LCD Final Line ($16) ===
The final line preceding line counter restart and the beginning of active display. By default, this is set to 158, which equals 159 total lines per frame.
It is said setting this register to an odd value on SwanCrystal has an adverse effect to the LCD panel,<ref>[http://daifukkat.su/docs/wsman/#REG_LCD_VTOTAL REG_LCD_VTOTAL - WSMan]</ref> but the exact mechanism is unknown. A starting point for research is that an even value, or odd total line count, is needed to balance positive and negative charges on the LCD.<ref>W.A. Steer. "[http://www.techmind.org/lcd/ LCD monitor technology and tests]". Techmind, 2011-12-03. Accessed 2024-11-19.</ref>
{{Anchor|LCD Back Porch Line}}
=== LCD Back Porch Line ($17, WSC only) ===
This port is available on the WonderSwan Color only - not the SwanCrystal!
The final line preceding the vertical back porch; by default, this should be set to 155.
The vertical back porch of the LCD is assumed to be 4 lines by some hardware, including IPS mods, as well as the official "TV Swan" capture device. Given that the first visible line is sent to the LCD on the display's line 1, this should be generally set to <code>LCD Final Line - 3</code>.
Conversely, it is said moving this value closer to vertical blank improves LCD visibility<ref>[http://daifukkat.su/docs/wsman/#REG_LCD_VSYNC REG_LCD_VSYNC - WSMan]</ref>, but the exact mechanism is unknown.
{{Anchor|LCD Status}}
=== LCD Status ($1A) ===
<pre>
7 bit 0
---- ----
...v vvhs
| ||||
| |||+- LCD sleep: 0 = no, 1 = sleep
| ||+-- Headphone icon
| ||
| || Volume icons:
| |+--- - Volume B (medium, high)
| +---- - Volume A (low, high)
+------ - Speaker
</pre>
The LCD sleep bit is writable. The remaining bits are read-only.
The volume and headphone icon are enabled when pressing the SOUND button, according to this algorithm:
* If headphones are plugged in, show the Headphone icon.
* If headphones are not plugged in, show the Speaker icon and the following Volume icons:
** Volume level 0: None
** Volume level 1: A
** Volume level 2: B
** Volume level 3: A, B
* Hide all visible icons after 128 frames from the last press.
TODO: This documents the WonderSwan Color. The specifics probably work differently on the mono WonderSwan.
=== TFT LCD Configuration ($70, $71, $72, $73, $74, $75, $76, $77 SwanCrystal only) ===
These eight bytes are read from internal EEPROM and configure unknown aspects of the console's TFT LCD panel.
They are only writable while the [[Boot ROM]] is unlocked - locking has the side effect of making them read-only.
== Notes ==
<references />
eb1758d35c8b6434ff9e997359cb2fe965861945
491
490
2025-01-21T16:23:11Z
Asie
351
/* I/O ports */
wikitext
text/x-wiki
The WonderSwan's display functionality generally consists of:
* a 224x144 display clocked at ~75.47 Hz by default, capable of displaying:
** up to sixteen distinct shades of gray
** 12-bit RGB444 color<sup>(color)</sup>
* two 32x32 background layers ("screens"), capable of displaying up to 512 (1024<sup>(color)</sup>) distinct tiles,
* a sprite layer, capable of displaying up to 128 8x8 sprites (up to 32 per line),
* a bar of LCD icon segments to the bottom (WS) or right (WSC/SC) of the display, usable as additional indicators.
== Components ==
=== Tiles ===
The WonderSwan can display up to 512 distinct tiles at a time, with two bits of palette index information for every pixel.
The WonderSwan Color expands this to 1024 distinct tiles for background (with 512 remaining the limit for sprites), while also introducing modes with four bits of palette index information for every pixel.
==== 2 bits per pixel, planar ====
The tiles are stored in an interleaved planar format, with two bits total for every pixel. Odd bytes store the first plane (bit 0 of each pixel), while even bytes store the second plane (bit 1 of each pixel).
<pre>
tile data (16 bytes)
01 7C 01 FC 00 C0 18 D8 18 D8 00 C0 00 00 C0 00
||
\/
plane 0 plane 1
7 bit 0 7 bit 0 full tile
---- ---- ---- ----
.... ...1 = 01 .222 22.. = 7C .22222.1
.... ...1 = 01 2222 22.. = FC 222222.1
.... .... = 00 22.. .... = C0 22......
...1 1... = 18 22.2 2... = D8 --\ 22.33...
...1 1... = 18 22.2 2... = D8 --/ 22.33...
.... .... = 00 22.. .... = C0 22......
.... .... = 00 .... .... = 00 ........
11.. .... = C0 .... .... = 00 11......
</pre>
This matches the format used by the Game Boy.
==== 4 bits per pixel, planar ====
This mode is stored in a manner similar to the 2 bits per pixel mode, but with an additional two planes for bit 2 and bit 3 of each pixel's palette index, expanding the tile data to 32 bytes.
<pre>
tile data (32 bytes)
54 32 01 00 54 32 F1 00 54 32 01 F0 54 32 F1 F0 04 02 01 00 F8 04 02 01 00 F8 04 02 00 00 F8 04
||
\/
plane 0 plane 1 plane 2 plane 3
7 bit 0 7 bit 0 7 bit 0 7 bit 0 full tile
---- ---- ---- ---- ---- ---- ---- ----
.1.1 .1.. = 54 ..22 ..2. = 32 .... ...4 = 01 .... .... = 00 .123.124
.1.1 .1.. = 54 ..22 ..2. = 32 4444 ...4 = F1 .... .... = 00 4567.124
.1.1 .1.. = 54 ..22 ..2. = 32 .... ...4 = 01 8888 .... = F0 89AB.124
.1.1 .1.. = 54 ..22 ..2. = 32 4444 ...4 = F1 8888 .... = F0 --\ CDEF.124
.... .1.. = 04 .... ..2. = 02 .... ...4 = 01 .... .... = 00 --/ .....124
1111 1... = F8 .... .2.. = 04 .... ..4. = 02 .... ...8 = 01 11111248
.... .... = 00 2222 2... = F8 .... .4.. = 04 .... ..8. = 02 2222248.
.... .... = 00 .... .... = 00 4444 4... = F8 .... .8.. = 04 444448..
</pre>
This format matches the one used by the Sega Master System and Game Gear family of consoles.
==== 4 bits per pixel, packed ====
Unlike the previous two formats, in the packed format each byte stores the complete palette index of two pixels - the high four bits store the left pixel, while the low four bits store the right pixel. Four such bytes make up a row of eight pixels from left to right.
<pre>
tile data (32 bytes)
01 23 01 24 45 67 01 24 89 AB 01 24 CD EF 01 24 00 00 01 24 11 11 12 48 22 22 24 80 44 44 48 00
||
\/
byte 0 1 2 3
bits 7-4 3-0 7-4 3-0 7-4 3-0 7-4 3-0
pixel 0 1 2 3 4 5 6 7 full tile
--- --- --- --- --- --- --- ---
. 1 = 01 2 3 = 23 . 1 = 01 2 4 = 24 .123.124 = 01 23 01 24
4 5 = 45 6 7 = 67 . 1 = 01 2 4 = 24 4567.124 = 45 67 01 24
8 9 = 89 A B = AB . 1 = 01 2 4 = 24 89AB.124 = 89 AB 01 24
C D = CD E F = EF . 1 = 01 2 4 = 24 --\ CDEF.124 = CD EF 01 24
. . = 00 . . = 00 . 1 = 01 2 4 = 24 --/ .....124 = 00 00 01 24
1 1 = 11 1 1 = 11 1 2 = 12 4 8 = 48 11111248 = 11 11 12 48
2 2 = 22 2 2 = 22 2 4 = 24 8 . = 80 2222248. = 22 22 24 80
4 4 = 44 4 4 = 44 4 8 = 48 . . = 00 444448.. = 44 44 48 00
</pre>
This format matches the one used by the Mega Drive console.
=== Palettes ===
The display system provides sixteen different palettes that can be used to color or shade tiles.
* Palettes 0-7 can be used for the two screens only;
* Palettes 8-15 can be used for both screens and sprites.
==== Mono ====
In ''mono'' modes, palettes are stored in I/O ports 0x20 through 0x3F. Each palette contains four three-bit entries, which are pointers into a global, four-bit shade lookup table:
<pre>
Palette Global shade LUT
1 ===========> 2 ==========================> 5
^ (0, 2, 4, 6) ^ (1, 3, 5, 7, 9, 11, 13, 15) ^
| | |
Palette index Value Displayed shade
</pre>
The shade value corresponds to the darkness of the pixel: shade 0 is the brightest, while shade 15 is the darkest.
==== Color ====
In ''color'' modes, palettes are stored as 16-bit words in memory addresses 0xFE00 through 0xFFFF, without additional lookup tables:
<pre>
Address
15 bit 8 7 bit 0
---- ---- ---- ----
1111 111p pppi iii.
| |||| |||
| |||+-+++-- Index in palette (0-15)
+--+++------- Palette number (0-15)
Data
15 bit 8 7 bit 0
---- ---- ---- ----
.... rrrr gggg bbbb
|||| |||| ||||
|||| |||| ++++- Blue (0-15)
|||| ++++------ Green (0-15)
++++------------ Red (0-15)
</pre>
In 2 bits per pixel color modes, palette entries 4 through 15 are not used.
==== Transparency ====
In two bit per pixel modes:
* Palettes 0-3 and 8-11 are ''opaque''. For these, index zero is treated as opaque.
* Palettes 4-7 and 12-15 are ''translucent''. For these, index zero is treated as transparent. This means that the color/shade value set to it is ignored, and only three distinct colors/shades can be used for tiles.
In four bit per pixel modes, all palettes are ''translucent''. Index zero is always treated as transparent, and fifteen different colors/shades can be used for tiles.
=== Background color ===
The background color is displayed if no ''opaque'' pixel from screens or sprites is drawn. This color is set in I/O port ''0x01'':
* In mono modes, it is set to an entry in the shade lookup table (0-7),
* In color modes, it is set to an entry in the color palette (0-255). Note that this allows you to use the first color (color zero) of any palette, which is normally ignored and assumed to be ''transparent''.
=== Screens ===
A screen is a layout of tiles. Each cell in a screen controls one 8x8 tile.
The display system can show two distinct screens simultaneously. It also supports hardware flipping of tiles, both horizontally and vertically.
The size of each screen is fixed at 32x32 cells or 256x256 pixels, while each cell is stored as a two-byte word:
<pre>
Address
15 bit 8 7 bit 0
---- ---- ---- ----
0bbb byyy yyxx xxx.
||| |||| |||| |||
||| |||| ||++-+++-- X coordinate (0-31)
||| |+++--++-------- Y coordinate (0-31)
+++-+--------------- Base address (from I/O port)
Data
15 bit 8 7 bit 0
---- ---- ---- ----
vhbp pppt tttt tttt
|||| |||| |||| ||||
|||| |||+--++++-++++- Tile index (0-511)
|||+-+++------------- Palette (0-15)
||+------------------ Tile bank (0-1) - color only
|+------------------- Horizontal flip
+-------------------- Vertical flip
</pre>
In ''color'' modes, the tile bank selects between tiles 0-511 and 512-1023.
=== Sprites ===
The display system can show up to 128 sprites at once.
Sprites are always drawn in front of Screen 1, but they can be drawn in front of or behind Screen 2.
Sprites are stored in a sprite table in the console's internal RAM. It consists of up to 128 four-byte entries, of which any sequential slice can be displayed:
<pre>
(Byte 1) (Byte 0)
15 bit 8 7 bit 0
---- ---- ---- ----
vhPi pppt tttt tttt
|||| |||| |||| ||||
|||| |||+--++++-++++- Tile index (0-511) - only tile bank 0
|||| +++------------- Palette (0-7) - mapped to screen palettes 8-15
|||+----------------- Window location - 0 = inside, 1 = outside
||+------------------ Priority - 0 = behind Screen 2, 1 = in front of Screen 2
|+------------------- Horizontal flip
+-------------------- Vertical flip
(Byte 2)
7 bit 0
---- ----
yyyy yyyy
|||| ||||
++++-++++- Y coordinate
(Byte 3)
7 bit 0
---- ----
xxxx xxxx
|||| ||||
++++-++++- X coordinate
</pre>
There is a sprite limit of 32 per scanline. This means that for each scanline, only the first 32 sprites will be drawn. Note that this includes sprites obscured by windows or outside of visible X coordinates; this list is determined solely by the Y coordinate. Between sprites themselves, earlier sprites in the list are always drawn on top of later sprites in the list.
The sprite table is copied from the console's RAM to a SoC-internal buffer every frame on line <tt>144</tt>; one word for every clock of the line, totaling 256 words (512 bytes) for 256 clocks. This internal buffer is then used for reading sprite data on the next frame.
=== Visibility priority ===
For display components, the visibility priority is as follows:
* Sprite 0, high priority
* Sprite 127, high priority
* Screen 2
* Sprite 0, low priority
* Sprite 127, low priority
* Screen 1
* Background color
=== Windows ===
Screen 2 and sprites can optionally have their drawing restricted within or outside of their specific rectangular windows.
Note that for sprites, the window is enabled globally (for all sprites), but each sprite can individually decide if it's rendered inside or outside of it.
=== Icons ===
The WonderSwan features thirteen fixed LCD segments which are displayed to the right<sup>(color)</sup> or below<sup>(mono)</sup> the main display. These are:
* [[#LCD_Icon_Control_($15)|Six under control of software]]
** Large circle
** Medium circle
** Small circle
** Horizontal orientation
** Vertical orientation
** (Shooting) Star (Sleep)
* [[#LCD_Status_($1A)|Four software can query]]
** Speaker
** Volume A (small wave<sup>(mono)</sup>, center wave<sup>(color)</sup>)
** Volume B (big wave<sup>(mono)</sup>, outside two waves<sup>(color)</sup>)
** Headphones
* [[Interrupts#Interrupt_NMI_Control_($B7)|One that the software can infer]]
** Low battery
* Two that are entirely invisible to software
** Power on ("Egg", resembles the mono power switch)
** Cartridge
== Interrupts ==
The display circuit generates two interrupts of its own:
* Display Interrupt Line Match - when <code>Display Current Line</code> == <code>Display Interrupt Line</code>, at the beginning of said line.
* Display Vertical Blank - when <code>Display Current Line</code> == <code>144</code>, at the beginning of said line.
It also provides a timing source for the two Horizontal and Vertical Blank [[Timers]], which provide their own respective interrupts.
== I/O ports ==
{{Anchor|Display Control}}
=== Display Control ($00) ===
<pre>
7 bit 0
---- ----
..wo Ws21
|| ||||
|| |||+- Enable Screen 1 layer
|| ||+-- Enable Screen 2 layer
|| |+--- Enable Sprite layer
|| +---- Enable Sprite window
|+------ Screen 2 tiles are drawn (if window enabled):
| 0 = inside window,
| 1 = outside window.
+------- Enable Screen 2 window
</pre>
{{Anchor|Display Background}}
=== Display Background Color ($01) ===
<pre>
(mono) (color)
7 bit 0 7 bit 0
---- ---- ---- ----
.... .sss pppp iiii
||| |||| ||||
+++- Value |||| ++++- Index in palette (0-15)
(0-7) ++++------ Color palette (0-15)
</pre>
{{Anchor|Display Current Line}}
=== Display Current Line ($02 read) ===
The current line being drawn by the display.
Note that lines are sent to the display with a one-line delay. This matters for color palette or shade LUT manipulation; changing these values when <code>current line == 1</code> will actually affect line 0.
{{Anchor|Display Interrupt Line}}
=== Display Interrupt Line ($03) ===
The line to emit an interrupt on.
{{Anchor|Sprite Table Address}}
=== Sprite Table Address ($04) ===
<pre>
7 bit 0
---- ----
..Aa aaaa
|| ||||
|+-++++- Address (bits 9-13)
+------- Address (bit 14) - color only
</pre>
{{Anchor|Sprite Table First}}
=== Sprite Table First ($05) ===
<pre>
7 bit 0
---- ----
.iii iiii
||| ||||
+++-++++- Index of first sprite entry to draw (0-127)
</pre>
{{Anchor|Sprite Table Count}}
=== Sprite Table Count ($06) ===
<pre>
7 bit 0
---- ----
cccc cccc
|||| ||||
++++-++++- Count of sprite entries to draw (1-128)
</pre>
{{Anchor|Screen Address}}
=== Screen Address ($07) ===
<pre>
7 bit 0
---- ----
2222 1111
|||| ||||
|||| |+++- Screen 1 address (bits 11-13)
|||| +---- Screen 1 address (bit 14) - color only
|+++------ Screen 2 address (bits 11-13)
+--------- Screen 2 address (bit 14) - color only
</pre>
{{Anchor|Screen 2 Window}}
=== Screen 2 Window Left ($08) ===
=== Screen 2 Window Top ($09) ===
=== Screen 2 Window Right ($0A) ===
=== Screen 2 Window Bottom ($0B) ===
The X and Y coordinates of the Screen 2 window.
Note that all coordinates are inclusive; for example, for a 200x100 window in the top-left corner, the values should be set as follows:
* Left - 0,
* Top - 0,
* Right - 199,
* Bottom - 99.
{{Anchor|Sprite Window}}
=== Sprite Window Left ($0C) ===
=== Sprite Window Top ($0D) ===
=== Sprite Window Right ($0E) ===
=== Sprite Window Bottom ($0F) ===
The X and Y coordinates of the Sprite window.
Note that all coordinates are inclusive.
{{Anchor|Screen Scroll}}
=== Screen 1 Scroll X ($10) ===
=== Screen 1 Scroll Y ($11) ===
The X and Y coordinates that Screen 1 is scrolled by.
For example, setting Scroll X to 24 and Scroll Y to 8 will omit, in 8x8 tile units, the first three rows and the first two columns of the 32x32 screen.
=== Screen 2 Scroll X ($12) ===
=== Screen 2 Scroll Y ($13) ===
The X and Y coordinates that Screen 2 is scrolled by.
{{Anchor|LCD Control}}
=== LCD Control ($14) ===
<pre>
7 bit 0
---- ----
.... ..Ce
||
|+- LCD enable: 0 = sleep, 1 = enabled
+-- Contrast (WSC): 0 = low, 1 = high
</pre>
The enable bit controls whether or not the LCD screen is displaying graphics; if sleeping, it displays nothing (all white). Note that icon segments continue displaying regardless of this configuration.
Note that port $1A provides a separate LCD sleep bit; the display will be disabled in the same way if any of those bits are set to "sleep".
The contrast bit allows enabling a "high contrast" mode: this works by having the LCD drive two lines with data received from the SoC - so the first line of the LCD is driven by the first line from the SoC, then additionally by the second line from the SoC.
{{Anchor|LCD Icon Control}}
=== LCD Icon Control ($15) ===
<pre>
7 bit 0
---- ----
..32 1hvs
|| ||||
|| |||+- Sleep
|| ||+-- Vertical orientation
|| |+--- Horizontal orientation
|| +---- Etc. 1 (Small circle)
|+------ Etc. 2 (Medium circle)
+------- Etc. 3 (Large circle)
</pre>
{{Anchor|LCD Mono Shade LUT}}
=== LCD Mono Shade LUT ($1C-$1F) ===
<pre>
$1C $1D $1E $1F
7 bit 0 7 bit 0 7 bit 0 7 bit 0
---- ---- ---- ---- ---- ---- ---- ----
1111 0000 3333 2222 5555 4444 7777 6666
|||| |||| |||| |||| |||| |||| |||| ||||
|||| |||| |||| |||| |||| |||| |||| ++++- Shade for LUT index 6
|||| |||| |||| |||| |||| |||| ++++------ Shade for LUT index 7
|||| |||| |||| |||| |||| ++++------------- Shade for LUT index 4
|||| |||| |||| |||| ++++------------------ Shade for LUT index 5
|||| |||| |||| ++++------------------------- Shade for LUT index 2
|||| |||| ++++------------------------------ Shade for LUT index 3
|||| ++++------------------------------------- Shade for LUT index 0
++++------------------------------------------ Shade for LUT index 1
</pre>
{{Anchor|LCD Mono Palette}}
=== LCD Mono Palette 0..15 ($20, $21 .. $3E, $3F) ===
The monochrome palette is laid out as sixteen words:
<pre>
N+1 N
15 bit 8 7 bit 0
---- ---- ---- ----
.333 .222 .111 .000
||| ||| ||| |||
||| ||| ||| +++- Shade LUT index for color 0
||| ||| +++------ Shade LUT index for color 1
||| +++------------ Shade LUT index for color 2
+++----------------- Shade LUT index for color 3
</pre>
== Internal I/O ports ==
These I/O ports are said to be internal and not intended for use by commercial games.
{{Anchor|LCD Final Line}}
=== LCD Final Line ($16) ===
The final line preceding line counter restart and the beginning of active display. By default, this is set to 158, which equals 159 total lines per frame.
It is said setting this register to an odd value on SwanCrystal has an adverse effect to the LCD panel,<ref>[http://daifukkat.su/docs/wsman/#REG_LCD_VTOTAL REG_LCD_VTOTAL - WSMan]</ref> but the exact mechanism is unknown. A starting point for research is that an even value, or odd total line count, is needed to balance positive and negative charges on the LCD.<ref>W.A. Steer. "[http://www.techmind.org/lcd/ LCD monitor technology and tests]". Techmind, 2011-12-03. Accessed 2024-11-19.</ref>
{{Anchor|LCD Back Porch Line}}
=== LCD Back Porch Line ($17, WSC only) ===
This port is available on the WonderSwan Color only - not the SwanCrystal!
The final line preceding the vertical back porch; by default, this should be set to 155.
The vertical back porch of the LCD is assumed to be 4 lines by some hardware, including IPS mods, as well as the official "TV Swan" capture device. Given that the first visible line is sent to the LCD on the display's line 1, this should be generally set to <code>LCD Final Line - 3</code>.
Conversely, it is said moving this value closer to vertical blank improves LCD visibility<ref>[http://daifukkat.su/docs/wsman/#REG_LCD_VSYNC REG_LCD_VSYNC - WSMan]</ref>, but the exact mechanism is unknown.
{{Anchor|LCD Status}}
=== LCD Status ($1A) ===
<pre>
7 bit 0
---- ----
...v vvhs
| ||||
| |||+- LCD sleep: 0 = no, 1 = sleep
| ||+-- Headphone icon
| ||
| || Volume icons:
| |+--- - Volume B (medium, high)
| +---- - Volume A (low, high)
+------ - Speaker
</pre>
The LCD sleep bit is writable. The remaining bits are read-only.
The volume and headphone icon are enabled when pressing the SOUND button, according to this algorithm:
* If headphones are plugged in, show the Headphone icon.
* If headphones are not plugged in, show the Speaker icon and the following Volume icons:
** Volume level 0: None
** Volume level 1: A
** Volume level 2: B
** Volume level 3: A, B
* Hide all visible icons after 128 frames from the last press.
TODO: This documents the WonderSwan Color. The specifics probably work differently on the mono WonderSwan.
=== TFT LCD Configuration ($70, $71, $72, $73, $74, $75, $76, $77 SwanCrystal only) ===
These eight bytes are read from internal EEPROM and configure unknown aspects of the console's TFT LCD panel.
They are only writable while the [[Boot ROM]] is unlocked - locking has the side effect of making them read-only.
== Notes ==
<references />
635612c42269856da03581fa98a3a8ee1d192ed3
492
491
2025-01-21T16:26:55Z
Lidnariq
7
/* LCD Icon Control ($15) */ "sleep" or "power save" icon is a star or shooting star
wikitext
text/x-wiki
The WonderSwan's display functionality generally consists of:
* a 224x144 display clocked at ~75.47 Hz by default, capable of displaying:
** up to sixteen distinct shades of gray
** 12-bit RGB444 color<sup>(color)</sup>
* two 32x32 background layers ("screens"), capable of displaying up to 512 (1024<sup>(color)</sup>) distinct tiles,
* a sprite layer, capable of displaying up to 128 8x8 sprites (up to 32 per line),
* a bar of LCD icon segments to the bottom (WS) or right (WSC/SC) of the display, usable as additional indicators.
== Components ==
=== Tiles ===
The WonderSwan can display up to 512 distinct tiles at a time, with two bits of palette index information for every pixel.
The WonderSwan Color expands this to 1024 distinct tiles for background (with 512 remaining the limit for sprites), while also introducing modes with four bits of palette index information for every pixel.
==== 2 bits per pixel, planar ====
The tiles are stored in an interleaved planar format, with two bits total for every pixel. Odd bytes store the first plane (bit 0 of each pixel), while even bytes store the second plane (bit 1 of each pixel).
<pre>
tile data (16 bytes)
01 7C 01 FC 00 C0 18 D8 18 D8 00 C0 00 00 C0 00
||
\/
plane 0 plane 1
7 bit 0 7 bit 0 full tile
---- ---- ---- ----
.... ...1 = 01 .222 22.. = 7C .22222.1
.... ...1 = 01 2222 22.. = FC 222222.1
.... .... = 00 22.. .... = C0 22......
...1 1... = 18 22.2 2... = D8 --\ 22.33...
...1 1... = 18 22.2 2... = D8 --/ 22.33...
.... .... = 00 22.. .... = C0 22......
.... .... = 00 .... .... = 00 ........
11.. .... = C0 .... .... = 00 11......
</pre>
This matches the format used by the Game Boy.
==== 4 bits per pixel, planar ====
This mode is stored in a manner similar to the 2 bits per pixel mode, but with an additional two planes for bit 2 and bit 3 of each pixel's palette index, expanding the tile data to 32 bytes.
<pre>
tile data (32 bytes)
54 32 01 00 54 32 F1 00 54 32 01 F0 54 32 F1 F0 04 02 01 00 F8 04 02 01 00 F8 04 02 00 00 F8 04
||
\/
plane 0 plane 1 plane 2 plane 3
7 bit 0 7 bit 0 7 bit 0 7 bit 0 full tile
---- ---- ---- ---- ---- ---- ---- ----
.1.1 .1.. = 54 ..22 ..2. = 32 .... ...4 = 01 .... .... = 00 .123.124
.1.1 .1.. = 54 ..22 ..2. = 32 4444 ...4 = F1 .... .... = 00 4567.124
.1.1 .1.. = 54 ..22 ..2. = 32 .... ...4 = 01 8888 .... = F0 89AB.124
.1.1 .1.. = 54 ..22 ..2. = 32 4444 ...4 = F1 8888 .... = F0 --\ CDEF.124
.... .1.. = 04 .... ..2. = 02 .... ...4 = 01 .... .... = 00 --/ .....124
1111 1... = F8 .... .2.. = 04 .... ..4. = 02 .... ...8 = 01 11111248
.... .... = 00 2222 2... = F8 .... .4.. = 04 .... ..8. = 02 2222248.
.... .... = 00 .... .... = 00 4444 4... = F8 .... .8.. = 04 444448..
</pre>
This format matches the one used by the Sega Master System and Game Gear family of consoles.
==== 4 bits per pixel, packed ====
Unlike the previous two formats, in the packed format each byte stores the complete palette index of two pixels - the high four bits store the left pixel, while the low four bits store the right pixel. Four such bytes make up a row of eight pixels from left to right.
<pre>
tile data (32 bytes)
01 23 01 24 45 67 01 24 89 AB 01 24 CD EF 01 24 00 00 01 24 11 11 12 48 22 22 24 80 44 44 48 00
||
\/
byte 0 1 2 3
bits 7-4 3-0 7-4 3-0 7-4 3-0 7-4 3-0
pixel 0 1 2 3 4 5 6 7 full tile
--- --- --- --- --- --- --- ---
. 1 = 01 2 3 = 23 . 1 = 01 2 4 = 24 .123.124 = 01 23 01 24
4 5 = 45 6 7 = 67 . 1 = 01 2 4 = 24 4567.124 = 45 67 01 24
8 9 = 89 A B = AB . 1 = 01 2 4 = 24 89AB.124 = 89 AB 01 24
C D = CD E F = EF . 1 = 01 2 4 = 24 --\ CDEF.124 = CD EF 01 24
. . = 00 . . = 00 . 1 = 01 2 4 = 24 --/ .....124 = 00 00 01 24
1 1 = 11 1 1 = 11 1 2 = 12 4 8 = 48 11111248 = 11 11 12 48
2 2 = 22 2 2 = 22 2 4 = 24 8 . = 80 2222248. = 22 22 24 80
4 4 = 44 4 4 = 44 4 8 = 48 . . = 00 444448.. = 44 44 48 00
</pre>
This format matches the one used by the Mega Drive console.
=== Palettes ===
The display system provides sixteen different palettes that can be used to color or shade tiles.
* Palettes 0-7 can be used for the two screens only;
* Palettes 8-15 can be used for both screens and sprites.
==== Mono ====
In ''mono'' modes, palettes are stored in I/O ports 0x20 through 0x3F. Each palette contains four three-bit entries, which are pointers into a global, four-bit shade lookup table:
<pre>
Palette Global shade LUT
1 ===========> 2 ==========================> 5
^ (0, 2, 4, 6) ^ (1, 3, 5, 7, 9, 11, 13, 15) ^
| | |
Palette index Value Displayed shade
</pre>
The shade value corresponds to the darkness of the pixel: shade 0 is the brightest, while shade 15 is the darkest.
==== Color ====
In ''color'' modes, palettes are stored as 16-bit words in memory addresses 0xFE00 through 0xFFFF, without additional lookup tables:
<pre>
Address
15 bit 8 7 bit 0
---- ---- ---- ----
1111 111p pppi iii.
| |||| |||
| |||+-+++-- Index in palette (0-15)
+--+++------- Palette number (0-15)
Data
15 bit 8 7 bit 0
---- ---- ---- ----
.... rrrr gggg bbbb
|||| |||| ||||
|||| |||| ++++- Blue (0-15)
|||| ++++------ Green (0-15)
++++------------ Red (0-15)
</pre>
In 2 bits per pixel color modes, palette entries 4 through 15 are not used.
==== Transparency ====
In two bit per pixel modes:
* Palettes 0-3 and 8-11 are ''opaque''. For these, index zero is treated as opaque.
* Palettes 4-7 and 12-15 are ''translucent''. For these, index zero is treated as transparent. This means that the color/shade value set to it is ignored, and only three distinct colors/shades can be used for tiles.
In four bit per pixel modes, all palettes are ''translucent''. Index zero is always treated as transparent, and fifteen different colors/shades can be used for tiles.
=== Background color ===
The background color is displayed if no ''opaque'' pixel from screens or sprites is drawn. This color is set in I/O port ''0x01'':
* In mono modes, it is set to an entry in the shade lookup table (0-7),
* In color modes, it is set to an entry in the color palette (0-255). Note that this allows you to use the first color (color zero) of any palette, which is normally ignored and assumed to be ''transparent''.
=== Screens ===
A screen is a layout of tiles. Each cell in a screen controls one 8x8 tile.
The display system can show two distinct screens simultaneously. It also supports hardware flipping of tiles, both horizontally and vertically.
The size of each screen is fixed at 32x32 cells or 256x256 pixels, while each cell is stored as a two-byte word:
<pre>
Address
15 bit 8 7 bit 0
---- ---- ---- ----
0bbb byyy yyxx xxx.
||| |||| |||| |||
||| |||| ||++-+++-- X coordinate (0-31)
||| |+++--++-------- Y coordinate (0-31)
+++-+--------------- Base address (from I/O port)
Data
15 bit 8 7 bit 0
---- ---- ---- ----
vhbp pppt tttt tttt
|||| |||| |||| ||||
|||| |||+--++++-++++- Tile index (0-511)
|||+-+++------------- Palette (0-15)
||+------------------ Tile bank (0-1) - color only
|+------------------- Horizontal flip
+-------------------- Vertical flip
</pre>
In ''color'' modes, the tile bank selects between tiles 0-511 and 512-1023.
=== Sprites ===
The display system can show up to 128 sprites at once.
Sprites are always drawn in front of Screen 1, but they can be drawn in front of or behind Screen 2.
Sprites are stored in a sprite table in the console's internal RAM. It consists of up to 128 four-byte entries, of which any sequential slice can be displayed:
<pre>
(Byte 1) (Byte 0)
15 bit 8 7 bit 0
---- ---- ---- ----
vhPi pppt tttt tttt
|||| |||| |||| ||||
|||| |||+--++++-++++- Tile index (0-511) - only tile bank 0
|||| +++------------- Palette (0-7) - mapped to screen palettes 8-15
|||+----------------- Window location - 0 = inside, 1 = outside
||+------------------ Priority - 0 = behind Screen 2, 1 = in front of Screen 2
|+------------------- Horizontal flip
+-------------------- Vertical flip
(Byte 2)
7 bit 0
---- ----
yyyy yyyy
|||| ||||
++++-++++- Y coordinate
(Byte 3)
7 bit 0
---- ----
xxxx xxxx
|||| ||||
++++-++++- X coordinate
</pre>
There is a sprite limit of 32 per scanline. This means that for each scanline, only the first 32 sprites will be drawn. Note that this includes sprites obscured by windows or outside of visible X coordinates; this list is determined solely by the Y coordinate. Between sprites themselves, earlier sprites in the list are always drawn on top of later sprites in the list.
The sprite table is copied from the console's RAM to a SoC-internal buffer every frame on line <tt>144</tt>; one word for every clock of the line, totaling 256 words (512 bytes) for 256 clocks. This internal buffer is then used for reading sprite data on the next frame.
=== Visibility priority ===
For display components, the visibility priority is as follows:
* Sprite 0, high priority
* Sprite 127, high priority
* Screen 2
* Sprite 0, low priority
* Sprite 127, low priority
* Screen 1
* Background color
=== Windows ===
Screen 2 and sprites can optionally have their drawing restricted within or outside of their specific rectangular windows.
Note that for sprites, the window is enabled globally (for all sprites), but each sprite can individually decide if it's rendered inside or outside of it.
=== Icons ===
The WonderSwan features thirteen fixed LCD segments which are displayed to the right<sup>(color)</sup> or below<sup>(mono)</sup> the main display. These are:
* [[#LCD_Icon_Control_($15)|Six under control of software]]
** Large circle
** Medium circle
** Small circle
** Horizontal orientation
** Vertical orientation
** (Shooting) Star (Sleep)
* [[#LCD_Status_($1A)|Four software can query]]
** Speaker
** Volume A (small wave<sup>(mono)</sup>, center wave<sup>(color)</sup>)
** Volume B (big wave<sup>(mono)</sup>, outside two waves<sup>(color)</sup>)
** Headphones
* [[Interrupts#Interrupt_NMI_Control_($B7)|One that the software can infer]]
** Low battery
* Two that are entirely invisible to software
** Power on ("Egg", resembles the mono power switch)
** Cartridge
== Interrupts ==
The display circuit generates two interrupts of its own:
* Display Interrupt Line Match - when <code>Display Current Line</code> == <code>Display Interrupt Line</code>, at the beginning of said line.
* Display Vertical Blank - when <code>Display Current Line</code> == <code>144</code>, at the beginning of said line.
It also provides a timing source for the two Horizontal and Vertical Blank [[Timers]], which provide their own respective interrupts.
== I/O ports ==
{{Anchor|Display Control}}
=== Display Control ($00) ===
<pre>
7 bit 0
---- ----
..wo Ws21
|| ||||
|| |||+- Enable Screen 1 layer
|| ||+-- Enable Screen 2 layer
|| |+--- Enable Sprite layer
|| +---- Enable Sprite window
|+------ Screen 2 tiles are drawn (if window enabled):
| 0 = inside window,
| 1 = outside window.
+------- Enable Screen 2 window
</pre>
{{Anchor|Display Background}}
=== Display Background Color ($01) ===
<pre>
(mono) (color)
7 bit 0 7 bit 0
---- ---- ---- ----
.... .sss pppp iiii
||| |||| ||||
+++- Value |||| ++++- Index in palette (0-15)
(0-7) ++++------ Color palette (0-15)
</pre>
{{Anchor|Display Current Line}}
=== Display Current Line ($02 read) ===
The current line being drawn by the display.
Note that lines are sent to the display with a one-line delay. This matters for color palette or shade LUT manipulation; changing these values when <code>current line == 1</code> will actually affect line 0.
{{Anchor|Display Interrupt Line}}
=== Display Interrupt Line ($03) ===
The line to emit an interrupt on.
{{Anchor|Sprite Table Address}}
=== Sprite Table Address ($04) ===
<pre>
7 bit 0
---- ----
..Aa aaaa
|| ||||
|+-++++- Address (bits 9-13)
+------- Address (bit 14) - color only
</pre>
{{Anchor|Sprite Table First}}
=== Sprite Table First ($05) ===
<pre>
7 bit 0
---- ----
.iii iiii
||| ||||
+++-++++- Index of first sprite entry to draw (0-127)
</pre>
{{Anchor|Sprite Table Count}}
=== Sprite Table Count ($06) ===
<pre>
7 bit 0
---- ----
cccc cccc
|||| ||||
++++-++++- Count of sprite entries to draw (1-128)
</pre>
{{Anchor|Screen Address}}
=== Screen Address ($07) ===
<pre>
7 bit 0
---- ----
2222 1111
|||| ||||
|||| |+++- Screen 1 address (bits 11-13)
|||| +---- Screen 1 address (bit 14) - color only
|+++------ Screen 2 address (bits 11-13)
+--------- Screen 2 address (bit 14) - color only
</pre>
{{Anchor|Screen 2 Window}}
=== Screen 2 Window Left ($08) ===
=== Screen 2 Window Top ($09) ===
=== Screen 2 Window Right ($0A) ===
=== Screen 2 Window Bottom ($0B) ===
The X and Y coordinates of the Screen 2 window.
Note that all coordinates are inclusive; for example, for a 200x100 window in the top-left corner, the values should be set as follows:
* Left - 0,
* Top - 0,
* Right - 199,
* Bottom - 99.
{{Anchor|Sprite Window}}
=== Sprite Window Left ($0C) ===
=== Sprite Window Top ($0D) ===
=== Sprite Window Right ($0E) ===
=== Sprite Window Bottom ($0F) ===
The X and Y coordinates of the Sprite window.
Note that all coordinates are inclusive.
{{Anchor|Screen Scroll}}
=== Screen 1 Scroll X ($10) ===
=== Screen 1 Scroll Y ($11) ===
The X and Y coordinates that Screen 1 is scrolled by.
For example, setting Scroll X to 24 and Scroll Y to 8 will omit, in 8x8 tile units, the first three rows and the first two columns of the 32x32 screen.
=== Screen 2 Scroll X ($12) ===
=== Screen 2 Scroll Y ($13) ===
The X and Y coordinates that Screen 2 is scrolled by.
{{Anchor|LCD Control}}
=== LCD Control ($14) ===
<pre>
7 bit 0
---- ----
.... ..Ce
||
|+- LCD enable: 0 = sleep, 1 = enabled
+-- Contrast (WSC): 0 = low, 1 = high
</pre>
The enable bit controls whether or not the LCD screen is displaying graphics; if sleeping, it displays nothing (all white). Note that icon segments continue displaying regardless of this configuration.
Note that port $1A provides a separate LCD sleep bit; the display will be disabled in the same way if any of those bits are set to "sleep".
The contrast bit allows enabling a "high contrast" mode: this works by having the LCD drive two lines with data received from the SoC - so the first line of the LCD is driven by the first line from the SoC, then additionally by the second line from the SoC.
{{Anchor|LCD Icon Control}}
=== LCD Icon Control ($15) ===
<pre>
7 bit 0
---- ----
..32 1hvs
|| ||||
|| |||+- Sleep (Star)
|| ||+-- Vertical orientation
|| |+--- Horizontal orientation
|| +---- Etc. 1 (Small circle)
|+------ Etc. 2 (Medium circle)
+------- Etc. 3 (Large circle)
</pre>
{{Anchor|LCD Mono Shade LUT}}
=== LCD Mono Shade LUT ($1C-$1F) ===
<pre>
$1C $1D $1E $1F
7 bit 0 7 bit 0 7 bit 0 7 bit 0
---- ---- ---- ---- ---- ---- ---- ----
1111 0000 3333 2222 5555 4444 7777 6666
|||| |||| |||| |||| |||| |||| |||| ||||
|||| |||| |||| |||| |||| |||| |||| ++++- Shade for LUT index 6
|||| |||| |||| |||| |||| |||| ++++------ Shade for LUT index 7
|||| |||| |||| |||| |||| ++++------------- Shade for LUT index 4
|||| |||| |||| |||| ++++------------------ Shade for LUT index 5
|||| |||| |||| ++++------------------------- Shade for LUT index 2
|||| |||| ++++------------------------------ Shade for LUT index 3
|||| ++++------------------------------------- Shade for LUT index 0
++++------------------------------------------ Shade for LUT index 1
</pre>
{{Anchor|LCD Mono Palette}}
=== LCD Mono Palette 0..15 ($20, $21 .. $3E, $3F) ===
The monochrome palette is laid out as sixteen words:
<pre>
N+1 N
15 bit 8 7 bit 0
---- ---- ---- ----
.333 .222 .111 .000
||| ||| ||| |||
||| ||| ||| +++- Shade LUT index for color 0
||| ||| +++------ Shade LUT index for color 1
||| +++------------ Shade LUT index for color 2
+++----------------- Shade LUT index for color 3
</pre>
== Internal I/O ports ==
These I/O ports are said to be internal and not intended for use by commercial games.
{{Anchor|LCD Final Line}}
=== LCD Final Line ($16) ===
The final line preceding line counter restart and the beginning of active display. By default, this is set to 158, which equals 159 total lines per frame.
It is said setting this register to an odd value on SwanCrystal has an adverse effect to the LCD panel,<ref>[http://daifukkat.su/docs/wsman/#REG_LCD_VTOTAL REG_LCD_VTOTAL - WSMan]</ref> but the exact mechanism is unknown. A starting point for research is that an even value, or odd total line count, is needed to balance positive and negative charges on the LCD.<ref>W.A. Steer. "[http://www.techmind.org/lcd/ LCD monitor technology and tests]". Techmind, 2011-12-03. Accessed 2024-11-19.</ref>
{{Anchor|LCD Back Porch Line}}
=== LCD Back Porch Line ($17, WSC only) ===
This port is available on the WonderSwan Color only - not the SwanCrystal!
The final line preceding the vertical back porch; by default, this should be set to 155.
The vertical back porch of the LCD is assumed to be 4 lines by some hardware, including IPS mods, as well as the official "TV Swan" capture device. Given that the first visible line is sent to the LCD on the display's line 1, this should be generally set to <code>LCD Final Line - 3</code>.
Conversely, it is said moving this value closer to vertical blank improves LCD visibility<ref>[http://daifukkat.su/docs/wsman/#REG_LCD_VSYNC REG_LCD_VSYNC - WSMan]</ref>, but the exact mechanism is unknown.
{{Anchor|LCD Status}}
=== LCD Status ($1A) ===
<pre>
7 bit 0
---- ----
...v vvhs
| ||||
| |||+- LCD sleep: 0 = no, 1 = sleep
| ||+-- Headphone icon
| ||
| || Volume icons:
| |+--- - Volume B (medium, high)
| +---- - Volume A (low, high)
+------ - Speaker
</pre>
The LCD sleep bit is writable. The remaining bits are read-only.
The volume and headphone icon are enabled when pressing the SOUND button, according to this algorithm:
* If headphones are plugged in, show the Headphone icon.
* If headphones are not plugged in, show the Speaker icon and the following Volume icons:
** Volume level 0: None
** Volume level 1: A
** Volume level 2: B
** Volume level 3: A, B
* Hide all visible icons after 128 frames from the last press.
TODO: This documents the WonderSwan Color. The specifics probably work differently on the mono WonderSwan.
=== TFT LCD Configuration ($70, $71, $72, $73, $74, $75, $76, $77 SwanCrystal only) ===
These eight bytes are read from internal EEPROM and configure unknown aspects of the console's TFT LCD panel.
They are only writable while the [[Boot ROM]] is unlocked - locking has the side effect of making them read-only.
== Notes ==
<references />
837157a7ddba43d1416699a92beadcd0eac9965c
I/O port map
0
8
487
363
2025-01-21T16:04:34Z
Asie
351
wikitext
text/x-wiki
The WonderSwan SoC has three general blocks of I/O port accesses:
{| class="wikitable"
! From !! To !! Holder !! Width !! Speed
|-
| $00 || $B7 || WonderSwan SoC || 16-bit || 1 cycle
|-
| $B8 || $BF || Internal EEPROM control || 16-bit || 1 cycle
|-
| $C0 || $FF || Cartridge bus || 8-bit || 1<sup>(color)</sup>/2 cycles (configurable)
|}
With the exception of internal EEPROM on the ASWAN, all unaligned 16-bit accesses can be converted to two 8-bit accesses with a 1-cycle penalty.
== I/O port map ==
* Superscripts are used to mark ports specific to a given mode or platform:
** Color mode: <sup>(color)</sup>. Such ports are only accessible when color mode is enabled through port <code>$60</code>.
** WS/WSC/SC console: <sup>(WS)</sup>, <sup>(WSC)</sup>, <sup>(SC)</sup>.
* If two Bits rows are provided, the second one refers to the "Color" mode.
* The Type can be: R - readable, W - writable, L - writable before boot ROM lockout, 8/16 - width (byte/word).
{| class="wikitable"
! Category
! Port
! Description
! Bits
! Type
! Notes
|-
! rowspan="45" | [[Display]]
! $00
| [[Display#Display Control|Display Control]]
| style="text-align: right" | <tt style="white-space: nowrap">..wo Ws21</tt>
| RW8
|
|-
! $01
| [[Display#Display Background|Display Background]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .sss</tt>
<tt style="white-space: nowrap">pppp iiii</tt>
| RW8
| Shade (s)
Palette (p), Index (i)
|-
! $02
| [[Display#Current Line|Display Current Line]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll</tt>
| R8
| Line (l)
|-
! $03
| [[Display#Interrupt Line|Display Interrupt Line]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll</tt>
| RW8
| Line (l)
|-
! $04
| [[Display#Sprite Table Address|Sprite Table Address]]
| style="text-align: right" | <tt style="white-space: nowrap">...a aaaa</tt>
<tt style="white-space: nowrap">..aa aaaa</tt>
| RW8
| Address >> 9 (a)
|-
! $05
| [[Display#Sprite Table First|Sprite Table First]]
| style="text-align: right" | <tt style="white-space: nowrap">.iii iiii</tt>
| RW8
| Index (i)
|-
! $06
| [[Display#Sprite Table Count|Sprite Table Count]]
| style="text-align: right" | <tt style="white-space: nowrap">cccc cccc</tt>
| RW8
| Count (c)
|-
! $07
| [[Display#Screen Address|Screen Address]]
| style="text-align: right" | <tt style="white-space: nowrap">.222 .111</tt>
<tt style="white-space: nowrap">2222 1111</tt>
| RW8
| Screen 1 address >> 11 (1)
Screen 2 address >> 11 (2)
|-
! $08
| [[Display#Screen 2 Window|Screen 2 Window Left]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $09
| [[Display#Screen 2 Window|Screen 2 Window Top]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $0A
| [[Display#Screen 2 Window|Screen 2 Window Right]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $0B
| [[Display#Screen 2 Window|Screen 2 Window Bottom]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $0C
| [[Display#Sprite Window|Sprite Window Left]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $0D
| [[Display#Sprite Window|Sprite Window Top]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $0E
| [[Display#Sprite Window|Sprite Window Right]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $0F
| [[Display#Sprite Window|Sprite Window Bottom]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $10
| [[Display#Screen Scroll|Screen 1 Scroll X]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $11
| [[Display#Screen Scroll|Screen 1 Scroll Y]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $12
| [[Display#Screen Scroll|Screen 2 Scroll X]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $13
| [[Display#Screen Scroll|Screen 2 Scroll Y]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $14
| [[Display#LCD Control|LCD Control]]
| style="text-align: right" | <tt style="white-space: nowrap">.... ..Ce</tt>
| RW8
| Contrast (C)<sup>(WSC)</sup>, Enable (e)
|-
! $15
| [[Display#LCD Icon Control|LCD Icon Control]]
| style="text-align: right" | <tt style="white-space: nowrap">..32 1hvs</tt>
| RW8
| Auxillary 3 (3), Auxillary 2 (2), Auxillary 1 (1),
Horizontal (h), Vertical (v), Sleep (s)
|-
! $16
| [[Display#LCD Final Line|LCD Final Line]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll</tt>
| RW8
| Line (l)
|-
! $17
| [[Display#LCD Back Porch Line|LCD Back Porch Line]]<sup>(WSC)</sup>
| style="text-align: right" | <tt style="white-space: nowrap">llll llll</tt>
| RW8
| Line (l)
|-
! $1A
| [[Display#LCD Status|LCD Status]]
| style="text-align: right" | <tt style="white-space: nowrap">...v vvhs</tt>
| RW8
| Volume icons (v), Headphone icon (h), Sleep (s)
|-
! $1C
| [[Display#LCD Mono Shade LUT|LCD Mono Shade LUT 0/1]]
| style="text-align: right" | <tt style="white-space: nowrap">1111 0000</tt>
| RW8
| Shade index
|-
! $1D
| [[Display#LCD Mono Shade LUT|LCD Mono Shade LUT 2/3]]
| style="text-align: right" | <tt style="white-space: nowrap">3333 2222</tt>
| RW8
| Shade index
|-
! $1E
| [[Display#LCD Mono Shade LUT|LCD Mono Shade LUT 4/5]]
| style="text-align: right" | <tt style="white-space: nowrap">5555 4444</tt>
| RW8
| Shade index
|-
! $1F
| [[Display#LCD Mono Shade LUT|LCD Mono Shade LUT 6/7]]
| style="text-align: right" | <tt style="white-space: nowrap">7777 6666</tt>
| RW8
| Shade index
|-
! $20
| [[Display#LCD Mono Palette|LCD Mono Palette 0]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $22
| [[Display#LCD Mono Palette|LCD Mono Palette 1]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $24
| [[Display#LCD Mono Palette|LCD Mono Palette 2]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $26
| [[Display#LCD Mono Palette|LCD Mono Palette 3]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $28
| [[Display#LCD Mono Palette|LCD Mono Palette 4]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $2A
| [[Display#LCD Mono Palette|LCD Mono Palette 5]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $2C
| [[Display#LCD Mono Palette|LCD Mono Palette 6]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $2E
| [[Display#LCD Mono Palette|LCD Mono Palette 7]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $30
| [[Display#LCD Mono Palette|LCD Mono Palette 8]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $32
| [[Display#LCD Mono Palette|LCD Mono Palette 9]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $34
| [[Display#LCD Mono Palette|LCD Mono Palette 10]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $36
| [[Display#LCD Mono Palette|LCD Mono Palette 11]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $38
| [[Display#LCD Mono Palette|LCD Mono Palette 12]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $3A
| [[Display#LCD Mono Palette|LCD Mono Palette 13]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $3C
| [[Display#LCD Mono Palette|LCD Mono Palette 14]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $3E
| [[Display#LCD Mono Palette|LCD Mono Palette 15]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! rowspan="10" | [[DMA]]<sup>(color)</sup>
! $40
| [[DMA#General DMA|GDMA Source Address Low]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll llll lll.</tt>
| RW16
| Linear address, low 16 bits (l)
|-
! $42
| [[DMA#General DMA|GDMA Source Address High]]
| style="text-align: right" | <tt style="white-space: nowrap">.... hhhh</tt>
| RW8
| Linear address, high 4 bits (h)
|-
! $44
| [[DMA#General DMA|GDMA Destination Address]]
| style="text-align: right" | <tt style="white-space: nowrap">aaaa aaaa aaaa aaa.</tt>
| RW16
| IRAM address (a)
|-
! $46
| [[DMA#General DMA|GDMA Length]]
| style="text-align: right" | <tt style="white-space: nowrap">bbbb bbbb bbbb bbb.</tt>
| RW16
| Bytes (b)
|-
! $48
| [[DMA#General DMA|GDMA Control]]
| style="text-align: right" | <tt style="white-space: nowrap">ed.. ....</tt>
| RW8
| Enable (e), Decrement (d)
|-
! $4A
| [[DMA#Sound DMA|SDMA Source Address Low]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll llll llll</tt>
| RW16
| Linear address, low 16 bits (l)
|-
! $4C
| [[DMA#Sound DMA|SDMA Source Address High]]
| style="text-align: right" | <tt style="white-space: nowrap">.... hhhh</tt>
| RW8
| Linear address, high 4 bits (h)
|-
! $4E
| [[DMA#Sound DMA|SDMA Length Low]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll llll llll</tt>
| RW16
| Length, low 16 bits (l)
|-
! $50
| [[DMA#Sound DMA|SDMA Length High]]
| style="text-align: right" | <tt style="white-space: nowrap">.... hhhh</tt>
| RW8
| Length, high 4 bits (h)
|-
! $52
| [[DMA#Sound DMA|SDMA Control]]
| style="text-align: right" | <tt style="white-space: nowrap">ed.t rhff</tt>
| RW8
| Enable (e), Decrement (d), Target (t),
Repeat (r), Hold (h), Frequency (f)
|-
! rowspan="2" | [[SoC]]<sup>(color)</sup>
! $60
| [[SoC#System Control 2|System Control 2]]
| style="text-align: right" | <tt style="white-space: nowrap">c4C. i?sl</tt>
| RW8
| Color (c), 4BPP (4), Chunky (C),<br/>
Cart I/O wait state (i), SRAM wait state (s),<br/>
Cart clock speed (l).
|-
! $62
| [[SoC#System Control 3|System Control 3]]
| style="text-align: right" | <tt style="white-space: nowrap">S... ...p</tt>
| RW8
| SwanCrystal (S), Power off (p)
|-
! rowspan="4" | [[Hyper Voice]]<sup>(color)</sup>
! $64
| [[Hyper Voice#Hyper Voice Output|Hyper Voice Left Output]]
| style="text-align: right" | <tt style="white-space: nowrap">ssss ssss ssss ssss</tt>
| W16
| Raw sample (s)
|-
! $66
| [[Hyper Voice#Hyper Voice Output|Hyper Voice Right Output]]
| style="text-align: right" | <tt style="white-space: nowrap">ssss ssss ssss ssss</tt>
| W16
| Raw sample (s)
|-
! $69
| [[Hyper Voice#Hyper Voice Input|Hyper Voice Right Input]]
| style="text-align: right" | <tt style="white-space: nowrap">ssss ssss</tt>
| W8
| Sample (s)
|-
! $6A
| [[Hyper Voice#Hyper Voice Control|Hyper Voice Control]]
| style="text-align: right" | <tt style="white-space: nowrap">.mmc ???? errr ffss</tt>
| RW16
| Mask (m), Channel reset (c), Enable (e),
Rate (r), Format (f), Shift (s)
|-
! rowspan="8" | [[Display]]<sup>(SC)</sup>
! $70
| LCD Timing Configuration 1?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $71
| LCD Timing Configuration 2?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $72
| LCD Timing Configuration 3?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $73
| LCD Timing Configuration 4?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $74
| LCD Timing Configuration 5?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $75
| LCD Timing Configuration 6?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $76
| LCD Timing Configuration 7?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $77
| LCD Timing Configuration 8?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! rowspan="22" | [[Sound]]
! $80
| [[Sound#Sound Channel Frequency|Sound Channel 1 Frequency]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .ddd dddd dddd</tt>
| RW16
| Divider (d)
|-
! $82
| [[Sound#Sound Channel Frequency|Sound Channel 2 Frequency]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .ddd dddd dddd</tt>
| RW16
| Divider (d)
|-
! $84
| [[Sound#Sound Channel Frequency|Sound Channel 3 Frequency]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .ddd dddd dddd</tt>
| RW16
| Divider (d)
|-
! $86
| [[Sound#Sound Channel Frequency|Sound Channel 4 Frequency]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .ddd dddd dddd</tt>
| RW16
| Divider (d)
|-
! $88
| [[Sound#Sound Channel Volume|Sound Channel 1 Volume]]
| style="text-align: right" | <tt style="white-space: nowrap">llll rrrr</tt>
| RW8
| Left (l), Right (r)
|-
! rowspan="2" | $89
| [[Sound#Sound Channel Volume|Sound Channel 2 Volume]]
| style="text-align: right" | <tt style="white-space: nowrap">llll rrrr</tt>
| RW8
| Left (l), Right (r)
|-
| [[Sound#Sound Channel 2 Voice Sample|Sound Channel 2 Voice Sample]]
| style="text-align: right" | <tt style="white-space: nowrap">ssss ssss</tt>
| RW8
| Sample (s)
|-
! $8A
| [[Sound#Sound Channel Volume|Sound Channel 3 Volume]]
| style="text-align: right" | <tt style="white-space: nowrap">llll rrrr</tt>
| RW8
| Left (l), Right (r)
|-
! $8B
| [[Sound#Sound Channel Volume|Sound Channel 4 Volume]]
| style="text-align: right" | <tt style="white-space: nowrap">llll rrrr</tt>
| RW8
| Left (l), Right (r)
|-
! $8C
| [[Sound#Sound Channel 3 Sweep Amount|Sound Channel 3 Sweep Amount]]
| style="text-align: right" | <tt style="white-space: nowrap">vvvv vvvv</tt>
| RW8
| Value (v)
|-
! $8D
| [[Sound#Sound Channel 3 Sweep Ticks|Sound Channel 3 Sweep Ticks]]
| style="text-align: right" | <tt style="white-space: nowrap">...t tttt</tt>
| RW8
| Ticks (t)
|-
! $8E
| [[Sound#Sound Channel 4 Noise Control|Sound Channel 4 Noise Control]]
| style="text-align: right" | <tt style="white-space: nowrap">...e rttt</tt>
| RW8
| Enable (e), Reset (r), Tap (t)
|-
! $8F
| [[Sound#Sound Wavetable Address|Sound Wavetable Address]]
| style="text-align: right" | <tt style="white-space: nowrap">wwww wwww</tt>
| RW8
| Address >> 6 (w)
|-
! $90
| [[Sound#Sound Channel Control|Sound Channel Control]]
| style="text-align: right" | <tt style="white-space: nowrap">nsv. 4321</tt>
| RW8
| Channel enable (1234)
Noise (n), Sweep (s), Voice (v)
|-
! $91
| [[Sound#Sound Output Control|Sound Output Control]]
| style="text-align: right" | <tt style="white-space: nowrap">H... hrrs</tt>
| RW8
| Headphones connected (H)
Headphone output (h)
Speaker output (s), range (r)
|-
! $92
| [[Sound#Sound Channel 4 LFSR Register|Sound Channel 4 LFSR Register]]
| style="text-align: right" | <tt style="white-space: nowrap">.rrr rrrr rrrr rrrr</tt>
| R16
| PRNG state (r)
|-
! $94
| [[Sound#Sound Channel 2 Voice Volume|Sound Channel 2 Voice Volume]]
| style="text-align: right" | <tt style="white-space: nowrap">.... lLrR</tt>
| RW8
| Left Half (l), Full (L)
Right Half (r), Full (R)
|-
! $95
| [[Sound#Sound Test|Sound Test]]
| style="text-align: right" | <tt style="white-space: nowrap">425? ???h</tt>
| RW8
|
|-
! $96
| [[Sound#Sound Channel Output Right|Sound Channel Output Right]]
| style="text-align: right" | <tt style="white-space: nowrap">.... ..ss ssss ssss</tt>
| R16
| Sample (s)
|-
! $98
| [[Sound#Sound Channel Output Left|Sound Channel Output Left]]
| style="text-align: right" | <tt style="white-space: nowrap">.... ..ss ssss ssss</tt>
| R16
| Sample (s)
|-
! $9A
| [[Sound#Sound Channel Output Sum|Sound Channel Output Sum]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .sss ssss ssss</tt>
| R16
| Sample (s)
|-
! $9E
| [[Sound#Sound Speaker Main Volume|Sound Speaker Main Volume]]<sup>(color)</sup>
| style="text-align: right" | <tt style="white-space: nowrap">.... ..vv</tt>
| RW8
| Main volume (v)
|-
! [[SoC]]
! $A0
| [[SoC#System Control|System Control]]
| style="text-align: right" | <tt style="white-space: nowrap">t??? swcl</tt>
| RW8
| Test OK (t), ROM wait state (s), ROM width (w),
Color system (c), Boot ROM lockout (l)
|-
! rowspan="5" | [[Timers]]
! $A2
| [[Timers#Timer Control|Timer Control]]
| style="text-align: right" | <tt style="white-space: nowrap">.... VvHh</tt>
| RW8
| Horizontal enable (h), auto reload (H)
Vertical enable (v), auto reload (V)
|-
! $A4
| [[Timers#Timer Reload|Horizontal Blank Timer Reload]]
| style="text-align: right" | <tt style="white-space: nowrap">tttt tttt tttt tttt</tt>
| RW16
| Ticks (t)
|-
! $A6
| [[Timers#Timer Reload|Vertical Blank Timer Reload]]
| style="text-align: right" | <tt style="white-space: nowrap">tttt tttt tttt tttt</tt>
| RW16
| Ticks (t)
|-
! $A8
| [[Timers#Timer Counter|Horizontal Blank Timer Counter]]
| style="text-align: right" | <tt style="white-space: nowrap">tttt tttt tttt tttt</tt>
| R16
| Ticks (t)
|-
! $AA
| [[Timers#Timer Counter|Vertical Blank Timer Counter]]
| style="text-align: right" | <tt style="white-space: nowrap">tttt tttt tttt tttt</tt>
| R16
| Ticks (t)
|-
! ?
! $AC
| ?
| style="text-align: right" | <tt style="white-space: nowrap">.... ...p</tt>
| W8?
| Power off (p)
|-
! rowspan="2" | [[Interrupts]]
! rowspan="2" | $B0
| [[Interrupts#Interrupt Vector Offset|Interrupt Vector Offset]]
| style="text-align: right" | <tt style="white-space: nowrap">VVVV V...</tt>
| W8
| Vector offset (V)
|-
| [[Interrupts#Interrupt Vector Request|Interrupt Vector Request]]
| style="text-align: right" | <tt style="white-space: nowrap">vvvv vvvv</tt>
| R8
| Requested vector offset (v)
|-
! rowspan="2" | [[UART]]
! $B1
| [[UART#Serial Receive Data|Serial Receive Data]]
| style="text-align: right" | <tt style="white-space: nowrap">dddd dddd</tt>
| R8
| Receive buffer data (d)
|-
! $B1
| [[UART#Serial Transmit Data|Serial Transmit Data]]
| style="text-align: right" | <tt style="white-space: nowrap">dddd dddd</tt>
| W8
| Transmit buffer data (d)
|-
! [[Interrupts]]
! $B2
| [[Interrupts#Interrupt Enable|Interrupt Enable]]
| style="text-align: right" | <tt style="white-space: nowrap">iiii iiii</tt>
| RW8
| Interrupt index (i)
|-
! rowspan="2" | [[UART]]
! $B3
| [[UART#Serial Status|Serial Status]]
| style="text-align: right" | <tt style="white-space: nowrap">eb.. .tor</tt>
| R8
| Enable (e), Baud rate (b),
Transfer ready (t), Overrun (o), Receive ready (r)
|-
! $B3
| [[UART#Serial Control|Serial Control]]
| style="text-align: right" | <tt style="white-space: nowrap">ebO. ....</tt>
| W8
| Enable (e), Baud rate (b), Reset Overrun (O)
|-
! [[Interrupts]]
! $B4
| [[Interrupts#Interrupt Status|Interrupt Status]]
| style="text-align: right" | <tt style="white-space: nowrap">iiii iiii</tt>
| R8
| Interrupt index (i)
|-
! [[Keypad]]
! $B5
| [[Keypad|Keypad Scan]]
| style="text-align: right" | <tt style="white-space: nowrap">.iii oooo</tt>
| RW8
| Input row (i), Output column (o)
|-
! rowspan="2" | [[Interrupts]]
! $B6
| [[Interrupts#Interrupt Acknowledge|Interrupt Acknowledge]]
| style="text-align: right" | <tt style="white-space: nowrap">iiii iiii</tt>
| W8
| Interrupt index (i)
|-
! $B7
| [[Interrupts#Interrupt NMI Control|Interrupt NMI Control]]
| style="text-align: right" | <tt style="white-space: nowrap">...b ....</tt>
| RW8
| Low battery (b)
|-
! rowspan="4" | [[EEPROM|Internal EEPROM]]
! $BA
| [[EEPROM#Internal EEPROM Data|Internal EEPROM Data]]
| style="text-align: right" | <tt style="white-space: nowrap">dddd dddd dddd dddd</tt>
| RW16
| Data (d)
|-
! $BC
| [[EEPROM#Internal EEPROM Command|Internal EEPROM Command]]
|
| RW16
|
|-
! rowspan="2" | $BE
| [[EEPROM#Internal EEPROM Status|Internal EEPROM Status]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .... p... ..RD</tt>
| R16
| Protected (p), Ready (R), Done (D)
|-
| [[EEPROM#Internal EEPROM Control|Internal EEPROM Control]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .... pewr ....</tt>
| W16
| Protect (p), Erase (e), Write (w), Read (r)
|-
! [[Mapper|Cartridge]]
! $C0<br />...<br />
$FF
| Cartridge I/O
|
| RW8
| Forwarded by the SoC
|}
== I/O port routing ==
The [[NEC V30MZ]] supports 16-bit I/O port addresses. The WonderSwan SoC routes them using the following algorithm:
* If an address is between <code>$00B8</code> and <code>$00BF</code> inclusive, it is routed to the internal EEPROM control block.
* If an address is between <code>$00C0</code> and <code>$00FF</code> inclusive, it is routed to the cartride bus.
* If an address's bits <code>0</code> through <code>8</code> inclusive are between <code>$000</code> and <code>$0B7</code> inclusive, they are routed to the SoC block.
* If none of these conditions are reached, open bus is read.
On the monochrome models, as well as color models in mono emulation, open bus is always <code>0x90</code>.
deb4155e11d7013b348a4037e88cbcc430f8978e
489
487
2025-01-21T16:05:43Z
Asie
351
use "Etc" over "Aux" to match official terminology
wikitext
text/x-wiki
The WonderSwan SoC has three general blocks of I/O port accesses:
{| class="wikitable"
! From !! To !! Holder !! Width !! Speed
|-
| $00 || $B7 || WonderSwan SoC || 16-bit || 1 cycle
|-
| $B8 || $BF || Internal EEPROM control || 16-bit || 1 cycle
|-
| $C0 || $FF || Cartridge bus || 8-bit || 1<sup>(color)</sup>/2 cycles (configurable)
|}
With the exception of internal EEPROM on the ASWAN, all unaligned 16-bit accesses can be converted to two 8-bit accesses with a 1-cycle penalty.
== I/O port map ==
* Superscripts are used to mark ports specific to a given mode or platform:
** Color mode: <sup>(color)</sup>. Such ports are only accessible when color mode is enabled through port <code>$60</code>.
** WS/WSC/SC console: <sup>(WS)</sup>, <sup>(WSC)</sup>, <sup>(SC)</sup>.
* If two Bits rows are provided, the second one refers to the "Color" mode.
* The Type can be: R - readable, W - writable, L - writable before boot ROM lockout, 8/16 - width (byte/word).
{| class="wikitable"
! Category
! Port
! Description
! Bits
! Type
! Notes
|-
! rowspan="45" | [[Display]]
! $00
| [[Display#Display Control|Display Control]]
| style="text-align: right" | <tt style="white-space: nowrap">..wo Ws21</tt>
| RW8
|
|-
! $01
| [[Display#Display Background|Display Background]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .sss</tt>
<tt style="white-space: nowrap">pppp iiii</tt>
| RW8
| Shade (s)
Palette (p), Index (i)
|-
! $02
| [[Display#Current Line|Display Current Line]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll</tt>
| R8
| Line (l)
|-
! $03
| [[Display#Interrupt Line|Display Interrupt Line]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll</tt>
| RW8
| Line (l)
|-
! $04
| [[Display#Sprite Table Address|Sprite Table Address]]
| style="text-align: right" | <tt style="white-space: nowrap">...a aaaa</tt>
<tt style="white-space: nowrap">..aa aaaa</tt>
| RW8
| Address >> 9 (a)
|-
! $05
| [[Display#Sprite Table First|Sprite Table First]]
| style="text-align: right" | <tt style="white-space: nowrap">.iii iiii</tt>
| RW8
| Index (i)
|-
! $06
| [[Display#Sprite Table Count|Sprite Table Count]]
| style="text-align: right" | <tt style="white-space: nowrap">cccc cccc</tt>
| RW8
| Count (c)
|-
! $07
| [[Display#Screen Address|Screen Address]]
| style="text-align: right" | <tt style="white-space: nowrap">.222 .111</tt>
<tt style="white-space: nowrap">2222 1111</tt>
| RW8
| Screen 1 address >> 11 (1)
Screen 2 address >> 11 (2)
|-
! $08
| [[Display#Screen 2 Window|Screen 2 Window Left]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $09
| [[Display#Screen 2 Window|Screen 2 Window Top]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $0A
| [[Display#Screen 2 Window|Screen 2 Window Right]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $0B
| [[Display#Screen 2 Window|Screen 2 Window Bottom]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $0C
| [[Display#Sprite Window|Sprite Window Left]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $0D
| [[Display#Sprite Window|Sprite Window Top]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $0E
| [[Display#Sprite Window|Sprite Window Right]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $0F
| [[Display#Sprite Window|Sprite Window Bottom]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $10
| [[Display#Screen Scroll|Screen 1 Scroll X]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $11
| [[Display#Screen Scroll|Screen 1 Scroll Y]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $12
| [[Display#Screen Scroll|Screen 2 Scroll X]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $13
| [[Display#Screen Scroll|Screen 2 Scroll Y]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $14
| [[Display#LCD Control|LCD Control]]
| style="text-align: right" | <tt style="white-space: nowrap">.... ..Ce</tt>
| RW8
| Contrast (C)<sup>(WSC)</sup>, Enable (e)
|-
! $15
| [[Display#LCD Icon Control|LCD Icon Control]]
| style="text-align: right" | <tt style="white-space: nowrap">..32 1hvs</tt>
| RW8
| Etc. 3 (3), Etc. 2 (2), Etc. 1 (1),
Horizontal (h), Vertical (v), Sleep (s)
|-
! $16
| [[Display#LCD Final Line|LCD Final Line]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll</tt>
| RW8
| Line (l)
|-
! $17
| [[Display#LCD Back Porch Line|LCD Back Porch Line]]<sup>(WSC)</sup>
| style="text-align: right" | <tt style="white-space: nowrap">llll llll</tt>
| RW8
| Line (l)
|-
! $1A
| [[Display#LCD Status|LCD Status]]
| style="text-align: right" | <tt style="white-space: nowrap">...v vvhs</tt>
| RW8
| Volume icons (v), Headphone icon (h), Sleep (s)
|-
! $1C
| [[Display#LCD Mono Shade LUT|LCD Mono Shade LUT 0/1]]
| style="text-align: right" | <tt style="white-space: nowrap">1111 0000</tt>
| RW8
| Shade index
|-
! $1D
| [[Display#LCD Mono Shade LUT|LCD Mono Shade LUT 2/3]]
| style="text-align: right" | <tt style="white-space: nowrap">3333 2222</tt>
| RW8
| Shade index
|-
! $1E
| [[Display#LCD Mono Shade LUT|LCD Mono Shade LUT 4/5]]
| style="text-align: right" | <tt style="white-space: nowrap">5555 4444</tt>
| RW8
| Shade index
|-
! $1F
| [[Display#LCD Mono Shade LUT|LCD Mono Shade LUT 6/7]]
| style="text-align: right" | <tt style="white-space: nowrap">7777 6666</tt>
| RW8
| Shade index
|-
! $20
| [[Display#LCD Mono Palette|LCD Mono Palette 0]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $22
| [[Display#LCD Mono Palette|LCD Mono Palette 1]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $24
| [[Display#LCD Mono Palette|LCD Mono Palette 2]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $26
| [[Display#LCD Mono Palette|LCD Mono Palette 3]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $28
| [[Display#LCD Mono Palette|LCD Mono Palette 4]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $2A
| [[Display#LCD Mono Palette|LCD Mono Palette 5]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $2C
| [[Display#LCD Mono Palette|LCD Mono Palette 6]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $2E
| [[Display#LCD Mono Palette|LCD Mono Palette 7]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $30
| [[Display#LCD Mono Palette|LCD Mono Palette 8]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $32
| [[Display#LCD Mono Palette|LCD Mono Palette 9]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $34
| [[Display#LCD Mono Palette|LCD Mono Palette 10]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $36
| [[Display#LCD Mono Palette|LCD Mono Palette 11]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $38
| [[Display#LCD Mono Palette|LCD Mono Palette 12]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $3A
| [[Display#LCD Mono Palette|LCD Mono Palette 13]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $3C
| [[Display#LCD Mono Palette|LCD Mono Palette 14]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $3E
| [[Display#LCD Mono Palette|LCD Mono Palette 15]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! rowspan="10" | [[DMA]]<sup>(color)</sup>
! $40
| [[DMA#General DMA|GDMA Source Address Low]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll llll lll.</tt>
| RW16
| Linear address, low 16 bits (l)
|-
! $42
| [[DMA#General DMA|GDMA Source Address High]]
| style="text-align: right" | <tt style="white-space: nowrap">.... hhhh</tt>
| RW8
| Linear address, high 4 bits (h)
|-
! $44
| [[DMA#General DMA|GDMA Destination Address]]
| style="text-align: right" | <tt style="white-space: nowrap">aaaa aaaa aaaa aaa.</tt>
| RW16
| IRAM address (a)
|-
! $46
| [[DMA#General DMA|GDMA Length]]
| style="text-align: right" | <tt style="white-space: nowrap">bbbb bbbb bbbb bbb.</tt>
| RW16
| Bytes (b)
|-
! $48
| [[DMA#General DMA|GDMA Control]]
| style="text-align: right" | <tt style="white-space: nowrap">ed.. ....</tt>
| RW8
| Enable (e), Decrement (d)
|-
! $4A
| [[DMA#Sound DMA|SDMA Source Address Low]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll llll llll</tt>
| RW16
| Linear address, low 16 bits (l)
|-
! $4C
| [[DMA#Sound DMA|SDMA Source Address High]]
| style="text-align: right" | <tt style="white-space: nowrap">.... hhhh</tt>
| RW8
| Linear address, high 4 bits (h)
|-
! $4E
| [[DMA#Sound DMA|SDMA Length Low]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll llll llll</tt>
| RW16
| Length, low 16 bits (l)
|-
! $50
| [[DMA#Sound DMA|SDMA Length High]]
| style="text-align: right" | <tt style="white-space: nowrap">.... hhhh</tt>
| RW8
| Length, high 4 bits (h)
|-
! $52
| [[DMA#Sound DMA|SDMA Control]]
| style="text-align: right" | <tt style="white-space: nowrap">ed.t rhff</tt>
| RW8
| Enable (e), Decrement (d), Target (t),
Repeat (r), Hold (h), Frequency (f)
|-
! rowspan="2" | [[SoC]]<sup>(color)</sup>
! $60
| [[SoC#System Control 2|System Control 2]]
| style="text-align: right" | <tt style="white-space: nowrap">c4C. i?sl</tt>
| RW8
| Color (c), 4BPP (4), Chunky (C),<br/>
Cart I/O wait state (i), SRAM wait state (s),<br/>
Cart clock speed (l).
|-
! $62
| [[SoC#System Control 3|System Control 3]]
| style="text-align: right" | <tt style="white-space: nowrap">S... ...p</tt>
| RW8
| SwanCrystal (S), Power off (p)
|-
! rowspan="4" | [[Hyper Voice]]<sup>(color)</sup>
! $64
| [[Hyper Voice#Hyper Voice Output|Hyper Voice Left Output]]
| style="text-align: right" | <tt style="white-space: nowrap">ssss ssss ssss ssss</tt>
| W16
| Raw sample (s)
|-
! $66
| [[Hyper Voice#Hyper Voice Output|Hyper Voice Right Output]]
| style="text-align: right" | <tt style="white-space: nowrap">ssss ssss ssss ssss</tt>
| W16
| Raw sample (s)
|-
! $69
| [[Hyper Voice#Hyper Voice Input|Hyper Voice Right Input]]
| style="text-align: right" | <tt style="white-space: nowrap">ssss ssss</tt>
| W8
| Sample (s)
|-
! $6A
| [[Hyper Voice#Hyper Voice Control|Hyper Voice Control]]
| style="text-align: right" | <tt style="white-space: nowrap">.mmc ???? errr ffss</tt>
| RW16
| Mask (m), Channel reset (c), Enable (e),
Rate (r), Format (f), Shift (s)
|-
! rowspan="8" | [[Display]]<sup>(SC)</sup>
! $70
| LCD Timing Configuration 1?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $71
| LCD Timing Configuration 2?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $72
| LCD Timing Configuration 3?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $73
| LCD Timing Configuration 4?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $74
| LCD Timing Configuration 5?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $75
| LCD Timing Configuration 6?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $76
| LCD Timing Configuration 7?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $77
| LCD Timing Configuration 8?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! rowspan="22" | [[Sound]]
! $80
| [[Sound#Sound Channel Frequency|Sound Channel 1 Frequency]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .ddd dddd dddd</tt>
| RW16
| Divider (d)
|-
! $82
| [[Sound#Sound Channel Frequency|Sound Channel 2 Frequency]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .ddd dddd dddd</tt>
| RW16
| Divider (d)
|-
! $84
| [[Sound#Sound Channel Frequency|Sound Channel 3 Frequency]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .ddd dddd dddd</tt>
| RW16
| Divider (d)
|-
! $86
| [[Sound#Sound Channel Frequency|Sound Channel 4 Frequency]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .ddd dddd dddd</tt>
| RW16
| Divider (d)
|-
! $88
| [[Sound#Sound Channel Volume|Sound Channel 1 Volume]]
| style="text-align: right" | <tt style="white-space: nowrap">llll rrrr</tt>
| RW8
| Left (l), Right (r)
|-
! rowspan="2" | $89
| [[Sound#Sound Channel Volume|Sound Channel 2 Volume]]
| style="text-align: right" | <tt style="white-space: nowrap">llll rrrr</tt>
| RW8
| Left (l), Right (r)
|-
| [[Sound#Sound Channel 2 Voice Sample|Sound Channel 2 Voice Sample]]
| style="text-align: right" | <tt style="white-space: nowrap">ssss ssss</tt>
| RW8
| Sample (s)
|-
! $8A
| [[Sound#Sound Channel Volume|Sound Channel 3 Volume]]
| style="text-align: right" | <tt style="white-space: nowrap">llll rrrr</tt>
| RW8
| Left (l), Right (r)
|-
! $8B
| [[Sound#Sound Channel Volume|Sound Channel 4 Volume]]
| style="text-align: right" | <tt style="white-space: nowrap">llll rrrr</tt>
| RW8
| Left (l), Right (r)
|-
! $8C
| [[Sound#Sound Channel 3 Sweep Amount|Sound Channel 3 Sweep Amount]]
| style="text-align: right" | <tt style="white-space: nowrap">vvvv vvvv</tt>
| RW8
| Value (v)
|-
! $8D
| [[Sound#Sound Channel 3 Sweep Ticks|Sound Channel 3 Sweep Ticks]]
| style="text-align: right" | <tt style="white-space: nowrap">...t tttt</tt>
| RW8
| Ticks (t)
|-
! $8E
| [[Sound#Sound Channel 4 Noise Control|Sound Channel 4 Noise Control]]
| style="text-align: right" | <tt style="white-space: nowrap">...e rttt</tt>
| RW8
| Enable (e), Reset (r), Tap (t)
|-
! $8F
| [[Sound#Sound Wavetable Address|Sound Wavetable Address]]
| style="text-align: right" | <tt style="white-space: nowrap">wwww wwww</tt>
| RW8
| Address >> 6 (w)
|-
! $90
| [[Sound#Sound Channel Control|Sound Channel Control]]
| style="text-align: right" | <tt style="white-space: nowrap">nsv. 4321</tt>
| RW8
| Channel enable (1234)
Noise (n), Sweep (s), Voice (v)
|-
! $91
| [[Sound#Sound Output Control|Sound Output Control]]
| style="text-align: right" | <tt style="white-space: nowrap">H... hrrs</tt>
| RW8
| Headphones connected (H)
Headphone output (h)
Speaker output (s), range (r)
|-
! $92
| [[Sound#Sound Channel 4 LFSR Register|Sound Channel 4 LFSR Register]]
| style="text-align: right" | <tt style="white-space: nowrap">.rrr rrrr rrrr rrrr</tt>
| R16
| PRNG state (r)
|-
! $94
| [[Sound#Sound Channel 2 Voice Volume|Sound Channel 2 Voice Volume]]
| style="text-align: right" | <tt style="white-space: nowrap">.... lLrR</tt>
| RW8
| Left Half (l), Full (L)
Right Half (r), Full (R)
|-
! $95
| [[Sound#Sound Test|Sound Test]]
| style="text-align: right" | <tt style="white-space: nowrap">425? ???h</tt>
| RW8
|
|-
! $96
| [[Sound#Sound Channel Output Right|Sound Channel Output Right]]
| style="text-align: right" | <tt style="white-space: nowrap">.... ..ss ssss ssss</tt>
| R16
| Sample (s)
|-
! $98
| [[Sound#Sound Channel Output Left|Sound Channel Output Left]]
| style="text-align: right" | <tt style="white-space: nowrap">.... ..ss ssss ssss</tt>
| R16
| Sample (s)
|-
! $9A
| [[Sound#Sound Channel Output Sum|Sound Channel Output Sum]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .sss ssss ssss</tt>
| R16
| Sample (s)
|-
! $9E
| [[Sound#Sound Speaker Main Volume|Sound Speaker Main Volume]]<sup>(color)</sup>
| style="text-align: right" | <tt style="white-space: nowrap">.... ..vv</tt>
| RW8
| Main volume (v)
|-
! [[SoC]]
! $A0
| [[SoC#System Control|System Control]]
| style="text-align: right" | <tt style="white-space: nowrap">t??? swcl</tt>
| RW8
| Test OK (t), ROM wait state (s), ROM width (w),
Color system (c), Boot ROM lockout (l)
|-
! rowspan="5" | [[Timers]]
! $A2
| [[Timers#Timer Control|Timer Control]]
| style="text-align: right" | <tt style="white-space: nowrap">.... VvHh</tt>
| RW8
| Horizontal enable (h), auto reload (H)
Vertical enable (v), auto reload (V)
|-
! $A4
| [[Timers#Timer Reload|Horizontal Blank Timer Reload]]
| style="text-align: right" | <tt style="white-space: nowrap">tttt tttt tttt tttt</tt>
| RW16
| Ticks (t)
|-
! $A6
| [[Timers#Timer Reload|Vertical Blank Timer Reload]]
| style="text-align: right" | <tt style="white-space: nowrap">tttt tttt tttt tttt</tt>
| RW16
| Ticks (t)
|-
! $A8
| [[Timers#Timer Counter|Horizontal Blank Timer Counter]]
| style="text-align: right" | <tt style="white-space: nowrap">tttt tttt tttt tttt</tt>
| R16
| Ticks (t)
|-
! $AA
| [[Timers#Timer Counter|Vertical Blank Timer Counter]]
| style="text-align: right" | <tt style="white-space: nowrap">tttt tttt tttt tttt</tt>
| R16
| Ticks (t)
|-
! ?
! $AC
| ?
| style="text-align: right" | <tt style="white-space: nowrap">.... ...p</tt>
| W8?
| Power off (p)
|-
! rowspan="2" | [[Interrupts]]
! rowspan="2" | $B0
| [[Interrupts#Interrupt Vector Offset|Interrupt Vector Offset]]
| style="text-align: right" | <tt style="white-space: nowrap">VVVV V...</tt>
| W8
| Vector offset (V)
|-
| [[Interrupts#Interrupt Vector Request|Interrupt Vector Request]]
| style="text-align: right" | <tt style="white-space: nowrap">vvvv vvvv</tt>
| R8
| Requested vector offset (v)
|-
! rowspan="2" | [[UART]]
! $B1
| [[UART#Serial Receive Data|Serial Receive Data]]
| style="text-align: right" | <tt style="white-space: nowrap">dddd dddd</tt>
| R8
| Receive buffer data (d)
|-
! $B1
| [[UART#Serial Transmit Data|Serial Transmit Data]]
| style="text-align: right" | <tt style="white-space: nowrap">dddd dddd</tt>
| W8
| Transmit buffer data (d)
|-
! [[Interrupts]]
! $B2
| [[Interrupts#Interrupt Enable|Interrupt Enable]]
| style="text-align: right" | <tt style="white-space: nowrap">iiii iiii</tt>
| RW8
| Interrupt index (i)
|-
! rowspan="2" | [[UART]]
! $B3
| [[UART#Serial Status|Serial Status]]
| style="text-align: right" | <tt style="white-space: nowrap">eb.. .tor</tt>
| R8
| Enable (e), Baud rate (b),
Transfer ready (t), Overrun (o), Receive ready (r)
|-
! $B3
| [[UART#Serial Control|Serial Control]]
| style="text-align: right" | <tt style="white-space: nowrap">ebO. ....</tt>
| W8
| Enable (e), Baud rate (b), Reset Overrun (O)
|-
! [[Interrupts]]
! $B4
| [[Interrupts#Interrupt Status|Interrupt Status]]
| style="text-align: right" | <tt style="white-space: nowrap">iiii iiii</tt>
| R8
| Interrupt index (i)
|-
! [[Keypad]]
! $B5
| [[Keypad|Keypad Scan]]
| style="text-align: right" | <tt style="white-space: nowrap">.iii oooo</tt>
| RW8
| Input row (i), Output column (o)
|-
! rowspan="2" | [[Interrupts]]
! $B6
| [[Interrupts#Interrupt Acknowledge|Interrupt Acknowledge]]
| style="text-align: right" | <tt style="white-space: nowrap">iiii iiii</tt>
| W8
| Interrupt index (i)
|-
! $B7
| [[Interrupts#Interrupt NMI Control|Interrupt NMI Control]]
| style="text-align: right" | <tt style="white-space: nowrap">...b ....</tt>
| RW8
| Low battery (b)
|-
! rowspan="4" | [[EEPROM|Internal EEPROM]]
! $BA
| [[EEPROM#Internal EEPROM Data|Internal EEPROM Data]]
| style="text-align: right" | <tt style="white-space: nowrap">dddd dddd dddd dddd</tt>
| RW16
| Data (d)
|-
! $BC
| [[EEPROM#Internal EEPROM Command|Internal EEPROM Command]]
|
| RW16
|
|-
! rowspan="2" | $BE
| [[EEPROM#Internal EEPROM Status|Internal EEPROM Status]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .... p... ..RD</tt>
| R16
| Protected (p), Ready (R), Done (D)
|-
| [[EEPROM#Internal EEPROM Control|Internal EEPROM Control]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .... pewr ....</tt>
| W16
| Protect (p), Erase (e), Write (w), Read (r)
|-
! [[Mapper|Cartridge]]
! $C0<br />...<br />
$FF
| Cartridge I/O
|
| RW8
| Forwarded by the SoC
|}
== I/O port routing ==
The [[NEC V30MZ]] supports 16-bit I/O port addresses. The WonderSwan SoC routes them using the following algorithm:
* If an address is between <code>$00B8</code> and <code>$00BF</code> inclusive, it is routed to the internal EEPROM control block.
* If an address is between <code>$00C0</code> and <code>$00FF</code> inclusive, it is routed to the cartride bus.
* If an address's bits <code>0</code> through <code>8</code> inclusive are between <code>$000</code> and <code>$0B7</code> inclusive, they are routed to the SoC block.
* If none of these conditions are reached, open bus is read.
On the monochrome models, as well as color models in mono emulation, open bus is always <code>0x90</code>.
fd42429958b990ea438ec015ca9705cbfde669bc
MediaWiki:Licenses
8
70
493
2025-02-05T15:57:02Z
Asie
351
Created page with "* Unknown license|I don't know * cc-by-4.0|Creative Commons Attribution 4.0 * cc0-1.0|CC0 1.0"
wikitext
text/x-wiki
* Unknown license|I don't know
* cc-by-4.0|Creative Commons Attribution 4.0
* cc0-1.0|CC0 1.0
377ec51ee7be5a4280f7f1d8e41c10d906f74f53
File:MobileWonderGate PCB top.jpg
6
71
494
2025-02-05T15:57:29Z
Asie
351
Top of the MobileWonderGate peripheral's PCB.
wikitext
text/x-wiki
== Summary ==
Top of the MobileWonderGate peripheral's PCB.
== Licensing ==
{{cc0-1.0}}
e52af2652c480f240e1f97614442cdce42ab4e3a
File:MobileWonderGate PCB bottom.jpg
6
72
495
2025-02-05T15:57:44Z
Asie
351
Bottom of the MobileWonderGate peripheral's PCB.
wikitext
text/x-wiki
== Summary ==
Bottom of the MobileWonderGate peripheral's PCB.
== Licensing ==
{{cc0-1.0}}
2f963ab367d1498cbba290a14838b96e6900337a
Template:Cc0-1.0
10
73
496
2025-02-05T15:58:14Z
Asie
351
Created page with "[[Category:CC0 1.0 files|{{PAGENAME}}]] [https://creativecommons.org/publicdomain/zero/1.0/ cc0-1.0 license text]"
wikitext
text/x-wiki
[[Category:CC0 1.0 files|{{PAGENAME}}]]
[https://creativecommons.org/publicdomain/zero/1.0/ cc0-1.0 license text]
f9517b7758fe476bda9a31fcd8dd1ca5a2d98d3c
WonderGate
0
14
497
196
2025-02-05T16:02:54Z
Asie
351
Initial hardware documentation
wikitext
text/x-wiki
The MobileWonderGate is a PPP Internet adapter for the WonderSwan, utilizing a PDC-standard mobile phone as a modem.
== Hardware ==
The MobileWonderGate features the following major components:
* Suntac D82525GC001 - CPU?
* ST M29W800AT - 8 Mbit NOR flash
* CY7C1021V33 - 1 Mbit SRAM
<gallery>
File:MobileWonderGate_PCB_top.jpg|PCB top|alt=PCB top
File:MobileWonderGate_PCB_bottom.jpg|PCB bottom|alt=PCB bottom
</gallery>
== Commands ==
All command communication uses the following format over 9,600 baud [[UART]]:
{| class="wikitable"
|-
! Offset !! Length !! Description
|-
| $00 || 1 || Command type
|-
| $01 || 1 || Zero?
|-
| $02 || 1 || Remaining length (from $03 onwards)
|-
| $03 || 1 || Command
|-
| $04 || ... || Parameters
|}
The following command IDs will be provided in the <code>Type:Command</code> format.
=== Check PDC status ($01:$00) ===
=== Initialize adapter ($01:$02) ===
=== Dial phone number ($01:$08) ===
=== Hang up ($01:$0A) ===
=== Set PPP login/password ($01:$10) ===
=== Set DNS servers ($01:$11) ===
=== Get adapter status ($02:$01) ===
=== Deinitialize adapter ($0F:$FF) ===
=== Create socket ($11:$01) ===
=== Connect to socket ($11:$03) ===
=== Close socket ($11:$07) ===
=== Get host name/IP address ($11:$08) ===
=== Read line from socket ($11:$0D) ===
=== Write bytes to socket ($11:$0E) ===
=== Read bytes from socket ($11:$0F) ===
== Servers ==
{| class="wikitable"
|-
! Software !! Hostname
|-
| rowspan="2" | MobileWonderGate (web browser)
| [[WonderGate/bplXX.mopera.ne.jp|bpl01.mopera.ne.jp]]
|-
| [[WonderGate/bplXX.mopera.ne.jp|bpl02.mopera.ne.jp]]
|-
| Pocket Fighter
|
|-
| Rainbow Islands - Putty's Party
|
|-
| Star Hearts
|
|-
| Terrors 2
| [[WonderGate/terrors2.wgg.channel.or.jp|terrors2.wgg.channel.or.jp]]
|-
| Wizardry
|
|}
461c03c0ea01acca0a726f694f1df65eb52e6d19
498
497
2025-02-05T17:33:53Z
Asie
351
/* Hardware */
wikitext
text/x-wiki
The MobileWonderGate is a PPP Internet adapter for the WonderSwan, utilizing a PDC-standard mobile phone as a modem.
== Hardware ==
The MobileWonderGate features the following major components:
* Suntac D82525GC001 - CPU?
* ST M29W800AT - 8 Mbit NOR flash
* CY7C1021V33 - 1 Mbit SRAM
The connector used for the PHS cable appears to be a 10-pin JST SH-1.0, but this has to be verified.
<gallery>
File:MobileWonderGate_PCB_top.jpg|PCB top|alt=PCB top
File:MobileWonderGate_PCB_bottom.jpg|PCB bottom|alt=PCB bottom
</gallery>
== Commands ==
All command communication uses the following format over 9,600 baud [[UART]]:
{| class="wikitable"
|-
! Offset !! Length !! Description
|-
| $00 || 1 || Command type
|-
| $01 || 1 || Zero?
|-
| $02 || 1 || Remaining length (from $03 onwards)
|-
| $03 || 1 || Command
|-
| $04 || ... || Parameters
|}
The following command IDs will be provided in the <code>Type:Command</code> format.
=== Check PDC status ($01:$00) ===
=== Initialize adapter ($01:$02) ===
=== Dial phone number ($01:$08) ===
=== Hang up ($01:$0A) ===
=== Set PPP login/password ($01:$10) ===
=== Set DNS servers ($01:$11) ===
=== Get adapter status ($02:$01) ===
=== Deinitialize adapter ($0F:$FF) ===
=== Create socket ($11:$01) ===
=== Connect to socket ($11:$03) ===
=== Close socket ($11:$07) ===
=== Get host name/IP address ($11:$08) ===
=== Read line from socket ($11:$0D) ===
=== Write bytes to socket ($11:$0E) ===
=== Read bytes from socket ($11:$0F) ===
== Servers ==
{| class="wikitable"
|-
! Software !! Hostname
|-
| rowspan="2" | MobileWonderGate (web browser)
| [[WonderGate/bplXX.mopera.ne.jp|bpl01.mopera.ne.jp]]
|-
| [[WonderGate/bplXX.mopera.ne.jp|bpl02.mopera.ne.jp]]
|-
| Pocket Fighter
|
|-
| Rainbow Islands - Putty's Party
|
|-
| Star Hearts
|
|-
| Terrors 2
| [[WonderGate/terrors2.wgg.channel.or.jp|terrors2.wgg.channel.or.jp]]
|-
| Wizardry
|
|}
14be966f7e0c8c2ac09e1e310823325a9c4da220
ROM header
0
5
499
406
2025-02-21T19:34:24Z
Asie
351
/* Flags ($C) */
wikitext
text/x-wiki
Every WonderSwan ROM contains a header. It is stored at the end - final sixteen bytes - of the ROM image.
== ROM header ==
Parts of this header are validated or otherwise used by the console's [[boot ROM]] - they are marked in '''bold'''.
{| class="wikitable"
|+ Header contents
|-
! Offset !! Length !! Contents
|-
| '''$0''' || '''5''' || Far jump instruction: '''0xEA''', offset, segment.
|-
| '''$5''' || '''1''' || '''Maintenance'''
|-
| $6 || 1 || Developer/Publisher ID
|-
| $7 || 1 || Color
|-
| $8 || 1 || Game ID (binary-coded decimal)
|-
| '''$9''' || '''1''' || '''Game version? / Safe mode'''
|-
| $A || 1 || ROM size
|-
| $B || 1 || Save type/size
|-
| '''$C''' || '''1''' || '''Flags'''
|-
| $D || 1 || Mapper
|-
| $E || 2 || Checksum (sum of all ROM bytes excluding the checksum)
|}
=== Maintenance ($5) ===
----
<pre>
7 bit 0
---- ----
s... 0000
| ||||
| ++++- Must be zero; otherwise the console will prohibit execution.
| Purpose unknown.
+--------- (Color) Splash bypass: 0 = Disable, 1 = Enable.
Bypasses the custom boot splash stored in the console's
internal EEPROM; presumably used for bricked console recovery.
</pre>
=== Developer/Publisher ID ($6) ===
----
{| class="wikitable"
|+ Known official developer/publisher IDs
|-
! ID !! Publisher code !! Publisher
|-
| $01 || BAN || Bandai
|-
| $02 || TAT || Taito
|-
| $03 || TMY || Tomy
|-
| $04 || KEX || Koei
|-
| $05 || DTE || Data East
|-
| $06 || AAE || Asmik Ace
|-
| $07 || MDE || Media Entertainment
|-
| $08 || NHB || Nichibutsu
|-
| $0A || CCJ || Coconuts Japan
|-
| $0B || SUM || Sammy
|-
| $0C || SUN || Sunsoft
|-
| $0D || PAW || Mebius
|-
| $0E || BPR || Banpresto
|-
| $10 || JLC || Jaleco
|-
| $11 || MGA || Imagineer
|-
| $12 || KNM || Konami
|-
| $16 || KBS || Kobunsha
|-
| $17 || BTM || Bottom Up
|-
| $18 || KGT || Kaga Tech
|-
| $19 || SRV || Sunrise
|-
| $1A || CFT || Cyber Front
|-
| $1B || MGH || Megahouse
|-
| $1D || BEC || Interbec
|-
| $1E || NAP || Nihon Application
|-
| $1F || BVL || Bandai Visual
|-
| $20 || ATN || Athena
|-
| $21 || KDX || KID
|-
| $22 || HAL || HAL Corporation
|-
| $23 || YKE || Yuki Enterprise
|-
| $24 || OMN || Omega Micott
|-
| $25 || LAY || Layup
|-
| $26 || KDK || Kadokawa Shoten
|-
| $27 || SHL || Shall Luck
|-
| $28 || SQR || Squaresoft
|-
| $2A || SCC || ? (SUNCORPORATION?)
|-
| $2B || TMC || Tom Create
|-
| $2D || NMC || Namco
|-
| $2E || SES || Soeishinsha
|-
| $2F || HTR || Hearty Robin
|-
| $31 || VGD || Vanguard
|-
| $32 || MGT || Megatron
|-
| $33 || WIZ || Wiz
|-
| $35 || TAN || Tanita
|-
| $36 || CPC || Capcom
|}
Note that IDs $00 and $01 are used across a variety of commercial games. Homebrew is known to use arbitrary values in this field.
=== Color ($7) ===
----
<pre>
7 bit 0
---- ----
???? ???c
|
+- 0 = Monochrome only, 1 = Supports Color mode.
</pre>
=== Game version? / Safe mode ($9) ===
----
<pre>
7 bit 0
---- ----
pvvv vvvv
|||| ||||
|+++ ++++- Game version?
+--------- Internal EEPROM write protect: 0 = Enable, 1 = Disable.
This prohibits writing to the internal EEPROM for addresses
0x60 and above (user settings, custom splash screen).
Games are expected to enable write protection; however, the
WonderWitch is factory configured with it disabled.
</pre>
=== ROM size ($A) ===
----
Unofficial/inferred ROM size values are marked in ''italic''.
{| class="wikitable"
|+ ROM size values
|-
! ID !! Size
|-
| ''$00'' || ''1 Mbit (128 KiB)''
|-
| ''$01'' || ''2 Mbit (256 KiB)''
|-
| $02 || 4 Mbit (512 KiB)
|-
| $03 || 8 Mbit (1 MiB)
|-
| $04 || 16 Mbit (2 MiB)
|-
| ''$05'' || ''24 Mbit (3 MiB)''
|-
| $06 || 32 Mbit (4 MiB)
|-
| ''$07'' || ''48 Mbit (6 MiB)''
|-
| $08 || 64 Mbit (8 MiB)
|-
| $09 || 128 Mbit (16 MiB)
|-
| ''$0A'' || ''256 Mbit (32 MiB)''
|-
| ''$0B'' || ''512 Mbit (64 MiB)''
|}
Note that ROM sizes over 16 MiB are not supported by the [[Bandai 2001]] mapper. The [[Bandai 2003]] mapper is limited to 64 MiB.
=== Save type/size ($B) ===
----
{| class="wikitable"
|+ Save type values
|-
! ID !! Type !! Size
|-
| $00 || colspan="2" style="text-align:center;" | None
|-
| $01 || rowspan="5" | SRAM || rowspan="2" | 256 Kbit (32 KiB)
|-
| $02
|-
| $03 || 1 Mbit (128 KiB)
|-
| $04 || 2 Mbit (256 KiB)
|-
| $05 || 4 Mbit (512 KiB)
|-
| $10 || rowspan="3" | EEPROM || 1 Kbit (128 B)
|-
| $20 || 16 Kbit (2 KiB)
|-
| $50 || 8 Kbit (1 KiB)
|}
Note that while ID <code>$01</code> is commonly documented as <code>64 Kbit</code>, all known cartridges using that value come with <code>256 Kbit</code> SRAM chips. This requires further investigation.
=== Flags ($C) ===
----
<pre>
7 bit 0
---- ----
???? ?SBv
|||
||+- Starting screen orientation: 0 = horizontal, 1 = vertical
|| Controls the splash screen's orientation.
|+-- Cartridge ROM width: 0 = 8-bit, 1 = 16-bit
+--- Cartridge ROM wait state: 0 = +0 cycles, 1 = +1
</pre>
Flag bits 1 and 2 correspond to [[SoC#System Control|System Control]] bits 2 and 3.
=== Mapper ($D) ===
----
{| class="wikitable"
|+ Known mapper types
|-
! ID !! Mapper
|-
| $00 || [[Bandai 2001]] or [[KARNAK]]
|-
| $01 || [[Bandai 2003]]
|}
37c540adf1adf47e606a78354c88138af73ca9ca
Display/IO Ports
0
74
500
2025-02-22T15:21:00Z
Asie
351
Created page with "== Graphics I/O ports == {{Anchor|Display Control}} === Display Control ($00) === <pre> 7 bit 0 ---- ---- ..wo Ws21 || |||| || |||+- Enable Screen 1 layer || ||+-- Enable Screen 2 layer || |+--- Enable Sprite layer || +---- Enable Sprite window |+------ Screen 2 tiles are drawn (if window enabled): | 0 = inside window, | 1 = outside window. +------- Enable Screen 2 window </pre> {{Anchor|Display Background}} === Display Background Co..."
wikitext
text/x-wiki
== Graphics I/O ports ==
{{Anchor|Display Control}}
=== Display Control ($00) ===
<pre>
7 bit 0
---- ----
..wo Ws21
|| ||||
|| |||+- Enable Screen 1 layer
|| ||+-- Enable Screen 2 layer
|| |+--- Enable Sprite layer
|| +---- Enable Sprite window
|+------ Screen 2 tiles are drawn (if window enabled):
| 0 = inside window,
| 1 = outside window.
+------- Enable Screen 2 window
</pre>
{{Anchor|Display Background}}
=== Display Background Color ($01) ===
<pre>
(mono) (color)
7 bit 0 7 bit 0
---- ---- ---- ----
.... .sss pppp iiii
||| |||| ||||
+++- Value |||| ++++- Index in palette (0-15)
(0-7) ++++------ Color palette (0-15)
</pre>
{{Anchor|Display Current Line}}
=== Display Current Line ($02 read) ===
The current line being drawn by the display.
Note that lines are sent to the display with a one-line delay. This matters for color palette or shade LUT manipulation; changing these values when <code>current line == 1</code> will actually affect line 0.
{{Anchor|Display Interrupt Line}}
=== Display Interrupt Line ($03) ===
The line to emit an interrupt on.
{{Anchor|Sprite Table Address}}
=== Sprite Table Address ($04) ===
<pre>
7 bit 0
---- ----
..Aa aaaa
|| ||||
|+-++++- Address (bits 9-13)
+------- Address (bit 14) - color only
</pre>
{{Anchor|Sprite Table First}}
=== Sprite Table First ($05) ===
<pre>
7 bit 0
---- ----
.iii iiii
||| ||||
+++-++++- Index of first sprite entry to draw (0-127)
</pre>
{{Anchor|Sprite Table Count}}
=== Sprite Table Count ($06) ===
<pre>
7 bit 0
---- ----
cccc cccc
|||| ||||
++++-++++- Count of sprite entries to draw (1-128)
</pre>
{{Anchor|Screen Address}}
=== Screen Address ($07) ===
<pre>
7 bit 0
---- ----
2222 1111
|||| ||||
|||| |+++- Screen 1 address (bits 11-13)
|||| +---- Screen 1 address (bit 14) - color only
|+++------ Screen 2 address (bits 11-13)
+--------- Screen 2 address (bit 14) - color only
</pre>
{{Anchor|Screen 2 Window}}
=== Screen 2 Window Left ($08) ===
=== Screen 2 Window Top ($09) ===
=== Screen 2 Window Right ($0A) ===
=== Screen 2 Window Bottom ($0B) ===
The X and Y coordinates of the Screen 2 window.
Note that all coordinates are inclusive; for example, for a 200x100 window in the top-left corner, the values should be set as follows:
* Left - 0,
* Top - 0,
* Right - 199,
* Bottom - 99.
{{Anchor|Sprite Window}}
=== Sprite Window Left ($0C) ===
=== Sprite Window Top ($0D) ===
=== Sprite Window Right ($0E) ===
=== Sprite Window Bottom ($0F) ===
The X and Y coordinates of the Sprite window.
Note that all coordinates are inclusive.
{{Anchor|Screen Scroll}}
=== Screen 1 Scroll X ($10) ===
=== Screen 1 Scroll Y ($11) ===
The X and Y coordinates that Screen 1 is scrolled by.
For example, setting Scroll X to 24 and Scroll Y to 8 will omit, in 8x8 tile units, the first three rows and the first two columns of the 32x32 screen.
=== Screen 2 Scroll X ($12) ===
=== Screen 2 Scroll Y ($13) ===
The X and Y coordinates that Screen 2 is scrolled by.
== Palette I/O ports ==
These I/O ports are only used in the monochrome display mode. Color display modes use the memory locations <tt>$FE00</tt> - <tt>$FFFF</tt> to store the color palette.
{{Anchor|LCD Mono Shade LUT}}
=== Mono Shade LUT ($1C, $1D, $1E, $1F) ===
<pre>
$1C $1D $1E $1F
7 bit 0 7 bit 0 7 bit 0 7 bit 0
---- ---- ---- ---- ---- ---- ---- ----
1111 0000 3333 2222 5555 4444 7777 6666
|||| |||| |||| |||| |||| |||| |||| ||||
|||| |||| |||| |||| |||| |||| |||| ++++- Shade for LUT index 6
|||| |||| |||| |||| |||| |||| ++++------ Shade for LUT index 7
|||| |||| |||| |||| |||| ++++------------- Shade for LUT index 4
|||| |||| |||| |||| ++++------------------ Shade for LUT index 5
|||| |||| |||| ++++------------------------- Shade for LUT index 2
|||| |||| ++++------------------------------ Shade for LUT index 3
|||| ++++------------------------------------- Shade for LUT index 0
++++------------------------------------------ Shade for LUT index 1
</pre>
{{Anchor|LCD Mono Palette}}
=== Mono Palette 0..15 ($20, $21 .. $3E, $3F) ===
The monochrome palette is laid out as sixteen words:
<pre>
N+1 N
15 bit 8 7 bit 0
---- ---- ---- ----
.333 .222 .111 .000
||| ||| ||| |||
||| ||| ||| +++- Shade LUT index for color 0
||| ||| +++------ Shade LUT index for color 1
||| +++------------ Shade LUT index for color 2
+++----------------- Shade LUT index for color 3
</pre>
== LCD I/O ports ==
{{Anchor|LCD Control}}
=== LCD Control ($14) ===
<pre>
7 bit 0
---- ----
.... ..Ce
||
|+- LCD enable: 0 = sleep, 1 = enabled
+-- Contrast (WSC): 0 = low, 1 = high
</pre>
The enable bit controls whether or not the LCD screen is displaying graphics; if sleeping, it displays nothing (all white). Note that icon segments continue displaying regardless of this configuration.
Note that port $1A provides a separate LCD sleep bit; the display will be disabled in the same way if any of those bits are set to "sleep".
The contrast bit allows enabling a "high contrast" mode: this works by having the LCD drive two lines with data received from the SoC - so the first line of the LCD is driven by the first line from the SoC, then additionally by the second line from the SoC.
{{Anchor|LCD Icon Control}}
=== LCD Icon Control ($15) ===
<pre>
7 bit 0
---- ----
..32 1hvs
|| ||||
|| |||+- Sleep (Star)
|| ||+-- Vertical orientation
|| |+--- Horizontal orientation
|| +---- Etc. 1 (Small circle)
|+------ Etc. 2 (Medium circle)
+------- Etc. 3 (Large circle)
</pre>
== LCD internal I/O ports ==
These I/O ports are not used and most likely not intended for use by commercial games.
{{Anchor|LCD Final Line}}
=== LCD Final Line ($16) ===
The final line preceding line counter restart and the beginning of active display. By default, this is set to 158, which equals 159 total lines per frame.
It is said setting this register to an odd value on SwanCrystal has an adverse effect to the LCD panel,<ref>[http://daifukkat.su/docs/wsman/#REG_LCD_VTOTAL REG_LCD_VTOTAL - WSMan]</ref> but the exact mechanism is unknown. A starting point for research is that an even value, or odd total line count, is needed to balance positive and negative charges on the LCD.<ref>W.A. Steer. "[http://www.techmind.org/lcd/ LCD monitor technology and tests]". Techmind, 2011-12-03. Accessed 2024-11-19.</ref>
{{Anchor|LCD Back Porch Line}}
=== LCD Back Porch Line ($17, WSC only) ===
This port is available on the WonderSwan Color only - not the SwanCrystal!
The final line preceding the vertical back porch; by default, this should be set to 155.
The vertical back porch of the LCD is assumed to be 4 lines by some hardware, including IPS mods, as well as the official "TV Swan" capture device. Given that the first visible line is sent to the LCD on the display's line 1, this should be generally set to <code>LCD Final Line - 3</code>.
Conversely, it is said moving this value closer to vertical blank improves LCD visibility<ref>[http://daifukkat.su/docs/wsman/#REG_LCD_VSYNC REG_LCD_VSYNC - WSMan]</ref>, but the exact mechanism is unknown.
{{Anchor|LCD Status}}
=== LCD Status ($1A) ===
<pre>
7 bit 0
---- ----
...v vvhs
| ||||
| |||+- LCD sleep: 0 = no, 1 = sleep
| ||+-- Headphone icon
| ||
| || Volume icons:
| |+--- - Volume B (medium, high)
| +---- - Volume A (low, high)
+------ - Speaker
</pre>
The LCD sleep bit is writable. The remaining bits are read-only.
The volume and headphone icon are enabled when pressing the SOUND button, according to this algorithm:
* If headphones are plugged in, show the Headphone icon.
* If headphones are not plugged in, show the Speaker icon and the following Volume icons:
** Volume level 0: None
** Volume level 1: A
** Volume level 2: B
** Volume level 3: A, B
* Hide all visible icons after 128 frames from the last press.
TODO: This documents the WonderSwan Color. The specifics probably work differently on the mono WonderSwan.
=== TFT LCD Configuration ($70, $71, $72, $73, $74, $75, $76, $77 SwanCrystal only) ===
These eight bytes are read from internal EEPROM and configure unknown aspects of the console's TFT LCD panel.
They are only writable while the [[Boot ROM]] is unlocked - locking has the side effect of making them read-only.
== Notes ==
<references />
e1296a5be1b18f00356dcda3d2fe5e1c603b7d79
Display
0
26
501
492
2025-02-22T15:21:41Z
Asie
351
move I/O ports out
wikitext
text/x-wiki
The WonderSwan's display functionality generally consists of:
* a 224x144 display clocked at ~75.47 Hz by default, capable of displaying:
** up to sixteen distinct shades of gray
** 12-bit RGB444 color<sup>(color)</sup>
* two 32x32 background layers ("screens"), capable of displaying up to 512 (1024<sup>(color)</sup>) distinct tiles,
* a sprite layer, capable of displaying up to 128 8x8 sprites (up to 32 per line),
* a bar of LCD icon segments to the bottom (WS) or right (WSC/SC) of the display, usable as additional indicators.
== Components ==
=== Tiles ===
The WonderSwan can display up to 512 distinct tiles at a time, with two bits of palette index information for every pixel.
The WonderSwan Color expands this to 1024 distinct tiles for background (with 512 remaining the limit for sprites), while also introducing modes with four bits of palette index information for every pixel.
==== 2 bits per pixel, planar ====
The tiles are stored in an interleaved planar format, with two bits total for every pixel. Odd bytes store the first plane (bit 0 of each pixel), while even bytes store the second plane (bit 1 of each pixel).
<pre>
tile data (16 bytes)
01 7C 01 FC 00 C0 18 D8 18 D8 00 C0 00 00 C0 00
||
\/
plane 0 plane 1
7 bit 0 7 bit 0 full tile
---- ---- ---- ----
.... ...1 = 01 .222 22.. = 7C .22222.1
.... ...1 = 01 2222 22.. = FC 222222.1
.... .... = 00 22.. .... = C0 22......
...1 1... = 18 22.2 2... = D8 --\ 22.33...
...1 1... = 18 22.2 2... = D8 --/ 22.33...
.... .... = 00 22.. .... = C0 22......
.... .... = 00 .... .... = 00 ........
11.. .... = C0 .... .... = 00 11......
</pre>
This matches the format used by the Game Boy.
==== 4 bits per pixel, planar ====
This mode is stored in a manner similar to the 2 bits per pixel mode, but with an additional two planes for bit 2 and bit 3 of each pixel's palette index, expanding the tile data to 32 bytes.
<pre>
tile data (32 bytes)
54 32 01 00 54 32 F1 00 54 32 01 F0 54 32 F1 F0 04 02 01 00 F8 04 02 01 00 F8 04 02 00 00 F8 04
||
\/
plane 0 plane 1 plane 2 plane 3
7 bit 0 7 bit 0 7 bit 0 7 bit 0 full tile
---- ---- ---- ---- ---- ---- ---- ----
.1.1 .1.. = 54 ..22 ..2. = 32 .... ...4 = 01 .... .... = 00 .123.124
.1.1 .1.. = 54 ..22 ..2. = 32 4444 ...4 = F1 .... .... = 00 4567.124
.1.1 .1.. = 54 ..22 ..2. = 32 .... ...4 = 01 8888 .... = F0 89AB.124
.1.1 .1.. = 54 ..22 ..2. = 32 4444 ...4 = F1 8888 .... = F0 --\ CDEF.124
.... .1.. = 04 .... ..2. = 02 .... ...4 = 01 .... .... = 00 --/ .....124
1111 1... = F8 .... .2.. = 04 .... ..4. = 02 .... ...8 = 01 11111248
.... .... = 00 2222 2... = F8 .... .4.. = 04 .... ..8. = 02 2222248.
.... .... = 00 .... .... = 00 4444 4... = F8 .... .8.. = 04 444448..
</pre>
This format matches the one used by the Sega Master System and Game Gear family of consoles.
==== 4 bits per pixel, packed ====
Unlike the previous two formats, in the packed format each byte stores the complete palette index of two pixels - the high four bits store the left pixel, while the low four bits store the right pixel. Four such bytes make up a row of eight pixels from left to right.
<pre>
tile data (32 bytes)
01 23 01 24 45 67 01 24 89 AB 01 24 CD EF 01 24 00 00 01 24 11 11 12 48 22 22 24 80 44 44 48 00
||
\/
byte 0 1 2 3
bits 7-4 3-0 7-4 3-0 7-4 3-0 7-4 3-0
pixel 0 1 2 3 4 5 6 7 full tile
--- --- --- --- --- --- --- ---
. 1 = 01 2 3 = 23 . 1 = 01 2 4 = 24 .123.124 = 01 23 01 24
4 5 = 45 6 7 = 67 . 1 = 01 2 4 = 24 4567.124 = 45 67 01 24
8 9 = 89 A B = AB . 1 = 01 2 4 = 24 89AB.124 = 89 AB 01 24
C D = CD E F = EF . 1 = 01 2 4 = 24 --\ CDEF.124 = CD EF 01 24
. . = 00 . . = 00 . 1 = 01 2 4 = 24 --/ .....124 = 00 00 01 24
1 1 = 11 1 1 = 11 1 2 = 12 4 8 = 48 11111248 = 11 11 12 48
2 2 = 22 2 2 = 22 2 4 = 24 8 . = 80 2222248. = 22 22 24 80
4 4 = 44 4 4 = 44 4 8 = 48 . . = 00 444448.. = 44 44 48 00
</pre>
This format matches the one used by the Mega Drive console.
=== Palettes ===
The display system provides sixteen different palettes that can be used to color or shade tiles.
* Palettes 0-7 can be used for the two screens only;
* Palettes 8-15 can be used for both screens and sprites.
==== Mono ====
In ''mono'' modes, palettes are stored in I/O ports 0x20 through 0x3F. Each palette contains four three-bit entries, which are pointers into a global, four-bit shade lookup table:
<pre>
Palette Global shade LUT
1 ===========> 2 ==========================> 5
^ (0, 2, 4, 6) ^ (1, 3, 5, 7, 9, 11, 13, 15) ^
| | |
Palette index Value Displayed shade
</pre>
The shade value corresponds to the darkness of the pixel: shade 0 is the brightest, while shade 15 is the darkest.
==== Color ====
In ''color'' modes, palettes are stored as 16-bit words in memory addresses 0xFE00 through 0xFFFF, without additional lookup tables:
<pre>
Address
15 bit 8 7 bit 0
---- ---- ---- ----
1111 111p pppi iii.
| |||| |||
| |||+-+++-- Index in palette (0-15)
+--+++------- Palette number (0-15)
Data
15 bit 8 7 bit 0
---- ---- ---- ----
.... rrrr gggg bbbb
|||| |||| ||||
|||| |||| ++++- Blue (0-15)
|||| ++++------ Green (0-15)
++++------------ Red (0-15)
</pre>
In 2 bits per pixel color modes, palette entries 4 through 15 are not used.
==== Transparency ====
In two bit per pixel modes:
* Palettes 0-3 and 8-11 are ''opaque''. For these, index zero is treated as opaque.
* Palettes 4-7 and 12-15 are ''translucent''. For these, index zero is treated as transparent. This means that the color/shade value set to it is ignored, and only three distinct colors/shades can be used for tiles.
In four bit per pixel modes, all palettes are ''translucent''. Index zero is always treated as transparent, and fifteen different colors/shades can be used for tiles.
=== Background color ===
The background color is displayed if no ''opaque'' pixel from screens or sprites is drawn. This color is set in I/O port ''0x01'':
* In mono modes, it is set to an entry in the shade lookup table (0-7),
* In color modes, it is set to an entry in the color palette (0-255). Note that this allows you to use the first color (color zero) of any palette, which is normally ignored and assumed to be ''transparent''.
=== Screens ===
A screen is a layout of tiles. Each cell in a screen controls one 8x8 tile.
The display system can show two distinct screens simultaneously. It also supports hardware flipping of tiles, both horizontally and vertically.
The size of each screen is fixed at 32x32 cells or 256x256 pixels, while each cell is stored as a two-byte word:
<pre>
Address
15 bit 8 7 bit 0
---- ---- ---- ----
0bbb byyy yyxx xxx.
||| |||| |||| |||
||| |||| ||++-+++-- X coordinate (0-31)
||| |+++--++-------- Y coordinate (0-31)
+++-+--------------- Base address (from I/O port)
Data
15 bit 8 7 bit 0
---- ---- ---- ----
vhbp pppt tttt tttt
|||| |||| |||| ||||
|||| |||+--++++-++++- Tile index (0-511)
|||+-+++------------- Palette (0-15)
||+------------------ Tile bank (0-1) - color only
|+------------------- Horizontal flip
+-------------------- Vertical flip
</pre>
In ''color'' modes, the tile bank selects between tiles 0-511 and 512-1023.
=== Sprites ===
The display system can show up to 128 sprites at once.
Sprites are always drawn in front of Screen 1, but they can be drawn in front of or behind Screen 2.
Sprites are stored in a sprite table in the console's internal RAM. It consists of up to 128 four-byte entries, of which any sequential slice can be displayed:
<pre>
(Byte 1) (Byte 0)
15 bit 8 7 bit 0
---- ---- ---- ----
vhPi pppt tttt tttt
|||| |||| |||| ||||
|||| |||+--++++-++++- Tile index (0-511) - only tile bank 0
|||| +++------------- Palette (0-7) - mapped to screen palettes 8-15
|||+----------------- Window location - 0 = inside, 1 = outside
||+------------------ Priority - 0 = behind Screen 2, 1 = in front of Screen 2
|+------------------- Horizontal flip
+-------------------- Vertical flip
(Byte 2)
7 bit 0
---- ----
yyyy yyyy
|||| ||||
++++-++++- Y coordinate
(Byte 3)
7 bit 0
---- ----
xxxx xxxx
|||| ||||
++++-++++- X coordinate
</pre>
There is a sprite limit of 32 per scanline. This means that for each scanline, only the first 32 sprites will be drawn. Note that this includes sprites obscured by windows or outside of visible X coordinates; this list is determined solely by the Y coordinate. Between sprites themselves, earlier sprites in the list are always drawn on top of later sprites in the list.
The sprite table is copied from the console's RAM to a SoC-internal buffer every frame on line <tt>144</tt>; one word for every clock of the line, totaling 256 words (512 bytes) for 256 clocks. This internal buffer is then used for reading sprite data on the next frame.
=== Visibility priority ===
For display components, the visibility priority is as follows:
* Sprite 0, high priority
* Sprite 127, high priority
* Screen 2
* Sprite 0, low priority
* Sprite 127, low priority
* Screen 1
* Background color
=== Windows ===
Screen 2 and sprites can optionally have their drawing restricted within or outside of their specific rectangular windows.
Note that for sprites, the window is enabled globally (for all sprites), but each sprite can individually decide if it's rendered inside or outside of it.
=== Icons ===
The WonderSwan features thirteen fixed LCD segments which are displayed to the right<sup>(color)</sup> or below<sup>(mono)</sup> the main display. These are:
* [[#LCD_Icon_Control_($15)|Six under control of software]]
** Large circle
** Medium circle
** Small circle
** Horizontal orientation
** Vertical orientation
** (Shooting) Star (Sleep)
* [[#LCD_Status_($1A)|Four software can query]]
** Speaker
** Volume A (small wave<sup>(mono)</sup>, center wave<sup>(color)</sup>)
** Volume B (big wave<sup>(mono)</sup>, outside two waves<sup>(color)</sup>)
** Headphones
* [[Interrupts#Interrupt_NMI_Control_($B7)|One that the software can infer]]
** Low battery
* Two that are entirely invisible to software
** Power on ("Egg", resembles the mono power switch)
** Cartridge
== Interrupts ==
The display circuit generates two interrupts of its own:
* Display Interrupt Line Match - when <code>Display Current Line</code> == <code>Display Interrupt Line</code>, at the beginning of said line.
* Display Vertical Blank - when <code>Display Current Line</code> == <code>144</code>, at the beginning of said line.
It also provides a timing source for the two Horizontal and Vertical Blank [[Timers]], which provide their own respective interrupts.
== See also ==
* [[Display/IO Ports|Display I/O ports]]
8d7bdb25ce8caa5eedcdb730d0658a393ee46d63
508
501
2025-02-23T09:55:55Z
Asie
351
wikitext
text/x-wiki
The WonderSwan features a 224x144 display capable of displaying up to 16 shades of gray (mono) or 4096 colors (color).
{| class="wikitable"
! ↑ Front ↑
! Window
! Scroll
|-
| align="center" | Sprites, high priority
| ✔
|
|-
| align="center" | Screen 2
| ✔
| ✔
|-
| align="center" | Sprites, low priority
| ✔
|
|-
| align="center" | Screen 1
|
| ✔
|-
| align="center" | Background color
|
|
|-
! ↑ Back ↑
!
!
|}
== Features ==
Screens are 32x32 tile maps; each map entry can use one of 512 (mono) or 1024 (color) tiles, one of sixteen distinct palettes, as well as be drawn mirrored or flipped.
The sprite layer consists of 128 distinct sprites. These can use any of the first 512 tiles, palettes 8 through 15, as well as be drawn over or under screen 2.
The window functionality can be used to restrict drawing of Screen 2's tiles, as well as the sprite layer, to a given pixel-perfect window. Individual sprites can be marked as being drawn inside or outside the window.
Each palette consists of four colors, of which the first entry - color zero - is opaque in palettes 0-3 and 8-11 and transparent otherwise. The color models additionally feature a sixteen-color palette mode, in which color zero is always considered transparent. The background color is displayed if no ''opaque'' pixel from any screens or sprites is drawn.
In addition, a set of LCD segment-based icons is provided to a side of the display which can be independently controlled as an indicator to the user.
== Interrupts ==
The display circuit generates two interrupts of its own:
* Display Interrupt Line Match - when <code>Display Current Line</code> == <code>Display Interrupt Line</code>, at the beginning of said line.
* Display Vertical Blank - when <code>Display Current Line</code> == <code>144</code>, at the beginning of said line.
It also provides a timing source for the two Horizontal and Vertical Blank [[Timers]], which provide their own respective interrupts.
== More information ==
* [[Display/Tile Data|Tile data]]
* [[Display/Palettes|Color palettes]]
* [[Display/Screens|Screen format]]
* [[Display/Sprites|Sprite format]]
* [[Display/LCD Icons|LCD icons]]
* [[Display/IO Ports|I/O ports]]
1822169930cc4dc54eb80d0d2cae2ec658924805
509
508
2025-02-23T09:56:05Z
Asie
351
/* More information */
wikitext
text/x-wiki
The WonderSwan features a 224x144 display capable of displaying up to 16 shades of gray (mono) or 4096 colors (color).
{| class="wikitable"
! ↑ Front ↑
! Window
! Scroll
|-
| align="center" | Sprites, high priority
| ✔
|
|-
| align="center" | Screen 2
| ✔
| ✔
|-
| align="center" | Sprites, low priority
| ✔
|
|-
| align="center" | Screen 1
|
| ✔
|-
| align="center" | Background color
|
|
|-
! ↑ Back ↑
!
!
|}
== Features ==
Screens are 32x32 tile maps; each map entry can use one of 512 (mono) or 1024 (color) tiles, one of sixteen distinct palettes, as well as be drawn mirrored or flipped.
The sprite layer consists of 128 distinct sprites. These can use any of the first 512 tiles, palettes 8 through 15, as well as be drawn over or under screen 2.
The window functionality can be used to restrict drawing of Screen 2's tiles, as well as the sprite layer, to a given pixel-perfect window. Individual sprites can be marked as being drawn inside or outside the window.
Each palette consists of four colors, of which the first entry - color zero - is opaque in palettes 0-3 and 8-11 and transparent otherwise. The color models additionally feature a sixteen-color palette mode, in which color zero is always considered transparent. The background color is displayed if no ''opaque'' pixel from any screens or sprites is drawn.
In addition, a set of LCD segment-based icons is provided to a side of the display which can be independently controlled as an indicator to the user.
== Interrupts ==
The display circuit generates two interrupts of its own:
* Display Interrupt Line Match - when <code>Display Current Line</code> == <code>Display Interrupt Line</code>, at the beginning of said line.
* Display Vertical Blank - when <code>Display Current Line</code> == <code>144</code>, at the beginning of said line.
It also provides a timing source for the two Horizontal and Vertical Blank [[Timers]], which provide their own respective interrupts.
== More information ==
* [[Display/Tile Data|Tile data]]
* [[Display/Palette|Color palette]]
* [[Display/Screens|Screen format]]
* [[Display/Sprites|Sprite format]]
* [[Display/LCD Icons|LCD icons]]
* [[Display/IO Ports|I/O ports]]
db680ed2e36b1e724d3dbdd8a458cea382fe9d54
515
509
2025-02-23T10:06:11Z
Asie
351
wikitext
text/x-wiki
The WonderSwan features a 224x144 display capable of displaying up to 16 shades of gray (mono) or 4096 colors (color).
{| class="wikitable"
! ↑ Front ↑
! Window
! Scroll
|-
| align="center" | Sprites, high priority
| ✔
|
|-
| align="center" | Screen 2
| ✔
| ✔
|-
| align="center" | Sprites, low priority
| ✔
|
|-
| align="center" | Screen 1
|
| ✔
|-
| align="center" | Background color
|
|
|-
! ↑ Back ↑
! Window
! Scroll
|}
== Features ==
Screens are 32x32 tile maps; each map entry can use one of 512 (mono) or 1024 (color) tiles, one of sixteen distinct palettes, as well as be drawn mirrored or flipped.
The sprite layer consists of 128 distinct sprites. These can use any of the first 512 tiles, palettes 8 through 15, as well as be drawn over or under screen 2.
The window functionality can be used to restrict drawing of Screen 2's tiles, as well as the sprite layer, to a given pixel-perfect window. Individual sprites can be marked as being drawn inside or outside the window.
Each palette consists of four colors, of which the first entry - color zero - is opaque in palettes 0-3 and 8-11 and transparent otherwise. The color models additionally feature a sixteen-color palette mode, in which color zero is always considered transparent. The background color is displayed if no ''opaque'' pixel from any screens or sprites is drawn.
In addition, a set of LCD segment-based icons is provided to a side of the display which can be independently controlled as an indicator to the user.
== Interrupts ==
The display circuit generates two interrupts of its own:
* Display Interrupt Line Match - when <code>Display Current Line</code> == <code>Display Interrupt Line</code>, at the beginning of said line.
* Display Vertical Blank - when <code>Display Current Line</code> == <code>144</code>, at the beginning of said line.
It also provides a timing source for the two Horizontal and Vertical Blank [[Timers]], which provide their own respective interrupts.
== More information ==
* [[Display/Tile Data|Tile data]]
* [[Display/Palette|Color palette]]
* [[Display/Screens|Screen format]]
* [[Display/Sprites|Sprite format]]
* [[Display/LCD Icons|LCD icons]]
* [[Display/IO Ports|I/O ports]]
1af84ba660a84cba0b038cdc7cea6306e82b3384
516
515
2025-02-23T11:02:18Z
Asie
351
/* More information */
wikitext
text/x-wiki
The WonderSwan features a 224x144 display capable of displaying up to 16 shades of gray (mono) or 4096 colors (color).
{| class="wikitable"
! ↑ Front ↑
! Window
! Scroll
|-
| align="center" | Sprites, high priority
| ✔
|
|-
| align="center" | Screen 2
| ✔
| ✔
|-
| align="center" | Sprites, low priority
| ✔
|
|-
| align="center" | Screen 1
|
| ✔
|-
| align="center" | Background color
|
|
|-
! ↑ Back ↑
! Window
! Scroll
|}
== Features ==
Screens are 32x32 tile maps; each map entry can use one of 512 (mono) or 1024 (color) tiles, one of sixteen distinct palettes, as well as be drawn mirrored or flipped.
The sprite layer consists of 128 distinct sprites. These can use any of the first 512 tiles, palettes 8 through 15, as well as be drawn over or under screen 2.
The window functionality can be used to restrict drawing of Screen 2's tiles, as well as the sprite layer, to a given pixel-perfect window. Individual sprites can be marked as being drawn inside or outside the window.
Each palette consists of four colors, of which the first entry - color zero - is opaque in palettes 0-3 and 8-11 and transparent otherwise. The color models additionally feature a sixteen-color palette mode, in which color zero is always considered transparent. The background color is displayed if no ''opaque'' pixel from any screens or sprites is drawn.
In addition, a set of LCD segment-based icons is provided to a side of the display which can be independently controlled as an indicator to the user.
== Interrupts ==
The display circuit generates two interrupts of its own:
* Display Interrupt Line Match - when <code>Display Current Line</code> == <code>Display Interrupt Line</code>, at the beginning of said line.
* Display Vertical Blank - when <code>Display Current Line</code> == <code>144</code>, at the beginning of said line.
It also provides a timing source for the two Horizontal and Vertical Blank [[Timers]], which provide their own respective interrupts.
== More information ==
* [[Display/Tile Data|Tile data]]
* [[Display/Palette|Color palette]]
* [[Display/Screens|Screen format]]
* [[Display/Sprites|Sprite format]]
* [[Display/Windows|Windows]]
* [[Display/LCD Icons|LCD icons]]
* [[Display/IO Ports|I/O ports]]
6255c2cfba6c6c1af1d4d8683566ccbaa4a0c9de
521
516
2025-02-23T11:13:27Z
Asie
351
/* Features */
wikitext
text/x-wiki
The WonderSwan features a 224x144 display capable of displaying up to 16 shades of gray (mono) or 4096 colors (color).
{| class="wikitable"
! ↑ Front ↑
! Window
! Scroll
|-
| align="center" | Sprites, high priority
| ✔
|
|-
| align="center" | Screen 2
| ✔
| ✔
|-
| align="center" | Sprites, low priority
| ✔
|
|-
| align="center" | Screen 1
|
| ✔
|-
| align="center" | Background color
|
|
|-
! ↑ Back ↑
! Window
! Scroll
|}
== Features ==
Screens are 32x32 tile maps, for a total of 256x256 pixels; each map entry can use one of 512 (mono) or 1024 (color) tiles, one of sixteen distinct palettes, as well as be drawn mirrored or flipped. The screens can be scrolled horizontally and vertically.
The sprite layer consists of 128 distinct sprites. These can use any of the first 512 tiles, palettes 8 through 15, as well as be drawn over or under screen 2.
The window functionality can be used to restrict drawing of Screen 2's tiles, as well as the sprite layer, to a given pixel-perfect window. Individual sprites can be marked as being drawn inside or outside the window.
Each palette consists of four colors, of which the first entry - color zero - is opaque in palettes 0-3 and 8-11 and transparent otherwise. The color models additionally feature a sixteen-color palette mode, in which color zero is always considered transparent. The background color is displayed if no ''opaque'' pixel from any screens or sprites is drawn.
In addition, a set of LCD segment-based icons is provided to a side of the display which can be independently controlled as an indicator to the user.
== Interrupts ==
The display circuit generates two interrupts of its own:
* Display Interrupt Line Match - when <code>Display Current Line</code> == <code>Display Interrupt Line</code>, at the beginning of said line.
* Display Vertical Blank - when <code>Display Current Line</code> == <code>144</code>, at the beginning of said line.
It also provides a timing source for the two Horizontal and Vertical Blank [[Timers]], which provide their own respective interrupts.
== More information ==
* [[Display/Tile Data|Tile data]]
* [[Display/Palette|Color palette]]
* [[Display/Screens|Screen format]]
* [[Display/Sprites|Sprite format]]
* [[Display/Windows|Windows]]
* [[Display/LCD Icons|LCD icons]]
* [[Display/IO Ports|I/O ports]]
d3f3c05eef37ed384ec9e32468700ffdd77bb341
I/O port map
0
8
502
489
2025-02-22T15:23:25Z
Asie
351
fix links
wikitext
text/x-wiki
The WonderSwan SoC has three general blocks of I/O port accesses:
{| class="wikitable"
! From !! To !! Holder !! Width !! Speed
|-
| $00 || $B7 || WonderSwan SoC || 16-bit || 1 cycle
|-
| $B8 || $BF || Internal EEPROM control || 16-bit || 1 cycle
|-
| $C0 || $FF || Cartridge bus || 8-bit || 1<sup>(color)</sup>/2 cycles (configurable)
|}
With the exception of internal EEPROM on the ASWAN, all unaligned 16-bit accesses can be converted to two 8-bit accesses with a 1-cycle penalty.
== I/O port map ==
* Superscripts are used to mark ports specific to a given mode or platform:
** Color mode: <sup>(color)</sup>. Such ports are only accessible when color mode is enabled through port <code>$60</code>.
** WS/WSC/SC console: <sup>(WS)</sup>, <sup>(WSC)</sup>, <sup>(SC)</sup>.
* If two Bits rows are provided, the second one refers to the "Color" mode.
* The Type can be: R - readable, W - writable, L - writable before boot ROM lockout, 8/16 - width (byte/word).
{| class="wikitable"
! Category
! Port
! Description
! Bits
! Type
! Notes
|-
! rowspan="45" | [[Display]]
! $00
| [[Display/IO Ports#Display Control|Display Control]]
| style="text-align: right" | <tt style="white-space: nowrap">..wo Ws21</tt>
| RW8
|
|-
! $01
| [[Display/IO Ports#Display Background|Display Background]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .sss</tt>
<tt style="white-space: nowrap">pppp iiii</tt>
| RW8
| Shade (s)
Palette (p), Index (i)
|-
! $02
| [[Display/IO Ports#Current Line|Display Current Line]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll</tt>
| R8
| Line (l)
|-
! $03
| [[Display/IO Ports#Interrupt Line|Display Interrupt Line]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll</tt>
| RW8
| Line (l)
|-
! $04
| [[Display/IO Ports#Sprite Table Address|Sprite Table Address]]
| style="text-align: right" | <tt style="white-space: nowrap">...a aaaa</tt>
<tt style="white-space: nowrap">..aa aaaa</tt>
| RW8
| Address >> 9 (a)
|-
! $05
| [[Display/IO Ports#Sprite Table First|Sprite Table First]]
| style="text-align: right" | <tt style="white-space: nowrap">.iii iiii</tt>
| RW8
| Index (i)
|-
! $06
| [[Display/IO Ports#Sprite Table Count|Sprite Table Count]]
| style="text-align: right" | <tt style="white-space: nowrap">cccc cccc</tt>
| RW8
| Count (c)
|-
! $07
| [[Display/IO Ports#Screen Address|Screen Address]]
| style="text-align: right" | <tt style="white-space: nowrap">.222 .111</tt>
<tt style="white-space: nowrap">2222 1111</tt>
| RW8
| Screen 1 address >> 11 (1)
Screen 2 address >> 11 (2)
|-
! $08
| [[Display/IO Ports#Screen 2 Window|Screen 2 Window Left]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $09
| [[Display/IO Ports#Screen 2 Window|Screen 2 Window Top]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $0A
| [[Display/IO Ports#Screen 2 Window|Screen 2 Window Right]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $0B
| [[Display/IO Ports#Screen 2 Window|Screen 2 Window Bottom]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $0C
| [[Display/IO Ports#Sprite Window|Sprite Window Left]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $0D
| [[Display/IO Ports#Sprite Window|Sprite Window Top]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $0E
| [[Display/IO Ports#Sprite Window|Sprite Window Right]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $0F
| [[Display/IO Ports#Sprite Window|Sprite Window Bottom]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $10
| [[Display/IO Ports#Screen Scroll|Screen 1 Scroll X]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $11
| [[Display/IO Ports#Screen Scroll|Screen 1 Scroll Y]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $12
| [[Display/IO Ports#Screen Scroll|Screen 2 Scroll X]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $13
| [[Display/IO Ports#Screen Scroll|Screen 2 Scroll Y]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $14
| [[Display/IO Ports#LCD Control|LCD Control]]
| style="text-align: right" | <tt style="white-space: nowrap">.... ..Ce</tt>
| RW8
| Contrast (C)<sup>(WSC)</sup>, Enable (e)
|-
! $15
| [[Display/IO Ports#LCD Icon Control|LCD Icon Control]]
| style="text-align: right" | <tt style="white-space: nowrap">..32 1hvs</tt>
| RW8
| Etc. 3 (3), Etc. 2 (2), Etc. 1 (1),
Horizontal (h), Vertical (v), Sleep (s)
|-
! $16
| [[Display/IO Ports#LCD Final Line|LCD Final Line]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll</tt>
| RW8
| Line (l)
|-
! $17
| [[Display/IO Ports#LCD Back Porch Line|LCD Back Porch Line]]<sup>(WSC)</sup>
| style="text-align: right" | <tt style="white-space: nowrap">llll llll</tt>
| RW8
| Line (l)
|-
! $1A
| [[Display/IO Ports#LCD Status|LCD Status]]
| style="text-align: right" | <tt style="white-space: nowrap">...v vvhs</tt>
| RW8
| Volume icons (v), Headphone icon (h), Sleep (s)
|-
! $1C
| [[Display/IO Ports#LCD Mono Shade LUT|LCD Mono Shade LUT 0/1]]
| style="text-align: right" | <tt style="white-space: nowrap">1111 0000</tt>
| RW8
| Shade index
|-
! $1D
| [[Display/IO Ports#LCD Mono Shade LUT|LCD Mono Shade LUT 2/3]]
| style="text-align: right" | <tt style="white-space: nowrap">3333 2222</tt>
| RW8
| Shade index
|-
! $1E
| [[Display/IO Ports#LCD Mono Shade LUT|LCD Mono Shade LUT 4/5]]
| style="text-align: right" | <tt style="white-space: nowrap">5555 4444</tt>
| RW8
| Shade index
|-
! $1F
| [[Display/IO Ports#LCD Mono Shade LUT|LCD Mono Shade LUT 6/7]]
| style="text-align: right" | <tt style="white-space: nowrap">7777 6666</tt>
| RW8
| Shade index
|-
! $20
| [[Display/IO Ports#LCD Mono Palette|LCD Mono Palette 0]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $22
| [[Display/IO Ports#LCD Mono Palette|LCD Mono Palette 1]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $24
| [[Display/IO Ports#LCD Mono Palette|LCD Mono Palette 2]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $26
| [[Display/IO Ports#LCD Mono Palette|LCD Mono Palette 3]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $28
| [[Display/IO Ports#LCD Mono Palette|LCD Mono Palette 4]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $2A
| [[Display/IO Ports#LCD Mono Palette|LCD Mono Palette 5]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $2C
| [[Display/IO Ports#LCD Mono Palette|LCD Mono Palette 6]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $2E
| [[Display/IO Ports#LCD Mono Palette|LCD Mono Palette 7]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $30
| [[Display/IO Ports#LCD Mono Palette|LCD Mono Palette 8]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $32
| [[Display/IO Ports#LCD Mono Palette|LCD Mono Palette 9]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $34
| [[Display/IO Ports#LCD Mono Palette|LCD Mono Palette 10]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $36
| [[Display/IO Ports#LCD Mono Palette|LCD Mono Palette 11]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $38
| [[Display/IO Ports#LCD Mono Palette|LCD Mono Palette 12]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $3A
| [[Display/IO Ports#LCD Mono Palette|LCD Mono Palette 13]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $3C
| [[Display/IO Ports#LCD Mono Palette|LCD Mono Palette 14]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $3E
| [[Display/IO Ports#LCD Mono Palette|LCD Mono Palette 15]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! rowspan="10" | [[DMA]]<sup>(color)</sup>
! $40
| [[DMA#General DMA|GDMA Source Address Low]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll llll lll.</tt>
| RW16
| Linear address, low 16 bits (l)
|-
! $42
| [[DMA#General DMA|GDMA Source Address High]]
| style="text-align: right" | <tt style="white-space: nowrap">.... hhhh</tt>
| RW8
| Linear address, high 4 bits (h)
|-
! $44
| [[DMA#General DMA|GDMA Destination Address]]
| style="text-align: right" | <tt style="white-space: nowrap">aaaa aaaa aaaa aaa.</tt>
| RW16
| IRAM address (a)
|-
! $46
| [[DMA#General DMA|GDMA Length]]
| style="text-align: right" | <tt style="white-space: nowrap">bbbb bbbb bbbb bbb.</tt>
| RW16
| Bytes (b)
|-
! $48
| [[DMA#General DMA|GDMA Control]]
| style="text-align: right" | <tt style="white-space: nowrap">ed.. ....</tt>
| RW8
| Enable (e), Decrement (d)
|-
! $4A
| [[DMA#Sound DMA|SDMA Source Address Low]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll llll llll</tt>
| RW16
| Linear address, low 16 bits (l)
|-
! $4C
| [[DMA#Sound DMA|SDMA Source Address High]]
| style="text-align: right" | <tt style="white-space: nowrap">.... hhhh</tt>
| RW8
| Linear address, high 4 bits (h)
|-
! $4E
| [[DMA#Sound DMA|SDMA Length Low]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll llll llll</tt>
| RW16
| Length, low 16 bits (l)
|-
! $50
| [[DMA#Sound DMA|SDMA Length High]]
| style="text-align: right" | <tt style="white-space: nowrap">.... hhhh</tt>
| RW8
| Length, high 4 bits (h)
|-
! $52
| [[DMA#Sound DMA|SDMA Control]]
| style="text-align: right" | <tt style="white-space: nowrap">ed.t rhff</tt>
| RW8
| Enable (e), Decrement (d), Target (t),
Repeat (r), Hold (h), Frequency (f)
|-
! rowspan="2" | [[SoC]]<sup>(color)</sup>
! $60
| [[SoC#System Control 2|System Control 2]]
| style="text-align: right" | <tt style="white-space: nowrap">c4C. i?sl</tt>
| RW8
| Color (c), 4BPP (4), Chunky (C),<br/>
Cart I/O wait state (i), SRAM wait state (s),<br/>
Cart clock speed (l).
|-
! $62
| [[SoC#System Control 3|System Control 3]]
| style="text-align: right" | <tt style="white-space: nowrap">S... ...p</tt>
| RW8
| SwanCrystal (S), Power off (p)
|-
! rowspan="4" | [[Hyper Voice]]<sup>(color)</sup>
! $64
| [[Hyper Voice#Hyper Voice Output|Hyper Voice Left Output]]
| style="text-align: right" | <tt style="white-space: nowrap">ssss ssss ssss ssss</tt>
| W16
| Raw sample (s)
|-
! $66
| [[Hyper Voice#Hyper Voice Output|Hyper Voice Right Output]]
| style="text-align: right" | <tt style="white-space: nowrap">ssss ssss ssss ssss</tt>
| W16
| Raw sample (s)
|-
! $69
| [[Hyper Voice#Hyper Voice Input|Hyper Voice Right Input]]
| style="text-align: right" | <tt style="white-space: nowrap">ssss ssss</tt>
| W8
| Sample (s)
|-
! $6A
| [[Hyper Voice#Hyper Voice Control|Hyper Voice Control]]
| style="text-align: right" | <tt style="white-space: nowrap">.mmc ???? errr ffss</tt>
| RW16
| Mask (m), Channel reset (c), Enable (e),
Rate (r), Format (f), Shift (s)
|-
! rowspan="8" | [[Display]]<sup>(SC)</sup>
! $70
| LCD Timing Configuration 1?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $71
| LCD Timing Configuration 2?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $72
| LCD Timing Configuration 3?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $73
| LCD Timing Configuration 4?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $74
| LCD Timing Configuration 5?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $75
| LCD Timing Configuration 6?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $76
| LCD Timing Configuration 7?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $77
| LCD Timing Configuration 8?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! rowspan="22" | [[Sound]]
! $80
| [[Sound#Sound Channel Frequency|Sound Channel 1 Frequency]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .ddd dddd dddd</tt>
| RW16
| Divider (d)
|-
! $82
| [[Sound#Sound Channel Frequency|Sound Channel 2 Frequency]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .ddd dddd dddd</tt>
| RW16
| Divider (d)
|-
! $84
| [[Sound#Sound Channel Frequency|Sound Channel 3 Frequency]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .ddd dddd dddd</tt>
| RW16
| Divider (d)
|-
! $86
| [[Sound#Sound Channel Frequency|Sound Channel 4 Frequency]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .ddd dddd dddd</tt>
| RW16
| Divider (d)
|-
! $88
| [[Sound#Sound Channel Volume|Sound Channel 1 Volume]]
| style="text-align: right" | <tt style="white-space: nowrap">llll rrrr</tt>
| RW8
| Left (l), Right (r)
|-
! rowspan="2" | $89
| [[Sound#Sound Channel Volume|Sound Channel 2 Volume]]
| style="text-align: right" | <tt style="white-space: nowrap">llll rrrr</tt>
| RW8
| Left (l), Right (r)
|-
| [[Sound#Sound Channel 2 Voice Sample|Sound Channel 2 Voice Sample]]
| style="text-align: right" | <tt style="white-space: nowrap">ssss ssss</tt>
| RW8
| Sample (s)
|-
! $8A
| [[Sound#Sound Channel Volume|Sound Channel 3 Volume]]
| style="text-align: right" | <tt style="white-space: nowrap">llll rrrr</tt>
| RW8
| Left (l), Right (r)
|-
! $8B
| [[Sound#Sound Channel Volume|Sound Channel 4 Volume]]
| style="text-align: right" | <tt style="white-space: nowrap">llll rrrr</tt>
| RW8
| Left (l), Right (r)
|-
! $8C
| [[Sound#Sound Channel 3 Sweep Amount|Sound Channel 3 Sweep Amount]]
| style="text-align: right" | <tt style="white-space: nowrap">vvvv vvvv</tt>
| RW8
| Value (v)
|-
! $8D
| [[Sound#Sound Channel 3 Sweep Ticks|Sound Channel 3 Sweep Ticks]]
| style="text-align: right" | <tt style="white-space: nowrap">...t tttt</tt>
| RW8
| Ticks (t)
|-
! $8E
| [[Sound#Sound Channel 4 Noise Control|Sound Channel 4 Noise Control]]
| style="text-align: right" | <tt style="white-space: nowrap">...e rttt</tt>
| RW8
| Enable (e), Reset (r), Tap (t)
|-
! $8F
| [[Sound#Sound Wavetable Address|Sound Wavetable Address]]
| style="text-align: right" | <tt style="white-space: nowrap">wwww wwww</tt>
| RW8
| Address >> 6 (w)
|-
! $90
| [[Sound#Sound Channel Control|Sound Channel Control]]
| style="text-align: right" | <tt style="white-space: nowrap">nsv. 4321</tt>
| RW8
| Channel enable (1234)
Noise (n), Sweep (s), Voice (v)
|-
! $91
| [[Sound#Sound Output Control|Sound Output Control]]
| style="text-align: right" | <tt style="white-space: nowrap">H... hrrs</tt>
| RW8
| Headphones connected (H)
Headphone output (h)
Speaker output (s), range (r)
|-
! $92
| [[Sound#Sound Channel 4 LFSR Register|Sound Channel 4 LFSR Register]]
| style="text-align: right" | <tt style="white-space: nowrap">.rrr rrrr rrrr rrrr</tt>
| R16
| PRNG state (r)
|-
! $94
| [[Sound#Sound Channel 2 Voice Volume|Sound Channel 2 Voice Volume]]
| style="text-align: right" | <tt style="white-space: nowrap">.... lLrR</tt>
| RW8
| Left Half (l), Full (L)
Right Half (r), Full (R)
|-
! $95
| [[Sound#Sound Test|Sound Test]]
| style="text-align: right" | <tt style="white-space: nowrap">425? ???h</tt>
| RW8
|
|-
! $96
| [[Sound#Sound Channel Output Right|Sound Channel Output Right]]
| style="text-align: right" | <tt style="white-space: nowrap">.... ..ss ssss ssss</tt>
| R16
| Sample (s)
|-
! $98
| [[Sound#Sound Channel Output Left|Sound Channel Output Left]]
| style="text-align: right" | <tt style="white-space: nowrap">.... ..ss ssss ssss</tt>
| R16
| Sample (s)
|-
! $9A
| [[Sound#Sound Channel Output Sum|Sound Channel Output Sum]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .sss ssss ssss</tt>
| R16
| Sample (s)
|-
! $9E
| [[Sound#Sound Speaker Main Volume|Sound Speaker Main Volume]]<sup>(color)</sup>
| style="text-align: right" | <tt style="white-space: nowrap">.... ..vv</tt>
| RW8
| Main volume (v)
|-
! [[SoC]]
! $A0
| [[SoC#System Control|System Control]]
| style="text-align: right" | <tt style="white-space: nowrap">t??? swcl</tt>
| RW8
| Test OK (t), ROM wait state (s), ROM width (w),
Color system (c), Boot ROM lockout (l)
|-
! rowspan="5" | [[Timers]]
! $A2
| [[Timers#Timer Control|Timer Control]]
| style="text-align: right" | <tt style="white-space: nowrap">.... VvHh</tt>
| RW8
| Horizontal enable (h), auto reload (H)
Vertical enable (v), auto reload (V)
|-
! $A4
| [[Timers#Timer Reload|Horizontal Blank Timer Reload]]
| style="text-align: right" | <tt style="white-space: nowrap">tttt tttt tttt tttt</tt>
| RW16
| Ticks (t)
|-
! $A6
| [[Timers#Timer Reload|Vertical Blank Timer Reload]]
| style="text-align: right" | <tt style="white-space: nowrap">tttt tttt tttt tttt</tt>
| RW16
| Ticks (t)
|-
! $A8
| [[Timers#Timer Counter|Horizontal Blank Timer Counter]]
| style="text-align: right" | <tt style="white-space: nowrap">tttt tttt tttt tttt</tt>
| R16
| Ticks (t)
|-
! $AA
| [[Timers#Timer Counter|Vertical Blank Timer Counter]]
| style="text-align: right" | <tt style="white-space: nowrap">tttt tttt tttt tttt</tt>
| R16
| Ticks (t)
|-
! ?
! $AC
| ?
| style="text-align: right" | <tt style="white-space: nowrap">.... ...p</tt>
| W8?
| Power off (p)
|-
! rowspan="2" | [[Interrupts]]
! rowspan="2" | $B0
| [[Interrupts#Interrupt Vector Offset|Interrupt Vector Offset]]
| style="text-align: right" | <tt style="white-space: nowrap">VVVV V...</tt>
| W8
| Vector offset (V)
|-
| [[Interrupts#Interrupt Vector Request|Interrupt Vector Request]]
| style="text-align: right" | <tt style="white-space: nowrap">vvvv vvvv</tt>
| R8
| Requested vector offset (v)
|-
! rowspan="2" | [[UART]]
! $B1
| [[UART#Serial Receive Data|Serial Receive Data]]
| style="text-align: right" | <tt style="white-space: nowrap">dddd dddd</tt>
| R8
| Receive buffer data (d)
|-
! $B1
| [[UART#Serial Transmit Data|Serial Transmit Data]]
| style="text-align: right" | <tt style="white-space: nowrap">dddd dddd</tt>
| W8
| Transmit buffer data (d)
|-
! [[Interrupts]]
! $B2
| [[Interrupts#Interrupt Enable|Interrupt Enable]]
| style="text-align: right" | <tt style="white-space: nowrap">iiii iiii</tt>
| RW8
| Interrupt index (i)
|-
! rowspan="2" | [[UART]]
! $B3
| [[UART#Serial Status|Serial Status]]
| style="text-align: right" | <tt style="white-space: nowrap">eb.. .tor</tt>
| R8
| Enable (e), Baud rate (b),
Transfer ready (t), Overrun (o), Receive ready (r)
|-
! $B3
| [[UART#Serial Control|Serial Control]]
| style="text-align: right" | <tt style="white-space: nowrap">ebO. ....</tt>
| W8
| Enable (e), Baud rate (b), Reset Overrun (O)
|-
! [[Interrupts]]
! $B4
| [[Interrupts#Interrupt Status|Interrupt Status]]
| style="text-align: right" | <tt style="white-space: nowrap">iiii iiii</tt>
| R8
| Interrupt index (i)
|-
! [[Keypad]]
! $B5
| [[Keypad|Keypad Scan]]
| style="text-align: right" | <tt style="white-space: nowrap">.iii oooo</tt>
| RW8
| Input row (i), Output column (o)
|-
! rowspan="2" | [[Interrupts]]
! $B6
| [[Interrupts#Interrupt Acknowledge|Interrupt Acknowledge]]
| style="text-align: right" | <tt style="white-space: nowrap">iiii iiii</tt>
| W8
| Interrupt index (i)
|-
! $B7
| [[Interrupts#Interrupt NMI Control|Interrupt NMI Control]]
| style="text-align: right" | <tt style="white-space: nowrap">...b ....</tt>
| RW8
| Low battery (b)
|-
! rowspan="4" | [[EEPROM|Internal EEPROM]]
! $BA
| [[EEPROM#Internal EEPROM Data|Internal EEPROM Data]]
| style="text-align: right" | <tt style="white-space: nowrap">dddd dddd dddd dddd</tt>
| RW16
| Data (d)
|-
! $BC
| [[EEPROM#Internal EEPROM Command|Internal EEPROM Command]]
|
| RW16
|
|-
! rowspan="2" | $BE
| [[EEPROM#Internal EEPROM Status|Internal EEPROM Status]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .... p... ..RD</tt>
| R16
| Protected (p), Ready (R), Done (D)
|-
| [[EEPROM#Internal EEPROM Control|Internal EEPROM Control]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .... pewr ....</tt>
| W16
| Protect (p), Erase (e), Write (w), Read (r)
|-
! [[Mapper|Cartridge]]
! $C0<br />...<br />
$FF
| Cartridge I/O
|
| RW8
| Forwarded by the SoC
|}
== I/O port routing ==
The [[NEC V30MZ]] supports 16-bit I/O port addresses. The WonderSwan SoC routes them using the following algorithm:
* If an address is between <code>$00B8</code> and <code>$00BF</code> inclusive, it is routed to the internal EEPROM control block.
* If an address is between <code>$00C0</code> and <code>$00FF</code> inclusive, it is routed to the cartride bus.
* If an address's bits <code>0</code> through <code>8</code> inclusive are between <code>$000</code> and <code>$0B7</code> inclusive, they are routed to the SoC block.
* If none of these conditions are reached, open bus is read.
On the monochrome models, as well as color models in mono emulation, open bus is always <code>0x90</code>.
5511f7e993d0ea33f729ee6b6b85982bbaf74723
523
502
2025-02-23T15:42:41Z
Asie
351
document $1A bit 5
wikitext
text/x-wiki
The WonderSwan SoC has three general blocks of I/O port accesses:
{| class="wikitable"
! From !! To !! Holder !! Width !! Speed
|-
| $00 || $B7 || WonderSwan SoC || 16-bit || 1 cycle
|-
| $B8 || $BF || Internal EEPROM control || 16-bit || 1 cycle
|-
| $C0 || $FF || Cartridge bus || 8-bit || 1<sup>(color)</sup>/2 cycles (configurable)
|}
With the exception of internal EEPROM on the ASWAN, all unaligned 16-bit accesses can be converted to two 8-bit accesses with a 1-cycle penalty.
== I/O port map ==
* Superscripts are used to mark ports specific to a given mode or platform:
** Color mode: <sup>(color)</sup>. Such ports are only accessible when color mode is enabled through port <code>$60</code>.
** WS/WSC/SC console: <sup>(WS)</sup>, <sup>(WSC)</sup>, <sup>(SC)</sup>.
* If two Bits rows are provided, the second one refers to the "Color" mode.
* The Type can be: R - readable, W - writable, L - writable before boot ROM lockout, 8/16 - width (byte/word).
{| class="wikitable"
! Category
! Port
! Description
! Bits
! Type
! Notes
|-
! rowspan="45" | [[Display]]
! $00
| [[Display/IO Ports#Display Control|Display Control]]
| style="text-align: right" | <tt style="white-space: nowrap">..wo Ws21</tt>
| RW8
|
|-
! $01
| [[Display/IO Ports#Display Background|Display Background]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .sss</tt>
<tt style="white-space: nowrap">pppp iiii</tt>
| RW8
| Shade (s)
Palette (p), Index (i)
|-
! $02
| [[Display/IO Ports#Current Line|Display Current Line]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll</tt>
| R8
| Line (l)
|-
! $03
| [[Display/IO Ports#Interrupt Line|Display Interrupt Line]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll</tt>
| RW8
| Line (l)
|-
! $04
| [[Display/IO Ports#Sprite Table Address|Sprite Table Address]]
| style="text-align: right" | <tt style="white-space: nowrap">...a aaaa</tt>
<tt style="white-space: nowrap">..aa aaaa</tt>
| RW8
| Address >> 9 (a)
|-
! $05
| [[Display/IO Ports#Sprite Table First|Sprite Table First]]
| style="text-align: right" | <tt style="white-space: nowrap">.iii iiii</tt>
| RW8
| Index (i)
|-
! $06
| [[Display/IO Ports#Sprite Table Count|Sprite Table Count]]
| style="text-align: right" | <tt style="white-space: nowrap">cccc cccc</tt>
| RW8
| Count (c)
|-
! $07
| [[Display/IO Ports#Screen Address|Screen Address]]
| style="text-align: right" | <tt style="white-space: nowrap">.222 .111</tt>
<tt style="white-space: nowrap">2222 1111</tt>
| RW8
| Screen 1 address >> 11 (1)
Screen 2 address >> 11 (2)
|-
! $08
| [[Display/IO Ports#Screen 2 Window|Screen 2 Window Left]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $09
| [[Display/IO Ports#Screen 2 Window|Screen 2 Window Top]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $0A
| [[Display/IO Ports#Screen 2 Window|Screen 2 Window Right]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $0B
| [[Display/IO Ports#Screen 2 Window|Screen 2 Window Bottom]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $0C
| [[Display/IO Ports#Sprite Window|Sprite Window Left]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $0D
| [[Display/IO Ports#Sprite Window|Sprite Window Top]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $0E
| [[Display/IO Ports#Sprite Window|Sprite Window Right]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $0F
| [[Display/IO Ports#Sprite Window|Sprite Window Bottom]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $10
| [[Display/IO Ports#Screen Scroll|Screen 1 Scroll X]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $11
| [[Display/IO Ports#Screen Scroll|Screen 1 Scroll Y]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $12
| [[Display/IO Ports#Screen Scroll|Screen 2 Scroll X]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $13
| [[Display/IO Ports#Screen Scroll|Screen 2 Scroll Y]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $14
| [[Display/IO Ports#LCD Control|LCD Control]]
| style="text-align: right" | <tt style="white-space: nowrap">.... ..Ce</tt>
| RW8
| Contrast (C)<sup>(WSC)</sup>, Enable (e)
|-
! $15
| [[Display/IO Ports#LCD Icon Control|LCD Icon Control]]
| style="text-align: right" | <tt style="white-space: nowrap">..32 1hvs</tt>
| RW8
| Etc. 3 (3), Etc. 2 (2), Etc. 1 (1),
Horizontal (h), Vertical (v), Sleep (s)
|-
! $16
| [[Display/IO Ports#LCD Final Line|LCD Final Line]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll</tt>
| RW8
| Line (l)
|-
! $17
| [[Display/IO Ports#LCD Back Porch Line|LCD Back Porch Line]]<sup>(WSC)</sup>
| style="text-align: right" | <tt style="white-space: nowrap">llll llll</tt>
| RW8
| Line (l)
|-
! $1A
| [[Display/IO Ports#LCD Status|LCD Status]]
| style="text-align: right" | <tt style="white-space: nowrap">..cv vvhs</tt>
| RW8
| Cartridge icon (c), Volume icons (v),
Headphone icon (h), Sleep (s)
|-
! $1C
| [[Display/IO Ports#LCD Mono Shade LUT|LCD Mono Shade LUT 0/1]]
| style="text-align: right" | <tt style="white-space: nowrap">1111 0000</tt>
| RW8
| Shade index
|-
! $1D
| [[Display/IO Ports#LCD Mono Shade LUT|LCD Mono Shade LUT 2/3]]
| style="text-align: right" | <tt style="white-space: nowrap">3333 2222</tt>
| RW8
| Shade index
|-
! $1E
| [[Display/IO Ports#LCD Mono Shade LUT|LCD Mono Shade LUT 4/5]]
| style="text-align: right" | <tt style="white-space: nowrap">5555 4444</tt>
| RW8
| Shade index
|-
! $1F
| [[Display/IO Ports#LCD Mono Shade LUT|LCD Mono Shade LUT 6/7]]
| style="text-align: right" | <tt style="white-space: nowrap">7777 6666</tt>
| RW8
| Shade index
|-
! $20
| [[Display/IO Ports#LCD Mono Palette|LCD Mono Palette 0]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $22
| [[Display/IO Ports#LCD Mono Palette|LCD Mono Palette 1]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $24
| [[Display/IO Ports#LCD Mono Palette|LCD Mono Palette 2]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $26
| [[Display/IO Ports#LCD Mono Palette|LCD Mono Palette 3]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $28
| [[Display/IO Ports#LCD Mono Palette|LCD Mono Palette 4]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $2A
| [[Display/IO Ports#LCD Mono Palette|LCD Mono Palette 5]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $2C
| [[Display/IO Ports#LCD Mono Palette|LCD Mono Palette 6]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $2E
| [[Display/IO Ports#LCD Mono Palette|LCD Mono Palette 7]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $30
| [[Display/IO Ports#LCD Mono Palette|LCD Mono Palette 8]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $32
| [[Display/IO Ports#LCD Mono Palette|LCD Mono Palette 9]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $34
| [[Display/IO Ports#LCD Mono Palette|LCD Mono Palette 10]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $36
| [[Display/IO Ports#LCD Mono Palette|LCD Mono Palette 11]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $38
| [[Display/IO Ports#LCD Mono Palette|LCD Mono Palette 12]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $3A
| [[Display/IO Ports#LCD Mono Palette|LCD Mono Palette 13]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $3C
| [[Display/IO Ports#LCD Mono Palette|LCD Mono Palette 14]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $3E
| [[Display/IO Ports#LCD Mono Palette|LCD Mono Palette 15]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! rowspan="10" | [[DMA]]<sup>(color)</sup>
! $40
| [[DMA#General DMA|GDMA Source Address Low]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll llll lll.</tt>
| RW16
| Linear address, low 16 bits (l)
|-
! $42
| [[DMA#General DMA|GDMA Source Address High]]
| style="text-align: right" | <tt style="white-space: nowrap">.... hhhh</tt>
| RW8
| Linear address, high 4 bits (h)
|-
! $44
| [[DMA#General DMA|GDMA Destination Address]]
| style="text-align: right" | <tt style="white-space: nowrap">aaaa aaaa aaaa aaa.</tt>
| RW16
| IRAM address (a)
|-
! $46
| [[DMA#General DMA|GDMA Length]]
| style="text-align: right" | <tt style="white-space: nowrap">bbbb bbbb bbbb bbb.</tt>
| RW16
| Bytes (b)
|-
! $48
| [[DMA#General DMA|GDMA Control]]
| style="text-align: right" | <tt style="white-space: nowrap">ed.. ....</tt>
| RW8
| Enable (e), Decrement (d)
|-
! $4A
| [[DMA#Sound DMA|SDMA Source Address Low]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll llll llll</tt>
| RW16
| Linear address, low 16 bits (l)
|-
! $4C
| [[DMA#Sound DMA|SDMA Source Address High]]
| style="text-align: right" | <tt style="white-space: nowrap">.... hhhh</tt>
| RW8
| Linear address, high 4 bits (h)
|-
! $4E
| [[DMA#Sound DMA|SDMA Length Low]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll llll llll</tt>
| RW16
| Length, low 16 bits (l)
|-
! $50
| [[DMA#Sound DMA|SDMA Length High]]
| style="text-align: right" | <tt style="white-space: nowrap">.... hhhh</tt>
| RW8
| Length, high 4 bits (h)
|-
! $52
| [[DMA#Sound DMA|SDMA Control]]
| style="text-align: right" | <tt style="white-space: nowrap">ed.t rhff</tt>
| RW8
| Enable (e), Decrement (d), Target (t),
Repeat (r), Hold (h), Frequency (f)
|-
! rowspan="2" | [[SoC]]<sup>(color)</sup>
! $60
| [[SoC#System Control 2|System Control 2]]
| style="text-align: right" | <tt style="white-space: nowrap">c4C. i?sl</tt>
| RW8
| Color (c), 4BPP (4), Chunky (C),<br/>
Cart I/O wait state (i), SRAM wait state (s),<br/>
Cart clock speed (l).
|-
! $62
| [[SoC#System Control 3|System Control 3]]
| style="text-align: right" | <tt style="white-space: nowrap">S... ...p</tt>
| RW8
| SwanCrystal (S), Power off (p)
|-
! rowspan="4" | [[Hyper Voice]]<sup>(color)</sup>
! $64
| [[Hyper Voice#Hyper Voice Output|Hyper Voice Left Output]]
| style="text-align: right" | <tt style="white-space: nowrap">ssss ssss ssss ssss</tt>
| W16
| Raw sample (s)
|-
! $66
| [[Hyper Voice#Hyper Voice Output|Hyper Voice Right Output]]
| style="text-align: right" | <tt style="white-space: nowrap">ssss ssss ssss ssss</tt>
| W16
| Raw sample (s)
|-
! $69
| [[Hyper Voice#Hyper Voice Input|Hyper Voice Right Input]]
| style="text-align: right" | <tt style="white-space: nowrap">ssss ssss</tt>
| W8
| Sample (s)
|-
! $6A
| [[Hyper Voice#Hyper Voice Control|Hyper Voice Control]]
| style="text-align: right" | <tt style="white-space: nowrap">.mmc ???? errr ffss</tt>
| RW16
| Mask (m), Channel reset (c), Enable (e),
Rate (r), Format (f), Shift (s)
|-
! rowspan="8" | [[Display]]<sup>(SC)</sup>
! $70
| LCD Timing Configuration 1?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $71
| LCD Timing Configuration 2?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $72
| LCD Timing Configuration 3?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $73
| LCD Timing Configuration 4?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $74
| LCD Timing Configuration 5?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $75
| LCD Timing Configuration 6?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $76
| LCD Timing Configuration 7?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $77
| LCD Timing Configuration 8?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! rowspan="22" | [[Sound]]
! $80
| [[Sound#Sound Channel Frequency|Sound Channel 1 Frequency]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .ddd dddd dddd</tt>
| RW16
| Divider (d)
|-
! $82
| [[Sound#Sound Channel Frequency|Sound Channel 2 Frequency]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .ddd dddd dddd</tt>
| RW16
| Divider (d)
|-
! $84
| [[Sound#Sound Channel Frequency|Sound Channel 3 Frequency]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .ddd dddd dddd</tt>
| RW16
| Divider (d)
|-
! $86
| [[Sound#Sound Channel Frequency|Sound Channel 4 Frequency]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .ddd dddd dddd</tt>
| RW16
| Divider (d)
|-
! $88
| [[Sound#Sound Channel Volume|Sound Channel 1 Volume]]
| style="text-align: right" | <tt style="white-space: nowrap">llll rrrr</tt>
| RW8
| Left (l), Right (r)
|-
! rowspan="2" | $89
| [[Sound#Sound Channel Volume|Sound Channel 2 Volume]]
| style="text-align: right" | <tt style="white-space: nowrap">llll rrrr</tt>
| RW8
| Left (l), Right (r)
|-
| [[Sound#Sound Channel 2 Voice Sample|Sound Channel 2 Voice Sample]]
| style="text-align: right" | <tt style="white-space: nowrap">ssss ssss</tt>
| RW8
| Sample (s)
|-
! $8A
| [[Sound#Sound Channel Volume|Sound Channel 3 Volume]]
| style="text-align: right" | <tt style="white-space: nowrap">llll rrrr</tt>
| RW8
| Left (l), Right (r)
|-
! $8B
| [[Sound#Sound Channel Volume|Sound Channel 4 Volume]]
| style="text-align: right" | <tt style="white-space: nowrap">llll rrrr</tt>
| RW8
| Left (l), Right (r)
|-
! $8C
| [[Sound#Sound Channel 3 Sweep Amount|Sound Channel 3 Sweep Amount]]
| style="text-align: right" | <tt style="white-space: nowrap">vvvv vvvv</tt>
| RW8
| Value (v)
|-
! $8D
| [[Sound#Sound Channel 3 Sweep Ticks|Sound Channel 3 Sweep Ticks]]
| style="text-align: right" | <tt style="white-space: nowrap">...t tttt</tt>
| RW8
| Ticks (t)
|-
! $8E
| [[Sound#Sound Channel 4 Noise Control|Sound Channel 4 Noise Control]]
| style="text-align: right" | <tt style="white-space: nowrap">...e rttt</tt>
| RW8
| Enable (e), Reset (r), Tap (t)
|-
! $8F
| [[Sound#Sound Wavetable Address|Sound Wavetable Address]]
| style="text-align: right" | <tt style="white-space: nowrap">wwww wwww</tt>
| RW8
| Address >> 6 (w)
|-
! $90
| [[Sound#Sound Channel Control|Sound Channel Control]]
| style="text-align: right" | <tt style="white-space: nowrap">nsv. 4321</tt>
| RW8
| Channel enable (1234)
Noise (n), Sweep (s), Voice (v)
|-
! $91
| [[Sound#Sound Output Control|Sound Output Control]]
| style="text-align: right" | <tt style="white-space: nowrap">H... hrrs</tt>
| RW8
| Headphones connected (H)
Headphone output (h)
Speaker output (s), range (r)
|-
! $92
| [[Sound#Sound Channel 4 LFSR Register|Sound Channel 4 LFSR Register]]
| style="text-align: right" | <tt style="white-space: nowrap">.rrr rrrr rrrr rrrr</tt>
| R16
| PRNG state (r)
|-
! $94
| [[Sound#Sound Channel 2 Voice Volume|Sound Channel 2 Voice Volume]]
| style="text-align: right" | <tt style="white-space: nowrap">.... lLrR</tt>
| RW8
| Left Half (l), Full (L)
Right Half (r), Full (R)
|-
! $95
| [[Sound#Sound Test|Sound Test]]
| style="text-align: right" | <tt style="white-space: nowrap">425? ???h</tt>
| RW8
|
|-
! $96
| [[Sound#Sound Channel Output Right|Sound Channel Output Right]]
| style="text-align: right" | <tt style="white-space: nowrap">.... ..ss ssss ssss</tt>
| R16
| Sample (s)
|-
! $98
| [[Sound#Sound Channel Output Left|Sound Channel Output Left]]
| style="text-align: right" | <tt style="white-space: nowrap">.... ..ss ssss ssss</tt>
| R16
| Sample (s)
|-
! $9A
| [[Sound#Sound Channel Output Sum|Sound Channel Output Sum]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .sss ssss ssss</tt>
| R16
| Sample (s)
|-
! $9E
| [[Sound#Sound Speaker Main Volume|Sound Speaker Main Volume]]<sup>(color)</sup>
| style="text-align: right" | <tt style="white-space: nowrap">.... ..vv</tt>
| RW8
| Main volume (v)
|-
! [[SoC]]
! $A0
| [[SoC#System Control|System Control]]
| style="text-align: right" | <tt style="white-space: nowrap">t??? swcl</tt>
| RW8
| Test OK (t), ROM wait state (s), ROM width (w),
Color system (c), Boot ROM lockout (l)
|-
! rowspan="5" | [[Timers]]
! $A2
| [[Timers#Timer Control|Timer Control]]
| style="text-align: right" | <tt style="white-space: nowrap">.... VvHh</tt>
| RW8
| Horizontal enable (h), auto reload (H)
Vertical enable (v), auto reload (V)
|-
! $A4
| [[Timers#Timer Reload|Horizontal Blank Timer Reload]]
| style="text-align: right" | <tt style="white-space: nowrap">tttt tttt tttt tttt</tt>
| RW16
| Ticks (t)
|-
! $A6
| [[Timers#Timer Reload|Vertical Blank Timer Reload]]
| style="text-align: right" | <tt style="white-space: nowrap">tttt tttt tttt tttt</tt>
| RW16
| Ticks (t)
|-
! $A8
| [[Timers#Timer Counter|Horizontal Blank Timer Counter]]
| style="text-align: right" | <tt style="white-space: nowrap">tttt tttt tttt tttt</tt>
| R16
| Ticks (t)
|-
! $AA
| [[Timers#Timer Counter|Vertical Blank Timer Counter]]
| style="text-align: right" | <tt style="white-space: nowrap">tttt tttt tttt tttt</tt>
| R16
| Ticks (t)
|-
! ?
! $AC
| ?
| style="text-align: right" | <tt style="white-space: nowrap">.... ...p</tt>
| W8?
| Power off (p)
|-
! rowspan="2" | [[Interrupts]]
! rowspan="2" | $B0
| [[Interrupts#Interrupt Vector Offset|Interrupt Vector Offset]]
| style="text-align: right" | <tt style="white-space: nowrap">VVVV V...</tt>
| W8
| Vector offset (V)
|-
| [[Interrupts#Interrupt Vector Request|Interrupt Vector Request]]
| style="text-align: right" | <tt style="white-space: nowrap">vvvv vvvv</tt>
| R8
| Requested vector offset (v)
|-
! rowspan="2" | [[UART]]
! $B1
| [[UART#Serial Receive Data|Serial Receive Data]]
| style="text-align: right" | <tt style="white-space: nowrap">dddd dddd</tt>
| R8
| Receive buffer data (d)
|-
! $B1
| [[UART#Serial Transmit Data|Serial Transmit Data]]
| style="text-align: right" | <tt style="white-space: nowrap">dddd dddd</tt>
| W8
| Transmit buffer data (d)
|-
! [[Interrupts]]
! $B2
| [[Interrupts#Interrupt Enable|Interrupt Enable]]
| style="text-align: right" | <tt style="white-space: nowrap">iiii iiii</tt>
| RW8
| Interrupt index (i)
|-
! rowspan="2" | [[UART]]
! $B3
| [[UART#Serial Status|Serial Status]]
| style="text-align: right" | <tt style="white-space: nowrap">eb.. .tor</tt>
| R8
| Enable (e), Baud rate (b),
Transfer ready (t), Overrun (o), Receive ready (r)
|-
! $B3
| [[UART#Serial Control|Serial Control]]
| style="text-align: right" | <tt style="white-space: nowrap">ebO. ....</tt>
| W8
| Enable (e), Baud rate (b), Reset Overrun (O)
|-
! [[Interrupts]]
! $B4
| [[Interrupts#Interrupt Status|Interrupt Status]]
| style="text-align: right" | <tt style="white-space: nowrap">iiii iiii</tt>
| R8
| Interrupt index (i)
|-
! [[Keypad]]
! $B5
| [[Keypad|Keypad Scan]]
| style="text-align: right" | <tt style="white-space: nowrap">.iii oooo</tt>
| RW8
| Input row (i), Output column (o)
|-
! rowspan="2" | [[Interrupts]]
! $B6
| [[Interrupts#Interrupt Acknowledge|Interrupt Acknowledge]]
| style="text-align: right" | <tt style="white-space: nowrap">iiii iiii</tt>
| W8
| Interrupt index (i)
|-
! $B7
| [[Interrupts#Interrupt NMI Control|Interrupt NMI Control]]
| style="text-align: right" | <tt style="white-space: nowrap">...b ....</tt>
| RW8
| Low battery (b)
|-
! rowspan="4" | [[EEPROM|Internal EEPROM]]
! $BA
| [[EEPROM#Internal EEPROM Data|Internal EEPROM Data]]
| style="text-align: right" | <tt style="white-space: nowrap">dddd dddd dddd dddd</tt>
| RW16
| Data (d)
|-
! $BC
| [[EEPROM#Internal EEPROM Command|Internal EEPROM Command]]
|
| RW16
|
|-
! rowspan="2" | $BE
| [[EEPROM#Internal EEPROM Status|Internal EEPROM Status]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .... p... ..RD</tt>
| R16
| Protected (p), Ready (R), Done (D)
|-
| [[EEPROM#Internal EEPROM Control|Internal EEPROM Control]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .... pewr ....</tt>
| W16
| Protect (p), Erase (e), Write (w), Read (r)
|-
! [[Mapper|Cartridge]]
! $C0<br />...<br />
$FF
| Cartridge I/O
|
| RW8
| Forwarded by the SoC
|}
== I/O port routing ==
The [[NEC V30MZ]] supports 16-bit I/O port addresses. The WonderSwan SoC routes them using the following algorithm:
* If an address is between <code>$00B8</code> and <code>$00BF</code> inclusive, it is routed to the internal EEPROM control block.
* If an address is between <code>$00C0</code> and <code>$00FF</code> inclusive, it is routed to the cartride bus.
* If an address's bits <code>0</code> through <code>8</code> inclusive are between <code>$000</code> and <code>$0B7</code> inclusive, they are routed to the SoC block.
* If none of these conditions are reached, open bus is read.
On the monochrome models, as well as color models in mono emulation, open bus is always <code>0x90</code>.
18e04bf4202a962da730a1c6fe8ceb7c4ba19a6d
526
523
2025-02-23T16:05:15Z
Asie
351
/* I/O port map */ document port $18
wikitext
text/x-wiki
The WonderSwan SoC has three general blocks of I/O port accesses:
{| class="wikitable"
! From !! To !! Holder !! Width !! Speed
|-
| $00 || $B7 || WonderSwan SoC || 16-bit || 1 cycle
|-
| $B8 || $BF || Internal EEPROM control || 16-bit || 1 cycle
|-
| $C0 || $FF || Cartridge bus || 8-bit || 1<sup>(color)</sup>/2 cycles (configurable)
|}
With the exception of internal EEPROM on the ASWAN, all unaligned 16-bit accesses can be converted to two 8-bit accesses with a 1-cycle penalty.
== I/O port map ==
* Superscripts are used to mark ports specific to a given mode or platform:
** Color mode: <sup>(color)</sup>. Such ports are only accessible when color mode is enabled through port <code>$60</code>.
** WS/WSC/SC console: <sup>(WS)</sup>, <sup>(WSC)</sup>, <sup>(SC)</sup>.
* If two Bits rows are provided, the second one refers to the "Color" mode.
* The Type can be: R - readable, W - writable, L - writable before boot ROM lockout, 8/16 - width (byte/word).
{| class="wikitable"
! Category
! Port
! Description
! Bits
! Type
! Notes
|-
! rowspan="45" | [[Display]]
! $00
| [[Display/IO Ports#Display Control|Display Control]]
| style="text-align: right" | <tt style="white-space: nowrap">..wo Ws21</tt>
| RW8
|
|-
! $01
| [[Display/IO Ports#Display Background|Display Background]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .sss</tt>
<tt style="white-space: nowrap">pppp iiii</tt>
| RW8
| Shade (s)
Palette (p), Index (i)
|-
! $02
| [[Display/IO Ports#Current Line|Display Current Line]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll</tt>
| R8
| Line (l)
|-
! $03
| [[Display/IO Ports#Interrupt Line|Display Interrupt Line]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll</tt>
| RW8
| Line (l)
|-
! $04
| [[Display/IO Ports#Sprite Table Address|Sprite Table Address]]
| style="text-align: right" | <tt style="white-space: nowrap">...a aaaa</tt>
<tt style="white-space: nowrap">..aa aaaa</tt>
| RW8
| Address >> 9 (a)
|-
! $05
| [[Display/IO Ports#Sprite Table First|Sprite Table First]]
| style="text-align: right" | <tt style="white-space: nowrap">.iii iiii</tt>
| RW8
| Index (i)
|-
! $06
| [[Display/IO Ports#Sprite Table Count|Sprite Table Count]]
| style="text-align: right" | <tt style="white-space: nowrap">cccc cccc</tt>
| RW8
| Count (c)
|-
! $07
| [[Display/IO Ports#Screen Address|Screen Address]]
| style="text-align: right" | <tt style="white-space: nowrap">.222 .111</tt>
<tt style="white-space: nowrap">2222 1111</tt>
| RW8
| Screen 1 address >> 11 (1)
Screen 2 address >> 11 (2)
|-
! $08
| [[Display/IO Ports#Screen 2 Window|Screen 2 Window Left]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $09
| [[Display/IO Ports#Screen 2 Window|Screen 2 Window Top]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $0A
| [[Display/IO Ports#Screen 2 Window|Screen 2 Window Right]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $0B
| [[Display/IO Ports#Screen 2 Window|Screen 2 Window Bottom]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $0C
| [[Display/IO Ports#Sprite Window|Sprite Window Left]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $0D
| [[Display/IO Ports#Sprite Window|Sprite Window Top]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $0E
| [[Display/IO Ports#Sprite Window|Sprite Window Right]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $0F
| [[Display/IO Ports#Sprite Window|Sprite Window Bottom]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $10
| [[Display/IO Ports#Screen Scroll|Screen 1 Scroll X]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $11
| [[Display/IO Ports#Screen Scroll|Screen 1 Scroll Y]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $12
| [[Display/IO Ports#Screen Scroll|Screen 2 Scroll X]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $13
| [[Display/IO Ports#Screen Scroll|Screen 2 Scroll Y]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $14
| [[Display/IO Ports#LCD Control|LCD Control]]
| style="text-align: right" | <tt style="white-space: nowrap">.... ..Ce</tt>
| RW8
| Contrast (C)<sup>(WSC)</sup>, Enable (e)
|-
! $15
| [[Display/IO Ports#LCD Icon Control|LCD Icon Control]]
| style="text-align: right" | <tt style="white-space: nowrap">..32 1hvs</tt>
| RW8
| Etc. 3 (3), Etc. 2 (2), Etc. 1 (1),
Horizontal (h), Vertical (v), Sleep (s)
|-
! $16
| [[Display/IO Ports#LCD Final Line|LCD Final Line]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll</tt>
| RW8
| Line (l)
|-
! $17
| [[Display/IO Ports#LCD Back Porch Line|LCD Back Porch Line]]<sup>(WSC)</sup>
| style="text-align: right" | <tt style="white-space: nowrap">llll llll</tt>
| RW8
| Line (l)
|-
! $18
| [[Display/IO Ports#LCD Current Line|LCD Current Line]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll</tt>
| W8
| Line (l)
|-
! $1A
| [[Display/IO Ports#LCD Status|LCD Status]]
| style="text-align: right" | <tt style="white-space: nowrap">..cv vvhs</tt>
| RW8
| Cartridge icon (c), Volume icons (v),
Headphone icon (h), Sleep (s)
|-
! $1C
| [[Display/IO Ports#LCD Mono Shade LUT|LCD Mono Shade LUT 0/1]]
| style="text-align: right" | <tt style="white-space: nowrap">1111 0000</tt>
| RW8
| Shade index
|-
! $1D
| [[Display/IO Ports#LCD Mono Shade LUT|LCD Mono Shade LUT 2/3]]
| style="text-align: right" | <tt style="white-space: nowrap">3333 2222</tt>
| RW8
| Shade index
|-
! $1E
| [[Display/IO Ports#LCD Mono Shade LUT|LCD Mono Shade LUT 4/5]]
| style="text-align: right" | <tt style="white-space: nowrap">5555 4444</tt>
| RW8
| Shade index
|-
! $1F
| [[Display/IO Ports#LCD Mono Shade LUT|LCD Mono Shade LUT 6/7]]
| style="text-align: right" | <tt style="white-space: nowrap">7777 6666</tt>
| RW8
| Shade index
|-
! $20
| [[Display/IO Ports#LCD Mono Palette|LCD Mono Palette 0]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $22
| [[Display/IO Ports#LCD Mono Palette|LCD Mono Palette 1]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $24
| [[Display/IO Ports#LCD Mono Palette|LCD Mono Palette 2]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $26
| [[Display/IO Ports#LCD Mono Palette|LCD Mono Palette 3]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $28
| [[Display/IO Ports#LCD Mono Palette|LCD Mono Palette 4]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $2A
| [[Display/IO Ports#LCD Mono Palette|LCD Mono Palette 5]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $2C
| [[Display/IO Ports#LCD Mono Palette|LCD Mono Palette 6]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $2E
| [[Display/IO Ports#LCD Mono Palette|LCD Mono Palette 7]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $30
| [[Display/IO Ports#LCD Mono Palette|LCD Mono Palette 8]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $32
| [[Display/IO Ports#LCD Mono Palette|LCD Mono Palette 9]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $34
| [[Display/IO Ports#LCD Mono Palette|LCD Mono Palette 10]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $36
| [[Display/IO Ports#LCD Mono Palette|LCD Mono Palette 11]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $38
| [[Display/IO Ports#LCD Mono Palette|LCD Mono Palette 12]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $3A
| [[Display/IO Ports#LCD Mono Palette|LCD Mono Palette 13]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $3C
| [[Display/IO Ports#LCD Mono Palette|LCD Mono Palette 14]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $3E
| [[Display/IO Ports#LCD Mono Palette|LCD Mono Palette 15]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! rowspan="10" | [[DMA]]<sup>(color)</sup>
! $40
| [[DMA#General DMA|GDMA Source Address Low]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll llll lll.</tt>
| RW16
| Linear address, low 16 bits (l)
|-
! $42
| [[DMA#General DMA|GDMA Source Address High]]
| style="text-align: right" | <tt style="white-space: nowrap">.... hhhh</tt>
| RW8
| Linear address, high 4 bits (h)
|-
! $44
| [[DMA#General DMA|GDMA Destination Address]]
| style="text-align: right" | <tt style="white-space: nowrap">aaaa aaaa aaaa aaa.</tt>
| RW16
| IRAM address (a)
|-
! $46
| [[DMA#General DMA|GDMA Length]]
| style="text-align: right" | <tt style="white-space: nowrap">bbbb bbbb bbbb bbb.</tt>
| RW16
| Bytes (b)
|-
! $48
| [[DMA#General DMA|GDMA Control]]
| style="text-align: right" | <tt style="white-space: nowrap">ed.. ....</tt>
| RW8
| Enable (e), Decrement (d)
|-
! $4A
| [[DMA#Sound DMA|SDMA Source Address Low]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll llll llll</tt>
| RW16
| Linear address, low 16 bits (l)
|-
! $4C
| [[DMA#Sound DMA|SDMA Source Address High]]
| style="text-align: right" | <tt style="white-space: nowrap">.... hhhh</tt>
| RW8
| Linear address, high 4 bits (h)
|-
! $4E
| [[DMA#Sound DMA|SDMA Length Low]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll llll llll</tt>
| RW16
| Length, low 16 bits (l)
|-
! $50
| [[DMA#Sound DMA|SDMA Length High]]
| style="text-align: right" | <tt style="white-space: nowrap">.... hhhh</tt>
| RW8
| Length, high 4 bits (h)
|-
! $52
| [[DMA#Sound DMA|SDMA Control]]
| style="text-align: right" | <tt style="white-space: nowrap">ed.t rhff</tt>
| RW8
| Enable (e), Decrement (d), Target (t),
Repeat (r), Hold (h), Frequency (f)
|-
! rowspan="2" | [[SoC]]<sup>(color)</sup>
! $60
| [[SoC#System Control 2|System Control 2]]
| style="text-align: right" | <tt style="white-space: nowrap">c4C. i?sl</tt>
| RW8
| Color (c), 4BPP (4), Chunky (C),<br/>
Cart I/O wait state (i), SRAM wait state (s),<br/>
Cart clock speed (l).
|-
! $62
| [[SoC#System Control 3|System Control 3]]
| style="text-align: right" | <tt style="white-space: nowrap">S... ...p</tt>
| RW8
| SwanCrystal (S), Power off (p)
|-
! rowspan="4" | [[Hyper Voice]]<sup>(color)</sup>
! $64
| [[Hyper Voice#Hyper Voice Output|Hyper Voice Left Output]]
| style="text-align: right" | <tt style="white-space: nowrap">ssss ssss ssss ssss</tt>
| W16
| Raw sample (s)
|-
! $66
| [[Hyper Voice#Hyper Voice Output|Hyper Voice Right Output]]
| style="text-align: right" | <tt style="white-space: nowrap">ssss ssss ssss ssss</tt>
| W16
| Raw sample (s)
|-
! $69
| [[Hyper Voice#Hyper Voice Input|Hyper Voice Right Input]]
| style="text-align: right" | <tt style="white-space: nowrap">ssss ssss</tt>
| W8
| Sample (s)
|-
! $6A
| [[Hyper Voice#Hyper Voice Control|Hyper Voice Control]]
| style="text-align: right" | <tt style="white-space: nowrap">.mmc ???? errr ffss</tt>
| RW16
| Mask (m), Channel reset (c), Enable (e),
Rate (r), Format (f), Shift (s)
|-
! rowspan="8" | [[Display]]<sup>(SC)</sup>
! $70
| LCD Timing Configuration 1?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $71
| LCD Timing Configuration 2?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $72
| LCD Timing Configuration 3?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $73
| LCD Timing Configuration 4?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $74
| LCD Timing Configuration 5?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $75
| LCD Timing Configuration 6?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $76
| LCD Timing Configuration 7?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $77
| LCD Timing Configuration 8?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! rowspan="22" | [[Sound]]
! $80
| [[Sound#Sound Channel Frequency|Sound Channel 1 Frequency]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .ddd dddd dddd</tt>
| RW16
| Divider (d)
|-
! $82
| [[Sound#Sound Channel Frequency|Sound Channel 2 Frequency]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .ddd dddd dddd</tt>
| RW16
| Divider (d)
|-
! $84
| [[Sound#Sound Channel Frequency|Sound Channel 3 Frequency]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .ddd dddd dddd</tt>
| RW16
| Divider (d)
|-
! $86
| [[Sound#Sound Channel Frequency|Sound Channel 4 Frequency]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .ddd dddd dddd</tt>
| RW16
| Divider (d)
|-
! $88
| [[Sound#Sound Channel Volume|Sound Channel 1 Volume]]
| style="text-align: right" | <tt style="white-space: nowrap">llll rrrr</tt>
| RW8
| Left (l), Right (r)
|-
! rowspan="2" | $89
| [[Sound#Sound Channel Volume|Sound Channel 2 Volume]]
| style="text-align: right" | <tt style="white-space: nowrap">llll rrrr</tt>
| RW8
| Left (l), Right (r)
|-
| [[Sound#Sound Channel 2 Voice Sample|Sound Channel 2 Voice Sample]]
| style="text-align: right" | <tt style="white-space: nowrap">ssss ssss</tt>
| RW8
| Sample (s)
|-
! $8A
| [[Sound#Sound Channel Volume|Sound Channel 3 Volume]]
| style="text-align: right" | <tt style="white-space: nowrap">llll rrrr</tt>
| RW8
| Left (l), Right (r)
|-
! $8B
| [[Sound#Sound Channel Volume|Sound Channel 4 Volume]]
| style="text-align: right" | <tt style="white-space: nowrap">llll rrrr</tt>
| RW8
| Left (l), Right (r)
|-
! $8C
| [[Sound#Sound Channel 3 Sweep Amount|Sound Channel 3 Sweep Amount]]
| style="text-align: right" | <tt style="white-space: nowrap">vvvv vvvv</tt>
| RW8
| Value (v)
|-
! $8D
| [[Sound#Sound Channel 3 Sweep Ticks|Sound Channel 3 Sweep Ticks]]
| style="text-align: right" | <tt style="white-space: nowrap">...t tttt</tt>
| RW8
| Ticks (t)
|-
! $8E
| [[Sound#Sound Channel 4 Noise Control|Sound Channel 4 Noise Control]]
| style="text-align: right" | <tt style="white-space: nowrap">...e rttt</tt>
| RW8
| Enable (e), Reset (r), Tap (t)
|-
! $8F
| [[Sound#Sound Wavetable Address|Sound Wavetable Address]]
| style="text-align: right" | <tt style="white-space: nowrap">wwww wwww</tt>
| RW8
| Address >> 6 (w)
|-
! $90
| [[Sound#Sound Channel Control|Sound Channel Control]]
| style="text-align: right" | <tt style="white-space: nowrap">nsv. 4321</tt>
| RW8
| Channel enable (1234)
Noise (n), Sweep (s), Voice (v)
|-
! $91
| [[Sound#Sound Output Control|Sound Output Control]]
| style="text-align: right" | <tt style="white-space: nowrap">H... hrrs</tt>
| RW8
| Headphones connected (H)
Headphone output (h)
Speaker output (s), range (r)
|-
! $92
| [[Sound#Sound Channel 4 LFSR Register|Sound Channel 4 LFSR Register]]
| style="text-align: right" | <tt style="white-space: nowrap">.rrr rrrr rrrr rrrr</tt>
| R16
| PRNG state (r)
|-
! $94
| [[Sound#Sound Channel 2 Voice Volume|Sound Channel 2 Voice Volume]]
| style="text-align: right" | <tt style="white-space: nowrap">.... lLrR</tt>
| RW8
| Left Half (l), Full (L)
Right Half (r), Full (R)
|-
! $95
| [[Sound#Sound Test|Sound Test]]
| style="text-align: right" | <tt style="white-space: nowrap">425? ???h</tt>
| RW8
|
|-
! $96
| [[Sound#Sound Channel Output Right|Sound Channel Output Right]]
| style="text-align: right" | <tt style="white-space: nowrap">.... ..ss ssss ssss</tt>
| R16
| Sample (s)
|-
! $98
| [[Sound#Sound Channel Output Left|Sound Channel Output Left]]
| style="text-align: right" | <tt style="white-space: nowrap">.... ..ss ssss ssss</tt>
| R16
| Sample (s)
|-
! $9A
| [[Sound#Sound Channel Output Sum|Sound Channel Output Sum]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .sss ssss ssss</tt>
| R16
| Sample (s)
|-
! $9E
| [[Sound#Sound Speaker Main Volume|Sound Speaker Main Volume]]<sup>(color)</sup>
| style="text-align: right" | <tt style="white-space: nowrap">.... ..vv</tt>
| RW8
| Main volume (v)
|-
! [[SoC]]
! $A0
| [[SoC#System Control|System Control]]
| style="text-align: right" | <tt style="white-space: nowrap">t??? swcl</tt>
| RW8
| Test OK (t), ROM wait state (s), ROM width (w),
Color system (c), Boot ROM lockout (l)
|-
! rowspan="5" | [[Timers]]
! $A2
| [[Timers#Timer Control|Timer Control]]
| style="text-align: right" | <tt style="white-space: nowrap">.... VvHh</tt>
| RW8
| Horizontal enable (h), auto reload (H)
Vertical enable (v), auto reload (V)
|-
! $A4
| [[Timers#Timer Reload|Horizontal Blank Timer Reload]]
| style="text-align: right" | <tt style="white-space: nowrap">tttt tttt tttt tttt</tt>
| RW16
| Ticks (t)
|-
! $A6
| [[Timers#Timer Reload|Vertical Blank Timer Reload]]
| style="text-align: right" | <tt style="white-space: nowrap">tttt tttt tttt tttt</tt>
| RW16
| Ticks (t)
|-
! $A8
| [[Timers#Timer Counter|Horizontal Blank Timer Counter]]
| style="text-align: right" | <tt style="white-space: nowrap">tttt tttt tttt tttt</tt>
| R16
| Ticks (t)
|-
! $AA
| [[Timers#Timer Counter|Vertical Blank Timer Counter]]
| style="text-align: right" | <tt style="white-space: nowrap">tttt tttt tttt tttt</tt>
| R16
| Ticks (t)
|-
! ?
! $AC
| ?
| style="text-align: right" | <tt style="white-space: nowrap">.... ...p</tt>
| W8?
| Power off (p)
|-
! rowspan="2" | [[Interrupts]]
! rowspan="2" | $B0
| [[Interrupts#Interrupt Vector Offset|Interrupt Vector Offset]]
| style="text-align: right" | <tt style="white-space: nowrap">VVVV V...</tt>
| W8
| Vector offset (V)
|-
| [[Interrupts#Interrupt Vector Request|Interrupt Vector Request]]
| style="text-align: right" | <tt style="white-space: nowrap">vvvv vvvv</tt>
| R8
| Requested vector offset (v)
|-
! rowspan="2" | [[UART]]
! $B1
| [[UART#Serial Receive Data|Serial Receive Data]]
| style="text-align: right" | <tt style="white-space: nowrap">dddd dddd</tt>
| R8
| Receive buffer data (d)
|-
! $B1
| [[UART#Serial Transmit Data|Serial Transmit Data]]
| style="text-align: right" | <tt style="white-space: nowrap">dddd dddd</tt>
| W8
| Transmit buffer data (d)
|-
! [[Interrupts]]
! $B2
| [[Interrupts#Interrupt Enable|Interrupt Enable]]
| style="text-align: right" | <tt style="white-space: nowrap">iiii iiii</tt>
| RW8
| Interrupt index (i)
|-
! rowspan="2" | [[UART]]
! $B3
| [[UART#Serial Status|Serial Status]]
| style="text-align: right" | <tt style="white-space: nowrap">eb.. .tor</tt>
| R8
| Enable (e), Baud rate (b),
Transfer ready (t), Overrun (o), Receive ready (r)
|-
! $B3
| [[UART#Serial Control|Serial Control]]
| style="text-align: right" | <tt style="white-space: nowrap">ebO. ....</tt>
| W8
| Enable (e), Baud rate (b), Reset Overrun (O)
|-
! [[Interrupts]]
! $B4
| [[Interrupts#Interrupt Status|Interrupt Status]]
| style="text-align: right" | <tt style="white-space: nowrap">iiii iiii</tt>
| R8
| Interrupt index (i)
|-
! [[Keypad]]
! $B5
| [[Keypad|Keypad Scan]]
| style="text-align: right" | <tt style="white-space: nowrap">.iii oooo</tt>
| RW8
| Input row (i), Output column (o)
|-
! rowspan="2" | [[Interrupts]]
! $B6
| [[Interrupts#Interrupt Acknowledge|Interrupt Acknowledge]]
| style="text-align: right" | <tt style="white-space: nowrap">iiii iiii</tt>
| W8
| Interrupt index (i)
|-
! $B7
| [[Interrupts#Interrupt NMI Control|Interrupt NMI Control]]
| style="text-align: right" | <tt style="white-space: nowrap">...b ....</tt>
| RW8
| Low battery (b)
|-
! rowspan="4" | [[EEPROM|Internal EEPROM]]
! $BA
| [[EEPROM#Internal EEPROM Data|Internal EEPROM Data]]
| style="text-align: right" | <tt style="white-space: nowrap">dddd dddd dddd dddd</tt>
| RW16
| Data (d)
|-
! $BC
| [[EEPROM#Internal EEPROM Command|Internal EEPROM Command]]
|
| RW16
|
|-
! rowspan="2" | $BE
| [[EEPROM#Internal EEPROM Status|Internal EEPROM Status]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .... p... ..RD</tt>
| R16
| Protected (p), Ready (R), Done (D)
|-
| [[EEPROM#Internal EEPROM Control|Internal EEPROM Control]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .... pewr ....</tt>
| W16
| Protect (p), Erase (e), Write (w), Read (r)
|-
! [[Mapper|Cartridge]]
! $C0<br />...<br />
$FF
| Cartridge I/O
|
| RW8
| Forwarded by the SoC
|}
== I/O port routing ==
The [[NEC V30MZ]] supports 16-bit I/O port addresses. The WonderSwan SoC routes them using the following algorithm:
* If an address is between <code>$00B8</code> and <code>$00BF</code> inclusive, it is routed to the internal EEPROM control block.
* If an address is between <code>$00C0</code> and <code>$00FF</code> inclusive, it is routed to the cartride bus.
* If an address's bits <code>0</code> through <code>8</code> inclusive are between <code>$000</code> and <code>$0B7</code> inclusive, they are routed to the SoC block.
* If none of these conditions are reached, open bus is read.
On the monochrome models, as well as color models in mono emulation, open bus is always <code>0x90</code>.
e8576c7b6c0ab50a135eb979f7666e75f2e69d34
528
526
2025-02-23T16:07:21Z
Asie
351
wikitext
text/x-wiki
The WonderSwan SoC has three general blocks of I/O port accesses:
{| class="wikitable"
! From !! To !! Holder !! Width !! Speed
|-
| $00 || $B7 || WonderSwan SoC || 16-bit || 1 cycle
|-
| $B8 || $BF || Internal EEPROM control || 16-bit || 1 cycle
|-
| $C0 || $FF || Cartridge bus || 8-bit || 1<sup>(color)</sup>/2 cycles (configurable)
|}
With the exception of internal EEPROM on the ASWAN, all unaligned 16-bit accesses can be converted to two 8-bit accesses with a 1-cycle penalty.
== I/O port map ==
* Superscripts are used to mark ports specific to a given mode or platform:
** Color mode: <sup>(color)</sup>. Such ports are only accessible when color mode is enabled through port <code>$60</code>.
** WS/WSC/SC console: <sup>(WS)</sup>, <sup>(WSC)</sup>, <sup>(SC)</sup>.
* If two Bits rows are provided, the second one refers to the "Color" mode.
* The Type can be: R - readable, W - writable, L - writable before boot ROM lockout, 8/16 - width (byte/word).
{| class="wikitable"
! Category
! Port
! Description
! Bits
! Type
! Notes
|-
! rowspan="45" | [[Display]]
! $00
| [[Display/IO Ports#Display Control|Display Control]]
| style="text-align: right" | <tt style="white-space: nowrap">..wo Ws21</tt>
| RW8
|
|-
! $01
| [[Display/IO Ports#Display Background|Display Background]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .sss</tt>
<tt style="white-space: nowrap">pppp iiii</tt>
| RW8
| Shade (s)
Palette (p), Index (i)
|-
! $02
| [[Display/IO Ports#Current Line|Display Current Line]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll</tt>
| R8
| Line (l)
|-
! $03
| [[Display/IO Ports#Interrupt Line|Display Interrupt Line]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll</tt>
| RW8
| Line (l)
|-
! $04
| [[Display/IO Ports#Sprite Table Address|Sprite Table Address]]
| style="text-align: right" | <tt style="white-space: nowrap">...a aaaa</tt>
<tt style="white-space: nowrap">..aa aaaa</tt>
| RW8
| Address >> 9 (a)
|-
! $05
| [[Display/IO Ports#Sprite Table First|Sprite Table First]]
| style="text-align: right" | <tt style="white-space: nowrap">.iii iiii</tt>
| RW8
| Index (i)
|-
! $06
| [[Display/IO Ports#Sprite Table Count|Sprite Table Count]]
| style="text-align: right" | <tt style="white-space: nowrap">cccc cccc</tt>
| RW8
| Count (c)
|-
! $07
| [[Display/IO Ports#Screen Address|Screen Address]]
| style="text-align: right" | <tt style="white-space: nowrap">.222 .111</tt>
<tt style="white-space: nowrap">2222 1111</tt>
| RW8
| Screen 1 address >> 11 (1)
Screen 2 address >> 11 (2)
|-
! $08
| [[Display/IO Ports#Screen 2 Window|Screen 2 Window Left]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $09
| [[Display/IO Ports#Screen 2 Window|Screen 2 Window Top]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $0A
| [[Display/IO Ports#Screen 2 Window|Screen 2 Window Right]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $0B
| [[Display/IO Ports#Screen 2 Window|Screen 2 Window Bottom]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $0C
| [[Display/IO Ports#Sprite Window|Sprite Window Left]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $0D
| [[Display/IO Ports#Sprite Window|Sprite Window Top]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $0E
| [[Display/IO Ports#Sprite Window|Sprite Window Right]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $0F
| [[Display/IO Ports#Sprite Window|Sprite Window Bottom]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $10
| [[Display/IO Ports#Screen Scroll|Screen 1 Scroll X]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $11
| [[Display/IO Ports#Screen Scroll|Screen 1 Scroll Y]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $12
| [[Display/IO Ports#Screen Scroll|Screen 2 Scroll X]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $13
| [[Display/IO Ports#Screen Scroll|Screen 2 Scroll Y]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $14
| [[Display/IO Ports#LCD Control|LCD Control]]
| style="text-align: right" | <tt style="white-space: nowrap">.... ..Ce</tt>
| RW8
| Contrast (C)<sup>(WSC)</sup>, Enable (e)
|-
! $15
| [[Display/IO Ports#LCD Icon Control|LCD Icon Control]]
| style="text-align: right" | <tt style="white-space: nowrap">..32 1hvs</tt>
| RW8
| Etc. 3 (3), Etc. 2 (2), Etc. 1 (1),
Horizontal (h), Vertical (v), Sleep (s)
|-
! $16
| [[Display/IO Ports#LCD Final Line|LCD Final Line]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll</tt>
| RW8
| Line (l)
|-
! $17
| [[Display/IO Ports#LCD Back Porch Line|LCD Back Porch Line]]<sup>(WSC)</sup>
| style="text-align: right" | <tt style="white-space: nowrap">llll llll</tt>
| RW8
| Line (l)
|-
! $18
| [[Display/IO Ports#LCD Line Counter|LCD Line Counter]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll</tt>
| W8
| Line (l)
|-
! $1A
| [[Display/IO Ports#LCD Status|LCD Status]]
| style="text-align: right" | <tt style="white-space: nowrap">..cv vvhs</tt>
| RW8
| Cartridge icon (c), Volume icons (v),
Headphone icon (h), Sleep (s)
|-
! $1C
| [[Display/IO Ports#LCD Mono Shade LUT|LCD Mono Shade LUT 0/1]]
| style="text-align: right" | <tt style="white-space: nowrap">1111 0000</tt>
| RW8
| Shade index
|-
! $1D
| [[Display/IO Ports#LCD Mono Shade LUT|LCD Mono Shade LUT 2/3]]
| style="text-align: right" | <tt style="white-space: nowrap">3333 2222</tt>
| RW8
| Shade index
|-
! $1E
| [[Display/IO Ports#LCD Mono Shade LUT|LCD Mono Shade LUT 4/5]]
| style="text-align: right" | <tt style="white-space: nowrap">5555 4444</tt>
| RW8
| Shade index
|-
! $1F
| [[Display/IO Ports#LCD Mono Shade LUT|LCD Mono Shade LUT 6/7]]
| style="text-align: right" | <tt style="white-space: nowrap">7777 6666</tt>
| RW8
| Shade index
|-
! $20
| [[Display/IO Ports#LCD Mono Palette|LCD Mono Palette 0]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $22
| [[Display/IO Ports#LCD Mono Palette|LCD Mono Palette 1]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $24
| [[Display/IO Ports#LCD Mono Palette|LCD Mono Palette 2]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $26
| [[Display/IO Ports#LCD Mono Palette|LCD Mono Palette 3]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $28
| [[Display/IO Ports#LCD Mono Palette|LCD Mono Palette 4]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $2A
| [[Display/IO Ports#LCD Mono Palette|LCD Mono Palette 5]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $2C
| [[Display/IO Ports#LCD Mono Palette|LCD Mono Palette 6]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $2E
| [[Display/IO Ports#LCD Mono Palette|LCD Mono Palette 7]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $30
| [[Display/IO Ports#LCD Mono Palette|LCD Mono Palette 8]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $32
| [[Display/IO Ports#LCD Mono Palette|LCD Mono Palette 9]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $34
| [[Display/IO Ports#LCD Mono Palette|LCD Mono Palette 10]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $36
| [[Display/IO Ports#LCD Mono Palette|LCD Mono Palette 11]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $38
| [[Display/IO Ports#LCD Mono Palette|LCD Mono Palette 12]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $3A
| [[Display/IO Ports#LCD Mono Palette|LCD Mono Palette 13]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $3C
| [[Display/IO Ports#LCD Mono Palette|LCD Mono Palette 14]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $3E
| [[Display/IO Ports#LCD Mono Palette|LCD Mono Palette 15]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! rowspan="10" | [[DMA]]<sup>(color)</sup>
! $40
| [[DMA#General DMA|GDMA Source Address Low]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll llll lll.</tt>
| RW16
| Linear address, low 16 bits (l)
|-
! $42
| [[DMA#General DMA|GDMA Source Address High]]
| style="text-align: right" | <tt style="white-space: nowrap">.... hhhh</tt>
| RW8
| Linear address, high 4 bits (h)
|-
! $44
| [[DMA#General DMA|GDMA Destination Address]]
| style="text-align: right" | <tt style="white-space: nowrap">aaaa aaaa aaaa aaa.</tt>
| RW16
| IRAM address (a)
|-
! $46
| [[DMA#General DMA|GDMA Length]]
| style="text-align: right" | <tt style="white-space: nowrap">bbbb bbbb bbbb bbb.</tt>
| RW16
| Bytes (b)
|-
! $48
| [[DMA#General DMA|GDMA Control]]
| style="text-align: right" | <tt style="white-space: nowrap">ed.. ....</tt>
| RW8
| Enable (e), Decrement (d)
|-
! $4A
| [[DMA#Sound DMA|SDMA Source Address Low]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll llll llll</tt>
| RW16
| Linear address, low 16 bits (l)
|-
! $4C
| [[DMA#Sound DMA|SDMA Source Address High]]
| style="text-align: right" | <tt style="white-space: nowrap">.... hhhh</tt>
| RW8
| Linear address, high 4 bits (h)
|-
! $4E
| [[DMA#Sound DMA|SDMA Length Low]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll llll llll</tt>
| RW16
| Length, low 16 bits (l)
|-
! $50
| [[DMA#Sound DMA|SDMA Length High]]
| style="text-align: right" | <tt style="white-space: nowrap">.... hhhh</tt>
| RW8
| Length, high 4 bits (h)
|-
! $52
| [[DMA#Sound DMA|SDMA Control]]
| style="text-align: right" | <tt style="white-space: nowrap">ed.t rhff</tt>
| RW8
| Enable (e), Decrement (d), Target (t),
Repeat (r), Hold (h), Frequency (f)
|-
! rowspan="2" | [[SoC]]<sup>(color)</sup>
! $60
| [[SoC#System Control 2|System Control 2]]
| style="text-align: right" | <tt style="white-space: nowrap">c4C. i?sl</tt>
| RW8
| Color (c), 4BPP (4), Chunky (C),<br/>
Cart I/O wait state (i), SRAM wait state (s),<br/>
Cart clock speed (l).
|-
! $62
| [[SoC#System Control 3|System Control 3]]
| style="text-align: right" | <tt style="white-space: nowrap">S... ...p</tt>
| RW8
| SwanCrystal (S), Power off (p)
|-
! rowspan="4" | [[Hyper Voice]]<sup>(color)</sup>
! $64
| [[Hyper Voice#Hyper Voice Output|Hyper Voice Left Output]]
| style="text-align: right" | <tt style="white-space: nowrap">ssss ssss ssss ssss</tt>
| W16
| Raw sample (s)
|-
! $66
| [[Hyper Voice#Hyper Voice Output|Hyper Voice Right Output]]
| style="text-align: right" | <tt style="white-space: nowrap">ssss ssss ssss ssss</tt>
| W16
| Raw sample (s)
|-
! $69
| [[Hyper Voice#Hyper Voice Input|Hyper Voice Right Input]]
| style="text-align: right" | <tt style="white-space: nowrap">ssss ssss</tt>
| W8
| Sample (s)
|-
! $6A
| [[Hyper Voice#Hyper Voice Control|Hyper Voice Control]]
| style="text-align: right" | <tt style="white-space: nowrap">.mmc ???? errr ffss</tt>
| RW16
| Mask (m), Channel reset (c), Enable (e),
Rate (r), Format (f), Shift (s)
|-
! rowspan="8" | [[Display]]<sup>(SC)</sup>
! $70
| LCD Timing Configuration 1?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $71
| LCD Timing Configuration 2?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $72
| LCD Timing Configuration 3?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $73
| LCD Timing Configuration 4?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $74
| LCD Timing Configuration 5?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $75
| LCD Timing Configuration 6?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $76
| LCD Timing Configuration 7?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $77
| LCD Timing Configuration 8?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! rowspan="22" | [[Sound]]
! $80
| [[Sound#Sound Channel Frequency|Sound Channel 1 Frequency]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .ddd dddd dddd</tt>
| RW16
| Divider (d)
|-
! $82
| [[Sound#Sound Channel Frequency|Sound Channel 2 Frequency]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .ddd dddd dddd</tt>
| RW16
| Divider (d)
|-
! $84
| [[Sound#Sound Channel Frequency|Sound Channel 3 Frequency]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .ddd dddd dddd</tt>
| RW16
| Divider (d)
|-
! $86
| [[Sound#Sound Channel Frequency|Sound Channel 4 Frequency]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .ddd dddd dddd</tt>
| RW16
| Divider (d)
|-
! $88
| [[Sound#Sound Channel Volume|Sound Channel 1 Volume]]
| style="text-align: right" | <tt style="white-space: nowrap">llll rrrr</tt>
| RW8
| Left (l), Right (r)
|-
! rowspan="2" | $89
| [[Sound#Sound Channel Volume|Sound Channel 2 Volume]]
| style="text-align: right" | <tt style="white-space: nowrap">llll rrrr</tt>
| RW8
| Left (l), Right (r)
|-
| [[Sound#Sound Channel 2 Voice Sample|Sound Channel 2 Voice Sample]]
| style="text-align: right" | <tt style="white-space: nowrap">ssss ssss</tt>
| RW8
| Sample (s)
|-
! $8A
| [[Sound#Sound Channel Volume|Sound Channel 3 Volume]]
| style="text-align: right" | <tt style="white-space: nowrap">llll rrrr</tt>
| RW8
| Left (l), Right (r)
|-
! $8B
| [[Sound#Sound Channel Volume|Sound Channel 4 Volume]]
| style="text-align: right" | <tt style="white-space: nowrap">llll rrrr</tt>
| RW8
| Left (l), Right (r)
|-
! $8C
| [[Sound#Sound Channel 3 Sweep Amount|Sound Channel 3 Sweep Amount]]
| style="text-align: right" | <tt style="white-space: nowrap">vvvv vvvv</tt>
| RW8
| Value (v)
|-
! $8D
| [[Sound#Sound Channel 3 Sweep Ticks|Sound Channel 3 Sweep Ticks]]
| style="text-align: right" | <tt style="white-space: nowrap">...t tttt</tt>
| RW8
| Ticks (t)
|-
! $8E
| [[Sound#Sound Channel 4 Noise Control|Sound Channel 4 Noise Control]]
| style="text-align: right" | <tt style="white-space: nowrap">...e rttt</tt>
| RW8
| Enable (e), Reset (r), Tap (t)
|-
! $8F
| [[Sound#Sound Wavetable Address|Sound Wavetable Address]]
| style="text-align: right" | <tt style="white-space: nowrap">wwww wwww</tt>
| RW8
| Address >> 6 (w)
|-
! $90
| [[Sound#Sound Channel Control|Sound Channel Control]]
| style="text-align: right" | <tt style="white-space: nowrap">nsv. 4321</tt>
| RW8
| Channel enable (1234)
Noise (n), Sweep (s), Voice (v)
|-
! $91
| [[Sound#Sound Output Control|Sound Output Control]]
| style="text-align: right" | <tt style="white-space: nowrap">H... hrrs</tt>
| RW8
| Headphones connected (H)
Headphone output (h)
Speaker output (s), range (r)
|-
! $92
| [[Sound#Sound Channel 4 LFSR Register|Sound Channel 4 LFSR Register]]
| style="text-align: right" | <tt style="white-space: nowrap">.rrr rrrr rrrr rrrr</tt>
| R16
| PRNG state (r)
|-
! $94
| [[Sound#Sound Channel 2 Voice Volume|Sound Channel 2 Voice Volume]]
| style="text-align: right" | <tt style="white-space: nowrap">.... lLrR</tt>
| RW8
| Left Half (l), Full (L)
Right Half (r), Full (R)
|-
! $95
| [[Sound#Sound Test|Sound Test]]
| style="text-align: right" | <tt style="white-space: nowrap">425? ???h</tt>
| RW8
|
|-
! $96
| [[Sound#Sound Channel Output Right|Sound Channel Output Right]]
| style="text-align: right" | <tt style="white-space: nowrap">.... ..ss ssss ssss</tt>
| R16
| Sample (s)
|-
! $98
| [[Sound#Sound Channel Output Left|Sound Channel Output Left]]
| style="text-align: right" | <tt style="white-space: nowrap">.... ..ss ssss ssss</tt>
| R16
| Sample (s)
|-
! $9A
| [[Sound#Sound Channel Output Sum|Sound Channel Output Sum]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .sss ssss ssss</tt>
| R16
| Sample (s)
|-
! $9E
| [[Sound#Sound Speaker Main Volume|Sound Speaker Main Volume]]<sup>(color)</sup>
| style="text-align: right" | <tt style="white-space: nowrap">.... ..vv</tt>
| RW8
| Main volume (v)
|-
! [[SoC]]
! $A0
| [[SoC#System Control|System Control]]
| style="text-align: right" | <tt style="white-space: nowrap">t??? swcl</tt>
| RW8
| Test OK (t), ROM wait state (s), ROM width (w),
Color system (c), Boot ROM lockout (l)
|-
! rowspan="5" | [[Timers]]
! $A2
| [[Timers#Timer Control|Timer Control]]
| style="text-align: right" | <tt style="white-space: nowrap">.... VvHh</tt>
| RW8
| Horizontal enable (h), auto reload (H)
Vertical enable (v), auto reload (V)
|-
! $A4
| [[Timers#Timer Reload|Horizontal Blank Timer Reload]]
| style="text-align: right" | <tt style="white-space: nowrap">tttt tttt tttt tttt</tt>
| RW16
| Ticks (t)
|-
! $A6
| [[Timers#Timer Reload|Vertical Blank Timer Reload]]
| style="text-align: right" | <tt style="white-space: nowrap">tttt tttt tttt tttt</tt>
| RW16
| Ticks (t)
|-
! $A8
| [[Timers#Timer Counter|Horizontal Blank Timer Counter]]
| style="text-align: right" | <tt style="white-space: nowrap">tttt tttt tttt tttt</tt>
| R16
| Ticks (t)
|-
! $AA
| [[Timers#Timer Counter|Vertical Blank Timer Counter]]
| style="text-align: right" | <tt style="white-space: nowrap">tttt tttt tttt tttt</tt>
| R16
| Ticks (t)
|-
! ?
! $AC
| ?
| style="text-align: right" | <tt style="white-space: nowrap">.... ...p</tt>
| W8?
| Power off (p)
|-
! rowspan="2" | [[Interrupts]]
! rowspan="2" | $B0
| [[Interrupts#Interrupt Vector Offset|Interrupt Vector Offset]]
| style="text-align: right" | <tt style="white-space: nowrap">VVVV V...</tt>
| W8
| Vector offset (V)
|-
| [[Interrupts#Interrupt Vector Request|Interrupt Vector Request]]
| style="text-align: right" | <tt style="white-space: nowrap">vvvv vvvv</tt>
| R8
| Requested vector offset (v)
|-
! rowspan="2" | [[UART]]
! $B1
| [[UART#Serial Receive Data|Serial Receive Data]]
| style="text-align: right" | <tt style="white-space: nowrap">dddd dddd</tt>
| R8
| Receive buffer data (d)
|-
! $B1
| [[UART#Serial Transmit Data|Serial Transmit Data]]
| style="text-align: right" | <tt style="white-space: nowrap">dddd dddd</tt>
| W8
| Transmit buffer data (d)
|-
! [[Interrupts]]
! $B2
| [[Interrupts#Interrupt Enable|Interrupt Enable]]
| style="text-align: right" | <tt style="white-space: nowrap">iiii iiii</tt>
| RW8
| Interrupt index (i)
|-
! rowspan="2" | [[UART]]
! $B3
| [[UART#Serial Status|Serial Status]]
| style="text-align: right" | <tt style="white-space: nowrap">eb.. .tor</tt>
| R8
| Enable (e), Baud rate (b),
Transfer ready (t), Overrun (o), Receive ready (r)
|-
! $B3
| [[UART#Serial Control|Serial Control]]
| style="text-align: right" | <tt style="white-space: nowrap">ebO. ....</tt>
| W8
| Enable (e), Baud rate (b), Reset Overrun (O)
|-
! [[Interrupts]]
! $B4
| [[Interrupts#Interrupt Status|Interrupt Status]]
| style="text-align: right" | <tt style="white-space: nowrap">iiii iiii</tt>
| R8
| Interrupt index (i)
|-
! [[Keypad]]
! $B5
| [[Keypad|Keypad Scan]]
| style="text-align: right" | <tt style="white-space: nowrap">.iii oooo</tt>
| RW8
| Input row (i), Output column (o)
|-
! rowspan="2" | [[Interrupts]]
! $B6
| [[Interrupts#Interrupt Acknowledge|Interrupt Acknowledge]]
| style="text-align: right" | <tt style="white-space: nowrap">iiii iiii</tt>
| W8
| Interrupt index (i)
|-
! $B7
| [[Interrupts#Interrupt NMI Control|Interrupt NMI Control]]
| style="text-align: right" | <tt style="white-space: nowrap">...b ....</tt>
| RW8
| Low battery (b)
|-
! rowspan="4" | [[EEPROM|Internal EEPROM]]
! $BA
| [[EEPROM#Internal EEPROM Data|Internal EEPROM Data]]
| style="text-align: right" | <tt style="white-space: nowrap">dddd dddd dddd dddd</tt>
| RW16
| Data (d)
|-
! $BC
| [[EEPROM#Internal EEPROM Command|Internal EEPROM Command]]
|
| RW16
|
|-
! rowspan="2" | $BE
| [[EEPROM#Internal EEPROM Status|Internal EEPROM Status]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .... p... ..RD</tt>
| R16
| Protected (p), Ready (R), Done (D)
|-
| [[EEPROM#Internal EEPROM Control|Internal EEPROM Control]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .... pewr ....</tt>
| W16
| Protect (p), Erase (e), Write (w), Read (r)
|-
! [[Mapper|Cartridge]]
! $C0<br />...<br />
$FF
| Cartridge I/O
|
| RW8
| Forwarded by the SoC
|}
== I/O port routing ==
The [[NEC V30MZ]] supports 16-bit I/O port addresses. The WonderSwan SoC routes them using the following algorithm:
* If an address is between <code>$00B8</code> and <code>$00BF</code> inclusive, it is routed to the internal EEPROM control block.
* If an address is between <code>$00C0</code> and <code>$00FF</code> inclusive, it is routed to the cartride bus.
* If an address's bits <code>0</code> through <code>8</code> inclusive are between <code>$000</code> and <code>$0B7</code> inclusive, they are routed to the SoC block.
* If none of these conditions are reached, open bus is read.
On the monochrome models, as well as color models in mono emulation, open bus is always <code>0x90</code>.
3b610589c20ad464118e57c883aefa49c6feb0b9
529
528
2025-02-23T16:07:53Z
Asie
351
wikitext
text/x-wiki
The WonderSwan SoC has three general blocks of I/O port accesses:
{| class="wikitable"
! From !! To !! Holder !! Width !! Speed
|-
| $00 || $B7 || WonderSwan SoC || 16-bit || 1 cycle
|-
| $B8 || $BF || Internal EEPROM control || 16-bit || 1 cycle
|-
| $C0 || $FF || Cartridge bus || 8-bit || 1<sup>(color)</sup>/2 cycles (configurable)
|}
With the exception of internal EEPROM on the ASWAN, all unaligned 16-bit accesses can be converted to two 8-bit accesses with a 1-cycle penalty.
== I/O port map ==
* Superscripts are used to mark ports specific to a given mode or platform:
** Color mode: <sup>(color)</sup>. Such ports are only accessible when color mode is enabled through port <code>$60</code>.
** WS/WSC/SC console: <sup>(WS)</sup>, <sup>(WSC)</sup>, <sup>(SC)</sup>.
* If two Bits rows are provided, the second one refers to the "Color" mode.
* The Type can be: R - readable, W - writable, L - writable before boot ROM lockout, 8/16 - width (byte/word).
{| class="wikitable"
! Category
! Port
! Description
! Bits
! Type
! Notes
|-
! rowspan="46" | [[Display]]
! $00
| [[Display/IO Ports#Display Control|Display Control]]
| style="text-align: right" | <tt style="white-space: nowrap">..wo Ws21</tt>
| RW8
|
|-
! $01
| [[Display/IO Ports#Display Background|Display Background]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .sss</tt>
<tt style="white-space: nowrap">pppp iiii</tt>
| RW8
| Shade (s)
Palette (p), Index (i)
|-
! $02
| [[Display/IO Ports#Current Line|Display Current Line]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll</tt>
| R8
| Line (l)
|-
! $03
| [[Display/IO Ports#Interrupt Line|Display Interrupt Line]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll</tt>
| RW8
| Line (l)
|-
! $04
| [[Display/IO Ports#Sprite Table Address|Sprite Table Address]]
| style="text-align: right" | <tt style="white-space: nowrap">...a aaaa</tt>
<tt style="white-space: nowrap">..aa aaaa</tt>
| RW8
| Address >> 9 (a)
|-
! $05
| [[Display/IO Ports#Sprite Table First|Sprite Table First]]
| style="text-align: right" | <tt style="white-space: nowrap">.iii iiii</tt>
| RW8
| Index (i)
|-
! $06
| [[Display/IO Ports#Sprite Table Count|Sprite Table Count]]
| style="text-align: right" | <tt style="white-space: nowrap">cccc cccc</tt>
| RW8
| Count (c)
|-
! $07
| [[Display/IO Ports#Screen Address|Screen Address]]
| style="text-align: right" | <tt style="white-space: nowrap">.222 .111</tt>
<tt style="white-space: nowrap">2222 1111</tt>
| RW8
| Screen 1 address >> 11 (1)
Screen 2 address >> 11 (2)
|-
! $08
| [[Display/IO Ports#Screen 2 Window|Screen 2 Window Left]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $09
| [[Display/IO Ports#Screen 2 Window|Screen 2 Window Top]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $0A
| [[Display/IO Ports#Screen 2 Window|Screen 2 Window Right]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $0B
| [[Display/IO Ports#Screen 2 Window|Screen 2 Window Bottom]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $0C
| [[Display/IO Ports#Sprite Window|Sprite Window Left]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $0D
| [[Display/IO Ports#Sprite Window|Sprite Window Top]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $0E
| [[Display/IO Ports#Sprite Window|Sprite Window Right]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $0F
| [[Display/IO Ports#Sprite Window|Sprite Window Bottom]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $10
| [[Display/IO Ports#Screen Scroll|Screen 1 Scroll X]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $11
| [[Display/IO Ports#Screen Scroll|Screen 1 Scroll Y]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $12
| [[Display/IO Ports#Screen Scroll|Screen 2 Scroll X]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $13
| [[Display/IO Ports#Screen Scroll|Screen 2 Scroll Y]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $14
| [[Display/IO Ports#LCD Control|LCD Control]]
| style="text-align: right" | <tt style="white-space: nowrap">.... ..Ce</tt>
| RW8
| Contrast (C)<sup>(WSC)</sup>, Enable (e)
|-
! $15
| [[Display/IO Ports#LCD Icon Control|LCD Icon Control]]
| style="text-align: right" | <tt style="white-space: nowrap">..32 1hvs</tt>
| RW8
| Etc. 3 (3), Etc. 2 (2), Etc. 1 (1),
Horizontal (h), Vertical (v), Sleep (s)
|-
! $16
| [[Display/IO Ports#LCD Final Line|LCD Final Line]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll</tt>
| RW8
| Line (l)
|-
! $17
| [[Display/IO Ports#LCD Back Porch Line|LCD Back Porch Line]]<sup>(WSC)</sup>
| style="text-align: right" | <tt style="white-space: nowrap">llll llll</tt>
| RW8
| Line (l)
|-
! $18
| [[Display/IO Ports#LCD Line Counter|LCD Line Counter]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll</tt>
| W8
| Line (l)
|-
! $1A
| [[Display/IO Ports#LCD Status|LCD Status]]
| style="text-align: right" | <tt style="white-space: nowrap">..cv vvhs</tt>
| RW8
| Cartridge icon (c), Volume icons (v),
Headphone icon (h), Sleep (s)
|-
! $1C
| [[Display/IO Ports#LCD Mono Shade LUT|LCD Mono Shade LUT 0/1]]
| style="text-align: right" | <tt style="white-space: nowrap">1111 0000</tt>
| RW8
| Shade index
|-
! $1D
| [[Display/IO Ports#LCD Mono Shade LUT|LCD Mono Shade LUT 2/3]]
| style="text-align: right" | <tt style="white-space: nowrap">3333 2222</tt>
| RW8
| Shade index
|-
! $1E
| [[Display/IO Ports#LCD Mono Shade LUT|LCD Mono Shade LUT 4/5]]
| style="text-align: right" | <tt style="white-space: nowrap">5555 4444</tt>
| RW8
| Shade index
|-
! $1F
| [[Display/IO Ports#LCD Mono Shade LUT|LCD Mono Shade LUT 6/7]]
| style="text-align: right" | <tt style="white-space: nowrap">7777 6666</tt>
| RW8
| Shade index
|-
! $20
| [[Display/IO Ports#LCD Mono Palette|LCD Mono Palette 0]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $22
| [[Display/IO Ports#LCD Mono Palette|LCD Mono Palette 1]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $24
| [[Display/IO Ports#LCD Mono Palette|LCD Mono Palette 2]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $26
| [[Display/IO Ports#LCD Mono Palette|LCD Mono Palette 3]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $28
| [[Display/IO Ports#LCD Mono Palette|LCD Mono Palette 4]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $2A
| [[Display/IO Ports#LCD Mono Palette|LCD Mono Palette 5]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $2C
| [[Display/IO Ports#LCD Mono Palette|LCD Mono Palette 6]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $2E
| [[Display/IO Ports#LCD Mono Palette|LCD Mono Palette 7]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $30
| [[Display/IO Ports#LCD Mono Palette|LCD Mono Palette 8]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $32
| [[Display/IO Ports#LCD Mono Palette|LCD Mono Palette 9]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $34
| [[Display/IO Ports#LCD Mono Palette|LCD Mono Palette 10]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $36
| [[Display/IO Ports#LCD Mono Palette|LCD Mono Palette 11]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $38
| [[Display/IO Ports#LCD Mono Palette|LCD Mono Palette 12]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $3A
| [[Display/IO Ports#LCD Mono Palette|LCD Mono Palette 13]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $3C
| [[Display/IO Ports#LCD Mono Palette|LCD Mono Palette 14]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $3E
| [[Display/IO Ports#LCD Mono Palette|LCD Mono Palette 15]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! rowspan="10" | [[DMA]]<sup>(color)</sup>
! $40
| [[DMA#General DMA|GDMA Source Address Low]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll llll lll.</tt>
| RW16
| Linear address, low 16 bits (l)
|-
! $42
| [[DMA#General DMA|GDMA Source Address High]]
| style="text-align: right" | <tt style="white-space: nowrap">.... hhhh</tt>
| RW8
| Linear address, high 4 bits (h)
|-
! $44
| [[DMA#General DMA|GDMA Destination Address]]
| style="text-align: right" | <tt style="white-space: nowrap">aaaa aaaa aaaa aaa.</tt>
| RW16
| IRAM address (a)
|-
! $46
| [[DMA#General DMA|GDMA Length]]
| style="text-align: right" | <tt style="white-space: nowrap">bbbb bbbb bbbb bbb.</tt>
| RW16
| Bytes (b)
|-
! $48
| [[DMA#General DMA|GDMA Control]]
| style="text-align: right" | <tt style="white-space: nowrap">ed.. ....</tt>
| RW8
| Enable (e), Decrement (d)
|-
! $4A
| [[DMA#Sound DMA|SDMA Source Address Low]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll llll llll</tt>
| RW16
| Linear address, low 16 bits (l)
|-
! $4C
| [[DMA#Sound DMA|SDMA Source Address High]]
| style="text-align: right" | <tt style="white-space: nowrap">.... hhhh</tt>
| RW8
| Linear address, high 4 bits (h)
|-
! $4E
| [[DMA#Sound DMA|SDMA Length Low]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll llll llll</tt>
| RW16
| Length, low 16 bits (l)
|-
! $50
| [[DMA#Sound DMA|SDMA Length High]]
| style="text-align: right" | <tt style="white-space: nowrap">.... hhhh</tt>
| RW8
| Length, high 4 bits (h)
|-
! $52
| [[DMA#Sound DMA|SDMA Control]]
| style="text-align: right" | <tt style="white-space: nowrap">ed.t rhff</tt>
| RW8
| Enable (e), Decrement (d), Target (t),
Repeat (r), Hold (h), Frequency (f)
|-
! rowspan="2" | [[SoC]]<sup>(color)</sup>
! $60
| [[SoC#System Control 2|System Control 2]]
| style="text-align: right" | <tt style="white-space: nowrap">c4C. i?sl</tt>
| RW8
| Color (c), 4BPP (4), Chunky (C),<br/>
Cart I/O wait state (i), SRAM wait state (s),<br/>
Cart clock speed (l).
|-
! $62
| [[SoC#System Control 3|System Control 3]]
| style="text-align: right" | <tt style="white-space: nowrap">S... ...p</tt>
| RW8
| SwanCrystal (S), Power off (p)
|-
! rowspan="4" | [[Hyper Voice]]<sup>(color)</sup>
! $64
| [[Hyper Voice#Hyper Voice Output|Hyper Voice Left Output]]
| style="text-align: right" | <tt style="white-space: nowrap">ssss ssss ssss ssss</tt>
| W16
| Raw sample (s)
|-
! $66
| [[Hyper Voice#Hyper Voice Output|Hyper Voice Right Output]]
| style="text-align: right" | <tt style="white-space: nowrap">ssss ssss ssss ssss</tt>
| W16
| Raw sample (s)
|-
! $69
| [[Hyper Voice#Hyper Voice Input|Hyper Voice Right Input]]
| style="text-align: right" | <tt style="white-space: nowrap">ssss ssss</tt>
| W8
| Sample (s)
|-
! $6A
| [[Hyper Voice#Hyper Voice Control|Hyper Voice Control]]
| style="text-align: right" | <tt style="white-space: nowrap">.mmc ???? errr ffss</tt>
| RW16
| Mask (m), Channel reset (c), Enable (e),
Rate (r), Format (f), Shift (s)
|-
! rowspan="8" | [[Display]]<sup>(SC)</sup>
! $70
| LCD Timing Configuration 1?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $71
| LCD Timing Configuration 2?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $72
| LCD Timing Configuration 3?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $73
| LCD Timing Configuration 4?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $74
| LCD Timing Configuration 5?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $75
| LCD Timing Configuration 6?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $76
| LCD Timing Configuration 7?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $77
| LCD Timing Configuration 8?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! rowspan="22" | [[Sound]]
! $80
| [[Sound#Sound Channel Frequency|Sound Channel 1 Frequency]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .ddd dddd dddd</tt>
| RW16
| Divider (d)
|-
! $82
| [[Sound#Sound Channel Frequency|Sound Channel 2 Frequency]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .ddd dddd dddd</tt>
| RW16
| Divider (d)
|-
! $84
| [[Sound#Sound Channel Frequency|Sound Channel 3 Frequency]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .ddd dddd dddd</tt>
| RW16
| Divider (d)
|-
! $86
| [[Sound#Sound Channel Frequency|Sound Channel 4 Frequency]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .ddd dddd dddd</tt>
| RW16
| Divider (d)
|-
! $88
| [[Sound#Sound Channel Volume|Sound Channel 1 Volume]]
| style="text-align: right" | <tt style="white-space: nowrap">llll rrrr</tt>
| RW8
| Left (l), Right (r)
|-
! rowspan="2" | $89
| [[Sound#Sound Channel Volume|Sound Channel 2 Volume]]
| style="text-align: right" | <tt style="white-space: nowrap">llll rrrr</tt>
| RW8
| Left (l), Right (r)
|-
| [[Sound#Sound Channel 2 Voice Sample|Sound Channel 2 Voice Sample]]
| style="text-align: right" | <tt style="white-space: nowrap">ssss ssss</tt>
| RW8
| Sample (s)
|-
! $8A
| [[Sound#Sound Channel Volume|Sound Channel 3 Volume]]
| style="text-align: right" | <tt style="white-space: nowrap">llll rrrr</tt>
| RW8
| Left (l), Right (r)
|-
! $8B
| [[Sound#Sound Channel Volume|Sound Channel 4 Volume]]
| style="text-align: right" | <tt style="white-space: nowrap">llll rrrr</tt>
| RW8
| Left (l), Right (r)
|-
! $8C
| [[Sound#Sound Channel 3 Sweep Amount|Sound Channel 3 Sweep Amount]]
| style="text-align: right" | <tt style="white-space: nowrap">vvvv vvvv</tt>
| RW8
| Value (v)
|-
! $8D
| [[Sound#Sound Channel 3 Sweep Ticks|Sound Channel 3 Sweep Ticks]]
| style="text-align: right" | <tt style="white-space: nowrap">...t tttt</tt>
| RW8
| Ticks (t)
|-
! $8E
| [[Sound#Sound Channel 4 Noise Control|Sound Channel 4 Noise Control]]
| style="text-align: right" | <tt style="white-space: nowrap">...e rttt</tt>
| RW8
| Enable (e), Reset (r), Tap (t)
|-
! $8F
| [[Sound#Sound Wavetable Address|Sound Wavetable Address]]
| style="text-align: right" | <tt style="white-space: nowrap">wwww wwww</tt>
| RW8
| Address >> 6 (w)
|-
! $90
| [[Sound#Sound Channel Control|Sound Channel Control]]
| style="text-align: right" | <tt style="white-space: nowrap">nsv. 4321</tt>
| RW8
| Channel enable (1234)
Noise (n), Sweep (s), Voice (v)
|-
! $91
| [[Sound#Sound Output Control|Sound Output Control]]
| style="text-align: right" | <tt style="white-space: nowrap">H... hrrs</tt>
| RW8
| Headphones connected (H)
Headphone output (h)
Speaker output (s), range (r)
|-
! $92
| [[Sound#Sound Channel 4 LFSR Register|Sound Channel 4 LFSR Register]]
| style="text-align: right" | <tt style="white-space: nowrap">.rrr rrrr rrrr rrrr</tt>
| R16
| PRNG state (r)
|-
! $94
| [[Sound#Sound Channel 2 Voice Volume|Sound Channel 2 Voice Volume]]
| style="text-align: right" | <tt style="white-space: nowrap">.... lLrR</tt>
| RW8
| Left Half (l), Full (L)
Right Half (r), Full (R)
|-
! $95
| [[Sound#Sound Test|Sound Test]]
| style="text-align: right" | <tt style="white-space: nowrap">425? ???h</tt>
| RW8
|
|-
! $96
| [[Sound#Sound Channel Output Right|Sound Channel Output Right]]
| style="text-align: right" | <tt style="white-space: nowrap">.... ..ss ssss ssss</tt>
| R16
| Sample (s)
|-
! $98
| [[Sound#Sound Channel Output Left|Sound Channel Output Left]]
| style="text-align: right" | <tt style="white-space: nowrap">.... ..ss ssss ssss</tt>
| R16
| Sample (s)
|-
! $9A
| [[Sound#Sound Channel Output Sum|Sound Channel Output Sum]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .sss ssss ssss</tt>
| R16
| Sample (s)
|-
! $9E
| [[Sound#Sound Speaker Main Volume|Sound Speaker Main Volume]]<sup>(color)</sup>
| style="text-align: right" | <tt style="white-space: nowrap">.... ..vv</tt>
| RW8
| Main volume (v)
|-
! [[SoC]]
! $A0
| [[SoC#System Control|System Control]]
| style="text-align: right" | <tt style="white-space: nowrap">t??? swcl</tt>
| RW8
| Test OK (t), ROM wait state (s), ROM width (w),
Color system (c), Boot ROM lockout (l)
|-
! rowspan="5" | [[Timers]]
! $A2
| [[Timers#Timer Control|Timer Control]]
| style="text-align: right" | <tt style="white-space: nowrap">.... VvHh</tt>
| RW8
| Horizontal enable (h), auto reload (H)
Vertical enable (v), auto reload (V)
|-
! $A4
| [[Timers#Timer Reload|Horizontal Blank Timer Reload]]
| style="text-align: right" | <tt style="white-space: nowrap">tttt tttt tttt tttt</tt>
| RW16
| Ticks (t)
|-
! $A6
| [[Timers#Timer Reload|Vertical Blank Timer Reload]]
| style="text-align: right" | <tt style="white-space: nowrap">tttt tttt tttt tttt</tt>
| RW16
| Ticks (t)
|-
! $A8
| [[Timers#Timer Counter|Horizontal Blank Timer Counter]]
| style="text-align: right" | <tt style="white-space: nowrap">tttt tttt tttt tttt</tt>
| R16
| Ticks (t)
|-
! $AA
| [[Timers#Timer Counter|Vertical Blank Timer Counter]]
| style="text-align: right" | <tt style="white-space: nowrap">tttt tttt tttt tttt</tt>
| R16
| Ticks (t)
|-
! ?
! $AC
| ?
| style="text-align: right" | <tt style="white-space: nowrap">.... ...p</tt>
| W8?
| Power off (p)
|-
! rowspan="2" | [[Interrupts]]
! rowspan="2" | $B0
| [[Interrupts#Interrupt Vector Offset|Interrupt Vector Offset]]
| style="text-align: right" | <tt style="white-space: nowrap">VVVV V...</tt>
| W8
| Vector offset (V)
|-
| [[Interrupts#Interrupt Vector Request|Interrupt Vector Request]]
| style="text-align: right" | <tt style="white-space: nowrap">vvvv vvvv</tt>
| R8
| Requested vector offset (v)
|-
! rowspan="2" | [[UART]]
! $B1
| [[UART#Serial Receive Data|Serial Receive Data]]
| style="text-align: right" | <tt style="white-space: nowrap">dddd dddd</tt>
| R8
| Receive buffer data (d)
|-
! $B1
| [[UART#Serial Transmit Data|Serial Transmit Data]]
| style="text-align: right" | <tt style="white-space: nowrap">dddd dddd</tt>
| W8
| Transmit buffer data (d)
|-
! [[Interrupts]]
! $B2
| [[Interrupts#Interrupt Enable|Interrupt Enable]]
| style="text-align: right" | <tt style="white-space: nowrap">iiii iiii</tt>
| RW8
| Interrupt index (i)
|-
! rowspan="2" | [[UART]]
! $B3
| [[UART#Serial Status|Serial Status]]
| style="text-align: right" | <tt style="white-space: nowrap">eb.. .tor</tt>
| R8
| Enable (e), Baud rate (b),
Transfer ready (t), Overrun (o), Receive ready (r)
|-
! $B3
| [[UART#Serial Control|Serial Control]]
| style="text-align: right" | <tt style="white-space: nowrap">ebO. ....</tt>
| W8
| Enable (e), Baud rate (b), Reset Overrun (O)
|-
! [[Interrupts]]
! $B4
| [[Interrupts#Interrupt Status|Interrupt Status]]
| style="text-align: right" | <tt style="white-space: nowrap">iiii iiii</tt>
| R8
| Interrupt index (i)
|-
! [[Keypad]]
! $B5
| [[Keypad|Keypad Scan]]
| style="text-align: right" | <tt style="white-space: nowrap">.iii oooo</tt>
| RW8
| Input row (i), Output column (o)
|-
! rowspan="2" | [[Interrupts]]
! $B6
| [[Interrupts#Interrupt Acknowledge|Interrupt Acknowledge]]
| style="text-align: right" | <tt style="white-space: nowrap">iiii iiii</tt>
| W8
| Interrupt index (i)
|-
! $B7
| [[Interrupts#Interrupt NMI Control|Interrupt NMI Control]]
| style="text-align: right" | <tt style="white-space: nowrap">...b ....</tt>
| RW8
| Low battery (b)
|-
! rowspan="4" | [[EEPROM|Internal EEPROM]]
! $BA
| [[EEPROM#Internal EEPROM Data|Internal EEPROM Data]]
| style="text-align: right" | <tt style="white-space: nowrap">dddd dddd dddd dddd</tt>
| RW16
| Data (d)
|-
! $BC
| [[EEPROM#Internal EEPROM Command|Internal EEPROM Command]]
|
| RW16
|
|-
! rowspan="2" | $BE
| [[EEPROM#Internal EEPROM Status|Internal EEPROM Status]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .... p... ..RD</tt>
| R16
| Protected (p), Ready (R), Done (D)
|-
| [[EEPROM#Internal EEPROM Control|Internal EEPROM Control]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .... pewr ....</tt>
| W16
| Protect (p), Erase (e), Write (w), Read (r)
|-
! [[Mapper|Cartridge]]
! $C0<br />...<br />
$FF
| Cartridge I/O
|
| RW8
| Forwarded by the SoC
|}
== I/O port routing ==
The [[NEC V30MZ]] supports 16-bit I/O port addresses. The WonderSwan SoC routes them using the following algorithm:
* If an address is between <code>$00B8</code> and <code>$00BF</code> inclusive, it is routed to the internal EEPROM control block.
* If an address is between <code>$00C0</code> and <code>$00FF</code> inclusive, it is routed to the cartride bus.
* If an address's bits <code>0</code> through <code>8</code> inclusive are between <code>$000</code> and <code>$0B7</code> inclusive, they are routed to the SoC block.
* If none of these conditions are reached, open bus is read.
On the monochrome models, as well as color models in mono emulation, open bus is always <code>0x90</code>.
258a463d8d2f8f51fc4f7eff2e7e031ce0b6b959
531
529
2025-02-23T20:08:46Z
Asie
351
wikitext
text/x-wiki
The WonderSwan SoC has three general blocks of I/O port accesses:
{| class="wikitable"
! From !! To !! Holder !! Width !! Speed
|-
| $00 || $B7 || WonderSwan SoC || 16-bit || 1 cycle
|-
| $B8 || $BF || Internal EEPROM control || 16-bit || 1 cycle
|-
| $C0 || $FF || Cartridge bus || 8-bit || 1<sup>(color)</sup>/2 cycles (configurable)
|}
With the exception of internal EEPROM on the ASWAN, all unaligned 16-bit accesses can be converted to two 8-bit accesses with a 1-cycle penalty.
== I/O port map ==
* Superscripts are used to mark ports specific to a given mode or platform:
** Color mode: <sup>(color)</sup>. Such ports are only accessible when color mode is enabled through port <code>$60</code>.
** WS/WSC/SC console: <sup>(WS)</sup>, <sup>(WSC)</sup>, <sup>(SC)</sup>.
* If two Bits rows are provided, the second one refers to the "Color" mode.
* The Type can be: R - readable, W - writable, L - writable before boot ROM lockout, 8/16 - width (byte/word).
{| class="wikitable"
! Category
! Port
! Description
! Bits
! Type
! Notes
|-
! rowspan="47" | [[Display]]
! $00
| [[Display/IO Ports#Display Control|Display Control]]
| style="text-align: right" | <tt style="white-space: nowrap">..wo Ws21</tt>
| RW8
|
|-
! $01
| [[Display/IO Ports#Display Background|Display Background]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .sss</tt>
<tt style="white-space: nowrap">pppp iiii</tt>
| RW8
| Shade (s)
Palette (p), Index (i)
|-
! $02
| [[Display/IO Ports#Current Line|Display Current Line]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll</tt>
| R8
| Line (l)
|-
! $03
| [[Display/IO Ports#Interrupt Line|Display Interrupt Line]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll</tt>
| RW8
| Line (l)
|-
! $04
| [[Display/IO Ports#Sprite Table Address|Sprite Table Address]]
| style="text-align: right" | <tt style="white-space: nowrap">...a aaaa</tt>
<tt style="white-space: nowrap">..aa aaaa</tt>
| RW8
| Address >> 9 (a)
|-
! $05
| [[Display/IO Ports#Sprite Table First|Sprite Table First]]
| style="text-align: right" | <tt style="white-space: nowrap">.iii iiii</tt>
| RW8
| Index (i)
|-
! $06
| [[Display/IO Ports#Sprite Table Count|Sprite Table Count]]
| style="text-align: right" | <tt style="white-space: nowrap">cccc cccc</tt>
| RW8
| Count (c)
|-
! $07
| [[Display/IO Ports#Screen Address|Screen Address]]
| style="text-align: right" | <tt style="white-space: nowrap">.222 .111</tt>
<tt style="white-space: nowrap">2222 1111</tt>
| RW8
| Screen 1 address >> 11 (1)
Screen 2 address >> 11 (2)
|-
! $08
| [[Display/IO Ports#Screen 2 Window|Screen 2 Window Left]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $09
| [[Display/IO Ports#Screen 2 Window|Screen 2 Window Top]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $0A
| [[Display/IO Ports#Screen 2 Window|Screen 2 Window Right]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $0B
| [[Display/IO Ports#Screen 2 Window|Screen 2 Window Bottom]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $0C
| [[Display/IO Ports#Sprite Window|Sprite Window Left]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $0D
| [[Display/IO Ports#Sprite Window|Sprite Window Top]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $0E
| [[Display/IO Ports#Sprite Window|Sprite Window Right]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $0F
| [[Display/IO Ports#Sprite Window|Sprite Window Bottom]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $10
| [[Display/IO Ports#Screen Scroll|Screen 1 Scroll X]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $11
| [[Display/IO Ports#Screen Scroll|Screen 1 Scroll Y]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $12
| [[Display/IO Ports#Screen Scroll|Screen 2 Scroll X]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $13
| [[Display/IO Ports#Screen Scroll|Screen 2 Scroll Y]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $14
| [[Display/IO Ports#LCD Control|LCD Control]]
| style="text-align: right" | <tt style="white-space: nowrap">.... ..Ce</tt>
| RW8
| Contrast (C)<sup>(WSC)</sup>, Enable (e)
|-
! $15
| [[Display/IO Ports#LCD Icon Control|LCD Icon Control]]
| style="text-align: right" | <tt style="white-space: nowrap">..32 1hvs</tt>
| RW8
| Etc. 3 (3), Etc. 2 (2), Etc. 1 (1),
Horizontal (h), Vertical (v), Sleep (s)
|-
! $16
| [[Display/IO Ports#LCD Final Line|LCD Final Line]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll</tt>
| RW8
| Line (l)
|-
! $17
| [[Display/IO Ports#LCD Back Porch Line|LCD Back Porch Line]]<sup>(WSC)</sup>
| style="text-align: right" | <tt style="white-space: nowrap">llll llll</tt>
| RW8
| Line (l)
|-
! $18
| [[Display/IO Ports#LCD Line Counter|LCD Line Counter]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll</tt>
| W8
| Line (l)
|-
! $1A
| [[Display/IO Ports#LCD Status|LCD Latched Icon Status]]
| style="text-align: right" | <tt style="white-space: nowrap">..cv vvhs</tt>
| R8
| Cartridge icon (c), Volume icons (v),
Headphone icon (h), Latch override (l)
|-
! $1A
| [[Display/IO Ports#LCD Status|LCD Latched Icon Control]]
| style="text-align: right" | <tt style="white-space: nowrap">..cv vvhs</tt>
| W8
| Cartridge (c), Sound (s), Latch override (l)
|-
! $1C
| [[Display/IO Ports#LCD Mono Shade LUT|LCD Mono Shade LUT 0/1]]
| style="text-align: right" | <tt style="white-space: nowrap">1111 0000</tt>
| RW8
| Shade index
|-
! $1D
| [[Display/IO Ports#LCD Mono Shade LUT|LCD Mono Shade LUT 2/3]]
| style="text-align: right" | <tt style="white-space: nowrap">3333 2222</tt>
| RW8
| Shade index
|-
! $1E
| [[Display/IO Ports#LCD Mono Shade LUT|LCD Mono Shade LUT 4/5]]
| style="text-align: right" | <tt style="white-space: nowrap">5555 4444</tt>
| RW8
| Shade index
|-
! $1F
| [[Display/IO Ports#LCD Mono Shade LUT|LCD Mono Shade LUT 6/7]]
| style="text-align: right" | <tt style="white-space: nowrap">7777 6666</tt>
| RW8
| Shade index
|-
! $20
| [[Display/IO Ports#LCD Mono Palette|LCD Mono Palette 0]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $22
| [[Display/IO Ports#LCD Mono Palette|LCD Mono Palette 1]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $24
| [[Display/IO Ports#LCD Mono Palette|LCD Mono Palette 2]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $26
| [[Display/IO Ports#LCD Mono Palette|LCD Mono Palette 3]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $28
| [[Display/IO Ports#LCD Mono Palette|LCD Mono Palette 4]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $2A
| [[Display/IO Ports#LCD Mono Palette|LCD Mono Palette 5]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $2C
| [[Display/IO Ports#LCD Mono Palette|LCD Mono Palette 6]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $2E
| [[Display/IO Ports#LCD Mono Palette|LCD Mono Palette 7]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $30
| [[Display/IO Ports#LCD Mono Palette|LCD Mono Palette 8]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $32
| [[Display/IO Ports#LCD Mono Palette|LCD Mono Palette 9]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $34
| [[Display/IO Ports#LCD Mono Palette|LCD Mono Palette 10]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $36
| [[Display/IO Ports#LCD Mono Palette|LCD Mono Palette 11]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $38
| [[Display/IO Ports#LCD Mono Palette|LCD Mono Palette 12]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $3A
| [[Display/IO Ports#LCD Mono Palette|LCD Mono Palette 13]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $3C
| [[Display/IO Ports#LCD Mono Palette|LCD Mono Palette 14]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $3E
| [[Display/IO Ports#LCD Mono Palette|LCD Mono Palette 15]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! rowspan="10" | [[DMA]]<sup>(color)</sup>
! $40
| [[DMA#General DMA|GDMA Source Address Low]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll llll lll.</tt>
| RW16
| Linear address, low 16 bits (l)
|-
! $42
| [[DMA#General DMA|GDMA Source Address High]]
| style="text-align: right" | <tt style="white-space: nowrap">.... hhhh</tt>
| RW8
| Linear address, high 4 bits (h)
|-
! $44
| [[DMA#General DMA|GDMA Destination Address]]
| style="text-align: right" | <tt style="white-space: nowrap">aaaa aaaa aaaa aaa.</tt>
| RW16
| IRAM address (a)
|-
! $46
| [[DMA#General DMA|GDMA Length]]
| style="text-align: right" | <tt style="white-space: nowrap">bbbb bbbb bbbb bbb.</tt>
| RW16
| Bytes (b)
|-
! $48
| [[DMA#General DMA|GDMA Control]]
| style="text-align: right" | <tt style="white-space: nowrap">ed.. ....</tt>
| RW8
| Enable (e), Decrement (d)
|-
! $4A
| [[DMA#Sound DMA|SDMA Source Address Low]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll llll llll</tt>
| RW16
| Linear address, low 16 bits (l)
|-
! $4C
| [[DMA#Sound DMA|SDMA Source Address High]]
| style="text-align: right" | <tt style="white-space: nowrap">.... hhhh</tt>
| RW8
| Linear address, high 4 bits (h)
|-
! $4E
| [[DMA#Sound DMA|SDMA Length Low]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll llll llll</tt>
| RW16
| Length, low 16 bits (l)
|-
! $50
| [[DMA#Sound DMA|SDMA Length High]]
| style="text-align: right" | <tt style="white-space: nowrap">.... hhhh</tt>
| RW8
| Length, high 4 bits (h)
|-
! $52
| [[DMA#Sound DMA|SDMA Control]]
| style="text-align: right" | <tt style="white-space: nowrap">ed.t rhff</tt>
| RW8
| Enable (e), Decrement (d), Target (t),
Repeat (r), Hold (h), Frequency (f)
|-
! rowspan="2" | [[SoC]]<sup>(color)</sup>
! $60
| [[SoC#System Control 2|System Control 2]]
| style="text-align: right" | <tt style="white-space: nowrap">c4C. i?sl</tt>
| RW8
| Color (c), 4BPP (4), Chunky (C),<br/>
Cart I/O wait state (i), SRAM wait state (s),<br/>
Cart clock speed (l).
|-
! $62
| [[SoC#System Control 3|System Control 3]]
| style="text-align: right" | <tt style="white-space: nowrap">S... ...p</tt>
| RW8
| SwanCrystal (S), Power off (p)
|-
! rowspan="4" | [[Hyper Voice]]<sup>(color)</sup>
! $64
| [[Hyper Voice#Hyper Voice Output|Hyper Voice Left Output]]
| style="text-align: right" | <tt style="white-space: nowrap">ssss ssss ssss ssss</tt>
| W16
| Raw sample (s)
|-
! $66
| [[Hyper Voice#Hyper Voice Output|Hyper Voice Right Output]]
| style="text-align: right" | <tt style="white-space: nowrap">ssss ssss ssss ssss</tt>
| W16
| Raw sample (s)
|-
! $69
| [[Hyper Voice#Hyper Voice Input|Hyper Voice Right Input]]
| style="text-align: right" | <tt style="white-space: nowrap">ssss ssss</tt>
| W8
| Sample (s)
|-
! $6A
| [[Hyper Voice#Hyper Voice Control|Hyper Voice Control]]
| style="text-align: right" | <tt style="white-space: nowrap">.mmc ???? errr ffss</tt>
| RW16
| Mask (m), Channel reset (c), Enable (e),
Rate (r), Format (f), Shift (s)
|-
! rowspan="8" | [[Display]]<sup>(SC)</sup>
! $70
| LCD Timing Configuration 1?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $71
| LCD Timing Configuration 2?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $72
| LCD Timing Configuration 3?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $73
| LCD Timing Configuration 4?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $74
| LCD Timing Configuration 5?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $75
| LCD Timing Configuration 6?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $76
| LCD Timing Configuration 7?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $77
| LCD Timing Configuration 8?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! rowspan="22" | [[Sound]]
! $80
| [[Sound#Sound Channel Frequency|Sound Channel 1 Frequency]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .ddd dddd dddd</tt>
| RW16
| Divider (d)
|-
! $82
| [[Sound#Sound Channel Frequency|Sound Channel 2 Frequency]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .ddd dddd dddd</tt>
| RW16
| Divider (d)
|-
! $84
| [[Sound#Sound Channel Frequency|Sound Channel 3 Frequency]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .ddd dddd dddd</tt>
| RW16
| Divider (d)
|-
! $86
| [[Sound#Sound Channel Frequency|Sound Channel 4 Frequency]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .ddd dddd dddd</tt>
| RW16
| Divider (d)
|-
! $88
| [[Sound#Sound Channel Volume|Sound Channel 1 Volume]]
| style="text-align: right" | <tt style="white-space: nowrap">llll rrrr</tt>
| RW8
| Left (l), Right (r)
|-
! rowspan="2" | $89
| [[Sound#Sound Channel Volume|Sound Channel 2 Volume]]
| style="text-align: right" | <tt style="white-space: nowrap">llll rrrr</tt>
| RW8
| Left (l), Right (r)
|-
| [[Sound#Sound Channel 2 Voice Sample|Sound Channel 2 Voice Sample]]
| style="text-align: right" | <tt style="white-space: nowrap">ssss ssss</tt>
| RW8
| Sample (s)
|-
! $8A
| [[Sound#Sound Channel Volume|Sound Channel 3 Volume]]
| style="text-align: right" | <tt style="white-space: nowrap">llll rrrr</tt>
| RW8
| Left (l), Right (r)
|-
! $8B
| [[Sound#Sound Channel Volume|Sound Channel 4 Volume]]
| style="text-align: right" | <tt style="white-space: nowrap">llll rrrr</tt>
| RW8
| Left (l), Right (r)
|-
! $8C
| [[Sound#Sound Channel 3 Sweep Amount|Sound Channel 3 Sweep Amount]]
| style="text-align: right" | <tt style="white-space: nowrap">vvvv vvvv</tt>
| RW8
| Value (v)
|-
! $8D
| [[Sound#Sound Channel 3 Sweep Ticks|Sound Channel 3 Sweep Ticks]]
| style="text-align: right" | <tt style="white-space: nowrap">...t tttt</tt>
| RW8
| Ticks (t)
|-
! $8E
| [[Sound#Sound Channel 4 Noise Control|Sound Channel 4 Noise Control]]
| style="text-align: right" | <tt style="white-space: nowrap">...e rttt</tt>
| RW8
| Enable (e), Reset (r), Tap (t)
|-
! $8F
| [[Sound#Sound Wavetable Address|Sound Wavetable Address]]
| style="text-align: right" | <tt style="white-space: nowrap">wwww wwww</tt>
| RW8
| Address >> 6 (w)
|-
! $90
| [[Sound#Sound Channel Control|Sound Channel Control]]
| style="text-align: right" | <tt style="white-space: nowrap">nsv. 4321</tt>
| RW8
| Channel enable (1234)
Noise (n), Sweep (s), Voice (v)
|-
! $91
| [[Sound#Sound Output Control|Sound Output Control]]
| style="text-align: right" | <tt style="white-space: nowrap">H... hrrs</tt>
| RW8
| Headphones connected (H)
Headphone output (h)
Speaker output (s), range (r)
|-
! $92
| [[Sound#Sound Channel 4 LFSR Register|Sound Channel 4 LFSR Register]]
| style="text-align: right" | <tt style="white-space: nowrap">.rrr rrrr rrrr rrrr</tt>
| R16
| PRNG state (r)
|-
! $94
| [[Sound#Sound Channel 2 Voice Volume|Sound Channel 2 Voice Volume]]
| style="text-align: right" | <tt style="white-space: nowrap">.... lLrR</tt>
| RW8
| Left Half (l), Full (L)
Right Half (r), Full (R)
|-
! $95
| [[Sound#Sound Test|Sound Test]]
| style="text-align: right" | <tt style="white-space: nowrap">425? ???h</tt>
| RW8
|
|-
! $96
| [[Sound#Sound Channel Output Right|Sound Channel Output Right]]
| style="text-align: right" | <tt style="white-space: nowrap">.... ..ss ssss ssss</tt>
| R16
| Sample (s)
|-
! $98
| [[Sound#Sound Channel Output Left|Sound Channel Output Left]]
| style="text-align: right" | <tt style="white-space: nowrap">.... ..ss ssss ssss</tt>
| R16
| Sample (s)
|-
! $9A
| [[Sound#Sound Channel Output Sum|Sound Channel Output Sum]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .sss ssss ssss</tt>
| R16
| Sample (s)
|-
! $9E
| [[Sound#Sound Speaker Main Volume|Sound Speaker Main Volume]]<sup>(color)</sup>
| style="text-align: right" | <tt style="white-space: nowrap">.... ..vv</tt>
| RW8
| Main volume (v)
|-
! [[SoC]]
! $A0
| [[SoC#System Control|System Control]]
| style="text-align: right" | <tt style="white-space: nowrap">t??? swcl</tt>
| RW8
| Test OK (t), ROM wait state (s), ROM width (w),
Color system (c), Boot ROM lockout (l)
|-
! rowspan="5" | [[Timers]]
! $A2
| [[Timers#Timer Control|Timer Control]]
| style="text-align: right" | <tt style="white-space: nowrap">.... VvHh</tt>
| RW8
| Horizontal enable (h), auto reload (H)
Vertical enable (v), auto reload (V)
|-
! $A4
| [[Timers#Timer Reload|Horizontal Blank Timer Reload]]
| style="text-align: right" | <tt style="white-space: nowrap">tttt tttt tttt tttt</tt>
| RW16
| Ticks (t)
|-
! $A6
| [[Timers#Timer Reload|Vertical Blank Timer Reload]]
| style="text-align: right" | <tt style="white-space: nowrap">tttt tttt tttt tttt</tt>
| RW16
| Ticks (t)
|-
! $A8
| [[Timers#Timer Counter|Horizontal Blank Timer Counter]]
| style="text-align: right" | <tt style="white-space: nowrap">tttt tttt tttt tttt</tt>
| R16
| Ticks (t)
|-
! $AA
| [[Timers#Timer Counter|Vertical Blank Timer Counter]]
| style="text-align: right" | <tt style="white-space: nowrap">tttt tttt tttt tttt</tt>
| R16
| Ticks (t)
|-
! ?
! $AC
| ?
| style="text-align: right" | <tt style="white-space: nowrap">.... ...p</tt>
| W8?
| Power off (p)
|-
! rowspan="2" | [[Interrupts]]
! rowspan="2" | $B0
| [[Interrupts#Interrupt Vector Offset|Interrupt Vector Offset]]
| style="text-align: right" | <tt style="white-space: nowrap">VVVV V...</tt>
| W8
| Vector offset (V)
|-
| [[Interrupts#Interrupt Vector Request|Interrupt Vector Request]]
| style="text-align: right" | <tt style="white-space: nowrap">vvvv vvvv</tt>
| R8
| Requested vector offset (v)
|-
! rowspan="2" | [[UART]]
! $B1
| [[UART#Serial Receive Data|Serial Receive Data]]
| style="text-align: right" | <tt style="white-space: nowrap">dddd dddd</tt>
| R8
| Receive buffer data (d)
|-
! $B1
| [[UART#Serial Transmit Data|Serial Transmit Data]]
| style="text-align: right" | <tt style="white-space: nowrap">dddd dddd</tt>
| W8
| Transmit buffer data (d)
|-
! [[Interrupts]]
! $B2
| [[Interrupts#Interrupt Enable|Interrupt Enable]]
| style="text-align: right" | <tt style="white-space: nowrap">iiii iiii</tt>
| RW8
| Interrupt index (i)
|-
! rowspan="2" | [[UART]]
! $B3
| [[UART#Serial Status|Serial Status]]
| style="text-align: right" | <tt style="white-space: nowrap">eb.. .tor</tt>
| R8
| Enable (e), Baud rate (b),
Transfer ready (t), Overrun (o), Receive ready (r)
|-
! $B3
| [[UART#Serial Control|Serial Control]]
| style="text-align: right" | <tt style="white-space: nowrap">ebO. ....</tt>
| W8
| Enable (e), Baud rate (b), Reset Overrun (O)
|-
! [[Interrupts]]
! $B4
| [[Interrupts#Interrupt Status|Interrupt Status]]
| style="text-align: right" | <tt style="white-space: nowrap">iiii iiii</tt>
| R8
| Interrupt index (i)
|-
! [[Keypad]]
! $B5
| [[Keypad|Keypad Scan]]
| style="text-align: right" | <tt style="white-space: nowrap">.iii oooo</tt>
| RW8
| Input row (i), Output column (o)
|-
! rowspan="2" | [[Interrupts]]
! $B6
| [[Interrupts#Interrupt Acknowledge|Interrupt Acknowledge]]
| style="text-align: right" | <tt style="white-space: nowrap">iiii iiii</tt>
| W8
| Interrupt index (i)
|-
! $B7
| [[Interrupts#Interrupt NMI Control|Interrupt NMI Control]]
| style="text-align: right" | <tt style="white-space: nowrap">...b ....</tt>
| RW8
| Low battery (b)
|-
! rowspan="4" | [[EEPROM|Internal EEPROM]]
! $BA
| [[EEPROM#Internal EEPROM Data|Internal EEPROM Data]]
| style="text-align: right" | <tt style="white-space: nowrap">dddd dddd dddd dddd</tt>
| RW16
| Data (d)
|-
! $BC
| [[EEPROM#Internal EEPROM Command|Internal EEPROM Command]]
|
| RW16
|
|-
! rowspan="2" | $BE
| [[EEPROM#Internal EEPROM Status|Internal EEPROM Status]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .... p... ..RD</tt>
| R16
| Protected (p), Ready (R), Done (D)
|-
| [[EEPROM#Internal EEPROM Control|Internal EEPROM Control]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .... pewr ....</tt>
| W16
| Protect (p), Erase (e), Write (w), Read (r)
|-
! [[Mapper|Cartridge]]
! $C0<br />...<br />
$FF
| Cartridge I/O
|
| RW8
| Forwarded by the SoC
|}
== I/O port routing ==
The [[NEC V30MZ]] supports 16-bit I/O port addresses. The WonderSwan SoC routes them using the following algorithm:
* If an address is between <code>$00B8</code> and <code>$00BF</code> inclusive, it is routed to the internal EEPROM control block.
* If an address is between <code>$00C0</code> and <code>$00FF</code> inclusive, it is routed to the cartride bus.
* If an address's bits <code>0</code> through <code>8</code> inclusive are between <code>$000</code> and <code>$0B7</code> inclusive, they are routed to the SoC block.
* If none of these conditions are reached, open bus is read.
On the monochrome models, as well as color models in mono emulation, open bus is always <code>0x90</code>.
b8cbc9ef7e841cc990587ee615b5764400246e94
533
531
2025-02-23T20:13:29Z
Asie
351
wikitext
text/x-wiki
The WonderSwan SoC has three general blocks of I/O port accesses:
{| class="wikitable"
! From !! To !! Holder !! Width !! Speed
|-
| $00 || $B7 || WonderSwan SoC || 16-bit || 1 cycle
|-
| $B8 || $BF || Internal EEPROM control || 16-bit || 1 cycle
|-
| $C0 || $FF || Cartridge bus || 8-bit || 1<sup>(color)</sup>/2 cycles (configurable)
|}
With the exception of internal EEPROM on the ASWAN, all unaligned 16-bit accesses can be converted to two 8-bit accesses with a 1-cycle penalty.
== I/O port map ==
* Superscripts are used to mark ports specific to a given mode or platform:
** Color mode: <sup>(color)</sup>. Such ports are only accessible when color mode is enabled through port <code>$60</code>.
** WS/WSC/SC console: <sup>(WS)</sup>, <sup>(WSC)</sup>, <sup>(SC)</sup>.
* If two Bits rows are provided, the second one refers to the "Color" mode.
* The Type can be: R - readable, W - writable, L - writable before boot ROM lockout, 8/16 - width (byte/word).
{| class="wikitable"
! Category
! Port
! Description
! Bits
! Type
! Notes
|-
! rowspan="47" | [[Display]]
! $00
| [[Display/IO Ports#Display Control|Display Control]]
| style="text-align: right" | <tt style="white-space: nowrap">..wo Ws21</tt>
| RW8
|
|-
! $01
| [[Display/IO Ports#Display Background|Display Background]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .sss</tt>
<tt style="white-space: nowrap">pppp iiii</tt>
| RW8
| Shade (s)
Palette (p), Index (i)
|-
! $02
| [[Display/IO Ports#Current Line|Display Current Line]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll</tt>
| R8
| Line (l)
|-
! $03
| [[Display/IO Ports#Interrupt Line|Display Interrupt Line]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll</tt>
| RW8
| Line (l)
|-
! $04
| [[Display/IO Ports#Sprite Table Address|Sprite Table Address]]
| style="text-align: right" | <tt style="white-space: nowrap">...a aaaa</tt>
<tt style="white-space: nowrap">..aa aaaa</tt>
| RW8
| Address >> 9 (a)
|-
! $05
| [[Display/IO Ports#Sprite Table First|Sprite Table First]]
| style="text-align: right" | <tt style="white-space: nowrap">.iii iiii</tt>
| RW8
| Index (i)
|-
! $06
| [[Display/IO Ports#Sprite Table Count|Sprite Table Count]]
| style="text-align: right" | <tt style="white-space: nowrap">cccc cccc</tt>
| RW8
| Count (c)
|-
! $07
| [[Display/IO Ports#Screen Address|Screen Address]]
| style="text-align: right" | <tt style="white-space: nowrap">.222 .111</tt>
<tt style="white-space: nowrap">2222 1111</tt>
| RW8
| Screen 1 address >> 11 (1)
Screen 2 address >> 11 (2)
|-
! $08
| [[Display/IO Ports#Screen 2 Window|Screen 2 Window Left]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $09
| [[Display/IO Ports#Screen 2 Window|Screen 2 Window Top]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $0A
| [[Display/IO Ports#Screen 2 Window|Screen 2 Window Right]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $0B
| [[Display/IO Ports#Screen 2 Window|Screen 2 Window Bottom]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $0C
| [[Display/IO Ports#Sprite Window|Sprite Window Left]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $0D
| [[Display/IO Ports#Sprite Window|Sprite Window Top]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $0E
| [[Display/IO Ports#Sprite Window|Sprite Window Right]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $0F
| [[Display/IO Ports#Sprite Window|Sprite Window Bottom]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $10
| [[Display/IO Ports#Screen Scroll|Screen 1 Scroll X]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $11
| [[Display/IO Ports#Screen Scroll|Screen 1 Scroll Y]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $12
| [[Display/IO Ports#Screen Scroll|Screen 2 Scroll X]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $13
| [[Display/IO Ports#Screen Scroll|Screen 2 Scroll Y]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $14
| [[Display/IO Ports#LCD Control|LCD Control]]
| style="text-align: right" | <tt style="white-space: nowrap">.... ..Ce</tt>
| RW8
| Contrast (C)<sup>(WSC)</sup>, Enable (e)
|-
! $15
| [[Display/IO Ports#LCD Icon Control|LCD Icon Control]]
| style="text-align: right" | <tt style="white-space: nowrap">..32 1hvs</tt>
| RW8
| Etc. 3 (3), Etc. 2 (2), Etc. 1 (1),
Horizontal (h), Vertical (v), Sleep (s)
|-
! $16
| [[Display/IO Ports#LCD Final Line|LCD Final Line]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll</tt>
| RW8
| Line (l)
|-
! $17
| [[Display/IO Ports#LCD Back Porch Line|LCD Back Porch Line]]<sup>(WSC)</sup>
| style="text-align: right" | <tt style="white-space: nowrap">llll llll</tt>
| RW8
| Line (l)
|-
! $18
| [[Display/IO Ports#LCD Line Counter|LCD Line Counter]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll</tt>
| W8
| Line (l)
|-
! $1A
| [[Display/IO Ports#LCD Status|LCD Latched Icon Status]]
| style="text-align: right" | <tt style="white-space: nowrap">..cv vvhs</tt>
| R8
| Cartridge icon (c), Volume icons (v),
Headphone icon (h), Latch override (l)
|-
! $1A
| [[Display/IO Ports#LCD Status|LCD Latched Icon Control]]
| style="text-align: right" | <tt style="white-space: nowrap">..cv vvhs</tt>
| W8
| Cartridge (c), Sound (s), Latch override (l)
|-
! $1C
| [[Display/IO Ports#LCD Mono Shade LUT|LCD Mono Shade LUT 0/1]]
| style="text-align: right" | <tt style="white-space: nowrap">1111 0000</tt>
| RW8
| Shade index
|-
! $1D
| [[Display/IO Ports#LCD Mono Shade LUT|LCD Mono Shade LUT 2/3]]
| style="text-align: right" | <tt style="white-space: nowrap">3333 2222</tt>
| RW8
| Shade index
|-
! $1E
| [[Display/IO Ports#LCD Mono Shade LUT|LCD Mono Shade LUT 4/5]]
| style="text-align: right" | <tt style="white-space: nowrap">5555 4444</tt>
| RW8
| Shade index
|-
! $1F
| [[Display/IO Ports#LCD Mono Shade LUT|LCD Mono Shade LUT 6/7]]
| style="text-align: right" | <tt style="white-space: nowrap">7777 6666</tt>
| RW8
| Shade index
|-
! $20
| [[Display/IO Ports#LCD Mono Palette|LCD Mono Palette 0]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $22
| [[Display/IO Ports#LCD Mono Palette|LCD Mono Palette 1]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $24
| [[Display/IO Ports#LCD Mono Palette|LCD Mono Palette 2]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $26
| [[Display/IO Ports#LCD Mono Palette|LCD Mono Palette 3]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $28
| [[Display/IO Ports#LCD Mono Palette|LCD Mono Palette 4]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $2A
| [[Display/IO Ports#LCD Mono Palette|LCD Mono Palette 5]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $2C
| [[Display/IO Ports#LCD Mono Palette|LCD Mono Palette 6]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $2E
| [[Display/IO Ports#LCD Mono Palette|LCD Mono Palette 7]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $30
| [[Display/IO Ports#LCD Mono Palette|LCD Mono Palette 8]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $32
| [[Display/IO Ports#LCD Mono Palette|LCD Mono Palette 9]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $34
| [[Display/IO Ports#LCD Mono Palette|LCD Mono Palette 10]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $36
| [[Display/IO Ports#LCD Mono Palette|LCD Mono Palette 11]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $38
| [[Display/IO Ports#LCD Mono Palette|LCD Mono Palette 12]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $3A
| [[Display/IO Ports#LCD Mono Palette|LCD Mono Palette 13]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $3C
| [[Display/IO Ports#LCD Mono Palette|LCD Mono Palette 14]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $3E
| [[Display/IO Ports#LCD Mono Palette|LCD Mono Palette 15]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! rowspan="10" | [[DMA]]<sup>(color)</sup>
! $40
| [[DMA#General DMA|GDMA Source Address Low]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll llll lll.</tt>
| RW16
| Linear address, low 16 bits (l)
|-
! $42
| [[DMA#General DMA|GDMA Source Address High]]
| style="text-align: right" | <tt style="white-space: nowrap">.... hhhh</tt>
| RW8
| Linear address, high 4 bits (h)
|-
! $44
| [[DMA#General DMA|GDMA Destination Address]]
| style="text-align: right" | <tt style="white-space: nowrap">aaaa aaaa aaaa aaa.</tt>
| RW16
| IRAM address (a)
|-
! $46
| [[DMA#General DMA|GDMA Length]]
| style="text-align: right" | <tt style="white-space: nowrap">bbbb bbbb bbbb bbb.</tt>
| RW16
| Bytes (b)
|-
! $48
| [[DMA#General DMA|GDMA Control]]
| style="text-align: right" | <tt style="white-space: nowrap">ed.. ....</tt>
| RW8
| Enable (e), Decrement (d)
|-
! $4A
| [[DMA#Sound DMA|SDMA Source Address Low]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll llll llll</tt>
| RW16
| Linear address, low 16 bits (l)
|-
! $4C
| [[DMA#Sound DMA|SDMA Source Address High]]
| style="text-align: right" | <tt style="white-space: nowrap">.... hhhh</tt>
| RW8
| Linear address, high 4 bits (h)
|-
! $4E
| [[DMA#Sound DMA|SDMA Length Low]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll llll llll</tt>
| RW16
| Length, low 16 bits (l)
|-
! $50
| [[DMA#Sound DMA|SDMA Length High]]
| style="text-align: right" | <tt style="white-space: nowrap">.... hhhh</tt>
| RW8
| Length, high 4 bits (h)
|-
! $52
| [[DMA#Sound DMA|SDMA Control]]
| style="text-align: right" | <tt style="white-space: nowrap">ed.t rhff</tt>
| RW8
| Enable (e), Decrement (d), Target (t),
Repeat (r), Hold (h), Frequency (f)
|-
! rowspan="2" | [[SoC]]<sup>(color)</sup>
! $60
| [[SoC#System Control 2|System Control 2]]
| style="text-align: right" | <tt style="white-space: nowrap">c4C. i?sl</tt>
| RW8
| Color (c), 4BPP (4), Chunky (C),<br/>
Cart I/O wait state (i), SRAM wait state (s),<br/>
Cart clock speed (l).
|-
! $62
| [[SoC#System Control 3|System Control 3]]
| style="text-align: right" | <tt style="white-space: nowrap">S... ...p</tt>
| RW8
| SwanCrystal (S), Power off (p)
|-
! rowspan="4" | [[Hyper Voice]]<sup>(color)</sup>
! $64
| [[Hyper Voice#Hyper Voice Output|Hyper Voice Left Output]]
| style="text-align: right" | <tt style="white-space: nowrap">ssss ssss ssss ssss</tt>
| W16
| Raw sample (s)
|-
! $66
| [[Hyper Voice#Hyper Voice Output|Hyper Voice Right Output]]
| style="text-align: right" | <tt style="white-space: nowrap">ssss ssss ssss ssss</tt>
| W16
| Raw sample (s)
|-
! $69
| [[Hyper Voice#Hyper Voice Input|Hyper Voice Right Input]]
| style="text-align: right" | <tt style="white-space: nowrap">ssss ssss</tt>
| W8
| Sample (s)
|-
! $6A
| [[Hyper Voice#Hyper Voice Control|Hyper Voice Control]]
| style="text-align: right" | <tt style="white-space: nowrap">.mmc ???? errr ffss</tt>
| RW16
| Mask (m), Channel reset (c), Enable (e),
Rate (r), Format (f), Shift (s)
|-
! rowspan="8" | [[Display]]<sup>(SC)</sup>
! $70
| LCD Timing Configuration 1?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $71
| LCD Timing Configuration 2?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $72
| LCD Timing Configuration 3?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $73
| LCD Timing Configuration 4?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $74
| LCD Timing Configuration 5?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $75
| LCD Timing Configuration 6?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $76
| LCD Timing Configuration 7?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $77
| LCD Timing Configuration 8?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! rowspan="22" | [[Sound]]
! $80
| [[Sound#Sound Channel Frequency|Sound Channel 1 Frequency]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .ddd dddd dddd</tt>
| RW16
| Divider (d)
|-
! $82
| [[Sound#Sound Channel Frequency|Sound Channel 2 Frequency]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .ddd dddd dddd</tt>
| RW16
| Divider (d)
|-
! $84
| [[Sound#Sound Channel Frequency|Sound Channel 3 Frequency]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .ddd dddd dddd</tt>
| RW16
| Divider (d)
|-
! $86
| [[Sound#Sound Channel Frequency|Sound Channel 4 Frequency]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .ddd dddd dddd</tt>
| RW16
| Divider (d)
|-
! $88
| [[Sound#Sound Channel Volume|Sound Channel 1 Volume]]
| style="text-align: right" | <tt style="white-space: nowrap">llll rrrr</tt>
| RW8
| Left (l), Right (r)
|-
! rowspan="2" | $89
| [[Sound#Sound Channel Volume|Sound Channel 2 Volume]]
| style="text-align: right" | <tt style="white-space: nowrap">llll rrrr</tt>
| RW8
| Left (l), Right (r)
|-
| [[Sound#Sound Channel 2 Voice Sample|Sound Channel 2 Voice Sample]]
| style="text-align: right" | <tt style="white-space: nowrap">ssss ssss</tt>
| RW8
| Sample (s)
|-
! $8A
| [[Sound#Sound Channel Volume|Sound Channel 3 Volume]]
| style="text-align: right" | <tt style="white-space: nowrap">llll rrrr</tt>
| RW8
| Left (l), Right (r)
|-
! $8B
| [[Sound#Sound Channel Volume|Sound Channel 4 Volume]]
| style="text-align: right" | <tt style="white-space: nowrap">llll rrrr</tt>
| RW8
| Left (l), Right (r)
|-
! $8C
| [[Sound#Sound Channel 3 Sweep Amount|Sound Channel 3 Sweep Amount]]
| style="text-align: right" | <tt style="white-space: nowrap">vvvv vvvv</tt>
| RW8
| Value (v)
|-
! $8D
| [[Sound#Sound Channel 3 Sweep Ticks|Sound Channel 3 Sweep Ticks]]
| style="text-align: right" | <tt style="white-space: nowrap">...t tttt</tt>
| RW8
| Ticks (t)
|-
! $8E
| [[Sound#Sound Channel 4 Noise Control|Sound Channel 4 Noise Control]]
| style="text-align: right" | <tt style="white-space: nowrap">...e rttt</tt>
| RW8
| Enable (e), Reset (r), Tap (t)
|-
! $8F
| [[Sound#Sound Wavetable Address|Sound Wavetable Address]]
| style="text-align: right" | <tt style="white-space: nowrap">wwww wwww</tt>
| RW8
| Address >> 6 (w)
|-
! $90
| [[Sound#Sound Channel Control|Sound Channel Control]]
| style="text-align: right" | <tt style="white-space: nowrap">nsv. 4321</tt>
| RW8
| Channel enable (1234)
Noise (n), Sweep (s), Voice (v)
|-
! $91
| [[Sound#Sound Output Control|Sound Output Control]]
| style="text-align: right" | <tt style="white-space: nowrap">H... hrrs</tt>
| RW8
| Headphones connected (H)
Headphone output (h)
Speaker output (s), range (r)
|-
! $92
| [[Sound#Sound Channel 4 LFSR Register|Sound Channel 4 LFSR Register]]
| style="text-align: right" | <tt style="white-space: nowrap">.rrr rrrr rrrr rrrr</tt>
| R16
| PRNG state (r)
|-
! $94
| [[Sound#Sound Channel 2 Voice Volume|Sound Channel 2 Voice Volume]]
| style="text-align: right" | <tt style="white-space: nowrap">.... lLrR</tt>
| RW8
| Left Half (l), Full (L)
Right Half (r), Full (R)
|-
! $95
| [[Sound#Sound Test|Sound Test]]
| style="text-align: right" | <tt style="white-space: nowrap">425? ???h</tt>
| RW8
|
|-
! $96
| [[Sound#Sound Channel Output Right|Sound Channel Output Right]]
| style="text-align: right" | <tt style="white-space: nowrap">.... ..ss ssss ssss</tt>
| R16
| Sample (s)
|-
! $98
| [[Sound#Sound Channel Output Left|Sound Channel Output Left]]
| style="text-align: right" | <tt style="white-space: nowrap">.... ..ss ssss ssss</tt>
| R16
| Sample (s)
|-
! $9A
| [[Sound#Sound Channel Output Sum|Sound Channel Output Sum]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .sss ssss ssss</tt>
| R16
| Sample (s)
|-
! $9E
| [[Sound#Sound Speaker Main Volume|Sound Speaker Main Volume]]<sup>(color)</sup>
| style="text-align: right" | <tt style="white-space: nowrap">.... ..vv</tt>
| RW8
| Main volume (v)
|-
! [[SoC]]
! $A0
| [[SoC#System Control|System Control]]
| style="text-align: right" | <tt style="white-space: nowrap">C??? swcl</tt>
| RW8
| Cartridge OK (C), ROM wait state (s), ROM width (w),
Color system (c), Boot ROM lockout (l)
|-
! rowspan="5" | [[Timers]]
! $A2
| [[Timers#Timer Control|Timer Control]]
| style="text-align: right" | <tt style="white-space: nowrap">.... VvHh</tt>
| RW8
| Horizontal enable (h), auto reload (H)
Vertical enable (v), auto reload (V)
|-
! $A4
| [[Timers#Timer Reload|Horizontal Blank Timer Reload]]
| style="text-align: right" | <tt style="white-space: nowrap">tttt tttt tttt tttt</tt>
| RW16
| Ticks (t)
|-
! $A6
| [[Timers#Timer Reload|Vertical Blank Timer Reload]]
| style="text-align: right" | <tt style="white-space: nowrap">tttt tttt tttt tttt</tt>
| RW16
| Ticks (t)
|-
! $A8
| [[Timers#Timer Counter|Horizontal Blank Timer Counter]]
| style="text-align: right" | <tt style="white-space: nowrap">tttt tttt tttt tttt</tt>
| R16
| Ticks (t)
|-
! $AA
| [[Timers#Timer Counter|Vertical Blank Timer Counter]]
| style="text-align: right" | <tt style="white-space: nowrap">tttt tttt tttt tttt</tt>
| R16
| Ticks (t)
|-
! ?
! $AC
| ?
| style="text-align: right" | <tt style="white-space: nowrap">.... ...p</tt>
| W8?
| Power off (p)
|-
! rowspan="2" | [[Interrupts]]
! rowspan="2" | $B0
| [[Interrupts#Interrupt Vector Offset|Interrupt Vector Offset]]
| style="text-align: right" | <tt style="white-space: nowrap">VVVV V...</tt>
| W8
| Vector offset (V)
|-
| [[Interrupts#Interrupt Vector Request|Interrupt Vector Request]]
| style="text-align: right" | <tt style="white-space: nowrap">vvvv vvvv</tt>
| R8
| Requested vector offset (v)
|-
! rowspan="2" | [[UART]]
! $B1
| [[UART#Serial Receive Data|Serial Receive Data]]
| style="text-align: right" | <tt style="white-space: nowrap">dddd dddd</tt>
| R8
| Receive buffer data (d)
|-
! $B1
| [[UART#Serial Transmit Data|Serial Transmit Data]]
| style="text-align: right" | <tt style="white-space: nowrap">dddd dddd</tt>
| W8
| Transmit buffer data (d)
|-
! [[Interrupts]]
! $B2
| [[Interrupts#Interrupt Enable|Interrupt Enable]]
| style="text-align: right" | <tt style="white-space: nowrap">iiii iiii</tt>
| RW8
| Interrupt index (i)
|-
! rowspan="2" | [[UART]]
! $B3
| [[UART#Serial Status|Serial Status]]
| style="text-align: right" | <tt style="white-space: nowrap">eb.. .tor</tt>
| R8
| Enable (e), Baud rate (b),
Transfer ready (t), Overrun (o), Receive ready (r)
|-
! $B3
| [[UART#Serial Control|Serial Control]]
| style="text-align: right" | <tt style="white-space: nowrap">ebO. ....</tt>
| W8
| Enable (e), Baud rate (b), Reset Overrun (O)
|-
! [[Interrupts]]
! $B4
| [[Interrupts#Interrupt Status|Interrupt Status]]
| style="text-align: right" | <tt style="white-space: nowrap">iiii iiii</tt>
| R8
| Interrupt index (i)
|-
! [[Keypad]]
! $B5
| [[Keypad|Keypad Scan]]
| style="text-align: right" | <tt style="white-space: nowrap">.iii oooo</tt>
| RW8
| Input row (i), Output column (o)
|-
! rowspan="2" | [[Interrupts]]
! $B6
| [[Interrupts#Interrupt Acknowledge|Interrupt Acknowledge]]
| style="text-align: right" | <tt style="white-space: nowrap">iiii iiii</tt>
| W8
| Interrupt index (i)
|-
! $B7
| [[Interrupts#Interrupt NMI Control|Interrupt NMI Control]]
| style="text-align: right" | <tt style="white-space: nowrap">...b ....</tt>
| RW8
| Low battery (b)
|-
! rowspan="4" | [[EEPROM|Internal EEPROM]]
! $BA
| [[EEPROM#Internal EEPROM Data|Internal EEPROM Data]]
| style="text-align: right" | <tt style="white-space: nowrap">dddd dddd dddd dddd</tt>
| RW16
| Data (d)
|-
! $BC
| [[EEPROM#Internal EEPROM Command|Internal EEPROM Command]]
|
| RW16
|
|-
! rowspan="2" | $BE
| [[EEPROM#Internal EEPROM Status|Internal EEPROM Status]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .... p... ..RD</tt>
| R16
| Protected (p), Ready (R), Done (D)
|-
| [[EEPROM#Internal EEPROM Control|Internal EEPROM Control]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .... pewr ....</tt>
| W16
| Protect (p), Erase (e), Write (w), Read (r)
|-
! [[Mapper|Cartridge]]
! $C0<br />...<br />
$FF
| Cartridge I/O
|
| RW8
| Forwarded by the SoC
|}
== I/O port routing ==
The [[NEC V30MZ]] supports 16-bit I/O port addresses. The WonderSwan SoC routes them using the following algorithm:
* If an address is between <code>$00B8</code> and <code>$00BF</code> inclusive, it is routed to the internal EEPROM control block.
* If an address is between <code>$00C0</code> and <code>$00FF</code> inclusive, it is routed to the cartride bus.
* If an address's bits <code>0</code> through <code>8</code> inclusive are between <code>$000</code> and <code>$0B7</code> inclusive, they are routed to the SoC block.
* If none of these conditions are reached, open bus is read.
On the monochrome models, as well as color models in mono emulation, open bus is always <code>0x90</code>.
2c5cfed0b0dbfa80c069add2cd83c205cf9412ed
Display/LCD Icons
0
75
503
2025-02-23T09:38:09Z
Asie
351
Created page with "The WonderSwan features thirteen fixed LCD segments which are displayed to the right<sup>(color)</sup> or below<sup>(mono)</sup> the main display. These are: * [[#LCD_Icon_Control_($15)|Six under control of software]] ** Large circle ** Medium circle ** Small circle ** Horizontal orientation ** Vertical orientation ** (Shooting) Star (Sleep) * [[#LCD_Status_($1A)|Four software can query]] ** Speaker ** Volume A (small wave<sup>(mono)</sup>, center wave<sup>(color)</sup..."
wikitext
text/x-wiki
The WonderSwan features thirteen fixed LCD segments which are displayed to the right<sup>(color)</sup> or below<sup>(mono)</sup> the main display. These are:
* [[#LCD_Icon_Control_($15)|Six under control of software]]
** Large circle
** Medium circle
** Small circle
** Horizontal orientation
** Vertical orientation
** (Shooting) Star (Sleep)
* [[#LCD_Status_($1A)|Four software can query]]
** Speaker
** Volume A (small wave<sup>(mono)</sup>, center wave<sup>(color)</sup>)
** Volume B (big wave<sup>(mono)</sup>, outside two waves<sup>(color)</sup>)
** Headphones
* [[Interrupts#Interrupt_NMI_Control_($B7)|One that the software can infer]]
** Low battery
* Two that are entirely invisible to software
** Power on ("Egg", resembles the mono power switch)
** Cartridge
8b79cb7a16de9ec06ea7148e2f7c32c0e6bc149d
524
503
2025-02-23T15:42:57Z
Asie
351
wikitext
text/x-wiki
The WonderSwan features thirteen fixed LCD segments which are displayed to the right<sup>(color)</sup> or below<sup>(mono)</sup> the main display. These are:
* [[#LCD_Icon_Control_($15)|Six under control of software]]
** Large circle
** Medium circle
** Small circle
** Horizontal orientation
** Vertical orientation
** (Shooting) Star (Sleep)
* [[#LCD_Status_($1A)|Four software can query]]
** Speaker
** Volume A (small wave<sup>(mono)</sup>, center wave<sup>(color)</sup>)
** Volume B (big wave<sup>(mono)</sup>, outside two waves<sup>(color)</sup>)
** Headphones
** Cartridge
* [[Interrupts#Interrupt_NMI_Control_($B7)|One that the software can infer]]
** Low battery
* One that is entirely invisible to software
** Power on ("Egg", resembles the mono power switch)
22ecaa19c195e46a506d873cdfbc20f42260ab0f
525
524
2025-02-23T15:43:08Z
Asie
351
wikitext
text/x-wiki
The WonderSwan features thirteen fixed LCD segments which are displayed to the right<sup>(color)</sup> or below<sup>(mono)</sup> the main display. These are:
* [[#LCD_Icon_Control_($15)|Six under control of software]]
** Large circle
** Medium circle
** Small circle
** Horizontal orientation
** Vertical orientation
** (Shooting) Star (Sleep)
* [[#LCD_Status_($1A)|Five software can query]]
** Speaker
** Volume A (small wave<sup>(mono)</sup>, center wave<sup>(color)</sup>)
** Volume B (big wave<sup>(mono)</sup>, outside two waves<sup>(color)</sup>)
** Headphones
** Cartridge
* [[Interrupts#Interrupt_NMI_Control_($B7)|One that the software can infer]]
** Low battery
* One that is entirely invisible to software
** Power on ("Egg", resembles the mono power switch)
1e7bb451d39b629f8b06f66fe49c43a827f8d4f7
535
525
2025-02-23T20:14:11Z
Asie
351
wikitext
text/x-wiki
The WonderSwan features thirteen fixed LCD segments which are displayed to the right<sup>(color)</sup> or below<sup>(mono)</sup> the main display. These are:
* [[Display/IO Ports#LCD_Icon_Control_($15)|Six controlled by software]]
** Large circle
** Medium circle
** Small circle
** Horizontal orientation
** Vertical orientation
** (Shooting) Star (Sleep)
* [[Display/IO Ports#LCD Status|Five controlled by hardware latches]]
** Speaker
** Volume A (small wave<sup>(mono)</sup>, center wave<sup>(color)</sup>)
** Volume B (big wave<sup>(mono)</sup>, outside two waves<sup>(color)</sup>)
** Headphones
** Cartridge
* [[Interrupts#Interrupt_NMI_Control_($B7)|One that the software can infer]]
** Low battery
* One that is entirely invisible to software
** Power on ("Egg", resembles the mono power switch)
== Hardware latch behaviour ==
There are two hardware latches: one controls the cartridge icon, while the other controls the sound icons. These latches are always displayed for an additional 128 ticks after their display condition stops being true.
=== Sound icons ===
The volume and headphone icon are enabled when pressing the SOUND button, according to this algorithm:
* If headphones are plugged in, show the Headphone icon.
* If headphones are not plugged in, show the Speaker icon and the following Volume icons:
** Volume level 0: None
** Volume level 1: A
** Volume level 2: B
** Volume level 3: A, B
TODO: This documents the WonderSwan Color. The specifics probably work differently on the mono WonderSwan.
=== Cartridge icon ===
The cartridge icon is displayed for 128 ticks after the [[SoC#System Control|System Control]] cartridge test passes on console start.
9a1f906d4191205c3ed0cf6bafb2e045703ab3c4
540
535
2025-02-24T18:30:22Z
Asie
351
wikitext
text/x-wiki
The WonderSwan features thirteen fixed LCD segments which are displayed to the right<sup>(color)</sup> or below<sup>(mono)</sup> the main display. These are:
* [[Display/IO Ports#LCD_Icon_Control_($15)|Six controlled by software]]
** Large circle
** Medium circle
** Small circle
** Horizontal orientation
** Vertical orientation
** (Shooting) Star (Sleep)
* [[Display/IO Ports#LCD Status|Five controlled by hardware latches]]
** Speaker
** Volume A (small wave<sup>(mono)</sup>, center wave<sup>(color)</sup>)
** Volume B (big wave<sup>(mono)</sup>, outside two waves<sup>(color)</sup>)
** Headphones
** Cartridge
* [[Interrupts#Interrupt_NMI_Control_($B7)|One that the software can infer]]
** Low battery
* One that is entirely invisible to software
** Power on ("Egg", resembles the mono power switch)
== Hardware latch behaviour ==
There are two hardware latches: one controls the cartridge icon, while the other controls the sound icons. These latches are always displayed for an additional 128 vertical blanks after their display condition stops being true.
=== Sound icons ===
The volume and headphone icon are enabled when pressing the SOUND button, according to this algorithm:
* If headphones are plugged in, show the Headphone icon.
* If headphones are not plugged in, show the Speaker icon and the following Volume icons:
** Volume level 0: None
** Volume level 1: A
** Volume level 2: B
** Volume level 3: A, B
TODO: This documents the WonderSwan Color. The specifics probably work differently on the mono WonderSwan.
=== Cartridge icon ===
The cartridge icon is displayed for 128 ticks after the [[SoC#System Control|System Control]] cartridge test passes on console start.
442e211eb498ec11ef51f991ef0239e3aab4e577
Display/Tile Data
0
76
504
2025-02-23T09:40:23Z
Asie
351
Created page with "== Tile data == The tile data is stored at a fixed memory location: * <tt>$2000</tt> - <tt>$3FFF</tt> for 2 bit per pixel tiles in "mono" mode, for a total of 512 tiles. * <tt>$2000</tt> - <tt>$5FFF</tt> for 2 bit per pixel tiles in "color" mode, for a total of 1024 tiles. * <tt>$4000</tt> - <tt>$BFFF</tt> for 4 bit per pixel tiles in "color" mode, for a total of 1024 tiles. == Tile data formats == === 2 bits per pixel, planar === The tiles are stored in an interlea..."
wikitext
text/x-wiki
== Tile data ==
The tile data is stored at a fixed memory location:
* <tt>$2000</tt> - <tt>$3FFF</tt> for 2 bit per pixel tiles in "mono" mode, for a total of 512 tiles.
* <tt>$2000</tt> - <tt>$5FFF</tt> for 2 bit per pixel tiles in "color" mode, for a total of 1024 tiles.
* <tt>$4000</tt> - <tt>$BFFF</tt> for 4 bit per pixel tiles in "color" mode, for a total of 1024 tiles.
== Tile data formats ==
=== 2 bits per pixel, planar ===
The tiles are stored in an interleaved planar format, with two bits total for every pixel. Odd bytes store the first plane (bit 0 of each pixel), while even bytes store the second plane (bit 1 of each pixel).
<pre>
tile data (16 bytes)
01 7C 01 FC 00 C0 18 D8 18 D8 00 C0 00 00 C0 00
||
\/
plane 0 plane 1
7 bit 0 7 bit 0 full tile
---- ---- ---- ----
.... ...1 = 01 .222 22.. = 7C .22222.1
.... ...1 = 01 2222 22.. = FC 222222.1
.... .... = 00 22.. .... = C0 22......
...1 1... = 18 22.2 2... = D8 --\ 22.33...
...1 1... = 18 22.2 2... = D8 --/ 22.33...
.... .... = 00 22.. .... = C0 22......
.... .... = 00 .... .... = 00 ........
11.. .... = C0 .... .... = 00 11......
</pre>
This matches the format used by the Game Boy.
=== 4 bits per pixel, planar ===
This mode is stored in a manner similar to the 2 bits per pixel mode, but with an additional two planes for bit 2 and bit 3 of each pixel's palette index, expanding the tile data to 32 bytes.
<pre>
tile data (32 bytes)
54 32 01 00 54 32 F1 00 54 32 01 F0 54 32 F1 F0 04 02 01 00 F8 04 02 01 00 F8 04 02 00 00 F8 04
||
\/
plane 0 plane 1 plane 2 plane 3
7 bit 0 7 bit 0 7 bit 0 7 bit 0 full tile
---- ---- ---- ---- ---- ---- ---- ----
.1.1 .1.. = 54 ..22 ..2. = 32 .... ...4 = 01 .... .... = 00 .123.124
.1.1 .1.. = 54 ..22 ..2. = 32 4444 ...4 = F1 .... .... = 00 4567.124
.1.1 .1.. = 54 ..22 ..2. = 32 .... ...4 = 01 8888 .... = F0 89AB.124
.1.1 .1.. = 54 ..22 ..2. = 32 4444 ...4 = F1 8888 .... = F0 --\ CDEF.124
.... .1.. = 04 .... ..2. = 02 .... ...4 = 01 .... .... = 00 --/ .....124
1111 1... = F8 .... .2.. = 04 .... ..4. = 02 .... ...8 = 01 11111248
.... .... = 00 2222 2... = F8 .... .4.. = 04 .... ..8. = 02 2222248.
.... .... = 00 .... .... = 00 4444 4... = F8 .... .8.. = 04 444448..
</pre>
This format matches the one used by the Sega Master System and Game Gear family of consoles.
=== 4 bits per pixel, packed ===
Unlike the previous two formats, in the packed format each byte stores the complete palette index of two pixels - the high four bits store the left pixel, while the low four bits store the right pixel. Four such bytes make up a row of eight pixels from left to right.
<pre>
tile data (32 bytes)
01 23 01 24 45 67 01 24 89 AB 01 24 CD EF 01 24 00 00 01 24 11 11 12 48 22 22 24 80 44 44 48 00
||
\/
byte 0 1 2 3
bits 7-4 3-0 7-4 3-0 7-4 3-0 7-4 3-0
pixel 0 1 2 3 4 5 6 7 full tile
--- --- --- --- --- --- --- ---
. 1 = 01 2 3 = 23 . 1 = 01 2 4 = 24 .123.124 = 01 23 01 24
4 5 = 45 6 7 = 67 . 1 = 01 2 4 = 24 4567.124 = 45 67 01 24
8 9 = 89 A B = AB . 1 = 01 2 4 = 24 89AB.124 = 89 AB 01 24
C D = CD E F = EF . 1 = 01 2 4 = 24 --\ CDEF.124 = CD EF 01 24
. . = 00 . . = 00 . 1 = 01 2 4 = 24 --/ .....124 = 00 00 01 24
1 1 = 11 1 1 = 11 1 2 = 12 4 8 = 48 11111248 = 11 11 12 48
2 2 = 22 2 2 = 22 2 4 = 24 8 . = 80 2222248. = 22 22 24 80
4 4 = 44 4 4 = 44 4 8 = 48 . . = 00 444448.. = 44 44 48 00
</pre>
This format matches the one used by the Mega Drive console.
215afcb95d2c4b37a7f3e7d5d8510ba225c448f1
Display/Palette
0
77
505
2025-02-23T09:51:46Z
Asie
351
Created page with "The display system provides sixteen different palettes that can be used to color or shade tiles. * Palettes 0-7 can be used for the two screens only; * Palettes 8-15 can be used for both screens and sprites. == Palette format == === Mono === In ''mono'' modes, palettes are stored in I/O ports 0x20 through 0x3F. Each palette contains four three-bit entries, which are pointers into a global, four-bit shade lookup table: <pre> Palette Global shade LUT..."
wikitext
text/x-wiki
The display system provides sixteen different palettes that can be used to color or shade tiles.
* Palettes 0-7 can be used for the two screens only;
* Palettes 8-15 can be used for both screens and sprites.
== Palette format ==
=== Mono ===
In ''mono'' modes, palettes are stored in I/O ports 0x20 through 0x3F. Each palette contains four three-bit entries, which are pointers into a global, four-bit shade lookup table:
<pre>
Palette Global shade LUT
1 ===========> 2 ==========================> 5
^ (0, 2, 4, 6) ^ (1, 3, 5, 7, 9, 11, 13, 15) ^
| | |
Palette index Value Displayed shade
</pre>
The shade value corresponds to the darkness of the pixel: shade 0 is the brightest, while shade 15 is the darkest.
=== Color ===
In ''color'' modes, palettes are stored as 16-bit words in memory addresses 0xFE00 through 0xFFFF, without additional lookup tables:
<pre>
Address
15 bit 8 7 bit 0
---- ---- ---- ----
1111 111p pppi iii.
| |||| |||
| |||+-+++-- Index in palette (0-15)
+--+++------- Palette number (0-15)
Data
15 bit 8 7 bit 0
---- ---- ---- ----
.... rrrr gggg bbbb
|||| |||| ||||
|||| |||| ++++- Blue (0-15)
|||| ++++------ Green (0-15)
++++------------ Red (0-15)
</pre>
In 2 bits per pixel color modes, palette entries 4 through 15 are not used.
== Palette transparency ==
In two bit per pixel modes:
* Palettes 0-3 and 8-11 are ''opaque''. For these, index zero is treated as opaque.
* Palettes 4-7 and 12-15 are ''translucent''. For these, index zero is treated as transparent. This means that the color/shade value set to it is ignored, and only three distinct colors/shades can be used for tiles.
In four bit per pixel modes, all palettes are ''translucent''. Index zero is always treated as transparent, and fifteen different colors/shades can be used for tiles.
83e9ea732f979187791713772d6de41732e63caf
510
505
2025-02-23T10:01:07Z
Asie
351
wikitext
text/x-wiki
The display system provides sixteen different palettes that can be used to color or shade tiles.
* Palettes 0-7 can be used for the two screens only;
* Palettes 8-15 can be used for both screens and sprites.
== Palette format ==
=== Mono ===
In ''mono'' modes, palettes are stored in I/O ports 0x20 through 0x3F. Each palette contains four three-bit entries, which are pointers into a global, four-bit shade lookup table:
<pre>
Palette Global shade LUT
1 ===========> 2 ==========================> 5
^ (0, 2, 4, 6) ^ (1, 3, 5, 7, 9, 11, 13, 15) ^
| | |
Palette index Value Displayed shade
</pre>
The shade value corresponds to the darkness of the pixel: shade 0 is the brightest, while shade 15 is the darkest.
=== Color ===
In ''color'' modes, palettes are stored as 16-bit words in memory addresses 0xFE00 through 0xFFFF, without additional lookup tables:
<pre>
Address
15 bit 8 7 bit 0
---- ---- ---- ----
1111 111p pppi iii.
| |||| |||
| |||+-+++-- Index in palette (0-15)
+--+++------- Palette number (0-15)
Data
15 bit 8 7 bit 0
---- ---- ---- ----
.... rrrr gggg bbbb
|||| |||| ||||
|||| |||| ++++- Blue (0-15)
|||| ++++------ Green (0-15)
++++------------ Red (0-15)
</pre>
In 2 bits per pixel color modes, palette entries 4 through 15 are not used.
== Palette transparency ==
In two bit per pixel modes:
* Palettes 0-3 and 8-11 are ''opaque''. For these, index zero is treated as opaque.
* Palettes 4-7 and 12-15 are ''translucent''. For these, index zero is treated as transparent. This means that the color/shade value set to it is ignored, and only three distinct colors/shades can be used for tiles.
In four bit per pixel modes, all palettes are ''translucent''. Index zero is always treated as transparent, and fifteen different colors/shades can be used for tiles.
== Color reproduction ==
Different variants of the WonderSwan render colors differently.
=== WonderSwan "mono" ===
This model uses an FSTN display with an approximately linear gamma (~1.0) response for the shades 0 (brightest) through 15 (darkest). Its color reproduction characteristics are very similar to Nintendo's Game Boy Pocket, which uses the same technology.
=== WonderSwan Color ===
This model uses a CSTN display.
In "mono" compatibility mode on Color consoles, the linear gamma response is not retained; shade 0 is equivalent to color <tt>#FFF</tt>, shade 1 to <tt>#EEE</tt>, and shade 15 is equivalent to color <tt>#000</tt>
=== SwanCrystal ===
This model uses a TFT LCD display. Its color reproduction characteristics are very similar to Nintendo's Game Boy Color, which uses the same technology. Its gamma is close to standard video (2.2).
=== Aftermarket/non-standard hardware ===
Generally, IPS mods, as well as both official and unofficial TV output kits, use standard video gamma throughout, even for the "mono" WonderSwan.
0de97937009d342a9e697de562db35a136d4889d
511
510
2025-02-23T10:01:53Z
Asie
351
/* Color reproduction */
wikitext
text/x-wiki
The display system provides sixteen different palettes that can be used to color or shade tiles.
* Palettes 0-7 can be used for the two screens only;
* Palettes 8-15 can be used for both screens and sprites.
== Palette format ==
=== Mono ===
In ''mono'' modes, palettes are stored in I/O ports 0x20 through 0x3F. Each palette contains four three-bit entries, which are pointers into a global, four-bit shade lookup table:
<pre>
Palette Global shade LUT
1 ===========> 2 ==========================> 5
^ (0, 2, 4, 6) ^ (1, 3, 5, 7, 9, 11, 13, 15) ^
| | |
Palette index Value Displayed shade
</pre>
The shade value corresponds to the darkness of the pixel: shade 0 is the brightest, while shade 15 is the darkest.
=== Color ===
In ''color'' modes, palettes are stored as 16-bit words in memory addresses 0xFE00 through 0xFFFF, without additional lookup tables:
<pre>
Address
15 bit 8 7 bit 0
---- ---- ---- ----
1111 111p pppi iii.
| |||| |||
| |||+-+++-- Index in palette (0-15)
+--+++------- Palette number (0-15)
Data
15 bit 8 7 bit 0
---- ---- ---- ----
.... rrrr gggg bbbb
|||| |||| ||||
|||| |||| ++++- Blue (0-15)
|||| ++++------ Green (0-15)
++++------------ Red (0-15)
</pre>
In 2 bits per pixel color modes, palette entries 4 through 15 are not used.
== Palette transparency ==
In two bit per pixel modes:
* Palettes 0-3 and 8-11 are ''opaque''. For these, index zero is treated as opaque.
* Palettes 4-7 and 12-15 are ''translucent''. For these, index zero is treated as transparent. This means that the color/shade value set to it is ignored, and only three distinct colors/shades can be used for tiles.
In four bit per pixel modes, all palettes are ''translucent''. Index zero is always treated as transparent, and fifteen different colors/shades can be used for tiles.
== Color reproduction ==
Different variants of the WonderSwan have displays which reproduce colors differently. As such, there is no canon palette for the system.
=== WonderSwan "mono" ===
This model uses an FSTN display with an approximately linear gamma (~1.0) response for the shades 0 (brightest) through 15 (darkest). Its color reproduction characteristics are very similar to Nintendo's Game Boy Pocket, which uses the same technology.
=== WonderSwan Color ===
This model uses a CSTN display.
In "mono" compatibility mode on Color consoles, the linear gamma response is not retained; shade 0 is equivalent to color <tt>#FFF</tt>, shade 1 to <tt>#EEE</tt>, and shade 15 is equivalent to color <tt>#000</tt>
=== SwanCrystal ===
This model uses a TFT LCD display. Its color reproduction characteristics are very similar to Nintendo's Game Boy Color, which uses the same technology. Its gamma is close to standard video (2.2).
=== Aftermarket/non-standard hardware ===
Generally, IPS mods, as well as both official and unofficial TV output kits, use standard video gamma throughout, even for the "mono" WonderSwan.
df89da41beed47f3337b8c212f86becf812f8a3e
514
511
2025-02-23T10:05:32Z
Asie
351
/* WonderSwan Color */
wikitext
text/x-wiki
The display system provides sixteen different palettes that can be used to color or shade tiles.
* Palettes 0-7 can be used for the two screens only;
* Palettes 8-15 can be used for both screens and sprites.
== Palette format ==
=== Mono ===
In ''mono'' modes, palettes are stored in I/O ports 0x20 through 0x3F. Each palette contains four three-bit entries, which are pointers into a global, four-bit shade lookup table:
<pre>
Palette Global shade LUT
1 ===========> 2 ==========================> 5
^ (0, 2, 4, 6) ^ (1, 3, 5, 7, 9, 11, 13, 15) ^
| | |
Palette index Value Displayed shade
</pre>
The shade value corresponds to the darkness of the pixel: shade 0 is the brightest, while shade 15 is the darkest.
=== Color ===
In ''color'' modes, palettes are stored as 16-bit words in memory addresses 0xFE00 through 0xFFFF, without additional lookup tables:
<pre>
Address
15 bit 8 7 bit 0
---- ---- ---- ----
1111 111p pppi iii.
| |||| |||
| |||+-+++-- Index in palette (0-15)
+--+++------- Palette number (0-15)
Data
15 bit 8 7 bit 0
---- ---- ---- ----
.... rrrr gggg bbbb
|||| |||| ||||
|||| |||| ++++- Blue (0-15)
|||| ++++------ Green (0-15)
++++------------ Red (0-15)
</pre>
In 2 bits per pixel color modes, palette entries 4 through 15 are not used.
== Palette transparency ==
In two bit per pixel modes:
* Palettes 0-3 and 8-11 are ''opaque''. For these, index zero is treated as opaque.
* Palettes 4-7 and 12-15 are ''translucent''. For these, index zero is treated as transparent. This means that the color/shade value set to it is ignored, and only three distinct colors/shades can be used for tiles.
In four bit per pixel modes, all palettes are ''translucent''. Index zero is always treated as transparent, and fifteen different colors/shades can be used for tiles.
== Color reproduction ==
Different variants of the WonderSwan have displays which reproduce colors differently. As such, there is no canon palette for the system.
=== WonderSwan "mono" ===
This model uses an FSTN display with an approximately linear gamma (~1.0) response for the shades 0 (brightest) through 15 (darkest). Its color reproduction characteristics are very similar to Nintendo's Game Boy Pocket, which uses the same technology.
=== WonderSwan Color ===
This model uses a CSTN display.
In "mono" compatibility mode on Color consoles, the linear gamma response is not retained; shade 0 is equivalent to color <tt>#FFF</tt>, shade 1 to <tt>#EEE</tt>, and shade 15 is equivalent to color <tt>#000</tt>.
=== SwanCrystal ===
This model uses a TFT LCD display. Its color reproduction characteristics are very similar to Nintendo's Game Boy Color, which uses the same technology. Its gamma is close to standard video (2.2).
=== Aftermarket/non-standard hardware ===
Generally, IPS mods, as well as both official and unofficial TV output kits, use standard video gamma throughout, even for the "mono" WonderSwan.
bfe8610ac0f1e8d7d505d404a2534292952d5cbc
Display/Screens
0
78
506
2025-02-23T09:54:15Z
Asie
351
Created page with " A screen is a layout of tiles. Each cell in a screen controls one 8x8 tile. The display system can show two distinct screens simultaneously. It also supports hardware flipping of tiles, both horizontally and vertically. The size of each screen is fixed at 32x32 cells or 256x256 pixels, while each cell is stored as a two-byte word: <pre> Address 15 bit 8 7 bit 0 ---- ---- ---- ---- 0bbb byyy yyxx xxx. ||| |||| |||| ||| ||| |||| ||++-+++-- X coord..."
wikitext
text/x-wiki
A screen is a layout of tiles. Each cell in a screen controls one 8x8 tile.
The display system can show two distinct screens simultaneously. It also supports hardware flipping of tiles, both horizontally and vertically.
The size of each screen is fixed at 32x32 cells or 256x256 pixels, while each cell is stored as a two-byte word:
<pre>
Address
15 bit 8 7 bit 0
---- ---- ---- ----
0bbb byyy yyxx xxx.
||| |||| |||| |||
||| |||| ||++-+++-- X coordinate (0-31)
||| |+++--++-------- Y coordinate (0-31)
+++-+--------------- Base address (from I/O port)
Data
15 bit 8 7 bit 0
---- ---- ---- ----
vhbp pppt tttt tttt
|||| |||| |||| ||||
|||| |||+--++++-++++- Tile index (0-511)
|||+-+++------------- Palette (0-15)
||+------------------ Tile bank (0-1) - color only
|+------------------- Horizontal flip
+-------------------- Vertical flip
</pre>
In ''color'' modes, the tile bank selects between tiles 0-511 and 512-1023.
02d9d5f71ec4b25fec9ced51ac05f5c35e5e0216
Display/Sprites
0
79
507
2025-02-23T09:54:27Z
Asie
351
Created page with " The display system can show up to 128 sprites at once. Sprites are always drawn in front of Screen 1, but they can be drawn in front of or behind Screen 2. Sprites are stored in a sprite table in the console's internal RAM. It consists of up to 128 four-byte entries, of which any sequential slice can be displayed: <pre> (Byte 1) (Byte 0) 15 bit 8 7 bit 0 ---- ---- ---- ---- vhPi pppt tttt tttt |||| |||| |||| |||| |||| |||+--++++-++++- Tile index (0-511..."
wikitext
text/x-wiki
The display system can show up to 128 sprites at once.
Sprites are always drawn in front of Screen 1, but they can be drawn in front of or behind Screen 2.
Sprites are stored in a sprite table in the console's internal RAM. It consists of up to 128 four-byte entries, of which any sequential slice can be displayed:
<pre>
(Byte 1) (Byte 0)
15 bit 8 7 bit 0
---- ---- ---- ----
vhPi pppt tttt tttt
|||| |||| |||| ||||
|||| |||+--++++-++++- Tile index (0-511) - only tile bank 0
|||| +++------------- Palette (0-7) - mapped to screen palettes 8-15
|||+----------------- Window location - 0 = inside, 1 = outside
||+------------------ Priority - 0 = behind Screen 2, 1 = in front of Screen 2
|+------------------- Horizontal flip
+-------------------- Vertical flip
(Byte 2)
7 bit 0
---- ----
yyyy yyyy
|||| ||||
++++-++++- Y coordinate
(Byte 3)
7 bit 0
---- ----
xxxx xxxx
|||| ||||
++++-++++- X coordinate
</pre>
There is a sprite limit of 32 per scanline. This means that for each scanline, only the first 32 sprites will be drawn. Note that this includes sprites obscured by windows or outside of visible X coordinates; this list is determined solely by the Y coordinate. Between sprites themselves, earlier sprites in the list are always drawn on top of later sprites in the list.
The sprite table is copied from the console's RAM to a SoC-internal buffer every frame on line <tt>144</tt>; one word for every clock of the line, totaling 256 words (512 bytes) for 256 clocks. This internal buffer is then used for reading sprite data on the next frame.
72be2493c30b1fe73e5f8d01635facb7da4c398e
WSdev Wiki
0
1
512
484
2025-02-23T10:02:16Z
Asie
351
/* Console components */
wikitext
text/x-wiki
'''WonderSwan Development Wiki'''
== Reference ==
=== General ===
* [[Memory map]]
* [[I/O port map]]
* [[ROM header]]
* [[NEC V30MZ]] - the WonderSwan CPU (80186-compatible)
* [[Timing]]
=== Console components ===
* [[SoC]]
** [[Display]]
*** [[Display/Tile Data|Tile data]]
*** [[Display/Palette|Color palette]]
*** [[Display/Screens|Screen format]]
*** [[Display/Sprites|Sprite format]]
*** [[Display/LCD Icons|LCD icons]]
*** [[Display/IO Ports|I/O ports]]
** [[Sound]]
*** [[Hyper Voice]]<sup>(color)</sup>
** [[Keypad]]
** [[Timers]]
** [[Interrupts]]
** [[UART]]
** [[DMA]]<sup>(color)</sup>
* [[Boot ROM]]
* [[EEPROM|Internal EEPROM]]
** [[Splash animation]]<sup>(color)</sup>
=== Cartridge components ===
* [[Cartridge connector]]
* [[Mapper]]
** [[Bandai 2001]]
** [[Bandai 2003]]
** [[KARNAK]]
* Mapper-specific components
** [[EEPROM]] (2001)
** [[Real-Time Clock]] (2003)
* Cartridge-specific components
** [[WonderWitch/Flash|WonderWitch NOR flash]]
** [[Handy Sonar]]
** [[mama Mitte]] (IR transceiver)
** [[Robot Works]] (IR transmitter)
=== Pinouts ===
* [[Cartridge connector#Pinout|Cartridge pinout]]
* [[Accessory port pinout]]
* [[2001 Mapper pinout]]
* [[2003 Mapper pinout]]
* [[KARNAK pinout]]
* [[GIZA pinout]]
* [[S-3511A pinout]]
=== Accessories ===
* [[WonderBeat 9480]] headphone adapter
* [[WonderBorg]] robot
* [[WonderGate]] mobile adapter
* [[WonderWave]] infrared adapter
=== WonderWitch ===
* [[WonderWitch]]
** [[WonderWitch/Flash|NOR flash]]
** [[WonderWitch/Memory map|Memory map]]
** [[WonderWitch/FreyaBIOS|FreyaBIOS]]
** [[WonderWitch/FreyaOS|FreyaOS]]
** [[WonderWitch/Filesystem|File system]]
** [[WonderWitch/Process|Process]]
** [[WonderWitch/IL|Indirect Library (IL)]]
** [[WonderWitch .fx files|.fx file format]]
== Links ==
* [https://wonderful.asie.pl/wiki/doku.php?id=wswan:index#guides Wonderful Toolchain Wiki] - gcc-ia16-based homebrew toolchain guides and documentation
* [https://github.com/WonderfulToolchain/awesome-wsdev awesome-wsdev] - curated documentation/tools/source code link list
== MediaWiki ==
* [https://www.mediawiki.org/wiki/Special:MyLanguage/Help:Contents User's Guide]
* [https://www.mediawiki.org/wiki/Special:MyLanguage/Manual:FAQ MediaWiki FAQ]
* [[:Category:Deletion requests|Deletion requests]]
ecce62f3de56d5dd631fea14885c65bf616b3a24
518
512
2025-02-23T11:06:24Z
Asie
351
/* Console components */
wikitext
text/x-wiki
'''WonderSwan Development Wiki'''
== Reference ==
=== General ===
* [[Memory map]]
* [[I/O port map]]
* [[ROM header]]
* [[NEC V30MZ]] - the WonderSwan CPU (80186-compatible)
* [[Timing]]
=== Console components ===
* [[SoC]]
** [[Display]]
*** [[Display/Tile Data|Tile data]]
*** [[Display/Palette|Color palette]]
*** [[Display/Screens|Screen format]]
*** [[Display/Sprites|Sprite format]]
*** [[Display/Windows|Windows]]
*** [[Display/LCD Icons|LCD icons]]
*** [[Display/IO Ports|I/O ports]]
** [[Sound]]
*** [[Hyper Voice]]<sup>(color)</sup>
** [[Keypad]]
** [[Timers]]
** [[Interrupts]]
** [[UART]]
** [[DMA]]<sup>(color)</sup>
* [[Boot ROM]]
* [[EEPROM|Internal EEPROM]]
** [[Splash animation]]<sup>(color)</sup>
=== Cartridge components ===
* [[Cartridge connector]]
* [[Mapper]]
** [[Bandai 2001]]
** [[Bandai 2003]]
** [[KARNAK]]
* Mapper-specific components
** [[EEPROM]] (2001)
** [[Real-Time Clock]] (2003)
* Cartridge-specific components
** [[WonderWitch/Flash|WonderWitch NOR flash]]
** [[Handy Sonar]]
** [[mama Mitte]] (IR transceiver)
** [[Robot Works]] (IR transmitter)
=== Pinouts ===
* [[Cartridge connector#Pinout|Cartridge pinout]]
* [[Accessory port pinout]]
* [[2001 Mapper pinout]]
* [[2003 Mapper pinout]]
* [[KARNAK pinout]]
* [[GIZA pinout]]
* [[S-3511A pinout]]
=== Accessories ===
* [[WonderBeat 9480]] headphone adapter
* [[WonderBorg]] robot
* [[WonderGate]] mobile adapter
* [[WonderWave]] infrared adapter
=== WonderWitch ===
* [[WonderWitch]]
** [[WonderWitch/Flash|NOR flash]]
** [[WonderWitch/Memory map|Memory map]]
** [[WonderWitch/FreyaBIOS|FreyaBIOS]]
** [[WonderWitch/FreyaOS|FreyaOS]]
** [[WonderWitch/Filesystem|File system]]
** [[WonderWitch/Process|Process]]
** [[WonderWitch/IL|Indirect Library (IL)]]
** [[WonderWitch .fx files|.fx file format]]
== Links ==
* [https://wonderful.asie.pl/wiki/doku.php?id=wswan:index#guides Wonderful Toolchain Wiki] - gcc-ia16-based homebrew toolchain guides and documentation
* [https://github.com/WonderfulToolchain/awesome-wsdev awesome-wsdev] - curated documentation/tools/source code link list
== MediaWiki ==
* [https://www.mediawiki.org/wiki/Special:MyLanguage/Help:Contents User's Guide]
* [https://www.mediawiki.org/wiki/Special:MyLanguage/Manual:FAQ MediaWiki FAQ]
* [[:Category:Deletion requests|Deletion requests]]
7b27a88f7498792cab06eda52149083363c364d5
519
518
2025-02-23T11:07:57Z
Asie
351
/* Console components */
wikitext
text/x-wiki
'''WonderSwan Development Wiki'''
== Reference ==
=== General ===
* [[Memory map]]
* [[I/O port map]]
* [[ROM header]]
* [[NEC V30MZ]] - the WonderSwan CPU (80186-compatible)
* [[Timing]]
=== Console components ===
* [[SoC]]
** [[Display]]
*** [[Display/Tile Data|Tile data]]
*** [[Display/Palette|Color palette]]
*** [[Display/Screens|Screen format]]
*** [[Display/Sprites|Sprite format]]
*** [[Display/Windows|Windows]]
*** [[Display/LCD Icons|LCD icons]]
*** [[Display/IO Ports|I/O ports]]
** [[Sound]]
*** [[DMA#Sound_DMA|Sound DMA]]<sup>(color)</sup>
*** [[Hyper Voice]]<sup>(color)</sup>
** [[Keypad]]
** [[Timers]]
** [[Interrupts]]
** [[UART]]
** [[DMA]]<sup>(color)</sup>
* [[Boot ROM]]
* [[EEPROM|Internal EEPROM]]
** [[Splash animation]]<sup>(color)</sup>
=== Cartridge components ===
* [[Cartridge connector]]
* [[Mapper]]
** [[Bandai 2001]]
** [[Bandai 2003]]
** [[KARNAK]]
* Mapper-specific components
** [[EEPROM]] (2001)
** [[Real-Time Clock]] (2003)
* Cartridge-specific components
** [[WonderWitch/Flash|WonderWitch NOR flash]]
** [[Handy Sonar]]
** [[mama Mitte]] (IR transceiver)
** [[Robot Works]] (IR transmitter)
=== Pinouts ===
* [[Cartridge connector#Pinout|Cartridge pinout]]
* [[Accessory port pinout]]
* [[2001 Mapper pinout]]
* [[2003 Mapper pinout]]
* [[KARNAK pinout]]
* [[GIZA pinout]]
* [[S-3511A pinout]]
=== Accessories ===
* [[WonderBeat 9480]] headphone adapter
* [[WonderBorg]] robot
* [[WonderGate]] mobile adapter
* [[WonderWave]] infrared adapter
=== WonderWitch ===
* [[WonderWitch]]
** [[WonderWitch/Flash|NOR flash]]
** [[WonderWitch/Memory map|Memory map]]
** [[WonderWitch/FreyaBIOS|FreyaBIOS]]
** [[WonderWitch/FreyaOS|FreyaOS]]
** [[WonderWitch/Filesystem|File system]]
** [[WonderWitch/Process|Process]]
** [[WonderWitch/IL|Indirect Library (IL)]]
** [[WonderWitch .fx files|.fx file format]]
== Links ==
* [https://wonderful.asie.pl/wiki/doku.php?id=wswan:index#guides Wonderful Toolchain Wiki] - gcc-ia16-based homebrew toolchain guides and documentation
* [https://github.com/WonderfulToolchain/awesome-wsdev awesome-wsdev] - curated documentation/tools/source code link list
== MediaWiki ==
* [https://www.mediawiki.org/wiki/Special:MyLanguage/Help:Contents User's Guide]
* [https://www.mediawiki.org/wiki/Special:MyLanguage/Manual:FAQ MediaWiki FAQ]
* [[:Category:Deletion requests|Deletion requests]]
969cce53fde0f2dd9d77c90b4798fd02f6e94aee
Memory map
0
25
513
330
2025-02-23T10:04:13Z
Asie
351
/* Internal */ add URLs to Display subpages
wikitext
text/x-wiki
The WonderSwan's SoC uses a 20-bit physical memory map, split into three regions with distinct bus widths, timings, and access permissions;
{| class="wikitable"
|+ WonderSwan physical memory map
! Bus
! colspan="2" | Address range
! Access width
! Access speed
! Read/Write
|-
| Internal
| colspan="2" style="text-align: center;" | 0x00000<br/>0x0FFFF
| 16-bit
| 1 cycle
| RW
|-
| rowspan="2" | Cartridge
| rowspan="2" style="text-align: center;" | 0x10000<br/>0xFFFFF
| style="text-align: center;" | 0x10000<br/>0x1FFFF
| 8-bit
| 1<sup>(color)</sup>/2 cycles (configurable)
| RW
|-
| style="text-align: center;" | 0x20000<br/>0xFFFFF
| 8/16-bit (configurable)
| 1/2 cycles (configurable)
| R
|}
== Internal ==
The WonderSwan SoC features an unified memory architecture. The CPU, [[Display]] and [[Sound]] components make use of data stored in a shared RAM in distinct segments of the 12.288 MHz SoC clock. This is in contrast to many other platforms which feature, for example, separate video memory. This allows the CPU to modify video and audio data without worrying about wait states or video timing; however, the video and audio components have location and alignment restrictions for data:
{| class="wikitable"
|+ WonderSwan SoC internal memory map
! Address
! WonderSwan
! WonderSwan Color (2BPP mode)
! WonderSwan Color (4BPP mode)
|-
| style="text-align: center;" | 0x0000
| colspan="3" style="text-align: center;" | '''Interrupt vectors''' (256 x 4 bytes - far addresses)
|-
| style="text-align: center;" | 0x0400
| colspan="3" style="text-align: center;" | Free RAM
|-
| style="text-align: center;" | 0x2000
| colspan="2" style="text-align: center;" | '''[[Display/Tile Data|Tile data]] (bank 0)'''
| style="text-align: center;" | Free RAM
|-
| style="text-align: center;" | 0x4000
! rowspan="6" style="text-align: center;" |
| style="text-align: center;" | '''[[Display/Tile Data|Tile data]] (bank 1)'''
| rowspan="2" style="text-align: center;" | '''[[Display/Tile Data|Tile data]] (bank 0)'''
|-
| style="text-align: center;" | 0x6000
| rowspan="2" style="text-align: center;" | Free RAM
|-
| style="text-align: center;" | 0x8000
| style="text-align: center;" | '''[[Display/Tile Data|Tile data]] (bank 1)'''
|-
| style="text-align: center;" | 0xC000
| colspan="2" style="text-align: center;" | Free RAM
|-
| style="text-align: center;" | 0xFE00
| rowspan="2" colspan="2" style="text-align: center;" | '''[[Display/Palette|Color palette]]'''
|-
| style="text-align: center;" | 0xFFFF
|}
In addition, some elements can be placed at configurable locations in RAM, but with restrictions:
{| class="wikitable"
|+ WonderSwan SoC internal memory layout limitations
! Type
! Lowest address
! Highest address
! Alignment
|-
| [[Display/Screens|Screen]]
| style="text-align: center;" | 0x0000
| style="text-align: center;" | 0x3800<br/>0x7800<sup>(color)</sup>
| 0x800 (2048) bytes
|-
| [[Display/Sprites|Sprite table]]
| style="text-align: center;" | 0x0000
| style="text-align: center;" | 0x3E00<br/>0x7E00<sup>(color)</sup>
| 0x200 (512) bytes
|-
| Sound wave table
| style="text-align: center;" | 0x0000
| style="text-align: center;" | 0x3FC0
| 0x40 (64) bytes
|}
Note that an element being present on this map does not mean that the space cannot be utilized for other data. For example, it is common for a WonderSwan game to only reserve sixteen out of the 256 interrupt vectors, reusing the remaining 240 as general RAM space.
== Cartridge ==
The cartridge part of the memory map is fully controlled by the cartridge bus; this is usually subdivided further by a [[Mapper]]. There exists a standard layout common to all official mappers:
{| class="wikitable"
|+ Standard mapper physical memory map
! Address range
! Bank
|-
| style="text-align: center;" | 0x10000<br/>0x1FFFF
| SRAM (or flashable ROM)
|-
| style="text-align: center;" | 0x20000<br/>0x2FFFF
| ROM bank 0
|-
| style="text-align: center;" | 0x30000<br/>0x3FFFF
| ROM bank 1
|-
| style="text-align: center;" | 0x40000<br/>0xFFFFF
| ROM linear (EX) bank
|}
719ee6d7ddab575f677256930561e756e100deba
Display/Windows
0
80
517
2025-02-23T11:06:02Z
Asie
351
Created page with "The Screen 2 and Sprite layers can optionally have their drawing restricted within or without specific rectangular windows. In the case of Screen 2, one can use the Display Control port to configure if the window should render only the tiles inside of it. Alternatively, once can configure the window to only render tiles outside of it, in which case the window rectangle acts as a cut-out. {| class="wikitable" ! ! Window inside ! Window outside |- ! Pixel inside | align=..."
wikitext
text/x-wiki
The Screen 2 and Sprite layers can optionally have their drawing restricted within or without specific rectangular windows.
In the case of Screen 2, one can use the Display Control port to configure if the window should render only the tiles inside of it. Alternatively, once can configure the window to only render tiles outside of it, in which case the window rectangle acts as a cut-out.
{| class="wikitable"
!
! Window inside
! Window outside
|-
! Pixel inside
| align="center" | ✔
|
|-
! Pixel outside
|
| align="center" | ✔
|}
In the case of the sprite layer, one can configure this individually for each sprite in its attributes.
{| class="wikitable"
!
! Sprite inside
! Sprite outside
|-
! Pixel inside
| align="center" | ✔
|
|-
! Pixel outside
|
| align="center" | ✔
|}
08b2e8edf47a6c2ac953bece6a3aae7af9f1d1cd
Boot ROM
0
81
520
2025-02-23T11:11:15Z
Asie
351
Created page with "The WonderSwan boot ROM is where the console begins execution on power on. * On the "mono" model, it occupies an area from <tt>$FF000</tt> to <tt>$FFFFF</tt>, for a total of 4 KiB. * On the Color model, it occupies an area from <tt>$FE000</tt> to <tt>$FFFFF</tt>, for a total of 8 KiB. It performs the following activities: * checks if the cartridge self-test passed; * checks if the cartridge footer is valid; * if START is held when the console is turned on, enters the..."
wikitext
text/x-wiki
The WonderSwan boot ROM is where the console begins execution on power on.
* On the "mono" model, it occupies an area from <tt>$FF000</tt> to <tt>$FFFFF</tt>, for a total of 4 KiB.
* On the Color model, it occupies an area from <tt>$FE000</tt> to <tt>$FFFFF</tt>, for a total of 8 KiB.
It performs the following activities:
* checks if the cartridge self-test passed;
* checks if the cartridge footer is valid;
* if START is held when the console is turned on, enters the boot ROM menu;
* updates telemetry/diagnostics information in the internal EEPROM;
* displays the splash screen (optionally, a custom splash screen on Color models);
* jumps to the cartridge.
b0854f5ba38da8a3fdda5bc6c7cc4091f0f5f705
Display/IO Ports
0
74
522
500
2025-02-23T15:41:50Z
Asie
351
/* LCD Status ($1A) */ add bit 5
wikitext
text/x-wiki
== Graphics I/O ports ==
{{Anchor|Display Control}}
=== Display Control ($00) ===
<pre>
7 bit 0
---- ----
..wo Ws21
|| ||||
|| |||+- Enable Screen 1 layer
|| ||+-- Enable Screen 2 layer
|| |+--- Enable Sprite layer
|| +---- Enable Sprite window
|+------ Screen 2 tiles are drawn (if window enabled):
| 0 = inside window,
| 1 = outside window.
+------- Enable Screen 2 window
</pre>
{{Anchor|Display Background}}
=== Display Background Color ($01) ===
<pre>
(mono) (color)
7 bit 0 7 bit 0
---- ---- ---- ----
.... .sss pppp iiii
||| |||| ||||
+++- Value |||| ++++- Index in palette (0-15)
(0-7) ++++------ Color palette (0-15)
</pre>
{{Anchor|Display Current Line}}
=== Display Current Line ($02 read) ===
The current line being drawn by the display.
Note that lines are sent to the display with a one-line delay. This matters for color palette or shade LUT manipulation; changing these values when <code>current line == 1</code> will actually affect line 0.
{{Anchor|Display Interrupt Line}}
=== Display Interrupt Line ($03) ===
The line to emit an interrupt on.
{{Anchor|Sprite Table Address}}
=== Sprite Table Address ($04) ===
<pre>
7 bit 0
---- ----
..Aa aaaa
|| ||||
|+-++++- Address (bits 9-13)
+------- Address (bit 14) - color only
</pre>
{{Anchor|Sprite Table First}}
=== Sprite Table First ($05) ===
<pre>
7 bit 0
---- ----
.iii iiii
||| ||||
+++-++++- Index of first sprite entry to draw (0-127)
</pre>
{{Anchor|Sprite Table Count}}
=== Sprite Table Count ($06) ===
<pre>
7 bit 0
---- ----
cccc cccc
|||| ||||
++++-++++- Count of sprite entries to draw (1-128)
</pre>
{{Anchor|Screen Address}}
=== Screen Address ($07) ===
<pre>
7 bit 0
---- ----
2222 1111
|||| ||||
|||| |+++- Screen 1 address (bits 11-13)
|||| +---- Screen 1 address (bit 14) - color only
|+++------ Screen 2 address (bits 11-13)
+--------- Screen 2 address (bit 14) - color only
</pre>
{{Anchor|Screen 2 Window}}
=== Screen 2 Window Left ($08) ===
=== Screen 2 Window Top ($09) ===
=== Screen 2 Window Right ($0A) ===
=== Screen 2 Window Bottom ($0B) ===
The X and Y coordinates of the Screen 2 window.
Note that all coordinates are inclusive; for example, for a 200x100 window in the top-left corner, the values should be set as follows:
* Left - 0,
* Top - 0,
* Right - 199,
* Bottom - 99.
{{Anchor|Sprite Window}}
=== Sprite Window Left ($0C) ===
=== Sprite Window Top ($0D) ===
=== Sprite Window Right ($0E) ===
=== Sprite Window Bottom ($0F) ===
The X and Y coordinates of the Sprite window.
Note that all coordinates are inclusive.
{{Anchor|Screen Scroll}}
=== Screen 1 Scroll X ($10) ===
=== Screen 1 Scroll Y ($11) ===
The X and Y coordinates that Screen 1 is scrolled by.
For example, setting Scroll X to 24 and Scroll Y to 8 will omit, in 8x8 tile units, the first three rows and the first two columns of the 32x32 screen.
=== Screen 2 Scroll X ($12) ===
=== Screen 2 Scroll Y ($13) ===
The X and Y coordinates that Screen 2 is scrolled by.
== Palette I/O ports ==
These I/O ports are only used in the monochrome display mode. Color display modes use the memory locations <tt>$FE00</tt> - <tt>$FFFF</tt> to store the color palette.
{{Anchor|LCD Mono Shade LUT}}
=== Mono Shade LUT ($1C, $1D, $1E, $1F) ===
<pre>
$1C $1D $1E $1F
7 bit 0 7 bit 0 7 bit 0 7 bit 0
---- ---- ---- ---- ---- ---- ---- ----
1111 0000 3333 2222 5555 4444 7777 6666
|||| |||| |||| |||| |||| |||| |||| ||||
|||| |||| |||| |||| |||| |||| |||| ++++- Shade for LUT index 6
|||| |||| |||| |||| |||| |||| ++++------ Shade for LUT index 7
|||| |||| |||| |||| |||| ++++------------- Shade for LUT index 4
|||| |||| |||| |||| ++++------------------ Shade for LUT index 5
|||| |||| |||| ++++------------------------- Shade for LUT index 2
|||| |||| ++++------------------------------ Shade for LUT index 3
|||| ++++------------------------------------- Shade for LUT index 0
++++------------------------------------------ Shade for LUT index 1
</pre>
{{Anchor|LCD Mono Palette}}
=== Mono Palette 0..15 ($20, $21 .. $3E, $3F) ===
The monochrome palette is laid out as sixteen words:
<pre>
N+1 N
15 bit 8 7 bit 0
---- ---- ---- ----
.333 .222 .111 .000
||| ||| ||| |||
||| ||| ||| +++- Shade LUT index for color 0
||| ||| +++------ Shade LUT index for color 1
||| +++------------ Shade LUT index for color 2
+++----------------- Shade LUT index for color 3
</pre>
== LCD I/O ports ==
{{Anchor|LCD Control}}
=== LCD Control ($14) ===
<pre>
7 bit 0
---- ----
.... ..Ce
||
|+- LCD enable: 0 = sleep, 1 = enabled
+-- Contrast (WSC): 0 = low, 1 = high
</pre>
The enable bit controls whether or not the LCD screen is displaying graphics; if sleeping, it displays nothing (all white). Note that icon segments continue displaying regardless of this configuration.
Note that port $1A provides a separate LCD sleep bit; the display will be disabled in the same way if any of those bits are set to "sleep".
The contrast bit allows enabling a "high contrast" mode: this works by having the LCD drive two lines with data received from the SoC - so the first line of the LCD is driven by the first line from the SoC, then additionally by the second line from the SoC.
{{Anchor|LCD Icon Control}}
=== LCD Icon Control ($15) ===
<pre>
7 bit 0
---- ----
..32 1hvs
|| ||||
|| |||+- Sleep (Star)
|| ||+-- Vertical orientation
|| |+--- Horizontal orientation
|| +---- Etc. 1 (Small circle)
|+------ Etc. 2 (Medium circle)
+------- Etc. 3 (Large circle)
</pre>
== LCD internal I/O ports ==
These I/O ports are not used and most likely not intended for use by commercial games.
{{Anchor|LCD Final Line}}
=== LCD Final Line ($16) ===
The final line preceding line counter restart and the beginning of active display. By default, this is set to 158, which equals 159 total lines per frame.
It is said setting this register to an odd value on SwanCrystal has an adverse effect to the LCD panel,<ref>[http://daifukkat.su/docs/wsman/#REG_LCD_VTOTAL REG_LCD_VTOTAL - WSMan]</ref> but the exact mechanism is unknown. A starting point for research is that an even value, or odd total line count, is needed to balance positive and negative charges on the LCD.<ref>W.A. Steer. "[http://www.techmind.org/lcd/ LCD monitor technology and tests]". Techmind, 2011-12-03. Accessed 2024-11-19.</ref>
{{Anchor|LCD Back Porch Line}}
=== LCD Back Porch Line ($17, WSC only) ===
This port is available on the WonderSwan Color only - not the SwanCrystal!
The final line preceding the vertical back porch; by default, this should be set to 155.
The vertical back porch of the LCD is assumed to be 4 lines by some hardware, including IPS mods, as well as the official "TV Swan" capture device. Given that the first visible line is sent to the LCD on the display's line 1, this should be generally set to <code>LCD Final Line - 3</code>.
Conversely, it is said moving this value closer to vertical blank improves LCD visibility<ref>[http://daifukkat.su/docs/wsman/#REG_LCD_VSYNC REG_LCD_VSYNC - WSMan]</ref>, but the exact mechanism is unknown.
{{Anchor|LCD Status}}
=== LCD Status ($1A) ===
<pre>
7 bit 0
---- ----
..cv vvhs
|| ||||
|| |||+- LCD sleep: 0 = no, 1 = sleep
|| ||+-- Headphone icon
|| ||
|| || Volume icons:
|| |+--- - Volume B (medium, high)
|| +---- - Volume A (low, high)
|+------ - Speaker
|
+------- Cartridge icon
</pre>
The LCD sleep bit is writable. The remaining bits are read-only.
The volume and headphone icon are enabled when pressing the SOUND button, according to this algorithm:
* If headphones are plugged in, show the Headphone icon.
* If headphones are not plugged in, show the Speaker icon and the following Volume icons:
** Volume level 0: None
** Volume level 1: A
** Volume level 2: B
** Volume level 3: A, B
* Hide all visible icons after 128 frames from the last press.
TODO: This documents the WonderSwan Color. The specifics probably work differently on the mono WonderSwan.
=== TFT LCD Configuration ($70, $71, $72, $73, $74, $75, $76, $77 SwanCrystal only) ===
These eight bytes are read from internal EEPROM and configure unknown aspects of the console's TFT LCD panel.
They are only writable while the [[Boot ROM]] is unlocked - locking has the side effect of making them read-only.
== Notes ==
<references />
b4afc078c7cb4006f30c6c91f2dd0a56375a17db
527
522
2025-02-23T16:06:59Z
Asie
351
/* LCD internal I/O ports */ document port $18
wikitext
text/x-wiki
== Graphics I/O ports ==
{{Anchor|Display Control}}
=== Display Control ($00) ===
<pre>
7 bit 0
---- ----
..wo Ws21
|| ||||
|| |||+- Enable Screen 1 layer
|| ||+-- Enable Screen 2 layer
|| |+--- Enable Sprite layer
|| +---- Enable Sprite window
|+------ Screen 2 tiles are drawn (if window enabled):
| 0 = inside window,
| 1 = outside window.
+------- Enable Screen 2 window
</pre>
{{Anchor|Display Background}}
=== Display Background Color ($01) ===
<pre>
(mono) (color)
7 bit 0 7 bit 0
---- ---- ---- ----
.... .sss pppp iiii
||| |||| ||||
+++- Value |||| ++++- Index in palette (0-15)
(0-7) ++++------ Color palette (0-15)
</pre>
{{Anchor|Display Current Line}}
=== Display Current Line ($02 read) ===
The current line being drawn by the display.
Note that lines are sent to the display with a one-line delay. This matters for color palette or shade LUT manipulation; changing these values when <code>current line == 1</code> will actually affect line 0.
{{Anchor|Display Interrupt Line}}
=== Display Interrupt Line ($03) ===
The line to emit an interrupt on.
{{Anchor|Sprite Table Address}}
=== Sprite Table Address ($04) ===
<pre>
7 bit 0
---- ----
..Aa aaaa
|| ||||
|+-++++- Address (bits 9-13)
+------- Address (bit 14) - color only
</pre>
{{Anchor|Sprite Table First}}
=== Sprite Table First ($05) ===
<pre>
7 bit 0
---- ----
.iii iiii
||| ||||
+++-++++- Index of first sprite entry to draw (0-127)
</pre>
{{Anchor|Sprite Table Count}}
=== Sprite Table Count ($06) ===
<pre>
7 bit 0
---- ----
cccc cccc
|||| ||||
++++-++++- Count of sprite entries to draw (1-128)
</pre>
{{Anchor|Screen Address}}
=== Screen Address ($07) ===
<pre>
7 bit 0
---- ----
2222 1111
|||| ||||
|||| |+++- Screen 1 address (bits 11-13)
|||| +---- Screen 1 address (bit 14) - color only
|+++------ Screen 2 address (bits 11-13)
+--------- Screen 2 address (bit 14) - color only
</pre>
{{Anchor|Screen 2 Window}}
=== Screen 2 Window Left ($08) ===
=== Screen 2 Window Top ($09) ===
=== Screen 2 Window Right ($0A) ===
=== Screen 2 Window Bottom ($0B) ===
The X and Y coordinates of the Screen 2 window.
Note that all coordinates are inclusive; for example, for a 200x100 window in the top-left corner, the values should be set as follows:
* Left - 0,
* Top - 0,
* Right - 199,
* Bottom - 99.
{{Anchor|Sprite Window}}
=== Sprite Window Left ($0C) ===
=== Sprite Window Top ($0D) ===
=== Sprite Window Right ($0E) ===
=== Sprite Window Bottom ($0F) ===
The X and Y coordinates of the Sprite window.
Note that all coordinates are inclusive.
{{Anchor|Screen Scroll}}
=== Screen 1 Scroll X ($10) ===
=== Screen 1 Scroll Y ($11) ===
The X and Y coordinates that Screen 1 is scrolled by.
For example, setting Scroll X to 24 and Scroll Y to 8 will omit, in 8x8 tile units, the first three rows and the first two columns of the 32x32 screen.
=== Screen 2 Scroll X ($12) ===
=== Screen 2 Scroll Y ($13) ===
The X and Y coordinates that Screen 2 is scrolled by.
== Palette I/O ports ==
These I/O ports are only used in the monochrome display mode. Color display modes use the memory locations <tt>$FE00</tt> - <tt>$FFFF</tt> to store the color palette.
{{Anchor|LCD Mono Shade LUT}}
=== Mono Shade LUT ($1C, $1D, $1E, $1F) ===
<pre>
$1C $1D $1E $1F
7 bit 0 7 bit 0 7 bit 0 7 bit 0
---- ---- ---- ---- ---- ---- ---- ----
1111 0000 3333 2222 5555 4444 7777 6666
|||| |||| |||| |||| |||| |||| |||| ||||
|||| |||| |||| |||| |||| |||| |||| ++++- Shade for LUT index 6
|||| |||| |||| |||| |||| |||| ++++------ Shade for LUT index 7
|||| |||| |||| |||| |||| ++++------------- Shade for LUT index 4
|||| |||| |||| |||| ++++------------------ Shade for LUT index 5
|||| |||| |||| ++++------------------------- Shade for LUT index 2
|||| |||| ++++------------------------------ Shade for LUT index 3
|||| ++++------------------------------------- Shade for LUT index 0
++++------------------------------------------ Shade for LUT index 1
</pre>
{{Anchor|LCD Mono Palette}}
=== Mono Palette 0..15 ($20, $21 .. $3E, $3F) ===
The monochrome palette is laid out as sixteen words:
<pre>
N+1 N
15 bit 8 7 bit 0
---- ---- ---- ----
.333 .222 .111 .000
||| ||| ||| |||
||| ||| ||| +++- Shade LUT index for color 0
||| ||| +++------ Shade LUT index for color 1
||| +++------------ Shade LUT index for color 2
+++----------------- Shade LUT index for color 3
</pre>
== LCD I/O ports ==
{{Anchor|LCD Control}}
=== LCD Control ($14) ===
<pre>
7 bit 0
---- ----
.... ..Ce
||
|+- LCD enable: 0 = sleep, 1 = enabled
+-- Contrast (WSC): 0 = low, 1 = high
</pre>
The enable bit controls whether or not the LCD screen is displaying graphics; if sleeping, it displays nothing (all white). Note that icon segments continue displaying regardless of this configuration.
Note that port $1A provides a separate LCD sleep bit; the display will be disabled in the same way if any of those bits are set to "sleep".
The contrast bit allows enabling a "high contrast" mode: this works by having the LCD drive two lines with data received from the SoC - so the first line of the LCD is driven by the first line from the SoC, then additionally by the second line from the SoC.
{{Anchor|LCD Icon Control}}
=== LCD Icon Control ($15) ===
<pre>
7 bit 0
---- ----
..32 1hvs
|| ||||
|| |||+- Sleep (Star)
|| ||+-- Vertical orientation
|| |+--- Horizontal orientation
|| +---- Etc. 1 (Small circle)
|+------ Etc. 2 (Medium circle)
+------- Etc. 3 (Large circle)
</pre>
== LCD internal I/O ports ==
These I/O ports are not used and most likely not intended for use by commercial games.
{{Anchor|LCD Final Line}}
=== LCD Final Line ($16) ===
The final line preceding line counter restart and the beginning of active display. By default, this is set to 158, which equals 159 total lines per frame.
It is said setting this register to an odd value on SwanCrystal has an adverse effect to the LCD panel,<ref>[http://daifukkat.su/docs/wsman/#REG_LCD_VTOTAL REG_LCD_VTOTAL - WSMan]</ref> but the exact mechanism is unknown. A starting point for research is that an even value, or odd total line count, is needed to balance positive and negative charges on the LCD.<ref>W.A. Steer. "[http://www.techmind.org/lcd/ LCD monitor technology and tests]". Techmind, 2011-12-03. Accessed 2024-11-19.</ref>
{{Anchor|LCD Back Porch Line}}
=== LCD Back Porch Line ($17, WSC only) ===
This port is available on the WonderSwan Color only - not the SwanCrystal!
The final line preceding the vertical back porch; by default, this should be set to 155.
The vertical back porch of the LCD is assumed to be 4 lines by some hardware, including IPS mods, as well as the official "TV Swan" capture device. Given that the first visible line is sent to the LCD on the display's line 1, this should be generally set to <code>LCD Final Line - 3</code>.
Conversely, it is said moving this value closer to vertical blank improves LCD visibility<ref>[http://daifukkat.su/docs/wsman/#REG_LCD_VSYNC REG_LCD_VSYNC - WSMan]</ref>, but the exact mechanism is unknown.
{{Anchor|LCD Line Counter}}
=== LCD Line Counter ($18) ===
This write-only port can be written to in order to change the next line to be drawn on the LCD.
For out of range values (higher than the final line), the LCD panel is not driven, but the line counter continues increasing until it rolls over to <tt>$00</tt>.
{{Anchor|LCD Status}}
=== LCD Status ($1A) ===
<pre>
7 bit 0
---- ----
..cv vvhs
|| ||||
|| |||+- LCD sleep: 0 = no, 1 = sleep
|| ||+-- Headphone icon
|| ||
|| || Volume icons:
|| |+--- - Volume B (medium, high)
|| +---- - Volume A (low, high)
|+------ - Speaker
|
+------- Cartridge icon
</pre>
The LCD sleep bit is writable. The remaining bits are read-only.
The volume and headphone icon are enabled when pressing the SOUND button, according to this algorithm:
* If headphones are plugged in, show the Headphone icon.
* If headphones are not plugged in, show the Speaker icon and the following Volume icons:
** Volume level 0: None
** Volume level 1: A
** Volume level 2: B
** Volume level 3: A, B
* Hide all visible icons after 128 frames from the last press.
TODO: This documents the WonderSwan Color. The specifics probably work differently on the mono WonderSwan.
=== TFT LCD Configuration ($70, $71, $72, $73, $74, $75, $76, $77 SwanCrystal only) ===
These eight bytes are read from internal EEPROM and configure unknown aspects of the console's TFT LCD panel.
They are only writable while the [[Boot ROM]] is unlocked - locking has the side effect of making them read-only.
== Notes ==
<references />
8037c6aff452a61f9de9d252456ff9ec1650bcc0
530
527
2025-02-23T20:07:49Z
Asie
351
/* LCD Status ($1A) */
wikitext
text/x-wiki
== Graphics I/O ports ==
{{Anchor|Display Control}}
=== Display Control ($00) ===
<pre>
7 bit 0
---- ----
..wo Ws21
|| ||||
|| |||+- Enable Screen 1 layer
|| ||+-- Enable Screen 2 layer
|| |+--- Enable Sprite layer
|| +---- Enable Sprite window
|+------ Screen 2 tiles are drawn (if window enabled):
| 0 = inside window,
| 1 = outside window.
+------- Enable Screen 2 window
</pre>
{{Anchor|Display Background}}
=== Display Background Color ($01) ===
<pre>
(mono) (color)
7 bit 0 7 bit 0
---- ---- ---- ----
.... .sss pppp iiii
||| |||| ||||
+++- Value |||| ++++- Index in palette (0-15)
(0-7) ++++------ Color palette (0-15)
</pre>
{{Anchor|Display Current Line}}
=== Display Current Line ($02 read) ===
The current line being drawn by the display.
Note that lines are sent to the display with a one-line delay. This matters for color palette or shade LUT manipulation; changing these values when <code>current line == 1</code> will actually affect line 0.
{{Anchor|Display Interrupt Line}}
=== Display Interrupt Line ($03) ===
The line to emit an interrupt on.
{{Anchor|Sprite Table Address}}
=== Sprite Table Address ($04) ===
<pre>
7 bit 0
---- ----
..Aa aaaa
|| ||||
|+-++++- Address (bits 9-13)
+------- Address (bit 14) - color only
</pre>
{{Anchor|Sprite Table First}}
=== Sprite Table First ($05) ===
<pre>
7 bit 0
---- ----
.iii iiii
||| ||||
+++-++++- Index of first sprite entry to draw (0-127)
</pre>
{{Anchor|Sprite Table Count}}
=== Sprite Table Count ($06) ===
<pre>
7 bit 0
---- ----
cccc cccc
|||| ||||
++++-++++- Count of sprite entries to draw (1-128)
</pre>
{{Anchor|Screen Address}}
=== Screen Address ($07) ===
<pre>
7 bit 0
---- ----
2222 1111
|||| ||||
|||| |+++- Screen 1 address (bits 11-13)
|||| +---- Screen 1 address (bit 14) - color only
|+++------ Screen 2 address (bits 11-13)
+--------- Screen 2 address (bit 14) - color only
</pre>
{{Anchor|Screen 2 Window}}
=== Screen 2 Window Left ($08) ===
=== Screen 2 Window Top ($09) ===
=== Screen 2 Window Right ($0A) ===
=== Screen 2 Window Bottom ($0B) ===
The X and Y coordinates of the Screen 2 window.
Note that all coordinates are inclusive; for example, for a 200x100 window in the top-left corner, the values should be set as follows:
* Left - 0,
* Top - 0,
* Right - 199,
* Bottom - 99.
{{Anchor|Sprite Window}}
=== Sprite Window Left ($0C) ===
=== Sprite Window Top ($0D) ===
=== Sprite Window Right ($0E) ===
=== Sprite Window Bottom ($0F) ===
The X and Y coordinates of the Sprite window.
Note that all coordinates are inclusive.
{{Anchor|Screen Scroll}}
=== Screen 1 Scroll X ($10) ===
=== Screen 1 Scroll Y ($11) ===
The X and Y coordinates that Screen 1 is scrolled by.
For example, setting Scroll X to 24 and Scroll Y to 8 will omit, in 8x8 tile units, the first three rows and the first two columns of the 32x32 screen.
=== Screen 2 Scroll X ($12) ===
=== Screen 2 Scroll Y ($13) ===
The X and Y coordinates that Screen 2 is scrolled by.
== Palette I/O ports ==
These I/O ports are only used in the monochrome display mode. Color display modes use the memory locations <tt>$FE00</tt> - <tt>$FFFF</tt> to store the color palette.
{{Anchor|LCD Mono Shade LUT}}
=== Mono Shade LUT ($1C, $1D, $1E, $1F) ===
<pre>
$1C $1D $1E $1F
7 bit 0 7 bit 0 7 bit 0 7 bit 0
---- ---- ---- ---- ---- ---- ---- ----
1111 0000 3333 2222 5555 4444 7777 6666
|||| |||| |||| |||| |||| |||| |||| ||||
|||| |||| |||| |||| |||| |||| |||| ++++- Shade for LUT index 6
|||| |||| |||| |||| |||| |||| ++++------ Shade for LUT index 7
|||| |||| |||| |||| |||| ++++------------- Shade for LUT index 4
|||| |||| |||| |||| ++++------------------ Shade for LUT index 5
|||| |||| |||| ++++------------------------- Shade for LUT index 2
|||| |||| ++++------------------------------ Shade for LUT index 3
|||| ++++------------------------------------- Shade for LUT index 0
++++------------------------------------------ Shade for LUT index 1
</pre>
{{Anchor|LCD Mono Palette}}
=== Mono Palette 0..15 ($20, $21 .. $3E, $3F) ===
The monochrome palette is laid out as sixteen words:
<pre>
N+1 N
15 bit 8 7 bit 0
---- ---- ---- ----
.333 .222 .111 .000
||| ||| ||| |||
||| ||| ||| +++- Shade LUT index for color 0
||| ||| +++------ Shade LUT index for color 1
||| +++------------ Shade LUT index for color 2
+++----------------- Shade LUT index for color 3
</pre>
== LCD I/O ports ==
{{Anchor|LCD Control}}
=== LCD Control ($14) ===
<pre>
7 bit 0
---- ----
.... ..Ce
||
|+- LCD enable: 0 = sleep, 1 = enabled
+-- Contrast (WSC): 0 = low, 1 = high
</pre>
The enable bit controls whether or not the LCD screen is displaying graphics; if sleeping, it displays nothing (all white). Note that icon segments continue displaying regardless of this configuration.
Note that port $1A provides a separate LCD sleep bit; the display will be disabled in the same way if any of those bits are set to "sleep".
The contrast bit allows enabling a "high contrast" mode: this works by having the LCD drive two lines with data received from the SoC - so the first line of the LCD is driven by the first line from the SoC, then additionally by the second line from the SoC.
{{Anchor|LCD Icon Control}}
=== LCD Icon Control ($15) ===
<pre>
7 bit 0
---- ----
..32 1hvs
|| ||||
|| |||+- Sleep (Star)
|| ||+-- Vertical orientation
|| |+--- Horizontal orientation
|| +---- Etc. 1 (Small circle)
|+------ Etc. 2 (Medium circle)
+------- Etc. 3 (Large circle)
</pre>
== LCD internal I/O ports ==
These I/O ports are not used and most likely not intended for use by commercial games.
{{Anchor|LCD Final Line}}
=== LCD Final Line ($16) ===
The final line preceding line counter restart and the beginning of active display. By default, this is set to 158, which equals 159 total lines per frame.
It is said setting this register to an odd value on SwanCrystal has an adverse effect to the LCD panel,<ref>[http://daifukkat.su/docs/wsman/#REG_LCD_VTOTAL REG_LCD_VTOTAL - WSMan]</ref> but the exact mechanism is unknown. A starting point for research is that an even value, or odd total line count, is needed to balance positive and negative charges on the LCD.<ref>W.A. Steer. "[http://www.techmind.org/lcd/ LCD monitor technology and tests]". Techmind, 2011-12-03. Accessed 2024-11-19.</ref>
{{Anchor|LCD Back Porch Line}}
=== LCD Back Porch Line ($17, WSC only) ===
This port is available on the WonderSwan Color only - not the SwanCrystal!
The final line preceding the vertical back porch; by default, this should be set to 155.
The vertical back porch of the LCD is assumed to be 4 lines by some hardware, including IPS mods, as well as the official "TV Swan" capture device. Given that the first visible line is sent to the LCD on the display's line 1, this should be generally set to <code>LCD Final Line - 3</code>.
Conversely, it is said moving this value closer to vertical blank improves LCD visibility<ref>[http://daifukkat.su/docs/wsman/#REG_LCD_VSYNC REG_LCD_VSYNC - WSMan]</ref>, but the exact mechanism is unknown.
{{Anchor|LCD Line Counter}}
=== LCD Line Counter ($18) ===
This write-only port can be written to in order to change the next line to be drawn on the LCD.
For out of range values (higher than the final line), the LCD panel is not driven, but the line counter continues increasing until it rolls over to <tt>$00</tt>.
{{Anchor|LCD Status}}
=== LCD Latched Icon Status ($1A read) ===
<pre>
7 bit 0
---- ----
..cv vvhl
|| ||||
|| |||+- Latch override: 0 = no, 1 = yes
|| ||+-- Headphone icon
|| ||
|| || Volume icons:
|| |+--- - Volume B (medium, high)
|| +---- - Volume A (low, high)
|+------ - Speaker
|
+------- Cartridge icon
</pre>
This port shows the state of latched LCD icons; these are displayed for an additional 128 ticks, counting from the last time they were enabled.
TODO: This documents the WonderSwan Color. The specifics may work differently on the mono WonderSwan.
=== LCD Latched Icon Control ($1A write) ===
<pre>
7 bit 0
---- ----
..cs ...l
|| |
|| +- Latch override: 0 = no, 1 = yes
|| (disables LCD panel, including all segments)
|+------ Show sound segments
+------- Show cartridge segment
</pre>
This port allows overriding the default behaviour of the "cartridge segment" and "sound segment" display logic.
Note that other bits may only be written to when the latch override is enabled.
=== TFT LCD Configuration ($70, $71, $72, $73, $74, $75, $76, $77 SwanCrystal only) ===
These eight bytes are read from internal EEPROM and configure unknown aspects of the console's TFT LCD panel.
They are only writable while the [[Boot ROM]] is unlocked - locking has the side effect of making them read-only.
== Notes ==
<references />
a69890cc25407c9dcecf8ddb5a528f55fba52a3b
532
530
2025-02-23T20:09:08Z
Asie
351
/* LCD Control ($14) */
wikitext
text/x-wiki
== Graphics I/O ports ==
{{Anchor|Display Control}}
=== Display Control ($00) ===
<pre>
7 bit 0
---- ----
..wo Ws21
|| ||||
|| |||+- Enable Screen 1 layer
|| ||+-- Enable Screen 2 layer
|| |+--- Enable Sprite layer
|| +---- Enable Sprite window
|+------ Screen 2 tiles are drawn (if window enabled):
| 0 = inside window,
| 1 = outside window.
+------- Enable Screen 2 window
</pre>
{{Anchor|Display Background}}
=== Display Background Color ($01) ===
<pre>
(mono) (color)
7 bit 0 7 bit 0
---- ---- ---- ----
.... .sss pppp iiii
||| |||| ||||
+++- Value |||| ++++- Index in palette (0-15)
(0-7) ++++------ Color palette (0-15)
</pre>
{{Anchor|Display Current Line}}
=== Display Current Line ($02 read) ===
The current line being drawn by the display.
Note that lines are sent to the display with a one-line delay. This matters for color palette or shade LUT manipulation; changing these values when <code>current line == 1</code> will actually affect line 0.
{{Anchor|Display Interrupt Line}}
=== Display Interrupt Line ($03) ===
The line to emit an interrupt on.
{{Anchor|Sprite Table Address}}
=== Sprite Table Address ($04) ===
<pre>
7 bit 0
---- ----
..Aa aaaa
|| ||||
|+-++++- Address (bits 9-13)
+------- Address (bit 14) - color only
</pre>
{{Anchor|Sprite Table First}}
=== Sprite Table First ($05) ===
<pre>
7 bit 0
---- ----
.iii iiii
||| ||||
+++-++++- Index of first sprite entry to draw (0-127)
</pre>
{{Anchor|Sprite Table Count}}
=== Sprite Table Count ($06) ===
<pre>
7 bit 0
---- ----
cccc cccc
|||| ||||
++++-++++- Count of sprite entries to draw (1-128)
</pre>
{{Anchor|Screen Address}}
=== Screen Address ($07) ===
<pre>
7 bit 0
---- ----
2222 1111
|||| ||||
|||| |+++- Screen 1 address (bits 11-13)
|||| +---- Screen 1 address (bit 14) - color only
|+++------ Screen 2 address (bits 11-13)
+--------- Screen 2 address (bit 14) - color only
</pre>
{{Anchor|Screen 2 Window}}
=== Screen 2 Window Left ($08) ===
=== Screen 2 Window Top ($09) ===
=== Screen 2 Window Right ($0A) ===
=== Screen 2 Window Bottom ($0B) ===
The X and Y coordinates of the Screen 2 window.
Note that all coordinates are inclusive; for example, for a 200x100 window in the top-left corner, the values should be set as follows:
* Left - 0,
* Top - 0,
* Right - 199,
* Bottom - 99.
{{Anchor|Sprite Window}}
=== Sprite Window Left ($0C) ===
=== Sprite Window Top ($0D) ===
=== Sprite Window Right ($0E) ===
=== Sprite Window Bottom ($0F) ===
The X and Y coordinates of the Sprite window.
Note that all coordinates are inclusive.
{{Anchor|Screen Scroll}}
=== Screen 1 Scroll X ($10) ===
=== Screen 1 Scroll Y ($11) ===
The X and Y coordinates that Screen 1 is scrolled by.
For example, setting Scroll X to 24 and Scroll Y to 8 will omit, in 8x8 tile units, the first three rows and the first two columns of the 32x32 screen.
=== Screen 2 Scroll X ($12) ===
=== Screen 2 Scroll Y ($13) ===
The X and Y coordinates that Screen 2 is scrolled by.
== Palette I/O ports ==
These I/O ports are only used in the monochrome display mode. Color display modes use the memory locations <tt>$FE00</tt> - <tt>$FFFF</tt> to store the color palette.
{{Anchor|LCD Mono Shade LUT}}
=== Mono Shade LUT ($1C, $1D, $1E, $1F) ===
<pre>
$1C $1D $1E $1F
7 bit 0 7 bit 0 7 bit 0 7 bit 0
---- ---- ---- ---- ---- ---- ---- ----
1111 0000 3333 2222 5555 4444 7777 6666
|||| |||| |||| |||| |||| |||| |||| ||||
|||| |||| |||| |||| |||| |||| |||| ++++- Shade for LUT index 6
|||| |||| |||| |||| |||| |||| ++++------ Shade for LUT index 7
|||| |||| |||| |||| |||| ++++------------- Shade for LUT index 4
|||| |||| |||| |||| ++++------------------ Shade for LUT index 5
|||| |||| |||| ++++------------------------- Shade for LUT index 2
|||| |||| ++++------------------------------ Shade for LUT index 3
|||| ++++------------------------------------- Shade for LUT index 0
++++------------------------------------------ Shade for LUT index 1
</pre>
{{Anchor|LCD Mono Palette}}
=== Mono Palette 0..15 ($20, $21 .. $3E, $3F) ===
The monochrome palette is laid out as sixteen words:
<pre>
N+1 N
15 bit 8 7 bit 0
---- ---- ---- ----
.333 .222 .111 .000
||| ||| ||| |||
||| ||| ||| +++- Shade LUT index for color 0
||| ||| +++------ Shade LUT index for color 1
||| +++------------ Shade LUT index for color 2
+++----------------- Shade LUT index for color 3
</pre>
== LCD I/O ports ==
{{Anchor|LCD Control}}
=== LCD Control ($14) ===
<pre>
7 bit 0
---- ----
.... ..Ce
||
|+- LCD enable: 0 = sleep, 1 = enabled
+-- Contrast (WSC): 0 = low, 1 = high
</pre>
The enable bit controls whether or not the LCD screen is displaying graphics; if sleeping, it displays nothing (all white). Note that icon segments continue displaying regardless of this configuration.
Note that port $1A provides a separate LCD sleep bit; the display will be disabled in the same way if any of those bits are set to "sleep".
The contrast bit allows enabling a "high contrast" mode: this works by having the LCD drive two lines with data received from the SoC - so the first line of the LCD is driven by the first line from the SoC, then additionally by the second line from the SoC.
TODO: Bits 4-7 are writable, but only on WSC. Their effect is unknown.
{{Anchor|LCD Icon Control}}
=== LCD Icon Control ($15) ===
<pre>
7 bit 0
---- ----
..32 1hvs
|| ||||
|| |||+- Sleep (Star)
|| ||+-- Vertical orientation
|| |+--- Horizontal orientation
|| +---- Etc. 1 (Small circle)
|+------ Etc. 2 (Medium circle)
+------- Etc. 3 (Large circle)
</pre>
== LCD internal I/O ports ==
These I/O ports are not used and most likely not intended for use by commercial games.
{{Anchor|LCD Final Line}}
=== LCD Final Line ($16) ===
The final line preceding line counter restart and the beginning of active display. By default, this is set to 158, which equals 159 total lines per frame.
It is said setting this register to an odd value on SwanCrystal has an adverse effect to the LCD panel,<ref>[http://daifukkat.su/docs/wsman/#REG_LCD_VTOTAL REG_LCD_VTOTAL - WSMan]</ref> but the exact mechanism is unknown. A starting point for research is that an even value, or odd total line count, is needed to balance positive and negative charges on the LCD.<ref>W.A. Steer. "[http://www.techmind.org/lcd/ LCD monitor technology and tests]". Techmind, 2011-12-03. Accessed 2024-11-19.</ref>
{{Anchor|LCD Back Porch Line}}
=== LCD Back Porch Line ($17, WSC only) ===
This port is available on the WonderSwan Color only - not the SwanCrystal!
The final line preceding the vertical back porch; by default, this should be set to 155.
The vertical back porch of the LCD is assumed to be 4 lines by some hardware, including IPS mods, as well as the official "TV Swan" capture device. Given that the first visible line is sent to the LCD on the display's line 1, this should be generally set to <code>LCD Final Line - 3</code>.
Conversely, it is said moving this value closer to vertical blank improves LCD visibility<ref>[http://daifukkat.su/docs/wsman/#REG_LCD_VSYNC REG_LCD_VSYNC - WSMan]</ref>, but the exact mechanism is unknown.
{{Anchor|LCD Line Counter}}
=== LCD Line Counter ($18) ===
This write-only port can be written to in order to change the next line to be drawn on the LCD.
For out of range values (higher than the final line), the LCD panel is not driven, but the line counter continues increasing until it rolls over to <tt>$00</tt>.
{{Anchor|LCD Status}}
=== LCD Latched Icon Status ($1A read) ===
<pre>
7 bit 0
---- ----
..cv vvhl
|| ||||
|| |||+- Latch override: 0 = no, 1 = yes
|| ||+-- Headphone icon
|| ||
|| || Volume icons:
|| |+--- - Volume B (medium, high)
|| +---- - Volume A (low, high)
|+------ - Speaker
|
+------- Cartridge icon
</pre>
This port shows the state of latched LCD icons; these are displayed for an additional 128 ticks, counting from the last time they were enabled.
TODO: This documents the WonderSwan Color. The specifics may work differently on the mono WonderSwan.
=== LCD Latched Icon Control ($1A write) ===
<pre>
7 bit 0
---- ----
..cs ...l
|| |
|| +- Latch override: 0 = no, 1 = yes
|| (disables LCD panel, including all segments)
|+------ Show sound segments
+------- Show cartridge segment
</pre>
This port allows overriding the default behaviour of the "cartridge segment" and "sound segment" display logic.
Note that other bits may only be written to when the latch override is enabled.
=== TFT LCD Configuration ($70, $71, $72, $73, $74, $75, $76, $77 SwanCrystal only) ===
These eight bytes are read from internal EEPROM and configure unknown aspects of the console's TFT LCD panel.
They are only writable while the [[Boot ROM]] is unlocked - locking has the side effect of making them read-only.
== Notes ==
<references />
9981b8d5bd9aa07c66a87056cc2e7d8f70860b54
538
532
2025-02-24T18:27:16Z
Asie
351
/* LCD Latched Icon Status ($1A read) */
wikitext
text/x-wiki
== Graphics I/O ports ==
{{Anchor|Display Control}}
=== Display Control ($00) ===
<pre>
7 bit 0
---- ----
..wo Ws21
|| ||||
|| |||+- Enable Screen 1 layer
|| ||+-- Enable Screen 2 layer
|| |+--- Enable Sprite layer
|| +---- Enable Sprite window
|+------ Screen 2 tiles are drawn (if window enabled):
| 0 = inside window,
| 1 = outside window.
+------- Enable Screen 2 window
</pre>
{{Anchor|Display Background}}
=== Display Background Color ($01) ===
<pre>
(mono) (color)
7 bit 0 7 bit 0
---- ---- ---- ----
.... .sss pppp iiii
||| |||| ||||
+++- Value |||| ++++- Index in palette (0-15)
(0-7) ++++------ Color palette (0-15)
</pre>
{{Anchor|Display Current Line}}
=== Display Current Line ($02 read) ===
The current line being drawn by the display.
Note that lines are sent to the display with a one-line delay. This matters for color palette or shade LUT manipulation; changing these values when <code>current line == 1</code> will actually affect line 0.
{{Anchor|Display Interrupt Line}}
=== Display Interrupt Line ($03) ===
The line to emit an interrupt on.
{{Anchor|Sprite Table Address}}
=== Sprite Table Address ($04) ===
<pre>
7 bit 0
---- ----
..Aa aaaa
|| ||||
|+-++++- Address (bits 9-13)
+------- Address (bit 14) - color only
</pre>
{{Anchor|Sprite Table First}}
=== Sprite Table First ($05) ===
<pre>
7 bit 0
---- ----
.iii iiii
||| ||||
+++-++++- Index of first sprite entry to draw (0-127)
</pre>
{{Anchor|Sprite Table Count}}
=== Sprite Table Count ($06) ===
<pre>
7 bit 0
---- ----
cccc cccc
|||| ||||
++++-++++- Count of sprite entries to draw (1-128)
</pre>
{{Anchor|Screen Address}}
=== Screen Address ($07) ===
<pre>
7 bit 0
---- ----
2222 1111
|||| ||||
|||| |+++- Screen 1 address (bits 11-13)
|||| +---- Screen 1 address (bit 14) - color only
|+++------ Screen 2 address (bits 11-13)
+--------- Screen 2 address (bit 14) - color only
</pre>
{{Anchor|Screen 2 Window}}
=== Screen 2 Window Left ($08) ===
=== Screen 2 Window Top ($09) ===
=== Screen 2 Window Right ($0A) ===
=== Screen 2 Window Bottom ($0B) ===
The X and Y coordinates of the Screen 2 window.
Note that all coordinates are inclusive; for example, for a 200x100 window in the top-left corner, the values should be set as follows:
* Left - 0,
* Top - 0,
* Right - 199,
* Bottom - 99.
{{Anchor|Sprite Window}}
=== Sprite Window Left ($0C) ===
=== Sprite Window Top ($0D) ===
=== Sprite Window Right ($0E) ===
=== Sprite Window Bottom ($0F) ===
The X and Y coordinates of the Sprite window.
Note that all coordinates are inclusive.
{{Anchor|Screen Scroll}}
=== Screen 1 Scroll X ($10) ===
=== Screen 1 Scroll Y ($11) ===
The X and Y coordinates that Screen 1 is scrolled by.
For example, setting Scroll X to 24 and Scroll Y to 8 will omit, in 8x8 tile units, the first three rows and the first two columns of the 32x32 screen.
=== Screen 2 Scroll X ($12) ===
=== Screen 2 Scroll Y ($13) ===
The X and Y coordinates that Screen 2 is scrolled by.
== Palette I/O ports ==
These I/O ports are only used in the monochrome display mode. Color display modes use the memory locations <tt>$FE00</tt> - <tt>$FFFF</tt> to store the color palette.
{{Anchor|LCD Mono Shade LUT}}
=== Mono Shade LUT ($1C, $1D, $1E, $1F) ===
<pre>
$1C $1D $1E $1F
7 bit 0 7 bit 0 7 bit 0 7 bit 0
---- ---- ---- ---- ---- ---- ---- ----
1111 0000 3333 2222 5555 4444 7777 6666
|||| |||| |||| |||| |||| |||| |||| ||||
|||| |||| |||| |||| |||| |||| |||| ++++- Shade for LUT index 6
|||| |||| |||| |||| |||| |||| ++++------ Shade for LUT index 7
|||| |||| |||| |||| |||| ++++------------- Shade for LUT index 4
|||| |||| |||| |||| ++++------------------ Shade for LUT index 5
|||| |||| |||| ++++------------------------- Shade for LUT index 2
|||| |||| ++++------------------------------ Shade for LUT index 3
|||| ++++------------------------------------- Shade for LUT index 0
++++------------------------------------------ Shade for LUT index 1
</pre>
{{Anchor|LCD Mono Palette}}
=== Mono Palette 0..15 ($20, $21 .. $3E, $3F) ===
The monochrome palette is laid out as sixteen words:
<pre>
N+1 N
15 bit 8 7 bit 0
---- ---- ---- ----
.333 .222 .111 .000
||| ||| ||| |||
||| ||| ||| +++- Shade LUT index for color 0
||| ||| +++------ Shade LUT index for color 1
||| +++------------ Shade LUT index for color 2
+++----------------- Shade LUT index for color 3
</pre>
== LCD I/O ports ==
{{Anchor|LCD Control}}
=== LCD Control ($14) ===
<pre>
7 bit 0
---- ----
.... ..Ce
||
|+- LCD enable: 0 = sleep, 1 = enabled
+-- Contrast (WSC): 0 = low, 1 = high
</pre>
The enable bit controls whether or not the LCD screen is displaying graphics; if sleeping, it displays nothing (all white). Note that icon segments continue displaying regardless of this configuration.
Note that port $1A provides a separate LCD sleep bit; the display will be disabled in the same way if any of those bits are set to "sleep".
The contrast bit allows enabling a "high contrast" mode: this works by having the LCD drive two lines with data received from the SoC - so the first line of the LCD is driven by the first line from the SoC, then additionally by the second line from the SoC.
TODO: Bits 4-7 are writable, but only on WSC. Their effect is unknown.
{{Anchor|LCD Icon Control}}
=== LCD Icon Control ($15) ===
<pre>
7 bit 0
---- ----
..32 1hvs
|| ||||
|| |||+- Sleep (Star)
|| ||+-- Vertical orientation
|| |+--- Horizontal orientation
|| +---- Etc. 1 (Small circle)
|+------ Etc. 2 (Medium circle)
+------- Etc. 3 (Large circle)
</pre>
== LCD internal I/O ports ==
These I/O ports are not used and most likely not intended for use by commercial games.
{{Anchor|LCD Final Line}}
=== LCD Final Line ($16) ===
The final line preceding line counter restart and the beginning of active display. By default, this is set to 158, which equals 159 total lines per frame.
It is said setting this register to an odd value on SwanCrystal has an adverse effect to the LCD panel,<ref>[http://daifukkat.su/docs/wsman/#REG_LCD_VTOTAL REG_LCD_VTOTAL - WSMan]</ref> but the exact mechanism is unknown. A starting point for research is that an even value, or odd total line count, is needed to balance positive and negative charges on the LCD.<ref>W.A. Steer. "[http://www.techmind.org/lcd/ LCD monitor technology and tests]". Techmind, 2011-12-03. Accessed 2024-11-19.</ref>
{{Anchor|LCD Back Porch Line}}
=== LCD Back Porch Line ($17, WSC only) ===
This port is available on the WonderSwan Color only - not the SwanCrystal!
The final line preceding the vertical back porch; by default, this should be set to 155.
The vertical back porch of the LCD is assumed to be 4 lines by some hardware, including IPS mods, as well as the official "TV Swan" capture device. Given that the first visible line is sent to the LCD on the display's line 1, this should be generally set to <code>LCD Final Line - 3</code>.
Conversely, it is said moving this value closer to vertical blank improves LCD visibility<ref>[http://daifukkat.su/docs/wsman/#REG_LCD_VSYNC REG_LCD_VSYNC - WSMan]</ref>, but the exact mechanism is unknown.
{{Anchor|LCD Line Counter}}
=== LCD Line Counter ($18) ===
This write-only port can be written to in order to change the next line to be drawn on the LCD.
For out of range values (higher than the final line), the LCD panel is not driven, but the line counter continues increasing until it rolls over to <tt>$00</tt>.
{{Anchor|LCD Status}}
=== LCD Latched Icon Status ($1A read) ===
<pre>
7 bit 0
---- ----
..cv vvhl
|| ||||
|| |||+- LCD block disable: 0 = no, 1 = yes
|| ||+-- Headphone icon
|| ||
|| || Volume icons:
|| |+--- - Volume B (medium, high)
|| +---- - Volume A (low, high)
|+------ - Speaker
|
+------- Cartridge icon
</pre>
This port shows the state of latched LCD icons; these are displayed for an additional 128 ticks, counting from the last time they were enabled.
Bit 0 (LCD block disable) reflects the value written to the port.
TODO: This documents the WonderSwan Color. The specifics may work differently on the mono WonderSwan.
=== LCD Latched Icon Control ($1A write) ===
<pre>
7 bit 0
---- ----
..cs ...l
|| |
|| +- Latch override: 0 = no, 1 = yes
|| (disables LCD panel, including all segments)
|+------ Show sound segments
+------- Show cartridge segment
</pre>
This port allows overriding the default behaviour of the "cartridge segment" and "sound segment" display logic.
Note that other bits may only be written to when the latch override is enabled.
=== TFT LCD Configuration ($70, $71, $72, $73, $74, $75, $76, $77 SwanCrystal only) ===
These eight bytes are read from internal EEPROM and configure unknown aspects of the console's TFT LCD panel.
They are only writable while the [[Boot ROM]] is unlocked - locking has the side effect of making them read-only.
== Notes ==
<references />
3de8efd972132fbf18e5931a609795c0cf91e151
539
538
2025-02-24T18:30:05Z
Asie
351
/* LCD Latched Icon Control ($1A write) */
wikitext
text/x-wiki
== Graphics I/O ports ==
{{Anchor|Display Control}}
=== Display Control ($00) ===
<pre>
7 bit 0
---- ----
..wo Ws21
|| ||||
|| |||+- Enable Screen 1 layer
|| ||+-- Enable Screen 2 layer
|| |+--- Enable Sprite layer
|| +---- Enable Sprite window
|+------ Screen 2 tiles are drawn (if window enabled):
| 0 = inside window,
| 1 = outside window.
+------- Enable Screen 2 window
</pre>
{{Anchor|Display Background}}
=== Display Background Color ($01) ===
<pre>
(mono) (color)
7 bit 0 7 bit 0
---- ---- ---- ----
.... .sss pppp iiii
||| |||| ||||
+++- Value |||| ++++- Index in palette (0-15)
(0-7) ++++------ Color palette (0-15)
</pre>
{{Anchor|Display Current Line}}
=== Display Current Line ($02 read) ===
The current line being drawn by the display.
Note that lines are sent to the display with a one-line delay. This matters for color palette or shade LUT manipulation; changing these values when <code>current line == 1</code> will actually affect line 0.
{{Anchor|Display Interrupt Line}}
=== Display Interrupt Line ($03) ===
The line to emit an interrupt on.
{{Anchor|Sprite Table Address}}
=== Sprite Table Address ($04) ===
<pre>
7 bit 0
---- ----
..Aa aaaa
|| ||||
|+-++++- Address (bits 9-13)
+------- Address (bit 14) - color only
</pre>
{{Anchor|Sprite Table First}}
=== Sprite Table First ($05) ===
<pre>
7 bit 0
---- ----
.iii iiii
||| ||||
+++-++++- Index of first sprite entry to draw (0-127)
</pre>
{{Anchor|Sprite Table Count}}
=== Sprite Table Count ($06) ===
<pre>
7 bit 0
---- ----
cccc cccc
|||| ||||
++++-++++- Count of sprite entries to draw (1-128)
</pre>
{{Anchor|Screen Address}}
=== Screen Address ($07) ===
<pre>
7 bit 0
---- ----
2222 1111
|||| ||||
|||| |+++- Screen 1 address (bits 11-13)
|||| +---- Screen 1 address (bit 14) - color only
|+++------ Screen 2 address (bits 11-13)
+--------- Screen 2 address (bit 14) - color only
</pre>
{{Anchor|Screen 2 Window}}
=== Screen 2 Window Left ($08) ===
=== Screen 2 Window Top ($09) ===
=== Screen 2 Window Right ($0A) ===
=== Screen 2 Window Bottom ($0B) ===
The X and Y coordinates of the Screen 2 window.
Note that all coordinates are inclusive; for example, for a 200x100 window in the top-left corner, the values should be set as follows:
* Left - 0,
* Top - 0,
* Right - 199,
* Bottom - 99.
{{Anchor|Sprite Window}}
=== Sprite Window Left ($0C) ===
=== Sprite Window Top ($0D) ===
=== Sprite Window Right ($0E) ===
=== Sprite Window Bottom ($0F) ===
The X and Y coordinates of the Sprite window.
Note that all coordinates are inclusive.
{{Anchor|Screen Scroll}}
=== Screen 1 Scroll X ($10) ===
=== Screen 1 Scroll Y ($11) ===
The X and Y coordinates that Screen 1 is scrolled by.
For example, setting Scroll X to 24 and Scroll Y to 8 will omit, in 8x8 tile units, the first three rows and the first two columns of the 32x32 screen.
=== Screen 2 Scroll X ($12) ===
=== Screen 2 Scroll Y ($13) ===
The X and Y coordinates that Screen 2 is scrolled by.
== Palette I/O ports ==
These I/O ports are only used in the monochrome display mode. Color display modes use the memory locations <tt>$FE00</tt> - <tt>$FFFF</tt> to store the color palette.
{{Anchor|LCD Mono Shade LUT}}
=== Mono Shade LUT ($1C, $1D, $1E, $1F) ===
<pre>
$1C $1D $1E $1F
7 bit 0 7 bit 0 7 bit 0 7 bit 0
---- ---- ---- ---- ---- ---- ---- ----
1111 0000 3333 2222 5555 4444 7777 6666
|||| |||| |||| |||| |||| |||| |||| ||||
|||| |||| |||| |||| |||| |||| |||| ++++- Shade for LUT index 6
|||| |||| |||| |||| |||| |||| ++++------ Shade for LUT index 7
|||| |||| |||| |||| |||| ++++------------- Shade for LUT index 4
|||| |||| |||| |||| ++++------------------ Shade for LUT index 5
|||| |||| |||| ++++------------------------- Shade for LUT index 2
|||| |||| ++++------------------------------ Shade for LUT index 3
|||| ++++------------------------------------- Shade for LUT index 0
++++------------------------------------------ Shade for LUT index 1
</pre>
{{Anchor|LCD Mono Palette}}
=== Mono Palette 0..15 ($20, $21 .. $3E, $3F) ===
The monochrome palette is laid out as sixteen words:
<pre>
N+1 N
15 bit 8 7 bit 0
---- ---- ---- ----
.333 .222 .111 .000
||| ||| ||| |||
||| ||| ||| +++- Shade LUT index for color 0
||| ||| +++------ Shade LUT index for color 1
||| +++------------ Shade LUT index for color 2
+++----------------- Shade LUT index for color 3
</pre>
== LCD I/O ports ==
{{Anchor|LCD Control}}
=== LCD Control ($14) ===
<pre>
7 bit 0
---- ----
.... ..Ce
||
|+- LCD enable: 0 = sleep, 1 = enabled
+-- Contrast (WSC): 0 = low, 1 = high
</pre>
The enable bit controls whether or not the LCD screen is displaying graphics; if sleeping, it displays nothing (all white). Note that icon segments continue displaying regardless of this configuration.
Note that port $1A provides a separate LCD sleep bit; the display will be disabled in the same way if any of those bits are set to "sleep".
The contrast bit allows enabling a "high contrast" mode: this works by having the LCD drive two lines with data received from the SoC - so the first line of the LCD is driven by the first line from the SoC, then additionally by the second line from the SoC.
TODO: Bits 4-7 are writable, but only on WSC. Their effect is unknown.
{{Anchor|LCD Icon Control}}
=== LCD Icon Control ($15) ===
<pre>
7 bit 0
---- ----
..32 1hvs
|| ||||
|| |||+- Sleep (Star)
|| ||+-- Vertical orientation
|| |+--- Horizontal orientation
|| +---- Etc. 1 (Small circle)
|+------ Etc. 2 (Medium circle)
+------- Etc. 3 (Large circle)
</pre>
== LCD internal I/O ports ==
These I/O ports are not used and most likely not intended for use by commercial games.
{{Anchor|LCD Final Line}}
=== LCD Final Line ($16) ===
The final line preceding line counter restart and the beginning of active display. By default, this is set to 158, which equals 159 total lines per frame.
It is said setting this register to an odd value on SwanCrystal has an adverse effect to the LCD panel,<ref>[http://daifukkat.su/docs/wsman/#REG_LCD_VTOTAL REG_LCD_VTOTAL - WSMan]</ref> but the exact mechanism is unknown. A starting point for research is that an even value, or odd total line count, is needed to balance positive and negative charges on the LCD.<ref>W.A. Steer. "[http://www.techmind.org/lcd/ LCD monitor technology and tests]". Techmind, 2011-12-03. Accessed 2024-11-19.</ref>
{{Anchor|LCD Back Porch Line}}
=== LCD Back Porch Line ($17, WSC only) ===
This port is available on the WonderSwan Color only - not the SwanCrystal!
The final line preceding the vertical back porch; by default, this should be set to 155.
The vertical back porch of the LCD is assumed to be 4 lines by some hardware, including IPS mods, as well as the official "TV Swan" capture device. Given that the first visible line is sent to the LCD on the display's line 1, this should be generally set to <code>LCD Final Line - 3</code>.
Conversely, it is said moving this value closer to vertical blank improves LCD visibility<ref>[http://daifukkat.su/docs/wsman/#REG_LCD_VSYNC REG_LCD_VSYNC - WSMan]</ref>, but the exact mechanism is unknown.
{{Anchor|LCD Line Counter}}
=== LCD Line Counter ($18) ===
This write-only port can be written to in order to change the next line to be drawn on the LCD.
For out of range values (higher than the final line), the LCD panel is not driven, but the line counter continues increasing until it rolls over to <tt>$00</tt>.
{{Anchor|LCD Status}}
=== LCD Latched Icon Status ($1A read) ===
<pre>
7 bit 0
---- ----
..cv vvhl
|| ||||
|| |||+- LCD block disable: 0 = no, 1 = yes
|| ||+-- Headphone icon
|| ||
|| || Volume icons:
|| |+--- - Volume B (medium, high)
|| +---- - Volume A (low, high)
|+------ - Speaker
|
+------- Cartridge icon
</pre>
This port shows the state of latched LCD icons; these are displayed for an additional 128 ticks, counting from the last time they were enabled.
Bit 0 (LCD block disable) reflects the value written to the port.
TODO: This documents the WonderSwan Color. The specifics may work differently on the mono WonderSwan.
=== LCD Latched Icon Control ($1A write) ===
<pre>
7 bit 0
---- ----
..cs ...l
|| |
|| +- LCD block disable: 0 = no, 1 = yes
|| (disables LCD panel, including all segments)
|+------ Latch sound segments
+------- Latch cartridge segment
</pre>
This port allows disabling the full LCD IP block; if bit 0 is set, all LCD panel control (including segments and sound/cartridge segment display timers) is disabled.
This port also allows manually latching the sound/cartridge segment display with their respective timers; however, this can only be done if bit 0 is set. For example, to latch the cartridge segment timer, one can write <tt>$21</tt> to the port to disable the LCD block and latch the cartridge segment. Next, after re-enabling the LCD block by clearing bit 0, the cartridge segment will be shown for 128 vertical blanks.
=== TFT LCD Configuration ($70, $71, $72, $73, $74, $75, $76, $77 SwanCrystal only) ===
These eight bytes are read from internal EEPROM and configure unknown aspects of the console's TFT LCD panel.
They are only writable while the [[Boot ROM]] is unlocked - locking has the side effect of making them read-only.
== Notes ==
<references />
1ce31fbf36db5275e9af39bf7a374ce1035343cb
544
539
2025-02-24T18:43:21Z
Asie
351
/* LCD Control ($14) */
wikitext
text/x-wiki
== Graphics I/O ports ==
{{Anchor|Display Control}}
=== Display Control ($00) ===
<pre>
7 bit 0
---- ----
..wo Ws21
|| ||||
|| |||+- Enable Screen 1 layer
|| ||+-- Enable Screen 2 layer
|| |+--- Enable Sprite layer
|| +---- Enable Sprite window
|+------ Screen 2 tiles are drawn (if window enabled):
| 0 = inside window,
| 1 = outside window.
+------- Enable Screen 2 window
</pre>
{{Anchor|Display Background}}
=== Display Background Color ($01) ===
<pre>
(mono) (color)
7 bit 0 7 bit 0
---- ---- ---- ----
.... .sss pppp iiii
||| |||| ||||
+++- Value |||| ++++- Index in palette (0-15)
(0-7) ++++------ Color palette (0-15)
</pre>
{{Anchor|Display Current Line}}
=== Display Current Line ($02 read) ===
The current line being drawn by the display.
Note that lines are sent to the display with a one-line delay. This matters for color palette or shade LUT manipulation; changing these values when <code>current line == 1</code> will actually affect line 0.
{{Anchor|Display Interrupt Line}}
=== Display Interrupt Line ($03) ===
The line to emit an interrupt on.
{{Anchor|Sprite Table Address}}
=== Sprite Table Address ($04) ===
<pre>
7 bit 0
---- ----
..Aa aaaa
|| ||||
|+-++++- Address (bits 9-13)
+------- Address (bit 14) - color only
</pre>
{{Anchor|Sprite Table First}}
=== Sprite Table First ($05) ===
<pre>
7 bit 0
---- ----
.iii iiii
||| ||||
+++-++++- Index of first sprite entry to draw (0-127)
</pre>
{{Anchor|Sprite Table Count}}
=== Sprite Table Count ($06) ===
<pre>
7 bit 0
---- ----
cccc cccc
|||| ||||
++++-++++- Count of sprite entries to draw (1-128)
</pre>
{{Anchor|Screen Address}}
=== Screen Address ($07) ===
<pre>
7 bit 0
---- ----
2222 1111
|||| ||||
|||| |+++- Screen 1 address (bits 11-13)
|||| +---- Screen 1 address (bit 14) - color only
|+++------ Screen 2 address (bits 11-13)
+--------- Screen 2 address (bit 14) - color only
</pre>
{{Anchor|Screen 2 Window}}
=== Screen 2 Window Left ($08) ===
=== Screen 2 Window Top ($09) ===
=== Screen 2 Window Right ($0A) ===
=== Screen 2 Window Bottom ($0B) ===
The X and Y coordinates of the Screen 2 window.
Note that all coordinates are inclusive; for example, for a 200x100 window in the top-left corner, the values should be set as follows:
* Left - 0,
* Top - 0,
* Right - 199,
* Bottom - 99.
{{Anchor|Sprite Window}}
=== Sprite Window Left ($0C) ===
=== Sprite Window Top ($0D) ===
=== Sprite Window Right ($0E) ===
=== Sprite Window Bottom ($0F) ===
The X and Y coordinates of the Sprite window.
Note that all coordinates are inclusive.
{{Anchor|Screen Scroll}}
=== Screen 1 Scroll X ($10) ===
=== Screen 1 Scroll Y ($11) ===
The X and Y coordinates that Screen 1 is scrolled by.
For example, setting Scroll X to 24 and Scroll Y to 8 will omit, in 8x8 tile units, the first three rows and the first two columns of the 32x32 screen.
=== Screen 2 Scroll X ($12) ===
=== Screen 2 Scroll Y ($13) ===
The X and Y coordinates that Screen 2 is scrolled by.
== Palette I/O ports ==
These I/O ports are only used in the monochrome display mode. Color display modes use the memory locations <tt>$FE00</tt> - <tt>$FFFF</tt> to store the color palette.
{{Anchor|LCD Mono Shade LUT}}
=== Mono Shade LUT ($1C, $1D, $1E, $1F) ===
<pre>
$1C $1D $1E $1F
7 bit 0 7 bit 0 7 bit 0 7 bit 0
---- ---- ---- ---- ---- ---- ---- ----
1111 0000 3333 2222 5555 4444 7777 6666
|||| |||| |||| |||| |||| |||| |||| ||||
|||| |||| |||| |||| |||| |||| |||| ++++- Shade for LUT index 6
|||| |||| |||| |||| |||| |||| ++++------ Shade for LUT index 7
|||| |||| |||| |||| |||| ++++------------- Shade for LUT index 4
|||| |||| |||| |||| ++++------------------ Shade for LUT index 5
|||| |||| |||| ++++------------------------- Shade for LUT index 2
|||| |||| ++++------------------------------ Shade for LUT index 3
|||| ++++------------------------------------- Shade for LUT index 0
++++------------------------------------------ Shade for LUT index 1
</pre>
{{Anchor|LCD Mono Palette}}
=== Mono Palette 0..15 ($20, $21 .. $3E, $3F) ===
The monochrome palette is laid out as sixteen words:
<pre>
N+1 N
15 bit 8 7 bit 0
---- ---- ---- ----
.333 .222 .111 .000
||| ||| ||| |||
||| ||| ||| +++- Shade LUT index for color 0
||| ||| +++------ Shade LUT index for color 1
||| +++------------ Shade LUT index for color 2
+++----------------- Shade LUT index for color 3
</pre>
== LCD I/O ports ==
{{Anchor|LCD Control}}
=== LCD Control ($14) ===
<pre>
7 bit 0
---- ----
.... ..Ce
||
|+- LCD enable: 0 = sleep, 1 = enabled
+-- Contrast (WSC): 0 = low, 1 = high
</pre>
The enable bit controls whether or not the LCD screen is displaying graphics. When it is cleared, the pixel area acts as if it was powered off, but the segment area continues functioning as normal.
The contrast bit allows enabling a "high contrast" mode: this works by having the LCD drive two lines with data received from the SoC - so the first line of the LCD is driven by the first line from the SoC, then additionally by the second line from the SoC.
TODO: Bits 4-7 are writable, but only on WSC. Their effect is unknown.
{{Anchor|LCD Icon Control}}
=== LCD Icon Control ($15) ===
<pre>
7 bit 0
---- ----
..32 1hvs
|| ||||
|| |||+- Sleep (Star)
|| ||+-- Vertical orientation
|| |+--- Horizontal orientation
|| +---- Etc. 1 (Small circle)
|+------ Etc. 2 (Medium circle)
+------- Etc. 3 (Large circle)
</pre>
== LCD internal I/O ports ==
These I/O ports are not used and most likely not intended for use by commercial games.
{{Anchor|LCD Final Line}}
=== LCD Final Line ($16) ===
The final line preceding line counter restart and the beginning of active display. By default, this is set to 158, which equals 159 total lines per frame.
It is said setting this register to an odd value on SwanCrystal has an adverse effect to the LCD panel,<ref>[http://daifukkat.su/docs/wsman/#REG_LCD_VTOTAL REG_LCD_VTOTAL - WSMan]</ref> but the exact mechanism is unknown. A starting point for research is that an even value, or odd total line count, is needed to balance positive and negative charges on the LCD.<ref>W.A. Steer. "[http://www.techmind.org/lcd/ LCD monitor technology and tests]". Techmind, 2011-12-03. Accessed 2024-11-19.</ref>
{{Anchor|LCD Back Porch Line}}
=== LCD Back Porch Line ($17, WSC only) ===
This port is available on the WonderSwan Color only - not the SwanCrystal!
The final line preceding the vertical back porch; by default, this should be set to 155.
The vertical back porch of the LCD is assumed to be 4 lines by some hardware, including IPS mods, as well as the official "TV Swan" capture device. Given that the first visible line is sent to the LCD on the display's line 1, this should be generally set to <code>LCD Final Line - 3</code>.
Conversely, it is said moving this value closer to vertical blank improves LCD visibility<ref>[http://daifukkat.su/docs/wsman/#REG_LCD_VSYNC REG_LCD_VSYNC - WSMan]</ref>, but the exact mechanism is unknown.
{{Anchor|LCD Line Counter}}
=== LCD Line Counter ($18) ===
This write-only port can be written to in order to change the next line to be drawn on the LCD.
For out of range values (higher than the final line), the LCD panel is not driven, but the line counter continues increasing until it rolls over to <tt>$00</tt>.
{{Anchor|LCD Status}}
=== LCD Latched Icon Status ($1A read) ===
<pre>
7 bit 0
---- ----
..cv vvhl
|| ||||
|| |||+- LCD block disable: 0 = no, 1 = yes
|| ||+-- Headphone icon
|| ||
|| || Volume icons:
|| |+--- - Volume B (medium, high)
|| +---- - Volume A (low, high)
|+------ - Speaker
|
+------- Cartridge icon
</pre>
This port shows the state of latched LCD icons; these are displayed for an additional 128 ticks, counting from the last time they were enabled.
Bit 0 (LCD block disable) reflects the value written to the port.
TODO: This documents the WonderSwan Color. The specifics may work differently on the mono WonderSwan.
=== LCD Latched Icon Control ($1A write) ===
<pre>
7 bit 0
---- ----
..cs ...l
|| |
|| +- LCD block disable: 0 = no, 1 = yes
|| (disables LCD panel, including all segments)
|+------ Latch sound segments
+------- Latch cartridge segment
</pre>
This port allows disabling the full LCD IP block; if bit 0 is set, all LCD panel control (including segments and sound/cartridge segment display timers) is disabled.
This port also allows manually latching the sound/cartridge segment display with their respective timers; however, this can only be done if bit 0 is set. For example, to latch the cartridge segment timer, one can write <tt>$21</tt> to the port to disable the LCD block and latch the cartridge segment. Next, after re-enabling the LCD block by clearing bit 0, the cartridge segment will be shown for 128 vertical blanks.
=== TFT LCD Configuration ($70, $71, $72, $73, $74, $75, $76, $77 SwanCrystal only) ===
These eight bytes are read from internal EEPROM and configure unknown aspects of the console's TFT LCD panel.
They are only writable while the [[Boot ROM]] is unlocked - locking has the side effect of making them read-only.
== Notes ==
<references />
a7dfe306ea73b6ff78b24a7040b3381f1f7d6854
545
544
2025-02-24T18:44:30Z
Asie
351
/* LCD Control ($14) */
wikitext
text/x-wiki
== Graphics I/O ports ==
{{Anchor|Display Control}}
=== Display Control ($00) ===
<pre>
7 bit 0
---- ----
..wo Ws21
|| ||||
|| |||+- Enable Screen 1 layer
|| ||+-- Enable Screen 2 layer
|| |+--- Enable Sprite layer
|| +---- Enable Sprite window
|+------ Screen 2 tiles are drawn (if window enabled):
| 0 = inside window,
| 1 = outside window.
+------- Enable Screen 2 window
</pre>
{{Anchor|Display Background}}
=== Display Background Color ($01) ===
<pre>
(mono) (color)
7 bit 0 7 bit 0
---- ---- ---- ----
.... .sss pppp iiii
||| |||| ||||
+++- Value |||| ++++- Index in palette (0-15)
(0-7) ++++------ Color palette (0-15)
</pre>
{{Anchor|Display Current Line}}
=== Display Current Line ($02 read) ===
The current line being drawn by the display.
Note that lines are sent to the display with a one-line delay. This matters for color palette or shade LUT manipulation; changing these values when <code>current line == 1</code> will actually affect line 0.
{{Anchor|Display Interrupt Line}}
=== Display Interrupt Line ($03) ===
The line to emit an interrupt on.
{{Anchor|Sprite Table Address}}
=== Sprite Table Address ($04) ===
<pre>
7 bit 0
---- ----
..Aa aaaa
|| ||||
|+-++++- Address (bits 9-13)
+------- Address (bit 14) - color only
</pre>
{{Anchor|Sprite Table First}}
=== Sprite Table First ($05) ===
<pre>
7 bit 0
---- ----
.iii iiii
||| ||||
+++-++++- Index of first sprite entry to draw (0-127)
</pre>
{{Anchor|Sprite Table Count}}
=== Sprite Table Count ($06) ===
<pre>
7 bit 0
---- ----
cccc cccc
|||| ||||
++++-++++- Count of sprite entries to draw (1-128)
</pre>
{{Anchor|Screen Address}}
=== Screen Address ($07) ===
<pre>
7 bit 0
---- ----
2222 1111
|||| ||||
|||| |+++- Screen 1 address (bits 11-13)
|||| +---- Screen 1 address (bit 14) - color only
|+++------ Screen 2 address (bits 11-13)
+--------- Screen 2 address (bit 14) - color only
</pre>
{{Anchor|Screen 2 Window}}
=== Screen 2 Window Left ($08) ===
=== Screen 2 Window Top ($09) ===
=== Screen 2 Window Right ($0A) ===
=== Screen 2 Window Bottom ($0B) ===
The X and Y coordinates of the Screen 2 window.
Note that all coordinates are inclusive; for example, for a 200x100 window in the top-left corner, the values should be set as follows:
* Left - 0,
* Top - 0,
* Right - 199,
* Bottom - 99.
{{Anchor|Sprite Window}}
=== Sprite Window Left ($0C) ===
=== Sprite Window Top ($0D) ===
=== Sprite Window Right ($0E) ===
=== Sprite Window Bottom ($0F) ===
The X and Y coordinates of the Sprite window.
Note that all coordinates are inclusive.
{{Anchor|Screen Scroll}}
=== Screen 1 Scroll X ($10) ===
=== Screen 1 Scroll Y ($11) ===
The X and Y coordinates that Screen 1 is scrolled by.
For example, setting Scroll X to 24 and Scroll Y to 8 will omit, in 8x8 tile units, the first three rows and the first two columns of the 32x32 screen.
=== Screen 2 Scroll X ($12) ===
=== Screen 2 Scroll Y ($13) ===
The X and Y coordinates that Screen 2 is scrolled by.
== Palette I/O ports ==
These I/O ports are only used in the monochrome display mode. Color display modes use the memory locations <tt>$FE00</tt> - <tt>$FFFF</tt> to store the color palette.
{{Anchor|LCD Mono Shade LUT}}
=== Mono Shade LUT ($1C, $1D, $1E, $1F) ===
<pre>
$1C $1D $1E $1F
7 bit 0 7 bit 0 7 bit 0 7 bit 0
---- ---- ---- ---- ---- ---- ---- ----
1111 0000 3333 2222 5555 4444 7777 6666
|||| |||| |||| |||| |||| |||| |||| ||||
|||| |||| |||| |||| |||| |||| |||| ++++- Shade for LUT index 6
|||| |||| |||| |||| |||| |||| ++++------ Shade for LUT index 7
|||| |||| |||| |||| |||| ++++------------- Shade for LUT index 4
|||| |||| |||| |||| ++++------------------ Shade for LUT index 5
|||| |||| |||| ++++------------------------- Shade for LUT index 2
|||| |||| ++++------------------------------ Shade for LUT index 3
|||| ++++------------------------------------- Shade for LUT index 0
++++------------------------------------------ Shade for LUT index 1
</pre>
{{Anchor|LCD Mono Palette}}
=== Mono Palette 0..15 ($20, $21 .. $3E, $3F) ===
The monochrome palette is laid out as sixteen words:
<pre>
N+1 N
15 bit 8 7 bit 0
---- ---- ---- ----
.333 .222 .111 .000
||| ||| ||| |||
||| ||| ||| +++- Shade LUT index for color 0
||| ||| +++------ Shade LUT index for color 1
||| +++------------ Shade LUT index for color 2
+++----------------- Shade LUT index for color 3
</pre>
== LCD I/O ports ==
{{Anchor|LCD Control}}
=== LCD Control ($14) ===
<pre>
7 bit 0
---- ----
.... ..Ce
||
|+- LCD enable: 0 = sleep, 1 = enabled
+-- Contrast (WSC): 0 = low, 1 = high
</pre>
The enable bit controls whether or not the LCD screen is displaying graphics. When it is cleared, the pixel area acts as if it was powered off, but the segment area continues functioning as normal.
The contrast bit allows enabling a "high contrast" mode: this works by having the LCD drive two lines with data received from the SoC - so the first line of the LCD is driven by the first line from the SoC, then additionally by the second line from the SoC.
TODO: Bits 4-7 are writable, but only on WS and WSC. Their effect is unknown.
{{Anchor|LCD Icon Control}}
=== LCD Icon Control ($15) ===
<pre>
7 bit 0
---- ----
..32 1hvs
|| ||||
|| |||+- Sleep (Star)
|| ||+-- Vertical orientation
|| |+--- Horizontal orientation
|| +---- Etc. 1 (Small circle)
|+------ Etc. 2 (Medium circle)
+------- Etc. 3 (Large circle)
</pre>
== LCD internal I/O ports ==
These I/O ports are not used and most likely not intended for use by commercial games.
{{Anchor|LCD Final Line}}
=== LCD Final Line ($16) ===
The final line preceding line counter restart and the beginning of active display. By default, this is set to 158, which equals 159 total lines per frame.
It is said setting this register to an odd value on SwanCrystal has an adverse effect to the LCD panel,<ref>[http://daifukkat.su/docs/wsman/#REG_LCD_VTOTAL REG_LCD_VTOTAL - WSMan]</ref> but the exact mechanism is unknown. A starting point for research is that an even value, or odd total line count, is needed to balance positive and negative charges on the LCD.<ref>W.A. Steer. "[http://www.techmind.org/lcd/ LCD monitor technology and tests]". Techmind, 2011-12-03. Accessed 2024-11-19.</ref>
{{Anchor|LCD Back Porch Line}}
=== LCD Back Porch Line ($17, WSC only) ===
This port is available on the WonderSwan Color only - not the SwanCrystal!
The final line preceding the vertical back porch; by default, this should be set to 155.
The vertical back porch of the LCD is assumed to be 4 lines by some hardware, including IPS mods, as well as the official "TV Swan" capture device. Given that the first visible line is sent to the LCD on the display's line 1, this should be generally set to <code>LCD Final Line - 3</code>.
Conversely, it is said moving this value closer to vertical blank improves LCD visibility<ref>[http://daifukkat.su/docs/wsman/#REG_LCD_VSYNC REG_LCD_VSYNC - WSMan]</ref>, but the exact mechanism is unknown.
{{Anchor|LCD Line Counter}}
=== LCD Line Counter ($18) ===
This write-only port can be written to in order to change the next line to be drawn on the LCD.
For out of range values (higher than the final line), the LCD panel is not driven, but the line counter continues increasing until it rolls over to <tt>$00</tt>.
{{Anchor|LCD Status}}
=== LCD Latched Icon Status ($1A read) ===
<pre>
7 bit 0
---- ----
..cv vvhl
|| ||||
|| |||+- LCD block disable: 0 = no, 1 = yes
|| ||+-- Headphone icon
|| ||
|| || Volume icons:
|| |+--- - Volume B (medium, high)
|| +---- - Volume A (low, high)
|+------ - Speaker
|
+------- Cartridge icon
</pre>
This port shows the state of latched LCD icons; these are displayed for an additional 128 ticks, counting from the last time they were enabled.
Bit 0 (LCD block disable) reflects the value written to the port.
TODO: This documents the WonderSwan Color. The specifics may work differently on the mono WonderSwan.
=== LCD Latched Icon Control ($1A write) ===
<pre>
7 bit 0
---- ----
..cs ...l
|| |
|| +- LCD block disable: 0 = no, 1 = yes
|| (disables LCD panel, including all segments)
|+------ Latch sound segments
+------- Latch cartridge segment
</pre>
This port allows disabling the full LCD IP block; if bit 0 is set, all LCD panel control (including segments and sound/cartridge segment display timers) is disabled.
This port also allows manually latching the sound/cartridge segment display with their respective timers; however, this can only be done if bit 0 is set. For example, to latch the cartridge segment timer, one can write <tt>$21</tt> to the port to disable the LCD block and latch the cartridge segment. Next, after re-enabling the LCD block by clearing bit 0, the cartridge segment will be shown for 128 vertical blanks.
=== TFT LCD Configuration ($70, $71, $72, $73, $74, $75, $76, $77 SwanCrystal only) ===
These eight bytes are read from internal EEPROM and configure unknown aspects of the console's TFT LCD panel.
They are only writable while the [[Boot ROM]] is unlocked - locking has the side effect of making them read-only.
== Notes ==
<references />
dea4ac49803ffda5ea918811257f314e5cd04578
SoC
0
46
534
328
2025-02-23T20:13:47Z
Asie
351
wikitext
text/x-wiki
The WonderSwan SoC is a single-chip solution powering the entirety of the system's hardware - containing the CPU, most peripheral logic, as well as the internal RAM.
There exist three variants of the SoC:
* ASWAN, used in the WonderSwan,
* SPHINX, used in the WonderSwan Color,
* SPHINX2, used in the SwanCrystal.
A fourth variant, CAIRO, was planned<ref>[https://web.archive.org/web/20071023111112/http://www.koto.co.jp/products/mono_sp.html CAIRO グラフィックス機能内蔵ローコストSoC - Wayback Machine]</ref>. It was designed as an ASWAN with a doubled clock speed and a built-in ADPCM decoder, but is not known to have been licensed for any commercial product.
== I/O ports ==
{{Anchor|System Control}}
=== System Control ($A0) ===
<pre>
7 bit 0
---- ----
t??? swcl
| ||||
| |||+- Boot ROM lockout: 0 = off, 1 = on
| ||+-- Color model: 0 = no, 1 = yes
| |+--- Cartridge ROM width: 0 = 8-bit, 1 = 16-bit
| +---- Cartridge ROM wait state: 0 = +0 cycles, 1 = +1
+--------- Cartridge bus test OK
</pre>
{{Anchor|System Control 2}}
=== System Control 2 ($60, color) ===
<pre>
7 bit 0
---- ----
c4C. i?sl
||| | ||
||| | |+- Cartridge clock speed?
||| | +-- Cartridge SRAM wait state: 0 = +0 cycles, 1 = +1
||| +---- Cartridge I/O wait state: 0 = +0 cycles, 1 = +1
||+------- 1 = 4bpp "chunky"; requires all previous
|+-------- 1 = 4bpp; requires all previous
+--------- 0 = mono, 1 = color; also controls access
to WSC-specific features (extra RAM, DMA, etc.)
</pre>
{{Anchor|System Control 3}}
=== System Control 3 ($62, color) ===
<pre>
7 bit 0
---- ----
S... ...p
| |
| +- 1 = Power off system
+--------- 0 = WonderSwan Color (SPHINX)
1 = SwanCrystal (SPHINX2)
</pre>
== Notes ==
<references />
2034e42571522c49c98bc90bd5f9f696ab22c00f
536
534
2025-02-23T20:16:13Z
Asie
351
/* System Control ($A0) */
wikitext
text/x-wiki
The WonderSwan SoC is a single-chip solution powering the entirety of the system's hardware - containing the CPU, most peripheral logic, as well as the internal RAM.
There exist three variants of the SoC:
* ASWAN, used in the WonderSwan,
* SPHINX, used in the WonderSwan Color,
* SPHINX2, used in the SwanCrystal.
A fourth variant, CAIRO, was planned<ref>[https://web.archive.org/web/20071023111112/http://www.koto.co.jp/products/mono_sp.html CAIRO グラフィックス機能内蔵ローコストSoC - Wayback Machine]</ref>. It was designed as an ASWAN with a doubled clock speed and a built-in ADPCM decoder, but is not known to have been licensed for any commercial product.
== I/O ports ==
{{Anchor|System Control}}
=== System Control ($A0) ===
<pre>
7 bit 0
---- ----
C??? swcl
| ||||
| |||+- Boot ROM lockout: 0 = off, 1 = on
| ||+-- Color model: 0 = no, 1 = yes
| |+--- Cartridge ROM width: 0 = 8-bit, 1 = 16-bit
| +---- Cartridge ROM wait state: 0 = +0 cycles, 1 = +1
+--------- Cartridge bus test OK
</pre>
{{Anchor|System Control 2}}
=== System Control 2 ($60, color) ===
<pre>
7 bit 0
---- ----
c4C. i?sl
||| | ||
||| | |+- Cartridge clock speed?
||| | +-- Cartridge SRAM wait state: 0 = +0 cycles, 1 = +1
||| +---- Cartridge I/O wait state: 0 = +0 cycles, 1 = +1
||+------- 1 = 4bpp "chunky"; requires all previous
|+-------- 1 = 4bpp; requires all previous
+--------- 0 = mono, 1 = color; also controls access
to WSC-specific features (extra RAM, DMA, etc.)
</pre>
{{Anchor|System Control 3}}
=== System Control 3 ($62, color) ===
<pre>
7 bit 0
---- ----
S... ...p
| |
| +- 1 = Power off system
+--------- 0 = WonderSwan Color (SPHINX)
1 = SwanCrystal (SPHINX2)
</pre>
== Notes ==
<references />
9075c576177a89fbd676c4feb1e470d751e28659
WonderWitch/Filesystem
0
59
537
365
2025-02-23T21:06:03Z
Asie
351
wikitext
text/x-wiki
== Mount points ==
{| class="wikitable"
|+ FreyaOS mount points
|-
! Path !! File data location !! File table location !! File table size (entries) !! Description
|-
| <code>/rom0</code> || ROM (384 KB) || SRAM bank 3, $16F2 || 128 ||
|-
| <code>/ram0</code> || SRAM bank 0 (64 KB) || SRAM bank 3, $06F2 || 64 ||
|-
| <code>/</code> || || SRAM bank 3, $02F2 || 16 ||
|}
== File table entry format ==
{| class="wikitable"
|+ Header contents
|-
! Offset !! Length !! Contents
|-
| 0 || 16 || File name; zero-terminated Shift-JIS string.
|-
| 16 || 24 || User-friendly file name; zero-terminated Shift-JIS string.
FreyaOS displays the first 12 characters in its file selector.
|-
| 40 || 4 || Location in CPU address space (segment:offset)
|-
| 44 || 4 || Total file size, in bytes, excluding the header.
|-
| 48 || 2 || XMODEM chunk count - above file size divided by 128, then rounded up.
|-
| 50 || 2 || File mode
|-
| 52 || 4 || Modification time
|-
| 56 || 4 || TODO
|-
| 60 || 4 || Offset to resource data, bytes excluding header; -1 if not present.
|}
=== Timestamp format ===
{| class="wikitable"
|+ Header contents
|-
! Bits !! Contents
|-
| 31 - 25 || Year, starting from 2000
|-
| 24 - 21 || Month
|-
| 20 - 16 || Day
|-
| 15 - 11 || Hour
|-
| 10 - 5 || Minute
|-
| 0 - 4 || Second, in two-second units
|}
=== File modes ===
----
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
???? ???? dlis mrwx
|||| ||||
|||| |||+- Execute
|||| ||+-- Write
|||| |+--- Read
|||| +---- Prohibit mmap() use
|||+------ StreamIL-related?
||+------- Intermediate library
|+-------- Symbolic link
+--------- Directory
</pre>
2559fafa1da69e189166ef4fd2bc76f8dd65b6bc
NEC V30MZ instruction set
0
68
541
481
2025-02-24T18:31:48Z
Asie
351
clarify register field
wikitext
text/x-wiki
__NOTOC__
Note that this page is a work in progress.
{| class="wikitable" style="text-align: center"
|+ Official V30MZ (80186) Instructions
|-
| [[#AAA|AAA]] || [[#AAD|AAD]] || [[#AAM|AAM]] || [[#AAS|AAS]] || [[#ADC|ADC]] || [[#ADD|ADD]] || [[#AND|AND]] || [[#BOUND|BOUND]] || [[#CALL|CALL]] || [[#CBW|CBW]] || [[#CLC|CLC]]
|-
| [[#CLD|CLD]] || [[#CLI|CLI]] || [[#CMC|CMC]] || [[#CMP|CMP]] || [[#CMPSB|CMPSB]] || [[#CMPSW|CMPSW]] || [[#CS|CS]] || [[#CWD|CWD]] || [[#DAA|DAA]] || [[#DAS|DAS]] || [[#DEC|DEC]]
|-
| [[#DIV|DIV]] || [[#DS|DS]] || [[#ENTER|ENTER]] || [[#ES|ES]] || [[#HLT|HLT]] || [[#IDIV|IDIV]] || [[#IMUL|IMUL]] || [[#IN|IN]] || [[#INC|INC]] || [[#INSB|INSB]] || [[#INSW|INSW]]
|-
| [[#INT|INT]] || [[#INTO|INTO]] || [[#IRET|IRET]] || [[#JA|JA]] || [[#JBE|JBE]] || [[#JC|JC]] || [[#JCXZ|JCXZ]] || [[#JG|JG]] || [[#JGE|JGE]] || [[#JL|JL]] || [[#JLE|JLE]]
|-
| [[#JMP|JMP]] || [[#JNC|JNC]] || [[#JNO|JNO]] || [[#JNP|JNP]] || [[#JNS|JNS]] || [[#JNZ|JNZ]] || [[#JO|JO]] || [[#JP|JP]] || [[#JS|JS]] || [[#JZ|JZ]] || [[#LAHF|LAHF]]
|-
| [[#LDS|LDS]] || [[#LEA|LEA]] || [[#LEAVE|LEAVE]] || [[#LES|LES]] || [[#LOCK|LOCK]] || [[#LODSB|LODSB]] || [[#LODSW|LODSW]] || [[#LOOP|LOOP]] || [[#LOOPE|LOOPE]] || [[#LOOPNE|LOOPNE]] || [[#MOV|MOV]]
|-
| [[#MOVSB|MOVSB]] || [[#MOVSW|MOVSW]] || [[#MUL|MUL]] || [[#NEG|NEG]] || [[#NOP|NOP]] || [[#NOT|NOT]] || [[#OR|OR]] || [[#OUT|OUT]] || [[#OUTSB|OUTSB]] || [[#OUTSW|OUTSW]] || [[#POLL|POLL]]
|-
| [[#POP|POP]] || [[#POPA|POPA]] || [[#POPF|POPF]] || [[#PUSH|PUSH]] || [[#PUSHA|PUSHA]] || [[#PUSHF|PUSHF]] || [[#RCL|RCL]] || [[#RCR|RCR]] || [[#REP|REP]] || [[#REPNE|REPNE]] || [[#RET|RET]]
|-
| [[#RETF|RETF]] || [[#ROL|ROL]] || [[#ROR|ROR]] || [[#SAHF|SAHF]] || [[#SAR|SAR]] || [[#SBB|SBB]] || [[#SCASB|SCASB]] || [[#SCASW|SCASW]] || [[#SHL|SHL]] || [[#SHR|SHR]] || [[#SS|SS]]
|-
| [[#STC|STC]] || [[#STD|STD]] || [[#STI|STI]] || [[#STOSB|STOSB]] || [[#STOSW|STOSW]] || [[#SUB|SUB]] || [[#TEST|TEST]] || [[#XCHG|XCHG]] || [[#XLAT|XLAT]] || [[#XOR|XOR]]
|}
{| class="mw-collapsible mw-collapsed wikitable sortable" style="width: 340px;"
|+ style="white-space:nowrap; border:1px solid; padding:3px; border-color:rgb(162, 169, 177); background-color:rgb(234, 236, 240);" | Intel <-> NEC mnemonic translation table
!Intel
!NEC
|-
| [[#AAA|AAA]]
| [[#AAA|ADJBA]]
|-
| [[#AAD|AAD]]
| [[#AAD|CVTDB]]
|-
| [[#AAM|AAM]]
| [[#AAM|CVTBD]]
|-
| [[#AAS|AAS]]
| [[#AAS|ADJBS]]
|-
| [[#ADC|ADC]]
| [[#ADC|ADDC]]
|-
| [[#ADD|ADD]]
| [[#ADD|ADD]]
|-
| [[#AND|AND]]
| [[#AND|AND]]
|-
| [[#BOUND|BOUND]]
| [[#BOUND|CHKIND]]
|-
| [[#CALL|CALL]]
| [[#CALL|CALL]]
|-
| [[#CBW|CBW]]
| [[#CBW|CVTBW]]
|-
| [[#CLC|CLC]]
| [[#CLC|CLR1 CY]]
|-
| [[#CLD|CLD]]
| [[#CLD|CLR1 DIR]]
|-
| [[#CLI|CLI]]
| [[#CLI|DI]]
|-
| [[#CMC|CMC]]
| [[#CMC|NOT1 CY]]
|-
| [[#CMP|CMP]]
| [[#CMP|CMP]]
|-
| [[#CMPSB|CMPSB]]
| [[#CMPSB|CMPBKB]]
|-
| [[#CMPSW|CMPSW]]
| [[#CMPSW|CMPBKW]]
|-
| [[#CS|CS]]
| [[#CS|PS]]
|-
| [[#CWD|CWD]]
| [[#CWD|CVTWL]]
|-
| [[#DAA|DAA]]
| [[#DAA|ADJ4A]]
|-
| [[#DAS|DAS]]
| [[#DAS|ADJ4S]]
|-
| [[#DEC|DEC]]
| [[#DEC|DEC]]
|-
| [[#DIV|DIV]]
| [[#DIV|DIVU]]
|-
| [[#DS|DS]]
| [[#DS|DS0]]
|-
| [[#ENTER|ENTER]]
| [[#ENTER|PREPARE]]
|-
| [[#ES|ES]]
| [[#ES|DS1]]
|-
| [[#HLT|HLT]]
| [[#HLT|HALT]]
|-
| [[#IDIV|IDIV]]
| [[#IDIV|DIV]]
|-
| [[#IMUL|IMUL]]
| [[#IMUL|MUL]]
|-
| [[#IN|IN]]
| [[#IN|IN]]
|-
| [[#INC|INC]]
| [[#INC|INC]]
|-
| [[#INSB|INSB]]
| [[#INSB|INMB]]
|-
| [[#INSW|INSW]]
| [[#INSW|INMW]]
|-
| [[#INT|INT]]
| [[#INT|BRK]]
|-
| [[#INTO|INTO]]
| [[#INTO|BRKV]]
|-
| [[#IRET|IRET]]
| [[#IRET|RETI]]
|-
| [[#JA|JA]]
| [[#JA|BH]]
|-
| [[#JBE|JBE]]
| [[#JBE|BNH]]
|-
| [[#JC|JC/JB]]
| [[#JC|BC/BL]]
|-
| [[#JCXZ|JCXZ]]
| [[#JCXZ|BCWZ]]
|-
| [[#JG|JG]]
| [[#JG|BGT]]
|-
| [[#JGE|JGE]]
| [[#JGE|BGE]]
|-
| [[#JL|JL]]
| [[#JL|BLT]]
|-
| [[#JLE|JLE]]
| [[#JLE|BLE]]
|-
| [[#JMP|JMP]]
| [[#JMP|BR]]
|-
| [[#JNC|JNC/JAE]]
| [[#JNC|BNC/BNL]]
|-
| [[#JNO|JNO]]
| [[#JNO|BNV]]
|-
| [[#JNP|JNP]]
| [[#JNP|BPO]]
|-
| [[#JNS|JNS]]
| [[#JNS|BP]]
|-
| [[#JNZ|JNZ/JNE]]
| [[#JNZ|BNZ/BNE]]
|-
| [[#JO|JO]]
| [[#JO|BV]]
|-
| [[#JP|JP]]
| [[#JP|BPE]]
|-
| [[#JS|JS]]
| [[#JS|BN]]
|-
| [[#JZ|JZ/JE]]
| [[#JZ|BZ/BE]]
|-
| [[#LAHF|LAHF]]
| [[#LAHF|MOV]]
|-
| [[#LDS|LDS]]
| [[#LDS|MOV]]
|-
| [[#LEA|LEA]]
| [[#LEA|LDEA]]
|-
| [[#LEAVE|LEAVE]]
| [[#LEAVE|DISPOSE]]
|-
| [[#LES|LES]]
| [[#LES|MOV]]
|-
| [[#LOCK|LOCK]]
| [[#LOCK|BUSLOCK]]
|-
| [[#LODSB|LODSB]]
| [[#LODSB|LDMB]]
|-
| [[#LODSW|LODSW]]
| [[#LODSW|LDMW]]
|-
| [[#LOOP|LOOP]]
| [[#LOOP|DBNZ]]
|-
| [[#LOOPE|LOOPE]]
| [[#LOOPE|DBNZE]]
|-
| [[#LOOPNE|LOOPNE]]
| [[#LOOPNE|DBNZNE]]
|-
| [[#MOV|MOV]]
| [[#MOV|MOV]]
|-
| [[#MOVSB|MOVSB]]
| [[#MOVSB|MOVBKB]]
|-
| [[#MOVSW|MOVSW]]
| [[#MOVSW|MOVBKW]]
|-
| [[#MUL|MUL]]
| [[#MUL|MULU]]
|-
| [[#NEG|NEG]]
| [[#NEG|NEG]]
|-
| [[#NOP|NOP]]
| [[#NOP|NOP]]
|-
| [[#NOT|NOT]]
| [[#NOT|NOT]]
|-
| [[#OR|OR]]
| [[#OR|OR]]
|-
| [[#OUT|OUT]]
| [[#OUT|OUT]]
|-
| [[#OUTSB|OUTSB]]
| [[#OUTSB|OUTM]]
|-
| [[#OUTSW|OUTSW]]
| [[#OUTSW|OUTM]]
|-
| [[#POLL|POLL]]
| [[#POLL|POLL]]
|-
| [[#POP|POP]]
| [[#POP|POP]]
|-
| [[#POPA|POPA]]
| [[#POPA|POP]]
|-
| [[#POPF|POPF]]
| [[#POPF|POP]]
|-
| [[#PUSH|PUSH]]
| [[#PUSH|PUSH]]
|-
| [[#PUSHA|PUSHA]]
| [[#PUSHA|PUSH]]
|-
| [[#PUSHF|PUSHF]]
| [[#PUSHF|PUSH]]
|-
| [[#RCL|RCL]]
| [[#RCL|ROLC]]
|-
| [[#RCR|RCR]]
| [[#RCR|RORC]]
|-
| [[#REP|REP/REPE/REPZ]]
| [[#REP|REP/REPE/REPZ]]
|-
| [[#REPNE|REPNE/REPNZ]]
| [[#REPNE|REPNE/REPNZ]]
|-
| [[#RET|RET]]
| [[#RET|RET]]
|-
| [[#RETF|RETF]]
| [[#RETF|RET]]
|-
| [[#ROL|ROL]]
| [[#ROL|ROL]]
|-
| [[#ROR|ROR]]
| [[#ROR|ROR]]
|-
| [[#SAHF|SAHF]]
| [[#SAHF|MOV]]
|-
| [[#SAR|SAR]]
| [[#SAR|SHRA]]
|-
| [[#SBB|SBB]]
| [[#SBB|SUBC]]
|-
| [[#SCASB|SCASB]]
| [[#SCASB|CMPMB]]
|-
| [[#SCASW|SCASW]]
| [[#SCASW|CMPMW]]
|-
| [[#SHL|SHL]]
| [[#SHL|SHL]]
|-
| [[#SHR|SHR]]
| [[#SHR|SHR]]
|-
| [[#SS|SS]]
| [[#SS|SS]]
|-
| [[#STC|STC]]
| [[#STC|SET1 CY]]
|-
| [[#STD|STD]]
| [[#STD|SET1 DIR]]
|-
| [[#STI|STI]]
| [[#STI|EI]]
|-
| [[#STOSB|STOSB]]
| [[#STOSB|STMB]]
|-
| [[#STOSW|STOSW]]
| [[#STOSW|STMW]]
|-
| [[#SUB|SUB]]
| [[#SUB|SUB]]
|-
| [[#TEST|TEST]]
| [[#TEST|TEST]]
|-
| [[#XCHG|XCHG]]
| [[#XCHG|XCH]]
|-
| [[#XLAT|XLAT]]
| [[#XLAT|TRANS]]
|-
| [[#XOR|XOR]]
| [[#XOR|XOR]]
|}
== Official instructions by type ==
{| class="wikitable sortable" style="text-align: center"
!Type
!colspan=16 class="unsortable" | Instructions
|-
| style="text-align:left;" | Memory
| style="" | [[#MOV|MOV]]
| style="" | [[#XCHG|XCHG]]
| style="" | [[#XLAT|XLAT]]
| style="" | [[#LEA|LEA]]
| style="border-right:none;" | [[#LDS|LDS]]
| style="border-left:none;" | [[#LES|LES]]
| style="border-right:none;" | [[#IN|IN]]
| style="border-left:none;" | [[#OUT|OUT]]
| colspan="8" |
|-
| style="text-align:left;" | Ports
| style="border-right:none;" | [[#IN|IN]]
| style="border-left:none;" | [[#OUT|OUT]]
| style="border-right:none;" | [[#INSB|INSB]]
| style="border-left:none;" | [[#OUTSB|OUTSB]]
| style="border-right:none;" | [[#INSW|INSW]]
| style="border-left:none;" | [[#OUTSW|OUTSW]]
| colspan="10" |
|-
| style="text-align:left;" | Arithmetic
| style="border-right:none;" | [[#ADD|ADD]]
| style="border-left:none;" | [[#SUB|SUB]]
| style="border-right:none;" | [[#ADC|ADC]]
| style="border-left:none;" | [[#SBB|SBB]]
| style="border-right:none;" | [[#INC|INC]]
| style="border-left:none;" | [[#DEC|DEC]]
| style="border-right:none;" | [[#MUL|MUL]]
| style="border-left:none;" | [[#DIV|DIV]]
| style="border-right:none;" | [[#IMUL|IMUL]]
| style="border-left:none;" | [[#IDIV|IDIV]]
| style="" | [[#CMP|CMP]]
| style="" | [[#NEG|NEG]]
| colspan="4" |
|-
| style="text-align:left;" | Numeric
| style="" | [[#CBW|CBW]]
| style="" | [[#CWD|CWD]]
| style="" | [[#AAA|AAA]]
| style="" | [[#AAS|AAS]]
| style="" | [[#AAM|AAM]]
| style="" | [[#AAD|AAD]]
| style="" | [[#DAA|DAA]]
| style="" | [[#DAS|DAS]]
| colspan="8" |
|-
| style="text-align:left;" | Shift
| style="border-right:none;" | [[#ROL|ROL]]
| style="border-left:none;" | [[#ROR|ROR]]
| style="border-right:none;" | [[#RCL|RCL]]
| style="border-left:none;" | [[#RCR|RCR]]
| style="border-right:none;" | [[#SHL|SHL]]
| style="border-left:none;" | [[#SHR|SHR]]
| style="" | [[#SAR|SAR]]
| colspan="9" |
|-
| style="text-align:left;" | Bitwise
| style="" | [[#AND|AND]]
| style="" | [[#OR|OR]]
| style="" | [[#XOR|XOR]]
| style="" | [[#NOT|NOT]]
| style="" | [[#TEST|TEST]]
| colspan="11" |
|-
| style="text-align:left;" | Branch
| style="border-right:none;" | [[#JC|JC]]
| style="border-left:none;" | [[#JNC|JNC]]
| style="border-right:none;" | [[#JZ|JZ]]
| style="border-left:none;" | [[#JNZ|JNZ]]
| style="border-right:none;" | [[#JBE|JBE]]
| style="border-left:none;" | [[#JA|JA]]
| style="border-right:none;" | [[#JO|JO]]
| style="border-left:none;" | [[#JNO|JNO]]
| style="border-right:none;" | [[#JP|JP]]
| style="border-left:none;" | [[#JNP|JNP]]
| style="border-right:none;" | [[#JS|JS]]
| style="border-left:none;" | [[#JNS|JNS]]
| style="border-right:none;" | [[#JL|JL]]
| style="border-left:none;" | [[#JGE|JGE]]
| style="border-right:none;" | [[#JLE|JLE]]
| style="border-left:none;" | [[#JG|JG]]
|-
| style="text-align:left;" | Jump
| style="" | [[#JMP|JMP]]
| style="border-right:none;" | [[#CALL|CALL]]
| style="border-left:none;border-right:none;" | [[#RET|RET]]
| style="border-left:none;" | [[#RETF|RETF]]
| colspan="12" |
|-
| style="text-align:left;" | Loop
| style="" | [[#LOOP|LOOP]]
| style="" | [[#LOOPE|LOOPE]]
| style="" | [[#LOOPNE|LOOPNE]]
| colspan="13" |
|-
| style="text-align:left;" | Interrupt
| style="border-right:none;" | [[#INT|INT]]
| style="border-left:none;" | [[#IRET|IRET]]
| style="" | [[#INTO|INTO]]
| style="" | [[#HLT|HLT]]
| style="" | [[#BOUND|BOUND]]
| colspan="11" |
|-
| style="text-align:left;" | Stack
| style="border-right:none;" | [[#PUSH|PUSH]]
| style="border-left:none;" | [[#POP|POP]]
| style="border-right:none;" | [[#PUSHA|PUSHA]]
| style="border-left:none;" | [[#POPA|POPA]]
| style="border-right:none;" | [[#PUSHF|PUSHF]]
| style="border-left:none;" | [[#POPF|POPF]]
| colspan="10" |
|-
| style="text-align:left;" | Flags
| style="border-right:none;" | [[#CLC|CLC]]
| style="border-left:none;" | [[#STC|STC]]
| style="border-right:none;" | [[#CLD|CLD]]
| style="border-left:none;" | [[#STD|STD]]
| style="border-right:none;" | [[#CLI|CLI]]
| style="border-left:none;" | [[#STI|STI]]
| style="" | [[#CMC|CMC]]
| style="border-right:none;" | [[#LAHF|LAHF]]
| style="border-left:none;" | [[#SAHF|SAHF]]
| colspan="7" |
|-
| style="text-align:left;" | Prefix
| style="" | [[#CS|CS]]
| style="" | [[#DS|DS]]
| style="" | [[#ES|ES]]
| style="" | [[#SS|SS]]
| colspan="12" |
|-
| style="text-align:left;" | String
| style="border-right:none;" | [[#REP|REP]]
| style="border-left:none;border-right:none;" | [[#REP|REPE]]
| style="border-left:none;" | [[#REPNE|REPNE]]
| style="" | [[#MOVSB|MOVSB]]
| style="" | [[#MOVSW|MOVSW]]
| style="border-right:none;" | [[#LODSB|LODSB]]
| style="border-left:none;" | [[#STOSB|STOSB]]
| style="border-right:none;" | [[#LODSW|LODSW]]
| style="border-left:none;" | [[#STOSW|STOSW]]
| style="" | [[#CMPSB|CMPSB]]
| style="" | [[#SCASB|SCASB]]
| style="" | [[#CMPSW|CMPSW]]
| style="" | [[#SCASW|SCASW]]
| colspan="3" |
|-
| style="text-align:left;" | Other
| style="" | [[#NOP|NOP]]
| style="border-right:none;" | [[#ENTER|ENTER]]
| style="border-left:none;" | [[#LEAVE|LEAVE]]
| style="" | [[#LOCK|LOCK]]
| style="" | [[#POLL|POLL]]
| colspan="11" |
|}
== Instruction encoding ==
=== ModR/M byte ===
The ModR/M byte is used in most addressing modes which reference a memory location. This byte consists of three bitfield values:
* <tt>oo</tt> - M'''o'''de;
* <tt>rrr</tt> - Two possible functions:
** '''R'''egister (for addressing modes which require both a register and a register/memory operand),
** Opcode extension (for some opcodes' addressing modes which do not have such a requirement);
* <tt>mmm</tt> - Register/'''M'''emory.
The ''Mode'' and ''Register/Memory'' bitfields can refer to a memory location or to a register, as shown in the table below.
Some instructions define a second argument using the ''Register'' field. It is always interpreted as if ''Mode'' was equal to <tt>11</tt> and, as such, can refer to a register only.
{| class="wikitable" style="text-align: center"
! R/M \ Mode
! <tt>00</tt>
! <tt>01</tt>
! <tt>10</tt>
! <tt>11</tt> ''(byte)''
! <tt>11</tt> ''(word)''
|-
| <tt>000</tt>
| DS:[BX + SI]
| DS:[BX + SI + disp8]
| DS:[BX + SI + disp16]
| AL
| AX
|-
| <tt>001</tt>
| DS:[BX + DI]
| DS:[BX + DI + disp8]
| DS:[BX + DI + disp16]
| CL
| CX
|-
| <tt>010</tt>
| SS:[BP + SI]
| SS:[BP + SI + disp8]
| SS:[BP + SI + disp16]
| DL
| DX
|-
| <tt>011</tt>
| SS:[BP + DI]
| SS:[BP + DI + disp8]
| SS:[BP + DI + disp16]
| BL
| BX
|-
| <tt>100</tt>
| DS:[SI]
| DS:[SI + disp8]
| DS:[SI + disp16]
| AH
| SP
|-
| <tt>101</tt>
| DS:[DI]
| DS:[DI + disp8]
| DS:[DI + disp16]
| CH
| BP
|-
| <tt>110</tt>
| ''DS:[disp16]''
| SS:[BP + disp8]
| SS:[BP + disp16]
| DH
| SI
|-
| <tt>111</tt>
| DS:[BX]
| DS:[BX + disp8]
| DS:[BX + disp16]
| BH
| DI
|}
Displacements are either 8-bit (disp8) or 16-bit (disp16) signed values and they always immediately follow the ModR/M byte. Note that (<tt>oo</tt> = <tt>00</tt>, <tt>mmm</tt> = <tt>110</tt>) is a special case, in which the ''disp16'' value is used directly as a near pointer.
The instruction encoding lists below refer to this byte as <tt>oorrrmmm</tt> (binary), <tt>/r</tt> (hexadecimal) or <tt>/0</tt> (hexademical, <tt>rrr</tt> used as function <tt>0</tt>).
== Official instructions ==
{{Anchor|AAA}}
=== AAA ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| AAA || <tt>37</tt> || <tt>00110111</tt> || 1 || 9
|}
----
{{Anchor|AAD}}
=== AAD ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| AAD imm8 || <tt>B5 ii</tt> || <tt>11010100 iiiiiiii</tt> || 2 || 6
|}
----
{{Anchor|AAM}}
=== AAM ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| AAM imm8 || <tt>B4 ii</tt> || <tt>11010100 iiiiiiii</tt> || 2 || 17
|}
----
{{Anchor|AAS}}
=== AAS ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| AAS || <tt>3F</tt> || <tt>00111111</tt> || 1 || 9
|}
----
{{Anchor|ADC}}
=== ADC ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| ADC AL, imm || <tt>14 ii</tt> || <tt>00010100 iiiiiiii</tt> || 2 || 1
|-
| ADC AX, imm || <tt>15 ii ii</tt> || <tt>00010101 iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| ADC mem8, imm8 || <tt>80 /2 ii</tt> || <tt>10000000 oo010mmm iiiiiiii</tt> || 3+ || 3
|-
| ADC mem16, imm16 || <tt>81 /2 ii ii</tt> || <tt>10000001 oo010mmm iiiiiiii iiiiiiii</tt> || 4+ || 3
|-
| ADC mem16, simm8 || <tt>83 /2 ii</tt> || <tt>10000011 oo010mmm iiiiiiii</tt> || 3+ || 3
|-
| ADC mem8, reg8 || <tt>10 /r</tt> || <tt>00010000 oorrrmmm</tt> || 2+ || 3
|-
| ADC mem16, reg16 || <tt>11 /r</tt> || <tt>00010001 oorrrmmm</tt> || 2+ || 3
|-
| ADC reg8, imm8 || <tt>80 /2 ii</tt> || <tt>10000000 11010mmm iiiiiiii</tt> || 3 || 1
|-
| ADC reg16, imm16 || <tt>81 /2 ii ii</tt> || <tt>10000001 11010mmm iiiiiiii iiiiiiii</tt> || 4 || 1
|-
| ADC reg16, simm8 || <tt>83 /2 ii</tt> || <tt>10000011 11010mmm iiiiiiii</tt> || 3 || 1
|-
| ADC reg8, mem8 || <tt>12 /r</tt> || <tt>00010010 oorrrmmm</tt> || 2+ || 2
|-
| ADC reg16, mem16 || <tt>13 /r</tt> || <tt>00010011 oorrrmmm</tt> || 2+ || 2
|-
| ADC reg8, reg8 || <tt>10 /r</tt> || <tt>000100.0 11rrrmmm</tt> || 2 || 1
|-
| ADC reg16, reg16 || <tt>11 /r</tt> || <tt>000100.1 11rrrmmm</tt> || 2 || 1
|}
----
{{Anchor|ADD}}
=== ADD ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| ADD AL, imm || <tt>04 ii</tt> || <tt>00000100 iiiiiiii</tt> || 2 || 1
|-
| ADD AX, imm || <tt>05 ii ii</tt> || <tt>00000101 iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| ADD mem8, imm8 || <tt>80 /0 ii</tt> || <tt>10000000 oo000mmm iiiiiiii</tt> || 3+ || 3
|-
| ADD mem16, imm16 || <tt>81 /0 ii ii</tt> || <tt>10000001 oo000mmm iiiiiiii iiiiiiii</tt> || 4+ || 3
|-
| ADD mem16, simm8 || <tt>83 /0 ii</tt> || <tt>10000011 oo000mmm iiiiiiii</tt> || 3+ || 3
|-
| ADD mem8, reg8 || <tt>00 /r</tt> || <tt>00000000 oorrrmmm</tt> || 2+ || 3
|-
| ADD mem16, reg16 || <tt>01 /r</tt> || <tt>00000001 oorrrmmm</tt> || 2+ || 3
|-
| ADD reg8, imm8 || <tt>80 /0 ii</tt> || <tt>10000000 11000mmm iiiiiiii</tt> || 3 || 1
|-
| ADD reg16, imm16 || <tt>81 /0 ii ii</tt> || <tt>10000001 11000mmm iiiiiiii iiiiiiii</tt> || 4 || 1
|-
| ADD reg16, simm8 || <tt>83 /0 ii</tt> || <tt>10000011 11000mmm iiiiiiii</tt> || 3 || 1
|-
| ADD reg8, mem8 || <tt>02 /r</tt> || <tt>00000010 oorrrmmm</tt> || 2+ || 2
|-
| ADD reg16, mem16 || <tt>03 /r</tt> || <tt>00000011 oorrrmmm</tt> || 2+ || 2
|-
| ADD reg8, reg8 || <tt>00 /r</tt> || <tt>000000.0 11rrrmmm</tt> || 2 || 1
|-
| ADD reg16, reg16 || <tt>01 /r</tt> || <tt>000000.1 11rrrmmm</tt> || 2 || 1
|}
----
{{Anchor|AND}}
=== AND ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| AND AL, imm || <tt>24 ii</tt> || <tt>00100100 iiiiiiii</tt> || 2 || 1
|-
| AND AX, imm || <tt>25 ii ii</tt> || <tt>00100101 iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| AND mem8, imm8 || <tt>80 /4 ii</tt> || <tt>10000000 oo100mmm iiiiiiii</tt> || 3+ || 3
|-
| AND mem16, imm16 || <tt>81 /4 ii ii</tt> || <tt>10000001 oo100mmm iiiiiiii iiiiiiii</tt> || 4+ || 3
|-
| AND mem16, simm8 || <tt>83 /4 ii</tt> || <tt>10000011 oo100mmm iiiiiiii</tt> || 3+ || 3
|-
| AND mem8, reg8 || <tt>20 /r</tt> || <tt>00100000 oorrrmmm</tt> || 2+ || 3
|-
| AND mem16, reg16 || <tt>21 /r</tt> || <tt>00100001 oorrrmmm</tt> || 2+ || 3
|-
| AND reg8, imm8 || <tt>80 /4 ii</tt> || <tt>10000000 11100mmm iiiiiiii</tt> || 3 || 1
|-
| AND reg16, imm16 || <tt>81 /4 ii ii</tt> || <tt>10000001 11100mmm iiiiiiii iiiiiiii</tt> || 4 || 1
|-
| AND reg16, simm8 || <tt>83 /4 ii</tt> || <tt>10000011 11100mmm iiiiiiii</tt> || 3 || 1
|-
| AND reg8, mem8 || <tt>22 /r</tt> || <tt>00100010 oorrrmmm</tt> || 2+ || 2
|-
| AND reg16, mem16 || <tt>23 /r</tt> || <tt>00100011 oorrrmmm</tt> || 2+ || 2
|-
| AND reg8, reg8 || <tt>20 /r</tt> || <tt>001000.0 11rrrmmm</tt> || 2 || 1
|-
| AND reg16, reg16 || <tt>21 /r</tt> || <tt>001000.1 11rrrmmm</tt> || 2 || 1
|}
----
{{Anchor|BOUND}}
=== BOUND ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| BOUND reg16, mem16:16 || <tt>62 /r</tt> || <tt>01100010 oorrrmmm</tt> || 2+ || 13 (20 if condition met)
|}
----
{{Anchor|CALL}}
=== CALL ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| CALL ptr16:16 || <tt>CA oo oo ss ss</tt> || <tt>10011010 oooooooo oooooooo ssssssss ssssssss</tt> || 5 || 10
|-
| CALL mem16 || <tt>FF /2</tt> || <tt>11111111 oo010mmm</tt> || 2+ || 6
|-
| CALL mem16:16 || <tt>FF /3</tt> || <tt>11111111 oo011mmm</tt> || 2+ || 12
|-
| CALL reg16 || <tt>FF /2</tt> || <tt>11111111 11010mmm</tt> || 2 || 5
|-
| CALL rel16 || <tt>E8 ii ii</tt> || <tt>11101000 iiiiiiii iiiiiiii</tt> || 3 || 5
|}
----
{{Anchor|CBW}}
=== CBW ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| CBW || <tt>98</tt> || <tt>10011000</tt> || 1 || 1
|}
----
{{Anchor|CLC}}
=== CLC ===
{| class="wikitable"
! Flag !! New value
|-
| [[NEC_V30MZ_flags#CF|CF - Carry]] || 0
|}
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| CLC || <tt>F8</tt> || <tt>11111000</tt> || 1 || 4
|}
----
{{Anchor|CLD}}
=== CLD ===
{| class="wikitable"
! Flag !! New value
|-
| [[NEC_V30MZ_flags#DF|DF - Direction]] || 0
|}
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| CLD || <tt>FC</tt> || <tt>11111100</tt> || 1 || 4
|}
----
{{Anchor|CLI}}
=== CLI ===
{| class="wikitable"
! Flag !! New value
|-
| [[NEC_V30MZ_flags#IF|IF - Interrupt]] || 0
|}
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| CLI || <tt>FA</tt> || <tt>11111010</tt> || 1 || 4
|}
----
{{Anchor|CMC}}
=== CMC ===
{| class="wikitable"
! Flag !! New value
|-
| [[NEC_V30MZ_flags#CF|CF - Carry]] || !CF
|}
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| CMC || <tt>F5</tt> || <tt>11110101</tt> || 1 || 4
|}
----
{{Anchor|CMP}}
=== CMP ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| CMP AL, imm || <tt>3C ii</tt> || <tt>00111100 iiiiiiii</tt> || 2 || 1
|-
| CMP AX, imm || <tt>3D ii ii</tt> || <tt>00111101 iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| CMP mem8, imm8 || <tt>80 /7 ii</tt> || <tt>10000000 oo111mmm iiiiiiii</tt> || 3+ || 2
|-
| CMP mem16, imm16 || <tt>81 /7 ii ii</tt> || <tt>10000001 oo111mmm iiiiiiii iiiiiiii</tt> || 4+ || 2
|-
| CMP mem16, simm8 || <tt>83 /7 ii</tt> || <tt>10000011 oo111mmm iiiiiiii</tt> || 3+ || 2
|-
| CMP mem8, reg8 || <tt>38 /r</tt> || <tt>00111000 oorrrmmm</tt> || 2+ || 2
|-
| CMP mem16, reg16 || <tt>39 /r</tt> || <tt>00111001 oorrrmmm</tt> || 2+ || 2
|-
| CMP reg8, imm8 || <tt>80 /7 ii</tt> || <tt>10000000 11111mmm iiiiiiii</tt> || 3 || 1
|-
| CMP reg16, imm16 || <tt>81 /7 ii ii</tt> || <tt>10000001 11111mmm iiiiiiii iiiiiiii</tt> || 4 || 1
|-
| CMP reg16, simm8 || <tt>83 /7 ii</tt> || <tt>10000011 11111mmm iiiiiiii</tt> || 3 || 1
|-
| CMP reg8, mem8 || <tt>3A /r</tt> || <tt>00111010 oorrrmmm</tt> || 2+ || 2
|-
| CMP reg16, mem16 || <tt>3B /r</tt> || <tt>00111011 oorrrmmm</tt> || 2+ || 2
|-
| CMP reg8, reg8 || <tt>38 /r</tt> || <tt>001110.0 11rrrmmm</tt> || 2 || 1
|-
| CMP reg16, reg16 || <tt>39 /r</tt> || <tt>001110.1 11rrrmmm</tt> || 2 || 1
|}
----
{{Anchor|CMPSB}}
{{Anchor|CMPSW}}
=== CMPSB/CMPSW ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| CMPSB || <tt>A6</tt> || <tt>10100110</tt> || 1 || 6
|-
| CMPSW || <tt>A7</tt> || <tt>10100111</tt> || 1 || 6
|}
----
{{Anchor|CS}}
=== CS ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| CS || <tt>2E</tt> || <tt>00101110</tt> || 1 || 1
|}
----
{{Anchor|CWD}}
=== CWD ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| CWD || <tt>99</tt> || <tt>10011001</tt> || 1 || 1
|}
----
{{Anchor|DAA}}
=== DAA ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| DAA || <tt>27</tt> || <tt>00100111</tt> || 1 || 10
|}
----
{{Anchor|DAS}}
=== DAS ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| DAS || <tt>2F</tt> || <tt>00101111</tt> || 1 || 10
|}
----
{{Anchor|DEC}}
=== DEC ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| DEC mem8 || <tt>FE /1</tt> || <tt>11111110 oo001mmm</tt> || 2+ || 3
|-
| DEC mem16 || <tt>FF /1</tt> || <tt>11111111 oo001mmm</tt> || 2+ || 3
|-
| DEC reg8 || <tt>FE /1</tt> || <tt>11111110 11001mmm</tt> || 2+ || 1
|-
| DEC reg16 || <tt>4x</tt> || <tt>01001rrr</tt> || 1 || 1
|}
----
{{Anchor|DIV}}
=== DIV ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| DIV mem8 || <tt>F6 /6</tt> || <tt>11110110 oo110mmm</tt> || 2+ || 16
|-
| DIV mem16 || <tt>F7 /6</tt> || <tt>11111111 oo110mmm</tt> || 2+ || 24
|-
| DIV reg8 || <tt>F6 /6</tt> || <tt>11111110 11110mmm</tt> || 2 || 15
|-
| DIV reg16 || <tt>F7 /6</tt> || <tt>11111111 11110mmm</tt> || 2 || 23
|}
----
{{Anchor|DS}}
=== DS ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| DS || <tt>3E</tt> || <tt>00111110</tt> || 1 || 1
|}
----
{{Anchor|ENTER}}
=== ENTER ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| ENTER imm16, imm8 || <tt>C8 ii ii jj</tt> || <tt>11001000 iiiiiiii iiiiiiii jjjjjjjj</tt> || 3 || 8 (imm8 = 0)<br/>14 (imm8 = 1)<br/>15 + imm8 * 4 (imm8 >= 2)
|}
----
{{Anchor|ES}}
=== ES ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| ES || <tt>26</tt> || <tt>00100110</tt> || 1 || 1
|}
----
{{Anchor|HLT}}
=== HLT ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| HLT || <tt>F4</tt> || <tt>11110100</tt> || 1 || 9
|}
----
{{Anchor|IDIV}}
=== IDIV ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| IDIV mem8 || <tt>F6 /7</tt> || <tt>11110110 oo111mmm</tt> || 2+ || 18
|-
| IDIV mem16 || <tt>F7 /7</tt> || <tt>11111111 oo111mmm</tt> || 2+ || 25
|-
| IDIV reg8 || <tt>F6 /7</tt> || <tt>11111110 11111mmm</tt> || 2 || 17
|-
| IDIV reg16 || <tt>F7 /7</tt> || <tt>11111111 11111mmm</tt> || 2 || 24
|}
----
{{Anchor|IMUL}}
=== IMUL ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| IMUL mem8 || <tt>F6 /5</tt> || <tt>11110110 oo101mmm</tt> || 2+ || 4
|-
| IMUL mem16 || <tt>F7 /5</tt> || <tt>11111111 oo101mmm</tt> || 2+ || 4
|-
| IMUL reg8 || <tt>F6 /5</tt> || <tt>11111110 11101mmm</tt> || 2 || 3
|-
| IMUL reg16 || <tt>F7 /5</tt> || <tt>11111111 11101mmm</tt> || 2 || 3
|-
| IMUL reg16, mem16, imm16 || <tt>69 /r ii ii</tt> || <tt>11111111 oorrrmmm iiiiiiii iiiiiiii</tt> || 4 || 4
|-
| IMUL reg16, mem16, simm8 || <tt>6B /r ii</tt> || <tt>11111111 oorrrmmm iiiiiiii</tt> || 3 || 4
|-
| IMUL reg16, reg16, imm16 || <tt>69 /r ii ii</tt> || <tt>11111111 11rrrmmm iiiiiiii iiiiiiii</tt> || 4 || 3
|-
| IMUL reg16, reg16, simm8 || <tt>6B /r ii</tt> || <tt>11111111 11rrrmmm iiiiiiii</tt> || 3 || 3
|}
----
{{Anchor|IN}}
=== IN ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| IN AL, DX || <tt>EC</tt> || <tt>11101100</tt> || 1 || 6
|-
| IN AX, DX || <tt>ED</tt> || <tt>11101101</tt> || 1 || 6
|-
| IN AL, imm8 || <tt>E4 ii</tt> || <tt>11100100 iiiiiiii</tt> || 2 || 6
|-
| IN AX, imm8 || <tt>E5 ii</tt> || <tt>11100101 iiiiiiii</tt> || 2 || 6
|}
----
{{Anchor|INC}}
=== INC ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| INC mem8 || <tt>FE /0</tt> || <tt>11111110 oo000mmm</tt> || 2+ || 3
|-
| INC mem16 || <tt>FF /0</tt> || <tt>11111111 oo000mmm</tt> || 2+ || 3
|-
| INC reg8 || <tt>FE /0</tt> || <tt>11111110 11000mmm</tt> || 2+ || 1
|-
| INC reg16 || <tt>4x</tt> || <tt>01000rrr</tt> || 1 || 1
|}
----
{{Anchor|INSB}}
{{Anchor|INSW}}
=== INSB/INSW ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| INSB || <tt>6C</tt> || <tt>01101100</tt> || 1 || 6
|-
| INSW || <tt>6D</tt> || <tt>01101101</tt> || 1 || 6
|}
----
{{Anchor|INT}}
=== INT ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| INT 3 || <tt>CC</tt> || <tt>11001100</tt> || 1 || 9
|-
| INT imm8 || <tt>CD ii</tt> || <tt>11001101 iiiiiiii</tt> || 2 || 10
|}
----
{{Anchor|INTO}}
=== INTO ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| INTO || <tt>CE</tt> || <tt>11001110</tt> || 1 || 6 (13 if OF = 1)
|}
----
{{Anchor|IRET}}
=== IRET ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| IRET || <tt>CF</tt> || <tt>11001111</tt> || 1 || 10
|}
----
{{Anchor|JA}}
=== JA ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JA rel8 || <tt>77 ii</tt> || <tt>01110111 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JBE}}
=== JBE ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JA rel8 || <tt>76 ii</tt> || <tt>01110110 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JC}}
=== JC/JB ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JC rel8 || <tt>72 ii</tt> || <tt>01110010 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JCXZ}}
=== JCXZ ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JCXZ rel8 || <tt>E3 ii</tt> || <tt>11100011 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JG}}
=== JG ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JG rel8 || <tt>7F ii</tt> || <tt>01111111 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JGE}}
=== JGE ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JGE rel8 || <tt>7D ii</tt> || <tt>01111101 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JL}}
=== JL ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JL rel8 || <tt>7C ii</tt> || <tt>01111100 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JLE}}
=== JLE ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JLE rel8 || <tt>7E ii</tt> || <tt>01111110 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JMP}}
=== JMP ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JMP ptr16:16 || <tt>EA oo oo ss ss</tt> || <tt>11101010 oooooooo oooooooo ssssssss ssssssss</tt> || 5 || 7
|-
| JMP mem16 || <tt>FF /4</tt> || <tt>11111111 oo100mmm</tt> || 2+ || 5
|-
| JMP mem16:16 || <tt>FF /5</tt> || <tt>11111111 oo101mmm</tt> || 2+ || 10
|-
| JMP reg16 || <tt>FF /4</tt> || <tt>11111111 11100mmm</tt> || 2 || 4
|-
| JMP rel8 || <tt>EB ii</tt> || <tt>11101011 iiiiiiii</tt> || 2 || 4
|-
| JMP rel16 || <tt>E9 ii ii</tt> || <tt>11101001 iiiiiiii iiiiiiii</tt> || 3 || 4
|}
----
{{Anchor|JNC}}
=== JNC/JAE ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JNC rel8 || <tt>73 ii</tt> || <tt>01110011 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JNO}}
=== JNO ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JNO rel8 || <tt>71 ii</tt> || <tt>01110001 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JNP}}
=== JNP ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JNP rel8 || <tt>7B ii</tt> || <tt>01111011 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JNS}}
=== JNS ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JNS rel8 || <tt>79 ii</tt> || <tt>01111001 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JNZ}}
=== JNZ/JNE ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JNZ rel8 || <tt>75 ii</tt> || <tt>01110101 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JO}}
=== JO ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JO rel8 || <tt>70 ii</tt> || <tt>01110000 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JP}}
=== JP ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JP rel8 || <tt>7A ii</tt> || <tt>01111010 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JS}}
=== JS ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JS rel8 || <tt>78 ii</tt> || <tt>01111000 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JZ}}
=== JZ/JE ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JZ rel8 || <tt>74 ii</tt> || <tt>01110100 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|LAHF}}
=== LAHF ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| LAHF || <tt>9F</tt> || <tt>10011111</tt> || 1 || 2
|}
----
{{Anchor|LDS}}
=== LDS ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| LDS reg16, mem16 || <tt>C5 /r</tt> || <tt>11000101 oorrrmmm</tt> || 2+ || 6
|}
----
{{Anchor|LEA}}
=== LEA ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| LEA reg16, mem16 || <tt>8D /r</tt> || <tt>10001101 oorrrmmm</tt> || 2+ || 1
|}
----
{{Anchor|LEAVE}}
=== LEAVE ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| LEAVE || <tt>C9</tt> || <tt>11001001</tt> || 1 || 2
|}
----
{{Anchor|LES}}
=== LES ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| LES reg16, mem16 || <tt>C4 /r</tt> || <tt>11000100 oorrrmmm</tt> || 2+ || 6
|}
----
{{Anchor|LOCK}}
=== LOCK ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| LOCK || <tt>F0</tt> || <tt>11110000</tt> || 1 || 1
|}
----
{{Anchor|LODSB}}
{{Anchor|LODSW}}
=== LODSB/LODSW ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| LODSB || <tt>AC</tt> || <tt>10101100</tt> || 1 || 3
|-
| LODSW || <tt>AD</tt> || <tt>10101101</tt> || 1 || 3
|}
----
{{Anchor|LOOP}}
=== LOOP ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| LOOP rel8 || <tt>E2 ii</tt> || <tt>11100010 iiiiiiii</tt> || 2 || 2 (5 if branch taken)
|}
----
{{Anchor|LOOPE}}
=== LOOPE ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| LOOPE rel8 || <tt>E1 ii</tt> || <tt>11100001 iiiiiiii</tt> || 2 || 3 (6 if branch taken)
|}
----
{{Anchor|LOOPNE}}
=== LOOPNE ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| LOOPNE rel8 || <tt>E0 ii</tt> || <tt>11100000 iiiiiiii</tt> || 2 || 3 (6 if branch taken)
|}
----
{{Anchor|MOV}}
=== MOV ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| MOV AL, ptr16 || <tt>A0 ii ii</tt> || <tt>10100000 iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| MOV AX, ptr16 || <tt>A1 ii ii</tt> || <tt>10100001 iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| MOV mem8, imm8 || <tt>C6 /0 ii</tt> || <tt>11000110 oo000mmm iiiiiiii</tt> || 3+ || 1
|-
| MOV mem16, imm16 || <tt>C7 /0 ii ii</tt> || <tt>11000111 oo000mmm iiiiiiii iiiiiiii</tt> || 4+ || 1
|-
| MOV mem8, reg8 || <tt>84 /r</tt> || <tt>10001000 oorrrmmm</tt> || 2+ || 1
|-
| MOV mem16, reg16 || <tt>85 /r</tt> || <tt>10001001 oorrrmmm</tt> || 2+ || 1
|-
| MOV mem16, sreg16 || <tt>8C /r</tt> || <tt>10001100 oo0rrmmm</tt> || 2+ || 3
|-
| MOV ptr16, AL || <tt>A2 ii ii</tt> || <tt>10100010 iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| MOV ptr16, AX || <tt>A3 ii ii</tt> || <tt>10100011 iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| MOV reg8, imm8 || <tt>Bx ii</tt> || <tt>10110rrr iiiiiiii</tt> || 2 || 1
|-
| MOV reg8, imm8 || <tt>C6 /0 ii</tt> || <tt>11000110 11000mmm iiiiiiii</tt> || 3 || 1
|-
| MOV reg16, imm16 || <tt>Bx ii</tt> || <tt>10111rrr iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| MOV reg16, imm16 || <tt>C7 /0 ii ii</tt> || <tt>11000111 11000mmm iiiiiiii iiiiiiii</tt> || 4 || 1
|-
| MOV reg8, mem8 || <tt>8A /r</tt> || <tt>10001010 oorrrmmm</tt> || 2+ || 1
|-
| MOV reg16, mem16 || <tt>8B /r</tt> || <tt>10001011 oorrrmmm</tt> || 2+ || 1
|-
| MOV reg8, reg8 || <tt>88 /r</tt> || <tt>100010.0 11rrrmmm</tt> || 2 || 1
|-
| MOV reg16, reg16 || <tt>89 /r</tt> || <tt>100010.1 11rrrmmm</tt> || 2 || 1
|-
| MOV reg16, sreg16 || <tt>8C /r</tt> || <tt>10001100 110rrmmm</tt> || 2 || 1
|-
| MOV sreg16, mem16 || <tt>8E /r</tt> || <tt>10001110 oo0rrmmm</tt> || 2 || 3
|-
| MOV sreg16, reg16 || <tt>8E /r</tt> || <tt>10001110 110rrmmm</tt> || 2+ || 2
|}
----
{{Anchor|MOVSB}}
{{Anchor|MOVSW}}
=== MOVSB/MOVSW ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| MOVSB || <tt>A4</tt> || <tt>10100100</tt> || 1 || 5
|-
| MOVSW || <tt>A5</tt> || <tt>10100101</tt> || 1 || 5
|}
----
{{Anchor|MUL}}
=== MUL ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| MUL mem8 || <tt>F6 /4</tt> || <tt>11110110 oo100mmm</tt> || 2+ || 4
|-
| MUL mem16 || <tt>F7 /4</tt> || <tt>11111111 oo100mmm</tt> || 2+ || 4
|-
| MUL reg8 || <tt>F6 /4</tt> || <tt>11111110 11100mmm</tt> || 2 || 3
|-
| MUL reg16 || <tt>F7 /4</tt> || <tt>11111111 11100mmm</tt> || 2 || 3
|}
----
{{Anchor|NEG}}
=== NEG ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| NEG mem8 || <tt>F6 /3</tt> || <tt>11110110 oo011mmm</tt> || 2+ || 3
|-
| NEG mem16 || <tt>F7 /3</tt> || <tt>11111111 oo011mmm</tt> || 2+ || 3
|-
| NEG reg8 || <tt>F6 /3</tt> || <tt>11111110 11011mmm</tt> || 2 || 1
|-
| NEG reg16 || <tt>F7 /3</tt> || <tt>11111111 11011mmm</tt> || 2 || 1
|}
----
{{Anchor|NOP}}
=== NOP ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| NOP || <tt>90</tt> || <tt>10010000</tt> || 1 || 1
|}
----
{{Anchor|NOT}}
=== NOT ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| NOT mem8 || <tt>F6 /2</tt> || <tt>11110110 oo010mmm</tt> || 2+ || 3
|-
| NOT mem16 || <tt>F7 /2</tt> || <tt>11111111 oo010mmm</tt> || 2+ || 3
|-
| NOT reg8 || <tt>F6 /2</tt> || <tt>11111110 11010mmm</tt> || 2 || 1
|-
| NOT reg16 || <tt>F7 /2</tt> || <tt>11111111 11010mmm</tt> || 2 || 1
|}
----
{{Anchor|OR}}
=== OR ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| OR AL, imm || <tt>0C ii</tt> || <tt>00001100 iiiiiiii</tt> || 2 || 1
|-
| OR AX, imm || <tt>0D ii ii</tt> || <tt>00001101 iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| OR mem8, imm8 || <tt>80 /6 ii</tt> || <tt>10000000 oo001mmm iiiiiiii</tt> || 3+ || 3
|-
| OR mem16, imm16 || <tt>81 /6 ii ii</tt> || <tt>10000001 oo001mmm iiiiiiii iiiiiiii</tt> || 4+ || 3
|-
| OR mem16, simm8 || <tt>83 /6 ii</tt> || <tt>10000011 oo001mmm iiiiiiii</tt> || 3+ || 3
|-
| OR mem8, reg8 || <tt>08 /r</tt> || <tt>00001000 oorrrmmm</tt> || 2+ || 3
|-
| OR mem16, reg16 || <tt>09 /r</tt> || <tt>00001001 oorrrmmm</tt> || 2+ || 3
|-
| OR reg8, imm8 || <tt>80 /6 ii</tt> || <tt>10000000 11001mmm iiiiiiii</tt> || 3 || 1
|-
| OR reg16, imm16 || <tt>81 /6 ii ii</tt> || <tt>10000001 11001mmm iiiiiiii iiiiiiii</tt> || 4 || 1
|-
| OR reg16, simm8 || <tt>83 /6 ii</tt> || <tt>10000011 11001mmm iiiiiiii</tt> || 3 || 1
|-
| OR reg8, mem8 || <tt>0A /r</tt> || <tt>00001010 oorrrmmm</tt> || 2+ || 2
|-
| OR reg16, mem16 || <tt>0B /r</tt> || <tt>00001011 oorrrmmm</tt> || 2+ || 2
|-
| OR reg8, reg8 || <tt>08 /r</tt> || <tt>000010.0 11rrrmmm</tt> || 2 || 1
|-
| OR reg16, reg16 || <tt>09 /r</tt> || <tt>000010.1 11rrrmmm</tt> || 2 || 1
|}
----
{{Anchor|OUT}}
=== OUT ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| OUT AL, DX || <tt>EE</tt> || <tt>11101110</tt> || 1 || 6
|-
| OUT AX, DX || <tt>EF</tt> || <tt>11101111</tt> || 1 || 6
|-
| OUT AL, imm8 || <tt>E6 ii</tt> || <tt>11100110 iiiiiiii</tt> || 2 || 6
|-
| OUT AX, imm8 || <tt>E7 ii</tt> || <tt>11100111 iiiiiiii</tt> || 2 || 6
|}
----
{{Anchor|OUTSB}}
{{Anchor|OUTSW}}
=== OUTSB/OUTSW ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| OUTSB || <tt>6E</tt> || <tt>01101110</tt> || 1 || 6
|-
| OUTSW || <tt>6F</tt> || <tt>01101111</tt> || 1 || 6
|}
----
{{Anchor|POLL}}
=== POLL ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| POLL || <tt>6E</tt> || <tt>01101110</tt> || 1 || 9<ref>On the WonderSwan implementation, POLLB is always held low; on other implementations, POLL will wait for POLLB to be held low in 9-cycle intervals.</ref>
|}
----
{{Anchor|POP}}
=== POP ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| POP mem16 || <tt>8F /0</tt> || <tt>10001111 oo000mmm</tt> || 2+ || 3
|-
| POP reg16 || <tt>5x</tt> || <tt>01011xxx</tt> || 1 || 1
|-
| POP reg16 || <tt>8F /0</tt> || <tt>10001111 11000mmm</tt> || 2 || 1
|-
| POP sreg16 || <tt>xx</tt> || <tt>000xx111</tt> || 1 || 3
|}
----
{{Anchor|POPA}}
=== POPA ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| POPA || <tt>61</tt> || <tt>01100001</tt> || 1 || 8
|}
----
{{Anchor|POPF}}
=== POPF ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| POPF || <tt>9D</tt> || <tt>10011101</tt> || 1 || 3
|}
----
{{Anchor|PUSH}}
=== PUSH ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| PUSH imm8 || <tt>6A ii</tt> || <tt>01101010 iiiiiiii</tt> || 2 || 1
|-
| PUSH imm16 || <tt>68 ii ii</tt> || <tt>01101000 iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| PUSH mem16 || <tt>FF /6</tt> || <tt>11111111 oo110mmm</tt> || 2+ || 2
|-
| PUSH reg16 || <tt>5x</tt> || <tt>01010xxx</tt> || 1 || 1
|-
| PUSH reg16 || <tt>FF /6</tt> || <tt>11111111 11110mmm</tt> || 2 || 1
|-
| PUSH sreg16 || <tt>xx</tt> || <tt>000xx110</tt> || 1 || 2
|}
----
{{Anchor|PUSHA}}
=== PUSHA ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| PUSHA || <tt>60</tt> || <tt>01100000</tt> || 1 || 9
|}
----
{{Anchor|PUSHF}}
=== PUSHF ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| PUSHF || <tt>9C</tt> || <tt>10011100</tt> || 1 || 2
|}
----
{{Anchor|RCL}}
=== RCL ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| RCL mem8, 1 || <tt>D0 /2</tt> || <tt>11010000 oo010rm</tt> || 2+ || 3
|-
| RCL mem8, CL || <tt>D2 /2</tt> || <tt>11010010 oo010rm</tt> || 2+ || 5
|-
| RCL mem8, imm8 || <tt>C0 /2 ii</tt> || <tt>11000000 oo010mmm iiiiiiii</tt> || 3+ || 5
|-
| RCL mem16, 1 || <tt>D1 /2</tt> || <tt>11010001 oo010rm</tt> || 2+ || 3
|-
| RCL mem16, CL || <tt>D3 /2</tt> || <tt>11010011 oo010rm</tt> || 2+ || 5
|-
| RCL mem16, imm8 || <tt>C1 /2 ii</tt> || <tt>11000001 oo010mmm iiiiiiii</tt> || 3+ || 5
|-
| RCL reg8, 1 || <tt>D0 /2</tt> || <tt>11010000 11010rm</tt> || 2 || 1
|-
| RCL reg8, CL || <tt>D2 /2</tt> || <tt>11010010 11010rm</tt> || 2 || 3
|-
| RCL reg8, imm8 || <tt>C0 /2 ii</tt> || <tt>11000000 11010mmm iiiiiiii</tt> || 3 || 3
|-
| RCL reg16, 1 || <tt>D1 /2</tt> || <tt>11010001 11010rm</tt> || 2 || 1
|-
| RCL reg16, CL || <tt>D3 /2</tt> || <tt>11010011 11010rm</tt> || 2 || 3
|-
| RCL reg16, imm8 || <tt>C1 /2 ii</tt> || <tt>11000001 11010mmm iiiiiiii</tt> || 3 || 3
|}
----
{{Anchor|RCR}}
=== RCR ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| RCR mem8, 1 || <tt>D0 /3</tt> || <tt>11010000 oo011rm</tt> || 2+ || 3
|-
| RCR mem8, CL || <tt>D2 /3</tt> || <tt>11010010 oo011rm</tt> || 2+ || 5
|-
| RCR mem8, imm8 || <tt>C0 /3 ii</tt> || <tt>11000000 oo011mmm iiiiiiii</tt> || 3+ || 5
|-
| RCR mem16, 1 || <tt>D1 /3</tt> || <tt>11010001 oo011rm</tt> || 2+ || 3
|-
| RCR mem16, CL || <tt>D3 /3</tt> || <tt>11010011 oo011rm</tt> || 2+ || 5
|-
| RCR mem16, imm8 || <tt>C1 /3 ii</tt> || <tt>11000001 oo011mmm iiiiiiii</tt> || 3+ || 5
|-
| RCR reg8, 1 || <tt>D0 /3</tt> || <tt>11010000 11011rm</tt> || 2 || 1
|-
| RCR reg8, CL || <tt>D2 /3</tt> || <tt>11010010 11011rm</tt> || 2 || 3
|-
| RCR reg8, imm8 || <tt>C0 /3 ii</tt> || <tt>11000000 11011mmm iiiiiiii</tt> || 3 || 3
|-
| RCR reg16, 1 || <tt>D1 /3</tt> || <tt>11010001 11011rm</tt> || 2 || 1
|-
| RCR reg16, CL || <tt>D3 /3</tt> || <tt>11010011 11011rm</tt> || 2 || 3
|-
| RCR reg16, imm8 || <tt>C1 /3 ii</tt> || <tt>11000001 11011mmm iiiiiiii</tt> || 3 || 3
|}
----
{{Anchor|REP}}
=== REP/REPE/REPZ ===
----
{{Anchor|REPNE}}
=== REPNE/REPNZ ===
----
{{Anchor|RET}}
=== RET ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| RET || <tt>C3</tt> || <tt>11000011</tt> || 1 || 6
|-
| RET imm16 || <tt>C2 ii ii</tt> || <tt>11000010 iiiiiiii iiiiiiii</tt> || 1 || 6
|}
----
{{Anchor|RETF}}
=== RETF ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| RETF || <tt>CB</tt> || <tt>11001011</tt> || 1 || 8
|-
| RETF imm16 || <tt>CA ii ii</tt> || <tt>11001010 iiiiiiii iiiiiiii</tt> || 1 || 9
|}
----
{{Anchor|ROL}}
=== ROL ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| ROL mem8, 1 || <tt>D0 /0</tt> || <tt>11010000 oo000rm</tt> || 2+ || 3
|-
| ROL mem8, CL || <tt>D2 /0</tt> || <tt>11010010 oo000rm</tt> || 2+ || 5
|-
| ROL mem8, imm8 || <tt>C0 /0 ii</tt> || <tt>11000000 oo000mmm iiiiiiii</tt> || 3+ || 5
|-
| ROL mem16, 1 || <tt>D1 /0</tt> || <tt>11010001 oo000rm</tt> || 2+ || 3
|-
| ROL mem16, CL || <tt>D3 /0</tt> || <tt>11010011 oo000rm</tt> || 2+ || 5
|-
| ROL mem16, imm8 || <tt>C1 /0 ii</tt> || <tt>11000001 oo000mmm iiiiiiii</tt> || 3+ || 5
|-
| ROL reg8, 1 || <tt>D0 /0</tt> || <tt>11010000 11000rm</tt> || 2 || 1
|-
| ROL reg8, CL || <tt>D2 /0</tt> || <tt>11010010 11000rm</tt> || 2 || 3
|-
| ROL reg8, imm8 || <tt>C0 /0 ii</tt> || <tt>11000000 11000mmm iiiiiiii</tt> || 3 || 3
|-
| ROL reg16, 1 || <tt>D1 /0</tt> || <tt>11010001 11000rm</tt> || 2 || 1
|-
| ROL reg16, CL || <tt>D3 /0</tt> || <tt>11010011 11000rm</tt> || 2 || 3
|-
| ROL reg16, imm8 || <tt>C1 /0 ii</tt> || <tt>11000001 11000mmm iiiiiiii</tt> || 3 || 3
|}
----
{{Anchor|ROR}}
=== ROR ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| ROR mem8, 1 || <tt>D0 /1</tt> || <tt>11010000 oo001rm</tt> || 2+ || 3
|-
| ROR mem8, CL || <tt>D2 /1</tt> || <tt>11010010 oo001rm</tt> || 2+ || 5
|-
| ROR mem8, imm8 || <tt>C0 /1 ii</tt> || <tt>11000000 oo001mmm iiiiiiii</tt> || 3+ || 5
|-
| ROR mem16, 1 || <tt>D1 /1</tt> || <tt>11010001 oo001rm</tt> || 2+ || 3
|-
| ROR mem16, CL || <tt>D3 /1</tt> || <tt>11010011 oo001rm</tt> || 2+ || 5
|-
| ROR mem16, imm8 || <tt>C1 /1 ii</tt> || <tt>11000001 oo001mmm iiiiiiii</tt> || 3+ || 5
|-
| ROR reg8, 1 || <tt>D0 /1</tt> || <tt>11010000 11001rm</tt> || 2 || 1
|-
| ROR reg8, CL || <tt>D2 /1</tt> || <tt>11010010 11001rm</tt> || 2 || 3
|-
| ROR reg8, imm8 || <tt>C0 /1 ii</tt> || <tt>11000000 11001mmm iiiiiiii</tt> || 3 || 3
|-
| ROR reg16, 1 || <tt>D1 /1</tt> || <tt>11010001 11001rm</tt> || 2 || 1
|-
| ROR reg16, CL || <tt>D3 /1</tt> || <tt>11010011 11001rm</tt> || 2 || 3
|-
| ROR reg16, imm8 || <tt>C1 /1 ii</tt> || <tt>11000001 11001mmm iiiiiiii</tt> || 3 || 3
|}
----
{{Anchor|SAHF}}
=== SAHF ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| SAHF || <tt>9E</tt> || <tt>10011110</tt> || 1 || 4
|}
----
{{Anchor|SAR}}
=== SAR ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| SAR mem8, 1 || <tt>D0 /7</tt> || <tt>11010000 oo111rm</tt> || 2+ || 3
|-
| SAR mem8, CL || <tt>D2 /7</tt> || <tt>11010010 oo111rm</tt> || 2+ || 5
|-
| SAR mem8, imm8 || <tt>C0 /7 ii</tt> || <tt>11000000 oo111mmm iiiiiiii</tt> || 3+ || 5
|-
| SAR mem16, 1 || <tt>D1 /7</tt> || <tt>11010001 oo111rm</tt> || 2+ || 3
|-
| SAR mem16, CL || <tt>D3 /7</tt> || <tt>11010011 oo111rm</tt> || 2+ || 5
|-
| SAR mem16, imm8 || <tt>C1 /7 ii</tt> || <tt>11000001 oo111mmm iiiiiiii</tt> || 3+ || 5
|-
| SAR reg8, 1 || <tt>D0 /7</tt> || <tt>11010000 11111rm</tt> || 2 || 1
|-
| SAR reg8, CL || <tt>D2 /7</tt> || <tt>11010010 11111rm</tt> || 2 || 3
|-
| SAR reg8, imm8 || <tt>C0 /7 ii</tt> || <tt>11000000 11111mmm iiiiiiii</tt> || 3 || 3
|-
| SAR reg16, 1 || <tt>D1 /7</tt> || <tt>11010001 11111rm</tt> || 2 || 1
|-
| SAR reg16, CL || <tt>D3 /7</tt> || <tt>11010011 11111rm</tt> || 2 || 3
|-
| SAR reg16, imm8 || <tt>C1 /7 ii</tt> || <tt>11000001 11111mmm iiiiiiii</tt> || 3 || 3
|}
----
{{Anchor|SBB}}
=== SBB ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| SBB AL, imm || <tt>1C ii</tt> || <tt>00011100 iiiiiiii</tt> || 2 || 1
|-
| SBB AX, imm || <tt>1D ii ii</tt> || <tt>00011101 iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| SBB mem8, imm8 || <tt>80 /3 ii</tt> || <tt>10000000 oo011mmm iiiiiiii</tt> || 3+ || 3
|-
| SBB mem16, imm16 || <tt>81 /3 ii ii</tt> || <tt>10000001 oo011mmm iiiiiiii iiiiiiii</tt> || 4+ || 3
|-
| SBB mem16, simm8 || <tt>83 /3 ii</tt> || <tt>10000011 oo011mmm iiiiiiii</tt> || 3+ || 3
|-
| SBB mem8, reg8 || <tt>18 /r</tt> || <tt>00011000 oorrrmmm</tt> || 2+ || 3
|-
| SBB mem16, reg16 || <tt>19 /r</tt> || <tt>00011001 oorrrmmm</tt> || 2+ || 3
|-
| SBB reg8, imm8 || <tt>80 /3 ii</tt> || <tt>10000000 11011mmm iiiiiiii</tt> || 3 || 1
|-
| SBB reg16, imm16 || <tt>81 /3 ii ii</tt> || <tt>10000001 11011mmm iiiiiiii iiiiiiii</tt> || 4 || 1
|-
| SBB reg16, simm8 || <tt>83 /3 ii</tt> || <tt>10000011 11011mmm iiiiiiii</tt> || 3 || 1
|-
| SBB reg8, mem8 || <tt>1A /r</tt> || <tt>00011010 oorrrmmm</tt> || 2+ || 2
|-
| SBB reg16, mem16 || <tt>1B /r</tt> || <tt>00011011 oorrrmmm</tt> || 2+ || 2
|-
| SBB reg8, reg8 || <tt>18 /r</tt> || <tt>000110.0 11rrrmmm</tt> || 2 || 1
|-
| SBB reg16, reg16 || <tt>19 /r</tt> || <tt>000110.1 11rrrmmm</tt> || 2 || 1
|}
----
{{Anchor|SCASB}}
{{Anchor|SCASW}}
=== SCASB/SCASW ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| SCASB || <tt>AE</tt> || <tt>10101110</tt> || 1 || 4
|-
| SCASW || <tt>AF</tt> || <tt>10101111</tt> || 1 || 4
|}
----
{{Anchor|SHL}}
=== SHL ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| SHL mem8, 1 || <tt>D0 /4</tt> || <tt>11010000 oo100rm</tt> || 2+ || 3
|-
| SHL mem8, CL || <tt>D2 /4</tt> || <tt>11010010 oo100rm</tt> || 2+ || 5
|-
| SHL mem8, imm8 || <tt>C0 /4 ii</tt> || <tt>11000000 oo100mmm iiiiiiii</tt> || 3+ || 5
|-
| SHL mem16, 1 || <tt>D1 /4</tt> || <tt>11010001 oo100rm</tt> || 2+ || 3
|-
| SHL mem16, CL || <tt>D3 /4</tt> || <tt>11010011 oo100rm</tt> || 2+ || 5
|-
| SHL mem16, imm8 || <tt>C1 /4 ii</tt> || <tt>11000001 oo100mmm iiiiiiii</tt> || 3+ || 5
|-
| SHL reg8, 1 || <tt>D0 /4</tt> || <tt>11010000 11100rm</tt> || 2 || 1
|-
| SHL reg8, CL || <tt>D2 /4</tt> || <tt>11010010 11100rm</tt> || 2 || 3
|-
| SHL reg8, imm8 || <tt>C0 /4 ii</tt> || <tt>11000000 11100mmm iiiiiiii</tt> || 3 || 3
|-
| SHL reg16, 1 || <tt>D1 /4</tt> || <tt>11010001 11100rm</tt> || 2 || 1
|-
| SHL reg16, CL || <tt>D3 /4</tt> || <tt>11010011 11100rm</tt> || 2 || 3
|-
| SHL reg16, imm8 || <tt>C1 /4 ii</tt> || <tt>11000001 11100mmm iiiiiiii</tt> || 3 || 3
|}
----
{{Anchor|SHR}}
=== SHR ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| SHR mem8, 1 || <tt>D0 /5</tt> || <tt>11010000 oo101rm</tt> || 2+ || 3
|-
| SHR mem8, CL || <tt>D2 /5</tt> || <tt>11010010 oo101rm</tt> || 2+ || 5
|-
| SHR mem8, imm8 || <tt>C0 /5 ii</tt> || <tt>11000000 oo101mmm iiiiiiii</tt> || 3+ || 5
|-
| SHR mem16, 1 || <tt>D1 /5</tt> || <tt>11010001 oo101rm</tt> || 2+ || 3
|-
| SHR mem16, CL || <tt>D3 /5</tt> || <tt>11010011 oo101rm</tt> || 2+ || 5
|-
| SHR mem16, imm8 || <tt>C1 /5 ii</tt> || <tt>11000001 oo101mmm iiiiiiii</tt> || 3+ || 5
|-
| SHR reg8, 1 || <tt>D0 /5</tt> || <tt>11010000 11101rm</tt> || 2 || 1
|-
| SHR reg8, CL || <tt>D2 /5</tt> || <tt>11010010 11101rm</tt> || 2 || 3
|-
| SHR reg8, imm8 || <tt>C0 /5 ii</tt> || <tt>11000000 11101mmm iiiiiiii</tt> || 3 || 3
|-
| SHR reg16, 1 || <tt>D1 /5</tt> || <tt>11010001 11101rm</tt> || 2 || 1
|-
| SHR reg16, CL || <tt>D3 /5</tt> || <tt>11010011 11101rm</tt> || 2 || 3
|-
| SHR reg16, imm8 || <tt>C1 /5 ii</tt> || <tt>11000001 11101mmm iiiiiiii</tt> || 3 || 3
|}
----
{{Anchor|SS}}
=== SS ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| SS || <tt>36</tt> || <tt>00110110</tt> || 1 || 1
|}
----
{{Anchor|STC}}
=== STC ===
{| class="wikitable"
! Flag !! New value
|-
| [[NEC_V30MZ_flags#CF|CF - Carry]] || 1
|}
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| STC || <tt>F9</tt> || <tt>11111001</tt> || 1 || 4
|}
----
{{Anchor|STD}}
=== STD ===
{| class="wikitable"
! Flag !! New value
|-
| [[NEC_V30MZ_flags#DF|DF - Direction]] || 1
|}
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| STD || <tt>FD</tt> || <tt>11111101</tt> || 1 || 4
|}
----
{{Anchor|STI}}
=== STI ===
{| class="wikitable"
! Flag !! New value
|-
| [[NEC_V30MZ_flags#IF|IF - Interrupt]] || 1
|}
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| STI || <tt>FB</tt> || <tt>11111011</tt> || 1 || 4
|}
----
{{Anchor|STOSB}}
{{Anchor|STOSW}}
=== STOSB/STOSW ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| STOSB || <tt>AA</tt> || <tt>10101010</tt> || 1 || 3
|-
| STOSW || <tt>AB</tt> || <tt>10101011</tt> || 1 || 3
|}
----
{{Anchor|SUB}}
=== SUB ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| SUB AL, imm || <tt>28 ii</tt> || <tt>00101100 iiiiiiii</tt> || 2 || 1
|-
| SUB AX, imm || <tt>29 ii ii</tt> || <tt>00101101 iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| SUB mem8, imm8 || <tt>80 /5 ii</tt> || <tt>10000000 oo101mmm iiiiiiii</tt> || 3+ || 3
|-
| SUB mem16, imm16 || <tt>81 /5 ii ii</tt> || <tt>10000001 oo101mmm iiiiiiii iiiiiiii</tt> || 4+ || 3
|-
| SUB mem16, simm8 || <tt>83 /5 ii</tt> || <tt>10000011 oo101mmm iiiiiiii</tt> || 3+ || 3
|-
| SUB mem8, reg8 || <tt>28 /r</tt> || <tt>00101000 oorrrmmm</tt> || 2+ || 3
|-
| SUB mem16, reg16 || <tt>29 /r</tt> || <tt>00101001 oorrrmmm</tt> || 2+ || 3
|-
| SUB reg8, imm8 || <tt>80 /5 ii</tt> || <tt>10000000 11101mmm iiiiiiii</tt> || 3 || 1
|-
| SUB reg16, imm16 || <tt>81 /5 ii ii</tt> || <tt>10000001 11101mmm iiiiiiii iiiiiiii</tt> || 4 || 1
|-
| SUB reg16, simm8 || <tt>83 /5 ii</tt> || <tt>10000011 11101mmm iiiiiiii</tt> || 3 || 1
|-
| SUB reg8, mem8 || <tt>2A /r</tt> || <tt>00101010 oorrrmmm</tt> || 2+ || 2
|-
| SUB reg16, mem16 || <tt>2B /r</tt> || <tt>00101011 oorrrmmm</tt> || 2+ || 2
|-
| SUB reg8, reg8 || <tt>28 /r</tt> || <tt>001010.0 11rrrmmm</tt> || 2 || 1
|-
| SUB reg16, reg16 || <tt>29 /r</tt> || <tt>001010.1 11rrrmmm</tt> || 2 || 1
|}
----
{{Anchor|TEST}}
=== TEST ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| TEST AL, imm || <tt>A8 ii</tt> || <tt>10101000 iiiiiiii</tt> || 2 || 1
|-
| TEST AX, imm || <tt>A9 ii ii</tt> || <tt>10101001 iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| TEST mem8, imm8 || <tt>F6 /0 ii</tt> || <tt>11110110 oo000mmm iiiiiiii</tt> || 3+ || 2
|-
| TEST mem16, imm16 || <tt>F7 /0 ii ii</tt> || <tt>11110111 oo000mmm iiiiiiii iiiiiiii</tt> || 4+ || 2
|-
| TEST mem8, reg8<br/>TEST reg8, mem8 || <tt>84 /r</tt> || <tt>10000100 oorrrmmm</tt> || 2+ || 2
|-
| TEST mem16, reg16<br/>TEST reg16, mem16 || <tt>85 /r</tt> || <tt>10000101 oorrrmmm</tt> || 2+ || 2
|-
| TEST reg8, imm8 || <tt>F6 /0 ii</tt> || <tt>11110110 11000mmm iiiiiiii</tt> || 3 || 1
|-
| TEST reg16, imm16 || <tt>F7 /0 ii ii</tt> || <tt>11110111 11000mmm iiiiiiii iiiiiiii</tt> || 4 || 1
|-
| TEST reg8, reg8 || <tt>84 /r</tt> || <tt>10000100 11rrrmmm</tt> || 2 || 1
|-
| TEST reg16, reg16 || <tt>85 /r</tt> || <tt>10000101 11rrrmmm</tt> || 2 || 1
|}
----
{{Anchor|XCHG}}
=== XCHG ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| XCHG AX, reg16<br/>XCHG reg16, AX || <tt>9x</tt> || <tt>10010rrr</tt> || 1 || 3
|-
| XCHG mem8, reg8<br/>XCHG reg8, mem8 || <tt>86 /r</tt> || <tt>10000110 oorrrmmm</tt> || 2+ || 5
|-
| XCHG mem16, reg16<br/>XCHG reg16, mem16 || <tt>87 /r</tt> || <tt>10000111 oorrrmmm</tt> || 2+ || 5
|-
| XCHG reg8, reg8 || <tt>86 /r</tt> || <tt>10000110 11rrrmmm</tt> || 2+ || 3
|-
| XCHG reg16, reg16 || <tt>87 /r</tt> || <tt>10000111 11rrrmmm</tt> || 2+ || 3
|}
----
{{Anchor|XLAT}}
=== XLAT ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| XLAT || <tt>D7</tt> || <tt>11010111</tt> || 1 || 5
|}
----
{{Anchor|XOR}}
=== XOR ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| XOR AL, imm || <tt>34 ii</tt> || <tt>00110100 iiiiiiii</tt> || 2 || 1
|-
| XOR AX, imm || <tt>35 ii ii</tt> || <tt>00110101 iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| XOR mem8, imm8 || <tt>80 /6 ii</tt> || <tt>10000000 oo110mmm iiiiiiii</tt> || 3+ || 3
|-
| XOR mem16, imm16 || <tt>81 /6 ii ii</tt> || <tt>10000001 oo110mmm iiiiiiii iiiiiiii</tt> || 4+ || 3
|-
| XOR mem16, simm8 || <tt>83 /6 ii</tt> || <tt>10000011 oo110mmm iiiiiiii</tt> || 3+ || 3
|-
| XOR mem8, reg8 || <tt>30 /r</tt> || <tt>00110000 oorrrmmm</tt> || 2+ || 3
|-
| XOR mem16, reg16 || <tt>31 /r</tt> || <tt>00110001 oorrrmmm</tt> || 2+ || 3
|-
| XOR reg8, imm8 || <tt>80 /6 ii</tt> || <tt>10000000 11110mmm iiiiiiii</tt> || 3 || 1
|-
| XOR reg16, imm16 || <tt>81 /6 ii ii</tt> || <tt>10000001 11110mmm iiiiiiii iiiiiiii</tt> || 4 || 1
|-
| XOR reg16, simm8 || <tt>83 /6 ii</tt> || <tt>10000011 11110mmm iiiiiiii</tt> || 3 || 1
|-
| XOR reg8, mem8 || <tt>32 /r</tt> || <tt>00110010 oorrrmmm</tt> || 2+ || 2
|-
| XOR reg16, mem16 || <tt>33 /r</tt> || <tt>00110011 oorrrmmm</tt> || 2+ || 2
|-
| XOR reg8, reg8 || <tt>30 /r</tt> || <tt>001100.0 11rrrmmm</tt> || 2 || 1
|-
| XOR reg16, reg16 || <tt>31 /r</tt> || <tt>001100.1 11rrrmmm</tt> || 2 || 1
|}
== Notes ==
<references />
e5146544a960b0bb55423ba9858cf830f1112b3a
542
541
2025-02-24T18:32:46Z
Asie
351
/* PUSH */ use simm8
wikitext
text/x-wiki
__NOTOC__
Note that this page is a work in progress.
{| class="wikitable" style="text-align: center"
|+ Official V30MZ (80186) Instructions
|-
| [[#AAA|AAA]] || [[#AAD|AAD]] || [[#AAM|AAM]] || [[#AAS|AAS]] || [[#ADC|ADC]] || [[#ADD|ADD]] || [[#AND|AND]] || [[#BOUND|BOUND]] || [[#CALL|CALL]] || [[#CBW|CBW]] || [[#CLC|CLC]]
|-
| [[#CLD|CLD]] || [[#CLI|CLI]] || [[#CMC|CMC]] || [[#CMP|CMP]] || [[#CMPSB|CMPSB]] || [[#CMPSW|CMPSW]] || [[#CS|CS]] || [[#CWD|CWD]] || [[#DAA|DAA]] || [[#DAS|DAS]] || [[#DEC|DEC]]
|-
| [[#DIV|DIV]] || [[#DS|DS]] || [[#ENTER|ENTER]] || [[#ES|ES]] || [[#HLT|HLT]] || [[#IDIV|IDIV]] || [[#IMUL|IMUL]] || [[#IN|IN]] || [[#INC|INC]] || [[#INSB|INSB]] || [[#INSW|INSW]]
|-
| [[#INT|INT]] || [[#INTO|INTO]] || [[#IRET|IRET]] || [[#JA|JA]] || [[#JBE|JBE]] || [[#JC|JC]] || [[#JCXZ|JCXZ]] || [[#JG|JG]] || [[#JGE|JGE]] || [[#JL|JL]] || [[#JLE|JLE]]
|-
| [[#JMP|JMP]] || [[#JNC|JNC]] || [[#JNO|JNO]] || [[#JNP|JNP]] || [[#JNS|JNS]] || [[#JNZ|JNZ]] || [[#JO|JO]] || [[#JP|JP]] || [[#JS|JS]] || [[#JZ|JZ]] || [[#LAHF|LAHF]]
|-
| [[#LDS|LDS]] || [[#LEA|LEA]] || [[#LEAVE|LEAVE]] || [[#LES|LES]] || [[#LOCK|LOCK]] || [[#LODSB|LODSB]] || [[#LODSW|LODSW]] || [[#LOOP|LOOP]] || [[#LOOPE|LOOPE]] || [[#LOOPNE|LOOPNE]] || [[#MOV|MOV]]
|-
| [[#MOVSB|MOVSB]] || [[#MOVSW|MOVSW]] || [[#MUL|MUL]] || [[#NEG|NEG]] || [[#NOP|NOP]] || [[#NOT|NOT]] || [[#OR|OR]] || [[#OUT|OUT]] || [[#OUTSB|OUTSB]] || [[#OUTSW|OUTSW]] || [[#POLL|POLL]]
|-
| [[#POP|POP]] || [[#POPA|POPA]] || [[#POPF|POPF]] || [[#PUSH|PUSH]] || [[#PUSHA|PUSHA]] || [[#PUSHF|PUSHF]] || [[#RCL|RCL]] || [[#RCR|RCR]] || [[#REP|REP]] || [[#REPNE|REPNE]] || [[#RET|RET]]
|-
| [[#RETF|RETF]] || [[#ROL|ROL]] || [[#ROR|ROR]] || [[#SAHF|SAHF]] || [[#SAR|SAR]] || [[#SBB|SBB]] || [[#SCASB|SCASB]] || [[#SCASW|SCASW]] || [[#SHL|SHL]] || [[#SHR|SHR]] || [[#SS|SS]]
|-
| [[#STC|STC]] || [[#STD|STD]] || [[#STI|STI]] || [[#STOSB|STOSB]] || [[#STOSW|STOSW]] || [[#SUB|SUB]] || [[#TEST|TEST]] || [[#XCHG|XCHG]] || [[#XLAT|XLAT]] || [[#XOR|XOR]]
|}
{| class="mw-collapsible mw-collapsed wikitable sortable" style="width: 340px;"
|+ style="white-space:nowrap; border:1px solid; padding:3px; border-color:rgb(162, 169, 177); background-color:rgb(234, 236, 240);" | Intel <-> NEC mnemonic translation table
!Intel
!NEC
|-
| [[#AAA|AAA]]
| [[#AAA|ADJBA]]
|-
| [[#AAD|AAD]]
| [[#AAD|CVTDB]]
|-
| [[#AAM|AAM]]
| [[#AAM|CVTBD]]
|-
| [[#AAS|AAS]]
| [[#AAS|ADJBS]]
|-
| [[#ADC|ADC]]
| [[#ADC|ADDC]]
|-
| [[#ADD|ADD]]
| [[#ADD|ADD]]
|-
| [[#AND|AND]]
| [[#AND|AND]]
|-
| [[#BOUND|BOUND]]
| [[#BOUND|CHKIND]]
|-
| [[#CALL|CALL]]
| [[#CALL|CALL]]
|-
| [[#CBW|CBW]]
| [[#CBW|CVTBW]]
|-
| [[#CLC|CLC]]
| [[#CLC|CLR1 CY]]
|-
| [[#CLD|CLD]]
| [[#CLD|CLR1 DIR]]
|-
| [[#CLI|CLI]]
| [[#CLI|DI]]
|-
| [[#CMC|CMC]]
| [[#CMC|NOT1 CY]]
|-
| [[#CMP|CMP]]
| [[#CMP|CMP]]
|-
| [[#CMPSB|CMPSB]]
| [[#CMPSB|CMPBKB]]
|-
| [[#CMPSW|CMPSW]]
| [[#CMPSW|CMPBKW]]
|-
| [[#CS|CS]]
| [[#CS|PS]]
|-
| [[#CWD|CWD]]
| [[#CWD|CVTWL]]
|-
| [[#DAA|DAA]]
| [[#DAA|ADJ4A]]
|-
| [[#DAS|DAS]]
| [[#DAS|ADJ4S]]
|-
| [[#DEC|DEC]]
| [[#DEC|DEC]]
|-
| [[#DIV|DIV]]
| [[#DIV|DIVU]]
|-
| [[#DS|DS]]
| [[#DS|DS0]]
|-
| [[#ENTER|ENTER]]
| [[#ENTER|PREPARE]]
|-
| [[#ES|ES]]
| [[#ES|DS1]]
|-
| [[#HLT|HLT]]
| [[#HLT|HALT]]
|-
| [[#IDIV|IDIV]]
| [[#IDIV|DIV]]
|-
| [[#IMUL|IMUL]]
| [[#IMUL|MUL]]
|-
| [[#IN|IN]]
| [[#IN|IN]]
|-
| [[#INC|INC]]
| [[#INC|INC]]
|-
| [[#INSB|INSB]]
| [[#INSB|INMB]]
|-
| [[#INSW|INSW]]
| [[#INSW|INMW]]
|-
| [[#INT|INT]]
| [[#INT|BRK]]
|-
| [[#INTO|INTO]]
| [[#INTO|BRKV]]
|-
| [[#IRET|IRET]]
| [[#IRET|RETI]]
|-
| [[#JA|JA]]
| [[#JA|BH]]
|-
| [[#JBE|JBE]]
| [[#JBE|BNH]]
|-
| [[#JC|JC/JB]]
| [[#JC|BC/BL]]
|-
| [[#JCXZ|JCXZ]]
| [[#JCXZ|BCWZ]]
|-
| [[#JG|JG]]
| [[#JG|BGT]]
|-
| [[#JGE|JGE]]
| [[#JGE|BGE]]
|-
| [[#JL|JL]]
| [[#JL|BLT]]
|-
| [[#JLE|JLE]]
| [[#JLE|BLE]]
|-
| [[#JMP|JMP]]
| [[#JMP|BR]]
|-
| [[#JNC|JNC/JAE]]
| [[#JNC|BNC/BNL]]
|-
| [[#JNO|JNO]]
| [[#JNO|BNV]]
|-
| [[#JNP|JNP]]
| [[#JNP|BPO]]
|-
| [[#JNS|JNS]]
| [[#JNS|BP]]
|-
| [[#JNZ|JNZ/JNE]]
| [[#JNZ|BNZ/BNE]]
|-
| [[#JO|JO]]
| [[#JO|BV]]
|-
| [[#JP|JP]]
| [[#JP|BPE]]
|-
| [[#JS|JS]]
| [[#JS|BN]]
|-
| [[#JZ|JZ/JE]]
| [[#JZ|BZ/BE]]
|-
| [[#LAHF|LAHF]]
| [[#LAHF|MOV]]
|-
| [[#LDS|LDS]]
| [[#LDS|MOV]]
|-
| [[#LEA|LEA]]
| [[#LEA|LDEA]]
|-
| [[#LEAVE|LEAVE]]
| [[#LEAVE|DISPOSE]]
|-
| [[#LES|LES]]
| [[#LES|MOV]]
|-
| [[#LOCK|LOCK]]
| [[#LOCK|BUSLOCK]]
|-
| [[#LODSB|LODSB]]
| [[#LODSB|LDMB]]
|-
| [[#LODSW|LODSW]]
| [[#LODSW|LDMW]]
|-
| [[#LOOP|LOOP]]
| [[#LOOP|DBNZ]]
|-
| [[#LOOPE|LOOPE]]
| [[#LOOPE|DBNZE]]
|-
| [[#LOOPNE|LOOPNE]]
| [[#LOOPNE|DBNZNE]]
|-
| [[#MOV|MOV]]
| [[#MOV|MOV]]
|-
| [[#MOVSB|MOVSB]]
| [[#MOVSB|MOVBKB]]
|-
| [[#MOVSW|MOVSW]]
| [[#MOVSW|MOVBKW]]
|-
| [[#MUL|MUL]]
| [[#MUL|MULU]]
|-
| [[#NEG|NEG]]
| [[#NEG|NEG]]
|-
| [[#NOP|NOP]]
| [[#NOP|NOP]]
|-
| [[#NOT|NOT]]
| [[#NOT|NOT]]
|-
| [[#OR|OR]]
| [[#OR|OR]]
|-
| [[#OUT|OUT]]
| [[#OUT|OUT]]
|-
| [[#OUTSB|OUTSB]]
| [[#OUTSB|OUTM]]
|-
| [[#OUTSW|OUTSW]]
| [[#OUTSW|OUTM]]
|-
| [[#POLL|POLL]]
| [[#POLL|POLL]]
|-
| [[#POP|POP]]
| [[#POP|POP]]
|-
| [[#POPA|POPA]]
| [[#POPA|POP]]
|-
| [[#POPF|POPF]]
| [[#POPF|POP]]
|-
| [[#PUSH|PUSH]]
| [[#PUSH|PUSH]]
|-
| [[#PUSHA|PUSHA]]
| [[#PUSHA|PUSH]]
|-
| [[#PUSHF|PUSHF]]
| [[#PUSHF|PUSH]]
|-
| [[#RCL|RCL]]
| [[#RCL|ROLC]]
|-
| [[#RCR|RCR]]
| [[#RCR|RORC]]
|-
| [[#REP|REP/REPE/REPZ]]
| [[#REP|REP/REPE/REPZ]]
|-
| [[#REPNE|REPNE/REPNZ]]
| [[#REPNE|REPNE/REPNZ]]
|-
| [[#RET|RET]]
| [[#RET|RET]]
|-
| [[#RETF|RETF]]
| [[#RETF|RET]]
|-
| [[#ROL|ROL]]
| [[#ROL|ROL]]
|-
| [[#ROR|ROR]]
| [[#ROR|ROR]]
|-
| [[#SAHF|SAHF]]
| [[#SAHF|MOV]]
|-
| [[#SAR|SAR]]
| [[#SAR|SHRA]]
|-
| [[#SBB|SBB]]
| [[#SBB|SUBC]]
|-
| [[#SCASB|SCASB]]
| [[#SCASB|CMPMB]]
|-
| [[#SCASW|SCASW]]
| [[#SCASW|CMPMW]]
|-
| [[#SHL|SHL]]
| [[#SHL|SHL]]
|-
| [[#SHR|SHR]]
| [[#SHR|SHR]]
|-
| [[#SS|SS]]
| [[#SS|SS]]
|-
| [[#STC|STC]]
| [[#STC|SET1 CY]]
|-
| [[#STD|STD]]
| [[#STD|SET1 DIR]]
|-
| [[#STI|STI]]
| [[#STI|EI]]
|-
| [[#STOSB|STOSB]]
| [[#STOSB|STMB]]
|-
| [[#STOSW|STOSW]]
| [[#STOSW|STMW]]
|-
| [[#SUB|SUB]]
| [[#SUB|SUB]]
|-
| [[#TEST|TEST]]
| [[#TEST|TEST]]
|-
| [[#XCHG|XCHG]]
| [[#XCHG|XCH]]
|-
| [[#XLAT|XLAT]]
| [[#XLAT|TRANS]]
|-
| [[#XOR|XOR]]
| [[#XOR|XOR]]
|}
== Official instructions by type ==
{| class="wikitable sortable" style="text-align: center"
!Type
!colspan=16 class="unsortable" | Instructions
|-
| style="text-align:left;" | Memory
| style="" | [[#MOV|MOV]]
| style="" | [[#XCHG|XCHG]]
| style="" | [[#XLAT|XLAT]]
| style="" | [[#LEA|LEA]]
| style="border-right:none;" | [[#LDS|LDS]]
| style="border-left:none;" | [[#LES|LES]]
| style="border-right:none;" | [[#IN|IN]]
| style="border-left:none;" | [[#OUT|OUT]]
| colspan="8" |
|-
| style="text-align:left;" | Ports
| style="border-right:none;" | [[#IN|IN]]
| style="border-left:none;" | [[#OUT|OUT]]
| style="border-right:none;" | [[#INSB|INSB]]
| style="border-left:none;" | [[#OUTSB|OUTSB]]
| style="border-right:none;" | [[#INSW|INSW]]
| style="border-left:none;" | [[#OUTSW|OUTSW]]
| colspan="10" |
|-
| style="text-align:left;" | Arithmetic
| style="border-right:none;" | [[#ADD|ADD]]
| style="border-left:none;" | [[#SUB|SUB]]
| style="border-right:none;" | [[#ADC|ADC]]
| style="border-left:none;" | [[#SBB|SBB]]
| style="border-right:none;" | [[#INC|INC]]
| style="border-left:none;" | [[#DEC|DEC]]
| style="border-right:none;" | [[#MUL|MUL]]
| style="border-left:none;" | [[#DIV|DIV]]
| style="border-right:none;" | [[#IMUL|IMUL]]
| style="border-left:none;" | [[#IDIV|IDIV]]
| style="" | [[#CMP|CMP]]
| style="" | [[#NEG|NEG]]
| colspan="4" |
|-
| style="text-align:left;" | Numeric
| style="" | [[#CBW|CBW]]
| style="" | [[#CWD|CWD]]
| style="" | [[#AAA|AAA]]
| style="" | [[#AAS|AAS]]
| style="" | [[#AAM|AAM]]
| style="" | [[#AAD|AAD]]
| style="" | [[#DAA|DAA]]
| style="" | [[#DAS|DAS]]
| colspan="8" |
|-
| style="text-align:left;" | Shift
| style="border-right:none;" | [[#ROL|ROL]]
| style="border-left:none;" | [[#ROR|ROR]]
| style="border-right:none;" | [[#RCL|RCL]]
| style="border-left:none;" | [[#RCR|RCR]]
| style="border-right:none;" | [[#SHL|SHL]]
| style="border-left:none;" | [[#SHR|SHR]]
| style="" | [[#SAR|SAR]]
| colspan="9" |
|-
| style="text-align:left;" | Bitwise
| style="" | [[#AND|AND]]
| style="" | [[#OR|OR]]
| style="" | [[#XOR|XOR]]
| style="" | [[#NOT|NOT]]
| style="" | [[#TEST|TEST]]
| colspan="11" |
|-
| style="text-align:left;" | Branch
| style="border-right:none;" | [[#JC|JC]]
| style="border-left:none;" | [[#JNC|JNC]]
| style="border-right:none;" | [[#JZ|JZ]]
| style="border-left:none;" | [[#JNZ|JNZ]]
| style="border-right:none;" | [[#JBE|JBE]]
| style="border-left:none;" | [[#JA|JA]]
| style="border-right:none;" | [[#JO|JO]]
| style="border-left:none;" | [[#JNO|JNO]]
| style="border-right:none;" | [[#JP|JP]]
| style="border-left:none;" | [[#JNP|JNP]]
| style="border-right:none;" | [[#JS|JS]]
| style="border-left:none;" | [[#JNS|JNS]]
| style="border-right:none;" | [[#JL|JL]]
| style="border-left:none;" | [[#JGE|JGE]]
| style="border-right:none;" | [[#JLE|JLE]]
| style="border-left:none;" | [[#JG|JG]]
|-
| style="text-align:left;" | Jump
| style="" | [[#JMP|JMP]]
| style="border-right:none;" | [[#CALL|CALL]]
| style="border-left:none;border-right:none;" | [[#RET|RET]]
| style="border-left:none;" | [[#RETF|RETF]]
| colspan="12" |
|-
| style="text-align:left;" | Loop
| style="" | [[#LOOP|LOOP]]
| style="" | [[#LOOPE|LOOPE]]
| style="" | [[#LOOPNE|LOOPNE]]
| colspan="13" |
|-
| style="text-align:left;" | Interrupt
| style="border-right:none;" | [[#INT|INT]]
| style="border-left:none;" | [[#IRET|IRET]]
| style="" | [[#INTO|INTO]]
| style="" | [[#HLT|HLT]]
| style="" | [[#BOUND|BOUND]]
| colspan="11" |
|-
| style="text-align:left;" | Stack
| style="border-right:none;" | [[#PUSH|PUSH]]
| style="border-left:none;" | [[#POP|POP]]
| style="border-right:none;" | [[#PUSHA|PUSHA]]
| style="border-left:none;" | [[#POPA|POPA]]
| style="border-right:none;" | [[#PUSHF|PUSHF]]
| style="border-left:none;" | [[#POPF|POPF]]
| colspan="10" |
|-
| style="text-align:left;" | Flags
| style="border-right:none;" | [[#CLC|CLC]]
| style="border-left:none;" | [[#STC|STC]]
| style="border-right:none;" | [[#CLD|CLD]]
| style="border-left:none;" | [[#STD|STD]]
| style="border-right:none;" | [[#CLI|CLI]]
| style="border-left:none;" | [[#STI|STI]]
| style="" | [[#CMC|CMC]]
| style="border-right:none;" | [[#LAHF|LAHF]]
| style="border-left:none;" | [[#SAHF|SAHF]]
| colspan="7" |
|-
| style="text-align:left;" | Prefix
| style="" | [[#CS|CS]]
| style="" | [[#DS|DS]]
| style="" | [[#ES|ES]]
| style="" | [[#SS|SS]]
| colspan="12" |
|-
| style="text-align:left;" | String
| style="border-right:none;" | [[#REP|REP]]
| style="border-left:none;border-right:none;" | [[#REP|REPE]]
| style="border-left:none;" | [[#REPNE|REPNE]]
| style="" | [[#MOVSB|MOVSB]]
| style="" | [[#MOVSW|MOVSW]]
| style="border-right:none;" | [[#LODSB|LODSB]]
| style="border-left:none;" | [[#STOSB|STOSB]]
| style="border-right:none;" | [[#LODSW|LODSW]]
| style="border-left:none;" | [[#STOSW|STOSW]]
| style="" | [[#CMPSB|CMPSB]]
| style="" | [[#SCASB|SCASB]]
| style="" | [[#CMPSW|CMPSW]]
| style="" | [[#SCASW|SCASW]]
| colspan="3" |
|-
| style="text-align:left;" | Other
| style="" | [[#NOP|NOP]]
| style="border-right:none;" | [[#ENTER|ENTER]]
| style="border-left:none;" | [[#LEAVE|LEAVE]]
| style="" | [[#LOCK|LOCK]]
| style="" | [[#POLL|POLL]]
| colspan="11" |
|}
== Instruction encoding ==
=== ModR/M byte ===
The ModR/M byte is used in most addressing modes which reference a memory location. This byte consists of three bitfield values:
* <tt>oo</tt> - M'''o'''de;
* <tt>rrr</tt> - Two possible functions:
** '''R'''egister (for addressing modes which require both a register and a register/memory operand),
** Opcode extension (for some opcodes' addressing modes which do not have such a requirement);
* <tt>mmm</tt> - Register/'''M'''emory.
The ''Mode'' and ''Register/Memory'' bitfields can refer to a memory location or to a register, as shown in the table below.
Some instructions define a second argument using the ''Register'' field. It is always interpreted as if ''Mode'' was equal to <tt>11</tt> and, as such, can refer to a register only.
{| class="wikitable" style="text-align: center"
! R/M \ Mode
! <tt>00</tt>
! <tt>01</tt>
! <tt>10</tt>
! <tt>11</tt> ''(byte)''
! <tt>11</tt> ''(word)''
|-
| <tt>000</tt>
| DS:[BX + SI]
| DS:[BX + SI + disp8]
| DS:[BX + SI + disp16]
| AL
| AX
|-
| <tt>001</tt>
| DS:[BX + DI]
| DS:[BX + DI + disp8]
| DS:[BX + DI + disp16]
| CL
| CX
|-
| <tt>010</tt>
| SS:[BP + SI]
| SS:[BP + SI + disp8]
| SS:[BP + SI + disp16]
| DL
| DX
|-
| <tt>011</tt>
| SS:[BP + DI]
| SS:[BP + DI + disp8]
| SS:[BP + DI + disp16]
| BL
| BX
|-
| <tt>100</tt>
| DS:[SI]
| DS:[SI + disp8]
| DS:[SI + disp16]
| AH
| SP
|-
| <tt>101</tt>
| DS:[DI]
| DS:[DI + disp8]
| DS:[DI + disp16]
| CH
| BP
|-
| <tt>110</tt>
| ''DS:[disp16]''
| SS:[BP + disp8]
| SS:[BP + disp16]
| DH
| SI
|-
| <tt>111</tt>
| DS:[BX]
| DS:[BX + disp8]
| DS:[BX + disp16]
| BH
| DI
|}
Displacements are either 8-bit (disp8) or 16-bit (disp16) signed values and they always immediately follow the ModR/M byte. Note that (<tt>oo</tt> = <tt>00</tt>, <tt>mmm</tt> = <tt>110</tt>) is a special case, in which the ''disp16'' value is used directly as a near pointer.
The instruction encoding lists below refer to this byte as <tt>oorrrmmm</tt> (binary), <tt>/r</tt> (hexadecimal) or <tt>/0</tt> (hexademical, <tt>rrr</tt> used as function <tt>0</tt>).
== Official instructions ==
{{Anchor|AAA}}
=== AAA ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| AAA || <tt>37</tt> || <tt>00110111</tt> || 1 || 9
|}
----
{{Anchor|AAD}}
=== AAD ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| AAD imm8 || <tt>B5 ii</tt> || <tt>11010100 iiiiiiii</tt> || 2 || 6
|}
----
{{Anchor|AAM}}
=== AAM ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| AAM imm8 || <tt>B4 ii</tt> || <tt>11010100 iiiiiiii</tt> || 2 || 17
|}
----
{{Anchor|AAS}}
=== AAS ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| AAS || <tt>3F</tt> || <tt>00111111</tt> || 1 || 9
|}
----
{{Anchor|ADC}}
=== ADC ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| ADC AL, imm || <tt>14 ii</tt> || <tt>00010100 iiiiiiii</tt> || 2 || 1
|-
| ADC AX, imm || <tt>15 ii ii</tt> || <tt>00010101 iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| ADC mem8, imm8 || <tt>80 /2 ii</tt> || <tt>10000000 oo010mmm iiiiiiii</tt> || 3+ || 3
|-
| ADC mem16, imm16 || <tt>81 /2 ii ii</tt> || <tt>10000001 oo010mmm iiiiiiii iiiiiiii</tt> || 4+ || 3
|-
| ADC mem16, simm8 || <tt>83 /2 ii</tt> || <tt>10000011 oo010mmm iiiiiiii</tt> || 3+ || 3
|-
| ADC mem8, reg8 || <tt>10 /r</tt> || <tt>00010000 oorrrmmm</tt> || 2+ || 3
|-
| ADC mem16, reg16 || <tt>11 /r</tt> || <tt>00010001 oorrrmmm</tt> || 2+ || 3
|-
| ADC reg8, imm8 || <tt>80 /2 ii</tt> || <tt>10000000 11010mmm iiiiiiii</tt> || 3 || 1
|-
| ADC reg16, imm16 || <tt>81 /2 ii ii</tt> || <tt>10000001 11010mmm iiiiiiii iiiiiiii</tt> || 4 || 1
|-
| ADC reg16, simm8 || <tt>83 /2 ii</tt> || <tt>10000011 11010mmm iiiiiiii</tt> || 3 || 1
|-
| ADC reg8, mem8 || <tt>12 /r</tt> || <tt>00010010 oorrrmmm</tt> || 2+ || 2
|-
| ADC reg16, mem16 || <tt>13 /r</tt> || <tt>00010011 oorrrmmm</tt> || 2+ || 2
|-
| ADC reg8, reg8 || <tt>10 /r</tt> || <tt>000100.0 11rrrmmm</tt> || 2 || 1
|-
| ADC reg16, reg16 || <tt>11 /r</tt> || <tt>000100.1 11rrrmmm</tt> || 2 || 1
|}
----
{{Anchor|ADD}}
=== ADD ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| ADD AL, imm || <tt>04 ii</tt> || <tt>00000100 iiiiiiii</tt> || 2 || 1
|-
| ADD AX, imm || <tt>05 ii ii</tt> || <tt>00000101 iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| ADD mem8, imm8 || <tt>80 /0 ii</tt> || <tt>10000000 oo000mmm iiiiiiii</tt> || 3+ || 3
|-
| ADD mem16, imm16 || <tt>81 /0 ii ii</tt> || <tt>10000001 oo000mmm iiiiiiii iiiiiiii</tt> || 4+ || 3
|-
| ADD mem16, simm8 || <tt>83 /0 ii</tt> || <tt>10000011 oo000mmm iiiiiiii</tt> || 3+ || 3
|-
| ADD mem8, reg8 || <tt>00 /r</tt> || <tt>00000000 oorrrmmm</tt> || 2+ || 3
|-
| ADD mem16, reg16 || <tt>01 /r</tt> || <tt>00000001 oorrrmmm</tt> || 2+ || 3
|-
| ADD reg8, imm8 || <tt>80 /0 ii</tt> || <tt>10000000 11000mmm iiiiiiii</tt> || 3 || 1
|-
| ADD reg16, imm16 || <tt>81 /0 ii ii</tt> || <tt>10000001 11000mmm iiiiiiii iiiiiiii</tt> || 4 || 1
|-
| ADD reg16, simm8 || <tt>83 /0 ii</tt> || <tt>10000011 11000mmm iiiiiiii</tt> || 3 || 1
|-
| ADD reg8, mem8 || <tt>02 /r</tt> || <tt>00000010 oorrrmmm</tt> || 2+ || 2
|-
| ADD reg16, mem16 || <tt>03 /r</tt> || <tt>00000011 oorrrmmm</tt> || 2+ || 2
|-
| ADD reg8, reg8 || <tt>00 /r</tt> || <tt>000000.0 11rrrmmm</tt> || 2 || 1
|-
| ADD reg16, reg16 || <tt>01 /r</tt> || <tt>000000.1 11rrrmmm</tt> || 2 || 1
|}
----
{{Anchor|AND}}
=== AND ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| AND AL, imm || <tt>24 ii</tt> || <tt>00100100 iiiiiiii</tt> || 2 || 1
|-
| AND AX, imm || <tt>25 ii ii</tt> || <tt>00100101 iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| AND mem8, imm8 || <tt>80 /4 ii</tt> || <tt>10000000 oo100mmm iiiiiiii</tt> || 3+ || 3
|-
| AND mem16, imm16 || <tt>81 /4 ii ii</tt> || <tt>10000001 oo100mmm iiiiiiii iiiiiiii</tt> || 4+ || 3
|-
| AND mem16, simm8 || <tt>83 /4 ii</tt> || <tt>10000011 oo100mmm iiiiiiii</tt> || 3+ || 3
|-
| AND mem8, reg8 || <tt>20 /r</tt> || <tt>00100000 oorrrmmm</tt> || 2+ || 3
|-
| AND mem16, reg16 || <tt>21 /r</tt> || <tt>00100001 oorrrmmm</tt> || 2+ || 3
|-
| AND reg8, imm8 || <tt>80 /4 ii</tt> || <tt>10000000 11100mmm iiiiiiii</tt> || 3 || 1
|-
| AND reg16, imm16 || <tt>81 /4 ii ii</tt> || <tt>10000001 11100mmm iiiiiiii iiiiiiii</tt> || 4 || 1
|-
| AND reg16, simm8 || <tt>83 /4 ii</tt> || <tt>10000011 11100mmm iiiiiiii</tt> || 3 || 1
|-
| AND reg8, mem8 || <tt>22 /r</tt> || <tt>00100010 oorrrmmm</tt> || 2+ || 2
|-
| AND reg16, mem16 || <tt>23 /r</tt> || <tt>00100011 oorrrmmm</tt> || 2+ || 2
|-
| AND reg8, reg8 || <tt>20 /r</tt> || <tt>001000.0 11rrrmmm</tt> || 2 || 1
|-
| AND reg16, reg16 || <tt>21 /r</tt> || <tt>001000.1 11rrrmmm</tt> || 2 || 1
|}
----
{{Anchor|BOUND}}
=== BOUND ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| BOUND reg16, mem16:16 || <tt>62 /r</tt> || <tt>01100010 oorrrmmm</tt> || 2+ || 13 (20 if condition met)
|}
----
{{Anchor|CALL}}
=== CALL ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| CALL ptr16:16 || <tt>CA oo oo ss ss</tt> || <tt>10011010 oooooooo oooooooo ssssssss ssssssss</tt> || 5 || 10
|-
| CALL mem16 || <tt>FF /2</tt> || <tt>11111111 oo010mmm</tt> || 2+ || 6
|-
| CALL mem16:16 || <tt>FF /3</tt> || <tt>11111111 oo011mmm</tt> || 2+ || 12
|-
| CALL reg16 || <tt>FF /2</tt> || <tt>11111111 11010mmm</tt> || 2 || 5
|-
| CALL rel16 || <tt>E8 ii ii</tt> || <tt>11101000 iiiiiiii iiiiiiii</tt> || 3 || 5
|}
----
{{Anchor|CBW}}
=== CBW ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| CBW || <tt>98</tt> || <tt>10011000</tt> || 1 || 1
|}
----
{{Anchor|CLC}}
=== CLC ===
{| class="wikitable"
! Flag !! New value
|-
| [[NEC_V30MZ_flags#CF|CF - Carry]] || 0
|}
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| CLC || <tt>F8</tt> || <tt>11111000</tt> || 1 || 4
|}
----
{{Anchor|CLD}}
=== CLD ===
{| class="wikitable"
! Flag !! New value
|-
| [[NEC_V30MZ_flags#DF|DF - Direction]] || 0
|}
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| CLD || <tt>FC</tt> || <tt>11111100</tt> || 1 || 4
|}
----
{{Anchor|CLI}}
=== CLI ===
{| class="wikitable"
! Flag !! New value
|-
| [[NEC_V30MZ_flags#IF|IF - Interrupt]] || 0
|}
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| CLI || <tt>FA</tt> || <tt>11111010</tt> || 1 || 4
|}
----
{{Anchor|CMC}}
=== CMC ===
{| class="wikitable"
! Flag !! New value
|-
| [[NEC_V30MZ_flags#CF|CF - Carry]] || !CF
|}
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| CMC || <tt>F5</tt> || <tt>11110101</tt> || 1 || 4
|}
----
{{Anchor|CMP}}
=== CMP ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| CMP AL, imm || <tt>3C ii</tt> || <tt>00111100 iiiiiiii</tt> || 2 || 1
|-
| CMP AX, imm || <tt>3D ii ii</tt> || <tt>00111101 iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| CMP mem8, imm8 || <tt>80 /7 ii</tt> || <tt>10000000 oo111mmm iiiiiiii</tt> || 3+ || 2
|-
| CMP mem16, imm16 || <tt>81 /7 ii ii</tt> || <tt>10000001 oo111mmm iiiiiiii iiiiiiii</tt> || 4+ || 2
|-
| CMP mem16, simm8 || <tt>83 /7 ii</tt> || <tt>10000011 oo111mmm iiiiiiii</tt> || 3+ || 2
|-
| CMP mem8, reg8 || <tt>38 /r</tt> || <tt>00111000 oorrrmmm</tt> || 2+ || 2
|-
| CMP mem16, reg16 || <tt>39 /r</tt> || <tt>00111001 oorrrmmm</tt> || 2+ || 2
|-
| CMP reg8, imm8 || <tt>80 /7 ii</tt> || <tt>10000000 11111mmm iiiiiiii</tt> || 3 || 1
|-
| CMP reg16, imm16 || <tt>81 /7 ii ii</tt> || <tt>10000001 11111mmm iiiiiiii iiiiiiii</tt> || 4 || 1
|-
| CMP reg16, simm8 || <tt>83 /7 ii</tt> || <tt>10000011 11111mmm iiiiiiii</tt> || 3 || 1
|-
| CMP reg8, mem8 || <tt>3A /r</tt> || <tt>00111010 oorrrmmm</tt> || 2+ || 2
|-
| CMP reg16, mem16 || <tt>3B /r</tt> || <tt>00111011 oorrrmmm</tt> || 2+ || 2
|-
| CMP reg8, reg8 || <tt>38 /r</tt> || <tt>001110.0 11rrrmmm</tt> || 2 || 1
|-
| CMP reg16, reg16 || <tt>39 /r</tt> || <tt>001110.1 11rrrmmm</tt> || 2 || 1
|}
----
{{Anchor|CMPSB}}
{{Anchor|CMPSW}}
=== CMPSB/CMPSW ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| CMPSB || <tt>A6</tt> || <tt>10100110</tt> || 1 || 6
|-
| CMPSW || <tt>A7</tt> || <tt>10100111</tt> || 1 || 6
|}
----
{{Anchor|CS}}
=== CS ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| CS || <tt>2E</tt> || <tt>00101110</tt> || 1 || 1
|}
----
{{Anchor|CWD}}
=== CWD ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| CWD || <tt>99</tt> || <tt>10011001</tt> || 1 || 1
|}
----
{{Anchor|DAA}}
=== DAA ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| DAA || <tt>27</tt> || <tt>00100111</tt> || 1 || 10
|}
----
{{Anchor|DAS}}
=== DAS ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| DAS || <tt>2F</tt> || <tt>00101111</tt> || 1 || 10
|}
----
{{Anchor|DEC}}
=== DEC ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| DEC mem8 || <tt>FE /1</tt> || <tt>11111110 oo001mmm</tt> || 2+ || 3
|-
| DEC mem16 || <tt>FF /1</tt> || <tt>11111111 oo001mmm</tt> || 2+ || 3
|-
| DEC reg8 || <tt>FE /1</tt> || <tt>11111110 11001mmm</tt> || 2+ || 1
|-
| DEC reg16 || <tt>4x</tt> || <tt>01001rrr</tt> || 1 || 1
|}
----
{{Anchor|DIV}}
=== DIV ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| DIV mem8 || <tt>F6 /6</tt> || <tt>11110110 oo110mmm</tt> || 2+ || 16
|-
| DIV mem16 || <tt>F7 /6</tt> || <tt>11111111 oo110mmm</tt> || 2+ || 24
|-
| DIV reg8 || <tt>F6 /6</tt> || <tt>11111110 11110mmm</tt> || 2 || 15
|-
| DIV reg16 || <tt>F7 /6</tt> || <tt>11111111 11110mmm</tt> || 2 || 23
|}
----
{{Anchor|DS}}
=== DS ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| DS || <tt>3E</tt> || <tt>00111110</tt> || 1 || 1
|}
----
{{Anchor|ENTER}}
=== ENTER ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| ENTER imm16, imm8 || <tt>C8 ii ii jj</tt> || <tt>11001000 iiiiiiii iiiiiiii jjjjjjjj</tt> || 3 || 8 (imm8 = 0)<br/>14 (imm8 = 1)<br/>15 + imm8 * 4 (imm8 >= 2)
|}
----
{{Anchor|ES}}
=== ES ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| ES || <tt>26</tt> || <tt>00100110</tt> || 1 || 1
|}
----
{{Anchor|HLT}}
=== HLT ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| HLT || <tt>F4</tt> || <tt>11110100</tt> || 1 || 9
|}
----
{{Anchor|IDIV}}
=== IDIV ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| IDIV mem8 || <tt>F6 /7</tt> || <tt>11110110 oo111mmm</tt> || 2+ || 18
|-
| IDIV mem16 || <tt>F7 /7</tt> || <tt>11111111 oo111mmm</tt> || 2+ || 25
|-
| IDIV reg8 || <tt>F6 /7</tt> || <tt>11111110 11111mmm</tt> || 2 || 17
|-
| IDIV reg16 || <tt>F7 /7</tt> || <tt>11111111 11111mmm</tt> || 2 || 24
|}
----
{{Anchor|IMUL}}
=== IMUL ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| IMUL mem8 || <tt>F6 /5</tt> || <tt>11110110 oo101mmm</tt> || 2+ || 4
|-
| IMUL mem16 || <tt>F7 /5</tt> || <tt>11111111 oo101mmm</tt> || 2+ || 4
|-
| IMUL reg8 || <tt>F6 /5</tt> || <tt>11111110 11101mmm</tt> || 2 || 3
|-
| IMUL reg16 || <tt>F7 /5</tt> || <tt>11111111 11101mmm</tt> || 2 || 3
|-
| IMUL reg16, mem16, imm16 || <tt>69 /r ii ii</tt> || <tt>11111111 oorrrmmm iiiiiiii iiiiiiii</tt> || 4 || 4
|-
| IMUL reg16, mem16, simm8 || <tt>6B /r ii</tt> || <tt>11111111 oorrrmmm iiiiiiii</tt> || 3 || 4
|-
| IMUL reg16, reg16, imm16 || <tt>69 /r ii ii</tt> || <tt>11111111 11rrrmmm iiiiiiii iiiiiiii</tt> || 4 || 3
|-
| IMUL reg16, reg16, simm8 || <tt>6B /r ii</tt> || <tt>11111111 11rrrmmm iiiiiiii</tt> || 3 || 3
|}
----
{{Anchor|IN}}
=== IN ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| IN AL, DX || <tt>EC</tt> || <tt>11101100</tt> || 1 || 6
|-
| IN AX, DX || <tt>ED</tt> || <tt>11101101</tt> || 1 || 6
|-
| IN AL, imm8 || <tt>E4 ii</tt> || <tt>11100100 iiiiiiii</tt> || 2 || 6
|-
| IN AX, imm8 || <tt>E5 ii</tt> || <tt>11100101 iiiiiiii</tt> || 2 || 6
|}
----
{{Anchor|INC}}
=== INC ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| INC mem8 || <tt>FE /0</tt> || <tt>11111110 oo000mmm</tt> || 2+ || 3
|-
| INC mem16 || <tt>FF /0</tt> || <tt>11111111 oo000mmm</tt> || 2+ || 3
|-
| INC reg8 || <tt>FE /0</tt> || <tt>11111110 11000mmm</tt> || 2+ || 1
|-
| INC reg16 || <tt>4x</tt> || <tt>01000rrr</tt> || 1 || 1
|}
----
{{Anchor|INSB}}
{{Anchor|INSW}}
=== INSB/INSW ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| INSB || <tt>6C</tt> || <tt>01101100</tt> || 1 || 6
|-
| INSW || <tt>6D</tt> || <tt>01101101</tt> || 1 || 6
|}
----
{{Anchor|INT}}
=== INT ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| INT 3 || <tt>CC</tt> || <tt>11001100</tt> || 1 || 9
|-
| INT imm8 || <tt>CD ii</tt> || <tt>11001101 iiiiiiii</tt> || 2 || 10
|}
----
{{Anchor|INTO}}
=== INTO ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| INTO || <tt>CE</tt> || <tt>11001110</tt> || 1 || 6 (13 if OF = 1)
|}
----
{{Anchor|IRET}}
=== IRET ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| IRET || <tt>CF</tt> || <tt>11001111</tt> || 1 || 10
|}
----
{{Anchor|JA}}
=== JA ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JA rel8 || <tt>77 ii</tt> || <tt>01110111 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JBE}}
=== JBE ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JA rel8 || <tt>76 ii</tt> || <tt>01110110 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JC}}
=== JC/JB ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JC rel8 || <tt>72 ii</tt> || <tt>01110010 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JCXZ}}
=== JCXZ ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JCXZ rel8 || <tt>E3 ii</tt> || <tt>11100011 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JG}}
=== JG ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JG rel8 || <tt>7F ii</tt> || <tt>01111111 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JGE}}
=== JGE ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JGE rel8 || <tt>7D ii</tt> || <tt>01111101 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JL}}
=== JL ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JL rel8 || <tt>7C ii</tt> || <tt>01111100 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JLE}}
=== JLE ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JLE rel8 || <tt>7E ii</tt> || <tt>01111110 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JMP}}
=== JMP ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JMP ptr16:16 || <tt>EA oo oo ss ss</tt> || <tt>11101010 oooooooo oooooooo ssssssss ssssssss</tt> || 5 || 7
|-
| JMP mem16 || <tt>FF /4</tt> || <tt>11111111 oo100mmm</tt> || 2+ || 5
|-
| JMP mem16:16 || <tt>FF /5</tt> || <tt>11111111 oo101mmm</tt> || 2+ || 10
|-
| JMP reg16 || <tt>FF /4</tt> || <tt>11111111 11100mmm</tt> || 2 || 4
|-
| JMP rel8 || <tt>EB ii</tt> || <tt>11101011 iiiiiiii</tt> || 2 || 4
|-
| JMP rel16 || <tt>E9 ii ii</tt> || <tt>11101001 iiiiiiii iiiiiiii</tt> || 3 || 4
|}
----
{{Anchor|JNC}}
=== JNC/JAE ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JNC rel8 || <tt>73 ii</tt> || <tt>01110011 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JNO}}
=== JNO ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JNO rel8 || <tt>71 ii</tt> || <tt>01110001 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JNP}}
=== JNP ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JNP rel8 || <tt>7B ii</tt> || <tt>01111011 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JNS}}
=== JNS ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JNS rel8 || <tt>79 ii</tt> || <tt>01111001 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JNZ}}
=== JNZ/JNE ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JNZ rel8 || <tt>75 ii</tt> || <tt>01110101 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JO}}
=== JO ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JO rel8 || <tt>70 ii</tt> || <tt>01110000 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JP}}
=== JP ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JP rel8 || <tt>7A ii</tt> || <tt>01111010 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JS}}
=== JS ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JS rel8 || <tt>78 ii</tt> || <tt>01111000 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JZ}}
=== JZ/JE ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JZ rel8 || <tt>74 ii</tt> || <tt>01110100 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|LAHF}}
=== LAHF ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| LAHF || <tt>9F</tt> || <tt>10011111</tt> || 1 || 2
|}
----
{{Anchor|LDS}}
=== LDS ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| LDS reg16, mem16 || <tt>C5 /r</tt> || <tt>11000101 oorrrmmm</tt> || 2+ || 6
|}
----
{{Anchor|LEA}}
=== LEA ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| LEA reg16, mem16 || <tt>8D /r</tt> || <tt>10001101 oorrrmmm</tt> || 2+ || 1
|}
----
{{Anchor|LEAVE}}
=== LEAVE ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| LEAVE || <tt>C9</tt> || <tt>11001001</tt> || 1 || 2
|}
----
{{Anchor|LES}}
=== LES ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| LES reg16, mem16 || <tt>C4 /r</tt> || <tt>11000100 oorrrmmm</tt> || 2+ || 6
|}
----
{{Anchor|LOCK}}
=== LOCK ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| LOCK || <tt>F0</tt> || <tt>11110000</tt> || 1 || 1
|}
----
{{Anchor|LODSB}}
{{Anchor|LODSW}}
=== LODSB/LODSW ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| LODSB || <tt>AC</tt> || <tt>10101100</tt> || 1 || 3
|-
| LODSW || <tt>AD</tt> || <tt>10101101</tt> || 1 || 3
|}
----
{{Anchor|LOOP}}
=== LOOP ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| LOOP rel8 || <tt>E2 ii</tt> || <tt>11100010 iiiiiiii</tt> || 2 || 2 (5 if branch taken)
|}
----
{{Anchor|LOOPE}}
=== LOOPE ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| LOOPE rel8 || <tt>E1 ii</tt> || <tt>11100001 iiiiiiii</tt> || 2 || 3 (6 if branch taken)
|}
----
{{Anchor|LOOPNE}}
=== LOOPNE ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| LOOPNE rel8 || <tt>E0 ii</tt> || <tt>11100000 iiiiiiii</tt> || 2 || 3 (6 if branch taken)
|}
----
{{Anchor|MOV}}
=== MOV ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| MOV AL, ptr16 || <tt>A0 ii ii</tt> || <tt>10100000 iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| MOV AX, ptr16 || <tt>A1 ii ii</tt> || <tt>10100001 iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| MOV mem8, imm8 || <tt>C6 /0 ii</tt> || <tt>11000110 oo000mmm iiiiiiii</tt> || 3+ || 1
|-
| MOV mem16, imm16 || <tt>C7 /0 ii ii</tt> || <tt>11000111 oo000mmm iiiiiiii iiiiiiii</tt> || 4+ || 1
|-
| MOV mem8, reg8 || <tt>84 /r</tt> || <tt>10001000 oorrrmmm</tt> || 2+ || 1
|-
| MOV mem16, reg16 || <tt>85 /r</tt> || <tt>10001001 oorrrmmm</tt> || 2+ || 1
|-
| MOV mem16, sreg16 || <tt>8C /r</tt> || <tt>10001100 oo0rrmmm</tt> || 2+ || 3
|-
| MOV ptr16, AL || <tt>A2 ii ii</tt> || <tt>10100010 iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| MOV ptr16, AX || <tt>A3 ii ii</tt> || <tt>10100011 iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| MOV reg8, imm8 || <tt>Bx ii</tt> || <tt>10110rrr iiiiiiii</tt> || 2 || 1
|-
| MOV reg8, imm8 || <tt>C6 /0 ii</tt> || <tt>11000110 11000mmm iiiiiiii</tt> || 3 || 1
|-
| MOV reg16, imm16 || <tt>Bx ii</tt> || <tt>10111rrr iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| MOV reg16, imm16 || <tt>C7 /0 ii ii</tt> || <tt>11000111 11000mmm iiiiiiii iiiiiiii</tt> || 4 || 1
|-
| MOV reg8, mem8 || <tt>8A /r</tt> || <tt>10001010 oorrrmmm</tt> || 2+ || 1
|-
| MOV reg16, mem16 || <tt>8B /r</tt> || <tt>10001011 oorrrmmm</tt> || 2+ || 1
|-
| MOV reg8, reg8 || <tt>88 /r</tt> || <tt>100010.0 11rrrmmm</tt> || 2 || 1
|-
| MOV reg16, reg16 || <tt>89 /r</tt> || <tt>100010.1 11rrrmmm</tt> || 2 || 1
|-
| MOV reg16, sreg16 || <tt>8C /r</tt> || <tt>10001100 110rrmmm</tt> || 2 || 1
|-
| MOV sreg16, mem16 || <tt>8E /r</tt> || <tt>10001110 oo0rrmmm</tt> || 2 || 3
|-
| MOV sreg16, reg16 || <tt>8E /r</tt> || <tt>10001110 110rrmmm</tt> || 2+ || 2
|}
----
{{Anchor|MOVSB}}
{{Anchor|MOVSW}}
=== MOVSB/MOVSW ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| MOVSB || <tt>A4</tt> || <tt>10100100</tt> || 1 || 5
|-
| MOVSW || <tt>A5</tt> || <tt>10100101</tt> || 1 || 5
|}
----
{{Anchor|MUL}}
=== MUL ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| MUL mem8 || <tt>F6 /4</tt> || <tt>11110110 oo100mmm</tt> || 2+ || 4
|-
| MUL mem16 || <tt>F7 /4</tt> || <tt>11111111 oo100mmm</tt> || 2+ || 4
|-
| MUL reg8 || <tt>F6 /4</tt> || <tt>11111110 11100mmm</tt> || 2 || 3
|-
| MUL reg16 || <tt>F7 /4</tt> || <tt>11111111 11100mmm</tt> || 2 || 3
|}
----
{{Anchor|NEG}}
=== NEG ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| NEG mem8 || <tt>F6 /3</tt> || <tt>11110110 oo011mmm</tt> || 2+ || 3
|-
| NEG mem16 || <tt>F7 /3</tt> || <tt>11111111 oo011mmm</tt> || 2+ || 3
|-
| NEG reg8 || <tt>F6 /3</tt> || <tt>11111110 11011mmm</tt> || 2 || 1
|-
| NEG reg16 || <tt>F7 /3</tt> || <tt>11111111 11011mmm</tt> || 2 || 1
|}
----
{{Anchor|NOP}}
=== NOP ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| NOP || <tt>90</tt> || <tt>10010000</tt> || 1 || 1
|}
----
{{Anchor|NOT}}
=== NOT ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| NOT mem8 || <tt>F6 /2</tt> || <tt>11110110 oo010mmm</tt> || 2+ || 3
|-
| NOT mem16 || <tt>F7 /2</tt> || <tt>11111111 oo010mmm</tt> || 2+ || 3
|-
| NOT reg8 || <tt>F6 /2</tt> || <tt>11111110 11010mmm</tt> || 2 || 1
|-
| NOT reg16 || <tt>F7 /2</tt> || <tt>11111111 11010mmm</tt> || 2 || 1
|}
----
{{Anchor|OR}}
=== OR ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| OR AL, imm || <tt>0C ii</tt> || <tt>00001100 iiiiiiii</tt> || 2 || 1
|-
| OR AX, imm || <tt>0D ii ii</tt> || <tt>00001101 iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| OR mem8, imm8 || <tt>80 /6 ii</tt> || <tt>10000000 oo001mmm iiiiiiii</tt> || 3+ || 3
|-
| OR mem16, imm16 || <tt>81 /6 ii ii</tt> || <tt>10000001 oo001mmm iiiiiiii iiiiiiii</tt> || 4+ || 3
|-
| OR mem16, simm8 || <tt>83 /6 ii</tt> || <tt>10000011 oo001mmm iiiiiiii</tt> || 3+ || 3
|-
| OR mem8, reg8 || <tt>08 /r</tt> || <tt>00001000 oorrrmmm</tt> || 2+ || 3
|-
| OR mem16, reg16 || <tt>09 /r</tt> || <tt>00001001 oorrrmmm</tt> || 2+ || 3
|-
| OR reg8, imm8 || <tt>80 /6 ii</tt> || <tt>10000000 11001mmm iiiiiiii</tt> || 3 || 1
|-
| OR reg16, imm16 || <tt>81 /6 ii ii</tt> || <tt>10000001 11001mmm iiiiiiii iiiiiiii</tt> || 4 || 1
|-
| OR reg16, simm8 || <tt>83 /6 ii</tt> || <tt>10000011 11001mmm iiiiiiii</tt> || 3 || 1
|-
| OR reg8, mem8 || <tt>0A /r</tt> || <tt>00001010 oorrrmmm</tt> || 2+ || 2
|-
| OR reg16, mem16 || <tt>0B /r</tt> || <tt>00001011 oorrrmmm</tt> || 2+ || 2
|-
| OR reg8, reg8 || <tt>08 /r</tt> || <tt>000010.0 11rrrmmm</tt> || 2 || 1
|-
| OR reg16, reg16 || <tt>09 /r</tt> || <tt>000010.1 11rrrmmm</tt> || 2 || 1
|}
----
{{Anchor|OUT}}
=== OUT ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| OUT AL, DX || <tt>EE</tt> || <tt>11101110</tt> || 1 || 6
|-
| OUT AX, DX || <tt>EF</tt> || <tt>11101111</tt> || 1 || 6
|-
| OUT AL, imm8 || <tt>E6 ii</tt> || <tt>11100110 iiiiiiii</tt> || 2 || 6
|-
| OUT AX, imm8 || <tt>E7 ii</tt> || <tt>11100111 iiiiiiii</tt> || 2 || 6
|}
----
{{Anchor|OUTSB}}
{{Anchor|OUTSW}}
=== OUTSB/OUTSW ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| OUTSB || <tt>6E</tt> || <tt>01101110</tt> || 1 || 6
|-
| OUTSW || <tt>6F</tt> || <tt>01101111</tt> || 1 || 6
|}
----
{{Anchor|POLL}}
=== POLL ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| POLL || <tt>6E</tt> || <tt>01101110</tt> || 1 || 9<ref>On the WonderSwan implementation, POLLB is always held low; on other implementations, POLL will wait for POLLB to be held low in 9-cycle intervals.</ref>
|}
----
{{Anchor|POP}}
=== POP ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| POP mem16 || <tt>8F /0</tt> || <tt>10001111 oo000mmm</tt> || 2+ || 3
|-
| POP reg16 || <tt>5x</tt> || <tt>01011xxx</tt> || 1 || 1
|-
| POP reg16 || <tt>8F /0</tt> || <tt>10001111 11000mmm</tt> || 2 || 1
|-
| POP sreg16 || <tt>xx</tt> || <tt>000xx111</tt> || 1 || 3
|}
----
{{Anchor|POPA}}
=== POPA ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| POPA || <tt>61</tt> || <tt>01100001</tt> || 1 || 8
|}
----
{{Anchor|POPF}}
=== POPF ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| POPF || <tt>9D</tt> || <tt>10011101</tt> || 1 || 3
|}
----
{{Anchor|PUSH}}
=== PUSH ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| PUSH simm8 || <tt>6A ii</tt> || <tt>01101010 iiiiiiii</tt> || 2 || 1
|-
| PUSH imm16 || <tt>68 ii ii</tt> || <tt>01101000 iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| PUSH mem16 || <tt>FF /6</tt> || <tt>11111111 oo110mmm</tt> || 2+ || 2
|-
| PUSH reg16 || <tt>5x</tt> || <tt>01010xxx</tt> || 1 || 1
|-
| PUSH reg16 || <tt>FF /6</tt> || <tt>11111111 11110mmm</tt> || 2 || 1
|-
| PUSH sreg16 || <tt>xx</tt> || <tt>000xx110</tt> || 1 || 2
|}
----
{{Anchor|PUSHA}}
=== PUSHA ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| PUSHA || <tt>60</tt> || <tt>01100000</tt> || 1 || 9
|}
----
{{Anchor|PUSHF}}
=== PUSHF ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| PUSHF || <tt>9C</tt> || <tt>10011100</tt> || 1 || 2
|}
----
{{Anchor|RCL}}
=== RCL ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| RCL mem8, 1 || <tt>D0 /2</tt> || <tt>11010000 oo010rm</tt> || 2+ || 3
|-
| RCL mem8, CL || <tt>D2 /2</tt> || <tt>11010010 oo010rm</tt> || 2+ || 5
|-
| RCL mem8, imm8 || <tt>C0 /2 ii</tt> || <tt>11000000 oo010mmm iiiiiiii</tt> || 3+ || 5
|-
| RCL mem16, 1 || <tt>D1 /2</tt> || <tt>11010001 oo010rm</tt> || 2+ || 3
|-
| RCL mem16, CL || <tt>D3 /2</tt> || <tt>11010011 oo010rm</tt> || 2+ || 5
|-
| RCL mem16, imm8 || <tt>C1 /2 ii</tt> || <tt>11000001 oo010mmm iiiiiiii</tt> || 3+ || 5
|-
| RCL reg8, 1 || <tt>D0 /2</tt> || <tt>11010000 11010rm</tt> || 2 || 1
|-
| RCL reg8, CL || <tt>D2 /2</tt> || <tt>11010010 11010rm</tt> || 2 || 3
|-
| RCL reg8, imm8 || <tt>C0 /2 ii</tt> || <tt>11000000 11010mmm iiiiiiii</tt> || 3 || 3
|-
| RCL reg16, 1 || <tt>D1 /2</tt> || <tt>11010001 11010rm</tt> || 2 || 1
|-
| RCL reg16, CL || <tt>D3 /2</tt> || <tt>11010011 11010rm</tt> || 2 || 3
|-
| RCL reg16, imm8 || <tt>C1 /2 ii</tt> || <tt>11000001 11010mmm iiiiiiii</tt> || 3 || 3
|}
----
{{Anchor|RCR}}
=== RCR ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| RCR mem8, 1 || <tt>D0 /3</tt> || <tt>11010000 oo011rm</tt> || 2+ || 3
|-
| RCR mem8, CL || <tt>D2 /3</tt> || <tt>11010010 oo011rm</tt> || 2+ || 5
|-
| RCR mem8, imm8 || <tt>C0 /3 ii</tt> || <tt>11000000 oo011mmm iiiiiiii</tt> || 3+ || 5
|-
| RCR mem16, 1 || <tt>D1 /3</tt> || <tt>11010001 oo011rm</tt> || 2+ || 3
|-
| RCR mem16, CL || <tt>D3 /3</tt> || <tt>11010011 oo011rm</tt> || 2+ || 5
|-
| RCR mem16, imm8 || <tt>C1 /3 ii</tt> || <tt>11000001 oo011mmm iiiiiiii</tt> || 3+ || 5
|-
| RCR reg8, 1 || <tt>D0 /3</tt> || <tt>11010000 11011rm</tt> || 2 || 1
|-
| RCR reg8, CL || <tt>D2 /3</tt> || <tt>11010010 11011rm</tt> || 2 || 3
|-
| RCR reg8, imm8 || <tt>C0 /3 ii</tt> || <tt>11000000 11011mmm iiiiiiii</tt> || 3 || 3
|-
| RCR reg16, 1 || <tt>D1 /3</tt> || <tt>11010001 11011rm</tt> || 2 || 1
|-
| RCR reg16, CL || <tt>D3 /3</tt> || <tt>11010011 11011rm</tt> || 2 || 3
|-
| RCR reg16, imm8 || <tt>C1 /3 ii</tt> || <tt>11000001 11011mmm iiiiiiii</tt> || 3 || 3
|}
----
{{Anchor|REP}}
=== REP/REPE/REPZ ===
----
{{Anchor|REPNE}}
=== REPNE/REPNZ ===
----
{{Anchor|RET}}
=== RET ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| RET || <tt>C3</tt> || <tt>11000011</tt> || 1 || 6
|-
| RET imm16 || <tt>C2 ii ii</tt> || <tt>11000010 iiiiiiii iiiiiiii</tt> || 1 || 6
|}
----
{{Anchor|RETF}}
=== RETF ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| RETF || <tt>CB</tt> || <tt>11001011</tt> || 1 || 8
|-
| RETF imm16 || <tt>CA ii ii</tt> || <tt>11001010 iiiiiiii iiiiiiii</tt> || 1 || 9
|}
----
{{Anchor|ROL}}
=== ROL ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| ROL mem8, 1 || <tt>D0 /0</tt> || <tt>11010000 oo000rm</tt> || 2+ || 3
|-
| ROL mem8, CL || <tt>D2 /0</tt> || <tt>11010010 oo000rm</tt> || 2+ || 5
|-
| ROL mem8, imm8 || <tt>C0 /0 ii</tt> || <tt>11000000 oo000mmm iiiiiiii</tt> || 3+ || 5
|-
| ROL mem16, 1 || <tt>D1 /0</tt> || <tt>11010001 oo000rm</tt> || 2+ || 3
|-
| ROL mem16, CL || <tt>D3 /0</tt> || <tt>11010011 oo000rm</tt> || 2+ || 5
|-
| ROL mem16, imm8 || <tt>C1 /0 ii</tt> || <tt>11000001 oo000mmm iiiiiiii</tt> || 3+ || 5
|-
| ROL reg8, 1 || <tt>D0 /0</tt> || <tt>11010000 11000rm</tt> || 2 || 1
|-
| ROL reg8, CL || <tt>D2 /0</tt> || <tt>11010010 11000rm</tt> || 2 || 3
|-
| ROL reg8, imm8 || <tt>C0 /0 ii</tt> || <tt>11000000 11000mmm iiiiiiii</tt> || 3 || 3
|-
| ROL reg16, 1 || <tt>D1 /0</tt> || <tt>11010001 11000rm</tt> || 2 || 1
|-
| ROL reg16, CL || <tt>D3 /0</tt> || <tt>11010011 11000rm</tt> || 2 || 3
|-
| ROL reg16, imm8 || <tt>C1 /0 ii</tt> || <tt>11000001 11000mmm iiiiiiii</tt> || 3 || 3
|}
----
{{Anchor|ROR}}
=== ROR ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| ROR mem8, 1 || <tt>D0 /1</tt> || <tt>11010000 oo001rm</tt> || 2+ || 3
|-
| ROR mem8, CL || <tt>D2 /1</tt> || <tt>11010010 oo001rm</tt> || 2+ || 5
|-
| ROR mem8, imm8 || <tt>C0 /1 ii</tt> || <tt>11000000 oo001mmm iiiiiiii</tt> || 3+ || 5
|-
| ROR mem16, 1 || <tt>D1 /1</tt> || <tt>11010001 oo001rm</tt> || 2+ || 3
|-
| ROR mem16, CL || <tt>D3 /1</tt> || <tt>11010011 oo001rm</tt> || 2+ || 5
|-
| ROR mem16, imm8 || <tt>C1 /1 ii</tt> || <tt>11000001 oo001mmm iiiiiiii</tt> || 3+ || 5
|-
| ROR reg8, 1 || <tt>D0 /1</tt> || <tt>11010000 11001rm</tt> || 2 || 1
|-
| ROR reg8, CL || <tt>D2 /1</tt> || <tt>11010010 11001rm</tt> || 2 || 3
|-
| ROR reg8, imm8 || <tt>C0 /1 ii</tt> || <tt>11000000 11001mmm iiiiiiii</tt> || 3 || 3
|-
| ROR reg16, 1 || <tt>D1 /1</tt> || <tt>11010001 11001rm</tt> || 2 || 1
|-
| ROR reg16, CL || <tt>D3 /1</tt> || <tt>11010011 11001rm</tt> || 2 || 3
|-
| ROR reg16, imm8 || <tt>C1 /1 ii</tt> || <tt>11000001 11001mmm iiiiiiii</tt> || 3 || 3
|}
----
{{Anchor|SAHF}}
=== SAHF ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| SAHF || <tt>9E</tt> || <tt>10011110</tt> || 1 || 4
|}
----
{{Anchor|SAR}}
=== SAR ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| SAR mem8, 1 || <tt>D0 /7</tt> || <tt>11010000 oo111rm</tt> || 2+ || 3
|-
| SAR mem8, CL || <tt>D2 /7</tt> || <tt>11010010 oo111rm</tt> || 2+ || 5
|-
| SAR mem8, imm8 || <tt>C0 /7 ii</tt> || <tt>11000000 oo111mmm iiiiiiii</tt> || 3+ || 5
|-
| SAR mem16, 1 || <tt>D1 /7</tt> || <tt>11010001 oo111rm</tt> || 2+ || 3
|-
| SAR mem16, CL || <tt>D3 /7</tt> || <tt>11010011 oo111rm</tt> || 2+ || 5
|-
| SAR mem16, imm8 || <tt>C1 /7 ii</tt> || <tt>11000001 oo111mmm iiiiiiii</tt> || 3+ || 5
|-
| SAR reg8, 1 || <tt>D0 /7</tt> || <tt>11010000 11111rm</tt> || 2 || 1
|-
| SAR reg8, CL || <tt>D2 /7</tt> || <tt>11010010 11111rm</tt> || 2 || 3
|-
| SAR reg8, imm8 || <tt>C0 /7 ii</tt> || <tt>11000000 11111mmm iiiiiiii</tt> || 3 || 3
|-
| SAR reg16, 1 || <tt>D1 /7</tt> || <tt>11010001 11111rm</tt> || 2 || 1
|-
| SAR reg16, CL || <tt>D3 /7</tt> || <tt>11010011 11111rm</tt> || 2 || 3
|-
| SAR reg16, imm8 || <tt>C1 /7 ii</tt> || <tt>11000001 11111mmm iiiiiiii</tt> || 3 || 3
|}
----
{{Anchor|SBB}}
=== SBB ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| SBB AL, imm || <tt>1C ii</tt> || <tt>00011100 iiiiiiii</tt> || 2 || 1
|-
| SBB AX, imm || <tt>1D ii ii</tt> || <tt>00011101 iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| SBB mem8, imm8 || <tt>80 /3 ii</tt> || <tt>10000000 oo011mmm iiiiiiii</tt> || 3+ || 3
|-
| SBB mem16, imm16 || <tt>81 /3 ii ii</tt> || <tt>10000001 oo011mmm iiiiiiii iiiiiiii</tt> || 4+ || 3
|-
| SBB mem16, simm8 || <tt>83 /3 ii</tt> || <tt>10000011 oo011mmm iiiiiiii</tt> || 3+ || 3
|-
| SBB mem8, reg8 || <tt>18 /r</tt> || <tt>00011000 oorrrmmm</tt> || 2+ || 3
|-
| SBB mem16, reg16 || <tt>19 /r</tt> || <tt>00011001 oorrrmmm</tt> || 2+ || 3
|-
| SBB reg8, imm8 || <tt>80 /3 ii</tt> || <tt>10000000 11011mmm iiiiiiii</tt> || 3 || 1
|-
| SBB reg16, imm16 || <tt>81 /3 ii ii</tt> || <tt>10000001 11011mmm iiiiiiii iiiiiiii</tt> || 4 || 1
|-
| SBB reg16, simm8 || <tt>83 /3 ii</tt> || <tt>10000011 11011mmm iiiiiiii</tt> || 3 || 1
|-
| SBB reg8, mem8 || <tt>1A /r</tt> || <tt>00011010 oorrrmmm</tt> || 2+ || 2
|-
| SBB reg16, mem16 || <tt>1B /r</tt> || <tt>00011011 oorrrmmm</tt> || 2+ || 2
|-
| SBB reg8, reg8 || <tt>18 /r</tt> || <tt>000110.0 11rrrmmm</tt> || 2 || 1
|-
| SBB reg16, reg16 || <tt>19 /r</tt> || <tt>000110.1 11rrrmmm</tt> || 2 || 1
|}
----
{{Anchor|SCASB}}
{{Anchor|SCASW}}
=== SCASB/SCASW ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| SCASB || <tt>AE</tt> || <tt>10101110</tt> || 1 || 4
|-
| SCASW || <tt>AF</tt> || <tt>10101111</tt> || 1 || 4
|}
----
{{Anchor|SHL}}
=== SHL ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| SHL mem8, 1 || <tt>D0 /4</tt> || <tt>11010000 oo100rm</tt> || 2+ || 3
|-
| SHL mem8, CL || <tt>D2 /4</tt> || <tt>11010010 oo100rm</tt> || 2+ || 5
|-
| SHL mem8, imm8 || <tt>C0 /4 ii</tt> || <tt>11000000 oo100mmm iiiiiiii</tt> || 3+ || 5
|-
| SHL mem16, 1 || <tt>D1 /4</tt> || <tt>11010001 oo100rm</tt> || 2+ || 3
|-
| SHL mem16, CL || <tt>D3 /4</tt> || <tt>11010011 oo100rm</tt> || 2+ || 5
|-
| SHL mem16, imm8 || <tt>C1 /4 ii</tt> || <tt>11000001 oo100mmm iiiiiiii</tt> || 3+ || 5
|-
| SHL reg8, 1 || <tt>D0 /4</tt> || <tt>11010000 11100rm</tt> || 2 || 1
|-
| SHL reg8, CL || <tt>D2 /4</tt> || <tt>11010010 11100rm</tt> || 2 || 3
|-
| SHL reg8, imm8 || <tt>C0 /4 ii</tt> || <tt>11000000 11100mmm iiiiiiii</tt> || 3 || 3
|-
| SHL reg16, 1 || <tt>D1 /4</tt> || <tt>11010001 11100rm</tt> || 2 || 1
|-
| SHL reg16, CL || <tt>D3 /4</tt> || <tt>11010011 11100rm</tt> || 2 || 3
|-
| SHL reg16, imm8 || <tt>C1 /4 ii</tt> || <tt>11000001 11100mmm iiiiiiii</tt> || 3 || 3
|}
----
{{Anchor|SHR}}
=== SHR ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| SHR mem8, 1 || <tt>D0 /5</tt> || <tt>11010000 oo101rm</tt> || 2+ || 3
|-
| SHR mem8, CL || <tt>D2 /5</tt> || <tt>11010010 oo101rm</tt> || 2+ || 5
|-
| SHR mem8, imm8 || <tt>C0 /5 ii</tt> || <tt>11000000 oo101mmm iiiiiiii</tt> || 3+ || 5
|-
| SHR mem16, 1 || <tt>D1 /5</tt> || <tt>11010001 oo101rm</tt> || 2+ || 3
|-
| SHR mem16, CL || <tt>D3 /5</tt> || <tt>11010011 oo101rm</tt> || 2+ || 5
|-
| SHR mem16, imm8 || <tt>C1 /5 ii</tt> || <tt>11000001 oo101mmm iiiiiiii</tt> || 3+ || 5
|-
| SHR reg8, 1 || <tt>D0 /5</tt> || <tt>11010000 11101rm</tt> || 2 || 1
|-
| SHR reg8, CL || <tt>D2 /5</tt> || <tt>11010010 11101rm</tt> || 2 || 3
|-
| SHR reg8, imm8 || <tt>C0 /5 ii</tt> || <tt>11000000 11101mmm iiiiiiii</tt> || 3 || 3
|-
| SHR reg16, 1 || <tt>D1 /5</tt> || <tt>11010001 11101rm</tt> || 2 || 1
|-
| SHR reg16, CL || <tt>D3 /5</tt> || <tt>11010011 11101rm</tt> || 2 || 3
|-
| SHR reg16, imm8 || <tt>C1 /5 ii</tt> || <tt>11000001 11101mmm iiiiiiii</tt> || 3 || 3
|}
----
{{Anchor|SS}}
=== SS ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| SS || <tt>36</tt> || <tt>00110110</tt> || 1 || 1
|}
----
{{Anchor|STC}}
=== STC ===
{| class="wikitable"
! Flag !! New value
|-
| [[NEC_V30MZ_flags#CF|CF - Carry]] || 1
|}
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| STC || <tt>F9</tt> || <tt>11111001</tt> || 1 || 4
|}
----
{{Anchor|STD}}
=== STD ===
{| class="wikitable"
! Flag !! New value
|-
| [[NEC_V30MZ_flags#DF|DF - Direction]] || 1
|}
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| STD || <tt>FD</tt> || <tt>11111101</tt> || 1 || 4
|}
----
{{Anchor|STI}}
=== STI ===
{| class="wikitable"
! Flag !! New value
|-
| [[NEC_V30MZ_flags#IF|IF - Interrupt]] || 1
|}
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| STI || <tt>FB</tt> || <tt>11111011</tt> || 1 || 4
|}
----
{{Anchor|STOSB}}
{{Anchor|STOSW}}
=== STOSB/STOSW ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| STOSB || <tt>AA</tt> || <tt>10101010</tt> || 1 || 3
|-
| STOSW || <tt>AB</tt> || <tt>10101011</tt> || 1 || 3
|}
----
{{Anchor|SUB}}
=== SUB ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| SUB AL, imm || <tt>28 ii</tt> || <tt>00101100 iiiiiiii</tt> || 2 || 1
|-
| SUB AX, imm || <tt>29 ii ii</tt> || <tt>00101101 iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| SUB mem8, imm8 || <tt>80 /5 ii</tt> || <tt>10000000 oo101mmm iiiiiiii</tt> || 3+ || 3
|-
| SUB mem16, imm16 || <tt>81 /5 ii ii</tt> || <tt>10000001 oo101mmm iiiiiiii iiiiiiii</tt> || 4+ || 3
|-
| SUB mem16, simm8 || <tt>83 /5 ii</tt> || <tt>10000011 oo101mmm iiiiiiii</tt> || 3+ || 3
|-
| SUB mem8, reg8 || <tt>28 /r</tt> || <tt>00101000 oorrrmmm</tt> || 2+ || 3
|-
| SUB mem16, reg16 || <tt>29 /r</tt> || <tt>00101001 oorrrmmm</tt> || 2+ || 3
|-
| SUB reg8, imm8 || <tt>80 /5 ii</tt> || <tt>10000000 11101mmm iiiiiiii</tt> || 3 || 1
|-
| SUB reg16, imm16 || <tt>81 /5 ii ii</tt> || <tt>10000001 11101mmm iiiiiiii iiiiiiii</tt> || 4 || 1
|-
| SUB reg16, simm8 || <tt>83 /5 ii</tt> || <tt>10000011 11101mmm iiiiiiii</tt> || 3 || 1
|-
| SUB reg8, mem8 || <tt>2A /r</tt> || <tt>00101010 oorrrmmm</tt> || 2+ || 2
|-
| SUB reg16, mem16 || <tt>2B /r</tt> || <tt>00101011 oorrrmmm</tt> || 2+ || 2
|-
| SUB reg8, reg8 || <tt>28 /r</tt> || <tt>001010.0 11rrrmmm</tt> || 2 || 1
|-
| SUB reg16, reg16 || <tt>29 /r</tt> || <tt>001010.1 11rrrmmm</tt> || 2 || 1
|}
----
{{Anchor|TEST}}
=== TEST ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| TEST AL, imm || <tt>A8 ii</tt> || <tt>10101000 iiiiiiii</tt> || 2 || 1
|-
| TEST AX, imm || <tt>A9 ii ii</tt> || <tt>10101001 iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| TEST mem8, imm8 || <tt>F6 /0 ii</tt> || <tt>11110110 oo000mmm iiiiiiii</tt> || 3+ || 2
|-
| TEST mem16, imm16 || <tt>F7 /0 ii ii</tt> || <tt>11110111 oo000mmm iiiiiiii iiiiiiii</tt> || 4+ || 2
|-
| TEST mem8, reg8<br/>TEST reg8, mem8 || <tt>84 /r</tt> || <tt>10000100 oorrrmmm</tt> || 2+ || 2
|-
| TEST mem16, reg16<br/>TEST reg16, mem16 || <tt>85 /r</tt> || <tt>10000101 oorrrmmm</tt> || 2+ || 2
|-
| TEST reg8, imm8 || <tt>F6 /0 ii</tt> || <tt>11110110 11000mmm iiiiiiii</tt> || 3 || 1
|-
| TEST reg16, imm16 || <tt>F7 /0 ii ii</tt> || <tt>11110111 11000mmm iiiiiiii iiiiiiii</tt> || 4 || 1
|-
| TEST reg8, reg8 || <tt>84 /r</tt> || <tt>10000100 11rrrmmm</tt> || 2 || 1
|-
| TEST reg16, reg16 || <tt>85 /r</tt> || <tt>10000101 11rrrmmm</tt> || 2 || 1
|}
----
{{Anchor|XCHG}}
=== XCHG ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| XCHG AX, reg16<br/>XCHG reg16, AX || <tt>9x</tt> || <tt>10010rrr</tt> || 1 || 3
|-
| XCHG mem8, reg8<br/>XCHG reg8, mem8 || <tt>86 /r</tt> || <tt>10000110 oorrrmmm</tt> || 2+ || 5
|-
| XCHG mem16, reg16<br/>XCHG reg16, mem16 || <tt>87 /r</tt> || <tt>10000111 oorrrmmm</tt> || 2+ || 5
|-
| XCHG reg8, reg8 || <tt>86 /r</tt> || <tt>10000110 11rrrmmm</tt> || 2+ || 3
|-
| XCHG reg16, reg16 || <tt>87 /r</tt> || <tt>10000111 11rrrmmm</tt> || 2+ || 3
|}
----
{{Anchor|XLAT}}
=== XLAT ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| XLAT || <tt>D7</tt> || <tt>11010111</tt> || 1 || 5
|}
----
{{Anchor|XOR}}
=== XOR ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| XOR AL, imm || <tt>34 ii</tt> || <tt>00110100 iiiiiiii</tt> || 2 || 1
|-
| XOR AX, imm || <tt>35 ii ii</tt> || <tt>00110101 iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| XOR mem8, imm8 || <tt>80 /6 ii</tt> || <tt>10000000 oo110mmm iiiiiiii</tt> || 3+ || 3
|-
| XOR mem16, imm16 || <tt>81 /6 ii ii</tt> || <tt>10000001 oo110mmm iiiiiiii iiiiiiii</tt> || 4+ || 3
|-
| XOR mem16, simm8 || <tt>83 /6 ii</tt> || <tt>10000011 oo110mmm iiiiiiii</tt> || 3+ || 3
|-
| XOR mem8, reg8 || <tt>30 /r</tt> || <tt>00110000 oorrrmmm</tt> || 2+ || 3
|-
| XOR mem16, reg16 || <tt>31 /r</tt> || <tt>00110001 oorrrmmm</tt> || 2+ || 3
|-
| XOR reg8, imm8 || <tt>80 /6 ii</tt> || <tt>10000000 11110mmm iiiiiiii</tt> || 3 || 1
|-
| XOR reg16, imm16 || <tt>81 /6 ii ii</tt> || <tt>10000001 11110mmm iiiiiiii iiiiiiii</tt> || 4 || 1
|-
| XOR reg16, simm8 || <tt>83 /6 ii</tt> || <tt>10000011 11110mmm iiiiiiii</tt> || 3 || 1
|-
| XOR reg8, mem8 || <tt>32 /r</tt> || <tt>00110010 oorrrmmm</tt> || 2+ || 2
|-
| XOR reg16, mem16 || <tt>33 /r</tt> || <tt>00110011 oorrrmmm</tt> || 2+ || 2
|-
| XOR reg8, reg8 || <tt>30 /r</tt> || <tt>001100.0 11rrrmmm</tt> || 2 || 1
|-
| XOR reg16, reg16 || <tt>31 /r</tt> || <tt>001100.1 11rrrmmm</tt> || 2 || 1
|}
== Notes ==
<references />
6107727191d4e552a94f26b13baf9cd1976a66a2
543
542
2025-02-24T18:33:22Z
Asie
351
wikitext
text/x-wiki
__NOTOC__
Note that this page is a work in progress.
{| class="wikitable" style="text-align: center"
|+ Official V30MZ (80186) Instructions
|-
| [[#AAA|AAA]] || [[#AAD|AAD]] || [[#AAM|AAM]] || [[#AAS|AAS]] || [[#ADC|ADC]] || [[#ADD|ADD]] || [[#AND|AND]] || [[#BOUND|BOUND]] || [[#CALL|CALL]] || [[#CBW|CBW]] || [[#CLC|CLC]]
|-
| [[#CLD|CLD]] || [[#CLI|CLI]] || [[#CMC|CMC]] || [[#CMP|CMP]] || [[#CMPSB|CMPSB]] || [[#CMPSW|CMPSW]] || [[#CS|CS]] || [[#CWD|CWD]] || [[#DAA|DAA]] || [[#DAS|DAS]] || [[#DEC|DEC]]
|-
| [[#DIV|DIV]] || [[#DS|DS]] || [[#ENTER|ENTER]] || [[#ES|ES]] || [[#HLT|HLT]] || [[#IDIV|IDIV]] || [[#IMUL|IMUL]] || [[#IN|IN]] || [[#INC|INC]] || [[#INSB|INSB]] || [[#INSW|INSW]]
|-
| [[#INT|INT]] || [[#INTO|INTO]] || [[#IRET|IRET]] || [[#JA|JA]] || [[#JBE|JBE]] || [[#JC|JC]] || [[#JCXZ|JCXZ]] || [[#JG|JG]] || [[#JGE|JGE]] || [[#JL|JL]] || [[#JLE|JLE]]
|-
| [[#JMP|JMP]] || [[#JNC|JNC]] || [[#JNO|JNO]] || [[#JNP|JNP]] || [[#JNS|JNS]] || [[#JNZ|JNZ]] || [[#JO|JO]] || [[#JP|JP]] || [[#JS|JS]] || [[#JZ|JZ]] || [[#LAHF|LAHF]]
|-
| [[#LDS|LDS]] || [[#LEA|LEA]] || [[#LEAVE|LEAVE]] || [[#LES|LES]] || [[#LOCK|LOCK]] || [[#LODSB|LODSB]] || [[#LODSW|LODSW]] || [[#LOOP|LOOP]] || [[#LOOPE|LOOPE]] || [[#LOOPNE|LOOPNE]] || [[#MOV|MOV]]
|-
| [[#MOVSB|MOVSB]] || [[#MOVSW|MOVSW]] || [[#MUL|MUL]] || [[#NEG|NEG]] || [[#NOP|NOP]] || [[#NOT|NOT]] || [[#OR|OR]] || [[#OUT|OUT]] || [[#OUTSB|OUTSB]] || [[#OUTSW|OUTSW]] || [[#POLL|POLL]]
|-
| [[#POP|POP]] || [[#POPA|POPA]] || [[#POPF|POPF]] || [[#PUSH|PUSH]] || [[#PUSHA|PUSHA]] || [[#PUSHF|PUSHF]] || [[#RCL|RCL]] || [[#RCR|RCR]] || [[#REP|REP]] || [[#REPNE|REPNE]] || [[#RET|RET]]
|-
| [[#RETF|RETF]] || [[#ROL|ROL]] || [[#ROR|ROR]] || [[#SAHF|SAHF]] || [[#SAR|SAR]] || [[#SBB|SBB]] || [[#SCASB|SCASB]] || [[#SCASW|SCASW]] || [[#SHL|SHL]] || [[#SHR|SHR]] || [[#SS|SS]]
|-
| [[#STC|STC]] || [[#STD|STD]] || [[#STI|STI]] || [[#STOSB|STOSB]] || [[#STOSW|STOSW]] || [[#SUB|SUB]] || [[#TEST|TEST]] || [[#XCHG|XCHG]] || [[#XLAT|XLAT]] || [[#XOR|XOR]]
|}
{| class="mw-collapsible mw-collapsed wikitable sortable" style="width: 340px;"
|+ style="white-space:nowrap; border:1px solid; padding:3px; border-color:rgb(162, 169, 177); background-color:rgb(234, 236, 240);" | Intel <-> NEC mnemonic translation table
!Intel
!NEC
|-
| [[#AAA|AAA]]
| [[#AAA|ADJBA]]
|-
| [[#AAD|AAD]]
| [[#AAD|CVTDB]]
|-
| [[#AAM|AAM]]
| [[#AAM|CVTBD]]
|-
| [[#AAS|AAS]]
| [[#AAS|ADJBS]]
|-
| [[#ADC|ADC]]
| [[#ADC|ADDC]]
|-
| [[#ADD|ADD]]
| [[#ADD|ADD]]
|-
| [[#AND|AND]]
| [[#AND|AND]]
|-
| [[#BOUND|BOUND]]
| [[#BOUND|CHKIND]]
|-
| [[#CALL|CALL]]
| [[#CALL|CALL]]
|-
| [[#CBW|CBW]]
| [[#CBW|CVTBW]]
|-
| [[#CLC|CLC]]
| [[#CLC|CLR1 CY]]
|-
| [[#CLD|CLD]]
| [[#CLD|CLR1 DIR]]
|-
| [[#CLI|CLI]]
| [[#CLI|DI]]
|-
| [[#CMC|CMC]]
| [[#CMC|NOT1 CY]]
|-
| [[#CMP|CMP]]
| [[#CMP|CMP]]
|-
| [[#CMPSB|CMPSB]]
| [[#CMPSB|CMPBKB]]
|-
| [[#CMPSW|CMPSW]]
| [[#CMPSW|CMPBKW]]
|-
| [[#CS|CS]]
| [[#CS|PS]]
|-
| [[#CWD|CWD]]
| [[#CWD|CVTWL]]
|-
| [[#DAA|DAA]]
| [[#DAA|ADJ4A]]
|-
| [[#DAS|DAS]]
| [[#DAS|ADJ4S]]
|-
| [[#DEC|DEC]]
| [[#DEC|DEC]]
|-
| [[#DIV|DIV]]
| [[#DIV|DIVU]]
|-
| [[#DS|DS]]
| [[#DS|DS0]]
|-
| [[#ENTER|ENTER]]
| [[#ENTER|PREPARE]]
|-
| [[#ES|ES]]
| [[#ES|DS1]]
|-
| [[#HLT|HLT]]
| [[#HLT|HALT]]
|-
| [[#IDIV|IDIV]]
| [[#IDIV|DIV]]
|-
| [[#IMUL|IMUL]]
| [[#IMUL|MUL]]
|-
| [[#IN|IN]]
| [[#IN|IN]]
|-
| [[#INC|INC]]
| [[#INC|INC]]
|-
| [[#INSB|INSB]]
| [[#INSB|INMB]]
|-
| [[#INSW|INSW]]
| [[#INSW|INMW]]
|-
| [[#INT|INT]]
| [[#INT|BRK]]
|-
| [[#INTO|INTO]]
| [[#INTO|BRKV]]
|-
| [[#IRET|IRET]]
| [[#IRET|RETI]]
|-
| [[#JA|JA]]
| [[#JA|BH]]
|-
| [[#JBE|JBE]]
| [[#JBE|BNH]]
|-
| [[#JC|JC/JB]]
| [[#JC|BC/BL]]
|-
| [[#JCXZ|JCXZ]]
| [[#JCXZ|BCWZ]]
|-
| [[#JG|JG]]
| [[#JG|BGT]]
|-
| [[#JGE|JGE]]
| [[#JGE|BGE]]
|-
| [[#JL|JL]]
| [[#JL|BLT]]
|-
| [[#JLE|JLE]]
| [[#JLE|BLE]]
|-
| [[#JMP|JMP]]
| [[#JMP|BR]]
|-
| [[#JNC|JNC/JAE]]
| [[#JNC|BNC/BNL]]
|-
| [[#JNO|JNO]]
| [[#JNO|BNV]]
|-
| [[#JNP|JNP]]
| [[#JNP|BPO]]
|-
| [[#JNS|JNS]]
| [[#JNS|BP]]
|-
| [[#JNZ|JNZ/JNE]]
| [[#JNZ|BNZ/BNE]]
|-
| [[#JO|JO]]
| [[#JO|BV]]
|-
| [[#JP|JP]]
| [[#JP|BPE]]
|-
| [[#JS|JS]]
| [[#JS|BN]]
|-
| [[#JZ|JZ/JE]]
| [[#JZ|BZ/BE]]
|-
| [[#LAHF|LAHF]]
| [[#LAHF|MOV]]
|-
| [[#LDS|LDS]]
| [[#LDS|MOV]]
|-
| [[#LEA|LEA]]
| [[#LEA|LDEA]]
|-
| [[#LEAVE|LEAVE]]
| [[#LEAVE|DISPOSE]]
|-
| [[#LES|LES]]
| [[#LES|MOV]]
|-
| [[#LOCK|LOCK]]
| [[#LOCK|BUSLOCK]]
|-
| [[#LODSB|LODSB]]
| [[#LODSB|LDMB]]
|-
| [[#LODSW|LODSW]]
| [[#LODSW|LDMW]]
|-
| [[#LOOP|LOOP]]
| [[#LOOP|DBNZ]]
|-
| [[#LOOPE|LOOPE]]
| [[#LOOPE|DBNZE]]
|-
| [[#LOOPNE|LOOPNE]]
| [[#LOOPNE|DBNZNE]]
|-
| [[#MOV|MOV]]
| [[#MOV|MOV]]
|-
| [[#MOVSB|MOVSB]]
| [[#MOVSB|MOVBKB]]
|-
| [[#MOVSW|MOVSW]]
| [[#MOVSW|MOVBKW]]
|-
| [[#MUL|MUL]]
| [[#MUL|MULU]]
|-
| [[#NEG|NEG]]
| [[#NEG|NEG]]
|-
| [[#NOP|NOP]]
| [[#NOP|NOP]]
|-
| [[#NOT|NOT]]
| [[#NOT|NOT]]
|-
| [[#OR|OR]]
| [[#OR|OR]]
|-
| [[#OUT|OUT]]
| [[#OUT|OUT]]
|-
| [[#OUTSB|OUTSB]]
| [[#OUTSB|OUTM]]
|-
| [[#OUTSW|OUTSW]]
| [[#OUTSW|OUTM]]
|-
| [[#POLL|POLL]]
| [[#POLL|POLL]]
|-
| [[#POP|POP]]
| [[#POP|POP]]
|-
| [[#POPA|POPA]]
| [[#POPA|POP]]
|-
| [[#POPF|POPF]]
| [[#POPF|POP]]
|-
| [[#PUSH|PUSH]]
| [[#PUSH|PUSH]]
|-
| [[#PUSHA|PUSHA]]
| [[#PUSHA|PUSH]]
|-
| [[#PUSHF|PUSHF]]
| [[#PUSHF|PUSH]]
|-
| [[#RCL|RCL]]
| [[#RCL|ROLC]]
|-
| [[#RCR|RCR]]
| [[#RCR|RORC]]
|-
| [[#REP|REP/REPE/REPZ]]
| [[#REP|REP/REPE/REPZ]]
|-
| [[#REPNE|REPNE/REPNZ]]
| [[#REPNE|REPNE/REPNZ]]
|-
| [[#RET|RET]]
| [[#RET|RET]]
|-
| [[#RETF|RETF]]
| [[#RETF|RET]]
|-
| [[#ROL|ROL]]
| [[#ROL|ROL]]
|-
| [[#ROR|ROR]]
| [[#ROR|ROR]]
|-
| [[#SAHF|SAHF]]
| [[#SAHF|MOV]]
|-
| [[#SAR|SAR]]
| [[#SAR|SHRA]]
|-
| [[#SBB|SBB]]
| [[#SBB|SUBC]]
|-
| [[#SCASB|SCASB]]
| [[#SCASB|CMPMB]]
|-
| [[#SCASW|SCASW]]
| [[#SCASW|CMPMW]]
|-
| [[#SHL|SHL]]
| [[#SHL|SHL]]
|-
| [[#SHR|SHR]]
| [[#SHR|SHR]]
|-
| [[#SS|SS]]
| [[#SS|SS]]
|-
| [[#STC|STC]]
| [[#STC|SET1 CY]]
|-
| [[#STD|STD]]
| [[#STD|SET1 DIR]]
|-
| [[#STI|STI]]
| [[#STI|EI]]
|-
| [[#STOSB|STOSB]]
| [[#STOSB|STMB]]
|-
| [[#STOSW|STOSW]]
| [[#STOSW|STMW]]
|-
| [[#SUB|SUB]]
| [[#SUB|SUB]]
|-
| [[#TEST|TEST]]
| [[#TEST|TEST]]
|-
| [[#XCHG|XCHG]]
| [[#XCHG|XCH]]
|-
| [[#XLAT|XLAT]]
| [[#XLAT|TRANS]]
|-
| [[#XOR|XOR]]
| [[#XOR|XOR]]
|}
== Official instructions by type ==
{| class="wikitable sortable" style="text-align: center"
!Type
!colspan=16 class="unsortable" | Instructions
|-
| style="text-align:left;" | Memory
| style="" | [[#MOV|MOV]]
| style="" | [[#XCHG|XCHG]]
| style="" | [[#XLAT|XLAT]]
| style="" | [[#LEA|LEA]]
| style="border-right:none;" | [[#LDS|LDS]]
| style="border-left:none;" | [[#LES|LES]]
| style="border-right:none;" | [[#IN|IN]]
| style="border-left:none;" | [[#OUT|OUT]]
| colspan="8" |
|-
| style="text-align:left;" | Ports
| style="border-right:none;" | [[#IN|IN]]
| style="border-left:none;" | [[#OUT|OUT]]
| style="border-right:none;" | [[#INSB|INSB]]
| style="border-left:none;" | [[#OUTSB|OUTSB]]
| style="border-right:none;" | [[#INSW|INSW]]
| style="border-left:none;" | [[#OUTSW|OUTSW]]
| colspan="10" |
|-
| style="text-align:left;" | Arithmetic
| style="border-right:none;" | [[#ADD|ADD]]
| style="border-left:none;" | [[#SUB|SUB]]
| style="border-right:none;" | [[#ADC|ADC]]
| style="border-left:none;" | [[#SBB|SBB]]
| style="border-right:none;" | [[#INC|INC]]
| style="border-left:none;" | [[#DEC|DEC]]
| style="border-right:none;" | [[#MUL|MUL]]
| style="border-left:none;" | [[#DIV|DIV]]
| style="border-right:none;" | [[#IMUL|IMUL]]
| style="border-left:none;" | [[#IDIV|IDIV]]
| style="" | [[#CMP|CMP]]
| style="" | [[#NEG|NEG]]
| colspan="4" |
|-
| style="text-align:left;" | Numeric
| style="" | [[#CBW|CBW]]
| style="" | [[#CWD|CWD]]
| style="" | [[#AAA|AAA]]
| style="" | [[#AAS|AAS]]
| style="" | [[#AAM|AAM]]
| style="" | [[#AAD|AAD]]
| style="" | [[#DAA|DAA]]
| style="" | [[#DAS|DAS]]
| colspan="8" |
|-
| style="text-align:left;" | Shift
| style="border-right:none;" | [[#ROL|ROL]]
| style="border-left:none;" | [[#ROR|ROR]]
| style="border-right:none;" | [[#RCL|RCL]]
| style="border-left:none;" | [[#RCR|RCR]]
| style="border-right:none;" | [[#SHL|SHL]]
| style="border-left:none;" | [[#SHR|SHR]]
| style="" | [[#SAR|SAR]]
| colspan="9" |
|-
| style="text-align:left;" | Bitwise
| style="" | [[#AND|AND]]
| style="" | [[#OR|OR]]
| style="" | [[#XOR|XOR]]
| style="" | [[#NOT|NOT]]
| style="" | [[#TEST|TEST]]
| colspan="11" |
|-
| style="text-align:left;" | Branch
| style="border-right:none;" | [[#JC|JC]]
| style="border-left:none;" | [[#JNC|JNC]]
| style="border-right:none;" | [[#JZ|JZ]]
| style="border-left:none;" | [[#JNZ|JNZ]]
| style="border-right:none;" | [[#JBE|JBE]]
| style="border-left:none;" | [[#JA|JA]]
| style="border-right:none;" | [[#JO|JO]]
| style="border-left:none;" | [[#JNO|JNO]]
| style="border-right:none;" | [[#JP|JP]]
| style="border-left:none;" | [[#JNP|JNP]]
| style="border-right:none;" | [[#JS|JS]]
| style="border-left:none;" | [[#JNS|JNS]]
| style="border-right:none;" | [[#JL|JL]]
| style="border-left:none;" | [[#JGE|JGE]]
| style="border-right:none;" | [[#JLE|JLE]]
| style="border-left:none;" | [[#JG|JG]]
|-
| style="text-align:left;" | Jump
| style="" | [[#JMP|JMP]]
| style="border-right:none;" | [[#CALL|CALL]]
| style="border-left:none;border-right:none;" | [[#RET|RET]]
| style="border-left:none;" | [[#RETF|RETF]]
| colspan="12" |
|-
| style="text-align:left;" | Loop
| style="" | [[#LOOP|LOOP]]
| style="" | [[#LOOPE|LOOPE]]
| style="" | [[#LOOPNE|LOOPNE]]
| colspan="13" |
|-
| style="text-align:left;" | Interrupt
| style="border-right:none;" | [[#INT|INT]]
| style="border-left:none;" | [[#IRET|IRET]]
| style="" | [[#INTO|INTO]]
| style="" | [[#HLT|HLT]]
| style="" | [[#BOUND|BOUND]]
| colspan="11" |
|-
| style="text-align:left;" | Stack
| style="border-right:none;" | [[#PUSH|PUSH]]
| style="border-left:none;" | [[#POP|POP]]
| style="border-right:none;" | [[#PUSHA|PUSHA]]
| style="border-left:none;" | [[#POPA|POPA]]
| style="border-right:none;" | [[#PUSHF|PUSHF]]
| style="border-left:none;" | [[#POPF|POPF]]
| colspan="10" |
|-
| style="text-align:left;" | Flags
| style="border-right:none;" | [[#CLC|CLC]]
| style="border-left:none;" | [[#STC|STC]]
| style="border-right:none;" | [[#CLD|CLD]]
| style="border-left:none;" | [[#STD|STD]]
| style="border-right:none;" | [[#CLI|CLI]]
| style="border-left:none;" | [[#STI|STI]]
| style="" | [[#CMC|CMC]]
| style="border-right:none;" | [[#LAHF|LAHF]]
| style="border-left:none;" | [[#SAHF|SAHF]]
| colspan="7" |
|-
| style="text-align:left;" | Prefix
| style="" | [[#CS|CS]]
| style="" | [[#DS|DS]]
| style="" | [[#ES|ES]]
| style="" | [[#SS|SS]]
| colspan="12" |
|-
| style="text-align:left;" | String
| style="border-right:none;" | [[#REP|REP]]
| style="border-left:none;border-right:none;" | [[#REP|REPE]]
| style="border-left:none;" | [[#REPNE|REPNE]]
| style="" | [[#MOVSB|MOVSB]]
| style="" | [[#MOVSW|MOVSW]]
| style="border-right:none;" | [[#LODSB|LODSB]]
| style="border-left:none;" | [[#STOSB|STOSB]]
| style="border-right:none;" | [[#LODSW|LODSW]]
| style="border-left:none;" | [[#STOSW|STOSW]]
| style="" | [[#CMPSB|CMPSB]]
| style="" | [[#SCASB|SCASB]]
| style="" | [[#CMPSW|CMPSW]]
| style="" | [[#SCASW|SCASW]]
| colspan="3" |
|-
| style="text-align:left;" | Other
| style="" | [[#NOP|NOP]]
| style="border-right:none;" | [[#ENTER|ENTER]]
| style="border-left:none;" | [[#LEAVE|LEAVE]]
| style="" | [[#LOCK|LOCK]]
| style="" | [[#POLL|POLL]]
| colspan="11" |
|}
== Instruction encoding ==
=== ModR/M byte ===
The ModR/M byte is used in most addressing modes which reference a memory location. This byte consists of three bitfield values:
* <tt>oo</tt> - M'''o'''de;
* <tt>rrr</tt> - Two possible functions:
** '''R'''egister (for addressing modes which require both a register and a register/memory operand),
** Opcode extension (for some opcodes' addressing modes which do not have such a requirement);
* <tt>mmm</tt> - Register/'''M'''emory.
The ''Mode'' and ''Register/Memory'' bitfields can refer to a memory location or to a register, as shown in the table below.
Some instructions define a second argument using the ''Register'' field. It is always interpreted as if ''Mode'' was equal to <tt>11</tt> and, as such, can refer to a register only.
{| class="wikitable" style="text-align: center"
! R/M \ Mode
! <tt>00</tt>
! <tt>01</tt>
! <tt>10</tt>
! <tt>11</tt> ''(byte)''
! <tt>11</tt> ''(word)''
|-
| <tt>000</tt>
| DS:[BX + SI]
| DS:[BX + SI + disp8]
| DS:[BX + SI + disp16]
| AL
| AX
|-
| <tt>001</tt>
| DS:[BX + DI]
| DS:[BX + DI + disp8]
| DS:[BX + DI + disp16]
| CL
| CX
|-
| <tt>010</tt>
| SS:[BP + SI]
| SS:[BP + SI + disp8]
| SS:[BP + SI + disp16]
| DL
| DX
|-
| <tt>011</tt>
| SS:[BP + DI]
| SS:[BP + DI + disp8]
| SS:[BP + DI + disp16]
| BL
| BX
|-
| <tt>100</tt>
| DS:[SI]
| DS:[SI + disp8]
| DS:[SI + disp16]
| AH
| SP
|-
| <tt>101</tt>
| DS:[DI]
| DS:[DI + disp8]
| DS:[DI + disp16]
| CH
| BP
|-
| <tt>110</tt>
| ''DS:[disp16]''
| SS:[BP + disp8]
| SS:[BP + disp16]
| DH
| SI
|-
| <tt>111</tt>
| DS:[BX]
| DS:[BX + disp8]
| DS:[BX + disp16]
| BH
| DI
|}
Displacements are either 8-bit (disp8) or 16-bit (disp16) signed values and they always immediately follow the ModR/M byte. Note that (<tt>oo</tt> = <tt>00</tt>, <tt>mmm</tt> = <tt>110</tt>) is a special case, in which the ''disp16'' value is used directly as a near pointer.
The instruction encoding lists below refer to this byte as <tt>oorrrmmm</tt> (binary), <tt>/r</tt> (hexadecimal) or <tt>/0</tt> (hexademical, <tt>rrr</tt> used as function <tt>0</tt>).
== Official instructions ==
{{Anchor|AAA}}
=== AAA ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| AAA || <tt>37</tt> || <tt>00110111</tt> || 1 || 9
|}
----
{{Anchor|AAD}}
=== AAD ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| AAD imm8 || <tt>B5 ii</tt> || <tt>11010100 iiiiiiii</tt> || 2 || 6
|}
----
{{Anchor|AAM}}
=== AAM ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| AAM imm8 || <tt>B4 ii</tt> || <tt>11010100 iiiiiiii</tt> || 2 || 17
|}
----
{{Anchor|AAS}}
=== AAS ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| AAS || <tt>3F</tt> || <tt>00111111</tt> || 1 || 9
|}
----
{{Anchor|ADC}}
=== ADC ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| ADC AL, imm || <tt>14 ii</tt> || <tt>00010100 iiiiiiii</tt> || 2 || 1
|-
| ADC AX, imm || <tt>15 ii ii</tt> || <tt>00010101 iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| ADC mem8, imm8 || <tt>80 /2 ii</tt> || <tt>10000000 oo010mmm iiiiiiii</tt> || 3+ || 3
|-
| ADC mem16, imm16 || <tt>81 /2 ii ii</tt> || <tt>10000001 oo010mmm iiiiiiii iiiiiiii</tt> || 4+ || 3
|-
| ADC mem16, simm8 || <tt>83 /2 ii</tt> || <tt>10000011 oo010mmm iiiiiiii</tt> || 3+ || 3
|-
| ADC mem8, reg8 || <tt>10 /r</tt> || <tt>00010000 oorrrmmm</tt> || 2+ || 3
|-
| ADC mem16, reg16 || <tt>11 /r</tt> || <tt>00010001 oorrrmmm</tt> || 2+ || 3
|-
| ADC reg8, imm8 || <tt>80 /2 ii</tt> || <tt>10000000 11010mmm iiiiiiii</tt> || 3 || 1
|-
| ADC reg16, imm16 || <tt>81 /2 ii ii</tt> || <tt>10000001 11010mmm iiiiiiii iiiiiiii</tt> || 4 || 1
|-
| ADC reg16, simm8 || <tt>83 /2 ii</tt> || <tt>10000011 11010mmm iiiiiiii</tt> || 3 || 1
|-
| ADC reg8, mem8 || <tt>12 /r</tt> || <tt>00010010 oorrrmmm</tt> || 2+ || 2
|-
| ADC reg16, mem16 || <tt>13 /r</tt> || <tt>00010011 oorrrmmm</tt> || 2+ || 2
|-
| ADC reg8, reg8 || <tt>10 /r</tt> || <tt>000100.0 11rrrmmm</tt> || 2 || 1
|-
| ADC reg16, reg16 || <tt>11 /r</tt> || <tt>000100.1 11rrrmmm</tt> || 2 || 1
|}
----
{{Anchor|ADD}}
=== ADD ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| ADD AL, imm || <tt>04 ii</tt> || <tt>00000100 iiiiiiii</tt> || 2 || 1
|-
| ADD AX, imm || <tt>05 ii ii</tt> || <tt>00000101 iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| ADD mem8, imm8 || <tt>80 /0 ii</tt> || <tt>10000000 oo000mmm iiiiiiii</tt> || 3+ || 3
|-
| ADD mem16, imm16 || <tt>81 /0 ii ii</tt> || <tt>10000001 oo000mmm iiiiiiii iiiiiiii</tt> || 4+ || 3
|-
| ADD mem16, simm8 || <tt>83 /0 ii</tt> || <tt>10000011 oo000mmm iiiiiiii</tt> || 3+ || 3
|-
| ADD mem8, reg8 || <tt>00 /r</tt> || <tt>00000000 oorrrmmm</tt> || 2+ || 3
|-
| ADD mem16, reg16 || <tt>01 /r</tt> || <tt>00000001 oorrrmmm</tt> || 2+ || 3
|-
| ADD reg8, imm8 || <tt>80 /0 ii</tt> || <tt>10000000 11000mmm iiiiiiii</tt> || 3 || 1
|-
| ADD reg16, imm16 || <tt>81 /0 ii ii</tt> || <tt>10000001 11000mmm iiiiiiii iiiiiiii</tt> || 4 || 1
|-
| ADD reg16, simm8 || <tt>83 /0 ii</tt> || <tt>10000011 11000mmm iiiiiiii</tt> || 3 || 1
|-
| ADD reg8, mem8 || <tt>02 /r</tt> || <tt>00000010 oorrrmmm</tt> || 2+ || 2
|-
| ADD reg16, mem16 || <tt>03 /r</tt> || <tt>00000011 oorrrmmm</tt> || 2+ || 2
|-
| ADD reg8, reg8 || <tt>00 /r</tt> || <tt>000000.0 11rrrmmm</tt> || 2 || 1
|-
| ADD reg16, reg16 || <tt>01 /r</tt> || <tt>000000.1 11rrrmmm</tt> || 2 || 1
|}
----
{{Anchor|AND}}
=== AND ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| AND AL, imm || <tt>24 ii</tt> || <tt>00100100 iiiiiiii</tt> || 2 || 1
|-
| AND AX, imm || <tt>25 ii ii</tt> || <tt>00100101 iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| AND mem8, imm8 || <tt>80 /4 ii</tt> || <tt>10000000 oo100mmm iiiiiiii</tt> || 3+ || 3
|-
| AND mem16, imm16 || <tt>81 /4 ii ii</tt> || <tt>10000001 oo100mmm iiiiiiii iiiiiiii</tt> || 4+ || 3
|-
| AND mem16, simm8 || <tt>83 /4 ii</tt> || <tt>10000011 oo100mmm iiiiiiii</tt> || 3+ || 3
|-
| AND mem8, reg8 || <tt>20 /r</tt> || <tt>00100000 oorrrmmm</tt> || 2+ || 3
|-
| AND mem16, reg16 || <tt>21 /r</tt> || <tt>00100001 oorrrmmm</tt> || 2+ || 3
|-
| AND reg8, imm8 || <tt>80 /4 ii</tt> || <tt>10000000 11100mmm iiiiiiii</tt> || 3 || 1
|-
| AND reg16, imm16 || <tt>81 /4 ii ii</tt> || <tt>10000001 11100mmm iiiiiiii iiiiiiii</tt> || 4 || 1
|-
| AND reg16, simm8 || <tt>83 /4 ii</tt> || <tt>10000011 11100mmm iiiiiiii</tt> || 3 || 1
|-
| AND reg8, mem8 || <tt>22 /r</tt> || <tt>00100010 oorrrmmm</tt> || 2+ || 2
|-
| AND reg16, mem16 || <tt>23 /r</tt> || <tt>00100011 oorrrmmm</tt> || 2+ || 2
|-
| AND reg8, reg8 || <tt>20 /r</tt> || <tt>001000.0 11rrrmmm</tt> || 2 || 1
|-
| AND reg16, reg16 || <tt>21 /r</tt> || <tt>001000.1 11rrrmmm</tt> || 2 || 1
|}
----
{{Anchor|BOUND}}
=== BOUND ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| BOUND reg16, mem16:16 || <tt>62 /r</tt> || <tt>01100010 oorrrmmm</tt> || 2+ || 13 (20 if condition met)
|}
----
{{Anchor|CALL}}
=== CALL ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| CALL ptr16:16 || <tt>CA oo oo ss ss</tt> || <tt>10011010 oooooooo oooooooo ssssssss ssssssss</tt> || 5 || 10
|-
| CALL mem16 || <tt>FF /2</tt> || <tt>11111111 oo010mmm</tt> || 2+ || 6
|-
| CALL mem16:16 || <tt>FF /3</tt> || <tt>11111111 oo011mmm</tt> || 2+ || 12
|-
| CALL reg16 || <tt>FF /2</tt> || <tt>11111111 11010mmm</tt> || 2 || 5
|-
| CALL rel16 || <tt>E8 ii ii</tt> || <tt>11101000 iiiiiiii iiiiiiii</tt> || 3 || 5
|}
----
{{Anchor|CBW}}
=== CBW ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| CBW || <tt>98</tt> || <tt>10011000</tt> || 1 || 1
|}
----
{{Anchor|CLC}}
=== CLC ===
{| class="wikitable"
! Flag !! New value
|-
| [[NEC_V30MZ_flags#CF|CF - Carry]] || 0
|}
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| CLC || <tt>F8</tt> || <tt>11111000</tt> || 1 || 4
|}
----
{{Anchor|CLD}}
=== CLD ===
{| class="wikitable"
! Flag !! New value
|-
| [[NEC_V30MZ_flags#DF|DF - Direction]] || 0
|}
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| CLD || <tt>FC</tt> || <tt>11111100</tt> || 1 || 4
|}
----
{{Anchor|CLI}}
=== CLI ===
{| class="wikitable"
! Flag !! New value
|-
| [[NEC_V30MZ_flags#IF|IF - Interrupt]] || 0
|}
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| CLI || <tt>FA</tt> || <tt>11111010</tt> || 1 || 4
|}
----
{{Anchor|CMC}}
=== CMC ===
{| class="wikitable"
! Flag !! New value
|-
| [[NEC_V30MZ_flags#CF|CF - Carry]] || !CF
|}
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| CMC || <tt>F5</tt> || <tt>11110101</tt> || 1 || 4
|}
----
{{Anchor|CMP}}
=== CMP ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| CMP AL, imm || <tt>3C ii</tt> || <tt>00111100 iiiiiiii</tt> || 2 || 1
|-
| CMP AX, imm || <tt>3D ii ii</tt> || <tt>00111101 iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| CMP mem8, imm8 || <tt>80 /7 ii</tt> || <tt>10000000 oo111mmm iiiiiiii</tt> || 3+ || 2
|-
| CMP mem16, imm16 || <tt>81 /7 ii ii</tt> || <tt>10000001 oo111mmm iiiiiiii iiiiiiii</tt> || 4+ || 2
|-
| CMP mem16, simm8 || <tt>83 /7 ii</tt> || <tt>10000011 oo111mmm iiiiiiii</tt> || 3+ || 2
|-
| CMP mem8, reg8 || <tt>38 /r</tt> || <tt>00111000 oorrrmmm</tt> || 2+ || 2
|-
| CMP mem16, reg16 || <tt>39 /r</tt> || <tt>00111001 oorrrmmm</tt> || 2+ || 2
|-
| CMP reg8, imm8 || <tt>80 /7 ii</tt> || <tt>10000000 11111mmm iiiiiiii</tt> || 3 || 1
|-
| CMP reg16, imm16 || <tt>81 /7 ii ii</tt> || <tt>10000001 11111mmm iiiiiiii iiiiiiii</tt> || 4 || 1
|-
| CMP reg16, simm8 || <tt>83 /7 ii</tt> || <tt>10000011 11111mmm iiiiiiii</tt> || 3 || 1
|-
| CMP reg8, mem8 || <tt>3A /r</tt> || <tt>00111010 oorrrmmm</tt> || 2+ || 2
|-
| CMP reg16, mem16 || <tt>3B /r</tt> || <tt>00111011 oorrrmmm</tt> || 2+ || 2
|-
| CMP reg8, reg8 || <tt>38 /r</tt> || <tt>001110.0 11rrrmmm</tt> || 2 || 1
|-
| CMP reg16, reg16 || <tt>39 /r</tt> || <tt>001110.1 11rrrmmm</tt> || 2 || 1
|}
----
{{Anchor|CMPSB}}
{{Anchor|CMPSW}}
=== CMPSB/CMPSW ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| CMPSB || <tt>A6</tt> || <tt>10100110</tt> || 1 || 6
|-
| CMPSW || <tt>A7</tt> || <tt>10100111</tt> || 1 || 6
|}
----
{{Anchor|CS}}
=== CS ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| CS || <tt>2E</tt> || <tt>00101110</tt> || 1 || 1
|}
----
{{Anchor|CWD}}
=== CWD ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| CWD || <tt>99</tt> || <tt>10011001</tt> || 1 || 1
|}
----
{{Anchor|DAA}}
=== DAA ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| DAA || <tt>27</tt> || <tt>00100111</tt> || 1 || 10
|}
----
{{Anchor|DAS}}
=== DAS ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| DAS || <tt>2F</tt> || <tt>00101111</tt> || 1 || 10
|}
----
{{Anchor|DEC}}
=== DEC ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| DEC mem8 || <tt>FE /1</tt> || <tt>11111110 oo001mmm</tt> || 2+ || 3
|-
| DEC mem16 || <tt>FF /1</tt> || <tt>11111111 oo001mmm</tt> || 2+ || 3
|-
| DEC reg8 || <tt>FE /1</tt> || <tt>11111110 11001mmm</tt> || 2+ || 1
|-
| DEC reg16 || <tt>4x</tt> || <tt>01001rrr</tt> || 1 || 1
|}
----
{{Anchor|DIV}}
=== DIV ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| DIV mem8 || <tt>F6 /6</tt> || <tt>11110110 oo110mmm</tt> || 2+ || 16
|-
| DIV mem16 || <tt>F7 /6</tt> || <tt>11111111 oo110mmm</tt> || 2+ || 24
|-
| DIV reg8 || <tt>F6 /6</tt> || <tt>11111110 11110mmm</tt> || 2 || 15
|-
| DIV reg16 || <tt>F7 /6</tt> || <tt>11111111 11110mmm</tt> || 2 || 23
|}
----
{{Anchor|DS}}
=== DS ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| DS || <tt>3E</tt> || <tt>00111110</tt> || 1 || 1
|}
----
{{Anchor|ENTER}}
=== ENTER ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| ENTER imm16, imm8 || <tt>C8 ii ii jj</tt> || <tt>11001000 iiiiiiii iiiiiiii jjjjjjjj</tt> || 3 || 8 (imm8 = 0)<br/>14 (imm8 = 1)<br/>15 + imm8 * 4 (imm8 >= 2)
|}
----
{{Anchor|ES}}
=== ES ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| ES || <tt>26</tt> || <tt>00100110</tt> || 1 || 1
|}
----
{{Anchor|HLT}}
=== HLT ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| HLT || <tt>F4</tt> || <tt>11110100</tt> || 1 || 9
|}
----
{{Anchor|IDIV}}
=== IDIV ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| IDIV mem8 || <tt>F6 /7</tt> || <tt>11110110 oo111mmm</tt> || 2+ || 18
|-
| IDIV mem16 || <tt>F7 /7</tt> || <tt>11111111 oo111mmm</tt> || 2+ || 25
|-
| IDIV reg8 || <tt>F6 /7</tt> || <tt>11111110 11111mmm</tt> || 2 || 17
|-
| IDIV reg16 || <tt>F7 /7</tt> || <tt>11111111 11111mmm</tt> || 2 || 24
|}
----
{{Anchor|IMUL}}
=== IMUL ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| IMUL mem8 || <tt>F6 /5</tt> || <tt>11110110 oo101mmm</tt> || 2+ || 4
|-
| IMUL mem16 || <tt>F7 /5</tt> || <tt>11111111 oo101mmm</tt> || 2+ || 4
|-
| IMUL reg8 || <tt>F6 /5</tt> || <tt>11111110 11101mmm</tt> || 2 || 3
|-
| IMUL reg16 || <tt>F7 /5</tt> || <tt>11111111 11101mmm</tt> || 2 || 3
|-
| IMUL reg16, mem16, imm16 || <tt>69 /r ii ii</tt> || <tt>11111111 oorrrmmm iiiiiiii iiiiiiii</tt> || 4 || 4
|-
| IMUL reg16, mem16, simm8 || <tt>6B /r ii</tt> || <tt>11111111 oorrrmmm iiiiiiii</tt> || 3 || 4
|-
| IMUL reg16, reg16, imm16 || <tt>69 /r ii ii</tt> || <tt>11111111 11rrrmmm iiiiiiii iiiiiiii</tt> || 4 || 3
|-
| IMUL reg16, reg16, simm8 || <tt>6B /r ii</tt> || <tt>11111111 11rrrmmm iiiiiiii</tt> || 3 || 3
|}
----
{{Anchor|IN}}
=== IN ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| IN AL, DX || <tt>EC</tt> || <tt>11101100</tt> || 1 || 6
|-
| IN AX, DX || <tt>ED</tt> || <tt>11101101</tt> || 1 || 6
|-
| IN AL, imm8 || <tt>E4 ii</tt> || <tt>11100100 iiiiiiii</tt> || 2 || 6
|-
| IN AX, imm8 || <tt>E5 ii</tt> || <tt>11100101 iiiiiiii</tt> || 2 || 6
|}
----
{{Anchor|INC}}
=== INC ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| INC mem8 || <tt>FE /0</tt> || <tt>11111110 oo000mmm</tt> || 2+ || 3
|-
| INC mem16 || <tt>FF /0</tt> || <tt>11111111 oo000mmm</tt> || 2+ || 3
|-
| INC reg8 || <tt>FE /0</tt> || <tt>11111110 11000mmm</tt> || 2+ || 1
|-
| INC reg16 || <tt>4x</tt> || <tt>01000rrr</tt> || 1 || 1
|}
----
{{Anchor|INSB}}
{{Anchor|INSW}}
=== INSB/INSW ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| INSB || <tt>6C</tt> || <tt>01101100</tt> || 1 || 6
|-
| INSW || <tt>6D</tt> || <tt>01101101</tt> || 1 || 6
|}
----
{{Anchor|INT}}
=== INT ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| INT 3 || <tt>CC</tt> || <tt>11001100</tt> || 1 || 9
|-
| INT imm8 || <tt>CD ii</tt> || <tt>11001101 iiiiiiii</tt> || 2 || 10
|}
----
{{Anchor|INTO}}
=== INTO ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| INTO || <tt>CE</tt> || <tt>11001110</tt> || 1 || 6 (13 if OF = 1)
|}
----
{{Anchor|IRET}}
=== IRET ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| IRET || <tt>CF</tt> || <tt>11001111</tt> || 1 || 10
|}
----
{{Anchor|JA}}
=== JA ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JA rel8 || <tt>77 ii</tt> || <tt>01110111 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JBE}}
=== JBE ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JA rel8 || <tt>76 ii</tt> || <tt>01110110 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JC}}
=== JC/JB ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JC rel8 || <tt>72 ii</tt> || <tt>01110010 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JCXZ}}
=== JCXZ ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JCXZ rel8 || <tt>E3 ii</tt> || <tt>11100011 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JG}}
=== JG ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JG rel8 || <tt>7F ii</tt> || <tt>01111111 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JGE}}
=== JGE ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JGE rel8 || <tt>7D ii</tt> || <tt>01111101 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JL}}
=== JL ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JL rel8 || <tt>7C ii</tt> || <tt>01111100 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JLE}}
=== JLE ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JLE rel8 || <tt>7E ii</tt> || <tt>01111110 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JMP}}
=== JMP ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JMP ptr16:16 || <tt>EA oo oo ss ss</tt> || <tt>11101010 oooooooo oooooooo ssssssss ssssssss</tt> || 5 || 7
|-
| JMP mem16 || <tt>FF /4</tt> || <tt>11111111 oo100mmm</tt> || 2+ || 5
|-
| JMP mem16:16 || <tt>FF /5</tt> || <tt>11111111 oo101mmm</tt> || 2+ || 10
|-
| JMP reg16 || <tt>FF /4</tt> || <tt>11111111 11100mmm</tt> || 2 || 4
|-
| JMP rel8 || <tt>EB ii</tt> || <tt>11101011 iiiiiiii</tt> || 2 || 4
|-
| JMP rel16 || <tt>E9 ii ii</tt> || <tt>11101001 iiiiiiii iiiiiiii</tt> || 3 || 4
|}
----
{{Anchor|JNC}}
=== JNC/JAE ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JNC rel8 || <tt>73 ii</tt> || <tt>01110011 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JNO}}
=== JNO ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JNO rel8 || <tt>71 ii</tt> || <tt>01110001 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JNP}}
=== JNP ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JNP rel8 || <tt>7B ii</tt> || <tt>01111011 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JNS}}
=== JNS ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JNS rel8 || <tt>79 ii</tt> || <tt>01111001 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JNZ}}
=== JNZ/JNE ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JNZ rel8 || <tt>75 ii</tt> || <tt>01110101 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JO}}
=== JO ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JO rel8 || <tt>70 ii</tt> || <tt>01110000 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JP}}
=== JP ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JP rel8 || <tt>7A ii</tt> || <tt>01111010 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JS}}
=== JS ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JS rel8 || <tt>78 ii</tt> || <tt>01111000 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JZ}}
=== JZ/JE ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JZ rel8 || <tt>74 ii</tt> || <tt>01110100 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|LAHF}}
=== LAHF ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| LAHF || <tt>9F</tt> || <tt>10011111</tt> || 1 || 2
|}
----
{{Anchor|LDS}}
=== LDS ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| LDS reg16, mem16 || <tt>C5 /r</tt> || <tt>11000101 oorrrmmm</tt> || 2+ || 6
|}
----
{{Anchor|LEA}}
=== LEA ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| LEA reg16, mem16 || <tt>8D /r</tt> || <tt>10001101 oorrrmmm</tt> || 2+ || 1
|}
----
{{Anchor|LEAVE}}
=== LEAVE ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| LEAVE || <tt>C9</tt> || <tt>11001001</tt> || 1 || 2
|}
----
{{Anchor|LES}}
=== LES ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| LES reg16, mem16 || <tt>C4 /r</tt> || <tt>11000100 oorrrmmm</tt> || 2+ || 6
|}
----
{{Anchor|LOCK}}
=== LOCK ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| LOCK || <tt>F0</tt> || <tt>11110000</tt> || 1 || 1
|}
----
{{Anchor|LODSB}}
{{Anchor|LODSW}}
=== LODSB/LODSW ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| LODSB || <tt>AC</tt> || <tt>10101100</tt> || 1 || 3
|-
| LODSW || <tt>AD</tt> || <tt>10101101</tt> || 1 || 3
|}
----
{{Anchor|LOOP}}
=== LOOP ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| LOOP rel8 || <tt>E2 ii</tt> || <tt>11100010 iiiiiiii</tt> || 2 || 2 (5 if branch taken)
|}
----
{{Anchor|LOOPE}}
=== LOOPE ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| LOOPE rel8 || <tt>E1 ii</tt> || <tt>11100001 iiiiiiii</tt> || 2 || 3 (6 if branch taken)
|}
----
{{Anchor|LOOPNE}}
=== LOOPNE ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| LOOPNE rel8 || <tt>E0 ii</tt> || <tt>11100000 iiiiiiii</tt> || 2 || 3 (6 if branch taken)
|}
----
{{Anchor|MOV}}
=== MOV ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| MOV AL, ptr16 || <tt>A0 ii ii</tt> || <tt>10100000 iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| MOV AX, ptr16 || <tt>A1 ii ii</tt> || <tt>10100001 iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| MOV mem8, imm8 || <tt>C6 /0 ii</tt> || <tt>11000110 oo000mmm iiiiiiii</tt> || 3+ || 1
|-
| MOV mem16, imm16 || <tt>C7 /0 ii ii</tt> || <tt>11000111 oo000mmm iiiiiiii iiiiiiii</tt> || 4+ || 1
|-
| MOV mem8, reg8 || <tt>84 /r</tt> || <tt>10001000 oorrrmmm</tt> || 2+ || 1
|-
| MOV mem16, reg16 || <tt>85 /r</tt> || <tt>10001001 oorrrmmm</tt> || 2+ || 1
|-
| MOV mem16, sreg16 || <tt>8C /r</tt> || <tt>10001100 oo0rrmmm</tt> || 2+ || 3
|-
| MOV ptr16, AL || <tt>A2 ii ii</tt> || <tt>10100010 iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| MOV ptr16, AX || <tt>A3 ii ii</tt> || <tt>10100011 iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| MOV reg8, imm8 || <tt>Bx ii</tt> || <tt>10110rrr iiiiiiii</tt> || 2 || 1
|-
| MOV reg8, imm8 || <tt>C6 /0 ii</tt> || <tt>11000110 11000mmm iiiiiiii</tt> || 3 || 1
|-
| MOV reg16, imm16 || <tt>Bx ii</tt> || <tt>10111rrr iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| MOV reg16, imm16 || <tt>C7 /0 ii ii</tt> || <tt>11000111 11000mmm iiiiiiii iiiiiiii</tt> || 4 || 1
|-
| MOV reg8, mem8 || <tt>8A /r</tt> || <tt>10001010 oorrrmmm</tt> || 2+ || 1
|-
| MOV reg16, mem16 || <tt>8B /r</tt> || <tt>10001011 oorrrmmm</tt> || 2+ || 1
|-
| MOV reg8, reg8 || <tt>88 /r</tt> || <tt>100010.0 11rrrmmm</tt> || 2 || 1
|-
| MOV reg16, reg16 || <tt>89 /r</tt> || <tt>100010.1 11rrrmmm</tt> || 2 || 1
|-
| MOV reg16, sreg16 || <tt>8C /r</tt> || <tt>10001100 110rrmmm</tt> || 2 || 1
|-
| MOV sreg16, mem16 || <tt>8E /r</tt> || <tt>10001110 oo0rrmmm</tt> || 2 || 3
|-
| MOV sreg16, reg16 || <tt>8E /r</tt> || <tt>10001110 110rrmmm</tt> || 2+ || 2
|}
----
{{Anchor|MOVSB}}
{{Anchor|MOVSW}}
=== MOVSB/MOVSW ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| MOVSB || <tt>A4</tt> || <tt>10100100</tt> || 1 || 5
|-
| MOVSW || <tt>A5</tt> || <tt>10100101</tt> || 1 || 5
|}
----
{{Anchor|MUL}}
=== MUL ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| MUL mem8 || <tt>F6 /4</tt> || <tt>11110110 oo100mmm</tt> || 2+ || 4
|-
| MUL mem16 || <tt>F7 /4</tt> || <tt>11111111 oo100mmm</tt> || 2+ || 4
|-
| MUL reg8 || <tt>F6 /4</tt> || <tt>11111110 11100mmm</tt> || 2 || 3
|-
| MUL reg16 || <tt>F7 /4</tt> || <tt>11111111 11100mmm</tt> || 2 || 3
|}
----
{{Anchor|NEG}}
=== NEG ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| NEG mem8 || <tt>F6 /3</tt> || <tt>11110110 oo011mmm</tt> || 2+ || 3
|-
| NEG mem16 || <tt>F7 /3</tt> || <tt>11111111 oo011mmm</tt> || 2+ || 3
|-
| NEG reg8 || <tt>F6 /3</tt> || <tt>11111110 11011mmm</tt> || 2 || 1
|-
| NEG reg16 || <tt>F7 /3</tt> || <tt>11111111 11011mmm</tt> || 2 || 1
|}
----
{{Anchor|NOP}}
=== NOP ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| NOP || <tt>90</tt> || <tt>10010000</tt> || 1 || 1
|}
----
{{Anchor|NOT}}
=== NOT ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| NOT mem8 || <tt>F6 /2</tt> || <tt>11110110 oo010mmm</tt> || 2+ || 3
|-
| NOT mem16 || <tt>F7 /2</tt> || <tt>11111111 oo010mmm</tt> || 2+ || 3
|-
| NOT reg8 || <tt>F6 /2</tt> || <tt>11111110 11010mmm</tt> || 2 || 1
|-
| NOT reg16 || <tt>F7 /2</tt> || <tt>11111111 11010mmm</tt> || 2 || 1
|}
----
{{Anchor|OR}}
=== OR ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| OR AL, imm || <tt>0C ii</tt> || <tt>00001100 iiiiiiii</tt> || 2 || 1
|-
| OR AX, imm || <tt>0D ii ii</tt> || <tt>00001101 iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| OR mem8, imm8 || <tt>80 /6 ii</tt> || <tt>10000000 oo001mmm iiiiiiii</tt> || 3+ || 3
|-
| OR mem16, imm16 || <tt>81 /6 ii ii</tt> || <tt>10000001 oo001mmm iiiiiiii iiiiiiii</tt> || 4+ || 3
|-
| OR mem16, simm8 || <tt>83 /6 ii</tt> || <tt>10000011 oo001mmm iiiiiiii</tt> || 3+ || 3
|-
| OR mem8, reg8 || <tt>08 /r</tt> || <tt>00001000 oorrrmmm</tt> || 2+ || 3
|-
| OR mem16, reg16 || <tt>09 /r</tt> || <tt>00001001 oorrrmmm</tt> || 2+ || 3
|-
| OR reg8, imm8 || <tt>80 /6 ii</tt> || <tt>10000000 11001mmm iiiiiiii</tt> || 3 || 1
|-
| OR reg16, imm16 || <tt>81 /6 ii ii</tt> || <tt>10000001 11001mmm iiiiiiii iiiiiiii</tt> || 4 || 1
|-
| OR reg16, simm8 || <tt>83 /6 ii</tt> || <tt>10000011 11001mmm iiiiiiii</tt> || 3 || 1
|-
| OR reg8, mem8 || <tt>0A /r</tt> || <tt>00001010 oorrrmmm</tt> || 2+ || 2
|-
| OR reg16, mem16 || <tt>0B /r</tt> || <tt>00001011 oorrrmmm</tt> || 2+ || 2
|-
| OR reg8, reg8 || <tt>08 /r</tt> || <tt>000010.0 11rrrmmm</tt> || 2 || 1
|-
| OR reg16, reg16 || <tt>09 /r</tt> || <tt>000010.1 11rrrmmm</tt> || 2 || 1
|}
----
{{Anchor|OUT}}
=== OUT ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| OUT AL, DX || <tt>EE</tt> || <tt>11101110</tt> || 1 || 6
|-
| OUT AX, DX || <tt>EF</tt> || <tt>11101111</tt> || 1 || 6
|-
| OUT AL, imm8 || <tt>E6 ii</tt> || <tt>11100110 iiiiiiii</tt> || 2 || 6
|-
| OUT AX, imm8 || <tt>E7 ii</tt> || <tt>11100111 iiiiiiii</tt> || 2 || 6
|}
----
{{Anchor|OUTSB}}
{{Anchor|OUTSW}}
=== OUTSB/OUTSW ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| OUTSB || <tt>6E</tt> || <tt>01101110</tt> || 1 || 6
|-
| OUTSW || <tt>6F</tt> || <tt>01101111</tt> || 1 || 6
|}
----
{{Anchor|POLL}}
=== POLL ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| POLL || <tt>6E</tt> || <tt>01101110</tt> || 1 || 9<ref>On the WonderSwan implementation, POLLB is always held low; on other implementations, POLL will wait for POLLB to be held low in 9-cycle intervals.</ref>
|}
----
{{Anchor|POP}}
=== POP ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| POP mem16 || <tt>8F /0</tt> || <tt>10001111 oo000mmm</tt> || 2+ || 3
|-
| POP reg16 || <tt>5x</tt> || <tt>01011xxx</tt> || 1 || 1
|-
| POP reg16 || <tt>8F /0</tt> || <tt>10001111 11000mmm</tt> || 2 || 1
|-
| POP sreg16 || <tt>xx</tt> || <tt>000xx111</tt> || 1 || 3
|}
----
{{Anchor|POPA}}
=== POPA ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| POPA || <tt>61</tt> || <tt>01100001</tt> || 1 || 8
|}
----
{{Anchor|POPF}}
=== POPF ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| POPF || <tt>9D</tt> || <tt>10011101</tt> || 1 || 3
|}
----
{{Anchor|PUSH}}
=== PUSH ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| PUSH simm8 || <tt>6A ii</tt> || <tt>01101010 iiiiiiii</tt> || 2 || 1
|-
| PUSH imm16 || <tt>68 ii ii</tt> || <tt>01101000 iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| PUSH mem16 || <tt>FF /6</tt> || <tt>11111111 oo110mmm</tt> || 2+ || 2
|-
| PUSH reg16 || <tt>5x</tt> || <tt>01010xxx</tt> || 1 || 1
|-
| PUSH reg16 || <tt>FF /6</tt> || <tt>11111111 11110mmm</tt> || 2 || 1
|-
| PUSH sreg16 || <tt>xx</tt> || <tt>000xx110</tt> || 1 || 2
|}
----
{{Anchor|PUSHA}}
=== PUSHA ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| PUSHA || <tt>60</tt> || <tt>01100000</tt> || 1 || 9
|}
----
{{Anchor|PUSHF}}
=== PUSHF ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| PUSHF || <tt>9C</tt> || <tt>10011100</tt> || 1 || 2
|}
----
{{Anchor|RCL}}
=== RCL ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| RCL mem8, 1 || <tt>D0 /2</tt> || <tt>11010000 oo010rm</tt> || 2+ || 3
|-
| RCL mem8, CL || <tt>D2 /2</tt> || <tt>11010010 oo010rm</tt> || 2+ || 5
|-
| RCL mem8, imm8 || <tt>C0 /2 ii</tt> || <tt>11000000 oo010mmm iiiiiiii</tt> || 3+ || 5
|-
| RCL mem16, 1 || <tt>D1 /2</tt> || <tt>11010001 oo010rm</tt> || 2+ || 3
|-
| RCL mem16, CL || <tt>D3 /2</tt> || <tt>11010011 oo010rm</tt> || 2+ || 5
|-
| RCL mem16, imm8 || <tt>C1 /2 ii</tt> || <tt>11000001 oo010mmm iiiiiiii</tt> || 3+ || 5
|-
| RCL reg8, 1 || <tt>D0 /2</tt> || <tt>11010000 11010rm</tt> || 2 || 1
|-
| RCL reg8, CL || <tt>D2 /2</tt> || <tt>11010010 11010rm</tt> || 2 || 3
|-
| RCL reg8, imm8 || <tt>C0 /2 ii</tt> || <tt>11000000 11010mmm iiiiiiii</tt> || 3 || 3
|-
| RCL reg16, 1 || <tt>D1 /2</tt> || <tt>11010001 11010rm</tt> || 2 || 1
|-
| RCL reg16, CL || <tt>D3 /2</tt> || <tt>11010011 11010rm</tt> || 2 || 3
|-
| RCL reg16, imm8 || <tt>C1 /2 ii</tt> || <tt>11000001 11010mmm iiiiiiii</tt> || 3 || 3
|}
----
{{Anchor|RCR}}
=== RCR ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| RCR mem8, 1 || <tt>D0 /3</tt> || <tt>11010000 oo011rm</tt> || 2+ || 3
|-
| RCR mem8, CL || <tt>D2 /3</tt> || <tt>11010010 oo011rm</tt> || 2+ || 5
|-
| RCR mem8, imm8 || <tt>C0 /3 ii</tt> || <tt>11000000 oo011mmm iiiiiiii</tt> || 3+ || 5
|-
| RCR mem16, 1 || <tt>D1 /3</tt> || <tt>11010001 oo011rm</tt> || 2+ || 3
|-
| RCR mem16, CL || <tt>D3 /3</tt> || <tt>11010011 oo011rm</tt> || 2+ || 5
|-
| RCR mem16, imm8 || <tt>C1 /3 ii</tt> || <tt>11000001 oo011mmm iiiiiiii</tt> || 3+ || 5
|-
| RCR reg8, 1 || <tt>D0 /3</tt> || <tt>11010000 11011rm</tt> || 2 || 1
|-
| RCR reg8, CL || <tt>D2 /3</tt> || <tt>11010010 11011rm</tt> || 2 || 3
|-
| RCR reg8, imm8 || <tt>C0 /3 ii</tt> || <tt>11000000 11011mmm iiiiiiii</tt> || 3 || 3
|-
| RCR reg16, 1 || <tt>D1 /3</tt> || <tt>11010001 11011rm</tt> || 2 || 1
|-
| RCR reg16, CL || <tt>D3 /3</tt> || <tt>11010011 11011rm</tt> || 2 || 3
|-
| RCR reg16, imm8 || <tt>C1 /3 ii</tt> || <tt>11000001 11011mmm iiiiiiii</tt> || 3 || 3
|}
----
{{Anchor|REP}}
=== REP/REPE/REPZ ===
----
{{Anchor|REPNE}}
=== REPNE/REPNZ ===
----
{{Anchor|RET}}
=== RET ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| RET || <tt>C3</tt> || <tt>11000011</tt> || 1 || 6
|-
| RET imm16 || <tt>C2 ii ii</tt> || <tt>11000010 iiiiiiii iiiiiiii</tt> || 1 || 6
|}
----
{{Anchor|RETF}}
=== RETF ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| RETF || <tt>CB</tt> || <tt>11001011</tt> || 1 || 8
|-
| RETF imm16 || <tt>CA ii ii</tt> || <tt>11001010 iiiiiiii iiiiiiii</tt> || 1 || 9
|}
----
{{Anchor|ROL}}
=== ROL ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| ROL mem8, 1 || <tt>D0 /0</tt> || <tt>11010000 oo000rm</tt> || 2+ || 3
|-
| ROL mem8, CL || <tt>D2 /0</tt> || <tt>11010010 oo000rm</tt> || 2+ || 5
|-
| ROL mem8, imm8 || <tt>C0 /0 ii</tt> || <tt>11000000 oo000mmm iiiiiiii</tt> || 3+ || 5
|-
| ROL mem16, 1 || <tt>D1 /0</tt> || <tt>11010001 oo000rm</tt> || 2+ || 3
|-
| ROL mem16, CL || <tt>D3 /0</tt> || <tt>11010011 oo000rm</tt> || 2+ || 5
|-
| ROL mem16, imm8 || <tt>C1 /0 ii</tt> || <tt>11000001 oo000mmm iiiiiiii</tt> || 3+ || 5
|-
| ROL reg8, 1 || <tt>D0 /0</tt> || <tt>11010000 11000rm</tt> || 2 || 1
|-
| ROL reg8, CL || <tt>D2 /0</tt> || <tt>11010010 11000rm</tt> || 2 || 3
|-
| ROL reg8, imm8 || <tt>C0 /0 ii</tt> || <tt>11000000 11000mmm iiiiiiii</tt> || 3 || 3
|-
| ROL reg16, 1 || <tt>D1 /0</tt> || <tt>11010001 11000rm</tt> || 2 || 1
|-
| ROL reg16, CL || <tt>D3 /0</tt> || <tt>11010011 11000rm</tt> || 2 || 3
|-
| ROL reg16, imm8 || <tt>C1 /0 ii</tt> || <tt>11000001 11000mmm iiiiiiii</tt> || 3 || 3
|}
----
{{Anchor|ROR}}
=== ROR ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| ROR mem8, 1 || <tt>D0 /1</tt> || <tt>11010000 oo001rm</tt> || 2+ || 3
|-
| ROR mem8, CL || <tt>D2 /1</tt> || <tt>11010010 oo001rm</tt> || 2+ || 5
|-
| ROR mem8, imm8 || <tt>C0 /1 ii</tt> || <tt>11000000 oo001mmm iiiiiiii</tt> || 3+ || 5
|-
| ROR mem16, 1 || <tt>D1 /1</tt> || <tt>11010001 oo001rm</tt> || 2+ || 3
|-
| ROR mem16, CL || <tt>D3 /1</tt> || <tt>11010011 oo001rm</tt> || 2+ || 5
|-
| ROR mem16, imm8 || <tt>C1 /1 ii</tt> || <tt>11000001 oo001mmm iiiiiiii</tt> || 3+ || 5
|-
| ROR reg8, 1 || <tt>D0 /1</tt> || <tt>11010000 11001rm</tt> || 2 || 1
|-
| ROR reg8, CL || <tt>D2 /1</tt> || <tt>11010010 11001rm</tt> || 2 || 3
|-
| ROR reg8, imm8 || <tt>C0 /1 ii</tt> || <tt>11000000 11001mmm iiiiiiii</tt> || 3 || 3
|-
| ROR reg16, 1 || <tt>D1 /1</tt> || <tt>11010001 11001rm</tt> || 2 || 1
|-
| ROR reg16, CL || <tt>D3 /1</tt> || <tt>11010011 11001rm</tt> || 2 || 3
|-
| ROR reg16, imm8 || <tt>C1 /1 ii</tt> || <tt>11000001 11001mmm iiiiiiii</tt> || 3 || 3
|}
----
{{Anchor|SAHF}}
=== SAHF ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| SAHF || <tt>9E</tt> || <tt>10011110</tt> || 1 || 4
|}
----
{{Anchor|SAR}}
=== SAR ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| SAR mem8, 1 || <tt>D0 /7</tt> || <tt>11010000 oo111rm</tt> || 2+ || 3
|-
| SAR mem8, CL || <tt>D2 /7</tt> || <tt>11010010 oo111rm</tt> || 2+ || 5
|-
| SAR mem8, imm8 || <tt>C0 /7 ii</tt> || <tt>11000000 oo111mmm iiiiiiii</tt> || 3+ || 5
|-
| SAR mem16, 1 || <tt>D1 /7</tt> || <tt>11010001 oo111rm</tt> || 2+ || 3
|-
| SAR mem16, CL || <tt>D3 /7</tt> || <tt>11010011 oo111rm</tt> || 2+ || 5
|-
| SAR mem16, imm8 || <tt>C1 /7 ii</tt> || <tt>11000001 oo111mmm iiiiiiii</tt> || 3+ || 5
|-
| SAR reg8, 1 || <tt>D0 /7</tt> || <tt>11010000 11111rm</tt> || 2 || 1
|-
| SAR reg8, CL || <tt>D2 /7</tt> || <tt>11010010 11111rm</tt> || 2 || 3
|-
| SAR reg8, imm8 || <tt>C0 /7 ii</tt> || <tt>11000000 11111mmm iiiiiiii</tt> || 3 || 3
|-
| SAR reg16, 1 || <tt>D1 /7</tt> || <tt>11010001 11111rm</tt> || 2 || 1
|-
| SAR reg16, CL || <tt>D3 /7</tt> || <tt>11010011 11111rm</tt> || 2 || 3
|-
| SAR reg16, imm8 || <tt>C1 /7 ii</tt> || <tt>11000001 11111mmm iiiiiiii</tt> || 3 || 3
|}
----
{{Anchor|SBB}}
=== SBB ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| SBB AL, imm || <tt>1C ii</tt> || <tt>00011100 iiiiiiii</tt> || 2 || 1
|-
| SBB AX, imm || <tt>1D ii ii</tt> || <tt>00011101 iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| SBB mem8, imm8 || <tt>80 /3 ii</tt> || <tt>10000000 oo011mmm iiiiiiii</tt> || 3+ || 3
|-
| SBB mem16, imm16 || <tt>81 /3 ii ii</tt> || <tt>10000001 oo011mmm iiiiiiii iiiiiiii</tt> || 4+ || 3
|-
| SBB mem16, simm8 || <tt>83 /3 ii</tt> || <tt>10000011 oo011mmm iiiiiiii</tt> || 3+ || 3
|-
| SBB mem8, reg8 || <tt>18 /r</tt> || <tt>00011000 oorrrmmm</tt> || 2+ || 3
|-
| SBB mem16, reg16 || <tt>19 /r</tt> || <tt>00011001 oorrrmmm</tt> || 2+ || 3
|-
| SBB reg8, imm8 || <tt>80 /3 ii</tt> || <tt>10000000 11011mmm iiiiiiii</tt> || 3 || 1
|-
| SBB reg16, imm16 || <tt>81 /3 ii ii</tt> || <tt>10000001 11011mmm iiiiiiii iiiiiiii</tt> || 4 || 1
|-
| SBB reg16, simm8 || <tt>83 /3 ii</tt> || <tt>10000011 11011mmm iiiiiiii</tt> || 3 || 1
|-
| SBB reg8, mem8 || <tt>1A /r</tt> || <tt>00011010 oorrrmmm</tt> || 2+ || 2
|-
| SBB reg16, mem16 || <tt>1B /r</tt> || <tt>00011011 oorrrmmm</tt> || 2+ || 2
|-
| SBB reg8, reg8 || <tt>18 /r</tt> || <tt>000110.0 11rrrmmm</tt> || 2 || 1
|-
| SBB reg16, reg16 || <tt>19 /r</tt> || <tt>000110.1 11rrrmmm</tt> || 2 || 1
|}
----
{{Anchor|SCASB}}
{{Anchor|SCASW}}
=== SCASB/SCASW ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| SCASB || <tt>AE</tt> || <tt>10101110</tt> || 1 || 4
|-
| SCASW || <tt>AF</tt> || <tt>10101111</tt> || 1 || 4
|}
----
{{Anchor|SHL}}
=== SHL ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| SHL mem8, 1 || <tt>D0 /4</tt> || <tt>11010000 oo100rm</tt> || 2+ || 3
|-
| SHL mem8, CL || <tt>D2 /4</tt> || <tt>11010010 oo100rm</tt> || 2+ || 5
|-
| SHL mem8, imm8 || <tt>C0 /4 ii</tt> || <tt>11000000 oo100mmm iiiiiiii</tt> || 3+ || 5
|-
| SHL mem16, 1 || <tt>D1 /4</tt> || <tt>11010001 oo100rm</tt> || 2+ || 3
|-
| SHL mem16, CL || <tt>D3 /4</tt> || <tt>11010011 oo100rm</tt> || 2+ || 5
|-
| SHL mem16, imm8 || <tt>C1 /4 ii</tt> || <tt>11000001 oo100mmm iiiiiiii</tt> || 3+ || 5
|-
| SHL reg8, 1 || <tt>D0 /4</tt> || <tt>11010000 11100rm</tt> || 2 || 1
|-
| SHL reg8, CL || <tt>D2 /4</tt> || <tt>11010010 11100rm</tt> || 2 || 3
|-
| SHL reg8, imm8 || <tt>C0 /4 ii</tt> || <tt>11000000 11100mmm iiiiiiii</tt> || 3 || 3
|-
| SHL reg16, 1 || <tt>D1 /4</tt> || <tt>11010001 11100rm</tt> || 2 || 1
|-
| SHL reg16, CL || <tt>D3 /4</tt> || <tt>11010011 11100rm</tt> || 2 || 3
|-
| SHL reg16, imm8 || <tt>C1 /4 ii</tt> || <tt>11000001 11100mmm iiiiiiii</tt> || 3 || 3
|}
----
{{Anchor|SHR}}
=== SHR ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| SHR mem8, 1 || <tt>D0 /5</tt> || <tt>11010000 oo101rm</tt> || 2+ || 3
|-
| SHR mem8, CL || <tt>D2 /5</tt> || <tt>11010010 oo101rm</tt> || 2+ || 5
|-
| SHR mem8, imm8 || <tt>C0 /5 ii</tt> || <tt>11000000 oo101mmm iiiiiiii</tt> || 3+ || 5
|-
| SHR mem16, 1 || <tt>D1 /5</tt> || <tt>11010001 oo101rm</tt> || 2+ || 3
|-
| SHR mem16, CL || <tt>D3 /5</tt> || <tt>11010011 oo101rm</tt> || 2+ || 5
|-
| SHR mem16, imm8 || <tt>C1 /5 ii</tt> || <tt>11000001 oo101mmm iiiiiiii</tt> || 3+ || 5
|-
| SHR reg8, 1 || <tt>D0 /5</tt> || <tt>11010000 11101rm</tt> || 2 || 1
|-
| SHR reg8, CL || <tt>D2 /5</tt> || <tt>11010010 11101rm</tt> || 2 || 3
|-
| SHR reg8, imm8 || <tt>C0 /5 ii</tt> || <tt>11000000 11101mmm iiiiiiii</tt> || 3 || 3
|-
| SHR reg16, 1 || <tt>D1 /5</tt> || <tt>11010001 11101rm</tt> || 2 || 1
|-
| SHR reg16, CL || <tt>D3 /5</tt> || <tt>11010011 11101rm</tt> || 2 || 3
|-
| SHR reg16, imm8 || <tt>C1 /5 ii</tt> || <tt>11000001 11101mmm iiiiiiii</tt> || 3 || 3
|}
----
{{Anchor|SS}}
=== SS ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| SS || <tt>36</tt> || <tt>00110110</tt> || 1 || 1
|}
----
{{Anchor|STC}}
=== STC ===
{| class="wikitable"
! Flag !! New value
|-
| [[NEC_V30MZ_flags#CF|CF - Carry]] || 1
|}
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| STC || <tt>F9</tt> || <tt>11111001</tt> || 1 || 4
|}
----
{{Anchor|STD}}
=== STD ===
{| class="wikitable"
! Flag !! New value
|-
| [[NEC_V30MZ_flags#DF|DF - Direction]] || 1
|}
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| STD || <tt>FD</tt> || <tt>11111101</tt> || 1 || 4
|}
----
{{Anchor|STI}}
=== STI ===
{| class="wikitable"
! Flag !! New value
|-
| [[NEC_V30MZ_flags#IF|IF - Interrupt]] || 1
|}
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| STI || <tt>FB</tt> || <tt>11111011</tt> || 1 || 4
|}
----
{{Anchor|STOSB}}
{{Anchor|STOSW}}
=== STOSB/STOSW ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| STOSB || <tt>AA</tt> || <tt>10101010</tt> || 1 || 3
|-
| STOSW || <tt>AB</tt> || <tt>10101011</tt> || 1 || 3
|}
----
{{Anchor|SUB}}
=== SUB ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| SUB AL, imm || <tt>28 ii</tt> || <tt>00101100 iiiiiiii</tt> || 2 || 1
|-
| SUB AX, imm || <tt>29 ii ii</tt> || <tt>00101101 iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| SUB mem8, imm8 || <tt>80 /5 ii</tt> || <tt>10000000 oo101mmm iiiiiiii</tt> || 3+ || 3
|-
| SUB mem16, imm16 || <tt>81 /5 ii ii</tt> || <tt>10000001 oo101mmm iiiiiiii iiiiiiii</tt> || 4+ || 3
|-
| SUB mem16, simm8 || <tt>83 /5 ii</tt> || <tt>10000011 oo101mmm iiiiiiii</tt> || 3+ || 3
|-
| SUB mem8, reg8 || <tt>28 /r</tt> || <tt>00101000 oorrrmmm</tt> || 2+ || 3
|-
| SUB mem16, reg16 || <tt>29 /r</tt> || <tt>00101001 oorrrmmm</tt> || 2+ || 3
|-
| SUB reg8, imm8 || <tt>80 /5 ii</tt> || <tt>10000000 11101mmm iiiiiiii</tt> || 3 || 1
|-
| SUB reg16, imm16 || <tt>81 /5 ii ii</tt> || <tt>10000001 11101mmm iiiiiiii iiiiiiii</tt> || 4 || 1
|-
| SUB reg16, simm8 || <tt>83 /5 ii</tt> || <tt>10000011 11101mmm iiiiiiii</tt> || 3 || 1
|-
| SUB reg8, mem8 || <tt>2A /r</tt> || <tt>00101010 oorrrmmm</tt> || 2+ || 2
|-
| SUB reg16, mem16 || <tt>2B /r</tt> || <tt>00101011 oorrrmmm</tt> || 2+ || 2
|-
| SUB reg8, reg8 || <tt>28 /r</tt> || <tt>001010.0 11rrrmmm</tt> || 2 || 1
|-
| SUB reg16, reg16 || <tt>29 /r</tt> || <tt>001010.1 11rrrmmm</tt> || 2 || 1
|}
----
{{Anchor|TEST}}
=== TEST ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| TEST AL, imm || <tt>A8 ii</tt> || <tt>10101000 iiiiiiii</tt> || 2 || 1
|-
| TEST AX, imm || <tt>A9 ii ii</tt> || <tt>10101001 iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| TEST mem8, imm8 || <tt>F6 /0 ii</tt> || <tt>11110110 oo000mmm iiiiiiii</tt> || 3+ || 2
|-
| TEST mem16, imm16 || <tt>F7 /0 ii ii</tt> || <tt>11110111 oo000mmm iiiiiiii iiiiiiii</tt> || 4+ || 2
|-
| TEST mem8, reg8<br/>TEST reg8, mem8 || <tt>84 /r</tt> || <tt>10000100 oorrrmmm</tt> || 2+ || 2
|-
| TEST mem16, reg16<br/>TEST reg16, mem16 || <tt>85 /r</tt> || <tt>10000101 oorrrmmm</tt> || 2+ || 2
|-
| TEST reg8, imm8 || <tt>F6 /0 ii</tt> || <tt>11110110 11000mmm iiiiiiii</tt> || 3 || 1
|-
| TEST reg16, imm16 || <tt>F7 /0 ii ii</tt> || <tt>11110111 11000mmm iiiiiiii iiiiiiii</tt> || 4 || 1
|-
| TEST reg8, reg8 || <tt>84 /r</tt> || <tt>10000100 11rrrmmm</tt> || 2 || 1
|-
| TEST reg16, reg16 || <tt>85 /r</tt> || <tt>10000101 11rrrmmm</tt> || 2 || 1
|}
----
{{Anchor|XCHG}}
=== XCHG ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| XCHG AX, reg16<br/>XCHG reg16, AX || <tt>9x</tt> || <tt>10010rrr</tt> || 1 || 3
|-
| XCHG mem8, reg8<br/>XCHG reg8, mem8 || <tt>86 /r</tt> || <tt>10000110 oorrrmmm</tt> || 2+ || 5
|-
| XCHG mem16, reg16<br/>XCHG reg16, mem16 || <tt>87 /r</tt> || <tt>10000111 oorrrmmm</tt> || 2+ || 5
|-
| XCHG reg8, reg8 || <tt>86 /r</tt> || <tt>10000110 11rrrmmm</tt> || 2+ || 3
|-
| XCHG reg16, reg16 || <tt>87 /r</tt> || <tt>10000111 11rrrmmm</tt> || 2+ || 3
|}
----
{{Anchor|XLAT}}
=== XLAT ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| XLAT || <tt>D7</tt> || <tt>11010111</tt> || 1 || 5
|}
----
{{Anchor|XOR}}
=== XOR ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| XOR AL, imm || <tt>34 ii</tt> || <tt>00110100 iiiiiiii</tt> || 2 || 1
|-
| XOR AX, imm || <tt>35 ii ii</tt> || <tt>00110101 iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| XOR mem8, imm8 || <tt>80 /6 ii</tt> || <tt>10000000 oo110mmm iiiiiiii</tt> || 3+ || 3
|-
| XOR mem16, imm16 || <tt>81 /6 ii ii</tt> || <tt>10000001 oo110mmm iiiiiiii iiiiiiii</tt> || 4+ || 3
|-
| XOR mem16, simm8 || <tt>83 /6 ii</tt> || <tt>10000011 oo110mmm iiiiiiii</tt> || 3+ || 3
|-
| XOR mem8, reg8 || <tt>30 /r</tt> || <tt>00110000 oorrrmmm</tt> || 2+ || 3
|-
| XOR mem16, reg16 || <tt>31 /r</tt> || <tt>00110001 oorrrmmm</tt> || 2+ || 3
|-
| XOR reg8, imm8 || <tt>80 /6 ii</tt> || <tt>10000000 11110mmm iiiiiiii</tt> || 3 || 1
|-
| XOR reg16, imm16 || <tt>81 /6 ii ii</tt> || <tt>10000001 11110mmm iiiiiiii iiiiiiii</tt> || 4 || 1
|-
| XOR reg16, simm8 || <tt>83 /6 ii</tt> || <tt>10000011 11110mmm iiiiiiii</tt> || 3 || 1
|-
| XOR reg8, mem8 || <tt>32 /r</tt> || <tt>00110010 oorrrmmm</tt> || 2+ || 2
|-
| XOR reg16, mem16 || <tt>33 /r</tt> || <tt>00110011 oorrrmmm</tt> || 2+ || 2
|-
| XOR reg8, reg8 || <tt>30 /r</tt> || <tt>001100.0 11rrrmmm</tt> || 2 || 1
|-
| XOR reg16, reg16 || <tt>31 /r</tt> || <tt>001100.1 11rrrmmm</tt> || 2 || 1
|}
== Notes ==
<references />
d340101c9753781594599503b826d46efae592ac
Real-Time Clock
0
40
546
410
2025-02-24T19:02:08Z
Asie
351
/* Reset RTC ($10, $11) */
wikitext
text/x-wiki
The [[Bandai 2003|2003]] mapper provides a special-purpose interface to interact with Seiko's S-3511A RTC chip.
This page will cover how games expect to interact with it; not the low-level protocol specifics. (For that see the datasheet and the Timing section of this wiki)
== Registers ==
=== Configuration ===
7 bit 0
---- ----
p2a0 m0f0
||| | |
||+--+-+-- Interrupt mode; see below
|+-------- 12/24 hour mode
| - 0: 12 hour mode
| - 1: 24 hour mode
+--------- Power failure occurred
Note that sending the Reset or Read Configuration commands clears the "power failure" bit.
==== Interrupt mode ====
{| class="wikitable"
! A
! M
! F
! Name
! Description
|-
| 0
| 0
| 0
| Disabled
| Continuously deasserts /IRQ pin.
|-
| 1
| 0
| 0
| Alarm
| Asserts /IRQ during the hour and minute set in the alarm configuration register.
|-
| rowspan="3" | x
| 0
| 1
| Frequency
| Subsecond prescaler is bitwise inverted, bitwise ANDed with the lower 15 bits of the "alarm configuration" register, then all fifteen bits are NORed together. This signal directly drives the /IRQ pin.
|-
| 1
| 0
| Per-minute edge
| Asserts /IRQ during the first 10 ms of each minute. During the following 990 ms, /IRQ can be deasserted by reading the configuration register.
|-
| 1
| 1
| Per-minute steady
| Asserts /IRQ during the first 10 ms of each minute. De-asserts /IRQ at the 30th second.
|}
=== Date/Time ===
The date and time is stored using seven bytes, of which the latter three correspond to the time.
==== Date ====
7 bit 0
---- ---- Byte 0
yyyy yyyy
|||| ||||
++++-++++- Year (00 - 99, BCD)
7 bit 0
---- ---- Byte 1
...m mmmm
| ||||
+-++++- Month (01 - 12, BCD)
7 bit 0
---- ---- Byte 2
..dd dddd
|| ||||
++-++++- Day of month (01 - 31, BCD)
7 bit 0
---- ---- Byte 3
.... .www
|||
+++- Day of week (0 - 6)
While this convention does not have to be followed, [[WonderWitch/FreyaBIOS|FreyaBIOS]] assumes that the first day of the week (0) is a Sunday, (1) is a Monday, ... (6) is a Saturday.
==== Time ====
7 bit 0
---- ---- Byte 4
p.hh hhhh
| || ||||
| ++-++++- Hour (00 - 11 or 23, BCD)
+--------- 0 = AM, 1 = PM
In the 24-hour mode, reading the AM/PM bit returns correct values (set if hour >= 12); however, writes to the bit are ignored.
7 bit 0
---- ---- Byte 5
.mmm mmmm
||| ||||
+++-++++- Minute (00 - 59, BCD)
7 bit 0
---- ---- Byte 6
.sss ssss
||| ||||
+++-++++- Second (00 - 59, BCD)
=== Alarm configuration ===
The alarm configuration register is two bytes in size; its interpretation depends on the configured interrupt mode.
==== Interrupt mode: Alarm ====
7 bit 0
---- ---- Byte 0
p.hh hhhh
| || ||||
| ++-++++- Hour to match for the alarm (BCD)
+--------- AM/PM bit to match for the alarm
7 bit 0
---- ---- Byte 1
.mmm mmmm
||| ||||
+++-++++- Minute to match for the alarm (BCD)
Note that the hour encoding of the alarm must match the hour encoding used by the clock itself.
==== Interrupt mode: Frequency ====
7 bit 0
---- ---- Byte 0
abcd efgh
|||| ||||
|||| |||+- 32768 Hz
|||| ||+-- 16384 Hz
|||| |+--- 8192 Hz
|||| +---- 4096 Hz
|||+------ 2048 Hz
||+------- 1024 Hz
|+-------- 512 Hz
+--------- 256 Hz
7 bit 0
---- ---- Byte 1
abcd efgh
|||| ||||
|||| |||+- 128 Hz
|||| ||+-- 64 Hz
|||| |+--- 32 Hz
|||| +---- 16 Hz
|||+------ 8 Hz
||+------- 4 Hz
|+-------- 2 Hz
+--------- 1 Hz
== Commands ==
=== Reset RTC ($10, $11) ===
Writing $10 or $11 to port $CA will send the "reset" command to the RTC. The S-3511A will then reset the following registers:
* Year = <tt>$00</tt>
* Month = <tt>$01</tt>
* Day of month = <tt>$01</tt>
* Day of week = <tt>$00</tt>
* Hour = <tt>$00</tt>
* Minute = <tt>$00</tt>
* Second = <tt>$00</tt>
* Configuration = <tt>$00</tt>
* Alarm = <tt>$0000</tt>
year, month, day-of-month, day-of-week, hour, minute, second, config, and alarm registers. It is unknown if it resets the sub-second prescaler.
=== Write Configuration ($12) ===
Writing $12 to port $CA will send the "set configuration" command to the RTC. The 2003 expects that $CB contains valid contents by the time the 2003 sends that register's contents.
=== Read Configuration ($13) ===
Writing $13 to port $CA will send the "get configuration" command to the RTC.
=== Write current YMDdHMS ($14) ===
Writing $14 will set the current Year, Month, Day-of-Month, Day-of-Week, Hour, Minute, and Second.
=== Read current YMDdHMS ($15) ===
Writing $15 will get the current Year, Month, Day-of-Month, Day-of-Week, Hour, Minute, and Second.
=== Write current HMS ($16) ===
Writing $16 will set the current Hour, Minute, and Second.
These are the same as command $14.
=== Read current HMS ($17) ===
Writing $17 will get the current Hour, Minute, and Second.
=== Write alarm configuration ($18) ===
Writing $18 will set the current alarm configuration. The interpretation of these two bytes depend on the Configuration register
=== Nonsense alarm configuration ($19) ===
Writing $19 will set the current alarm configuration to $FFFF. The 2003 thinks it's reading from the S-3511A, but the S-3511A disagrees.
$FFFF will be read back by the 2003.
=== Write nonsense ($1A) ===
Writing $1A expects to send 2 bytes to the RTC. The S-3511A ignores them.
=== Read nonsense ($1B) ===
Writing $1B expects to read 2 bytes from the RTC. The S-3511A leaves its output high, returning $FFFF.
== Interrupts ==
The 2003 and S-3511A do not provide a thread-safe way to acknowledge the IRQ. Since the 2003 only holds one byte at a time, an interrupt can be fired in the middle of a multi-byte read or write without knowing what needs to be done for the rest of the command, nor how to safely restart that command when exiting the interrupt.
As such, the only choices are:
* all communication to the 2003 happens while cartridge IRQs are disabled, or
* the only thing the interrupt handler can do is [[Interrupts#Interrupt_Enable|mask]] the interrupt and then [[Interrupts#Interrupt_Acknowledge|acknowledge]] it, and only afterwards handle any subsequent communication.
e12332fd16e5c3f28190b587deb25787f31fc8d2
547
546
2025-02-24T19:02:23Z
Asie
351
/* Reset RTC ($10, $11) */
wikitext
text/x-wiki
The [[Bandai 2003|2003]] mapper provides a special-purpose interface to interact with Seiko's S-3511A RTC chip.
This page will cover how games expect to interact with it; not the low-level protocol specifics. (For that see the datasheet and the Timing section of this wiki)
== Registers ==
=== Configuration ===
7 bit 0
---- ----
p2a0 m0f0
||| | |
||+--+-+-- Interrupt mode; see below
|+-------- 12/24 hour mode
| - 0: 12 hour mode
| - 1: 24 hour mode
+--------- Power failure occurred
Note that sending the Reset or Read Configuration commands clears the "power failure" bit.
==== Interrupt mode ====
{| class="wikitable"
! A
! M
! F
! Name
! Description
|-
| 0
| 0
| 0
| Disabled
| Continuously deasserts /IRQ pin.
|-
| 1
| 0
| 0
| Alarm
| Asserts /IRQ during the hour and minute set in the alarm configuration register.
|-
| rowspan="3" | x
| 0
| 1
| Frequency
| Subsecond prescaler is bitwise inverted, bitwise ANDed with the lower 15 bits of the "alarm configuration" register, then all fifteen bits are NORed together. This signal directly drives the /IRQ pin.
|-
| 1
| 0
| Per-minute edge
| Asserts /IRQ during the first 10 ms of each minute. During the following 990 ms, /IRQ can be deasserted by reading the configuration register.
|-
| 1
| 1
| Per-minute steady
| Asserts /IRQ during the first 10 ms of each minute. De-asserts /IRQ at the 30th second.
|}
=== Date/Time ===
The date and time is stored using seven bytes, of which the latter three correspond to the time.
==== Date ====
7 bit 0
---- ---- Byte 0
yyyy yyyy
|||| ||||
++++-++++- Year (00 - 99, BCD)
7 bit 0
---- ---- Byte 1
...m mmmm
| ||||
+-++++- Month (01 - 12, BCD)
7 bit 0
---- ---- Byte 2
..dd dddd
|| ||||
++-++++- Day of month (01 - 31, BCD)
7 bit 0
---- ---- Byte 3
.... .www
|||
+++- Day of week (0 - 6)
While this convention does not have to be followed, [[WonderWitch/FreyaBIOS|FreyaBIOS]] assumes that the first day of the week (0) is a Sunday, (1) is a Monday, ... (6) is a Saturday.
==== Time ====
7 bit 0
---- ---- Byte 4
p.hh hhhh
| || ||||
| ++-++++- Hour (00 - 11 or 23, BCD)
+--------- 0 = AM, 1 = PM
In the 24-hour mode, reading the AM/PM bit returns correct values (set if hour >= 12); however, writes to the bit are ignored.
7 bit 0
---- ---- Byte 5
.mmm mmmm
||| ||||
+++-++++- Minute (00 - 59, BCD)
7 bit 0
---- ---- Byte 6
.sss ssss
||| ||||
+++-++++- Second (00 - 59, BCD)
=== Alarm configuration ===
The alarm configuration register is two bytes in size; its interpretation depends on the configured interrupt mode.
==== Interrupt mode: Alarm ====
7 bit 0
---- ---- Byte 0
p.hh hhhh
| || ||||
| ++-++++- Hour to match for the alarm (BCD)
+--------- AM/PM bit to match for the alarm
7 bit 0
---- ---- Byte 1
.mmm mmmm
||| ||||
+++-++++- Minute to match for the alarm (BCD)
Note that the hour encoding of the alarm must match the hour encoding used by the clock itself.
==== Interrupt mode: Frequency ====
7 bit 0
---- ---- Byte 0
abcd efgh
|||| ||||
|||| |||+- 32768 Hz
|||| ||+-- 16384 Hz
|||| |+--- 8192 Hz
|||| +---- 4096 Hz
|||+------ 2048 Hz
||+------- 1024 Hz
|+-------- 512 Hz
+--------- 256 Hz
7 bit 0
---- ---- Byte 1
abcd efgh
|||| ||||
|||| |||+- 128 Hz
|||| ||+-- 64 Hz
|||| |+--- 32 Hz
|||| +---- 16 Hz
|||+------ 8 Hz
||+------- 4 Hz
|+-------- 2 Hz
+--------- 1 Hz
== Commands ==
=== Reset RTC ($10, $11) ===
Writing $10 or $11 to port $CA will send the "reset" command to the RTC. The S-3511A will then reset the following registers:
* Year = <tt>$00</tt>
* Month = <tt>$01</tt>
* Day of month = <tt>$01</tt>
* Day of week = <tt>$00</tt>
* Hour = <tt>$00</tt>
* Minute = <tt>$00</tt>
* Second = <tt>$00</tt>
* Configuration = <tt>$00</tt>
* Alarm = <tt>$0000</tt>
It is unknown if it resets the sub-second prescaler.
=== Write Configuration ($12) ===
Writing $12 to port $CA will send the "set configuration" command to the RTC. The 2003 expects that $CB contains valid contents by the time the 2003 sends that register's contents.
=== Read Configuration ($13) ===
Writing $13 to port $CA will send the "get configuration" command to the RTC.
=== Write current YMDdHMS ($14) ===
Writing $14 will set the current Year, Month, Day-of-Month, Day-of-Week, Hour, Minute, and Second.
=== Read current YMDdHMS ($15) ===
Writing $15 will get the current Year, Month, Day-of-Month, Day-of-Week, Hour, Minute, and Second.
=== Write current HMS ($16) ===
Writing $16 will set the current Hour, Minute, and Second.
These are the same as command $14.
=== Read current HMS ($17) ===
Writing $17 will get the current Hour, Minute, and Second.
=== Write alarm configuration ($18) ===
Writing $18 will set the current alarm configuration. The interpretation of these two bytes depend on the Configuration register
=== Nonsense alarm configuration ($19) ===
Writing $19 will set the current alarm configuration to $FFFF. The 2003 thinks it's reading from the S-3511A, but the S-3511A disagrees.
$FFFF will be read back by the 2003.
=== Write nonsense ($1A) ===
Writing $1A expects to send 2 bytes to the RTC. The S-3511A ignores them.
=== Read nonsense ($1B) ===
Writing $1B expects to read 2 bytes from the RTC. The S-3511A leaves its output high, returning $FFFF.
== Interrupts ==
The 2003 and S-3511A do not provide a thread-safe way to acknowledge the IRQ. Since the 2003 only holds one byte at a time, an interrupt can be fired in the middle of a multi-byte read or write without knowing what needs to be done for the rest of the command, nor how to safely restart that command when exiting the interrupt.
As such, the only choices are:
* all communication to the 2003 happens while cartridge IRQs are disabled, or
* the only thing the interrupt handler can do is [[Interrupts#Interrupt_Enable|mask]] the interrupt and then [[Interrupts#Interrupt_Acknowledge|acknowledge]] it, and only afterwards handle any subsequent communication.
166b32f1c2a400474f30c805b0721823ceb48c0a
548
547
2025-02-24T19:02:56Z
Asie
351
/* Registers */
wikitext
text/x-wiki
The [[Bandai 2003|2003]] mapper provides a special-purpose interface to interact with Seiko's S-3511A RTC chip.
This page will cover how games expect to interact with it; not the low-level protocol specifics. (For that see the datasheet and the Timing section of this wiki)
== Registers ==
=== Configuration ===
7 bit 0
---- ----
p2a0 m0f0
||| | |
||+--+-+-- Interrupt mode; see below
|+-------- 12/24 hour mode
| - 0: 12 hour mode
| - 1: 24 hour mode
+--------- Power failure occurred
Note that sending the Reset or Read Configuration commands clears the "power failure" bit.
==== Interrupt mode ====
{| class="wikitable"
! A
! M
! F
! Name
! Description
|-
| 0
| 0
| 0
| Disabled
| Continuously deasserts /IRQ pin.
|-
| 1
| 0
| 0
| Alarm
| Asserts /IRQ during the hour and minute set in the alarm configuration register.
|-
| rowspan="3" | x
| 0
| 1
| Frequency
| Subsecond prescaler is bitwise inverted, bitwise ANDed with the lower 15 bits of the "alarm configuration" register, then all fifteen bits are NORed together. This signal directly drives the /IRQ pin.
|-
| 1
| 0
| Per-minute edge
| Asserts /IRQ during the first 10 ms of each minute. During the following 990 ms, /IRQ can be deasserted by reading the configuration register.
|-
| 1
| 1
| Per-minute steady
| Asserts /IRQ during the first 10 ms of each minute. De-asserts /IRQ at the 30th second.
|}
=== Date/Time ===
The date and time is stored using seven bytes, of which the latter three correspond to the time.
==== Date ====
7 bit 0
---- ---- Byte 0
yyyy yyyy
|||| ||||
++++-++++- Year (00 - 99, BCD)
7 bit 0
---- ---- Byte 1
...m mmmm
| ||||
+-++++- Month (01 - 12, BCD)
7 bit 0
---- ---- Byte 2
..dd dddd
|| ||||
++-++++- Day of month (01 - 31, BCD)
7 bit 0
---- ---- Byte 3
.... .www
|||
+++- Day of week (0 - 6)
While this convention does not have to be followed, [[WonderWitch/FreyaBIOS|FreyaBIOS]] assumes that the first day of the week (0) is a Sunday, (1) is a Monday, ... (6) is a Saturday.
==== Time ====
7 bit 0
---- ---- Byte 4
p.hh hhhh
| || ||||
| ++-++++- Hour (00 - 11 or 23, BCD)
+--------- 0 = AM, 1 = PM
In the 24-hour mode, reading the AM/PM bit returns correct values (set if hour >= 12); however, writes to the bit are ignored.
7 bit 0
---- ---- Byte 5
.mmm mmmm
||| ||||
+++-++++- Minute (00 - 59, BCD)
7 bit 0
---- ---- Byte 6
.sss ssss
||| ||||
+++-++++- Second (00 - 59, BCD)
=== Alarm configuration ===
The alarm configuration register is two bytes in size; its interpretation depends on the configured interrupt mode.
==== Interrupt mode: Alarm ====
7 bit 0
---- ---- Byte 0
p.hh hhhh
| || ||||
| ++-++++- Hour to match for the alarm (BCD)
+--------- AM/PM bit to match for the alarm
7 bit 0
---- ---- Byte 1
.mmm mmmm
||| ||||
+++-++++- Minute to match for the alarm (BCD)
Note that the hour encoding of the alarm must match the hour encoding used by the clock itself.
==== Interrupt mode: Frequency ====
7 bit 0
---- ---- Byte 0
abcd efgh
|||| ||||
|||| |||+- 32768 Hz
|||| ||+-- 16384 Hz
|||| |+--- 8192 Hz
|||| +---- 4096 Hz
|||+------ 2048 Hz
||+------- 1024 Hz
|+-------- 512 Hz
+--------- 256 Hz
7 bit 0
---- ---- Byte 1
abcd efgh
|||| ||||
|||| |||+- 128 Hz
|||| ||+-- 64 Hz
|||| |+--- 32 Hz
|||| +---- 16 Hz
|||+------ 8 Hz
||+------- 4 Hz
|+-------- 2 Hz
+--------- 1 Hz
=== Initial power on state ===
* Year = <tt>$00</tt>
* Month = <tt>$01</tt>
* Day of month = <tt>$01</tt>
* Day of week = <tt>$00</tt>
* Hour = <tt>$00</tt>
* Minute = <tt>$00</tt>
* Second = <tt>$00</tt>
* Configuration = <tt>$82</tt>
* Alarm = <tt>$8000</tt>
== Commands ==
=== Reset RTC ($10, $11) ===
Writing $10 or $11 to port $CA will send the "reset" command to the RTC. The S-3511A will then reset the following registers:
* Year = <tt>$00</tt>
* Month = <tt>$01</tt>
* Day of month = <tt>$01</tt>
* Day of week = <tt>$00</tt>
* Hour = <tt>$00</tt>
* Minute = <tt>$00</tt>
* Second = <tt>$00</tt>
* Configuration = <tt>$00</tt>
* Alarm = <tt>$0000</tt>
It is unknown if it resets the sub-second prescaler.
=== Write Configuration ($12) ===
Writing $12 to port $CA will send the "set configuration" command to the RTC. The 2003 expects that $CB contains valid contents by the time the 2003 sends that register's contents.
=== Read Configuration ($13) ===
Writing $13 to port $CA will send the "get configuration" command to the RTC.
=== Write current YMDdHMS ($14) ===
Writing $14 will set the current Year, Month, Day-of-Month, Day-of-Week, Hour, Minute, and Second.
=== Read current YMDdHMS ($15) ===
Writing $15 will get the current Year, Month, Day-of-Month, Day-of-Week, Hour, Minute, and Second.
=== Write current HMS ($16) ===
Writing $16 will set the current Hour, Minute, and Second.
These are the same as command $14.
=== Read current HMS ($17) ===
Writing $17 will get the current Hour, Minute, and Second.
=== Write alarm configuration ($18) ===
Writing $18 will set the current alarm configuration. The interpretation of these two bytes depend on the Configuration register
=== Nonsense alarm configuration ($19) ===
Writing $19 will set the current alarm configuration to $FFFF. The 2003 thinks it's reading from the S-3511A, but the S-3511A disagrees.
$FFFF will be read back by the 2003.
=== Write nonsense ($1A) ===
Writing $1A expects to send 2 bytes to the RTC. The S-3511A ignores them.
=== Read nonsense ($1B) ===
Writing $1B expects to read 2 bytes from the RTC. The S-3511A leaves its output high, returning $FFFF.
== Interrupts ==
The 2003 and S-3511A do not provide a thread-safe way to acknowledge the IRQ. Since the 2003 only holds one byte at a time, an interrupt can be fired in the middle of a multi-byte read or write without knowing what needs to be done for the rest of the command, nor how to safely restart that command when exiting the interrupt.
As such, the only choices are:
* all communication to the 2003 happens while cartridge IRQs are disabled, or
* the only thing the interrupt handler can do is [[Interrupts#Interrupt_Enable|mask]] the interrupt and then [[Interrupts#Interrupt_Acknowledge|acknowledge]] it, and only afterwards handle any subsequent communication.
9257554945dd3042f5dfc5e34a7b678d23da4bf1
NEC V30MZ interrupts
0
58
549
346
2025-03-01T11:05:37Z
Asie
351
/* Timing */ document IRQ acknowledgement timing
wikitext
text/x-wiki
The NEC V30MZ provides six of the eight interrupts provided by the 80186.
== Interrupts ==
=== INT 0 - Divide Error ===
This interrupt is emitted as the result of a DIV<sup>IDIV</sup> or DIVU<sup>DIV</sup> instruction.
=== INT 1 - Single Step/Break ===
This interrupt is emitted if the single step flag is set after executing an instruction. (The instruction which changed the single step flag is ignored.) The single step flag is cleared for the duration of the interrupt, allowing the user to store state and perform debug activities; it is then restored when returning from the interrupt, by restoring the original processor flags stored on the stack.
=== INT 2 - Non-Maskable interrupt (NMI) ===
This interrupt is emitted when the SoC requests a non-maskable interrupt. On the WonderSwan, the condtions for emitting an NMI are configured by the relevant I/O port.
=== INT 3 - Breakpoint ===
This interrupt is emitted by the INT 3<sup>BRK</sup> instruction. Unlike other unconditional interrupt instructions, it is encoded with only one byte.
=== INT 4 - Overflow ===
This interrupt is emitted by the INTO<sup>BRKV</sup> instruction, if the overflow flag is set while it is being executed.
=== INT 5 - Array Bounds ===
This interrupt is emitted only by the BOUND<sup>CHKIND</sup> instruction.
== Timing ==
Both non-maskable and maskable interrupts are acknowledged after the execution of an instruction is complete. However, under some conditions, interrupts may not be processed on a given instruction and delayed until the next one. This is the case for:
* instructions which change the stack segment register (MOV and POP),
* prefix instructions (LOCK, REP, segment prefixes),
* instructions which set the interrupt enable CPU flag (STI, POPF) if the flag was cleared prior to the instruction's execution (for maskable interrupts only).
TODO: Document how many cycles interrupt processing takes.
== Notes ==
* The following 80186 interrupts are not implemented:
** INT 6 - Unused Opcode - the V30MZ treats most unimplemented instructions as NOPs.
** INT 7 - ESC Opcode - the V30MZ, likewise, treats these instructions as NOPs.
30f6d3d613d2fa77ef534d22ff2db46613cff761
550
549
2025-03-01T11:09:16Z
Asie
351
wikitext
text/x-wiki
== CPU interrupts ==
The NEC V30MZ implements six of the eight CPU interrupts provided by the 80186.
=== INT 0 - Divide Error ===
This interrupt is emitted as the result of a DIV<sup>IDIV</sup> or DIVU<sup>DIV</sup> instruction.
=== INT 1 - Single Step/Break ===
This interrupt is emitted if the single step flag is set after executing an instruction. (The instruction which changed the single step flag is ignored.) The single step flag is cleared for the duration of the interrupt, allowing the user to store state and perform debug activities; it is then restored when returning from the interrupt, by restoring the original processor flags stored on the stack.
=== INT 2 - Non-Maskable interrupt (NMI) ===
This interrupt is emitted when the SoC requests a non-maskable interrupt. On the WonderSwan, the condtions for emitting an NMI are configured by the relevant I/O port.
=== INT 3 - Breakpoint ===
This interrupt is emitted by the INT 3<sup>BRK</sup> instruction. Unlike other unconditional interrupt instructions, it is encoded with only one byte.
=== INT 4 - Overflow ===
This interrupt is emitted by the INTO<sup>BRKV</sup> instruction, if the overflow flag is set while it is being executed.
=== INT 5 - Array Bounds ===
This interrupt is emitted only by the BOUND<sup>CHKIND</sup> instruction.
== External interrupts ==
The NEC V30MZ distinguishes three sources of external interrupts - that is, interrupts not triggered by an instruction itself:
* Non-maskable interrupts:
** NMI - controlled by the NMI control I/O port on WS,
** BRK - controlled by the single-step flag.
* Maskable interrupts:
** IRQ - controlled by the IRQ control I/O ports on WS.
== Timing ==
Both non-maskable and maskable interrupts are acknowledged after the execution of an instruction is complete. However, under some conditions, interrupts may not be processed on a given instruction and delayed until the next one. This is the case for:
* instructions which change the stack segment register (MOV and POP),
* prefix instructions (LOCK, REP, segment prefixes),
* instructions which set the interrupt enable CPU flag (STI, POPF) if the flag was cleared prior to the instruction's execution (for maskable interrupts only).
TODO: Document how many cycles interrupt processing takes.
== Notes ==
* The following 80186 interrupts are not implemented:
** INT 6 - Unused Opcode - the V30MZ treats most unimplemented instructions as NOPs.
** INT 7 - ESC Opcode - the V30MZ, likewise, treats these instructions as NOPs.
faf5bdd681bc610330478d8b01ddd3e33aabbcb2
NEC V30MZ instruction set
0
68
551
543
2025-03-01T17:03:01Z
Asie
351
/* MOV */ fix encoding
wikitext
text/x-wiki
__NOTOC__
Note that this page is a work in progress.
{| class="wikitable" style="text-align: center"
|+ Official V30MZ (80186) Instructions
|-
| [[#AAA|AAA]] || [[#AAD|AAD]] || [[#AAM|AAM]] || [[#AAS|AAS]] || [[#ADC|ADC]] || [[#ADD|ADD]] || [[#AND|AND]] || [[#BOUND|BOUND]] || [[#CALL|CALL]] || [[#CBW|CBW]] || [[#CLC|CLC]]
|-
| [[#CLD|CLD]] || [[#CLI|CLI]] || [[#CMC|CMC]] || [[#CMP|CMP]] || [[#CMPSB|CMPSB]] || [[#CMPSW|CMPSW]] || [[#CS|CS]] || [[#CWD|CWD]] || [[#DAA|DAA]] || [[#DAS|DAS]] || [[#DEC|DEC]]
|-
| [[#DIV|DIV]] || [[#DS|DS]] || [[#ENTER|ENTER]] || [[#ES|ES]] || [[#HLT|HLT]] || [[#IDIV|IDIV]] || [[#IMUL|IMUL]] || [[#IN|IN]] || [[#INC|INC]] || [[#INSB|INSB]] || [[#INSW|INSW]]
|-
| [[#INT|INT]] || [[#INTO|INTO]] || [[#IRET|IRET]] || [[#JA|JA]] || [[#JBE|JBE]] || [[#JC|JC]] || [[#JCXZ|JCXZ]] || [[#JG|JG]] || [[#JGE|JGE]] || [[#JL|JL]] || [[#JLE|JLE]]
|-
| [[#JMP|JMP]] || [[#JNC|JNC]] || [[#JNO|JNO]] || [[#JNP|JNP]] || [[#JNS|JNS]] || [[#JNZ|JNZ]] || [[#JO|JO]] || [[#JP|JP]] || [[#JS|JS]] || [[#JZ|JZ]] || [[#LAHF|LAHF]]
|-
| [[#LDS|LDS]] || [[#LEA|LEA]] || [[#LEAVE|LEAVE]] || [[#LES|LES]] || [[#LOCK|LOCK]] || [[#LODSB|LODSB]] || [[#LODSW|LODSW]] || [[#LOOP|LOOP]] || [[#LOOPE|LOOPE]] || [[#LOOPNE|LOOPNE]] || [[#MOV|MOV]]
|-
| [[#MOVSB|MOVSB]] || [[#MOVSW|MOVSW]] || [[#MUL|MUL]] || [[#NEG|NEG]] || [[#NOP|NOP]] || [[#NOT|NOT]] || [[#OR|OR]] || [[#OUT|OUT]] || [[#OUTSB|OUTSB]] || [[#OUTSW|OUTSW]] || [[#POLL|POLL]]
|-
| [[#POP|POP]] || [[#POPA|POPA]] || [[#POPF|POPF]] || [[#PUSH|PUSH]] || [[#PUSHA|PUSHA]] || [[#PUSHF|PUSHF]] || [[#RCL|RCL]] || [[#RCR|RCR]] || [[#REP|REP]] || [[#REPNE|REPNE]] || [[#RET|RET]]
|-
| [[#RETF|RETF]] || [[#ROL|ROL]] || [[#ROR|ROR]] || [[#SAHF|SAHF]] || [[#SAR|SAR]] || [[#SBB|SBB]] || [[#SCASB|SCASB]] || [[#SCASW|SCASW]] || [[#SHL|SHL]] || [[#SHR|SHR]] || [[#SS|SS]]
|-
| [[#STC|STC]] || [[#STD|STD]] || [[#STI|STI]] || [[#STOSB|STOSB]] || [[#STOSW|STOSW]] || [[#SUB|SUB]] || [[#TEST|TEST]] || [[#XCHG|XCHG]] || [[#XLAT|XLAT]] || [[#XOR|XOR]]
|}
{| class="mw-collapsible mw-collapsed wikitable sortable" style="width: 340px;"
|+ style="white-space:nowrap; border:1px solid; padding:3px; border-color:rgb(162, 169, 177); background-color:rgb(234, 236, 240);" | Intel <-> NEC mnemonic translation table
!Intel
!NEC
|-
| [[#AAA|AAA]]
| [[#AAA|ADJBA]]
|-
| [[#AAD|AAD]]
| [[#AAD|CVTDB]]
|-
| [[#AAM|AAM]]
| [[#AAM|CVTBD]]
|-
| [[#AAS|AAS]]
| [[#AAS|ADJBS]]
|-
| [[#ADC|ADC]]
| [[#ADC|ADDC]]
|-
| [[#ADD|ADD]]
| [[#ADD|ADD]]
|-
| [[#AND|AND]]
| [[#AND|AND]]
|-
| [[#BOUND|BOUND]]
| [[#BOUND|CHKIND]]
|-
| [[#CALL|CALL]]
| [[#CALL|CALL]]
|-
| [[#CBW|CBW]]
| [[#CBW|CVTBW]]
|-
| [[#CLC|CLC]]
| [[#CLC|CLR1 CY]]
|-
| [[#CLD|CLD]]
| [[#CLD|CLR1 DIR]]
|-
| [[#CLI|CLI]]
| [[#CLI|DI]]
|-
| [[#CMC|CMC]]
| [[#CMC|NOT1 CY]]
|-
| [[#CMP|CMP]]
| [[#CMP|CMP]]
|-
| [[#CMPSB|CMPSB]]
| [[#CMPSB|CMPBKB]]
|-
| [[#CMPSW|CMPSW]]
| [[#CMPSW|CMPBKW]]
|-
| [[#CS|CS]]
| [[#CS|PS]]
|-
| [[#CWD|CWD]]
| [[#CWD|CVTWL]]
|-
| [[#DAA|DAA]]
| [[#DAA|ADJ4A]]
|-
| [[#DAS|DAS]]
| [[#DAS|ADJ4S]]
|-
| [[#DEC|DEC]]
| [[#DEC|DEC]]
|-
| [[#DIV|DIV]]
| [[#DIV|DIVU]]
|-
| [[#DS|DS]]
| [[#DS|DS0]]
|-
| [[#ENTER|ENTER]]
| [[#ENTER|PREPARE]]
|-
| [[#ES|ES]]
| [[#ES|DS1]]
|-
| [[#HLT|HLT]]
| [[#HLT|HALT]]
|-
| [[#IDIV|IDIV]]
| [[#IDIV|DIV]]
|-
| [[#IMUL|IMUL]]
| [[#IMUL|MUL]]
|-
| [[#IN|IN]]
| [[#IN|IN]]
|-
| [[#INC|INC]]
| [[#INC|INC]]
|-
| [[#INSB|INSB]]
| [[#INSB|INMB]]
|-
| [[#INSW|INSW]]
| [[#INSW|INMW]]
|-
| [[#INT|INT]]
| [[#INT|BRK]]
|-
| [[#INTO|INTO]]
| [[#INTO|BRKV]]
|-
| [[#IRET|IRET]]
| [[#IRET|RETI]]
|-
| [[#JA|JA]]
| [[#JA|BH]]
|-
| [[#JBE|JBE]]
| [[#JBE|BNH]]
|-
| [[#JC|JC/JB]]
| [[#JC|BC/BL]]
|-
| [[#JCXZ|JCXZ]]
| [[#JCXZ|BCWZ]]
|-
| [[#JG|JG]]
| [[#JG|BGT]]
|-
| [[#JGE|JGE]]
| [[#JGE|BGE]]
|-
| [[#JL|JL]]
| [[#JL|BLT]]
|-
| [[#JLE|JLE]]
| [[#JLE|BLE]]
|-
| [[#JMP|JMP]]
| [[#JMP|BR]]
|-
| [[#JNC|JNC/JAE]]
| [[#JNC|BNC/BNL]]
|-
| [[#JNO|JNO]]
| [[#JNO|BNV]]
|-
| [[#JNP|JNP]]
| [[#JNP|BPO]]
|-
| [[#JNS|JNS]]
| [[#JNS|BP]]
|-
| [[#JNZ|JNZ/JNE]]
| [[#JNZ|BNZ/BNE]]
|-
| [[#JO|JO]]
| [[#JO|BV]]
|-
| [[#JP|JP]]
| [[#JP|BPE]]
|-
| [[#JS|JS]]
| [[#JS|BN]]
|-
| [[#JZ|JZ/JE]]
| [[#JZ|BZ/BE]]
|-
| [[#LAHF|LAHF]]
| [[#LAHF|MOV]]
|-
| [[#LDS|LDS]]
| [[#LDS|MOV]]
|-
| [[#LEA|LEA]]
| [[#LEA|LDEA]]
|-
| [[#LEAVE|LEAVE]]
| [[#LEAVE|DISPOSE]]
|-
| [[#LES|LES]]
| [[#LES|MOV]]
|-
| [[#LOCK|LOCK]]
| [[#LOCK|BUSLOCK]]
|-
| [[#LODSB|LODSB]]
| [[#LODSB|LDMB]]
|-
| [[#LODSW|LODSW]]
| [[#LODSW|LDMW]]
|-
| [[#LOOP|LOOP]]
| [[#LOOP|DBNZ]]
|-
| [[#LOOPE|LOOPE]]
| [[#LOOPE|DBNZE]]
|-
| [[#LOOPNE|LOOPNE]]
| [[#LOOPNE|DBNZNE]]
|-
| [[#MOV|MOV]]
| [[#MOV|MOV]]
|-
| [[#MOVSB|MOVSB]]
| [[#MOVSB|MOVBKB]]
|-
| [[#MOVSW|MOVSW]]
| [[#MOVSW|MOVBKW]]
|-
| [[#MUL|MUL]]
| [[#MUL|MULU]]
|-
| [[#NEG|NEG]]
| [[#NEG|NEG]]
|-
| [[#NOP|NOP]]
| [[#NOP|NOP]]
|-
| [[#NOT|NOT]]
| [[#NOT|NOT]]
|-
| [[#OR|OR]]
| [[#OR|OR]]
|-
| [[#OUT|OUT]]
| [[#OUT|OUT]]
|-
| [[#OUTSB|OUTSB]]
| [[#OUTSB|OUTM]]
|-
| [[#OUTSW|OUTSW]]
| [[#OUTSW|OUTM]]
|-
| [[#POLL|POLL]]
| [[#POLL|POLL]]
|-
| [[#POP|POP]]
| [[#POP|POP]]
|-
| [[#POPA|POPA]]
| [[#POPA|POP]]
|-
| [[#POPF|POPF]]
| [[#POPF|POP]]
|-
| [[#PUSH|PUSH]]
| [[#PUSH|PUSH]]
|-
| [[#PUSHA|PUSHA]]
| [[#PUSHA|PUSH]]
|-
| [[#PUSHF|PUSHF]]
| [[#PUSHF|PUSH]]
|-
| [[#RCL|RCL]]
| [[#RCL|ROLC]]
|-
| [[#RCR|RCR]]
| [[#RCR|RORC]]
|-
| [[#REP|REP/REPE/REPZ]]
| [[#REP|REP/REPE/REPZ]]
|-
| [[#REPNE|REPNE/REPNZ]]
| [[#REPNE|REPNE/REPNZ]]
|-
| [[#RET|RET]]
| [[#RET|RET]]
|-
| [[#RETF|RETF]]
| [[#RETF|RET]]
|-
| [[#ROL|ROL]]
| [[#ROL|ROL]]
|-
| [[#ROR|ROR]]
| [[#ROR|ROR]]
|-
| [[#SAHF|SAHF]]
| [[#SAHF|MOV]]
|-
| [[#SAR|SAR]]
| [[#SAR|SHRA]]
|-
| [[#SBB|SBB]]
| [[#SBB|SUBC]]
|-
| [[#SCASB|SCASB]]
| [[#SCASB|CMPMB]]
|-
| [[#SCASW|SCASW]]
| [[#SCASW|CMPMW]]
|-
| [[#SHL|SHL]]
| [[#SHL|SHL]]
|-
| [[#SHR|SHR]]
| [[#SHR|SHR]]
|-
| [[#SS|SS]]
| [[#SS|SS]]
|-
| [[#STC|STC]]
| [[#STC|SET1 CY]]
|-
| [[#STD|STD]]
| [[#STD|SET1 DIR]]
|-
| [[#STI|STI]]
| [[#STI|EI]]
|-
| [[#STOSB|STOSB]]
| [[#STOSB|STMB]]
|-
| [[#STOSW|STOSW]]
| [[#STOSW|STMW]]
|-
| [[#SUB|SUB]]
| [[#SUB|SUB]]
|-
| [[#TEST|TEST]]
| [[#TEST|TEST]]
|-
| [[#XCHG|XCHG]]
| [[#XCHG|XCH]]
|-
| [[#XLAT|XLAT]]
| [[#XLAT|TRANS]]
|-
| [[#XOR|XOR]]
| [[#XOR|XOR]]
|}
== Official instructions by type ==
{| class="wikitable sortable" style="text-align: center"
!Type
!colspan=16 class="unsortable" | Instructions
|-
| style="text-align:left;" | Memory
| style="" | [[#MOV|MOV]]
| style="" | [[#XCHG|XCHG]]
| style="" | [[#XLAT|XLAT]]
| style="" | [[#LEA|LEA]]
| style="border-right:none;" | [[#LDS|LDS]]
| style="border-left:none;" | [[#LES|LES]]
| style="border-right:none;" | [[#IN|IN]]
| style="border-left:none;" | [[#OUT|OUT]]
| colspan="8" |
|-
| style="text-align:left;" | Ports
| style="border-right:none;" | [[#IN|IN]]
| style="border-left:none;" | [[#OUT|OUT]]
| style="border-right:none;" | [[#INSB|INSB]]
| style="border-left:none;" | [[#OUTSB|OUTSB]]
| style="border-right:none;" | [[#INSW|INSW]]
| style="border-left:none;" | [[#OUTSW|OUTSW]]
| colspan="10" |
|-
| style="text-align:left;" | Arithmetic
| style="border-right:none;" | [[#ADD|ADD]]
| style="border-left:none;" | [[#SUB|SUB]]
| style="border-right:none;" | [[#ADC|ADC]]
| style="border-left:none;" | [[#SBB|SBB]]
| style="border-right:none;" | [[#INC|INC]]
| style="border-left:none;" | [[#DEC|DEC]]
| style="border-right:none;" | [[#MUL|MUL]]
| style="border-left:none;" | [[#DIV|DIV]]
| style="border-right:none;" | [[#IMUL|IMUL]]
| style="border-left:none;" | [[#IDIV|IDIV]]
| style="" | [[#CMP|CMP]]
| style="" | [[#NEG|NEG]]
| colspan="4" |
|-
| style="text-align:left;" | Numeric
| style="" | [[#CBW|CBW]]
| style="" | [[#CWD|CWD]]
| style="" | [[#AAA|AAA]]
| style="" | [[#AAS|AAS]]
| style="" | [[#AAM|AAM]]
| style="" | [[#AAD|AAD]]
| style="" | [[#DAA|DAA]]
| style="" | [[#DAS|DAS]]
| colspan="8" |
|-
| style="text-align:left;" | Shift
| style="border-right:none;" | [[#ROL|ROL]]
| style="border-left:none;" | [[#ROR|ROR]]
| style="border-right:none;" | [[#RCL|RCL]]
| style="border-left:none;" | [[#RCR|RCR]]
| style="border-right:none;" | [[#SHL|SHL]]
| style="border-left:none;" | [[#SHR|SHR]]
| style="" | [[#SAR|SAR]]
| colspan="9" |
|-
| style="text-align:left;" | Bitwise
| style="" | [[#AND|AND]]
| style="" | [[#OR|OR]]
| style="" | [[#XOR|XOR]]
| style="" | [[#NOT|NOT]]
| style="" | [[#TEST|TEST]]
| colspan="11" |
|-
| style="text-align:left;" | Branch
| style="border-right:none;" | [[#JC|JC]]
| style="border-left:none;" | [[#JNC|JNC]]
| style="border-right:none;" | [[#JZ|JZ]]
| style="border-left:none;" | [[#JNZ|JNZ]]
| style="border-right:none;" | [[#JBE|JBE]]
| style="border-left:none;" | [[#JA|JA]]
| style="border-right:none;" | [[#JO|JO]]
| style="border-left:none;" | [[#JNO|JNO]]
| style="border-right:none;" | [[#JP|JP]]
| style="border-left:none;" | [[#JNP|JNP]]
| style="border-right:none;" | [[#JS|JS]]
| style="border-left:none;" | [[#JNS|JNS]]
| style="border-right:none;" | [[#JL|JL]]
| style="border-left:none;" | [[#JGE|JGE]]
| style="border-right:none;" | [[#JLE|JLE]]
| style="border-left:none;" | [[#JG|JG]]
|-
| style="text-align:left;" | Jump
| style="" | [[#JMP|JMP]]
| style="border-right:none;" | [[#CALL|CALL]]
| style="border-left:none;border-right:none;" | [[#RET|RET]]
| style="border-left:none;" | [[#RETF|RETF]]
| colspan="12" |
|-
| style="text-align:left;" | Loop
| style="" | [[#LOOP|LOOP]]
| style="" | [[#LOOPE|LOOPE]]
| style="" | [[#LOOPNE|LOOPNE]]
| colspan="13" |
|-
| style="text-align:left;" | Interrupt
| style="border-right:none;" | [[#INT|INT]]
| style="border-left:none;" | [[#IRET|IRET]]
| style="" | [[#INTO|INTO]]
| style="" | [[#HLT|HLT]]
| style="" | [[#BOUND|BOUND]]
| colspan="11" |
|-
| style="text-align:left;" | Stack
| style="border-right:none;" | [[#PUSH|PUSH]]
| style="border-left:none;" | [[#POP|POP]]
| style="border-right:none;" | [[#PUSHA|PUSHA]]
| style="border-left:none;" | [[#POPA|POPA]]
| style="border-right:none;" | [[#PUSHF|PUSHF]]
| style="border-left:none;" | [[#POPF|POPF]]
| colspan="10" |
|-
| style="text-align:left;" | Flags
| style="border-right:none;" | [[#CLC|CLC]]
| style="border-left:none;" | [[#STC|STC]]
| style="border-right:none;" | [[#CLD|CLD]]
| style="border-left:none;" | [[#STD|STD]]
| style="border-right:none;" | [[#CLI|CLI]]
| style="border-left:none;" | [[#STI|STI]]
| style="" | [[#CMC|CMC]]
| style="border-right:none;" | [[#LAHF|LAHF]]
| style="border-left:none;" | [[#SAHF|SAHF]]
| colspan="7" |
|-
| style="text-align:left;" | Prefix
| style="" | [[#CS|CS]]
| style="" | [[#DS|DS]]
| style="" | [[#ES|ES]]
| style="" | [[#SS|SS]]
| colspan="12" |
|-
| style="text-align:left;" | String
| style="border-right:none;" | [[#REP|REP]]
| style="border-left:none;border-right:none;" | [[#REP|REPE]]
| style="border-left:none;" | [[#REPNE|REPNE]]
| style="" | [[#MOVSB|MOVSB]]
| style="" | [[#MOVSW|MOVSW]]
| style="border-right:none;" | [[#LODSB|LODSB]]
| style="border-left:none;" | [[#STOSB|STOSB]]
| style="border-right:none;" | [[#LODSW|LODSW]]
| style="border-left:none;" | [[#STOSW|STOSW]]
| style="" | [[#CMPSB|CMPSB]]
| style="" | [[#SCASB|SCASB]]
| style="" | [[#CMPSW|CMPSW]]
| style="" | [[#SCASW|SCASW]]
| colspan="3" |
|-
| style="text-align:left;" | Other
| style="" | [[#NOP|NOP]]
| style="border-right:none;" | [[#ENTER|ENTER]]
| style="border-left:none;" | [[#LEAVE|LEAVE]]
| style="" | [[#LOCK|LOCK]]
| style="" | [[#POLL|POLL]]
| colspan="11" |
|}
== Instruction encoding ==
=== ModR/M byte ===
The ModR/M byte is used in most addressing modes which reference a memory location. This byte consists of three bitfield values:
* <tt>oo</tt> - M'''o'''de;
* <tt>rrr</tt> - Two possible functions:
** '''R'''egister (for addressing modes which require both a register and a register/memory operand),
** Opcode extension (for some opcodes' addressing modes which do not have such a requirement);
* <tt>mmm</tt> - Register/'''M'''emory.
The ''Mode'' and ''Register/Memory'' bitfields can refer to a memory location or to a register, as shown in the table below.
Some instructions define a second argument using the ''Register'' field. It is always interpreted as if ''Mode'' was equal to <tt>11</tt> and, as such, can refer to a register only.
{| class="wikitable" style="text-align: center"
! R/M \ Mode
! <tt>00</tt>
! <tt>01</tt>
! <tt>10</tt>
! <tt>11</tt> ''(byte)''
! <tt>11</tt> ''(word)''
|-
| <tt>000</tt>
| DS:[BX + SI]
| DS:[BX + SI + disp8]
| DS:[BX + SI + disp16]
| AL
| AX
|-
| <tt>001</tt>
| DS:[BX + DI]
| DS:[BX + DI + disp8]
| DS:[BX + DI + disp16]
| CL
| CX
|-
| <tt>010</tt>
| SS:[BP + SI]
| SS:[BP + SI + disp8]
| SS:[BP + SI + disp16]
| DL
| DX
|-
| <tt>011</tt>
| SS:[BP + DI]
| SS:[BP + DI + disp8]
| SS:[BP + DI + disp16]
| BL
| BX
|-
| <tt>100</tt>
| DS:[SI]
| DS:[SI + disp8]
| DS:[SI + disp16]
| AH
| SP
|-
| <tt>101</tt>
| DS:[DI]
| DS:[DI + disp8]
| DS:[DI + disp16]
| CH
| BP
|-
| <tt>110</tt>
| ''DS:[disp16]''
| SS:[BP + disp8]
| SS:[BP + disp16]
| DH
| SI
|-
| <tt>111</tt>
| DS:[BX]
| DS:[BX + disp8]
| DS:[BX + disp16]
| BH
| DI
|}
Displacements are either 8-bit (disp8) or 16-bit (disp16) signed values and they always immediately follow the ModR/M byte. Note that (<tt>oo</tt> = <tt>00</tt>, <tt>mmm</tt> = <tt>110</tt>) is a special case, in which the ''disp16'' value is used directly as a near pointer.
The instruction encoding lists below refer to this byte as <tt>oorrrmmm</tt> (binary), <tt>/r</tt> (hexadecimal) or <tt>/0</tt> (hexademical, <tt>rrr</tt> used as function <tt>0</tt>).
== Official instructions ==
{{Anchor|AAA}}
=== AAA ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| AAA || <tt>37</tt> || <tt>00110111</tt> || 1 || 9
|}
----
{{Anchor|AAD}}
=== AAD ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| AAD imm8 || <tt>B5 ii</tt> || <tt>11010100 iiiiiiii</tt> || 2 || 6
|}
----
{{Anchor|AAM}}
=== AAM ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| AAM imm8 || <tt>B4 ii</tt> || <tt>11010100 iiiiiiii</tt> || 2 || 17
|}
----
{{Anchor|AAS}}
=== AAS ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| AAS || <tt>3F</tt> || <tt>00111111</tt> || 1 || 9
|}
----
{{Anchor|ADC}}
=== ADC ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| ADC AL, imm || <tt>14 ii</tt> || <tt>00010100 iiiiiiii</tt> || 2 || 1
|-
| ADC AX, imm || <tt>15 ii ii</tt> || <tt>00010101 iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| ADC mem8, imm8 || <tt>80 /2 ii</tt> || <tt>10000000 oo010mmm iiiiiiii</tt> || 3+ || 3
|-
| ADC mem16, imm16 || <tt>81 /2 ii ii</tt> || <tt>10000001 oo010mmm iiiiiiii iiiiiiii</tt> || 4+ || 3
|-
| ADC mem16, simm8 || <tt>83 /2 ii</tt> || <tt>10000011 oo010mmm iiiiiiii</tt> || 3+ || 3
|-
| ADC mem8, reg8 || <tt>10 /r</tt> || <tt>00010000 oorrrmmm</tt> || 2+ || 3
|-
| ADC mem16, reg16 || <tt>11 /r</tt> || <tt>00010001 oorrrmmm</tt> || 2+ || 3
|-
| ADC reg8, imm8 || <tt>80 /2 ii</tt> || <tt>10000000 11010mmm iiiiiiii</tt> || 3 || 1
|-
| ADC reg16, imm16 || <tt>81 /2 ii ii</tt> || <tt>10000001 11010mmm iiiiiiii iiiiiiii</tt> || 4 || 1
|-
| ADC reg16, simm8 || <tt>83 /2 ii</tt> || <tt>10000011 11010mmm iiiiiiii</tt> || 3 || 1
|-
| ADC reg8, mem8 || <tt>12 /r</tt> || <tt>00010010 oorrrmmm</tt> || 2+ || 2
|-
| ADC reg16, mem16 || <tt>13 /r</tt> || <tt>00010011 oorrrmmm</tt> || 2+ || 2
|-
| ADC reg8, reg8 || <tt>10 /r</tt> || <tt>000100.0 11rrrmmm</tt> || 2 || 1
|-
| ADC reg16, reg16 || <tt>11 /r</tt> || <tt>000100.1 11rrrmmm</tt> || 2 || 1
|}
----
{{Anchor|ADD}}
=== ADD ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| ADD AL, imm || <tt>04 ii</tt> || <tt>00000100 iiiiiiii</tt> || 2 || 1
|-
| ADD AX, imm || <tt>05 ii ii</tt> || <tt>00000101 iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| ADD mem8, imm8 || <tt>80 /0 ii</tt> || <tt>10000000 oo000mmm iiiiiiii</tt> || 3+ || 3
|-
| ADD mem16, imm16 || <tt>81 /0 ii ii</tt> || <tt>10000001 oo000mmm iiiiiiii iiiiiiii</tt> || 4+ || 3
|-
| ADD mem16, simm8 || <tt>83 /0 ii</tt> || <tt>10000011 oo000mmm iiiiiiii</tt> || 3+ || 3
|-
| ADD mem8, reg8 || <tt>00 /r</tt> || <tt>00000000 oorrrmmm</tt> || 2+ || 3
|-
| ADD mem16, reg16 || <tt>01 /r</tt> || <tt>00000001 oorrrmmm</tt> || 2+ || 3
|-
| ADD reg8, imm8 || <tt>80 /0 ii</tt> || <tt>10000000 11000mmm iiiiiiii</tt> || 3 || 1
|-
| ADD reg16, imm16 || <tt>81 /0 ii ii</tt> || <tt>10000001 11000mmm iiiiiiii iiiiiiii</tt> || 4 || 1
|-
| ADD reg16, simm8 || <tt>83 /0 ii</tt> || <tt>10000011 11000mmm iiiiiiii</tt> || 3 || 1
|-
| ADD reg8, mem8 || <tt>02 /r</tt> || <tt>00000010 oorrrmmm</tt> || 2+ || 2
|-
| ADD reg16, mem16 || <tt>03 /r</tt> || <tt>00000011 oorrrmmm</tt> || 2+ || 2
|-
| ADD reg8, reg8 || <tt>00 /r</tt> || <tt>000000.0 11rrrmmm</tt> || 2 || 1
|-
| ADD reg16, reg16 || <tt>01 /r</tt> || <tt>000000.1 11rrrmmm</tt> || 2 || 1
|}
----
{{Anchor|AND}}
=== AND ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| AND AL, imm || <tt>24 ii</tt> || <tt>00100100 iiiiiiii</tt> || 2 || 1
|-
| AND AX, imm || <tt>25 ii ii</tt> || <tt>00100101 iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| AND mem8, imm8 || <tt>80 /4 ii</tt> || <tt>10000000 oo100mmm iiiiiiii</tt> || 3+ || 3
|-
| AND mem16, imm16 || <tt>81 /4 ii ii</tt> || <tt>10000001 oo100mmm iiiiiiii iiiiiiii</tt> || 4+ || 3
|-
| AND mem16, simm8 || <tt>83 /4 ii</tt> || <tt>10000011 oo100mmm iiiiiiii</tt> || 3+ || 3
|-
| AND mem8, reg8 || <tt>20 /r</tt> || <tt>00100000 oorrrmmm</tt> || 2+ || 3
|-
| AND mem16, reg16 || <tt>21 /r</tt> || <tt>00100001 oorrrmmm</tt> || 2+ || 3
|-
| AND reg8, imm8 || <tt>80 /4 ii</tt> || <tt>10000000 11100mmm iiiiiiii</tt> || 3 || 1
|-
| AND reg16, imm16 || <tt>81 /4 ii ii</tt> || <tt>10000001 11100mmm iiiiiiii iiiiiiii</tt> || 4 || 1
|-
| AND reg16, simm8 || <tt>83 /4 ii</tt> || <tt>10000011 11100mmm iiiiiiii</tt> || 3 || 1
|-
| AND reg8, mem8 || <tt>22 /r</tt> || <tt>00100010 oorrrmmm</tt> || 2+ || 2
|-
| AND reg16, mem16 || <tt>23 /r</tt> || <tt>00100011 oorrrmmm</tt> || 2+ || 2
|-
| AND reg8, reg8 || <tt>20 /r</tt> || <tt>001000.0 11rrrmmm</tt> || 2 || 1
|-
| AND reg16, reg16 || <tt>21 /r</tt> || <tt>001000.1 11rrrmmm</tt> || 2 || 1
|}
----
{{Anchor|BOUND}}
=== BOUND ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| BOUND reg16, mem16:16 || <tt>62 /r</tt> || <tt>01100010 oorrrmmm</tt> || 2+ || 13 (20 if condition met)
|}
----
{{Anchor|CALL}}
=== CALL ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| CALL ptr16:16 || <tt>CA oo oo ss ss</tt> || <tt>10011010 oooooooo oooooooo ssssssss ssssssss</tt> || 5 || 10
|-
| CALL mem16 || <tt>FF /2</tt> || <tt>11111111 oo010mmm</tt> || 2+ || 6
|-
| CALL mem16:16 || <tt>FF /3</tt> || <tt>11111111 oo011mmm</tt> || 2+ || 12
|-
| CALL reg16 || <tt>FF /2</tt> || <tt>11111111 11010mmm</tt> || 2 || 5
|-
| CALL rel16 || <tt>E8 ii ii</tt> || <tt>11101000 iiiiiiii iiiiiiii</tt> || 3 || 5
|}
----
{{Anchor|CBW}}
=== CBW ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| CBW || <tt>98</tt> || <tt>10011000</tt> || 1 || 1
|}
----
{{Anchor|CLC}}
=== CLC ===
{| class="wikitable"
! Flag !! New value
|-
| [[NEC_V30MZ_flags#CF|CF - Carry]] || 0
|}
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| CLC || <tt>F8</tt> || <tt>11111000</tt> || 1 || 4
|}
----
{{Anchor|CLD}}
=== CLD ===
{| class="wikitable"
! Flag !! New value
|-
| [[NEC_V30MZ_flags#DF|DF - Direction]] || 0
|}
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| CLD || <tt>FC</tt> || <tt>11111100</tt> || 1 || 4
|}
----
{{Anchor|CLI}}
=== CLI ===
{| class="wikitable"
! Flag !! New value
|-
| [[NEC_V30MZ_flags#IF|IF - Interrupt]] || 0
|}
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| CLI || <tt>FA</tt> || <tt>11111010</tt> || 1 || 4
|}
----
{{Anchor|CMC}}
=== CMC ===
{| class="wikitable"
! Flag !! New value
|-
| [[NEC_V30MZ_flags#CF|CF - Carry]] || !CF
|}
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| CMC || <tt>F5</tt> || <tt>11110101</tt> || 1 || 4
|}
----
{{Anchor|CMP}}
=== CMP ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| CMP AL, imm || <tt>3C ii</tt> || <tt>00111100 iiiiiiii</tt> || 2 || 1
|-
| CMP AX, imm || <tt>3D ii ii</tt> || <tt>00111101 iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| CMP mem8, imm8 || <tt>80 /7 ii</tt> || <tt>10000000 oo111mmm iiiiiiii</tt> || 3+ || 2
|-
| CMP mem16, imm16 || <tt>81 /7 ii ii</tt> || <tt>10000001 oo111mmm iiiiiiii iiiiiiii</tt> || 4+ || 2
|-
| CMP mem16, simm8 || <tt>83 /7 ii</tt> || <tt>10000011 oo111mmm iiiiiiii</tt> || 3+ || 2
|-
| CMP mem8, reg8 || <tt>38 /r</tt> || <tt>00111000 oorrrmmm</tt> || 2+ || 2
|-
| CMP mem16, reg16 || <tt>39 /r</tt> || <tt>00111001 oorrrmmm</tt> || 2+ || 2
|-
| CMP reg8, imm8 || <tt>80 /7 ii</tt> || <tt>10000000 11111mmm iiiiiiii</tt> || 3 || 1
|-
| CMP reg16, imm16 || <tt>81 /7 ii ii</tt> || <tt>10000001 11111mmm iiiiiiii iiiiiiii</tt> || 4 || 1
|-
| CMP reg16, simm8 || <tt>83 /7 ii</tt> || <tt>10000011 11111mmm iiiiiiii</tt> || 3 || 1
|-
| CMP reg8, mem8 || <tt>3A /r</tt> || <tt>00111010 oorrrmmm</tt> || 2+ || 2
|-
| CMP reg16, mem16 || <tt>3B /r</tt> || <tt>00111011 oorrrmmm</tt> || 2+ || 2
|-
| CMP reg8, reg8 || <tt>38 /r</tt> || <tt>001110.0 11rrrmmm</tt> || 2 || 1
|-
| CMP reg16, reg16 || <tt>39 /r</tt> || <tt>001110.1 11rrrmmm</tt> || 2 || 1
|}
----
{{Anchor|CMPSB}}
{{Anchor|CMPSW}}
=== CMPSB/CMPSW ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| CMPSB || <tt>A6</tt> || <tt>10100110</tt> || 1 || 6
|-
| CMPSW || <tt>A7</tt> || <tt>10100111</tt> || 1 || 6
|}
----
{{Anchor|CS}}
=== CS ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| CS || <tt>2E</tt> || <tt>00101110</tt> || 1 || 1
|}
----
{{Anchor|CWD}}
=== CWD ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| CWD || <tt>99</tt> || <tt>10011001</tt> || 1 || 1
|}
----
{{Anchor|DAA}}
=== DAA ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| DAA || <tt>27</tt> || <tt>00100111</tt> || 1 || 10
|}
----
{{Anchor|DAS}}
=== DAS ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| DAS || <tt>2F</tt> || <tt>00101111</tt> || 1 || 10
|}
----
{{Anchor|DEC}}
=== DEC ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| DEC mem8 || <tt>FE /1</tt> || <tt>11111110 oo001mmm</tt> || 2+ || 3
|-
| DEC mem16 || <tt>FF /1</tt> || <tt>11111111 oo001mmm</tt> || 2+ || 3
|-
| DEC reg8 || <tt>FE /1</tt> || <tt>11111110 11001mmm</tt> || 2+ || 1
|-
| DEC reg16 || <tt>4x</tt> || <tt>01001rrr</tt> || 1 || 1
|}
----
{{Anchor|DIV}}
=== DIV ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| DIV mem8 || <tt>F6 /6</tt> || <tt>11110110 oo110mmm</tt> || 2+ || 16
|-
| DIV mem16 || <tt>F7 /6</tt> || <tt>11111111 oo110mmm</tt> || 2+ || 24
|-
| DIV reg8 || <tt>F6 /6</tt> || <tt>11111110 11110mmm</tt> || 2 || 15
|-
| DIV reg16 || <tt>F7 /6</tt> || <tt>11111111 11110mmm</tt> || 2 || 23
|}
----
{{Anchor|DS}}
=== DS ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| DS || <tt>3E</tt> || <tt>00111110</tt> || 1 || 1
|}
----
{{Anchor|ENTER}}
=== ENTER ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| ENTER imm16, imm8 || <tt>C8 ii ii jj</tt> || <tt>11001000 iiiiiiii iiiiiiii jjjjjjjj</tt> || 3 || 8 (imm8 = 0)<br/>14 (imm8 = 1)<br/>15 + imm8 * 4 (imm8 >= 2)
|}
----
{{Anchor|ES}}
=== ES ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| ES || <tt>26</tt> || <tt>00100110</tt> || 1 || 1
|}
----
{{Anchor|HLT}}
=== HLT ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| HLT || <tt>F4</tt> || <tt>11110100</tt> || 1 || 9
|}
----
{{Anchor|IDIV}}
=== IDIV ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| IDIV mem8 || <tt>F6 /7</tt> || <tt>11110110 oo111mmm</tt> || 2+ || 18
|-
| IDIV mem16 || <tt>F7 /7</tt> || <tt>11111111 oo111mmm</tt> || 2+ || 25
|-
| IDIV reg8 || <tt>F6 /7</tt> || <tt>11111110 11111mmm</tt> || 2 || 17
|-
| IDIV reg16 || <tt>F7 /7</tt> || <tt>11111111 11111mmm</tt> || 2 || 24
|}
----
{{Anchor|IMUL}}
=== IMUL ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| IMUL mem8 || <tt>F6 /5</tt> || <tt>11110110 oo101mmm</tt> || 2+ || 4
|-
| IMUL mem16 || <tt>F7 /5</tt> || <tt>11111111 oo101mmm</tt> || 2+ || 4
|-
| IMUL reg8 || <tt>F6 /5</tt> || <tt>11111110 11101mmm</tt> || 2 || 3
|-
| IMUL reg16 || <tt>F7 /5</tt> || <tt>11111111 11101mmm</tt> || 2 || 3
|-
| IMUL reg16, mem16, imm16 || <tt>69 /r ii ii</tt> || <tt>11111111 oorrrmmm iiiiiiii iiiiiiii</tt> || 4 || 4
|-
| IMUL reg16, mem16, simm8 || <tt>6B /r ii</tt> || <tt>11111111 oorrrmmm iiiiiiii</tt> || 3 || 4
|-
| IMUL reg16, reg16, imm16 || <tt>69 /r ii ii</tt> || <tt>11111111 11rrrmmm iiiiiiii iiiiiiii</tt> || 4 || 3
|-
| IMUL reg16, reg16, simm8 || <tt>6B /r ii</tt> || <tt>11111111 11rrrmmm iiiiiiii</tt> || 3 || 3
|}
----
{{Anchor|IN}}
=== IN ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| IN AL, DX || <tt>EC</tt> || <tt>11101100</tt> || 1 || 6
|-
| IN AX, DX || <tt>ED</tt> || <tt>11101101</tt> || 1 || 6
|-
| IN AL, imm8 || <tt>E4 ii</tt> || <tt>11100100 iiiiiiii</tt> || 2 || 6
|-
| IN AX, imm8 || <tt>E5 ii</tt> || <tt>11100101 iiiiiiii</tt> || 2 || 6
|}
----
{{Anchor|INC}}
=== INC ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| INC mem8 || <tt>FE /0</tt> || <tt>11111110 oo000mmm</tt> || 2+ || 3
|-
| INC mem16 || <tt>FF /0</tt> || <tt>11111111 oo000mmm</tt> || 2+ || 3
|-
| INC reg8 || <tt>FE /0</tt> || <tt>11111110 11000mmm</tt> || 2+ || 1
|-
| INC reg16 || <tt>4x</tt> || <tt>01000rrr</tt> || 1 || 1
|}
----
{{Anchor|INSB}}
{{Anchor|INSW}}
=== INSB/INSW ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| INSB || <tt>6C</tt> || <tt>01101100</tt> || 1 || 6
|-
| INSW || <tt>6D</tt> || <tt>01101101</tt> || 1 || 6
|}
----
{{Anchor|INT}}
=== INT ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| INT 3 || <tt>CC</tt> || <tt>11001100</tt> || 1 || 9
|-
| INT imm8 || <tt>CD ii</tt> || <tt>11001101 iiiiiiii</tt> || 2 || 10
|}
----
{{Anchor|INTO}}
=== INTO ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| INTO || <tt>CE</tt> || <tt>11001110</tt> || 1 || 6 (13 if OF = 1)
|}
----
{{Anchor|IRET}}
=== IRET ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| IRET || <tt>CF</tt> || <tt>11001111</tt> || 1 || 10
|}
----
{{Anchor|JA}}
=== JA ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JA rel8 || <tt>77 ii</tt> || <tt>01110111 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JBE}}
=== JBE ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JA rel8 || <tt>76 ii</tt> || <tt>01110110 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JC}}
=== JC/JB ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JC rel8 || <tt>72 ii</tt> || <tt>01110010 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JCXZ}}
=== JCXZ ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JCXZ rel8 || <tt>E3 ii</tt> || <tt>11100011 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JG}}
=== JG ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JG rel8 || <tt>7F ii</tt> || <tt>01111111 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JGE}}
=== JGE ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JGE rel8 || <tt>7D ii</tt> || <tt>01111101 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JL}}
=== JL ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JL rel8 || <tt>7C ii</tt> || <tt>01111100 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JLE}}
=== JLE ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JLE rel8 || <tt>7E ii</tt> || <tt>01111110 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JMP}}
=== JMP ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JMP ptr16:16 || <tt>EA oo oo ss ss</tt> || <tt>11101010 oooooooo oooooooo ssssssss ssssssss</tt> || 5 || 7
|-
| JMP mem16 || <tt>FF /4</tt> || <tt>11111111 oo100mmm</tt> || 2+ || 5
|-
| JMP mem16:16 || <tt>FF /5</tt> || <tt>11111111 oo101mmm</tt> || 2+ || 10
|-
| JMP reg16 || <tt>FF /4</tt> || <tt>11111111 11100mmm</tt> || 2 || 4
|-
| JMP rel8 || <tt>EB ii</tt> || <tt>11101011 iiiiiiii</tt> || 2 || 4
|-
| JMP rel16 || <tt>E9 ii ii</tt> || <tt>11101001 iiiiiiii iiiiiiii</tt> || 3 || 4
|}
----
{{Anchor|JNC}}
=== JNC/JAE ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JNC rel8 || <tt>73 ii</tt> || <tt>01110011 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JNO}}
=== JNO ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JNO rel8 || <tt>71 ii</tt> || <tt>01110001 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JNP}}
=== JNP ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JNP rel8 || <tt>7B ii</tt> || <tt>01111011 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JNS}}
=== JNS ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JNS rel8 || <tt>79 ii</tt> || <tt>01111001 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JNZ}}
=== JNZ/JNE ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JNZ rel8 || <tt>75 ii</tt> || <tt>01110101 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JO}}
=== JO ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JO rel8 || <tt>70 ii</tt> || <tt>01110000 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JP}}
=== JP ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JP rel8 || <tt>7A ii</tt> || <tt>01111010 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JS}}
=== JS ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JS rel8 || <tt>78 ii</tt> || <tt>01111000 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JZ}}
=== JZ/JE ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JZ rel8 || <tt>74 ii</tt> || <tt>01110100 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|LAHF}}
=== LAHF ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| LAHF || <tt>9F</tt> || <tt>10011111</tt> || 1 || 2
|}
----
{{Anchor|LDS}}
=== LDS ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| LDS reg16, mem16 || <tt>C5 /r</tt> || <tt>11000101 oorrrmmm</tt> || 2+ || 6
|}
----
{{Anchor|LEA}}
=== LEA ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| LEA reg16, mem16 || <tt>8D /r</tt> || <tt>10001101 oorrrmmm</tt> || 2+ || 1
|}
----
{{Anchor|LEAVE}}
=== LEAVE ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| LEAVE || <tt>C9</tt> || <tt>11001001</tt> || 1 || 2
|}
----
{{Anchor|LES}}
=== LES ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| LES reg16, mem16 || <tt>C4 /r</tt> || <tt>11000100 oorrrmmm</tt> || 2+ || 6
|}
----
{{Anchor|LOCK}}
=== LOCK ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| LOCK || <tt>F0</tt> || <tt>11110000</tt> || 1 || 1
|}
----
{{Anchor|LODSB}}
{{Anchor|LODSW}}
=== LODSB/LODSW ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| LODSB || <tt>AC</tt> || <tt>10101100</tt> || 1 || 3
|-
| LODSW || <tt>AD</tt> || <tt>10101101</tt> || 1 || 3
|}
----
{{Anchor|LOOP}}
=== LOOP ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| LOOP rel8 || <tt>E2 ii</tt> || <tt>11100010 iiiiiiii</tt> || 2 || 2 (5 if branch taken)
|}
----
{{Anchor|LOOPE}}
=== LOOPE ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| LOOPE rel8 || <tt>E1 ii</tt> || <tt>11100001 iiiiiiii</tt> || 2 || 3 (6 if branch taken)
|}
----
{{Anchor|LOOPNE}}
=== LOOPNE ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| LOOPNE rel8 || <tt>E0 ii</tt> || <tt>11100000 iiiiiiii</tt> || 2 || 3 (6 if branch taken)
|}
----
{{Anchor|MOV}}
=== MOV ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| MOV AL, ptr16 || <tt>A0 ii ii</tt> || <tt>10100000 iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| MOV AX, ptr16 || <tt>A1 ii ii</tt> || <tt>10100001 iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| MOV mem8, imm8 || <tt>C6 /0 ii</tt> || <tt>11000110 oo000mmm iiiiiiii</tt> || 3+ || 1
|-
| MOV mem16, imm16 || <tt>C7 /0 ii ii</tt> || <tt>11000111 oo000mmm iiiiiiii iiiiiiii</tt> || 4+ || 1
|-
| MOV mem8, reg8 || <tt>88 /r</tt> || <tt>10001000 oorrrmmm</tt> || 2+ || 1
|-
| MOV mem16, reg16 || <tt>89 /r</tt> || <tt>10001001 oorrrmmm</tt> || 2+ || 1
|-
| MOV mem16, sreg16 || <tt>8C /r</tt> || <tt>10001100 oo0rrmmm</tt> || 2+ || 3
|-
| MOV ptr16, AL || <tt>A2 ii ii</tt> || <tt>10100010 iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| MOV ptr16, AX || <tt>A3 ii ii</tt> || <tt>10100011 iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| MOV reg8, imm8 || <tt>Bx ii</tt> || <tt>10110rrr iiiiiiii</tt> || 2 || 1
|-
| MOV reg8, imm8 || <tt>C6 /0 ii</tt> || <tt>11000110 11000mmm iiiiiiii</tt> || 3 || 1
|-
| MOV reg16, imm16 || <tt>Bx ii</tt> || <tt>10111rrr iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| MOV reg16, imm16 || <tt>C7 /0 ii ii</tt> || <tt>11000111 11000mmm iiiiiiii iiiiiiii</tt> || 4 || 1
|-
| MOV reg8, mem8 || <tt>8A /r</tt> || <tt>10001010 oorrrmmm</tt> || 2+ || 1
|-
| MOV reg16, mem16 || <tt>8B /r</tt> || <tt>10001011 oorrrmmm</tt> || 2+ || 1
|-
| MOV reg8, reg8 || <tt>88 /r</tt> || <tt>100010.0 11rrrmmm</tt> || 2 || 1
|-
| MOV reg16, reg16 || <tt>89 /r</tt> || <tt>100010.1 11rrrmmm</tt> || 2 || 1
|-
| MOV reg16, sreg16 || <tt>8C /r</tt> || <tt>10001100 110rrmmm</tt> || 2 || 1
|-
| MOV sreg16, mem16 || <tt>8E /r</tt> || <tt>10001110 oo0rrmmm</tt> || 2 || 3
|-
| MOV sreg16, reg16 || <tt>8E /r</tt> || <tt>10001110 110rrmmm</tt> || 2+ || 2
|}
----
{{Anchor|MOVSB}}
{{Anchor|MOVSW}}
=== MOVSB/MOVSW ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| MOVSB || <tt>A4</tt> || <tt>10100100</tt> || 1 || 5
|-
| MOVSW || <tt>A5</tt> || <tt>10100101</tt> || 1 || 5
|}
----
{{Anchor|MUL}}
=== MUL ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| MUL mem8 || <tt>F6 /4</tt> || <tt>11110110 oo100mmm</tt> || 2+ || 4
|-
| MUL mem16 || <tt>F7 /4</tt> || <tt>11111111 oo100mmm</tt> || 2+ || 4
|-
| MUL reg8 || <tt>F6 /4</tt> || <tt>11111110 11100mmm</tt> || 2 || 3
|-
| MUL reg16 || <tt>F7 /4</tt> || <tt>11111111 11100mmm</tt> || 2 || 3
|}
----
{{Anchor|NEG}}
=== NEG ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| NEG mem8 || <tt>F6 /3</tt> || <tt>11110110 oo011mmm</tt> || 2+ || 3
|-
| NEG mem16 || <tt>F7 /3</tt> || <tt>11111111 oo011mmm</tt> || 2+ || 3
|-
| NEG reg8 || <tt>F6 /3</tt> || <tt>11111110 11011mmm</tt> || 2 || 1
|-
| NEG reg16 || <tt>F7 /3</tt> || <tt>11111111 11011mmm</tt> || 2 || 1
|}
----
{{Anchor|NOP}}
=== NOP ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| NOP || <tt>90</tt> || <tt>10010000</tt> || 1 || 1
|}
----
{{Anchor|NOT}}
=== NOT ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| NOT mem8 || <tt>F6 /2</tt> || <tt>11110110 oo010mmm</tt> || 2+ || 3
|-
| NOT mem16 || <tt>F7 /2</tt> || <tt>11111111 oo010mmm</tt> || 2+ || 3
|-
| NOT reg8 || <tt>F6 /2</tt> || <tt>11111110 11010mmm</tt> || 2 || 1
|-
| NOT reg16 || <tt>F7 /2</tt> || <tt>11111111 11010mmm</tt> || 2 || 1
|}
----
{{Anchor|OR}}
=== OR ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| OR AL, imm || <tt>0C ii</tt> || <tt>00001100 iiiiiiii</tt> || 2 || 1
|-
| OR AX, imm || <tt>0D ii ii</tt> || <tt>00001101 iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| OR mem8, imm8 || <tt>80 /6 ii</tt> || <tt>10000000 oo001mmm iiiiiiii</tt> || 3+ || 3
|-
| OR mem16, imm16 || <tt>81 /6 ii ii</tt> || <tt>10000001 oo001mmm iiiiiiii iiiiiiii</tt> || 4+ || 3
|-
| OR mem16, simm8 || <tt>83 /6 ii</tt> || <tt>10000011 oo001mmm iiiiiiii</tt> || 3+ || 3
|-
| OR mem8, reg8 || <tt>08 /r</tt> || <tt>00001000 oorrrmmm</tt> || 2+ || 3
|-
| OR mem16, reg16 || <tt>09 /r</tt> || <tt>00001001 oorrrmmm</tt> || 2+ || 3
|-
| OR reg8, imm8 || <tt>80 /6 ii</tt> || <tt>10000000 11001mmm iiiiiiii</tt> || 3 || 1
|-
| OR reg16, imm16 || <tt>81 /6 ii ii</tt> || <tt>10000001 11001mmm iiiiiiii iiiiiiii</tt> || 4 || 1
|-
| OR reg16, simm8 || <tt>83 /6 ii</tt> || <tt>10000011 11001mmm iiiiiiii</tt> || 3 || 1
|-
| OR reg8, mem8 || <tt>0A /r</tt> || <tt>00001010 oorrrmmm</tt> || 2+ || 2
|-
| OR reg16, mem16 || <tt>0B /r</tt> || <tt>00001011 oorrrmmm</tt> || 2+ || 2
|-
| OR reg8, reg8 || <tt>08 /r</tt> || <tt>000010.0 11rrrmmm</tt> || 2 || 1
|-
| OR reg16, reg16 || <tt>09 /r</tt> || <tt>000010.1 11rrrmmm</tt> || 2 || 1
|}
----
{{Anchor|OUT}}
=== OUT ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| OUT AL, DX || <tt>EE</tt> || <tt>11101110</tt> || 1 || 6
|-
| OUT AX, DX || <tt>EF</tt> || <tt>11101111</tt> || 1 || 6
|-
| OUT AL, imm8 || <tt>E6 ii</tt> || <tt>11100110 iiiiiiii</tt> || 2 || 6
|-
| OUT AX, imm8 || <tt>E7 ii</tt> || <tt>11100111 iiiiiiii</tt> || 2 || 6
|}
----
{{Anchor|OUTSB}}
{{Anchor|OUTSW}}
=== OUTSB/OUTSW ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| OUTSB || <tt>6E</tt> || <tt>01101110</tt> || 1 || 6
|-
| OUTSW || <tt>6F</tt> || <tt>01101111</tt> || 1 || 6
|}
----
{{Anchor|POLL}}
=== POLL ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| POLL || <tt>6E</tt> || <tt>01101110</tt> || 1 || 9<ref>On the WonderSwan implementation, POLLB is always held low; on other implementations, POLL will wait for POLLB to be held low in 9-cycle intervals.</ref>
|}
----
{{Anchor|POP}}
=== POP ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| POP mem16 || <tt>8F /0</tt> || <tt>10001111 oo000mmm</tt> || 2+ || 3
|-
| POP reg16 || <tt>5x</tt> || <tt>01011xxx</tt> || 1 || 1
|-
| POP reg16 || <tt>8F /0</tt> || <tt>10001111 11000mmm</tt> || 2 || 1
|-
| POP sreg16 || <tt>xx</tt> || <tt>000xx111</tt> || 1 || 3
|}
----
{{Anchor|POPA}}
=== POPA ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| POPA || <tt>61</tt> || <tt>01100001</tt> || 1 || 8
|}
----
{{Anchor|POPF}}
=== POPF ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| POPF || <tt>9D</tt> || <tt>10011101</tt> || 1 || 3
|}
----
{{Anchor|PUSH}}
=== PUSH ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| PUSH simm8 || <tt>6A ii</tt> || <tt>01101010 iiiiiiii</tt> || 2 || 1
|-
| PUSH imm16 || <tt>68 ii ii</tt> || <tt>01101000 iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| PUSH mem16 || <tt>FF /6</tt> || <tt>11111111 oo110mmm</tt> || 2+ || 2
|-
| PUSH reg16 || <tt>5x</tt> || <tt>01010xxx</tt> || 1 || 1
|-
| PUSH reg16 || <tt>FF /6</tt> || <tt>11111111 11110mmm</tt> || 2 || 1
|-
| PUSH sreg16 || <tt>xx</tt> || <tt>000xx110</tt> || 1 || 2
|}
----
{{Anchor|PUSHA}}
=== PUSHA ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| PUSHA || <tt>60</tt> || <tt>01100000</tt> || 1 || 9
|}
----
{{Anchor|PUSHF}}
=== PUSHF ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| PUSHF || <tt>9C</tt> || <tt>10011100</tt> || 1 || 2
|}
----
{{Anchor|RCL}}
=== RCL ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| RCL mem8, 1 || <tt>D0 /2</tt> || <tt>11010000 oo010rm</tt> || 2+ || 3
|-
| RCL mem8, CL || <tt>D2 /2</tt> || <tt>11010010 oo010rm</tt> || 2+ || 5
|-
| RCL mem8, imm8 || <tt>C0 /2 ii</tt> || <tt>11000000 oo010mmm iiiiiiii</tt> || 3+ || 5
|-
| RCL mem16, 1 || <tt>D1 /2</tt> || <tt>11010001 oo010rm</tt> || 2+ || 3
|-
| RCL mem16, CL || <tt>D3 /2</tt> || <tt>11010011 oo010rm</tt> || 2+ || 5
|-
| RCL mem16, imm8 || <tt>C1 /2 ii</tt> || <tt>11000001 oo010mmm iiiiiiii</tt> || 3+ || 5
|-
| RCL reg8, 1 || <tt>D0 /2</tt> || <tt>11010000 11010rm</tt> || 2 || 1
|-
| RCL reg8, CL || <tt>D2 /2</tt> || <tt>11010010 11010rm</tt> || 2 || 3
|-
| RCL reg8, imm8 || <tt>C0 /2 ii</tt> || <tt>11000000 11010mmm iiiiiiii</tt> || 3 || 3
|-
| RCL reg16, 1 || <tt>D1 /2</tt> || <tt>11010001 11010rm</tt> || 2 || 1
|-
| RCL reg16, CL || <tt>D3 /2</tt> || <tt>11010011 11010rm</tt> || 2 || 3
|-
| RCL reg16, imm8 || <tt>C1 /2 ii</tt> || <tt>11000001 11010mmm iiiiiiii</tt> || 3 || 3
|}
----
{{Anchor|RCR}}
=== RCR ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| RCR mem8, 1 || <tt>D0 /3</tt> || <tt>11010000 oo011rm</tt> || 2+ || 3
|-
| RCR mem8, CL || <tt>D2 /3</tt> || <tt>11010010 oo011rm</tt> || 2+ || 5
|-
| RCR mem8, imm8 || <tt>C0 /3 ii</tt> || <tt>11000000 oo011mmm iiiiiiii</tt> || 3+ || 5
|-
| RCR mem16, 1 || <tt>D1 /3</tt> || <tt>11010001 oo011rm</tt> || 2+ || 3
|-
| RCR mem16, CL || <tt>D3 /3</tt> || <tt>11010011 oo011rm</tt> || 2+ || 5
|-
| RCR mem16, imm8 || <tt>C1 /3 ii</tt> || <tt>11000001 oo011mmm iiiiiiii</tt> || 3+ || 5
|-
| RCR reg8, 1 || <tt>D0 /3</tt> || <tt>11010000 11011rm</tt> || 2 || 1
|-
| RCR reg8, CL || <tt>D2 /3</tt> || <tt>11010010 11011rm</tt> || 2 || 3
|-
| RCR reg8, imm8 || <tt>C0 /3 ii</tt> || <tt>11000000 11011mmm iiiiiiii</tt> || 3 || 3
|-
| RCR reg16, 1 || <tt>D1 /3</tt> || <tt>11010001 11011rm</tt> || 2 || 1
|-
| RCR reg16, CL || <tt>D3 /3</tt> || <tt>11010011 11011rm</tt> || 2 || 3
|-
| RCR reg16, imm8 || <tt>C1 /3 ii</tt> || <tt>11000001 11011mmm iiiiiiii</tt> || 3 || 3
|}
----
{{Anchor|REP}}
=== REP/REPE/REPZ ===
----
{{Anchor|REPNE}}
=== REPNE/REPNZ ===
----
{{Anchor|RET}}
=== RET ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| RET || <tt>C3</tt> || <tt>11000011</tt> || 1 || 6
|-
| RET imm16 || <tt>C2 ii ii</tt> || <tt>11000010 iiiiiiii iiiiiiii</tt> || 1 || 6
|}
----
{{Anchor|RETF}}
=== RETF ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| RETF || <tt>CB</tt> || <tt>11001011</tt> || 1 || 8
|-
| RETF imm16 || <tt>CA ii ii</tt> || <tt>11001010 iiiiiiii iiiiiiii</tt> || 1 || 9
|}
----
{{Anchor|ROL}}
=== ROL ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| ROL mem8, 1 || <tt>D0 /0</tt> || <tt>11010000 oo000rm</tt> || 2+ || 3
|-
| ROL mem8, CL || <tt>D2 /0</tt> || <tt>11010010 oo000rm</tt> || 2+ || 5
|-
| ROL mem8, imm8 || <tt>C0 /0 ii</tt> || <tt>11000000 oo000mmm iiiiiiii</tt> || 3+ || 5
|-
| ROL mem16, 1 || <tt>D1 /0</tt> || <tt>11010001 oo000rm</tt> || 2+ || 3
|-
| ROL mem16, CL || <tt>D3 /0</tt> || <tt>11010011 oo000rm</tt> || 2+ || 5
|-
| ROL mem16, imm8 || <tt>C1 /0 ii</tt> || <tt>11000001 oo000mmm iiiiiiii</tt> || 3+ || 5
|-
| ROL reg8, 1 || <tt>D0 /0</tt> || <tt>11010000 11000rm</tt> || 2 || 1
|-
| ROL reg8, CL || <tt>D2 /0</tt> || <tt>11010010 11000rm</tt> || 2 || 3
|-
| ROL reg8, imm8 || <tt>C0 /0 ii</tt> || <tt>11000000 11000mmm iiiiiiii</tt> || 3 || 3
|-
| ROL reg16, 1 || <tt>D1 /0</tt> || <tt>11010001 11000rm</tt> || 2 || 1
|-
| ROL reg16, CL || <tt>D3 /0</tt> || <tt>11010011 11000rm</tt> || 2 || 3
|-
| ROL reg16, imm8 || <tt>C1 /0 ii</tt> || <tt>11000001 11000mmm iiiiiiii</tt> || 3 || 3
|}
----
{{Anchor|ROR}}
=== ROR ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| ROR mem8, 1 || <tt>D0 /1</tt> || <tt>11010000 oo001rm</tt> || 2+ || 3
|-
| ROR mem8, CL || <tt>D2 /1</tt> || <tt>11010010 oo001rm</tt> || 2+ || 5
|-
| ROR mem8, imm8 || <tt>C0 /1 ii</tt> || <tt>11000000 oo001mmm iiiiiiii</tt> || 3+ || 5
|-
| ROR mem16, 1 || <tt>D1 /1</tt> || <tt>11010001 oo001rm</tt> || 2+ || 3
|-
| ROR mem16, CL || <tt>D3 /1</tt> || <tt>11010011 oo001rm</tt> || 2+ || 5
|-
| ROR mem16, imm8 || <tt>C1 /1 ii</tt> || <tt>11000001 oo001mmm iiiiiiii</tt> || 3+ || 5
|-
| ROR reg8, 1 || <tt>D0 /1</tt> || <tt>11010000 11001rm</tt> || 2 || 1
|-
| ROR reg8, CL || <tt>D2 /1</tt> || <tt>11010010 11001rm</tt> || 2 || 3
|-
| ROR reg8, imm8 || <tt>C0 /1 ii</tt> || <tt>11000000 11001mmm iiiiiiii</tt> || 3 || 3
|-
| ROR reg16, 1 || <tt>D1 /1</tt> || <tt>11010001 11001rm</tt> || 2 || 1
|-
| ROR reg16, CL || <tt>D3 /1</tt> || <tt>11010011 11001rm</tt> || 2 || 3
|-
| ROR reg16, imm8 || <tt>C1 /1 ii</tt> || <tt>11000001 11001mmm iiiiiiii</tt> || 3 || 3
|}
----
{{Anchor|SAHF}}
=== SAHF ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| SAHF || <tt>9E</tt> || <tt>10011110</tt> || 1 || 4
|}
----
{{Anchor|SAR}}
=== SAR ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| SAR mem8, 1 || <tt>D0 /7</tt> || <tt>11010000 oo111rm</tt> || 2+ || 3
|-
| SAR mem8, CL || <tt>D2 /7</tt> || <tt>11010010 oo111rm</tt> || 2+ || 5
|-
| SAR mem8, imm8 || <tt>C0 /7 ii</tt> || <tt>11000000 oo111mmm iiiiiiii</tt> || 3+ || 5
|-
| SAR mem16, 1 || <tt>D1 /7</tt> || <tt>11010001 oo111rm</tt> || 2+ || 3
|-
| SAR mem16, CL || <tt>D3 /7</tt> || <tt>11010011 oo111rm</tt> || 2+ || 5
|-
| SAR mem16, imm8 || <tt>C1 /7 ii</tt> || <tt>11000001 oo111mmm iiiiiiii</tt> || 3+ || 5
|-
| SAR reg8, 1 || <tt>D0 /7</tt> || <tt>11010000 11111rm</tt> || 2 || 1
|-
| SAR reg8, CL || <tt>D2 /7</tt> || <tt>11010010 11111rm</tt> || 2 || 3
|-
| SAR reg8, imm8 || <tt>C0 /7 ii</tt> || <tt>11000000 11111mmm iiiiiiii</tt> || 3 || 3
|-
| SAR reg16, 1 || <tt>D1 /7</tt> || <tt>11010001 11111rm</tt> || 2 || 1
|-
| SAR reg16, CL || <tt>D3 /7</tt> || <tt>11010011 11111rm</tt> || 2 || 3
|-
| SAR reg16, imm8 || <tt>C1 /7 ii</tt> || <tt>11000001 11111mmm iiiiiiii</tt> || 3 || 3
|}
----
{{Anchor|SBB}}
=== SBB ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| SBB AL, imm || <tt>1C ii</tt> || <tt>00011100 iiiiiiii</tt> || 2 || 1
|-
| SBB AX, imm || <tt>1D ii ii</tt> || <tt>00011101 iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| SBB mem8, imm8 || <tt>80 /3 ii</tt> || <tt>10000000 oo011mmm iiiiiiii</tt> || 3+ || 3
|-
| SBB mem16, imm16 || <tt>81 /3 ii ii</tt> || <tt>10000001 oo011mmm iiiiiiii iiiiiiii</tt> || 4+ || 3
|-
| SBB mem16, simm8 || <tt>83 /3 ii</tt> || <tt>10000011 oo011mmm iiiiiiii</tt> || 3+ || 3
|-
| SBB mem8, reg8 || <tt>18 /r</tt> || <tt>00011000 oorrrmmm</tt> || 2+ || 3
|-
| SBB mem16, reg16 || <tt>19 /r</tt> || <tt>00011001 oorrrmmm</tt> || 2+ || 3
|-
| SBB reg8, imm8 || <tt>80 /3 ii</tt> || <tt>10000000 11011mmm iiiiiiii</tt> || 3 || 1
|-
| SBB reg16, imm16 || <tt>81 /3 ii ii</tt> || <tt>10000001 11011mmm iiiiiiii iiiiiiii</tt> || 4 || 1
|-
| SBB reg16, simm8 || <tt>83 /3 ii</tt> || <tt>10000011 11011mmm iiiiiiii</tt> || 3 || 1
|-
| SBB reg8, mem8 || <tt>1A /r</tt> || <tt>00011010 oorrrmmm</tt> || 2+ || 2
|-
| SBB reg16, mem16 || <tt>1B /r</tt> || <tt>00011011 oorrrmmm</tt> || 2+ || 2
|-
| SBB reg8, reg8 || <tt>18 /r</tt> || <tt>000110.0 11rrrmmm</tt> || 2 || 1
|-
| SBB reg16, reg16 || <tt>19 /r</tt> || <tt>000110.1 11rrrmmm</tt> || 2 || 1
|}
----
{{Anchor|SCASB}}
{{Anchor|SCASW}}
=== SCASB/SCASW ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| SCASB || <tt>AE</tt> || <tt>10101110</tt> || 1 || 4
|-
| SCASW || <tt>AF</tt> || <tt>10101111</tt> || 1 || 4
|}
----
{{Anchor|SHL}}
=== SHL ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| SHL mem8, 1 || <tt>D0 /4</tt> || <tt>11010000 oo100rm</tt> || 2+ || 3
|-
| SHL mem8, CL || <tt>D2 /4</tt> || <tt>11010010 oo100rm</tt> || 2+ || 5
|-
| SHL mem8, imm8 || <tt>C0 /4 ii</tt> || <tt>11000000 oo100mmm iiiiiiii</tt> || 3+ || 5
|-
| SHL mem16, 1 || <tt>D1 /4</tt> || <tt>11010001 oo100rm</tt> || 2+ || 3
|-
| SHL mem16, CL || <tt>D3 /4</tt> || <tt>11010011 oo100rm</tt> || 2+ || 5
|-
| SHL mem16, imm8 || <tt>C1 /4 ii</tt> || <tt>11000001 oo100mmm iiiiiiii</tt> || 3+ || 5
|-
| SHL reg8, 1 || <tt>D0 /4</tt> || <tt>11010000 11100rm</tt> || 2 || 1
|-
| SHL reg8, CL || <tt>D2 /4</tt> || <tt>11010010 11100rm</tt> || 2 || 3
|-
| SHL reg8, imm8 || <tt>C0 /4 ii</tt> || <tt>11000000 11100mmm iiiiiiii</tt> || 3 || 3
|-
| SHL reg16, 1 || <tt>D1 /4</tt> || <tt>11010001 11100rm</tt> || 2 || 1
|-
| SHL reg16, CL || <tt>D3 /4</tt> || <tt>11010011 11100rm</tt> || 2 || 3
|-
| SHL reg16, imm8 || <tt>C1 /4 ii</tt> || <tt>11000001 11100mmm iiiiiiii</tt> || 3 || 3
|}
----
{{Anchor|SHR}}
=== SHR ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| SHR mem8, 1 || <tt>D0 /5</tt> || <tt>11010000 oo101rm</tt> || 2+ || 3
|-
| SHR mem8, CL || <tt>D2 /5</tt> || <tt>11010010 oo101rm</tt> || 2+ || 5
|-
| SHR mem8, imm8 || <tt>C0 /5 ii</tt> || <tt>11000000 oo101mmm iiiiiiii</tt> || 3+ || 5
|-
| SHR mem16, 1 || <tt>D1 /5</tt> || <tt>11010001 oo101rm</tt> || 2+ || 3
|-
| SHR mem16, CL || <tt>D3 /5</tt> || <tt>11010011 oo101rm</tt> || 2+ || 5
|-
| SHR mem16, imm8 || <tt>C1 /5 ii</tt> || <tt>11000001 oo101mmm iiiiiiii</tt> || 3+ || 5
|-
| SHR reg8, 1 || <tt>D0 /5</tt> || <tt>11010000 11101rm</tt> || 2 || 1
|-
| SHR reg8, CL || <tt>D2 /5</tt> || <tt>11010010 11101rm</tt> || 2 || 3
|-
| SHR reg8, imm8 || <tt>C0 /5 ii</tt> || <tt>11000000 11101mmm iiiiiiii</tt> || 3 || 3
|-
| SHR reg16, 1 || <tt>D1 /5</tt> || <tt>11010001 11101rm</tt> || 2 || 1
|-
| SHR reg16, CL || <tt>D3 /5</tt> || <tt>11010011 11101rm</tt> || 2 || 3
|-
| SHR reg16, imm8 || <tt>C1 /5 ii</tt> || <tt>11000001 11101mmm iiiiiiii</tt> || 3 || 3
|}
----
{{Anchor|SS}}
=== SS ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| SS || <tt>36</tt> || <tt>00110110</tt> || 1 || 1
|}
----
{{Anchor|STC}}
=== STC ===
{| class="wikitable"
! Flag !! New value
|-
| [[NEC_V30MZ_flags#CF|CF - Carry]] || 1
|}
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| STC || <tt>F9</tt> || <tt>11111001</tt> || 1 || 4
|}
----
{{Anchor|STD}}
=== STD ===
{| class="wikitable"
! Flag !! New value
|-
| [[NEC_V30MZ_flags#DF|DF - Direction]] || 1
|}
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| STD || <tt>FD</tt> || <tt>11111101</tt> || 1 || 4
|}
----
{{Anchor|STI}}
=== STI ===
{| class="wikitable"
! Flag !! New value
|-
| [[NEC_V30MZ_flags#IF|IF - Interrupt]] || 1
|}
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| STI || <tt>FB</tt> || <tt>11111011</tt> || 1 || 4
|}
----
{{Anchor|STOSB}}
{{Anchor|STOSW}}
=== STOSB/STOSW ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| STOSB || <tt>AA</tt> || <tt>10101010</tt> || 1 || 3
|-
| STOSW || <tt>AB</tt> || <tt>10101011</tt> || 1 || 3
|}
----
{{Anchor|SUB}}
=== SUB ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| SUB AL, imm || <tt>28 ii</tt> || <tt>00101100 iiiiiiii</tt> || 2 || 1
|-
| SUB AX, imm || <tt>29 ii ii</tt> || <tt>00101101 iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| SUB mem8, imm8 || <tt>80 /5 ii</tt> || <tt>10000000 oo101mmm iiiiiiii</tt> || 3+ || 3
|-
| SUB mem16, imm16 || <tt>81 /5 ii ii</tt> || <tt>10000001 oo101mmm iiiiiiii iiiiiiii</tt> || 4+ || 3
|-
| SUB mem16, simm8 || <tt>83 /5 ii</tt> || <tt>10000011 oo101mmm iiiiiiii</tt> || 3+ || 3
|-
| SUB mem8, reg8 || <tt>28 /r</tt> || <tt>00101000 oorrrmmm</tt> || 2+ || 3
|-
| SUB mem16, reg16 || <tt>29 /r</tt> || <tt>00101001 oorrrmmm</tt> || 2+ || 3
|-
| SUB reg8, imm8 || <tt>80 /5 ii</tt> || <tt>10000000 11101mmm iiiiiiii</tt> || 3 || 1
|-
| SUB reg16, imm16 || <tt>81 /5 ii ii</tt> || <tt>10000001 11101mmm iiiiiiii iiiiiiii</tt> || 4 || 1
|-
| SUB reg16, simm8 || <tt>83 /5 ii</tt> || <tt>10000011 11101mmm iiiiiiii</tt> || 3 || 1
|-
| SUB reg8, mem8 || <tt>2A /r</tt> || <tt>00101010 oorrrmmm</tt> || 2+ || 2
|-
| SUB reg16, mem16 || <tt>2B /r</tt> || <tt>00101011 oorrrmmm</tt> || 2+ || 2
|-
| SUB reg8, reg8 || <tt>28 /r</tt> || <tt>001010.0 11rrrmmm</tt> || 2 || 1
|-
| SUB reg16, reg16 || <tt>29 /r</tt> || <tt>001010.1 11rrrmmm</tt> || 2 || 1
|}
----
{{Anchor|TEST}}
=== TEST ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| TEST AL, imm || <tt>A8 ii</tt> || <tt>10101000 iiiiiiii</tt> || 2 || 1
|-
| TEST AX, imm || <tt>A9 ii ii</tt> || <tt>10101001 iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| TEST mem8, imm8 || <tt>F6 /0 ii</tt> || <tt>11110110 oo000mmm iiiiiiii</tt> || 3+ || 2
|-
| TEST mem16, imm16 || <tt>F7 /0 ii ii</tt> || <tt>11110111 oo000mmm iiiiiiii iiiiiiii</tt> || 4+ || 2
|-
| TEST mem8, reg8<br/>TEST reg8, mem8 || <tt>84 /r</tt> || <tt>10000100 oorrrmmm</tt> || 2+ || 2
|-
| TEST mem16, reg16<br/>TEST reg16, mem16 || <tt>85 /r</tt> || <tt>10000101 oorrrmmm</tt> || 2+ || 2
|-
| TEST reg8, imm8 || <tt>F6 /0 ii</tt> || <tt>11110110 11000mmm iiiiiiii</tt> || 3 || 1
|-
| TEST reg16, imm16 || <tt>F7 /0 ii ii</tt> || <tt>11110111 11000mmm iiiiiiii iiiiiiii</tt> || 4 || 1
|-
| TEST reg8, reg8 || <tt>84 /r</tt> || <tt>10000100 11rrrmmm</tt> || 2 || 1
|-
| TEST reg16, reg16 || <tt>85 /r</tt> || <tt>10000101 11rrrmmm</tt> || 2 || 1
|}
----
{{Anchor|XCHG}}
=== XCHG ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| XCHG AX, reg16<br/>XCHG reg16, AX || <tt>9x</tt> || <tt>10010rrr</tt> || 1 || 3
|-
| XCHG mem8, reg8<br/>XCHG reg8, mem8 || <tt>86 /r</tt> || <tt>10000110 oorrrmmm</tt> || 2+ || 5
|-
| XCHG mem16, reg16<br/>XCHG reg16, mem16 || <tt>87 /r</tt> || <tt>10000111 oorrrmmm</tt> || 2+ || 5
|-
| XCHG reg8, reg8 || <tt>86 /r</tt> || <tt>10000110 11rrrmmm</tt> || 2+ || 3
|-
| XCHG reg16, reg16 || <tt>87 /r</tt> || <tt>10000111 11rrrmmm</tt> || 2+ || 3
|}
----
{{Anchor|XLAT}}
=== XLAT ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| XLAT || <tt>D7</tt> || <tt>11010111</tt> || 1 || 5
|}
----
{{Anchor|XOR}}
=== XOR ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| XOR AL, imm || <tt>34 ii</tt> || <tt>00110100 iiiiiiii</tt> || 2 || 1
|-
| XOR AX, imm || <tt>35 ii ii</tt> || <tt>00110101 iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| XOR mem8, imm8 || <tt>80 /6 ii</tt> || <tt>10000000 oo110mmm iiiiiiii</tt> || 3+ || 3
|-
| XOR mem16, imm16 || <tt>81 /6 ii ii</tt> || <tt>10000001 oo110mmm iiiiiiii iiiiiiii</tt> || 4+ || 3
|-
| XOR mem16, simm8 || <tt>83 /6 ii</tt> || <tt>10000011 oo110mmm iiiiiiii</tt> || 3+ || 3
|-
| XOR mem8, reg8 || <tt>30 /r</tt> || <tt>00110000 oorrrmmm</tt> || 2+ || 3
|-
| XOR mem16, reg16 || <tt>31 /r</tt> || <tt>00110001 oorrrmmm</tt> || 2+ || 3
|-
| XOR reg8, imm8 || <tt>80 /6 ii</tt> || <tt>10000000 11110mmm iiiiiiii</tt> || 3 || 1
|-
| XOR reg16, imm16 || <tt>81 /6 ii ii</tt> || <tt>10000001 11110mmm iiiiiiii iiiiiiii</tt> || 4 || 1
|-
| XOR reg16, simm8 || <tt>83 /6 ii</tt> || <tt>10000011 11110mmm iiiiiiii</tt> || 3 || 1
|-
| XOR reg8, mem8 || <tt>32 /r</tt> || <tt>00110010 oorrrmmm</tt> || 2+ || 2
|-
| XOR reg16, mem16 || <tt>33 /r</tt> || <tt>00110011 oorrrmmm</tt> || 2+ || 2
|-
| XOR reg8, reg8 || <tt>30 /r</tt> || <tt>001100.0 11rrrmmm</tt> || 2 || 1
|-
| XOR reg16, reg16 || <tt>31 /r</tt> || <tt>001100.1 11rrrmmm</tt> || 2 || 1
|}
== Notes ==
<references />
bda72248085fbadcb904b9e2d776d79f32971b73
594
551
2025-04-13T12:36:37Z
Asie
351
POLL -> WAIT
wikitext
text/x-wiki
__NOTOC__
Note that this page is a work in progress.
{| class="wikitable" style="text-align: center"
|+ Official V30MZ (80186) Instructions
|-
| [[#AAA|AAA]] || [[#AAD|AAD]] || [[#AAM|AAM]] || [[#AAS|AAS]] || [[#ADC|ADC]] || [[#ADD|ADD]] || [[#AND|AND]] || [[#BOUND|BOUND]] || [[#CALL|CALL]] || [[#CBW|CBW]] || [[#CLC|CLC]]
|-
| [[#CLD|CLD]] || [[#CLI|CLI]] || [[#CMC|CMC]] || [[#CMP|CMP]] || [[#CMPSB|CMPSB]] || [[#CMPSW|CMPSW]] || [[#CS|CS]] || [[#CWD|CWD]] || [[#DAA|DAA]] || [[#DAS|DAS]] || [[#DEC|DEC]]
|-
| [[#DIV|DIV]] || [[#DS|DS]] || [[#ENTER|ENTER]] || [[#ES|ES]] || [[#HLT|HLT]] || [[#IDIV|IDIV]] || [[#IMUL|IMUL]] || [[#IN|IN]] || [[#INC|INC]] || [[#INSB|INSB]] || [[#INSW|INSW]]
|-
| [[#INT|INT]] || [[#INTO|INTO]] || [[#IRET|IRET]] || [[#JA|JA]] || [[#JBE|JBE]] || [[#JC|JC]] || [[#JCXZ|JCXZ]] || [[#JG|JG]] || [[#JGE|JGE]] || [[#JL|JL]] || [[#JLE|JLE]]
|-
| [[#JMP|JMP]] || [[#JNC|JNC]] || [[#JNO|JNO]] || [[#JNP|JNP]] || [[#JNS|JNS]] || [[#JNZ|JNZ]] || [[#JO|JO]] || [[#JP|JP]] || [[#JS|JS]] || [[#JZ|JZ]] || [[#LAHF|LAHF]]
|-
| [[#LDS|LDS]] || [[#LEA|LEA]] || [[#LEAVE|LEAVE]] || [[#LES|LES]] || [[#LOCK|LOCK]] || [[#LODSB|LODSB]] || [[#LODSW|LODSW]] || [[#LOOP|LOOP]] || [[#LOOPE|LOOPE]] || [[#LOOPNE|LOOPNE]] || [[#MOV|MOV]]
|-
| [[#MOVSB|MOVSB]] || [[#MOVSW|MOVSW]] || [[#MUL|MUL]] || [[#NEG|NEG]] || [[#NOP|NOP]] || [[#NOT|NOT]] || [[#OR|OR]] || [[#OUT|OUT]] || [[#OUTSB|OUTSB]] || [[#OUTSW|OUTSW]] || [[#POP|POP]]
|-
| [[#POPA|POPA]] || [[#POPF|POPF]] || [[#PUSH|PUSH]] || [[#PUSHA|PUSHA]] || [[#PUSHF|PUSHF]] || [[#RCL|RCL]] || [[#RCR|RCR]] || [[#REP|REP]] || [[#REPNE|REPNE]] || [[#RET|RET]] || [[#RETF|RETF]]
|-
| [[#ROL|ROL]] || [[#ROR|ROR]] || [[#SAHF|SAHF]] || [[#SAR|SAR]] || [[#SBB|SBB]] || [[#SCASB|SCASB]] || [[#SCASW|SCASW]] || [[#SHL|SHL]] || [[#SHR|SHR]] || [[#SS|SS]] || [[#STC|STC]]
|-
| [[#STD|STD]] || [[#STI|STI]] || [[#STOSB|STOSB]] || [[#STOSW|STOSW]] || [[#SUB|SUB]] || [[#TEST|TEST]] || [[#WAIT|WAIT]] || [[#XCHG|XCHG]] || [[#XLAT|XLAT]] || [[#XOR|XOR]]
|}
{| class="mw-collapsible mw-collapsed wikitable sortable" style="width: 340px;"
|+ style="white-space:nowrap; border:1px solid; padding:3px; border-color:rgb(162, 169, 177); background-color:rgb(234, 236, 240);" | Intel <-> NEC mnemonic translation table
!Intel
!NEC
|-
| [[#AAA|AAA]]
| [[#AAA|ADJBA]]
|-
| [[#AAD|AAD]]
| [[#AAD|CVTDB]]
|-
| [[#AAM|AAM]]
| [[#AAM|CVTBD]]
|-
| [[#AAS|AAS]]
| [[#AAS|ADJBS]]
|-
| [[#ADC|ADC]]
| [[#ADC|ADDC]]
|-
| [[#ADD|ADD]]
| [[#ADD|ADD]]
|-
| [[#AND|AND]]
| [[#AND|AND]]
|-
| [[#BOUND|BOUND]]
| [[#BOUND|CHKIND]]
|-
| [[#CALL|CALL]]
| [[#CALL|CALL]]
|-
| [[#CBW|CBW]]
| [[#CBW|CVTBW]]
|-
| [[#CLC|CLC]]
| [[#CLC|CLR1 CY]]
|-
| [[#CLD|CLD]]
| [[#CLD|CLR1 DIR]]
|-
| [[#CLI|CLI]]
| [[#CLI|DI]]
|-
| [[#CMC|CMC]]
| [[#CMC|NOT1 CY]]
|-
| [[#CMP|CMP]]
| [[#CMP|CMP]]
|-
| [[#CMPSB|CMPSB]]
| [[#CMPSB|CMPBKB]]
|-
| [[#CMPSW|CMPSW]]
| [[#CMPSW|CMPBKW]]
|-
| [[#CS|CS]]
| [[#CS|PS]]
|-
| [[#CWD|CWD]]
| [[#CWD|CVTWL]]
|-
| [[#DAA|DAA]]
| [[#DAA|ADJ4A]]
|-
| [[#DAS|DAS]]
| [[#DAS|ADJ4S]]
|-
| [[#DEC|DEC]]
| [[#DEC|DEC]]
|-
| [[#DIV|DIV]]
| [[#DIV|DIVU]]
|-
| [[#DS|DS]]
| [[#DS|DS0]]
|-
| [[#ENTER|ENTER]]
| [[#ENTER|PREPARE]]
|-
| [[#ES|ES]]
| [[#ES|DS1]]
|-
| [[#HLT|HLT]]
| [[#HLT|HALT]]
|-
| [[#IDIV|IDIV]]
| [[#IDIV|DIV]]
|-
| [[#IMUL|IMUL]]
| [[#IMUL|MUL]]
|-
| [[#IN|IN]]
| [[#IN|IN]]
|-
| [[#INC|INC]]
| [[#INC|INC]]
|-
| [[#INSB|INSB]]
| [[#INSB|INMB]]
|-
| [[#INSW|INSW]]
| [[#INSW|INMW]]
|-
| [[#INT|INT]]
| [[#INT|BRK]]
|-
| [[#INTO|INTO]]
| [[#INTO|BRKV]]
|-
| [[#IRET|IRET]]
| [[#IRET|RETI]]
|-
| [[#JA|JA]]
| [[#JA|BH]]
|-
| [[#JBE|JBE]]
| [[#JBE|BNH]]
|-
| [[#JC|JC/JB]]
| [[#JC|BC/BL]]
|-
| [[#JCXZ|JCXZ]]
| [[#JCXZ|BCWZ]]
|-
| [[#JG|JG]]
| [[#JG|BGT]]
|-
| [[#JGE|JGE]]
| [[#JGE|BGE]]
|-
| [[#JL|JL]]
| [[#JL|BLT]]
|-
| [[#JLE|JLE]]
| [[#JLE|BLE]]
|-
| [[#JMP|JMP]]
| [[#JMP|BR]]
|-
| [[#JNC|JNC/JAE]]
| [[#JNC|BNC/BNL]]
|-
| [[#JNO|JNO]]
| [[#JNO|BNV]]
|-
| [[#JNP|JNP]]
| [[#JNP|BPO]]
|-
| [[#JNS|JNS]]
| [[#JNS|BP]]
|-
| [[#JNZ|JNZ/JNE]]
| [[#JNZ|BNZ/BNE]]
|-
| [[#JO|JO]]
| [[#JO|BV]]
|-
| [[#JP|JP]]
| [[#JP|BPE]]
|-
| [[#JS|JS]]
| [[#JS|BN]]
|-
| [[#JZ|JZ/JE]]
| [[#JZ|BZ/BE]]
|-
| [[#LAHF|LAHF]]
| [[#LAHF|MOV]]
|-
| [[#LDS|LDS]]
| [[#LDS|MOV]]
|-
| [[#LEA|LEA]]
| [[#LEA|LDEA]]
|-
| [[#LEAVE|LEAVE]]
| [[#LEAVE|DISPOSE]]
|-
| [[#LES|LES]]
| [[#LES|MOV]]
|-
| [[#LOCK|LOCK]]
| [[#LOCK|BUSLOCK]]
|-
| [[#LODSB|LODSB]]
| [[#LODSB|LDMB]]
|-
| [[#LODSW|LODSW]]
| [[#LODSW|LDMW]]
|-
| [[#LOOP|LOOP]]
| [[#LOOP|DBNZ]]
|-
| [[#LOOPE|LOOPE]]
| [[#LOOPE|DBNZE]]
|-
| [[#LOOPNE|LOOPNE]]
| [[#LOOPNE|DBNZNE]]
|-
| [[#MOV|MOV]]
| [[#MOV|MOV]]
|-
| [[#MOVSB|MOVSB]]
| [[#MOVSB|MOVBKB]]
|-
| [[#MOVSW|MOVSW]]
| [[#MOVSW|MOVBKW]]
|-
| [[#MUL|MUL]]
| [[#MUL|MULU]]
|-
| [[#NEG|NEG]]
| [[#NEG|NEG]]
|-
| [[#NOP|NOP]]
| [[#NOP|NOP]]
|-
| [[#NOT|NOT]]
| [[#NOT|NOT]]
|-
| [[#OR|OR]]
| [[#OR|OR]]
|-
| [[#OUT|OUT]]
| [[#OUT|OUT]]
|-
| [[#OUTSB|OUTSB]]
| [[#OUTSB|OUTM]]
|-
| [[#OUTSW|OUTSW]]
| [[#OUTSW|OUTM]]
|-
| [[#POP|POP]]
| [[#POP|POP]]
|-
| [[#POPA|POPA]]
| [[#POPA|POP]]
|-
| [[#POPF|POPF]]
| [[#POPF|POP]]
|-
| [[#PUSH|PUSH]]
| [[#PUSH|PUSH]]
|-
| [[#PUSHA|PUSHA]]
| [[#PUSHA|PUSH]]
|-
| [[#PUSHF|PUSHF]]
| [[#PUSHF|PUSH]]
|-
| [[#RCL|RCL]]
| [[#RCL|ROLC]]
|-
| [[#RCR|RCR]]
| [[#RCR|RORC]]
|-
| [[#REP|REP/REPE/REPZ]]
| [[#REP|REP/REPE/REPZ]]
|-
| [[#REPNE|REPNE/REPNZ]]
| [[#REPNE|REPNE/REPNZ]]
|-
| [[#RET|RET]]
| [[#RET|RET]]
|-
| [[#RETF|RETF]]
| [[#RETF|RET]]
|-
| [[#ROL|ROL]]
| [[#ROL|ROL]]
|-
| [[#ROR|ROR]]
| [[#ROR|ROR]]
|-
| [[#SAHF|SAHF]]
| [[#SAHF|MOV]]
|-
| [[#SAR|SAR]]
| [[#SAR|SHRA]]
|-
| [[#SBB|SBB]]
| [[#SBB|SUBC]]
|-
| [[#SCASB|SCASB]]
| [[#SCASB|CMPMB]]
|-
| [[#SCASW|SCASW]]
| [[#SCASW|CMPMW]]
|-
| [[#SHL|SHL]]
| [[#SHL|SHL]]
|-
| [[#SHR|SHR]]
| [[#SHR|SHR]]
|-
| [[#SS|SS]]
| [[#SS|SS]]
|-
| [[#STC|STC]]
| [[#STC|SET1 CY]]
|-
| [[#STD|STD]]
| [[#STD|SET1 DIR]]
|-
| [[#STI|STI]]
| [[#STI|EI]]
|-
| [[#STOSB|STOSB]]
| [[#STOSB|STMB]]
|-
| [[#STOSW|STOSW]]
| [[#STOSW|STMW]]
|-
| [[#SUB|SUB]]
| [[#SUB|SUB]]
|-
| [[#TEST|TEST]]
| [[#TEST|TEST]]
|-
| [[#WAIT|WAIT]]
| [[#WAIT|POLL]]
|-
| [[#XCHG|XCHG]]
| [[#XCHG|XCH]]
|-
| [[#XLAT|XLAT]]
| [[#XLAT|TRANS]]
|-
| [[#XOR|XOR]]
| [[#XOR|XOR]]
|}
== Official instructions by type ==
{| class="wikitable sortable" style="text-align: center"
!Type
!colspan=16 class="unsortable" | Instructions
|-
| style="text-align:left;" | Memory
| style="" | [[#MOV|MOV]]
| style="" | [[#XCHG|XCHG]]
| style="" | [[#XLAT|XLAT]]
| style="" | [[#LEA|LEA]]
| style="border-right:none;" | [[#LDS|LDS]]
| style="border-left:none;" | [[#LES|LES]]
| style="border-right:none;" | [[#IN|IN]]
| style="border-left:none;" | [[#OUT|OUT]]
| colspan="8" |
|-
| style="text-align:left;" | Ports
| style="border-right:none;" | [[#IN|IN]]
| style="border-left:none;" | [[#OUT|OUT]]
| style="border-right:none;" | [[#INSB|INSB]]
| style="border-left:none;" | [[#OUTSB|OUTSB]]
| style="border-right:none;" | [[#INSW|INSW]]
| style="border-left:none;" | [[#OUTSW|OUTSW]]
| colspan="10" |
|-
| style="text-align:left;" | Arithmetic
| style="border-right:none;" | [[#ADD|ADD]]
| style="border-left:none;" | [[#SUB|SUB]]
| style="border-right:none;" | [[#ADC|ADC]]
| style="border-left:none;" | [[#SBB|SBB]]
| style="border-right:none;" | [[#INC|INC]]
| style="border-left:none;" | [[#DEC|DEC]]
| style="border-right:none;" | [[#MUL|MUL]]
| style="border-left:none;" | [[#DIV|DIV]]
| style="border-right:none;" | [[#IMUL|IMUL]]
| style="border-left:none;" | [[#IDIV|IDIV]]
| style="" | [[#CMP|CMP]]
| style="" | [[#NEG|NEG]]
| colspan="4" |
|-
| style="text-align:left;" | Numeric
| style="" | [[#CBW|CBW]]
| style="" | [[#CWD|CWD]]
| style="" | [[#AAA|AAA]]
| style="" | [[#AAS|AAS]]
| style="" | [[#AAM|AAM]]
| style="" | [[#AAD|AAD]]
| style="" | [[#DAA|DAA]]
| style="" | [[#DAS|DAS]]
| colspan="8" |
|-
| style="text-align:left;" | Shift
| style="border-right:none;" | [[#ROL|ROL]]
| style="border-left:none;" | [[#ROR|ROR]]
| style="border-right:none;" | [[#RCL|RCL]]
| style="border-left:none;" | [[#RCR|RCR]]
| style="border-right:none;" | [[#SHL|SHL]]
| style="border-left:none;" | [[#SHR|SHR]]
| style="" | [[#SAR|SAR]]
| colspan="9" |
|-
| style="text-align:left;" | Bitwise
| style="" | [[#AND|AND]]
| style="" | [[#OR|OR]]
| style="" | [[#XOR|XOR]]
| style="" | [[#NOT|NOT]]
| style="" | [[#TEST|TEST]]
| colspan="11" |
|-
| style="text-align:left;" | Branch
| style="border-right:none;" | [[#JC|JC]]
| style="border-left:none;" | [[#JNC|JNC]]
| style="border-right:none;" | [[#JZ|JZ]]
| style="border-left:none;" | [[#JNZ|JNZ]]
| style="border-right:none;" | [[#JBE|JBE]]
| style="border-left:none;" | [[#JA|JA]]
| style="border-right:none;" | [[#JO|JO]]
| style="border-left:none;" | [[#JNO|JNO]]
| style="border-right:none;" | [[#JP|JP]]
| style="border-left:none;" | [[#JNP|JNP]]
| style="border-right:none;" | [[#JS|JS]]
| style="border-left:none;" | [[#JNS|JNS]]
| style="border-right:none;" | [[#JL|JL]]
| style="border-left:none;" | [[#JGE|JGE]]
| style="border-right:none;" | [[#JLE|JLE]]
| style="border-left:none;" | [[#JG|JG]]
|-
| style="text-align:left;" | Jump
| style="" | [[#JMP|JMP]]
| style="border-right:none;" | [[#CALL|CALL]]
| style="border-left:none;border-right:none;" | [[#RET|RET]]
| style="border-left:none;" | [[#RETF|RETF]]
| colspan="12" |
|-
| style="text-align:left;" | Loop
| style="" | [[#LOOP|LOOP]]
| style="" | [[#LOOPE|LOOPE]]
| style="" | [[#LOOPNE|LOOPNE]]
| colspan="13" |
|-
| style="text-align:left;" | Interrupt
| style="border-right:none;" | [[#INT|INT]]
| style="border-left:none;" | [[#IRET|IRET]]
| style="" | [[#INTO|INTO]]
| style="" | [[#HLT|HLT]]
| style="" | [[#BOUND|BOUND]]
| colspan="11" |
|-
| style="text-align:left;" | Stack
| style="border-right:none;" | [[#PUSH|PUSH]]
| style="border-left:none;" | [[#POP|POP]]
| style="border-right:none;" | [[#PUSHA|PUSHA]]
| style="border-left:none;" | [[#POPA|POPA]]
| style="border-right:none;" | [[#PUSHF|PUSHF]]
| style="border-left:none;" | [[#POPF|POPF]]
| colspan="10" |
|-
| style="text-align:left;" | Flags
| style="border-right:none;" | [[#CLC|CLC]]
| style="border-left:none;" | [[#STC|STC]]
| style="border-right:none;" | [[#CLD|CLD]]
| style="border-left:none;" | [[#STD|STD]]
| style="border-right:none;" | [[#CLI|CLI]]
| style="border-left:none;" | [[#STI|STI]]
| style="" | [[#CMC|CMC]]
| style="border-right:none;" | [[#LAHF|LAHF]]
| style="border-left:none;" | [[#SAHF|SAHF]]
| colspan="7" |
|-
| style="text-align:left;" | Prefix
| style="" | [[#CS|CS]]
| style="" | [[#DS|DS]]
| style="" | [[#ES|ES]]
| style="" | [[#SS|SS]]
| colspan="12" |
|-
| style="text-align:left;" | String
| style="border-right:none;" | [[#REP|REP]]
| style="border-left:none;border-right:none;" | [[#REP|REPE]]
| style="border-left:none;" | [[#REPNE|REPNE]]
| style="" | [[#MOVSB|MOVSB]]
| style="" | [[#MOVSW|MOVSW]]
| style="border-right:none;" | [[#LODSB|LODSB]]
| style="border-left:none;" | [[#STOSB|STOSB]]
| style="border-right:none;" | [[#LODSW|LODSW]]
| style="border-left:none;" | [[#STOSW|STOSW]]
| style="" | [[#CMPSB|CMPSB]]
| style="" | [[#SCASB|SCASB]]
| style="" | [[#CMPSW|CMPSW]]
| style="" | [[#SCASW|SCASW]]
| colspan="3" |
|-
| style="text-align:left;" | Other
| style="" | [[#NOP|NOP]]
| style="border-right:none;" | [[#ENTER|ENTER]]
| style="border-left:none;" | [[#LEAVE|LEAVE]]
| style="" | [[#LOCK|LOCK]]
| style="" | [[#WAIT|WAIT]]
| colspan="11" |
|}
== Instruction encoding ==
=== ModR/M byte ===
The ModR/M byte is used in most addressing modes which reference a memory location. This byte consists of three bitfield values:
* <tt>oo</tt> - M'''o'''de;
* <tt>rrr</tt> - Two possible functions:
** '''R'''egister (for addressing modes which require both a register and a register/memory operand),
** Opcode extension (for some opcodes' addressing modes which do not have such a requirement);
* <tt>mmm</tt> - Register/'''M'''emory.
The ''Mode'' and ''Register/Memory'' bitfields can refer to a memory location or to a register, as shown in the table below.
Some instructions define a second argument using the ''Register'' field. It is always interpreted as if ''Mode'' was equal to <tt>11</tt> and, as such, can refer to a register only.
{| class="wikitable" style="text-align: center"
! R/M \ Mode
! <tt>00</tt>
! <tt>01</tt>
! <tt>10</tt>
! <tt>11</tt> ''(byte)''
! <tt>11</tt> ''(word)''
|-
| <tt>000</tt>
| DS:[BX + SI]
| DS:[BX + SI + disp8]
| DS:[BX + SI + disp16]
| AL
| AX
|-
| <tt>001</tt>
| DS:[BX + DI]
| DS:[BX + DI + disp8]
| DS:[BX + DI + disp16]
| CL
| CX
|-
| <tt>010</tt>
| SS:[BP + SI]
| SS:[BP + SI + disp8]
| SS:[BP + SI + disp16]
| DL
| DX
|-
| <tt>011</tt>
| SS:[BP + DI]
| SS:[BP + DI + disp8]
| SS:[BP + DI + disp16]
| BL
| BX
|-
| <tt>100</tt>
| DS:[SI]
| DS:[SI + disp8]
| DS:[SI + disp16]
| AH
| SP
|-
| <tt>101</tt>
| DS:[DI]
| DS:[DI + disp8]
| DS:[DI + disp16]
| CH
| BP
|-
| <tt>110</tt>
| ''DS:[disp16]''
| SS:[BP + disp8]
| SS:[BP + disp16]
| DH
| SI
|-
| <tt>111</tt>
| DS:[BX]
| DS:[BX + disp8]
| DS:[BX + disp16]
| BH
| DI
|}
Displacements are either 8-bit (disp8) or 16-bit (disp16) signed values and they always immediately follow the ModR/M byte. Note that (<tt>oo</tt> = <tt>00</tt>, <tt>mmm</tt> = <tt>110</tt>) is a special case, in which the ''disp16'' value is used directly as a near pointer.
The instruction encoding lists below refer to this byte as <tt>oorrrmmm</tt> (binary), <tt>/r</tt> (hexadecimal) or <tt>/0</tt> (hexademical, <tt>rrr</tt> used as function <tt>0</tt>).
== Official instructions ==
{{Anchor|AAA}}
=== AAA ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| AAA || <tt>37</tt> || <tt>00110111</tt> || 1 || 9
|}
----
{{Anchor|AAD}}
=== AAD ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| AAD imm8 || <tt>B5 ii</tt> || <tt>11010100 iiiiiiii</tt> || 2 || 6
|}
----
{{Anchor|AAM}}
=== AAM ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| AAM imm8 || <tt>B4 ii</tt> || <tt>11010100 iiiiiiii</tt> || 2 || 17
|}
----
{{Anchor|AAS}}
=== AAS ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| AAS || <tt>3F</tt> || <tt>00111111</tt> || 1 || 9
|}
----
{{Anchor|ADC}}
=== ADC ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| ADC AL, imm || <tt>14 ii</tt> || <tt>00010100 iiiiiiii</tt> || 2 || 1
|-
| ADC AX, imm || <tt>15 ii ii</tt> || <tt>00010101 iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| ADC mem8, imm8 || <tt>80 /2 ii</tt> || <tt>10000000 oo010mmm iiiiiiii</tt> || 3+ || 3
|-
| ADC mem16, imm16 || <tt>81 /2 ii ii</tt> || <tt>10000001 oo010mmm iiiiiiii iiiiiiii</tt> || 4+ || 3
|-
| ADC mem16, simm8 || <tt>83 /2 ii</tt> || <tt>10000011 oo010mmm iiiiiiii</tt> || 3+ || 3
|-
| ADC mem8, reg8 || <tt>10 /r</tt> || <tt>00010000 oorrrmmm</tt> || 2+ || 3
|-
| ADC mem16, reg16 || <tt>11 /r</tt> || <tt>00010001 oorrrmmm</tt> || 2+ || 3
|-
| ADC reg8, imm8 || <tt>80 /2 ii</tt> || <tt>10000000 11010mmm iiiiiiii</tt> || 3 || 1
|-
| ADC reg16, imm16 || <tt>81 /2 ii ii</tt> || <tt>10000001 11010mmm iiiiiiii iiiiiiii</tt> || 4 || 1
|-
| ADC reg16, simm8 || <tt>83 /2 ii</tt> || <tt>10000011 11010mmm iiiiiiii</tt> || 3 || 1
|-
| ADC reg8, mem8 || <tt>12 /r</tt> || <tt>00010010 oorrrmmm</tt> || 2+ || 2
|-
| ADC reg16, mem16 || <tt>13 /r</tt> || <tt>00010011 oorrrmmm</tt> || 2+ || 2
|-
| ADC reg8, reg8 || <tt>10 /r</tt> || <tt>000100.0 11rrrmmm</tt> || 2 || 1
|-
| ADC reg16, reg16 || <tt>11 /r</tt> || <tt>000100.1 11rrrmmm</tt> || 2 || 1
|}
----
{{Anchor|ADD}}
=== ADD ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| ADD AL, imm || <tt>04 ii</tt> || <tt>00000100 iiiiiiii</tt> || 2 || 1
|-
| ADD AX, imm || <tt>05 ii ii</tt> || <tt>00000101 iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| ADD mem8, imm8 || <tt>80 /0 ii</tt> || <tt>10000000 oo000mmm iiiiiiii</tt> || 3+ || 3
|-
| ADD mem16, imm16 || <tt>81 /0 ii ii</tt> || <tt>10000001 oo000mmm iiiiiiii iiiiiiii</tt> || 4+ || 3
|-
| ADD mem16, simm8 || <tt>83 /0 ii</tt> || <tt>10000011 oo000mmm iiiiiiii</tt> || 3+ || 3
|-
| ADD mem8, reg8 || <tt>00 /r</tt> || <tt>00000000 oorrrmmm</tt> || 2+ || 3
|-
| ADD mem16, reg16 || <tt>01 /r</tt> || <tt>00000001 oorrrmmm</tt> || 2+ || 3
|-
| ADD reg8, imm8 || <tt>80 /0 ii</tt> || <tt>10000000 11000mmm iiiiiiii</tt> || 3 || 1
|-
| ADD reg16, imm16 || <tt>81 /0 ii ii</tt> || <tt>10000001 11000mmm iiiiiiii iiiiiiii</tt> || 4 || 1
|-
| ADD reg16, simm8 || <tt>83 /0 ii</tt> || <tt>10000011 11000mmm iiiiiiii</tt> || 3 || 1
|-
| ADD reg8, mem8 || <tt>02 /r</tt> || <tt>00000010 oorrrmmm</tt> || 2+ || 2
|-
| ADD reg16, mem16 || <tt>03 /r</tt> || <tt>00000011 oorrrmmm</tt> || 2+ || 2
|-
| ADD reg8, reg8 || <tt>00 /r</tt> || <tt>000000.0 11rrrmmm</tt> || 2 || 1
|-
| ADD reg16, reg16 || <tt>01 /r</tt> || <tt>000000.1 11rrrmmm</tt> || 2 || 1
|}
----
{{Anchor|AND}}
=== AND ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| AND AL, imm || <tt>24 ii</tt> || <tt>00100100 iiiiiiii</tt> || 2 || 1
|-
| AND AX, imm || <tt>25 ii ii</tt> || <tt>00100101 iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| AND mem8, imm8 || <tt>80 /4 ii</tt> || <tt>10000000 oo100mmm iiiiiiii</tt> || 3+ || 3
|-
| AND mem16, imm16 || <tt>81 /4 ii ii</tt> || <tt>10000001 oo100mmm iiiiiiii iiiiiiii</tt> || 4+ || 3
|-
| AND mem16, simm8 || <tt>83 /4 ii</tt> || <tt>10000011 oo100mmm iiiiiiii</tt> || 3+ || 3
|-
| AND mem8, reg8 || <tt>20 /r</tt> || <tt>00100000 oorrrmmm</tt> || 2+ || 3
|-
| AND mem16, reg16 || <tt>21 /r</tt> || <tt>00100001 oorrrmmm</tt> || 2+ || 3
|-
| AND reg8, imm8 || <tt>80 /4 ii</tt> || <tt>10000000 11100mmm iiiiiiii</tt> || 3 || 1
|-
| AND reg16, imm16 || <tt>81 /4 ii ii</tt> || <tt>10000001 11100mmm iiiiiiii iiiiiiii</tt> || 4 || 1
|-
| AND reg16, simm8 || <tt>83 /4 ii</tt> || <tt>10000011 11100mmm iiiiiiii</tt> || 3 || 1
|-
| AND reg8, mem8 || <tt>22 /r</tt> || <tt>00100010 oorrrmmm</tt> || 2+ || 2
|-
| AND reg16, mem16 || <tt>23 /r</tt> || <tt>00100011 oorrrmmm</tt> || 2+ || 2
|-
| AND reg8, reg8 || <tt>20 /r</tt> || <tt>001000.0 11rrrmmm</tt> || 2 || 1
|-
| AND reg16, reg16 || <tt>21 /r</tt> || <tt>001000.1 11rrrmmm</tt> || 2 || 1
|}
----
{{Anchor|BOUND}}
=== BOUND ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| BOUND reg16, mem16:16 || <tt>62 /r</tt> || <tt>01100010 oorrrmmm</tt> || 2+ || 13 (20 if condition met)
|}
----
{{Anchor|CALL}}
=== CALL ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| CALL ptr16:16 || <tt>CA oo oo ss ss</tt> || <tt>10011010 oooooooo oooooooo ssssssss ssssssss</tt> || 5 || 10
|-
| CALL mem16 || <tt>FF /2</tt> || <tt>11111111 oo010mmm</tt> || 2+ || 6
|-
| CALL mem16:16 || <tt>FF /3</tt> || <tt>11111111 oo011mmm</tt> || 2+ || 12
|-
| CALL reg16 || <tt>FF /2</tt> || <tt>11111111 11010mmm</tt> || 2 || 5
|-
| CALL rel16 || <tt>E8 ii ii</tt> || <tt>11101000 iiiiiiii iiiiiiii</tt> || 3 || 5
|}
----
{{Anchor|CBW}}
=== CBW ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| CBW || <tt>98</tt> || <tt>10011000</tt> || 1 || 1
|}
----
{{Anchor|CLC}}
=== CLC ===
{| class="wikitable"
! Flag !! New value
|-
| [[NEC_V30MZ_flags#CF|CF - Carry]] || 0
|}
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| CLC || <tt>F8</tt> || <tt>11111000</tt> || 1 || 4
|}
----
{{Anchor|CLD}}
=== CLD ===
{| class="wikitable"
! Flag !! New value
|-
| [[NEC_V30MZ_flags#DF|DF - Direction]] || 0
|}
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| CLD || <tt>FC</tt> || <tt>11111100</tt> || 1 || 4
|}
----
{{Anchor|CLI}}
=== CLI ===
{| class="wikitable"
! Flag !! New value
|-
| [[NEC_V30MZ_flags#IF|IF - Interrupt]] || 0
|}
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| CLI || <tt>FA</tt> || <tt>11111010</tt> || 1 || 4
|}
----
{{Anchor|CMC}}
=== CMC ===
{| class="wikitable"
! Flag !! New value
|-
| [[NEC_V30MZ_flags#CF|CF - Carry]] || !CF
|}
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| CMC || <tt>F5</tt> || <tt>11110101</tt> || 1 || 4
|}
----
{{Anchor|CMP}}
=== CMP ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| CMP AL, imm || <tt>3C ii</tt> || <tt>00111100 iiiiiiii</tt> || 2 || 1
|-
| CMP AX, imm || <tt>3D ii ii</tt> || <tt>00111101 iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| CMP mem8, imm8 || <tt>80 /7 ii</tt> || <tt>10000000 oo111mmm iiiiiiii</tt> || 3+ || 2
|-
| CMP mem16, imm16 || <tt>81 /7 ii ii</tt> || <tt>10000001 oo111mmm iiiiiiii iiiiiiii</tt> || 4+ || 2
|-
| CMP mem16, simm8 || <tt>83 /7 ii</tt> || <tt>10000011 oo111mmm iiiiiiii</tt> || 3+ || 2
|-
| CMP mem8, reg8 || <tt>38 /r</tt> || <tt>00111000 oorrrmmm</tt> || 2+ || 2
|-
| CMP mem16, reg16 || <tt>39 /r</tt> || <tt>00111001 oorrrmmm</tt> || 2+ || 2
|-
| CMP reg8, imm8 || <tt>80 /7 ii</tt> || <tt>10000000 11111mmm iiiiiiii</tt> || 3 || 1
|-
| CMP reg16, imm16 || <tt>81 /7 ii ii</tt> || <tt>10000001 11111mmm iiiiiiii iiiiiiii</tt> || 4 || 1
|-
| CMP reg16, simm8 || <tt>83 /7 ii</tt> || <tt>10000011 11111mmm iiiiiiii</tt> || 3 || 1
|-
| CMP reg8, mem8 || <tt>3A /r</tt> || <tt>00111010 oorrrmmm</tt> || 2+ || 2
|-
| CMP reg16, mem16 || <tt>3B /r</tt> || <tt>00111011 oorrrmmm</tt> || 2+ || 2
|-
| CMP reg8, reg8 || <tt>38 /r</tt> || <tt>001110.0 11rrrmmm</tt> || 2 || 1
|-
| CMP reg16, reg16 || <tt>39 /r</tt> || <tt>001110.1 11rrrmmm</tt> || 2 || 1
|}
----
{{Anchor|CMPSB}}
{{Anchor|CMPSW}}
=== CMPSB/CMPSW ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| CMPSB || <tt>A6</tt> || <tt>10100110</tt> || 1 || 6
|-
| CMPSW || <tt>A7</tt> || <tt>10100111</tt> || 1 || 6
|}
----
{{Anchor|CS}}
=== CS ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| CS || <tt>2E</tt> || <tt>00101110</tt> || 1 || 1
|}
----
{{Anchor|CWD}}
=== CWD ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| CWD || <tt>99</tt> || <tt>10011001</tt> || 1 || 1
|}
----
{{Anchor|DAA}}
=== DAA ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| DAA || <tt>27</tt> || <tt>00100111</tt> || 1 || 10
|}
----
{{Anchor|DAS}}
=== DAS ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| DAS || <tt>2F</tt> || <tt>00101111</tt> || 1 || 10
|}
----
{{Anchor|DEC}}
=== DEC ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| DEC mem8 || <tt>FE /1</tt> || <tt>11111110 oo001mmm</tt> || 2+ || 3
|-
| DEC mem16 || <tt>FF /1</tt> || <tt>11111111 oo001mmm</tt> || 2+ || 3
|-
| DEC reg8 || <tt>FE /1</tt> || <tt>11111110 11001mmm</tt> || 2+ || 1
|-
| DEC reg16 || <tt>4x</tt> || <tt>01001rrr</tt> || 1 || 1
|}
----
{{Anchor|DIV}}
=== DIV ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| DIV mem8 || <tt>F6 /6</tt> || <tt>11110110 oo110mmm</tt> || 2+ || 16
|-
| DIV mem16 || <tt>F7 /6</tt> || <tt>11111111 oo110mmm</tt> || 2+ || 24
|-
| DIV reg8 || <tt>F6 /6</tt> || <tt>11111110 11110mmm</tt> || 2 || 15
|-
| DIV reg16 || <tt>F7 /6</tt> || <tt>11111111 11110mmm</tt> || 2 || 23
|}
----
{{Anchor|DS}}
=== DS ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| DS || <tt>3E</tt> || <tt>00111110</tt> || 1 || 1
|}
----
{{Anchor|ENTER}}
=== ENTER ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| ENTER imm16, imm8 || <tt>C8 ii ii jj</tt> || <tt>11001000 iiiiiiii iiiiiiii jjjjjjjj</tt> || 3 || 8 (imm8 = 0)<br/>14 (imm8 = 1)<br/>15 + imm8 * 4 (imm8 >= 2)
|}
----
{{Anchor|ES}}
=== ES ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| ES || <tt>26</tt> || <tt>00100110</tt> || 1 || 1
|}
----
{{Anchor|HLT}}
=== HLT ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| HLT || <tt>F4</tt> || <tt>11110100</tt> || 1 || 9
|}
----
{{Anchor|IDIV}}
=== IDIV ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| IDIV mem8 || <tt>F6 /7</tt> || <tt>11110110 oo111mmm</tt> || 2+ || 18
|-
| IDIV mem16 || <tt>F7 /7</tt> || <tt>11111111 oo111mmm</tt> || 2+ || 25
|-
| IDIV reg8 || <tt>F6 /7</tt> || <tt>11111110 11111mmm</tt> || 2 || 17
|-
| IDIV reg16 || <tt>F7 /7</tt> || <tt>11111111 11111mmm</tt> || 2 || 24
|}
----
{{Anchor|IMUL}}
=== IMUL ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| IMUL mem8 || <tt>F6 /5</tt> || <tt>11110110 oo101mmm</tt> || 2+ || 4
|-
| IMUL mem16 || <tt>F7 /5</tt> || <tt>11111111 oo101mmm</tt> || 2+ || 4
|-
| IMUL reg8 || <tt>F6 /5</tt> || <tt>11111110 11101mmm</tt> || 2 || 3
|-
| IMUL reg16 || <tt>F7 /5</tt> || <tt>11111111 11101mmm</tt> || 2 || 3
|-
| IMUL reg16, mem16, imm16 || <tt>69 /r ii ii</tt> || <tt>11111111 oorrrmmm iiiiiiii iiiiiiii</tt> || 4 || 4
|-
| IMUL reg16, mem16, simm8 || <tt>6B /r ii</tt> || <tt>11111111 oorrrmmm iiiiiiii</tt> || 3 || 4
|-
| IMUL reg16, reg16, imm16 || <tt>69 /r ii ii</tt> || <tt>11111111 11rrrmmm iiiiiiii iiiiiiii</tt> || 4 || 3
|-
| IMUL reg16, reg16, simm8 || <tt>6B /r ii</tt> || <tt>11111111 11rrrmmm iiiiiiii</tt> || 3 || 3
|}
----
{{Anchor|IN}}
=== IN ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| IN AL, DX || <tt>EC</tt> || <tt>11101100</tt> || 1 || 6
|-
| IN AX, DX || <tt>ED</tt> || <tt>11101101</tt> || 1 || 6
|-
| IN AL, imm8 || <tt>E4 ii</tt> || <tt>11100100 iiiiiiii</tt> || 2 || 6
|-
| IN AX, imm8 || <tt>E5 ii</tt> || <tt>11100101 iiiiiiii</tt> || 2 || 6
|}
----
{{Anchor|INC}}
=== INC ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| INC mem8 || <tt>FE /0</tt> || <tt>11111110 oo000mmm</tt> || 2+ || 3
|-
| INC mem16 || <tt>FF /0</tt> || <tt>11111111 oo000mmm</tt> || 2+ || 3
|-
| INC reg8 || <tt>FE /0</tt> || <tt>11111110 11000mmm</tt> || 2+ || 1
|-
| INC reg16 || <tt>4x</tt> || <tt>01000rrr</tt> || 1 || 1
|}
----
{{Anchor|INSB}}
{{Anchor|INSW}}
=== INSB/INSW ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| INSB || <tt>6C</tt> || <tt>01101100</tt> || 1 || 6
|-
| INSW || <tt>6D</tt> || <tt>01101101</tt> || 1 || 6
|}
----
{{Anchor|INT}}
=== INT ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| INT 3 || <tt>CC</tt> || <tt>11001100</tt> || 1 || 9
|-
| INT imm8 || <tt>CD ii</tt> || <tt>11001101 iiiiiiii</tt> || 2 || 10
|}
----
{{Anchor|INTO}}
=== INTO ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| INTO || <tt>CE</tt> || <tt>11001110</tt> || 1 || 6 (13 if OF = 1)
|}
----
{{Anchor|IRET}}
=== IRET ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| IRET || <tt>CF</tt> || <tt>11001111</tt> || 1 || 10
|}
----
{{Anchor|JA}}
=== JA ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JA rel8 || <tt>77 ii</tt> || <tt>01110111 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JBE}}
=== JBE ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JA rel8 || <tt>76 ii</tt> || <tt>01110110 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JC}}
=== JC/JB ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JC rel8 || <tt>72 ii</tt> || <tt>01110010 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JCXZ}}
=== JCXZ ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JCXZ rel8 || <tt>E3 ii</tt> || <tt>11100011 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JG}}
=== JG ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JG rel8 || <tt>7F ii</tt> || <tt>01111111 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JGE}}
=== JGE ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JGE rel8 || <tt>7D ii</tt> || <tt>01111101 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JL}}
=== JL ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JL rel8 || <tt>7C ii</tt> || <tt>01111100 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JLE}}
=== JLE ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JLE rel8 || <tt>7E ii</tt> || <tt>01111110 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JMP}}
=== JMP ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JMP ptr16:16 || <tt>EA oo oo ss ss</tt> || <tt>11101010 oooooooo oooooooo ssssssss ssssssss</tt> || 5 || 7
|-
| JMP mem16 || <tt>FF /4</tt> || <tt>11111111 oo100mmm</tt> || 2+ || 5
|-
| JMP mem16:16 || <tt>FF /5</tt> || <tt>11111111 oo101mmm</tt> || 2+ || 10
|-
| JMP reg16 || <tt>FF /4</tt> || <tt>11111111 11100mmm</tt> || 2 || 4
|-
| JMP rel8 || <tt>EB ii</tt> || <tt>11101011 iiiiiiii</tt> || 2 || 4
|-
| JMP rel16 || <tt>E9 ii ii</tt> || <tt>11101001 iiiiiiii iiiiiiii</tt> || 3 || 4
|}
----
{{Anchor|JNC}}
=== JNC/JAE ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JNC rel8 || <tt>73 ii</tt> || <tt>01110011 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JNO}}
=== JNO ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JNO rel8 || <tt>71 ii</tt> || <tt>01110001 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JNP}}
=== JNP ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JNP rel8 || <tt>7B ii</tt> || <tt>01111011 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JNS}}
=== JNS ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JNS rel8 || <tt>79 ii</tt> || <tt>01111001 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JNZ}}
=== JNZ/JNE ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JNZ rel8 || <tt>75 ii</tt> || <tt>01110101 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JO}}
=== JO ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JO rel8 || <tt>70 ii</tt> || <tt>01110000 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JP}}
=== JP ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JP rel8 || <tt>7A ii</tt> || <tt>01111010 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JS}}
=== JS ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JS rel8 || <tt>78 ii</tt> || <tt>01111000 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JZ}}
=== JZ/JE ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JZ rel8 || <tt>74 ii</tt> || <tt>01110100 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|LAHF}}
=== LAHF ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| LAHF || <tt>9F</tt> || <tt>10011111</tt> || 1 || 2
|}
----
{{Anchor|LDS}}
=== LDS ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| LDS reg16, mem16 || <tt>C5 /r</tt> || <tt>11000101 oorrrmmm</tt> || 2+ || 6
|}
----
{{Anchor|LEA}}
=== LEA ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| LEA reg16, mem16 || <tt>8D /r</tt> || <tt>10001101 oorrrmmm</tt> || 2+ || 1
|}
----
{{Anchor|LEAVE}}
=== LEAVE ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| LEAVE || <tt>C9</tt> || <tt>11001001</tt> || 1 || 2
|}
----
{{Anchor|LES}}
=== LES ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| LES reg16, mem16 || <tt>C4 /r</tt> || <tt>11000100 oorrrmmm</tt> || 2+ || 6
|}
----
{{Anchor|LOCK}}
=== LOCK ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| LOCK || <tt>F0</tt> || <tt>11110000</tt> || 1 || 1
|}
----
{{Anchor|LODSB}}
{{Anchor|LODSW}}
=== LODSB/LODSW ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| LODSB || <tt>AC</tt> || <tt>10101100</tt> || 1 || 3
|-
| LODSW || <tt>AD</tt> || <tt>10101101</tt> || 1 || 3
|}
----
{{Anchor|LOOP}}
=== LOOP ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| LOOP rel8 || <tt>E2 ii</tt> || <tt>11100010 iiiiiiii</tt> || 2 || 2 (5 if branch taken)
|}
----
{{Anchor|LOOPE}}
=== LOOPE ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| LOOPE rel8 || <tt>E1 ii</tt> || <tt>11100001 iiiiiiii</tt> || 2 || 3 (6 if branch taken)
|}
----
{{Anchor|LOOPNE}}
=== LOOPNE ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| LOOPNE rel8 || <tt>E0 ii</tt> || <tt>11100000 iiiiiiii</tt> || 2 || 3 (6 if branch taken)
|}
----
{{Anchor|MOV}}
=== MOV ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| MOV AL, ptr16 || <tt>A0 ii ii</tt> || <tt>10100000 iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| MOV AX, ptr16 || <tt>A1 ii ii</tt> || <tt>10100001 iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| MOV mem8, imm8 || <tt>C6 /0 ii</tt> || <tt>11000110 oo000mmm iiiiiiii</tt> || 3+ || 1
|-
| MOV mem16, imm16 || <tt>C7 /0 ii ii</tt> || <tt>11000111 oo000mmm iiiiiiii iiiiiiii</tt> || 4+ || 1
|-
| MOV mem8, reg8 || <tt>88 /r</tt> || <tt>10001000 oorrrmmm</tt> || 2+ || 1
|-
| MOV mem16, reg16 || <tt>89 /r</tt> || <tt>10001001 oorrrmmm</tt> || 2+ || 1
|-
| MOV mem16, sreg16 || <tt>8C /r</tt> || <tt>10001100 oo0rrmmm</tt> || 2+ || 3
|-
| MOV ptr16, AL || <tt>A2 ii ii</tt> || <tt>10100010 iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| MOV ptr16, AX || <tt>A3 ii ii</tt> || <tt>10100011 iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| MOV reg8, imm8 || <tt>Bx ii</tt> || <tt>10110rrr iiiiiiii</tt> || 2 || 1
|-
| MOV reg8, imm8 || <tt>C6 /0 ii</tt> || <tt>11000110 11000mmm iiiiiiii</tt> || 3 || 1
|-
| MOV reg16, imm16 || <tt>Bx ii</tt> || <tt>10111rrr iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| MOV reg16, imm16 || <tt>C7 /0 ii ii</tt> || <tt>11000111 11000mmm iiiiiiii iiiiiiii</tt> || 4 || 1
|-
| MOV reg8, mem8 || <tt>8A /r</tt> || <tt>10001010 oorrrmmm</tt> || 2+ || 1
|-
| MOV reg16, mem16 || <tt>8B /r</tt> || <tt>10001011 oorrrmmm</tt> || 2+ || 1
|-
| MOV reg8, reg8 || <tt>88 /r</tt> || <tt>100010.0 11rrrmmm</tt> || 2 || 1
|-
| MOV reg16, reg16 || <tt>89 /r</tt> || <tt>100010.1 11rrrmmm</tt> || 2 || 1
|-
| MOV reg16, sreg16 || <tt>8C /r</tt> || <tt>10001100 110rrmmm</tt> || 2 || 1
|-
| MOV sreg16, mem16 || <tt>8E /r</tt> || <tt>10001110 oo0rrmmm</tt> || 2 || 3
|-
| MOV sreg16, reg16 || <tt>8E /r</tt> || <tt>10001110 110rrmmm</tt> || 2+ || 2
|}
----
{{Anchor|MOVSB}}
{{Anchor|MOVSW}}
=== MOVSB/MOVSW ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| MOVSB || <tt>A4</tt> || <tt>10100100</tt> || 1 || 5
|-
| MOVSW || <tt>A5</tt> || <tt>10100101</tt> || 1 || 5
|}
----
{{Anchor|MUL}}
=== MUL ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| MUL mem8 || <tt>F6 /4</tt> || <tt>11110110 oo100mmm</tt> || 2+ || 4
|-
| MUL mem16 || <tt>F7 /4</tt> || <tt>11111111 oo100mmm</tt> || 2+ || 4
|-
| MUL reg8 || <tt>F6 /4</tt> || <tt>11111110 11100mmm</tt> || 2 || 3
|-
| MUL reg16 || <tt>F7 /4</tt> || <tt>11111111 11100mmm</tt> || 2 || 3
|}
----
{{Anchor|NEG}}
=== NEG ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| NEG mem8 || <tt>F6 /3</tt> || <tt>11110110 oo011mmm</tt> || 2+ || 3
|-
| NEG mem16 || <tt>F7 /3</tt> || <tt>11111111 oo011mmm</tt> || 2+ || 3
|-
| NEG reg8 || <tt>F6 /3</tt> || <tt>11111110 11011mmm</tt> || 2 || 1
|-
| NEG reg16 || <tt>F7 /3</tt> || <tt>11111111 11011mmm</tt> || 2 || 1
|}
----
{{Anchor|NOP}}
=== NOP ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| NOP || <tt>90</tt> || <tt>10010000</tt> || 1 || 1
|}
----
{{Anchor|NOT}}
=== NOT ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| NOT mem8 || <tt>F6 /2</tt> || <tt>11110110 oo010mmm</tt> || 2+ || 3
|-
| NOT mem16 || <tt>F7 /2</tt> || <tt>11111111 oo010mmm</tt> || 2+ || 3
|-
| NOT reg8 || <tt>F6 /2</tt> || <tt>11111110 11010mmm</tt> || 2 || 1
|-
| NOT reg16 || <tt>F7 /2</tt> || <tt>11111111 11010mmm</tt> || 2 || 1
|}
----
{{Anchor|OR}}
=== OR ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| OR AL, imm || <tt>0C ii</tt> || <tt>00001100 iiiiiiii</tt> || 2 || 1
|-
| OR AX, imm || <tt>0D ii ii</tt> || <tt>00001101 iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| OR mem8, imm8 || <tt>80 /6 ii</tt> || <tt>10000000 oo001mmm iiiiiiii</tt> || 3+ || 3
|-
| OR mem16, imm16 || <tt>81 /6 ii ii</tt> || <tt>10000001 oo001mmm iiiiiiii iiiiiiii</tt> || 4+ || 3
|-
| OR mem16, simm8 || <tt>83 /6 ii</tt> || <tt>10000011 oo001mmm iiiiiiii</tt> || 3+ || 3
|-
| OR mem8, reg8 || <tt>08 /r</tt> || <tt>00001000 oorrrmmm</tt> || 2+ || 3
|-
| OR mem16, reg16 || <tt>09 /r</tt> || <tt>00001001 oorrrmmm</tt> || 2+ || 3
|-
| OR reg8, imm8 || <tt>80 /6 ii</tt> || <tt>10000000 11001mmm iiiiiiii</tt> || 3 || 1
|-
| OR reg16, imm16 || <tt>81 /6 ii ii</tt> || <tt>10000001 11001mmm iiiiiiii iiiiiiii</tt> || 4 || 1
|-
| OR reg16, simm8 || <tt>83 /6 ii</tt> || <tt>10000011 11001mmm iiiiiiii</tt> || 3 || 1
|-
| OR reg8, mem8 || <tt>0A /r</tt> || <tt>00001010 oorrrmmm</tt> || 2+ || 2
|-
| OR reg16, mem16 || <tt>0B /r</tt> || <tt>00001011 oorrrmmm</tt> || 2+ || 2
|-
| OR reg8, reg8 || <tt>08 /r</tt> || <tt>000010.0 11rrrmmm</tt> || 2 || 1
|-
| OR reg16, reg16 || <tt>09 /r</tt> || <tt>000010.1 11rrrmmm</tt> || 2 || 1
|}
----
{{Anchor|OUT}}
=== OUT ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| OUT AL, DX || <tt>EE</tt> || <tt>11101110</tt> || 1 || 6
|-
| OUT AX, DX || <tt>EF</tt> || <tt>11101111</tt> || 1 || 6
|-
| OUT AL, imm8 || <tt>E6 ii</tt> || <tt>11100110 iiiiiiii</tt> || 2 || 6
|-
| OUT AX, imm8 || <tt>E7 ii</tt> || <tt>11100111 iiiiiiii</tt> || 2 || 6
|}
----
{{Anchor|OUTSB}}
{{Anchor|OUTSW}}
=== OUTSB/OUTSW ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| OUTSB || <tt>6E</tt> || <tt>01101110</tt> || 1 || 6
|-
| OUTSW || <tt>6F</tt> || <tt>01101111</tt> || 1 || 6
|}
----
{{Anchor|POP}}
=== POP ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| POP mem16 || <tt>8F /0</tt> || <tt>10001111 oo000mmm</tt> || 2+ || 3
|-
| POP reg16 || <tt>5x</tt> || <tt>01011xxx</tt> || 1 || 1
|-
| POP reg16 || <tt>8F /0</tt> || <tt>10001111 11000mmm</tt> || 2 || 1
|-
| POP sreg16 || <tt>xx</tt> || <tt>000xx111</tt> || 1 || 3
|}
----
{{Anchor|POPA}}
=== POPA ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| POPA || <tt>61</tt> || <tt>01100001</tt> || 1 || 8
|}
----
{{Anchor|POPF}}
=== POPF ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| POPF || <tt>9D</tt> || <tt>10011101</tt> || 1 || 3
|}
----
{{Anchor|PUSH}}
=== PUSH ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| PUSH simm8 || <tt>6A ii</tt> || <tt>01101010 iiiiiiii</tt> || 2 || 1
|-
| PUSH imm16 || <tt>68 ii ii</tt> || <tt>01101000 iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| PUSH mem16 || <tt>FF /6</tt> || <tt>11111111 oo110mmm</tt> || 2+ || 2
|-
| PUSH reg16 || <tt>5x</tt> || <tt>01010xxx</tt> || 1 || 1
|-
| PUSH reg16 || <tt>FF /6</tt> || <tt>11111111 11110mmm</tt> || 2 || 1
|-
| PUSH sreg16 || <tt>xx</tt> || <tt>000xx110</tt> || 1 || 2
|}
----
{{Anchor|PUSHA}}
=== PUSHA ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| PUSHA || <tt>60</tt> || <tt>01100000</tt> || 1 || 9
|}
----
{{Anchor|PUSHF}}
=== PUSHF ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| PUSHF || <tt>9C</tt> || <tt>10011100</tt> || 1 || 2
|}
----
{{Anchor|RCL}}
=== RCL ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| RCL mem8, 1 || <tt>D0 /2</tt> || <tt>11010000 oo010rm</tt> || 2+ || 3
|-
| RCL mem8, CL || <tt>D2 /2</tt> || <tt>11010010 oo010rm</tt> || 2+ || 5
|-
| RCL mem8, imm8 || <tt>C0 /2 ii</tt> || <tt>11000000 oo010mmm iiiiiiii</tt> || 3+ || 5
|-
| RCL mem16, 1 || <tt>D1 /2</tt> || <tt>11010001 oo010rm</tt> || 2+ || 3
|-
| RCL mem16, CL || <tt>D3 /2</tt> || <tt>11010011 oo010rm</tt> || 2+ || 5
|-
| RCL mem16, imm8 || <tt>C1 /2 ii</tt> || <tt>11000001 oo010mmm iiiiiiii</tt> || 3+ || 5
|-
| RCL reg8, 1 || <tt>D0 /2</tt> || <tt>11010000 11010rm</tt> || 2 || 1
|-
| RCL reg8, CL || <tt>D2 /2</tt> || <tt>11010010 11010rm</tt> || 2 || 3
|-
| RCL reg8, imm8 || <tt>C0 /2 ii</tt> || <tt>11000000 11010mmm iiiiiiii</tt> || 3 || 3
|-
| RCL reg16, 1 || <tt>D1 /2</tt> || <tt>11010001 11010rm</tt> || 2 || 1
|-
| RCL reg16, CL || <tt>D3 /2</tt> || <tt>11010011 11010rm</tt> || 2 || 3
|-
| RCL reg16, imm8 || <tt>C1 /2 ii</tt> || <tt>11000001 11010mmm iiiiiiii</tt> || 3 || 3
|}
----
{{Anchor|RCR}}
=== RCR ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| RCR mem8, 1 || <tt>D0 /3</tt> || <tt>11010000 oo011rm</tt> || 2+ || 3
|-
| RCR mem8, CL || <tt>D2 /3</tt> || <tt>11010010 oo011rm</tt> || 2+ || 5
|-
| RCR mem8, imm8 || <tt>C0 /3 ii</tt> || <tt>11000000 oo011mmm iiiiiiii</tt> || 3+ || 5
|-
| RCR mem16, 1 || <tt>D1 /3</tt> || <tt>11010001 oo011rm</tt> || 2+ || 3
|-
| RCR mem16, CL || <tt>D3 /3</tt> || <tt>11010011 oo011rm</tt> || 2+ || 5
|-
| RCR mem16, imm8 || <tt>C1 /3 ii</tt> || <tt>11000001 oo011mmm iiiiiiii</tt> || 3+ || 5
|-
| RCR reg8, 1 || <tt>D0 /3</tt> || <tt>11010000 11011rm</tt> || 2 || 1
|-
| RCR reg8, CL || <tt>D2 /3</tt> || <tt>11010010 11011rm</tt> || 2 || 3
|-
| RCR reg8, imm8 || <tt>C0 /3 ii</tt> || <tt>11000000 11011mmm iiiiiiii</tt> || 3 || 3
|-
| RCR reg16, 1 || <tt>D1 /3</tt> || <tt>11010001 11011rm</tt> || 2 || 1
|-
| RCR reg16, CL || <tt>D3 /3</tt> || <tt>11010011 11011rm</tt> || 2 || 3
|-
| RCR reg16, imm8 || <tt>C1 /3 ii</tt> || <tt>11000001 11011mmm iiiiiiii</tt> || 3 || 3
|}
----
{{Anchor|REP}}
=== REP/REPE/REPZ ===
----
{{Anchor|REPNE}}
=== REPNE/REPNZ ===
----
{{Anchor|RET}}
=== RET ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| RET || <tt>C3</tt> || <tt>11000011</tt> || 1 || 6
|-
| RET imm16 || <tt>C2 ii ii</tt> || <tt>11000010 iiiiiiii iiiiiiii</tt> || 1 || 6
|}
----
{{Anchor|RETF}}
=== RETF ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| RETF || <tt>CB</tt> || <tt>11001011</tt> || 1 || 8
|-
| RETF imm16 || <tt>CA ii ii</tt> || <tt>11001010 iiiiiiii iiiiiiii</tt> || 1 || 9
|}
----
{{Anchor|ROL}}
=== ROL ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| ROL mem8, 1 || <tt>D0 /0</tt> || <tt>11010000 oo000rm</tt> || 2+ || 3
|-
| ROL mem8, CL || <tt>D2 /0</tt> || <tt>11010010 oo000rm</tt> || 2+ || 5
|-
| ROL mem8, imm8 || <tt>C0 /0 ii</tt> || <tt>11000000 oo000mmm iiiiiiii</tt> || 3+ || 5
|-
| ROL mem16, 1 || <tt>D1 /0</tt> || <tt>11010001 oo000rm</tt> || 2+ || 3
|-
| ROL mem16, CL || <tt>D3 /0</tt> || <tt>11010011 oo000rm</tt> || 2+ || 5
|-
| ROL mem16, imm8 || <tt>C1 /0 ii</tt> || <tt>11000001 oo000mmm iiiiiiii</tt> || 3+ || 5
|-
| ROL reg8, 1 || <tt>D0 /0</tt> || <tt>11010000 11000rm</tt> || 2 || 1
|-
| ROL reg8, CL || <tt>D2 /0</tt> || <tt>11010010 11000rm</tt> || 2 || 3
|-
| ROL reg8, imm8 || <tt>C0 /0 ii</tt> || <tt>11000000 11000mmm iiiiiiii</tt> || 3 || 3
|-
| ROL reg16, 1 || <tt>D1 /0</tt> || <tt>11010001 11000rm</tt> || 2 || 1
|-
| ROL reg16, CL || <tt>D3 /0</tt> || <tt>11010011 11000rm</tt> || 2 || 3
|-
| ROL reg16, imm8 || <tt>C1 /0 ii</tt> || <tt>11000001 11000mmm iiiiiiii</tt> || 3 || 3
|}
----
{{Anchor|ROR}}
=== ROR ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| ROR mem8, 1 || <tt>D0 /1</tt> || <tt>11010000 oo001rm</tt> || 2+ || 3
|-
| ROR mem8, CL || <tt>D2 /1</tt> || <tt>11010010 oo001rm</tt> || 2+ || 5
|-
| ROR mem8, imm8 || <tt>C0 /1 ii</tt> || <tt>11000000 oo001mmm iiiiiiii</tt> || 3+ || 5
|-
| ROR mem16, 1 || <tt>D1 /1</tt> || <tt>11010001 oo001rm</tt> || 2+ || 3
|-
| ROR mem16, CL || <tt>D3 /1</tt> || <tt>11010011 oo001rm</tt> || 2+ || 5
|-
| ROR mem16, imm8 || <tt>C1 /1 ii</tt> || <tt>11000001 oo001mmm iiiiiiii</tt> || 3+ || 5
|-
| ROR reg8, 1 || <tt>D0 /1</tt> || <tt>11010000 11001rm</tt> || 2 || 1
|-
| ROR reg8, CL || <tt>D2 /1</tt> || <tt>11010010 11001rm</tt> || 2 || 3
|-
| ROR reg8, imm8 || <tt>C0 /1 ii</tt> || <tt>11000000 11001mmm iiiiiiii</tt> || 3 || 3
|-
| ROR reg16, 1 || <tt>D1 /1</tt> || <tt>11010001 11001rm</tt> || 2 || 1
|-
| ROR reg16, CL || <tt>D3 /1</tt> || <tt>11010011 11001rm</tt> || 2 || 3
|-
| ROR reg16, imm8 || <tt>C1 /1 ii</tt> || <tt>11000001 11001mmm iiiiiiii</tt> || 3 || 3
|}
----
{{Anchor|SAHF}}
=== SAHF ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| SAHF || <tt>9E</tt> || <tt>10011110</tt> || 1 || 4
|}
----
{{Anchor|SAR}}
=== SAR ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| SAR mem8, 1 || <tt>D0 /7</tt> || <tt>11010000 oo111rm</tt> || 2+ || 3
|-
| SAR mem8, CL || <tt>D2 /7</tt> || <tt>11010010 oo111rm</tt> || 2+ || 5
|-
| SAR mem8, imm8 || <tt>C0 /7 ii</tt> || <tt>11000000 oo111mmm iiiiiiii</tt> || 3+ || 5
|-
| SAR mem16, 1 || <tt>D1 /7</tt> || <tt>11010001 oo111rm</tt> || 2+ || 3
|-
| SAR mem16, CL || <tt>D3 /7</tt> || <tt>11010011 oo111rm</tt> || 2+ || 5
|-
| SAR mem16, imm8 || <tt>C1 /7 ii</tt> || <tt>11000001 oo111mmm iiiiiiii</tt> || 3+ || 5
|-
| SAR reg8, 1 || <tt>D0 /7</tt> || <tt>11010000 11111rm</tt> || 2 || 1
|-
| SAR reg8, CL || <tt>D2 /7</tt> || <tt>11010010 11111rm</tt> || 2 || 3
|-
| SAR reg8, imm8 || <tt>C0 /7 ii</tt> || <tt>11000000 11111mmm iiiiiiii</tt> || 3 || 3
|-
| SAR reg16, 1 || <tt>D1 /7</tt> || <tt>11010001 11111rm</tt> || 2 || 1
|-
| SAR reg16, CL || <tt>D3 /7</tt> || <tt>11010011 11111rm</tt> || 2 || 3
|-
| SAR reg16, imm8 || <tt>C1 /7 ii</tt> || <tt>11000001 11111mmm iiiiiiii</tt> || 3 || 3
|}
----
{{Anchor|SBB}}
=== SBB ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| SBB AL, imm || <tt>1C ii</tt> || <tt>00011100 iiiiiiii</tt> || 2 || 1
|-
| SBB AX, imm || <tt>1D ii ii</tt> || <tt>00011101 iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| SBB mem8, imm8 || <tt>80 /3 ii</tt> || <tt>10000000 oo011mmm iiiiiiii</tt> || 3+ || 3
|-
| SBB mem16, imm16 || <tt>81 /3 ii ii</tt> || <tt>10000001 oo011mmm iiiiiiii iiiiiiii</tt> || 4+ || 3
|-
| SBB mem16, simm8 || <tt>83 /3 ii</tt> || <tt>10000011 oo011mmm iiiiiiii</tt> || 3+ || 3
|-
| SBB mem8, reg8 || <tt>18 /r</tt> || <tt>00011000 oorrrmmm</tt> || 2+ || 3
|-
| SBB mem16, reg16 || <tt>19 /r</tt> || <tt>00011001 oorrrmmm</tt> || 2+ || 3
|-
| SBB reg8, imm8 || <tt>80 /3 ii</tt> || <tt>10000000 11011mmm iiiiiiii</tt> || 3 || 1
|-
| SBB reg16, imm16 || <tt>81 /3 ii ii</tt> || <tt>10000001 11011mmm iiiiiiii iiiiiiii</tt> || 4 || 1
|-
| SBB reg16, simm8 || <tt>83 /3 ii</tt> || <tt>10000011 11011mmm iiiiiiii</tt> || 3 || 1
|-
| SBB reg8, mem8 || <tt>1A /r</tt> || <tt>00011010 oorrrmmm</tt> || 2+ || 2
|-
| SBB reg16, mem16 || <tt>1B /r</tt> || <tt>00011011 oorrrmmm</tt> || 2+ || 2
|-
| SBB reg8, reg8 || <tt>18 /r</tt> || <tt>000110.0 11rrrmmm</tt> || 2 || 1
|-
| SBB reg16, reg16 || <tt>19 /r</tt> || <tt>000110.1 11rrrmmm</tt> || 2 || 1
|}
----
{{Anchor|SCASB}}
{{Anchor|SCASW}}
=== SCASB/SCASW ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| SCASB || <tt>AE</tt> || <tt>10101110</tt> || 1 || 4
|-
| SCASW || <tt>AF</tt> || <tt>10101111</tt> || 1 || 4
|}
----
{{Anchor|SHL}}
=== SHL ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| SHL mem8, 1 || <tt>D0 /4</tt> || <tt>11010000 oo100rm</tt> || 2+ || 3
|-
| SHL mem8, CL || <tt>D2 /4</tt> || <tt>11010010 oo100rm</tt> || 2+ || 5
|-
| SHL mem8, imm8 || <tt>C0 /4 ii</tt> || <tt>11000000 oo100mmm iiiiiiii</tt> || 3+ || 5
|-
| SHL mem16, 1 || <tt>D1 /4</tt> || <tt>11010001 oo100rm</tt> || 2+ || 3
|-
| SHL mem16, CL || <tt>D3 /4</tt> || <tt>11010011 oo100rm</tt> || 2+ || 5
|-
| SHL mem16, imm8 || <tt>C1 /4 ii</tt> || <tt>11000001 oo100mmm iiiiiiii</tt> || 3+ || 5
|-
| SHL reg8, 1 || <tt>D0 /4</tt> || <tt>11010000 11100rm</tt> || 2 || 1
|-
| SHL reg8, CL || <tt>D2 /4</tt> || <tt>11010010 11100rm</tt> || 2 || 3
|-
| SHL reg8, imm8 || <tt>C0 /4 ii</tt> || <tt>11000000 11100mmm iiiiiiii</tt> || 3 || 3
|-
| SHL reg16, 1 || <tt>D1 /4</tt> || <tt>11010001 11100rm</tt> || 2 || 1
|-
| SHL reg16, CL || <tt>D3 /4</tt> || <tt>11010011 11100rm</tt> || 2 || 3
|-
| SHL reg16, imm8 || <tt>C1 /4 ii</tt> || <tt>11000001 11100mmm iiiiiiii</tt> || 3 || 3
|}
----
{{Anchor|SHR}}
=== SHR ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| SHR mem8, 1 || <tt>D0 /5</tt> || <tt>11010000 oo101rm</tt> || 2+ || 3
|-
| SHR mem8, CL || <tt>D2 /5</tt> || <tt>11010010 oo101rm</tt> || 2+ || 5
|-
| SHR mem8, imm8 || <tt>C0 /5 ii</tt> || <tt>11000000 oo101mmm iiiiiiii</tt> || 3+ || 5
|-
| SHR mem16, 1 || <tt>D1 /5</tt> || <tt>11010001 oo101rm</tt> || 2+ || 3
|-
| SHR mem16, CL || <tt>D3 /5</tt> || <tt>11010011 oo101rm</tt> || 2+ || 5
|-
| SHR mem16, imm8 || <tt>C1 /5 ii</tt> || <tt>11000001 oo101mmm iiiiiiii</tt> || 3+ || 5
|-
| SHR reg8, 1 || <tt>D0 /5</tt> || <tt>11010000 11101rm</tt> || 2 || 1
|-
| SHR reg8, CL || <tt>D2 /5</tt> || <tt>11010010 11101rm</tt> || 2 || 3
|-
| SHR reg8, imm8 || <tt>C0 /5 ii</tt> || <tt>11000000 11101mmm iiiiiiii</tt> || 3 || 3
|-
| SHR reg16, 1 || <tt>D1 /5</tt> || <tt>11010001 11101rm</tt> || 2 || 1
|-
| SHR reg16, CL || <tt>D3 /5</tt> || <tt>11010011 11101rm</tt> || 2 || 3
|-
| SHR reg16, imm8 || <tt>C1 /5 ii</tt> || <tt>11000001 11101mmm iiiiiiii</tt> || 3 || 3
|}
----
{{Anchor|SS}}
=== SS ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| SS || <tt>36</tt> || <tt>00110110</tt> || 1 || 1
|}
----
{{Anchor|STC}}
=== STC ===
{| class="wikitable"
! Flag !! New value
|-
| [[NEC_V30MZ_flags#CF|CF - Carry]] || 1
|}
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| STC || <tt>F9</tt> || <tt>11111001</tt> || 1 || 4
|}
----
{{Anchor|STD}}
=== STD ===
{| class="wikitable"
! Flag !! New value
|-
| [[NEC_V30MZ_flags#DF|DF - Direction]] || 1
|}
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| STD || <tt>FD</tt> || <tt>11111101</tt> || 1 || 4
|}
----
{{Anchor|STI}}
=== STI ===
{| class="wikitable"
! Flag !! New value
|-
| [[NEC_V30MZ_flags#IF|IF - Interrupt]] || 1
|}
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| STI || <tt>FB</tt> || <tt>11111011</tt> || 1 || 4
|}
----
{{Anchor|STOSB}}
{{Anchor|STOSW}}
=== STOSB/STOSW ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| STOSB || <tt>AA</tt> || <tt>10101010</tt> || 1 || 3
|-
| STOSW || <tt>AB</tt> || <tt>10101011</tt> || 1 || 3
|}
----
{{Anchor|SUB}}
=== SUB ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| SUB AL, imm || <tt>28 ii</tt> || <tt>00101100 iiiiiiii</tt> || 2 || 1
|-
| SUB AX, imm || <tt>29 ii ii</tt> || <tt>00101101 iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| SUB mem8, imm8 || <tt>80 /5 ii</tt> || <tt>10000000 oo101mmm iiiiiiii</tt> || 3+ || 3
|-
| SUB mem16, imm16 || <tt>81 /5 ii ii</tt> || <tt>10000001 oo101mmm iiiiiiii iiiiiiii</tt> || 4+ || 3
|-
| SUB mem16, simm8 || <tt>83 /5 ii</tt> || <tt>10000011 oo101mmm iiiiiiii</tt> || 3+ || 3
|-
| SUB mem8, reg8 || <tt>28 /r</tt> || <tt>00101000 oorrrmmm</tt> || 2+ || 3
|-
| SUB mem16, reg16 || <tt>29 /r</tt> || <tt>00101001 oorrrmmm</tt> || 2+ || 3
|-
| SUB reg8, imm8 || <tt>80 /5 ii</tt> || <tt>10000000 11101mmm iiiiiiii</tt> || 3 || 1
|-
| SUB reg16, imm16 || <tt>81 /5 ii ii</tt> || <tt>10000001 11101mmm iiiiiiii iiiiiiii</tt> || 4 || 1
|-
| SUB reg16, simm8 || <tt>83 /5 ii</tt> || <tt>10000011 11101mmm iiiiiiii</tt> || 3 || 1
|-
| SUB reg8, mem8 || <tt>2A /r</tt> || <tt>00101010 oorrrmmm</tt> || 2+ || 2
|-
| SUB reg16, mem16 || <tt>2B /r</tt> || <tt>00101011 oorrrmmm</tt> || 2+ || 2
|-
| SUB reg8, reg8 || <tt>28 /r</tt> || <tt>001010.0 11rrrmmm</tt> || 2 || 1
|-
| SUB reg16, reg16 || <tt>29 /r</tt> || <tt>001010.1 11rrrmmm</tt> || 2 || 1
|}
----
{{Anchor|TEST}}
=== TEST ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| TEST AL, imm || <tt>A8 ii</tt> || <tt>10101000 iiiiiiii</tt> || 2 || 1
|-
| TEST AX, imm || <tt>A9 ii ii</tt> || <tt>10101001 iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| TEST mem8, imm8 || <tt>F6 /0 ii</tt> || <tt>11110110 oo000mmm iiiiiiii</tt> || 3+ || 2
|-
| TEST mem16, imm16 || <tt>F7 /0 ii ii</tt> || <tt>11110111 oo000mmm iiiiiiii iiiiiiii</tt> || 4+ || 2
|-
| TEST mem8, reg8<br/>TEST reg8, mem8 || <tt>84 /r</tt> || <tt>10000100 oorrrmmm</tt> || 2+ || 2
|-
| TEST mem16, reg16<br/>TEST reg16, mem16 || <tt>85 /r</tt> || <tt>10000101 oorrrmmm</tt> || 2+ || 2
|-
| TEST reg8, imm8 || <tt>F6 /0 ii</tt> || <tt>11110110 11000mmm iiiiiiii</tt> || 3 || 1
|-
| TEST reg16, imm16 || <tt>F7 /0 ii ii</tt> || <tt>11110111 11000mmm iiiiiiii iiiiiiii</tt> || 4 || 1
|-
| TEST reg8, reg8 || <tt>84 /r</tt> || <tt>10000100 11rrrmmm</tt> || 2 || 1
|-
| TEST reg16, reg16 || <tt>85 /r</tt> || <tt>10000101 11rrrmmm</tt> || 2 || 1
|}
----
{{Anchor|WAIT}}
=== WAIT ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| WAIT || <tt>6E</tt> || <tt>01101110</tt> || 1 || 9<ref>On the WonderSwan implementation, POLLB is always held low; on other implementations, POLL will wait for POLLB to be held low in 9-cycle intervals.</ref>
|}
Nominally, this instruction synchronizes the CPU with an external co-processor. However, as the WonderSwan does not feature one, this instruction simply becomes a (slower) no-op.
----
{{Anchor|XCHG}}
=== XCHG ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| XCHG AX, reg16<br/>XCHG reg16, AX || <tt>9x</tt> || <tt>10010rrr</tt> || 1 || 3
|-
| XCHG mem8, reg8<br/>XCHG reg8, mem8 || <tt>86 /r</tt> || <tt>10000110 oorrrmmm</tt> || 2+ || 5
|-
| XCHG mem16, reg16<br/>XCHG reg16, mem16 || <tt>87 /r</tt> || <tt>10000111 oorrrmmm</tt> || 2+ || 5
|-
| XCHG reg8, reg8 || <tt>86 /r</tt> || <tt>10000110 11rrrmmm</tt> || 2+ || 3
|-
| XCHG reg16, reg16 || <tt>87 /r</tt> || <tt>10000111 11rrrmmm</tt> || 2+ || 3
|}
----
{{Anchor|XLAT}}
=== XLAT ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| XLAT || <tt>D7</tt> || <tt>11010111</tt> || 1 || 5
|}
----
{{Anchor|XOR}}
=== XOR ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| XOR AL, imm || <tt>34 ii</tt> || <tt>00110100 iiiiiiii</tt> || 2 || 1
|-
| XOR AX, imm || <tt>35 ii ii</tt> || <tt>00110101 iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| XOR mem8, imm8 || <tt>80 /6 ii</tt> || <tt>10000000 oo110mmm iiiiiiii</tt> || 3+ || 3
|-
| XOR mem16, imm16 || <tt>81 /6 ii ii</tt> || <tt>10000001 oo110mmm iiiiiiii iiiiiiii</tt> || 4+ || 3
|-
| XOR mem16, simm8 || <tt>83 /6 ii</tt> || <tt>10000011 oo110mmm iiiiiiii</tt> || 3+ || 3
|-
| XOR mem8, reg8 || <tt>30 /r</tt> || <tt>00110000 oorrrmmm</tt> || 2+ || 3
|-
| XOR mem16, reg16 || <tt>31 /r</tt> || <tt>00110001 oorrrmmm</tt> || 2+ || 3
|-
| XOR reg8, imm8 || <tt>80 /6 ii</tt> || <tt>10000000 11110mmm iiiiiiii</tt> || 3 || 1
|-
| XOR reg16, imm16 || <tt>81 /6 ii ii</tt> || <tt>10000001 11110mmm iiiiiiii iiiiiiii</tt> || 4 || 1
|-
| XOR reg16, simm8 || <tt>83 /6 ii</tt> || <tt>10000011 11110mmm iiiiiiii</tt> || 3 || 1
|-
| XOR reg8, mem8 || <tt>32 /r</tt> || <tt>00110010 oorrrmmm</tt> || 2+ || 2
|-
| XOR reg16, mem16 || <tt>33 /r</tt> || <tt>00110011 oorrrmmm</tt> || 2+ || 2
|-
| XOR reg8, reg8 || <tt>30 /r</tt> || <tt>001100.0 11rrrmmm</tt> || 2 || 1
|-
| XOR reg16, reg16 || <tt>31 /r</tt> || <tt>001100.1 11rrrmmm</tt> || 2 || 1
|}
== Notes ==
<references />
591c480a1e15b36b90ee7969bb8738aa03600586
595
594
2025-04-20T17:56:08Z
Asie
351
/* OUT */ Fix operand order (thanks PECO!)
wikitext
text/x-wiki
__NOTOC__
Note that this page is a work in progress.
{| class="wikitable" style="text-align: center"
|+ Official V30MZ (80186) Instructions
|-
| [[#AAA|AAA]] || [[#AAD|AAD]] || [[#AAM|AAM]] || [[#AAS|AAS]] || [[#ADC|ADC]] || [[#ADD|ADD]] || [[#AND|AND]] || [[#BOUND|BOUND]] || [[#CALL|CALL]] || [[#CBW|CBW]] || [[#CLC|CLC]]
|-
| [[#CLD|CLD]] || [[#CLI|CLI]] || [[#CMC|CMC]] || [[#CMP|CMP]] || [[#CMPSB|CMPSB]] || [[#CMPSW|CMPSW]] || [[#CS|CS]] || [[#CWD|CWD]] || [[#DAA|DAA]] || [[#DAS|DAS]] || [[#DEC|DEC]]
|-
| [[#DIV|DIV]] || [[#DS|DS]] || [[#ENTER|ENTER]] || [[#ES|ES]] || [[#HLT|HLT]] || [[#IDIV|IDIV]] || [[#IMUL|IMUL]] || [[#IN|IN]] || [[#INC|INC]] || [[#INSB|INSB]] || [[#INSW|INSW]]
|-
| [[#INT|INT]] || [[#INTO|INTO]] || [[#IRET|IRET]] || [[#JA|JA]] || [[#JBE|JBE]] || [[#JC|JC]] || [[#JCXZ|JCXZ]] || [[#JG|JG]] || [[#JGE|JGE]] || [[#JL|JL]] || [[#JLE|JLE]]
|-
| [[#JMP|JMP]] || [[#JNC|JNC]] || [[#JNO|JNO]] || [[#JNP|JNP]] || [[#JNS|JNS]] || [[#JNZ|JNZ]] || [[#JO|JO]] || [[#JP|JP]] || [[#JS|JS]] || [[#JZ|JZ]] || [[#LAHF|LAHF]]
|-
| [[#LDS|LDS]] || [[#LEA|LEA]] || [[#LEAVE|LEAVE]] || [[#LES|LES]] || [[#LOCK|LOCK]] || [[#LODSB|LODSB]] || [[#LODSW|LODSW]] || [[#LOOP|LOOP]] || [[#LOOPE|LOOPE]] || [[#LOOPNE|LOOPNE]] || [[#MOV|MOV]]
|-
| [[#MOVSB|MOVSB]] || [[#MOVSW|MOVSW]] || [[#MUL|MUL]] || [[#NEG|NEG]] || [[#NOP|NOP]] || [[#NOT|NOT]] || [[#OR|OR]] || [[#OUT|OUT]] || [[#OUTSB|OUTSB]] || [[#OUTSW|OUTSW]] || [[#POP|POP]]
|-
| [[#POPA|POPA]] || [[#POPF|POPF]] || [[#PUSH|PUSH]] || [[#PUSHA|PUSHA]] || [[#PUSHF|PUSHF]] || [[#RCL|RCL]] || [[#RCR|RCR]] || [[#REP|REP]] || [[#REPNE|REPNE]] || [[#RET|RET]] || [[#RETF|RETF]]
|-
| [[#ROL|ROL]] || [[#ROR|ROR]] || [[#SAHF|SAHF]] || [[#SAR|SAR]] || [[#SBB|SBB]] || [[#SCASB|SCASB]] || [[#SCASW|SCASW]] || [[#SHL|SHL]] || [[#SHR|SHR]] || [[#SS|SS]] || [[#STC|STC]]
|-
| [[#STD|STD]] || [[#STI|STI]] || [[#STOSB|STOSB]] || [[#STOSW|STOSW]] || [[#SUB|SUB]] || [[#TEST|TEST]] || [[#WAIT|WAIT]] || [[#XCHG|XCHG]] || [[#XLAT|XLAT]] || [[#XOR|XOR]]
|}
{| class="mw-collapsible mw-collapsed wikitable sortable" style="width: 340px;"
|+ style="white-space:nowrap; border:1px solid; padding:3px; border-color:rgb(162, 169, 177); background-color:rgb(234, 236, 240);" | Intel <-> NEC mnemonic translation table
!Intel
!NEC
|-
| [[#AAA|AAA]]
| [[#AAA|ADJBA]]
|-
| [[#AAD|AAD]]
| [[#AAD|CVTDB]]
|-
| [[#AAM|AAM]]
| [[#AAM|CVTBD]]
|-
| [[#AAS|AAS]]
| [[#AAS|ADJBS]]
|-
| [[#ADC|ADC]]
| [[#ADC|ADDC]]
|-
| [[#ADD|ADD]]
| [[#ADD|ADD]]
|-
| [[#AND|AND]]
| [[#AND|AND]]
|-
| [[#BOUND|BOUND]]
| [[#BOUND|CHKIND]]
|-
| [[#CALL|CALL]]
| [[#CALL|CALL]]
|-
| [[#CBW|CBW]]
| [[#CBW|CVTBW]]
|-
| [[#CLC|CLC]]
| [[#CLC|CLR1 CY]]
|-
| [[#CLD|CLD]]
| [[#CLD|CLR1 DIR]]
|-
| [[#CLI|CLI]]
| [[#CLI|DI]]
|-
| [[#CMC|CMC]]
| [[#CMC|NOT1 CY]]
|-
| [[#CMP|CMP]]
| [[#CMP|CMP]]
|-
| [[#CMPSB|CMPSB]]
| [[#CMPSB|CMPBKB]]
|-
| [[#CMPSW|CMPSW]]
| [[#CMPSW|CMPBKW]]
|-
| [[#CS|CS]]
| [[#CS|PS]]
|-
| [[#CWD|CWD]]
| [[#CWD|CVTWL]]
|-
| [[#DAA|DAA]]
| [[#DAA|ADJ4A]]
|-
| [[#DAS|DAS]]
| [[#DAS|ADJ4S]]
|-
| [[#DEC|DEC]]
| [[#DEC|DEC]]
|-
| [[#DIV|DIV]]
| [[#DIV|DIVU]]
|-
| [[#DS|DS]]
| [[#DS|DS0]]
|-
| [[#ENTER|ENTER]]
| [[#ENTER|PREPARE]]
|-
| [[#ES|ES]]
| [[#ES|DS1]]
|-
| [[#HLT|HLT]]
| [[#HLT|HALT]]
|-
| [[#IDIV|IDIV]]
| [[#IDIV|DIV]]
|-
| [[#IMUL|IMUL]]
| [[#IMUL|MUL]]
|-
| [[#IN|IN]]
| [[#IN|IN]]
|-
| [[#INC|INC]]
| [[#INC|INC]]
|-
| [[#INSB|INSB]]
| [[#INSB|INMB]]
|-
| [[#INSW|INSW]]
| [[#INSW|INMW]]
|-
| [[#INT|INT]]
| [[#INT|BRK]]
|-
| [[#INTO|INTO]]
| [[#INTO|BRKV]]
|-
| [[#IRET|IRET]]
| [[#IRET|RETI]]
|-
| [[#JA|JA]]
| [[#JA|BH]]
|-
| [[#JBE|JBE]]
| [[#JBE|BNH]]
|-
| [[#JC|JC/JB]]
| [[#JC|BC/BL]]
|-
| [[#JCXZ|JCXZ]]
| [[#JCXZ|BCWZ]]
|-
| [[#JG|JG]]
| [[#JG|BGT]]
|-
| [[#JGE|JGE]]
| [[#JGE|BGE]]
|-
| [[#JL|JL]]
| [[#JL|BLT]]
|-
| [[#JLE|JLE]]
| [[#JLE|BLE]]
|-
| [[#JMP|JMP]]
| [[#JMP|BR]]
|-
| [[#JNC|JNC/JAE]]
| [[#JNC|BNC/BNL]]
|-
| [[#JNO|JNO]]
| [[#JNO|BNV]]
|-
| [[#JNP|JNP]]
| [[#JNP|BPO]]
|-
| [[#JNS|JNS]]
| [[#JNS|BP]]
|-
| [[#JNZ|JNZ/JNE]]
| [[#JNZ|BNZ/BNE]]
|-
| [[#JO|JO]]
| [[#JO|BV]]
|-
| [[#JP|JP]]
| [[#JP|BPE]]
|-
| [[#JS|JS]]
| [[#JS|BN]]
|-
| [[#JZ|JZ/JE]]
| [[#JZ|BZ/BE]]
|-
| [[#LAHF|LAHF]]
| [[#LAHF|MOV]]
|-
| [[#LDS|LDS]]
| [[#LDS|MOV]]
|-
| [[#LEA|LEA]]
| [[#LEA|LDEA]]
|-
| [[#LEAVE|LEAVE]]
| [[#LEAVE|DISPOSE]]
|-
| [[#LES|LES]]
| [[#LES|MOV]]
|-
| [[#LOCK|LOCK]]
| [[#LOCK|BUSLOCK]]
|-
| [[#LODSB|LODSB]]
| [[#LODSB|LDMB]]
|-
| [[#LODSW|LODSW]]
| [[#LODSW|LDMW]]
|-
| [[#LOOP|LOOP]]
| [[#LOOP|DBNZ]]
|-
| [[#LOOPE|LOOPE]]
| [[#LOOPE|DBNZE]]
|-
| [[#LOOPNE|LOOPNE]]
| [[#LOOPNE|DBNZNE]]
|-
| [[#MOV|MOV]]
| [[#MOV|MOV]]
|-
| [[#MOVSB|MOVSB]]
| [[#MOVSB|MOVBKB]]
|-
| [[#MOVSW|MOVSW]]
| [[#MOVSW|MOVBKW]]
|-
| [[#MUL|MUL]]
| [[#MUL|MULU]]
|-
| [[#NEG|NEG]]
| [[#NEG|NEG]]
|-
| [[#NOP|NOP]]
| [[#NOP|NOP]]
|-
| [[#NOT|NOT]]
| [[#NOT|NOT]]
|-
| [[#OR|OR]]
| [[#OR|OR]]
|-
| [[#OUT|OUT]]
| [[#OUT|OUT]]
|-
| [[#OUTSB|OUTSB]]
| [[#OUTSB|OUTM]]
|-
| [[#OUTSW|OUTSW]]
| [[#OUTSW|OUTM]]
|-
| [[#POP|POP]]
| [[#POP|POP]]
|-
| [[#POPA|POPA]]
| [[#POPA|POP]]
|-
| [[#POPF|POPF]]
| [[#POPF|POP]]
|-
| [[#PUSH|PUSH]]
| [[#PUSH|PUSH]]
|-
| [[#PUSHA|PUSHA]]
| [[#PUSHA|PUSH]]
|-
| [[#PUSHF|PUSHF]]
| [[#PUSHF|PUSH]]
|-
| [[#RCL|RCL]]
| [[#RCL|ROLC]]
|-
| [[#RCR|RCR]]
| [[#RCR|RORC]]
|-
| [[#REP|REP/REPE/REPZ]]
| [[#REP|REP/REPE/REPZ]]
|-
| [[#REPNE|REPNE/REPNZ]]
| [[#REPNE|REPNE/REPNZ]]
|-
| [[#RET|RET]]
| [[#RET|RET]]
|-
| [[#RETF|RETF]]
| [[#RETF|RET]]
|-
| [[#ROL|ROL]]
| [[#ROL|ROL]]
|-
| [[#ROR|ROR]]
| [[#ROR|ROR]]
|-
| [[#SAHF|SAHF]]
| [[#SAHF|MOV]]
|-
| [[#SAR|SAR]]
| [[#SAR|SHRA]]
|-
| [[#SBB|SBB]]
| [[#SBB|SUBC]]
|-
| [[#SCASB|SCASB]]
| [[#SCASB|CMPMB]]
|-
| [[#SCASW|SCASW]]
| [[#SCASW|CMPMW]]
|-
| [[#SHL|SHL]]
| [[#SHL|SHL]]
|-
| [[#SHR|SHR]]
| [[#SHR|SHR]]
|-
| [[#SS|SS]]
| [[#SS|SS]]
|-
| [[#STC|STC]]
| [[#STC|SET1 CY]]
|-
| [[#STD|STD]]
| [[#STD|SET1 DIR]]
|-
| [[#STI|STI]]
| [[#STI|EI]]
|-
| [[#STOSB|STOSB]]
| [[#STOSB|STMB]]
|-
| [[#STOSW|STOSW]]
| [[#STOSW|STMW]]
|-
| [[#SUB|SUB]]
| [[#SUB|SUB]]
|-
| [[#TEST|TEST]]
| [[#TEST|TEST]]
|-
| [[#WAIT|WAIT]]
| [[#WAIT|POLL]]
|-
| [[#XCHG|XCHG]]
| [[#XCHG|XCH]]
|-
| [[#XLAT|XLAT]]
| [[#XLAT|TRANS]]
|-
| [[#XOR|XOR]]
| [[#XOR|XOR]]
|}
== Official instructions by type ==
{| class="wikitable sortable" style="text-align: center"
!Type
!colspan=16 class="unsortable" | Instructions
|-
| style="text-align:left;" | Memory
| style="" | [[#MOV|MOV]]
| style="" | [[#XCHG|XCHG]]
| style="" | [[#XLAT|XLAT]]
| style="" | [[#LEA|LEA]]
| style="border-right:none;" | [[#LDS|LDS]]
| style="border-left:none;" | [[#LES|LES]]
| style="border-right:none;" | [[#IN|IN]]
| style="border-left:none;" | [[#OUT|OUT]]
| colspan="8" |
|-
| style="text-align:left;" | Ports
| style="border-right:none;" | [[#IN|IN]]
| style="border-left:none;" | [[#OUT|OUT]]
| style="border-right:none;" | [[#INSB|INSB]]
| style="border-left:none;" | [[#OUTSB|OUTSB]]
| style="border-right:none;" | [[#INSW|INSW]]
| style="border-left:none;" | [[#OUTSW|OUTSW]]
| colspan="10" |
|-
| style="text-align:left;" | Arithmetic
| style="border-right:none;" | [[#ADD|ADD]]
| style="border-left:none;" | [[#SUB|SUB]]
| style="border-right:none;" | [[#ADC|ADC]]
| style="border-left:none;" | [[#SBB|SBB]]
| style="border-right:none;" | [[#INC|INC]]
| style="border-left:none;" | [[#DEC|DEC]]
| style="border-right:none;" | [[#MUL|MUL]]
| style="border-left:none;" | [[#DIV|DIV]]
| style="border-right:none;" | [[#IMUL|IMUL]]
| style="border-left:none;" | [[#IDIV|IDIV]]
| style="" | [[#CMP|CMP]]
| style="" | [[#NEG|NEG]]
| colspan="4" |
|-
| style="text-align:left;" | Numeric
| style="" | [[#CBW|CBW]]
| style="" | [[#CWD|CWD]]
| style="" | [[#AAA|AAA]]
| style="" | [[#AAS|AAS]]
| style="" | [[#AAM|AAM]]
| style="" | [[#AAD|AAD]]
| style="" | [[#DAA|DAA]]
| style="" | [[#DAS|DAS]]
| colspan="8" |
|-
| style="text-align:left;" | Shift
| style="border-right:none;" | [[#ROL|ROL]]
| style="border-left:none;" | [[#ROR|ROR]]
| style="border-right:none;" | [[#RCL|RCL]]
| style="border-left:none;" | [[#RCR|RCR]]
| style="border-right:none;" | [[#SHL|SHL]]
| style="border-left:none;" | [[#SHR|SHR]]
| style="" | [[#SAR|SAR]]
| colspan="9" |
|-
| style="text-align:left;" | Bitwise
| style="" | [[#AND|AND]]
| style="" | [[#OR|OR]]
| style="" | [[#XOR|XOR]]
| style="" | [[#NOT|NOT]]
| style="" | [[#TEST|TEST]]
| colspan="11" |
|-
| style="text-align:left;" | Branch
| style="border-right:none;" | [[#JC|JC]]
| style="border-left:none;" | [[#JNC|JNC]]
| style="border-right:none;" | [[#JZ|JZ]]
| style="border-left:none;" | [[#JNZ|JNZ]]
| style="border-right:none;" | [[#JBE|JBE]]
| style="border-left:none;" | [[#JA|JA]]
| style="border-right:none;" | [[#JO|JO]]
| style="border-left:none;" | [[#JNO|JNO]]
| style="border-right:none;" | [[#JP|JP]]
| style="border-left:none;" | [[#JNP|JNP]]
| style="border-right:none;" | [[#JS|JS]]
| style="border-left:none;" | [[#JNS|JNS]]
| style="border-right:none;" | [[#JL|JL]]
| style="border-left:none;" | [[#JGE|JGE]]
| style="border-right:none;" | [[#JLE|JLE]]
| style="border-left:none;" | [[#JG|JG]]
|-
| style="text-align:left;" | Jump
| style="" | [[#JMP|JMP]]
| style="border-right:none;" | [[#CALL|CALL]]
| style="border-left:none;border-right:none;" | [[#RET|RET]]
| style="border-left:none;" | [[#RETF|RETF]]
| colspan="12" |
|-
| style="text-align:left;" | Loop
| style="" | [[#LOOP|LOOP]]
| style="" | [[#LOOPE|LOOPE]]
| style="" | [[#LOOPNE|LOOPNE]]
| colspan="13" |
|-
| style="text-align:left;" | Interrupt
| style="border-right:none;" | [[#INT|INT]]
| style="border-left:none;" | [[#IRET|IRET]]
| style="" | [[#INTO|INTO]]
| style="" | [[#HLT|HLT]]
| style="" | [[#BOUND|BOUND]]
| colspan="11" |
|-
| style="text-align:left;" | Stack
| style="border-right:none;" | [[#PUSH|PUSH]]
| style="border-left:none;" | [[#POP|POP]]
| style="border-right:none;" | [[#PUSHA|PUSHA]]
| style="border-left:none;" | [[#POPA|POPA]]
| style="border-right:none;" | [[#PUSHF|PUSHF]]
| style="border-left:none;" | [[#POPF|POPF]]
| colspan="10" |
|-
| style="text-align:left;" | Flags
| style="border-right:none;" | [[#CLC|CLC]]
| style="border-left:none;" | [[#STC|STC]]
| style="border-right:none;" | [[#CLD|CLD]]
| style="border-left:none;" | [[#STD|STD]]
| style="border-right:none;" | [[#CLI|CLI]]
| style="border-left:none;" | [[#STI|STI]]
| style="" | [[#CMC|CMC]]
| style="border-right:none;" | [[#LAHF|LAHF]]
| style="border-left:none;" | [[#SAHF|SAHF]]
| colspan="7" |
|-
| style="text-align:left;" | Prefix
| style="" | [[#CS|CS]]
| style="" | [[#DS|DS]]
| style="" | [[#ES|ES]]
| style="" | [[#SS|SS]]
| colspan="12" |
|-
| style="text-align:left;" | String
| style="border-right:none;" | [[#REP|REP]]
| style="border-left:none;border-right:none;" | [[#REP|REPE]]
| style="border-left:none;" | [[#REPNE|REPNE]]
| style="" | [[#MOVSB|MOVSB]]
| style="" | [[#MOVSW|MOVSW]]
| style="border-right:none;" | [[#LODSB|LODSB]]
| style="border-left:none;" | [[#STOSB|STOSB]]
| style="border-right:none;" | [[#LODSW|LODSW]]
| style="border-left:none;" | [[#STOSW|STOSW]]
| style="" | [[#CMPSB|CMPSB]]
| style="" | [[#SCASB|SCASB]]
| style="" | [[#CMPSW|CMPSW]]
| style="" | [[#SCASW|SCASW]]
| colspan="3" |
|-
| style="text-align:left;" | Other
| style="" | [[#NOP|NOP]]
| style="border-right:none;" | [[#ENTER|ENTER]]
| style="border-left:none;" | [[#LEAVE|LEAVE]]
| style="" | [[#LOCK|LOCK]]
| style="" | [[#WAIT|WAIT]]
| colspan="11" |
|}
== Instruction encoding ==
=== ModR/M byte ===
The ModR/M byte is used in most addressing modes which reference a memory location. This byte consists of three bitfield values:
* <tt>oo</tt> - M'''o'''de;
* <tt>rrr</tt> - Two possible functions:
** '''R'''egister (for addressing modes which require both a register and a register/memory operand),
** Opcode extension (for some opcodes' addressing modes which do not have such a requirement);
* <tt>mmm</tt> - Register/'''M'''emory.
The ''Mode'' and ''Register/Memory'' bitfields can refer to a memory location or to a register, as shown in the table below.
Some instructions define a second argument using the ''Register'' field. It is always interpreted as if ''Mode'' was equal to <tt>11</tt> and, as such, can refer to a register only.
{| class="wikitable" style="text-align: center"
! R/M \ Mode
! <tt>00</tt>
! <tt>01</tt>
! <tt>10</tt>
! <tt>11</tt> ''(byte)''
! <tt>11</tt> ''(word)''
|-
| <tt>000</tt>
| DS:[BX + SI]
| DS:[BX + SI + disp8]
| DS:[BX + SI + disp16]
| AL
| AX
|-
| <tt>001</tt>
| DS:[BX + DI]
| DS:[BX + DI + disp8]
| DS:[BX + DI + disp16]
| CL
| CX
|-
| <tt>010</tt>
| SS:[BP + SI]
| SS:[BP + SI + disp8]
| SS:[BP + SI + disp16]
| DL
| DX
|-
| <tt>011</tt>
| SS:[BP + DI]
| SS:[BP + DI + disp8]
| SS:[BP + DI + disp16]
| BL
| BX
|-
| <tt>100</tt>
| DS:[SI]
| DS:[SI + disp8]
| DS:[SI + disp16]
| AH
| SP
|-
| <tt>101</tt>
| DS:[DI]
| DS:[DI + disp8]
| DS:[DI + disp16]
| CH
| BP
|-
| <tt>110</tt>
| ''DS:[disp16]''
| SS:[BP + disp8]
| SS:[BP + disp16]
| DH
| SI
|-
| <tt>111</tt>
| DS:[BX]
| DS:[BX + disp8]
| DS:[BX + disp16]
| BH
| DI
|}
Displacements are either 8-bit (disp8) or 16-bit (disp16) signed values and they always immediately follow the ModR/M byte. Note that (<tt>oo</tt> = <tt>00</tt>, <tt>mmm</tt> = <tt>110</tt>) is a special case, in which the ''disp16'' value is used directly as a near pointer.
The instruction encoding lists below refer to this byte as <tt>oorrrmmm</tt> (binary), <tt>/r</tt> (hexadecimal) or <tt>/0</tt> (hexademical, <tt>rrr</tt> used as function <tt>0</tt>).
== Official instructions ==
{{Anchor|AAA}}
=== AAA ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| AAA || <tt>37</tt> || <tt>00110111</tt> || 1 || 9
|}
----
{{Anchor|AAD}}
=== AAD ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| AAD imm8 || <tt>B5 ii</tt> || <tt>11010100 iiiiiiii</tt> || 2 || 6
|}
----
{{Anchor|AAM}}
=== AAM ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| AAM imm8 || <tt>B4 ii</tt> || <tt>11010100 iiiiiiii</tt> || 2 || 17
|}
----
{{Anchor|AAS}}
=== AAS ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| AAS || <tt>3F</tt> || <tt>00111111</tt> || 1 || 9
|}
----
{{Anchor|ADC}}
=== ADC ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| ADC AL, imm || <tt>14 ii</tt> || <tt>00010100 iiiiiiii</tt> || 2 || 1
|-
| ADC AX, imm || <tt>15 ii ii</tt> || <tt>00010101 iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| ADC mem8, imm8 || <tt>80 /2 ii</tt> || <tt>10000000 oo010mmm iiiiiiii</tt> || 3+ || 3
|-
| ADC mem16, imm16 || <tt>81 /2 ii ii</tt> || <tt>10000001 oo010mmm iiiiiiii iiiiiiii</tt> || 4+ || 3
|-
| ADC mem16, simm8 || <tt>83 /2 ii</tt> || <tt>10000011 oo010mmm iiiiiiii</tt> || 3+ || 3
|-
| ADC mem8, reg8 || <tt>10 /r</tt> || <tt>00010000 oorrrmmm</tt> || 2+ || 3
|-
| ADC mem16, reg16 || <tt>11 /r</tt> || <tt>00010001 oorrrmmm</tt> || 2+ || 3
|-
| ADC reg8, imm8 || <tt>80 /2 ii</tt> || <tt>10000000 11010mmm iiiiiiii</tt> || 3 || 1
|-
| ADC reg16, imm16 || <tt>81 /2 ii ii</tt> || <tt>10000001 11010mmm iiiiiiii iiiiiiii</tt> || 4 || 1
|-
| ADC reg16, simm8 || <tt>83 /2 ii</tt> || <tt>10000011 11010mmm iiiiiiii</tt> || 3 || 1
|-
| ADC reg8, mem8 || <tt>12 /r</tt> || <tt>00010010 oorrrmmm</tt> || 2+ || 2
|-
| ADC reg16, mem16 || <tt>13 /r</tt> || <tt>00010011 oorrrmmm</tt> || 2+ || 2
|-
| ADC reg8, reg8 || <tt>10 /r</tt> || <tt>000100.0 11rrrmmm</tt> || 2 || 1
|-
| ADC reg16, reg16 || <tt>11 /r</tt> || <tt>000100.1 11rrrmmm</tt> || 2 || 1
|}
----
{{Anchor|ADD}}
=== ADD ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| ADD AL, imm || <tt>04 ii</tt> || <tt>00000100 iiiiiiii</tt> || 2 || 1
|-
| ADD AX, imm || <tt>05 ii ii</tt> || <tt>00000101 iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| ADD mem8, imm8 || <tt>80 /0 ii</tt> || <tt>10000000 oo000mmm iiiiiiii</tt> || 3+ || 3
|-
| ADD mem16, imm16 || <tt>81 /0 ii ii</tt> || <tt>10000001 oo000mmm iiiiiiii iiiiiiii</tt> || 4+ || 3
|-
| ADD mem16, simm8 || <tt>83 /0 ii</tt> || <tt>10000011 oo000mmm iiiiiiii</tt> || 3+ || 3
|-
| ADD mem8, reg8 || <tt>00 /r</tt> || <tt>00000000 oorrrmmm</tt> || 2+ || 3
|-
| ADD mem16, reg16 || <tt>01 /r</tt> || <tt>00000001 oorrrmmm</tt> || 2+ || 3
|-
| ADD reg8, imm8 || <tt>80 /0 ii</tt> || <tt>10000000 11000mmm iiiiiiii</tt> || 3 || 1
|-
| ADD reg16, imm16 || <tt>81 /0 ii ii</tt> || <tt>10000001 11000mmm iiiiiiii iiiiiiii</tt> || 4 || 1
|-
| ADD reg16, simm8 || <tt>83 /0 ii</tt> || <tt>10000011 11000mmm iiiiiiii</tt> || 3 || 1
|-
| ADD reg8, mem8 || <tt>02 /r</tt> || <tt>00000010 oorrrmmm</tt> || 2+ || 2
|-
| ADD reg16, mem16 || <tt>03 /r</tt> || <tt>00000011 oorrrmmm</tt> || 2+ || 2
|-
| ADD reg8, reg8 || <tt>00 /r</tt> || <tt>000000.0 11rrrmmm</tt> || 2 || 1
|-
| ADD reg16, reg16 || <tt>01 /r</tt> || <tt>000000.1 11rrrmmm</tt> || 2 || 1
|}
----
{{Anchor|AND}}
=== AND ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| AND AL, imm || <tt>24 ii</tt> || <tt>00100100 iiiiiiii</tt> || 2 || 1
|-
| AND AX, imm || <tt>25 ii ii</tt> || <tt>00100101 iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| AND mem8, imm8 || <tt>80 /4 ii</tt> || <tt>10000000 oo100mmm iiiiiiii</tt> || 3+ || 3
|-
| AND mem16, imm16 || <tt>81 /4 ii ii</tt> || <tt>10000001 oo100mmm iiiiiiii iiiiiiii</tt> || 4+ || 3
|-
| AND mem16, simm8 || <tt>83 /4 ii</tt> || <tt>10000011 oo100mmm iiiiiiii</tt> || 3+ || 3
|-
| AND mem8, reg8 || <tt>20 /r</tt> || <tt>00100000 oorrrmmm</tt> || 2+ || 3
|-
| AND mem16, reg16 || <tt>21 /r</tt> || <tt>00100001 oorrrmmm</tt> || 2+ || 3
|-
| AND reg8, imm8 || <tt>80 /4 ii</tt> || <tt>10000000 11100mmm iiiiiiii</tt> || 3 || 1
|-
| AND reg16, imm16 || <tt>81 /4 ii ii</tt> || <tt>10000001 11100mmm iiiiiiii iiiiiiii</tt> || 4 || 1
|-
| AND reg16, simm8 || <tt>83 /4 ii</tt> || <tt>10000011 11100mmm iiiiiiii</tt> || 3 || 1
|-
| AND reg8, mem8 || <tt>22 /r</tt> || <tt>00100010 oorrrmmm</tt> || 2+ || 2
|-
| AND reg16, mem16 || <tt>23 /r</tt> || <tt>00100011 oorrrmmm</tt> || 2+ || 2
|-
| AND reg8, reg8 || <tt>20 /r</tt> || <tt>001000.0 11rrrmmm</tt> || 2 || 1
|-
| AND reg16, reg16 || <tt>21 /r</tt> || <tt>001000.1 11rrrmmm</tt> || 2 || 1
|}
----
{{Anchor|BOUND}}
=== BOUND ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| BOUND reg16, mem16:16 || <tt>62 /r</tt> || <tt>01100010 oorrrmmm</tt> || 2+ || 13 (20 if condition met)
|}
----
{{Anchor|CALL}}
=== CALL ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| CALL ptr16:16 || <tt>CA oo oo ss ss</tt> || <tt>10011010 oooooooo oooooooo ssssssss ssssssss</tt> || 5 || 10
|-
| CALL mem16 || <tt>FF /2</tt> || <tt>11111111 oo010mmm</tt> || 2+ || 6
|-
| CALL mem16:16 || <tt>FF /3</tt> || <tt>11111111 oo011mmm</tt> || 2+ || 12
|-
| CALL reg16 || <tt>FF /2</tt> || <tt>11111111 11010mmm</tt> || 2 || 5
|-
| CALL rel16 || <tt>E8 ii ii</tt> || <tt>11101000 iiiiiiii iiiiiiii</tt> || 3 || 5
|}
----
{{Anchor|CBW}}
=== CBW ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| CBW || <tt>98</tt> || <tt>10011000</tt> || 1 || 1
|}
----
{{Anchor|CLC}}
=== CLC ===
{| class="wikitable"
! Flag !! New value
|-
| [[NEC_V30MZ_flags#CF|CF - Carry]] || 0
|}
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| CLC || <tt>F8</tt> || <tt>11111000</tt> || 1 || 4
|}
----
{{Anchor|CLD}}
=== CLD ===
{| class="wikitable"
! Flag !! New value
|-
| [[NEC_V30MZ_flags#DF|DF - Direction]] || 0
|}
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| CLD || <tt>FC</tt> || <tt>11111100</tt> || 1 || 4
|}
----
{{Anchor|CLI}}
=== CLI ===
{| class="wikitable"
! Flag !! New value
|-
| [[NEC_V30MZ_flags#IF|IF - Interrupt]] || 0
|}
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| CLI || <tt>FA</tt> || <tt>11111010</tt> || 1 || 4
|}
----
{{Anchor|CMC}}
=== CMC ===
{| class="wikitable"
! Flag !! New value
|-
| [[NEC_V30MZ_flags#CF|CF - Carry]] || !CF
|}
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| CMC || <tt>F5</tt> || <tt>11110101</tt> || 1 || 4
|}
----
{{Anchor|CMP}}
=== CMP ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| CMP AL, imm || <tt>3C ii</tt> || <tt>00111100 iiiiiiii</tt> || 2 || 1
|-
| CMP AX, imm || <tt>3D ii ii</tt> || <tt>00111101 iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| CMP mem8, imm8 || <tt>80 /7 ii</tt> || <tt>10000000 oo111mmm iiiiiiii</tt> || 3+ || 2
|-
| CMP mem16, imm16 || <tt>81 /7 ii ii</tt> || <tt>10000001 oo111mmm iiiiiiii iiiiiiii</tt> || 4+ || 2
|-
| CMP mem16, simm8 || <tt>83 /7 ii</tt> || <tt>10000011 oo111mmm iiiiiiii</tt> || 3+ || 2
|-
| CMP mem8, reg8 || <tt>38 /r</tt> || <tt>00111000 oorrrmmm</tt> || 2+ || 2
|-
| CMP mem16, reg16 || <tt>39 /r</tt> || <tt>00111001 oorrrmmm</tt> || 2+ || 2
|-
| CMP reg8, imm8 || <tt>80 /7 ii</tt> || <tt>10000000 11111mmm iiiiiiii</tt> || 3 || 1
|-
| CMP reg16, imm16 || <tt>81 /7 ii ii</tt> || <tt>10000001 11111mmm iiiiiiii iiiiiiii</tt> || 4 || 1
|-
| CMP reg16, simm8 || <tt>83 /7 ii</tt> || <tt>10000011 11111mmm iiiiiiii</tt> || 3 || 1
|-
| CMP reg8, mem8 || <tt>3A /r</tt> || <tt>00111010 oorrrmmm</tt> || 2+ || 2
|-
| CMP reg16, mem16 || <tt>3B /r</tt> || <tt>00111011 oorrrmmm</tt> || 2+ || 2
|-
| CMP reg8, reg8 || <tt>38 /r</tt> || <tt>001110.0 11rrrmmm</tt> || 2 || 1
|-
| CMP reg16, reg16 || <tt>39 /r</tt> || <tt>001110.1 11rrrmmm</tt> || 2 || 1
|}
----
{{Anchor|CMPSB}}
{{Anchor|CMPSW}}
=== CMPSB/CMPSW ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| CMPSB || <tt>A6</tt> || <tt>10100110</tt> || 1 || 6
|-
| CMPSW || <tt>A7</tt> || <tt>10100111</tt> || 1 || 6
|}
----
{{Anchor|CS}}
=== CS ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| CS || <tt>2E</tt> || <tt>00101110</tt> || 1 || 1
|}
----
{{Anchor|CWD}}
=== CWD ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| CWD || <tt>99</tt> || <tt>10011001</tt> || 1 || 1
|}
----
{{Anchor|DAA}}
=== DAA ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| DAA || <tt>27</tt> || <tt>00100111</tt> || 1 || 10
|}
----
{{Anchor|DAS}}
=== DAS ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| DAS || <tt>2F</tt> || <tt>00101111</tt> || 1 || 10
|}
----
{{Anchor|DEC}}
=== DEC ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| DEC mem8 || <tt>FE /1</tt> || <tt>11111110 oo001mmm</tt> || 2+ || 3
|-
| DEC mem16 || <tt>FF /1</tt> || <tt>11111111 oo001mmm</tt> || 2+ || 3
|-
| DEC reg8 || <tt>FE /1</tt> || <tt>11111110 11001mmm</tt> || 2+ || 1
|-
| DEC reg16 || <tt>4x</tt> || <tt>01001rrr</tt> || 1 || 1
|}
----
{{Anchor|DIV}}
=== DIV ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| DIV mem8 || <tt>F6 /6</tt> || <tt>11110110 oo110mmm</tt> || 2+ || 16
|-
| DIV mem16 || <tt>F7 /6</tt> || <tt>11111111 oo110mmm</tt> || 2+ || 24
|-
| DIV reg8 || <tt>F6 /6</tt> || <tt>11111110 11110mmm</tt> || 2 || 15
|-
| DIV reg16 || <tt>F7 /6</tt> || <tt>11111111 11110mmm</tt> || 2 || 23
|}
----
{{Anchor|DS}}
=== DS ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| DS || <tt>3E</tt> || <tt>00111110</tt> || 1 || 1
|}
----
{{Anchor|ENTER}}
=== ENTER ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| ENTER imm16, imm8 || <tt>C8 ii ii jj</tt> || <tt>11001000 iiiiiiii iiiiiiii jjjjjjjj</tt> || 3 || 8 (imm8 = 0)<br/>14 (imm8 = 1)<br/>15 + imm8 * 4 (imm8 >= 2)
|}
----
{{Anchor|ES}}
=== ES ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| ES || <tt>26</tt> || <tt>00100110</tt> || 1 || 1
|}
----
{{Anchor|HLT}}
=== HLT ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| HLT || <tt>F4</tt> || <tt>11110100</tt> || 1 || 9
|}
----
{{Anchor|IDIV}}
=== IDIV ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| IDIV mem8 || <tt>F6 /7</tt> || <tt>11110110 oo111mmm</tt> || 2+ || 18
|-
| IDIV mem16 || <tt>F7 /7</tt> || <tt>11111111 oo111mmm</tt> || 2+ || 25
|-
| IDIV reg8 || <tt>F6 /7</tt> || <tt>11111110 11111mmm</tt> || 2 || 17
|-
| IDIV reg16 || <tt>F7 /7</tt> || <tt>11111111 11111mmm</tt> || 2 || 24
|}
----
{{Anchor|IMUL}}
=== IMUL ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| IMUL mem8 || <tt>F6 /5</tt> || <tt>11110110 oo101mmm</tt> || 2+ || 4
|-
| IMUL mem16 || <tt>F7 /5</tt> || <tt>11111111 oo101mmm</tt> || 2+ || 4
|-
| IMUL reg8 || <tt>F6 /5</tt> || <tt>11111110 11101mmm</tt> || 2 || 3
|-
| IMUL reg16 || <tt>F7 /5</tt> || <tt>11111111 11101mmm</tt> || 2 || 3
|-
| IMUL reg16, mem16, imm16 || <tt>69 /r ii ii</tt> || <tt>11111111 oorrrmmm iiiiiiii iiiiiiii</tt> || 4 || 4
|-
| IMUL reg16, mem16, simm8 || <tt>6B /r ii</tt> || <tt>11111111 oorrrmmm iiiiiiii</tt> || 3 || 4
|-
| IMUL reg16, reg16, imm16 || <tt>69 /r ii ii</tt> || <tt>11111111 11rrrmmm iiiiiiii iiiiiiii</tt> || 4 || 3
|-
| IMUL reg16, reg16, simm8 || <tt>6B /r ii</tt> || <tt>11111111 11rrrmmm iiiiiiii</tt> || 3 || 3
|}
----
{{Anchor|IN}}
=== IN ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| IN AL, DX || <tt>EC</tt> || <tt>11101100</tt> || 1 || 6
|-
| IN AX, DX || <tt>ED</tt> || <tt>11101101</tt> || 1 || 6
|-
| IN AL, imm8 || <tt>E4 ii</tt> || <tt>11100100 iiiiiiii</tt> || 2 || 6
|-
| IN AX, imm8 || <tt>E5 ii</tt> || <tt>11100101 iiiiiiii</tt> || 2 || 6
|}
----
{{Anchor|INC}}
=== INC ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| INC mem8 || <tt>FE /0</tt> || <tt>11111110 oo000mmm</tt> || 2+ || 3
|-
| INC mem16 || <tt>FF /0</tt> || <tt>11111111 oo000mmm</tt> || 2+ || 3
|-
| INC reg8 || <tt>FE /0</tt> || <tt>11111110 11000mmm</tt> || 2+ || 1
|-
| INC reg16 || <tt>4x</tt> || <tt>01000rrr</tt> || 1 || 1
|}
----
{{Anchor|INSB}}
{{Anchor|INSW}}
=== INSB/INSW ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| INSB || <tt>6C</tt> || <tt>01101100</tt> || 1 || 6
|-
| INSW || <tt>6D</tt> || <tt>01101101</tt> || 1 || 6
|}
----
{{Anchor|INT}}
=== INT ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| INT 3 || <tt>CC</tt> || <tt>11001100</tt> || 1 || 9
|-
| INT imm8 || <tt>CD ii</tt> || <tt>11001101 iiiiiiii</tt> || 2 || 10
|}
----
{{Anchor|INTO}}
=== INTO ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| INTO || <tt>CE</tt> || <tt>11001110</tt> || 1 || 6 (13 if OF = 1)
|}
----
{{Anchor|IRET}}
=== IRET ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| IRET || <tt>CF</tt> || <tt>11001111</tt> || 1 || 10
|}
----
{{Anchor|JA}}
=== JA ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JA rel8 || <tt>77 ii</tt> || <tt>01110111 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JBE}}
=== JBE ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JA rel8 || <tt>76 ii</tt> || <tt>01110110 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JC}}
=== JC/JB ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JC rel8 || <tt>72 ii</tt> || <tt>01110010 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JCXZ}}
=== JCXZ ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JCXZ rel8 || <tt>E3 ii</tt> || <tt>11100011 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JG}}
=== JG ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JG rel8 || <tt>7F ii</tt> || <tt>01111111 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JGE}}
=== JGE ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JGE rel8 || <tt>7D ii</tt> || <tt>01111101 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JL}}
=== JL ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JL rel8 || <tt>7C ii</tt> || <tt>01111100 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JLE}}
=== JLE ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JLE rel8 || <tt>7E ii</tt> || <tt>01111110 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JMP}}
=== JMP ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JMP ptr16:16 || <tt>EA oo oo ss ss</tt> || <tt>11101010 oooooooo oooooooo ssssssss ssssssss</tt> || 5 || 7
|-
| JMP mem16 || <tt>FF /4</tt> || <tt>11111111 oo100mmm</tt> || 2+ || 5
|-
| JMP mem16:16 || <tt>FF /5</tt> || <tt>11111111 oo101mmm</tt> || 2+ || 10
|-
| JMP reg16 || <tt>FF /4</tt> || <tt>11111111 11100mmm</tt> || 2 || 4
|-
| JMP rel8 || <tt>EB ii</tt> || <tt>11101011 iiiiiiii</tt> || 2 || 4
|-
| JMP rel16 || <tt>E9 ii ii</tt> || <tt>11101001 iiiiiiii iiiiiiii</tt> || 3 || 4
|}
----
{{Anchor|JNC}}
=== JNC/JAE ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JNC rel8 || <tt>73 ii</tt> || <tt>01110011 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JNO}}
=== JNO ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JNO rel8 || <tt>71 ii</tt> || <tt>01110001 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JNP}}
=== JNP ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JNP rel8 || <tt>7B ii</tt> || <tt>01111011 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JNS}}
=== JNS ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JNS rel8 || <tt>79 ii</tt> || <tt>01111001 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JNZ}}
=== JNZ/JNE ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JNZ rel8 || <tt>75 ii</tt> || <tt>01110101 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JO}}
=== JO ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JO rel8 || <tt>70 ii</tt> || <tt>01110000 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JP}}
=== JP ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JP rel8 || <tt>7A ii</tt> || <tt>01111010 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JS}}
=== JS ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JS rel8 || <tt>78 ii</tt> || <tt>01111000 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|JZ}}
=== JZ/JE ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| JZ rel8 || <tt>74 ii</tt> || <tt>01110100 iiiiiiii</tt> || 2 || 1 (4 if branch taken)
|}
----
{{Anchor|LAHF}}
=== LAHF ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| LAHF || <tt>9F</tt> || <tt>10011111</tt> || 1 || 2
|}
----
{{Anchor|LDS}}
=== LDS ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| LDS reg16, mem16 || <tt>C5 /r</tt> || <tt>11000101 oorrrmmm</tt> || 2+ || 6
|}
----
{{Anchor|LEA}}
=== LEA ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| LEA reg16, mem16 || <tt>8D /r</tt> || <tt>10001101 oorrrmmm</tt> || 2+ || 1
|}
----
{{Anchor|LEAVE}}
=== LEAVE ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| LEAVE || <tt>C9</tt> || <tt>11001001</tt> || 1 || 2
|}
----
{{Anchor|LES}}
=== LES ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| LES reg16, mem16 || <tt>C4 /r</tt> || <tt>11000100 oorrrmmm</tt> || 2+ || 6
|}
----
{{Anchor|LOCK}}
=== LOCK ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| LOCK || <tt>F0</tt> || <tt>11110000</tt> || 1 || 1
|}
----
{{Anchor|LODSB}}
{{Anchor|LODSW}}
=== LODSB/LODSW ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| LODSB || <tt>AC</tt> || <tt>10101100</tt> || 1 || 3
|-
| LODSW || <tt>AD</tt> || <tt>10101101</tt> || 1 || 3
|}
----
{{Anchor|LOOP}}
=== LOOP ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| LOOP rel8 || <tt>E2 ii</tt> || <tt>11100010 iiiiiiii</tt> || 2 || 2 (5 if branch taken)
|}
----
{{Anchor|LOOPE}}
=== LOOPE ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| LOOPE rel8 || <tt>E1 ii</tt> || <tt>11100001 iiiiiiii</tt> || 2 || 3 (6 if branch taken)
|}
----
{{Anchor|LOOPNE}}
=== LOOPNE ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| LOOPNE rel8 || <tt>E0 ii</tt> || <tt>11100000 iiiiiiii</tt> || 2 || 3 (6 if branch taken)
|}
----
{{Anchor|MOV}}
=== MOV ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| MOV AL, ptr16 || <tt>A0 ii ii</tt> || <tt>10100000 iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| MOV AX, ptr16 || <tt>A1 ii ii</tt> || <tt>10100001 iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| MOV mem8, imm8 || <tt>C6 /0 ii</tt> || <tt>11000110 oo000mmm iiiiiiii</tt> || 3+ || 1
|-
| MOV mem16, imm16 || <tt>C7 /0 ii ii</tt> || <tt>11000111 oo000mmm iiiiiiii iiiiiiii</tt> || 4+ || 1
|-
| MOV mem8, reg8 || <tt>88 /r</tt> || <tt>10001000 oorrrmmm</tt> || 2+ || 1
|-
| MOV mem16, reg16 || <tt>89 /r</tt> || <tt>10001001 oorrrmmm</tt> || 2+ || 1
|-
| MOV mem16, sreg16 || <tt>8C /r</tt> || <tt>10001100 oo0rrmmm</tt> || 2+ || 3
|-
| MOV ptr16, AL || <tt>A2 ii ii</tt> || <tt>10100010 iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| MOV ptr16, AX || <tt>A3 ii ii</tt> || <tt>10100011 iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| MOV reg8, imm8 || <tt>Bx ii</tt> || <tt>10110rrr iiiiiiii</tt> || 2 || 1
|-
| MOV reg8, imm8 || <tt>C6 /0 ii</tt> || <tt>11000110 11000mmm iiiiiiii</tt> || 3 || 1
|-
| MOV reg16, imm16 || <tt>Bx ii</tt> || <tt>10111rrr iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| MOV reg16, imm16 || <tt>C7 /0 ii ii</tt> || <tt>11000111 11000mmm iiiiiiii iiiiiiii</tt> || 4 || 1
|-
| MOV reg8, mem8 || <tt>8A /r</tt> || <tt>10001010 oorrrmmm</tt> || 2+ || 1
|-
| MOV reg16, mem16 || <tt>8B /r</tt> || <tt>10001011 oorrrmmm</tt> || 2+ || 1
|-
| MOV reg8, reg8 || <tt>88 /r</tt> || <tt>100010.0 11rrrmmm</tt> || 2 || 1
|-
| MOV reg16, reg16 || <tt>89 /r</tt> || <tt>100010.1 11rrrmmm</tt> || 2 || 1
|-
| MOV reg16, sreg16 || <tt>8C /r</tt> || <tt>10001100 110rrmmm</tt> || 2 || 1
|-
| MOV sreg16, mem16 || <tt>8E /r</tt> || <tt>10001110 oo0rrmmm</tt> || 2 || 3
|-
| MOV sreg16, reg16 || <tt>8E /r</tt> || <tt>10001110 110rrmmm</tt> || 2+ || 2
|}
----
{{Anchor|MOVSB}}
{{Anchor|MOVSW}}
=== MOVSB/MOVSW ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| MOVSB || <tt>A4</tt> || <tt>10100100</tt> || 1 || 5
|-
| MOVSW || <tt>A5</tt> || <tt>10100101</tt> || 1 || 5
|}
----
{{Anchor|MUL}}
=== MUL ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| MUL mem8 || <tt>F6 /4</tt> || <tt>11110110 oo100mmm</tt> || 2+ || 4
|-
| MUL mem16 || <tt>F7 /4</tt> || <tt>11111111 oo100mmm</tt> || 2+ || 4
|-
| MUL reg8 || <tt>F6 /4</tt> || <tt>11111110 11100mmm</tt> || 2 || 3
|-
| MUL reg16 || <tt>F7 /4</tt> || <tt>11111111 11100mmm</tt> || 2 || 3
|}
----
{{Anchor|NEG}}
=== NEG ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| NEG mem8 || <tt>F6 /3</tt> || <tt>11110110 oo011mmm</tt> || 2+ || 3
|-
| NEG mem16 || <tt>F7 /3</tt> || <tt>11111111 oo011mmm</tt> || 2+ || 3
|-
| NEG reg8 || <tt>F6 /3</tt> || <tt>11111110 11011mmm</tt> || 2 || 1
|-
| NEG reg16 || <tt>F7 /3</tt> || <tt>11111111 11011mmm</tt> || 2 || 1
|}
----
{{Anchor|NOP}}
=== NOP ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| NOP || <tt>90</tt> || <tt>10010000</tt> || 1 || 1
|}
----
{{Anchor|NOT}}
=== NOT ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| NOT mem8 || <tt>F6 /2</tt> || <tt>11110110 oo010mmm</tt> || 2+ || 3
|-
| NOT mem16 || <tt>F7 /2</tt> || <tt>11111111 oo010mmm</tt> || 2+ || 3
|-
| NOT reg8 || <tt>F6 /2</tt> || <tt>11111110 11010mmm</tt> || 2 || 1
|-
| NOT reg16 || <tt>F7 /2</tt> || <tt>11111111 11010mmm</tt> || 2 || 1
|}
----
{{Anchor|OR}}
=== OR ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| OR AL, imm || <tt>0C ii</tt> || <tt>00001100 iiiiiiii</tt> || 2 || 1
|-
| OR AX, imm || <tt>0D ii ii</tt> || <tt>00001101 iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| OR mem8, imm8 || <tt>80 /6 ii</tt> || <tt>10000000 oo001mmm iiiiiiii</tt> || 3+ || 3
|-
| OR mem16, imm16 || <tt>81 /6 ii ii</tt> || <tt>10000001 oo001mmm iiiiiiii iiiiiiii</tt> || 4+ || 3
|-
| OR mem16, simm8 || <tt>83 /6 ii</tt> || <tt>10000011 oo001mmm iiiiiiii</tt> || 3+ || 3
|-
| OR mem8, reg8 || <tt>08 /r</tt> || <tt>00001000 oorrrmmm</tt> || 2+ || 3
|-
| OR mem16, reg16 || <tt>09 /r</tt> || <tt>00001001 oorrrmmm</tt> || 2+ || 3
|-
| OR reg8, imm8 || <tt>80 /6 ii</tt> || <tt>10000000 11001mmm iiiiiiii</tt> || 3 || 1
|-
| OR reg16, imm16 || <tt>81 /6 ii ii</tt> || <tt>10000001 11001mmm iiiiiiii iiiiiiii</tt> || 4 || 1
|-
| OR reg16, simm8 || <tt>83 /6 ii</tt> || <tt>10000011 11001mmm iiiiiiii</tt> || 3 || 1
|-
| OR reg8, mem8 || <tt>0A /r</tt> || <tt>00001010 oorrrmmm</tt> || 2+ || 2
|-
| OR reg16, mem16 || <tt>0B /r</tt> || <tt>00001011 oorrrmmm</tt> || 2+ || 2
|-
| OR reg8, reg8 || <tt>08 /r</tt> || <tt>000010.0 11rrrmmm</tt> || 2 || 1
|-
| OR reg16, reg16 || <tt>09 /r</tt> || <tt>000010.1 11rrrmmm</tt> || 2 || 1
|}
----
{{Anchor|OUT}}
=== OUT ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| OUT DX, AL || <tt>EE</tt> || <tt>11101110</tt> || 1 || 6
|-
| OUT DX, AX || <tt>EF</tt> || <tt>11101111</tt> || 1 || 6
|-
| OUT imm8, AL || <tt>E6 ii</tt> || <tt>11100110 iiiiiiii</tt> || 2 || 6
|-
| OUT imm8, AX || <tt>E7 ii</tt> || <tt>11100111 iiiiiiii</tt> || 2 || 6
|}
----
{{Anchor|OUTSB}}
{{Anchor|OUTSW}}
=== OUTSB/OUTSW ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| OUTSB || <tt>6E</tt> || <tt>01101110</tt> || 1 || 6
|-
| OUTSW || <tt>6F</tt> || <tt>01101111</tt> || 1 || 6
|}
----
{{Anchor|POP}}
=== POP ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| POP mem16 || <tt>8F /0</tt> || <tt>10001111 oo000mmm</tt> || 2+ || 3
|-
| POP reg16 || <tt>5x</tt> || <tt>01011xxx</tt> || 1 || 1
|-
| POP reg16 || <tt>8F /0</tt> || <tt>10001111 11000mmm</tt> || 2 || 1
|-
| POP sreg16 || <tt>xx</tt> || <tt>000xx111</tt> || 1 || 3
|}
----
{{Anchor|POPA}}
=== POPA ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| POPA || <tt>61</tt> || <tt>01100001</tt> || 1 || 8
|}
----
{{Anchor|POPF}}
=== POPF ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| POPF || <tt>9D</tt> || <tt>10011101</tt> || 1 || 3
|}
----
{{Anchor|PUSH}}
=== PUSH ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| PUSH simm8 || <tt>6A ii</tt> || <tt>01101010 iiiiiiii</tt> || 2 || 1
|-
| PUSH imm16 || <tt>68 ii ii</tt> || <tt>01101000 iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| PUSH mem16 || <tt>FF /6</tt> || <tt>11111111 oo110mmm</tt> || 2+ || 2
|-
| PUSH reg16 || <tt>5x</tt> || <tt>01010xxx</tt> || 1 || 1
|-
| PUSH reg16 || <tt>FF /6</tt> || <tt>11111111 11110mmm</tt> || 2 || 1
|-
| PUSH sreg16 || <tt>xx</tt> || <tt>000xx110</tt> || 1 || 2
|}
----
{{Anchor|PUSHA}}
=== PUSHA ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| PUSHA || <tt>60</tt> || <tt>01100000</tt> || 1 || 9
|}
----
{{Anchor|PUSHF}}
=== PUSHF ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| PUSHF || <tt>9C</tt> || <tt>10011100</tt> || 1 || 2
|}
----
{{Anchor|RCL}}
=== RCL ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| RCL mem8, 1 || <tt>D0 /2</tt> || <tt>11010000 oo010rm</tt> || 2+ || 3
|-
| RCL mem8, CL || <tt>D2 /2</tt> || <tt>11010010 oo010rm</tt> || 2+ || 5
|-
| RCL mem8, imm8 || <tt>C0 /2 ii</tt> || <tt>11000000 oo010mmm iiiiiiii</tt> || 3+ || 5
|-
| RCL mem16, 1 || <tt>D1 /2</tt> || <tt>11010001 oo010rm</tt> || 2+ || 3
|-
| RCL mem16, CL || <tt>D3 /2</tt> || <tt>11010011 oo010rm</tt> || 2+ || 5
|-
| RCL mem16, imm8 || <tt>C1 /2 ii</tt> || <tt>11000001 oo010mmm iiiiiiii</tt> || 3+ || 5
|-
| RCL reg8, 1 || <tt>D0 /2</tt> || <tt>11010000 11010rm</tt> || 2 || 1
|-
| RCL reg8, CL || <tt>D2 /2</tt> || <tt>11010010 11010rm</tt> || 2 || 3
|-
| RCL reg8, imm8 || <tt>C0 /2 ii</tt> || <tt>11000000 11010mmm iiiiiiii</tt> || 3 || 3
|-
| RCL reg16, 1 || <tt>D1 /2</tt> || <tt>11010001 11010rm</tt> || 2 || 1
|-
| RCL reg16, CL || <tt>D3 /2</tt> || <tt>11010011 11010rm</tt> || 2 || 3
|-
| RCL reg16, imm8 || <tt>C1 /2 ii</tt> || <tt>11000001 11010mmm iiiiiiii</tt> || 3 || 3
|}
----
{{Anchor|RCR}}
=== RCR ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| RCR mem8, 1 || <tt>D0 /3</tt> || <tt>11010000 oo011rm</tt> || 2+ || 3
|-
| RCR mem8, CL || <tt>D2 /3</tt> || <tt>11010010 oo011rm</tt> || 2+ || 5
|-
| RCR mem8, imm8 || <tt>C0 /3 ii</tt> || <tt>11000000 oo011mmm iiiiiiii</tt> || 3+ || 5
|-
| RCR mem16, 1 || <tt>D1 /3</tt> || <tt>11010001 oo011rm</tt> || 2+ || 3
|-
| RCR mem16, CL || <tt>D3 /3</tt> || <tt>11010011 oo011rm</tt> || 2+ || 5
|-
| RCR mem16, imm8 || <tt>C1 /3 ii</tt> || <tt>11000001 oo011mmm iiiiiiii</tt> || 3+ || 5
|-
| RCR reg8, 1 || <tt>D0 /3</tt> || <tt>11010000 11011rm</tt> || 2 || 1
|-
| RCR reg8, CL || <tt>D2 /3</tt> || <tt>11010010 11011rm</tt> || 2 || 3
|-
| RCR reg8, imm8 || <tt>C0 /3 ii</tt> || <tt>11000000 11011mmm iiiiiiii</tt> || 3 || 3
|-
| RCR reg16, 1 || <tt>D1 /3</tt> || <tt>11010001 11011rm</tt> || 2 || 1
|-
| RCR reg16, CL || <tt>D3 /3</tt> || <tt>11010011 11011rm</tt> || 2 || 3
|-
| RCR reg16, imm8 || <tt>C1 /3 ii</tt> || <tt>11000001 11011mmm iiiiiiii</tt> || 3 || 3
|}
----
{{Anchor|REP}}
=== REP/REPE/REPZ ===
----
{{Anchor|REPNE}}
=== REPNE/REPNZ ===
----
{{Anchor|RET}}
=== RET ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| RET || <tt>C3</tt> || <tt>11000011</tt> || 1 || 6
|-
| RET imm16 || <tt>C2 ii ii</tt> || <tt>11000010 iiiiiiii iiiiiiii</tt> || 1 || 6
|}
----
{{Anchor|RETF}}
=== RETF ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| RETF || <tt>CB</tt> || <tt>11001011</tt> || 1 || 8
|-
| RETF imm16 || <tt>CA ii ii</tt> || <tt>11001010 iiiiiiii iiiiiiii</tt> || 1 || 9
|}
----
{{Anchor|ROL}}
=== ROL ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| ROL mem8, 1 || <tt>D0 /0</tt> || <tt>11010000 oo000rm</tt> || 2+ || 3
|-
| ROL mem8, CL || <tt>D2 /0</tt> || <tt>11010010 oo000rm</tt> || 2+ || 5
|-
| ROL mem8, imm8 || <tt>C0 /0 ii</tt> || <tt>11000000 oo000mmm iiiiiiii</tt> || 3+ || 5
|-
| ROL mem16, 1 || <tt>D1 /0</tt> || <tt>11010001 oo000rm</tt> || 2+ || 3
|-
| ROL mem16, CL || <tt>D3 /0</tt> || <tt>11010011 oo000rm</tt> || 2+ || 5
|-
| ROL mem16, imm8 || <tt>C1 /0 ii</tt> || <tt>11000001 oo000mmm iiiiiiii</tt> || 3+ || 5
|-
| ROL reg8, 1 || <tt>D0 /0</tt> || <tt>11010000 11000rm</tt> || 2 || 1
|-
| ROL reg8, CL || <tt>D2 /0</tt> || <tt>11010010 11000rm</tt> || 2 || 3
|-
| ROL reg8, imm8 || <tt>C0 /0 ii</tt> || <tt>11000000 11000mmm iiiiiiii</tt> || 3 || 3
|-
| ROL reg16, 1 || <tt>D1 /0</tt> || <tt>11010001 11000rm</tt> || 2 || 1
|-
| ROL reg16, CL || <tt>D3 /0</tt> || <tt>11010011 11000rm</tt> || 2 || 3
|-
| ROL reg16, imm8 || <tt>C1 /0 ii</tt> || <tt>11000001 11000mmm iiiiiiii</tt> || 3 || 3
|}
----
{{Anchor|ROR}}
=== ROR ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| ROR mem8, 1 || <tt>D0 /1</tt> || <tt>11010000 oo001rm</tt> || 2+ || 3
|-
| ROR mem8, CL || <tt>D2 /1</tt> || <tt>11010010 oo001rm</tt> || 2+ || 5
|-
| ROR mem8, imm8 || <tt>C0 /1 ii</tt> || <tt>11000000 oo001mmm iiiiiiii</tt> || 3+ || 5
|-
| ROR mem16, 1 || <tt>D1 /1</tt> || <tt>11010001 oo001rm</tt> || 2+ || 3
|-
| ROR mem16, CL || <tt>D3 /1</tt> || <tt>11010011 oo001rm</tt> || 2+ || 5
|-
| ROR mem16, imm8 || <tt>C1 /1 ii</tt> || <tt>11000001 oo001mmm iiiiiiii</tt> || 3+ || 5
|-
| ROR reg8, 1 || <tt>D0 /1</tt> || <tt>11010000 11001rm</tt> || 2 || 1
|-
| ROR reg8, CL || <tt>D2 /1</tt> || <tt>11010010 11001rm</tt> || 2 || 3
|-
| ROR reg8, imm8 || <tt>C0 /1 ii</tt> || <tt>11000000 11001mmm iiiiiiii</tt> || 3 || 3
|-
| ROR reg16, 1 || <tt>D1 /1</tt> || <tt>11010001 11001rm</tt> || 2 || 1
|-
| ROR reg16, CL || <tt>D3 /1</tt> || <tt>11010011 11001rm</tt> || 2 || 3
|-
| ROR reg16, imm8 || <tt>C1 /1 ii</tt> || <tt>11000001 11001mmm iiiiiiii</tt> || 3 || 3
|}
----
{{Anchor|SAHF}}
=== SAHF ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| SAHF || <tt>9E</tt> || <tt>10011110</tt> || 1 || 4
|}
----
{{Anchor|SAR}}
=== SAR ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| SAR mem8, 1 || <tt>D0 /7</tt> || <tt>11010000 oo111rm</tt> || 2+ || 3
|-
| SAR mem8, CL || <tt>D2 /7</tt> || <tt>11010010 oo111rm</tt> || 2+ || 5
|-
| SAR mem8, imm8 || <tt>C0 /7 ii</tt> || <tt>11000000 oo111mmm iiiiiiii</tt> || 3+ || 5
|-
| SAR mem16, 1 || <tt>D1 /7</tt> || <tt>11010001 oo111rm</tt> || 2+ || 3
|-
| SAR mem16, CL || <tt>D3 /7</tt> || <tt>11010011 oo111rm</tt> || 2+ || 5
|-
| SAR mem16, imm8 || <tt>C1 /7 ii</tt> || <tt>11000001 oo111mmm iiiiiiii</tt> || 3+ || 5
|-
| SAR reg8, 1 || <tt>D0 /7</tt> || <tt>11010000 11111rm</tt> || 2 || 1
|-
| SAR reg8, CL || <tt>D2 /7</tt> || <tt>11010010 11111rm</tt> || 2 || 3
|-
| SAR reg8, imm8 || <tt>C0 /7 ii</tt> || <tt>11000000 11111mmm iiiiiiii</tt> || 3 || 3
|-
| SAR reg16, 1 || <tt>D1 /7</tt> || <tt>11010001 11111rm</tt> || 2 || 1
|-
| SAR reg16, CL || <tt>D3 /7</tt> || <tt>11010011 11111rm</tt> || 2 || 3
|-
| SAR reg16, imm8 || <tt>C1 /7 ii</tt> || <tt>11000001 11111mmm iiiiiiii</tt> || 3 || 3
|}
----
{{Anchor|SBB}}
=== SBB ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| SBB AL, imm || <tt>1C ii</tt> || <tt>00011100 iiiiiiii</tt> || 2 || 1
|-
| SBB AX, imm || <tt>1D ii ii</tt> || <tt>00011101 iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| SBB mem8, imm8 || <tt>80 /3 ii</tt> || <tt>10000000 oo011mmm iiiiiiii</tt> || 3+ || 3
|-
| SBB mem16, imm16 || <tt>81 /3 ii ii</tt> || <tt>10000001 oo011mmm iiiiiiii iiiiiiii</tt> || 4+ || 3
|-
| SBB mem16, simm8 || <tt>83 /3 ii</tt> || <tt>10000011 oo011mmm iiiiiiii</tt> || 3+ || 3
|-
| SBB mem8, reg8 || <tt>18 /r</tt> || <tt>00011000 oorrrmmm</tt> || 2+ || 3
|-
| SBB mem16, reg16 || <tt>19 /r</tt> || <tt>00011001 oorrrmmm</tt> || 2+ || 3
|-
| SBB reg8, imm8 || <tt>80 /3 ii</tt> || <tt>10000000 11011mmm iiiiiiii</tt> || 3 || 1
|-
| SBB reg16, imm16 || <tt>81 /3 ii ii</tt> || <tt>10000001 11011mmm iiiiiiii iiiiiiii</tt> || 4 || 1
|-
| SBB reg16, simm8 || <tt>83 /3 ii</tt> || <tt>10000011 11011mmm iiiiiiii</tt> || 3 || 1
|-
| SBB reg8, mem8 || <tt>1A /r</tt> || <tt>00011010 oorrrmmm</tt> || 2+ || 2
|-
| SBB reg16, mem16 || <tt>1B /r</tt> || <tt>00011011 oorrrmmm</tt> || 2+ || 2
|-
| SBB reg8, reg8 || <tt>18 /r</tt> || <tt>000110.0 11rrrmmm</tt> || 2 || 1
|-
| SBB reg16, reg16 || <tt>19 /r</tt> || <tt>000110.1 11rrrmmm</tt> || 2 || 1
|}
----
{{Anchor|SCASB}}
{{Anchor|SCASW}}
=== SCASB/SCASW ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| SCASB || <tt>AE</tt> || <tt>10101110</tt> || 1 || 4
|-
| SCASW || <tt>AF</tt> || <tt>10101111</tt> || 1 || 4
|}
----
{{Anchor|SHL}}
=== SHL ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| SHL mem8, 1 || <tt>D0 /4</tt> || <tt>11010000 oo100rm</tt> || 2+ || 3
|-
| SHL mem8, CL || <tt>D2 /4</tt> || <tt>11010010 oo100rm</tt> || 2+ || 5
|-
| SHL mem8, imm8 || <tt>C0 /4 ii</tt> || <tt>11000000 oo100mmm iiiiiiii</tt> || 3+ || 5
|-
| SHL mem16, 1 || <tt>D1 /4</tt> || <tt>11010001 oo100rm</tt> || 2+ || 3
|-
| SHL mem16, CL || <tt>D3 /4</tt> || <tt>11010011 oo100rm</tt> || 2+ || 5
|-
| SHL mem16, imm8 || <tt>C1 /4 ii</tt> || <tt>11000001 oo100mmm iiiiiiii</tt> || 3+ || 5
|-
| SHL reg8, 1 || <tt>D0 /4</tt> || <tt>11010000 11100rm</tt> || 2 || 1
|-
| SHL reg8, CL || <tt>D2 /4</tt> || <tt>11010010 11100rm</tt> || 2 || 3
|-
| SHL reg8, imm8 || <tt>C0 /4 ii</tt> || <tt>11000000 11100mmm iiiiiiii</tt> || 3 || 3
|-
| SHL reg16, 1 || <tt>D1 /4</tt> || <tt>11010001 11100rm</tt> || 2 || 1
|-
| SHL reg16, CL || <tt>D3 /4</tt> || <tt>11010011 11100rm</tt> || 2 || 3
|-
| SHL reg16, imm8 || <tt>C1 /4 ii</tt> || <tt>11000001 11100mmm iiiiiiii</tt> || 3 || 3
|}
----
{{Anchor|SHR}}
=== SHR ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| SHR mem8, 1 || <tt>D0 /5</tt> || <tt>11010000 oo101rm</tt> || 2+ || 3
|-
| SHR mem8, CL || <tt>D2 /5</tt> || <tt>11010010 oo101rm</tt> || 2+ || 5
|-
| SHR mem8, imm8 || <tt>C0 /5 ii</tt> || <tt>11000000 oo101mmm iiiiiiii</tt> || 3+ || 5
|-
| SHR mem16, 1 || <tt>D1 /5</tt> || <tt>11010001 oo101rm</tt> || 2+ || 3
|-
| SHR mem16, CL || <tt>D3 /5</tt> || <tt>11010011 oo101rm</tt> || 2+ || 5
|-
| SHR mem16, imm8 || <tt>C1 /5 ii</tt> || <tt>11000001 oo101mmm iiiiiiii</tt> || 3+ || 5
|-
| SHR reg8, 1 || <tt>D0 /5</tt> || <tt>11010000 11101rm</tt> || 2 || 1
|-
| SHR reg8, CL || <tt>D2 /5</tt> || <tt>11010010 11101rm</tt> || 2 || 3
|-
| SHR reg8, imm8 || <tt>C0 /5 ii</tt> || <tt>11000000 11101mmm iiiiiiii</tt> || 3 || 3
|-
| SHR reg16, 1 || <tt>D1 /5</tt> || <tt>11010001 11101rm</tt> || 2 || 1
|-
| SHR reg16, CL || <tt>D3 /5</tt> || <tt>11010011 11101rm</tt> || 2 || 3
|-
| SHR reg16, imm8 || <tt>C1 /5 ii</tt> || <tt>11000001 11101mmm iiiiiiii</tt> || 3 || 3
|}
----
{{Anchor|SS}}
=== SS ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| SS || <tt>36</tt> || <tt>00110110</tt> || 1 || 1
|}
----
{{Anchor|STC}}
=== STC ===
{| class="wikitable"
! Flag !! New value
|-
| [[NEC_V30MZ_flags#CF|CF - Carry]] || 1
|}
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| STC || <tt>F9</tt> || <tt>11111001</tt> || 1 || 4
|}
----
{{Anchor|STD}}
=== STD ===
{| class="wikitable"
! Flag !! New value
|-
| [[NEC_V30MZ_flags#DF|DF - Direction]] || 1
|}
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| STD || <tt>FD</tt> || <tt>11111101</tt> || 1 || 4
|}
----
{{Anchor|STI}}
=== STI ===
{| class="wikitable"
! Flag !! New value
|-
| [[NEC_V30MZ_flags#IF|IF - Interrupt]] || 1
|}
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| STI || <tt>FB</tt> || <tt>11111011</tt> || 1 || 4
|}
----
{{Anchor|STOSB}}
{{Anchor|STOSW}}
=== STOSB/STOSW ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| STOSB || <tt>AA</tt> || <tt>10101010</tt> || 1 || 3
|-
| STOSW || <tt>AB</tt> || <tt>10101011</tt> || 1 || 3
|}
----
{{Anchor|SUB}}
=== SUB ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| SUB AL, imm || <tt>28 ii</tt> || <tt>00101100 iiiiiiii</tt> || 2 || 1
|-
| SUB AX, imm || <tt>29 ii ii</tt> || <tt>00101101 iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| SUB mem8, imm8 || <tt>80 /5 ii</tt> || <tt>10000000 oo101mmm iiiiiiii</tt> || 3+ || 3
|-
| SUB mem16, imm16 || <tt>81 /5 ii ii</tt> || <tt>10000001 oo101mmm iiiiiiii iiiiiiii</tt> || 4+ || 3
|-
| SUB mem16, simm8 || <tt>83 /5 ii</tt> || <tt>10000011 oo101mmm iiiiiiii</tt> || 3+ || 3
|-
| SUB mem8, reg8 || <tt>28 /r</tt> || <tt>00101000 oorrrmmm</tt> || 2+ || 3
|-
| SUB mem16, reg16 || <tt>29 /r</tt> || <tt>00101001 oorrrmmm</tt> || 2+ || 3
|-
| SUB reg8, imm8 || <tt>80 /5 ii</tt> || <tt>10000000 11101mmm iiiiiiii</tt> || 3 || 1
|-
| SUB reg16, imm16 || <tt>81 /5 ii ii</tt> || <tt>10000001 11101mmm iiiiiiii iiiiiiii</tt> || 4 || 1
|-
| SUB reg16, simm8 || <tt>83 /5 ii</tt> || <tt>10000011 11101mmm iiiiiiii</tt> || 3 || 1
|-
| SUB reg8, mem8 || <tt>2A /r</tt> || <tt>00101010 oorrrmmm</tt> || 2+ || 2
|-
| SUB reg16, mem16 || <tt>2B /r</tt> || <tt>00101011 oorrrmmm</tt> || 2+ || 2
|-
| SUB reg8, reg8 || <tt>28 /r</tt> || <tt>001010.0 11rrrmmm</tt> || 2 || 1
|-
| SUB reg16, reg16 || <tt>29 /r</tt> || <tt>001010.1 11rrrmmm</tt> || 2 || 1
|}
----
{{Anchor|TEST}}
=== TEST ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| TEST AL, imm || <tt>A8 ii</tt> || <tt>10101000 iiiiiiii</tt> || 2 || 1
|-
| TEST AX, imm || <tt>A9 ii ii</tt> || <tt>10101001 iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| TEST mem8, imm8 || <tt>F6 /0 ii</tt> || <tt>11110110 oo000mmm iiiiiiii</tt> || 3+ || 2
|-
| TEST mem16, imm16 || <tt>F7 /0 ii ii</tt> || <tt>11110111 oo000mmm iiiiiiii iiiiiiii</tt> || 4+ || 2
|-
| TEST mem8, reg8<br/>TEST reg8, mem8 || <tt>84 /r</tt> || <tt>10000100 oorrrmmm</tt> || 2+ || 2
|-
| TEST mem16, reg16<br/>TEST reg16, mem16 || <tt>85 /r</tt> || <tt>10000101 oorrrmmm</tt> || 2+ || 2
|-
| TEST reg8, imm8 || <tt>F6 /0 ii</tt> || <tt>11110110 11000mmm iiiiiiii</tt> || 3 || 1
|-
| TEST reg16, imm16 || <tt>F7 /0 ii ii</tt> || <tt>11110111 11000mmm iiiiiiii iiiiiiii</tt> || 4 || 1
|-
| TEST reg8, reg8 || <tt>84 /r</tt> || <tt>10000100 11rrrmmm</tt> || 2 || 1
|-
| TEST reg16, reg16 || <tt>85 /r</tt> || <tt>10000101 11rrrmmm</tt> || 2 || 1
|}
----
{{Anchor|WAIT}}
=== WAIT ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| WAIT || <tt>6E</tt> || <tt>01101110</tt> || 1 || 9<ref>On the WonderSwan implementation, POLLB is always held low; on other implementations, POLL will wait for POLLB to be held low in 9-cycle intervals.</ref>
|}
Nominally, this instruction synchronizes the CPU with an external co-processor. However, as the WonderSwan does not feature one, this instruction simply becomes a (slower) no-op.
----
{{Anchor|XCHG}}
=== XCHG ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| XCHG AX, reg16<br/>XCHG reg16, AX || <tt>9x</tt> || <tt>10010rrr</tt> || 1 || 3
|-
| XCHG mem8, reg8<br/>XCHG reg8, mem8 || <tt>86 /r</tt> || <tt>10000110 oorrrmmm</tt> || 2+ || 5
|-
| XCHG mem16, reg16<br/>XCHG reg16, mem16 || <tt>87 /r</tt> || <tt>10000111 oorrrmmm</tt> || 2+ || 5
|-
| XCHG reg8, reg8 || <tt>86 /r</tt> || <tt>10000110 11rrrmmm</tt> || 2+ || 3
|-
| XCHG reg16, reg16 || <tt>87 /r</tt> || <tt>10000111 11rrrmmm</tt> || 2+ || 3
|}
----
{{Anchor|XLAT}}
=== XLAT ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| XLAT || <tt>D7</tt> || <tt>11010111</tt> || 1 || 5
|}
----
{{Anchor|XOR}}
=== XOR ===
{| class="wikitable sortable"
! Instruction !! Opcode (hex) !! Opcode (bin) !! Bytes !! Cycles
|-
| XOR AL, imm || <tt>34 ii</tt> || <tt>00110100 iiiiiiii</tt> || 2 || 1
|-
| XOR AX, imm || <tt>35 ii ii</tt> || <tt>00110101 iiiiiiii iiiiiiii</tt> || 3 || 1
|-
| XOR mem8, imm8 || <tt>80 /6 ii</tt> || <tt>10000000 oo110mmm iiiiiiii</tt> || 3+ || 3
|-
| XOR mem16, imm16 || <tt>81 /6 ii ii</tt> || <tt>10000001 oo110mmm iiiiiiii iiiiiiii</tt> || 4+ || 3
|-
| XOR mem16, simm8 || <tt>83 /6 ii</tt> || <tt>10000011 oo110mmm iiiiiiii</tt> || 3+ || 3
|-
| XOR mem8, reg8 || <tt>30 /r</tt> || <tt>00110000 oorrrmmm</tt> || 2+ || 3
|-
| XOR mem16, reg16 || <tt>31 /r</tt> || <tt>00110001 oorrrmmm</tt> || 2+ || 3
|-
| XOR reg8, imm8 || <tt>80 /6 ii</tt> || <tt>10000000 11110mmm iiiiiiii</tt> || 3 || 1
|-
| XOR reg16, imm16 || <tt>81 /6 ii ii</tt> || <tt>10000001 11110mmm iiiiiiii iiiiiiii</tt> || 4 || 1
|-
| XOR reg16, simm8 || <tt>83 /6 ii</tt> || <tt>10000011 11110mmm iiiiiiii</tt> || 3 || 1
|-
| XOR reg8, mem8 || <tt>32 /r</tt> || <tt>00110010 oorrrmmm</tt> || 2+ || 2
|-
| XOR reg16, mem16 || <tt>33 /r</tt> || <tt>00110011 oorrrmmm</tt> || 2+ || 2
|-
| XOR reg8, reg8 || <tt>30 /r</tt> || <tt>001100.0 11rrrmmm</tt> || 2 || 1
|-
| XOR reg16, reg16 || <tt>31 /r</tt> || <tt>001100.1 11rrrmmm</tt> || 2 || 1
|}
== Notes ==
<references />
314a1bbe36662854c5fc166ef7f7630703eab9be
NEC V30MZ interrupts
0
58
552
550
2025-03-02T13:31:00Z
Asie
351
/* Timing */ BRK also has a latch
wikitext
text/x-wiki
== CPU interrupts ==
The NEC V30MZ implements six of the eight CPU interrupts provided by the 80186.
=== INT 0 - Divide Error ===
This interrupt is emitted as the result of a DIV<sup>IDIV</sup> or DIVU<sup>DIV</sup> instruction.
=== INT 1 - Single Step/Break ===
This interrupt is emitted if the single step flag is set after executing an instruction. (The instruction which changed the single step flag is ignored.) The single step flag is cleared for the duration of the interrupt, allowing the user to store state and perform debug activities; it is then restored when returning from the interrupt, by restoring the original processor flags stored on the stack.
=== INT 2 - Non-Maskable interrupt (NMI) ===
This interrupt is emitted when the SoC requests a non-maskable interrupt. On the WonderSwan, the condtions for emitting an NMI are configured by the relevant I/O port.
=== INT 3 - Breakpoint ===
This interrupt is emitted by the INT 3<sup>BRK</sup> instruction. Unlike other unconditional interrupt instructions, it is encoded with only one byte.
=== INT 4 - Overflow ===
This interrupt is emitted by the INTO<sup>BRKV</sup> instruction, if the overflow flag is set while it is being executed.
=== INT 5 - Array Bounds ===
This interrupt is emitted only by the BOUND<sup>CHKIND</sup> instruction.
== External interrupts ==
The NEC V30MZ distinguishes three sources of external interrupts - that is, interrupts not triggered by an instruction itself:
* Non-maskable interrupts:
** NMI - controlled by the NMI control I/O port on WS,
** BRK - controlled by the single-step flag.
* Maskable interrupts:
** IRQ - controlled by the IRQ control I/O ports on WS.
== Timing ==
Both non-maskable and maskable interrupts are acknowledged after the execution of an instruction is complete. However, under some conditions, interrupts may not be processed on a given instruction and delayed until the next one. This is the case for:
* instructions which change the stack segment register (MOV and POP),
* prefix instructions (LOCK, REP, segment prefixes),
* instructions which set the interrupt enable CPU flag (STI, POPF), if the flag was cleared prior to the instruction's execution (for IRQ interrupts only),
* instructions which set the single-step CPU flag, if the flag was cleared prior to the instruction's execution (for BRK interrupts only).
TODO: Document how many cycles interrupt processing takes.
== Notes ==
* The following 80186 interrupts are not implemented:
** INT 6 - Unused Opcode - the V30MZ treats most unimplemented instructions as NOPs.
** INT 7 - ESC Opcode - the V30MZ, likewise, treats these instructions as NOPs.
c763c4e67bfb1d1227dafbd1218c4e3a4bc4229b
Interrupts
0
22
553
352
2025-03-08T12:00:04Z
Asie
351
/* Interrupts */
wikitext
text/x-wiki
== Interrupts ==
The WonderSwan features fourteen different interrupts:
* CPU interrupts - six provided by the V30MZ CPU ($00-$05),
* Hardware interrupts - eight provided by the SoC's hardware ($00-$07, or $08-$0F, or $10-$1F, or ... $F8-$FF - controlled by an offset <code>V</code>):
** Level - will be constantly requested while enabled and the prerequisite condition is true,
** Edge - will only be requested while enabled the moment the prerequisite condition ''becomes'' true.
Interrupt requests happen when the condition is true and the interrupt is enabled. Note that edge interrupts are only requested once; level interrupts are requested constantly, making acknowledgements ineffective until the condition is cleared or the interrupt is disabled. However, neither disabling an interrupt nor satisfying the condition clears the acknowledgement bit.
The user can additionally make use of all 256 available interrupt vectors in their own code.
{| class="wikitable"
|+ List of WonderSwan interrupts
! Source
! Type
! Index
! Description
|-
! rowspan="6" | CPU
| rowspan="6" | N/A
| $00
| DIV or IDIV instruction divide error<br/>
(division by zero or result overflow)
|-
| $01
| Single-step (T flag)
|-
| $02
| NMI (non-maskable interrupt)
|-
| $03
| INT 3 opcode
|-
| $04
| INTO opcode (if V = 1)
|-
| $05
| BOUND opcode (if index out of bounds)
|-
! rowspan="8" | Hardware
| Level
| V + 0
| [[UART|UART Send Ready]]
|-
| Edge
| V + 1
| [[Keypad|Key Pressed]]
|-
| rowspan="2" | Level
| V + 2
| [[Cartridge|Cartridge IRQ]]
|-
| V + 3
| [[UART|UART Receive Ready]]
|-
| rowspan="4" | Edge
| V + 4
| [[Display|Display Interrupt Line Match]]
|-
| V + 5
| [[Timers|Vertical Blank Timer]]
|-
| V + 6
| [[Display|Display Vertical Blank]]
|-
| V + 7
| [[Timers|Horizontal Blank Timer]]
|}
== I/O ports ==
{{Anchor|Interrupt Vector Offset}}
=== Interrupt Vector Offset ($B0 write) ===
<pre>
7 bit 0
---- ----
VVVV V...
|||| |
++++-+---- Interrupt vector offset
</pre>
{{Anchor|Interrupt Vector Request}}
=== Interrupt Vector Request ($B0 read) ===
<pre>
7 bit 0
---- ----
vvvv vvvv
|||| ||||
++++-++++- Interrupt vector requested
from the CPU.
</pre>
* Bits <code>7 .. 3</code> of this will always equal the user-provided vector offset.
* Bits <code>2 .. 0</code> of this will always equal the highest set bit index of Interrupt Status; if all bits in Interrupt Status are clear, they will equal <code>0</code>.
{{Anchor|Interrupt Enable}}
=== Interrupt Enable ($B2) ===
<pre>
7 bit 0
---- ----
iiii iiii
|||| ||||
++++-++++- Hardware interrupt to enable
(acts as a mask)
</pre>
Contrary to other systems, this also controls whether interrupts set the relevant bit in Interrupt Status.
{{Anchor|Interrupt Status}}
=== Interrupt Status ($B4 read)===
<pre>
7 bit 0
---- ----
iiii iiii
|||| ||||
++++-++++- 1 if interrupt requested
</pre>
{{Anchor|Interrupt Acknowledge}}
=== Interrupt Acknowledge ($B6 write)===
<pre>
7 bit 0
---- ----
iiii iiii
|||| ||||
++++-++++- Write 1 to clear interrupt request
</pre>
{{Anchor|Interrupt NMI Control}}
=== Interrupt NMI Control ($B7)===
<pre>
7 bit 0
---- ----
...b ....
|
+----- Enable NMI on low battery detection
</pre>
a3a659fa27ddb1e3a8fe91d5742963bf92d47eb2
UART
0
23
554
123
2025-03-08T12:00:42Z
Asie
351
/* Interrupts */
wikitext
text/x-wiki
The WonderSwan's EXT port features an UART operating with the following configuration:
* 9,600 or 38,400 bps (bauds per second),
* 8N1 (8 data bits followed by 1 stop bit, no parity).
This allows for an effective maximum transfer speed of 960 or 3840 bytes per second, respectively.
The hardware also features one-byte transmit and receive buffers, which allow for a slight delay in code when handling data to/from the console.
== Interrupts ==
The UART features two interrupts:
* UART Send Ready - constantly triggering (level interrupt) as long as the transmit buffer is empty (Serial Status bit 2),
* UART Receive Ready - constantly triggering (level interrupt) as long as the receive buffer contains a byte (Serial Status bit 0).
These interrupts are only triggering if the UART block is enabled.
== I/O ports ==
{{Anchor|Serial Receive Data}}
=== Serial Receive Data ($B1 read) ===
<pre>
7 bit 0
---- ----
dddd dddd
|||| ||||
++++-++++- Receive buffer value
</pre>
{{Anchor|Serial Transmit Data}}
=== Serial Transmit Data ($B1 write) ===
<pre>
7 bit 0
---- ----
dddd dddd
|||| ||||
++++-++++- Transmit buffer value
</pre>
{{Anchor|Serial Status}}
=== Serial Status ($B3 read) ===
<pre>
7 bit 0
---- ----
eb.. .tor
|| |||
|| ||+- 1 if the receive buffer contains a byte
|| |+-- 1 on overrun (receive buffer overflow)
|| +--- 1 if the transmit buffer is empty (can transmit another byte)
|+-------- UART speed: 0 = 9600 bps, 1 = 38400 bps
+--------- UART enable: 0 = off, 1 = on
</pre>
{{Anchor|Serial Control}}
=== Serial Control ($B3 write) ===
<pre>
7 bit 0
---- ----
ebO. ....
|||
||+------- Write 1 to reset overrun
|+-------- UART speed: 0 = 9600 bps, 1 = 38400 bps
+--------- UART enable: 0 = off, 1 = on
</pre>
baaf6e2fdc043e9b5063291d88dfcdf936b6aa39
Display
0
26
555
521
2025-03-08T13:13:01Z
Asie
351
document sprite drawing priority
wikitext
text/x-wiki
The WonderSwan features a 224x144 display capable of displaying up to 16 shades of gray (mono) or 4096 colors (color).
{| class="wikitable"
! ↑ Front ↑
! Window
! Scroll
|-
| align="center" | Sprites, high priority
| ✔
|
|-
| align="center" | Screen 2
| ✔
| ✔
|-
| align="center" | Sprites, low priority
| ✔
|
|-
| align="center" | Screen 1
|
| ✔
|-
| align="center" | Background color
|
|
|-
! ↑ Back ↑
! Window
! Scroll
|}
== Features ==
=== Screens ===
Screens are 32x32 tile maps, for a total of 256x256 pixels; each map entry can use one of 512 (mono) or 1024 (color) tiles, one of sixteen distinct palettes, as well as be drawn mirrored or flipped. The screens can be scrolled horizontally and vertically.
=== Sprites ===
The sprite layer consists of 128 distinct sprites. These can use any of the first 512 tiles, palettes 8 through 15, as well as be drawn over or under screen 2.
Each scanline can display up to 32 sprites at a time; these will be the first 32 sprites found on the list for the given scanline. Sprites are then drawn in order from last to first.
=== Windows ===
The window functionality can be used to restrict drawing of Screen 2's tiles, as well as the sprite layer, to a given pixel-perfect window. Individual sprites can be marked as being drawn inside or outside the window.
=== Palettes ===
Each palette consists of four colors, of which the first entry - color zero - is opaque in palettes 0-3 and 8-11 and transparent otherwise. The color models additionally feature a sixteen-color palette mode, in which color zero is always considered transparent. The background color is displayed if no ''opaque'' pixel from any screens or sprites is drawn.
=== Icons ===
In addition, a set of LCD segment-based icons is provided to a side of the display which can be independently controlled as an indicator to the user.
== Interrupts ==
The display circuit generates two interrupts of its own:
* Display Interrupt Line Match - when <code>Display Current Line</code> == <code>Display Interrupt Line</code>, at the beginning of said line.
* Display Vertical Blank - when <code>Display Current Line</code> == <code>144</code>, at the beginning of said line.
It also provides a timing source for the two Horizontal and Vertical Blank [[Timers]], which provide their own respective interrupts.
== More information ==
* [[Display/Tile Data|Tile data]]
* [[Display/Palette|Color palette]]
* [[Display/Screens|Screen format]]
* [[Display/Sprites|Sprite format]]
* [[Display/Windows|Windows]]
* [[Display/LCD Icons|LCD icons]]
* [[Display/IO Ports|I/O ports]]
65203d5c8077bf8b8364261ef69cdee818cd22b1
WonderWitch/Filesystem
0
59
556
537
2025-03-09T17:34:56Z
Asie
351
/* Timestamp format */ Ranges
wikitext
text/x-wiki
== Mount points ==
{| class="wikitable"
|+ FreyaOS mount points
|-
! Path !! File data location !! File table location !! File table size (entries) !! Description
|-
| <code>/rom0</code> || ROM (384 KB) || SRAM bank 3, $16F2 || 128 ||
|-
| <code>/ram0</code> || SRAM bank 0 (64 KB) || SRAM bank 3, $06F2 || 64 ||
|-
| <code>/</code> || || SRAM bank 3, $02F2 || 16 ||
|}
== File table entry format ==
{| class="wikitable"
|+ Header contents
|-
! Offset !! Length !! Contents
|-
| 0 || 16 || File name; zero-terminated Shift-JIS string.
|-
| 16 || 24 || User-friendly file name; zero-terminated Shift-JIS string.
FreyaOS displays the first 12 characters in its file selector.
|-
| 40 || 4 || Location in CPU address space (segment:offset)
|-
| 44 || 4 || Total file size, in bytes, excluding the header.
|-
| 48 || 2 || XMODEM chunk count - above file size divided by 128, then rounded up.
|-
| 50 || 2 || File mode
|-
| 52 || 4 || Modification time
|-
| 56 || 4 || TODO
|-
| 60 || 4 || Offset to resource data, bytes excluding header; -1 if not present.
|}
=== Timestamp format ===
{| class="wikitable"
|+ Header contents
|-
! Bits !! Contents
|-
| 31 - 25 || Year, 0 .. (starting from 2000)
|-
| 24 - 21 || Month, 1 .. 12
|-
| 20 - 16 || Day, 1 .. 31
|-
| 15 - 11 || Hour, 0 .. 23
|-
| 10 - 5 || Minute, 0 .. 59
|-
| 0 - 4 || Second, 0 .. 29 (in two-second units)
|}
=== File modes ===
----
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
???? ???? dlis mrwx
|||| ||||
|||| |||+- Execute
|||| ||+-- Write
|||| |+--- Read
|||| +---- Prohibit mmap() use
|||+------ StreamIL-related?
||+------- Intermediate library
|+-------- Symbolic link
+--------- Directory
</pre>
254d7cee908f619de9058c57e4d8b0c151ec5e86
590
556
2025-04-11T20:00:41Z
Asie
351
/* Mount points */ /kern
wikitext
text/x-wiki
== Mount points ==
{| class="wikitable"
|+ FreyaOS mount points
|-
! Path !! File data location !! File table location !! File table size (entries) !! Description
|-
| <code>/rom0</code> || ROM (384 KB) || SRAM bank 3, $16F2 || 128 ||
|-
| <code>/ram0</code> || SRAM bank 0 (64 KB) || SRAM bank 3, $06F2 || 64 ||
|-
| <code>/</code> || || SRAM bank 3, $02F2 || 16 ||
|}
=== /kern ===
The <tt>/kern</tt> folder is provided by FreyaOS.
{| class="wikitable"
|-
! File !! Description
|-
| <tt>@ilib</tt>
| [[WonderWitch/IL/IlibIL|IlibIL]]; can be overridden in <tt>/rom0</tt>
|-
| <tt>@proc</tt>
| [[WonderWitch/IL/ProcIL|ProcIL]]; can be overridden in <tt>/rom0</tt>
|-
| <tt>@pfs</tt>
| [[WonderWitch/IL/FsIL|FsIL]]
|-
| <tt>@shell</tt>
| Shell program; can be overridden in <tt>/rom0</tt>
|-
| <tt>@aux</tt>
|
|-
| <tt>about.txt</tt>
| "About Freya"
|}
== File table entry format ==
{| class="wikitable"
|+ Header contents
|-
! Offset !! Length !! Contents
|-
| 0 || 16 || File name; zero-terminated Shift-JIS string.
|-
| 16 || 24 || User-friendly file name; zero-terminated Shift-JIS string.
FreyaOS displays the first 12 characters in its file selector.
|-
| 40 || 4 || Location in CPU address space (segment:offset)
|-
| 44 || 4 || Total file size, in bytes, excluding the header.
|-
| 48 || 2 || XMODEM chunk count - above file size divided by 128, then rounded up.
|-
| 50 || 2 || File mode
|-
| 52 || 4 || Modification time
|-
| 56 || 4 || TODO
|-
| 60 || 4 || Offset to resource data, bytes excluding header; -1 if not present.
|}
=== Timestamp format ===
{| class="wikitable"
|+ Header contents
|-
! Bits !! Contents
|-
| 31 - 25 || Year, 0 .. (starting from 2000)
|-
| 24 - 21 || Month, 1 .. 12
|-
| 20 - 16 || Day, 1 .. 31
|-
| 15 - 11 || Hour, 0 .. 23
|-
| 10 - 5 || Minute, 0 .. 59
|-
| 0 - 4 || Second, 0 .. 29 (in two-second units)
|}
=== File modes ===
----
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
???? ???? dlis mrwx
|||| ||||
|||| |||+- Execute
|||| ||+-- Write
|||| |+--- Read
|||| +---- Prohibit mmap() use
|||+------ StreamIL-related?
||+------- Intermediate library
|+-------- Symbolic link
+--------- Directory
</pre>
3e2c0ccffc1d550799854b3030425322e2ae8c29
591
590
2025-04-11T20:23:23Z
Asie
351
/* File table entry format */
wikitext
text/x-wiki
== Mount points ==
{| class="wikitable"
|+ FreyaOS mount points
|-
! Path !! File data location !! File table location !! File table size (entries) !! Description
|-
| <code>/rom0</code> || ROM (384 KB) || SRAM bank 3, $16F2 || 128 ||
|-
| <code>/ram0</code> || SRAM bank 0 (64 KB) || SRAM bank 3, $06F2 || 64 ||
|-
| <code>/</code> || || SRAM bank 3, $02F2 || 16 ||
|}
=== /kern ===
The <tt>/kern</tt> folder is provided by FreyaOS.
{| class="wikitable"
|-
! File !! Description
|-
| <tt>@ilib</tt>
| [[WonderWitch/IL/IlibIL|IlibIL]]; can be overridden in <tt>/rom0</tt>
|-
| <tt>@proc</tt>
| [[WonderWitch/IL/ProcIL|ProcIL]]; can be overridden in <tt>/rom0</tt>
|-
| <tt>@pfs</tt>
| [[WonderWitch/IL/FsIL|FsIL]]
|-
| <tt>@shell</tt>
| Shell program; can be overridden in <tt>/rom0</tt>
|-
| <tt>@aux</tt>
|
|-
| <tt>about.txt</tt>
| "About Freya"
|}
== File table entry format ==
{| class="wikitable"
|+ Header contents
|-
! Offset !! Length !! Contents
|-
| 0 || 16 || File name; zero-terminated Shift-JIS string.
|-
| 16 || 24 || User-friendly file name; zero-terminated Shift-JIS string.
FreyaOS displays the first 12 characters in its file selector.
|-
| 40 || 4 || Location in CPU address space (segment:offset)
|-
| 44 || 4 || Total file size, in bytes, excluding the header.
|-
| 48 || 2 || File: 128-byte (XMODEM) chunk count, rounded up
Directory: Number of entries
|-
| 50 || 2 || File mode
|-
| 52 || 4 || Modification time
|-
| 56 || 4 || File: TODO
Directory: Pointer to FsIL implementation for directory
|-
| 60 || 4 || Offset to resource data, bytes excluding header; -1 if not present.
|}
=== Timestamp format ===
{| class="wikitable"
|+ Header contents
|-
! Bits !! Contents
|-
| 31 - 25 || Year, 0 .. (starting from 2000)
|-
| 24 - 21 || Month, 1 .. 12
|-
| 20 - 16 || Day, 1 .. 31
|-
| 15 - 11 || Hour, 0 .. 23
|-
| 10 - 5 || Minute, 0 .. 59
|-
| 0 - 4 || Second, 0 .. 29 (in two-second units)
|}
=== File modes ===
----
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
???? ???? dlis mrwx
|||| ||||
|||| |||+- Execute
|||| ||+-- Write
|||| |+--- Read
|||| +---- Prohibit mmap() use
|||+------ StreamIL-related?
||+------- Intermediate library
|+-------- Symbolic link
+--------- Directory
</pre>
d1d08e65a05f228b9caba27ee2ce85fa7ea18ce2
592
591
2025-04-11T20:32:35Z
Asie
351
/* File table entry format */
wikitext
text/x-wiki
== Mount points ==
{| class="wikitable"
|+ FreyaOS mount points
|-
! Path !! File data location !! File table location !! File table size (entries) !! Description
|-
| <code>/rom0</code> || ROM (384 KB) || SRAM bank 3, $16F2 || 128 ||
|-
| <code>/ram0</code> || SRAM bank 0 (64 KB) || SRAM bank 3, $06F2 || 64 ||
|-
| <code>/</code> || || SRAM bank 3, $02F2 || 16 ||
|}
=== /kern ===
The <tt>/kern</tt> folder is provided by FreyaOS.
{| class="wikitable"
|-
! File !! Description
|-
| <tt>@ilib</tt>
| [[WonderWitch/IL/IlibIL|IlibIL]]; can be overridden in <tt>/rom0</tt>
|-
| <tt>@proc</tt>
| [[WonderWitch/IL/ProcIL|ProcIL]]; can be overridden in <tt>/rom0</tt>
|-
| <tt>@pfs</tt>
| [[WonderWitch/IL/FsIL|FsIL]]
|-
| <tt>@shell</tt>
| Shell program; can be overridden in <tt>/rom0</tt>
|-
| <tt>@aux</tt>
|
|-
| <tt>about.txt</tt>
| "About Freya"
|}
== File table entry format ==
{| class="wikitable"
|+ Header contents
|-
! Offset !! Length !! Contents
|-
| 0 || 16 || File name; zero-terminated Shift-JIS string.
|-
| 16 || 24 || User-friendly file name; zero-terminated Shift-JIS string.
FreyaOS displays the first 12 characters in its file selector.
|-
| 40 || 4 || Location in CPU address space (segment:offset)
|-
| 44 || 4 || Total file size, in bytes, excluding the header.
|-
| 48 || 2 || File: 128-byte (XMODEM) chunk count, rounded up; <tt>0xFFFF</tt> if deleted file.
Directory: Number of entries.
|-
| 50 || 2 || File mode
|-
| 52 || 4 || Modification time
|-
| 56 || 4 || File: TODO
Directory: Pointer to FsIL implementation for directory
|-
| 60 || 4 || Offset to resource data, bytes excluding header; <tt>0xFFFFFFFF</tt> if not present.
|}
=== Timestamp format ===
{| class="wikitable"
|+ Header contents
|-
! Bits !! Contents
|-
| 31 - 25 || Year, 0 .. (starting from 2000)
|-
| 24 - 21 || Month, 1 .. 12
|-
| 20 - 16 || Day, 1 .. 31
|-
| 15 - 11 || Hour, 0 .. 23
|-
| 10 - 5 || Minute, 0 .. 59
|-
| 0 - 4 || Second, 0 .. 29 (in two-second units)
|}
=== File modes ===
----
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
???? ???? dlis mrwx
|||| ||||
|||| |||+- Execute
|||| ||+-- Write
|||| |+--- Read
|||| +---- Prohibit mmap() use
|||+------ StreamIL-related?
||+------- Intermediate library
|+-------- Symbolic link
+--------- Directory
</pre>
c572bce0a848c1d75487ed86427316e91071c0e6
593
592
2025-04-12T17:52:52Z
Asie
351
/* File table entry format */
wikitext
text/x-wiki
== Mount points ==
{| class="wikitable"
|+ FreyaOS mount points
|-
! Path !! File data location !! File table location !! File table size (entries) !! Description
|-
| <code>/rom0</code> || ROM (384 KB) || SRAM bank 3, $16F2 || 128 ||
|-
| <code>/ram0</code> || SRAM bank 0 (64 KB) || SRAM bank 3, $06F2 || 64 ||
|-
| <code>/</code> || || SRAM bank 3, $02F2 || 16 ||
|}
=== /kern ===
The <tt>/kern</tt> folder is provided by FreyaOS.
{| class="wikitable"
|-
! File !! Description
|-
| <tt>@ilib</tt>
| [[WonderWitch/IL/IlibIL|IlibIL]]; can be overridden in <tt>/rom0</tt>
|-
| <tt>@proc</tt>
| [[WonderWitch/IL/ProcIL|ProcIL]]; can be overridden in <tt>/rom0</tt>
|-
| <tt>@pfs</tt>
| [[WonderWitch/IL/FsIL|FsIL]]
|-
| <tt>@shell</tt>
| Shell program; can be overridden in <tt>/rom0</tt>
|-
| <tt>@aux</tt>
|
|-
| <tt>about.txt</tt>
| "About Freya"
|}
== File table entry format ==
{| class="wikitable"
|+ Header contents
|-
! Offset !! Length !! Contents
|-
| 0 || 16 || File name; zero-terminated Shift-JIS string.
|-
| 16 || 24 || User-friendly file name; zero-terminated Shift-JIS string.
FreyaOS displays the first 12 characters in its file selector.
|-
| 40 || 4 || File: Location in CPU address space (segment:offset)
|-
| 44 || 4 || File: Total file size, in bytes, excluding the header.
|-
| 48 || 2 || File: 128-byte (XMODEM) chunk count, rounded up.
Directory: Number of total available entries.
<tt>0xFFFF</tt> (-1): Unallocated entry.
|-
| 50 || 2 || File mode
|-
| 52 || 4 || Modification time
|-
| 56 || 4 || File: TODO
Directory: Pointer to FsIL implementation for directory
|-
| 60 || 4 || Offset to resource data, bytes excluding header; <tt>0xFFFFFFFF</tt> if not present.
|}
=== Timestamp format ===
{| class="wikitable"
|+ Header contents
|-
! Bits !! Contents
|-
| 31 - 25 || Year, 0 .. (starting from 2000)
|-
| 24 - 21 || Month, 1 .. 12
|-
| 20 - 16 || Day, 1 .. 31
|-
| 15 - 11 || Hour, 0 .. 23
|-
| 10 - 5 || Minute, 0 .. 59
|-
| 0 - 4 || Second, 0 .. 29 (in two-second units)
|}
=== File modes ===
----
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
???? ???? dlis mrwx
|||| ||||
|||| |||+- Execute
|||| ||+-- Write
|||| |+--- Read
|||| +---- Prohibit mmap() use
|||+------ StreamIL-related?
||+------- Intermediate library
|+-------- Symbolic link
+--------- Directory
</pre>
74f5ac6a48411a133177fa5a54c757d6817da93b
Sound
0
27
557
359
2025-03-09T20:15:38Z
Asie
351
wikitext
text/x-wiki
The WonderSwan features the following sound hardware:
* Four audio channels:
** channel 1 - wavetable (32 x 4-bit samples),
** channel 2 - wavetable or 8-bit unsigned PCM sample,
** channel 3 - wavetable with optional hardware sweep,
** channel 4 - wavetable or LFSR noise,
* [[Hyper Voice]]<sup>(color)</sup> - headphone output exclusive 16-bit stereo PCM output,
* 24000 Hz output:
** internal speaker - 8-bit, mono,
** headphone output - 16-bit, stereo.
[[Hyper Voice]] functionality is documented on its own sub-page.
== Mixing diagram ==
The sound is mixed as follows:
<pre>
Ch1 Ch2 Ch3 Ch4 Glossary: L = left, R = right, M = mono
| | | | Mnn = nn-bit mono
8 8 8 8 port $98 port $nn = value port
| | | | /
_V___V___V___V_ / _____ _____
| |--L10------+----->| | | |
| + | | | + |--M11-->| >>r |--M8--> Speaker output
|_______________|--R10------|-+--->|_____| / |_____|
/ _|_|_ / (r=0...3)
/ | | / \
port $96 | <<5 | port $9A \
|_____| \
| | port $91
| |
port $68 port $64 | |
/ _______________ \ __V_V__ _____
L8-->| (Color only) |--L16-->| |----------L16-->| |
| Hyper Voice | | + + | | I2S |------> Headphone output
R8-->|_______________|--R16-->|_______|----------R16-->|_____|
\ /
port $69 port $66
</pre>
== I/O Ports ==
{{Anchor|Sound Channel Frequency}}
=== Sound Channel Frequency ($80, $81; $82, $83; $84, $85; $86, $87) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
.... .ddd dddd dddd
||| |||| ||||
+++--++++-++++- Frequency divisor
</pre>
This frequency is used for wavetable output. It is calculated as follows: <code>sample rate = 3072000 Hz / (2048 - divisor)</code>.
Note that this refers to the sample rate of each sample in the ''wavetable'', and needs to be scaled accordingly for a given waveform. For example, a 50% duty square wave (16 samples of <tt>0</tt> followed by 16 samples of <tt>15</tt>) will have an effective sample rate of <code>(3072000 / 32) Hz / (2048 - divisor)</code>, or <code> 96000 Hz / (2048 - divisor)</code>.
{{Anchor|Sound Channel Volume}}
=== Sound Channel Volume ($88; $89; $8A; $8B) ===
<pre>
7 bit 0
---------
llll rrrr
|||| ||||
|||| ++++- Right channel volume (0-15)
++++------ Left channel volume (0-15)
</pre>
This volume is used for wavetable output.
The calculation to get an unsigned 8-bit sample out of a 4-bit wavetable sample / 4-bit volume pair is simple: <code>out_sample = sample * volume</code>. This means that the maximum sample in wavetable output mode is <code>15 * 15 = 225</code>.
{{Anchor|Sound Channel 2 Voice Sample}}
=== Sound Channel 2 Voice Sample ($89) ===
<pre>
7 bit 0
---- ----
ssss ssss
|||| ||||
++++-++++- Unsigned 8-bit PCM sample (0-255)
</pre>
This sample is used for voice output.
{{Anchor|Sound Channel 3 Sweep Amount}}
=== Sound Channel 3 Sweep Amount ($8C) ===
<pre>
7 bit 0
---- ----
vvvv vvvv
|||| ||||
++++-++++- Value; 8-bit, signed.
</pre>
This port is used for wavetable output with sweep enabled.
The signed value in this port will be added to the frequency divider for channel 3 every sweep step (as determined by the Sweep Ticks port). Wraparound is present - adding 1 to a frequency divider value of 2047 will cause it to roll over back to 0.
{{Anchor|Sound Channel 3 Sweep Ticks}}
=== Sound Channel 3 Sweep Ticks ($8D) ===
<pre>
7 bit 0
---- ----
...t tttt
| ||||
+-++++- Ticks per step - 1
</pre>
This port is used for wavetable output with sweep enabled.
Every <code>ttttt + 1</code> ticks, clocked at 375 Hz, the value in the Sweep Amount port will be added to the frequency divider for channel 3.
{{Anchor|Sound Channel 4 Noise Control}}
=== Sound Channel 4 Noise Control ($8E) ===
<pre>
7 bit 0
---- ----
...e rttt
| ||||
| |+++- LFSR tap mode
| +---- LFSR reset: 1 = reset shift register
+------ LFSR enabled: 0 = off, 1 = on
</pre>
This port is used for noise output.
{| class="wikitable"
|+ List of LFSR tap modes
! Tap mode
! Tap bit
! Sequence length
|-
| 0
| 14
| 32767
|-
| 1
| 10
| 1953
|-
| 2
| 13
| 254
|-
| 3
| 4
| 217
|-
| 4
| 8
| 73
|-
| 5
| 6
| 63
|-
| 6
| 9
| 42
|-
| 7
| 11
| 28
|}
Noise output works using the following algorithm, performed once per sample generated:
# Create a new bit by inverting the XOR of bit 7 with the tap bit.
# Shift the LFSR register one bit to the left.
# Write the new bit as bit 0.
# Use the new bit as if it were a wavetable sample: 0 = 0, 1 = 15.
Note that, for the LFSR register to advance, all three of: the channel 4 enable bit, the channel 4 noise mode bit, and the LFSR enable bit have to be set.
{{Anchor|Sound Wavetable Address}}
=== Sound Wavetable Address ($8F) ===
<pre>
7 bit 0
---- ----
wwww wwww
|||| ||||
++++-++++- Wavetable address (bits 6-13)
</pre>
The wavetable is 4 x 16 bytes long; each 16-byte block contains 32 4-bit samples for the relevant channel:
<pre>
Address $00 $01 $02 $03 $04 $05 $06 $07 $08 $09 $0A $0B $0C $0D $0E $0F
98 CB ED FF FF EF BD 8A 57 24 01 00 00 21 43 76
Sample
15 .. .. .. ## ## #. .. .. .. .. .. .. .. .. .. ..
14 .. .. .# || || |# .. .. .. .. .. .. .. .. .. ..
13 .. .. #| || || || #. .. .. .. .. .. .. .. .. ..
12 .. .# || || || || |. .. .. .. .. .. .. .. .. ..
11 .. #| || || || || |# .. .. .. .. .. .. .. .. ..
10 .. || || || || || || #. .. .. .. .. .. .. .. ..
9 .# || || || || || || |. .. .. .. .. .. .. .. ..
8 #| || || || || || || |# .. .. .. .. .. .. .. ..
7 || || || || || || || || #. .. .. .. .. .. .. .#
6 || || || || || || || || |. .. .. .. .. .. .. #|
5 || || || || || || || || |# .. .. .. .. .. .. ||
4 || || || || || || || || || #. .. .. .. .. .# ||
3 || || || || || || || || || |. .. .. .. .. #| ||
2 || || || || || || || || || |# .. .. .. .# || ||
1 || || || || || || || || || || #. .. .. #| || ||
0 || || || || || || || || || || |# ## ## || || ||
</pre>
Note that the ''higher'' bits - the first hexadecimal number - specify the ''later'' samples; that is to say, the nybbles of each sample are swapped relative to the wave drawing.
{{Anchor|Sound Channel Control}}
=== Sound Channel Control ($90) ===
<pre>
7 bit 0
---- ----
nsv. 4321
||| ||||
||| |||+- Channel 1 enable
||| ||+-- Channel 2 enable
||| |+--- Channel 3 enable
||| +---- Channel 4 enable
||+------- Channel 2 mode: 0 = wavetable, 1 = voice
|+-------- Channel 3 sweep: 0 = disable, 1 = enable
+--------- Channel 4 mode: 0 = wavetable, 1 = noise
</pre>
Note that:
* Channel 1-4 enable bits also control whether or not the sample period counters are active.
* Channel 2's voice mode (bit 5) does not require channel 2's wavetable mode (bit 1) to be enabled.
* Conversely, Channel 4's noise mode (bit 7) ''does'' require channel 4's wavetable mode (bit 3) to be enabled.
{{Anchor|Sound Output Control}}
=== Sound Output Control ($91) ===
<pre>
7 bit 0
---- ----
H... hrrs
| ||||
| |||+- Internal speaker output enable
| |++-- Internal speaker shift/volume:
| | 0 = 100% 1 = 50%
| | 2 = 25% 3 = 12.5%
| +---- Headphone output enable
+--------- Headphones connected, 1 if true
</pre>
For correct playback on the internal speaker, it is important to set the shift/volume correctly, to match the peak summed output of the first four channels. If the value is too low, music using multiple loud channels will wrap, causing audible distortion. If the value is too high, single-channel PCM sample playback will be very quiet.
{{Anchor|Sound Channel 4 LFSR Register}}
=== Sound Channel 4 LFSR Register ($92, $93 read) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
.rrr rrrr rrrr rrrr
||| |||| |||| ||||
+++-++++--++++-++++- Shift register value
</pre>
{{Anchor|Sound Channel 2 Voice Volume}}
=== Sound Channel 2 Voice Volume ($94) ===
<pre>
7 bit 0
---- ----
.... lLrR
||||
|||+- Right channel 100% volume
||+-- Right channel 50% volume
|+--- Left channel 100% volume
+---- Left channel 50% volume
</pre>
This port is used for voice output.
The <code>50% volume</code> have no effect if their respective <code>100% volume</code> bits are set.
{{Anchor|Sound Test}}
=== Sound Test ($95) ===
<pre>
7 bit 0
---- ----
??5? llsh
| ||||
| |||+- Hold Ch1-4 output updates
| ||+-- Use 3072000 Hz CPU clock for sweep
| ++--- Hold noise LFSR output
| (Differences between bit 2/3
| behavior are unknown)
+------- Force L10/R10 outputs to (channel 2 voice output * 5) & 0x3FF
</pre>
{{Anchor|Sound Channel Output Right}}
=== Sound Channel Output Right ($96, $97 read) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
.... ..ss ssss ssss
|| |||| ||||
++--++++-++++- Unsigned 10-bit sample
</pre>
{{Anchor|Sound Channel Output Left}}
=== Sound Channel Output Left ($98, $99 read) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
.... ..ss ssss ssss
|| |||| ||||
++--++++-++++- Unsigned 10-bit sample
</pre>
{{Anchor|Sound Channel Output Sum}}
=== Sound Channel Output Sum ($9A, $9B read) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
.... .sss ssss ssss
||| |||| ||||
+++--++++-++++- Unsigned 11-bit sample
</pre>
{{Anchor|Sound Speaker Main Volume}}
=== Sound Speaker Main Volume ($9E) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
.... .... .... ..vv
||
++- Built-in speaker output volume
</pre>
Writing to this port changes the output volume of the built-in speaker.
While it functions the same way as the SOUND button (and affects the same internal register), pressing the SOUND button does ''not'' update this port's value. However, manual writes do, and those values can be read out.
This port does not affect the headphone output in any way, just like the SOUND button.
TODO: The exact volume levels have not been verified; it's probably either 0, 25, 50, 100% or 0, ~33, ~67, 100%.
0853b2090060a9193baaa794899ce0e718eb03b9
558
557
2025-03-09T20:27:49Z
Asie
351
/* Sound Channel Frequency ($80, $81; $82, $83; $84, $85; $86, $87) */
wikitext
text/x-wiki
The WonderSwan features the following sound hardware:
* Four audio channels:
** channel 1 - wavetable (32 x 4-bit samples),
** channel 2 - wavetable or 8-bit unsigned PCM sample,
** channel 3 - wavetable with optional hardware sweep,
** channel 4 - wavetable or LFSR noise,
* [[Hyper Voice]]<sup>(color)</sup> - headphone output exclusive 16-bit stereo PCM output,
* 24000 Hz output:
** internal speaker - 8-bit, mono,
** headphone output - 16-bit, stereo.
[[Hyper Voice]] functionality is documented on its own sub-page.
== Mixing diagram ==
The sound is mixed as follows:
<pre>
Ch1 Ch2 Ch3 Ch4 Glossary: L = left, R = right, M = mono
| | | | Mnn = nn-bit mono
8 8 8 8 port $98 port $nn = value port
| | | | /
_V___V___V___V_ / _____ _____
| |--L10------+----->| | | |
| + | | | + |--M11-->| >>r |--M8--> Speaker output
|_______________|--R10------|-+--->|_____| / |_____|
/ _|_|_ / (r=0...3)
/ | | / \
port $96 | <<5 | port $9A \
|_____| \
| | port $91
| |
port $68 port $64 | |
/ _______________ \ __V_V__ _____
L8-->| (Color only) |--L16-->| |----------L16-->| |
| Hyper Voice | | + + | | I2S |------> Headphone output
R8-->|_______________|--R16-->|_______|----------R16-->|_____|
\ /
port $69 port $66
</pre>
== I/O Ports ==
{{Anchor|Sound Channel Frequency}}
=== Sound Channel Frequency ($80, $81; $82, $83; $84, $85; $86, $87) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
.... .ddd dddd dddd
||| |||| ||||
+++--++++-++++- Frequency divisor
</pre>
This value controls the sample period counters. Every <code>2048 - divisor</code> cycles, the index of the sample to be fetched from the wavetable is incremented; in addition, if noise is enabled, the state of the noise LFSR is advanced.
The resulting frequency is calculated as follows: <code>sample rate = 3072000 Hz / (2048 - divisor)</code>.
Note that this refers to the sample rate of each sample in the ''wavetable'', and needs to be scaled accordingly for a given waveform. For example, a 50% duty square wave (16 samples of <tt>0</tt> followed by 16 samples of <tt>15</tt>) will have an effective sample rate of <code>(3072000 / 32) Hz / (2048 - divisor)</code>, or <code> 96000 Hz / (2048 - divisor)</code>.
{{Anchor|Sound Channel Volume}}
=== Sound Channel Volume ($88; $89; $8A; $8B) ===
<pre>
7 bit 0
---------
llll rrrr
|||| ||||
|||| ++++- Right channel volume (0-15)
++++------ Left channel volume (0-15)
</pre>
This volume is used for wavetable output.
The calculation to get an unsigned 8-bit sample out of a 4-bit wavetable sample / 4-bit volume pair is simple: <code>out_sample = sample * volume</code>. This means that the maximum sample in wavetable output mode is <code>15 * 15 = 225</code>.
{{Anchor|Sound Channel 2 Voice Sample}}
=== Sound Channel 2 Voice Sample ($89) ===
<pre>
7 bit 0
---- ----
ssss ssss
|||| ||||
++++-++++- Unsigned 8-bit PCM sample (0-255)
</pre>
This sample is used for voice output.
{{Anchor|Sound Channel 3 Sweep Amount}}
=== Sound Channel 3 Sweep Amount ($8C) ===
<pre>
7 bit 0
---- ----
vvvv vvvv
|||| ||||
++++-++++- Value; 8-bit, signed.
</pre>
This port is used for wavetable output with sweep enabled.
The signed value in this port will be added to the frequency divider for channel 3 every sweep step (as determined by the Sweep Ticks port). Wraparound is present - adding 1 to a frequency divider value of 2047 will cause it to roll over back to 0.
{{Anchor|Sound Channel 3 Sweep Ticks}}
=== Sound Channel 3 Sweep Ticks ($8D) ===
<pre>
7 bit 0
---- ----
...t tttt
| ||||
+-++++- Ticks per step - 1
</pre>
This port is used for wavetable output with sweep enabled.
Every <code>ttttt + 1</code> ticks, clocked at 375 Hz, the value in the Sweep Amount port will be added to the frequency divider for channel 3.
{{Anchor|Sound Channel 4 Noise Control}}
=== Sound Channel 4 Noise Control ($8E) ===
<pre>
7 bit 0
---- ----
...e rttt
| ||||
| |+++- LFSR tap mode
| +---- LFSR reset: 1 = reset shift register
+------ LFSR enabled: 0 = off, 1 = on
</pre>
This port is used for noise output.
{| class="wikitable"
|+ List of LFSR tap modes
! Tap mode
! Tap bit
! Sequence length
|-
| 0
| 14
| 32767
|-
| 1
| 10
| 1953
|-
| 2
| 13
| 254
|-
| 3
| 4
| 217
|-
| 4
| 8
| 73
|-
| 5
| 6
| 63
|-
| 6
| 9
| 42
|-
| 7
| 11
| 28
|}
Noise output works using the following algorithm, performed once per sample generated:
# Create a new bit by inverting the XOR of bit 7 with the tap bit.
# Shift the LFSR register one bit to the left.
# Write the new bit as bit 0.
# Use the new bit as if it were a wavetable sample: 0 = 0, 1 = 15.
Note that, for the LFSR register to advance, all three of: the channel 4 enable bit, the channel 4 noise mode bit, and the LFSR enable bit have to be set.
{{Anchor|Sound Wavetable Address}}
=== Sound Wavetable Address ($8F) ===
<pre>
7 bit 0
---- ----
wwww wwww
|||| ||||
++++-++++- Wavetable address (bits 6-13)
</pre>
The wavetable is 4 x 16 bytes long; each 16-byte block contains 32 4-bit samples for the relevant channel:
<pre>
Address $00 $01 $02 $03 $04 $05 $06 $07 $08 $09 $0A $0B $0C $0D $0E $0F
98 CB ED FF FF EF BD 8A 57 24 01 00 00 21 43 76
Sample
15 .. .. .. ## ## #. .. .. .. .. .. .. .. .. .. ..
14 .. .. .# || || |# .. .. .. .. .. .. .. .. .. ..
13 .. .. #| || || || #. .. .. .. .. .. .. .. .. ..
12 .. .# || || || || |. .. .. .. .. .. .. .. .. ..
11 .. #| || || || || |# .. .. .. .. .. .. .. .. ..
10 .. || || || || || || #. .. .. .. .. .. .. .. ..
9 .# || || || || || || |. .. .. .. .. .. .. .. ..
8 #| || || || || || || |# .. .. .. .. .. .. .. ..
7 || || || || || || || || #. .. .. .. .. .. .. .#
6 || || || || || || || || |. .. .. .. .. .. .. #|
5 || || || || || || || || |# .. .. .. .. .. .. ||
4 || || || || || || || || || #. .. .. .. .. .# ||
3 || || || || || || || || || |. .. .. .. .. #| ||
2 || || || || || || || || || |# .. .. .. .# || ||
1 || || || || || || || || || || #. .. .. #| || ||
0 || || || || || || || || || || |# ## ## || || ||
</pre>
Note that the ''higher'' bits - the first hexadecimal number - specify the ''later'' samples; that is to say, the nybbles of each sample are swapped relative to the wave drawing.
{{Anchor|Sound Channel Control}}
=== Sound Channel Control ($90) ===
<pre>
7 bit 0
---- ----
nsv. 4321
||| ||||
||| |||+- Channel 1 enable
||| ||+-- Channel 2 enable
||| |+--- Channel 3 enable
||| +---- Channel 4 enable
||+------- Channel 2 mode: 0 = wavetable, 1 = voice
|+-------- Channel 3 sweep: 0 = disable, 1 = enable
+--------- Channel 4 mode: 0 = wavetable, 1 = noise
</pre>
Note that:
* Channel 1-4 enable bits also control whether or not the sample period counters are active.
* Channel 2's voice mode (bit 5) does not require channel 2's wavetable mode (bit 1) to be enabled.
* Conversely, Channel 4's noise mode (bit 7) ''does'' require channel 4's wavetable mode (bit 3) to be enabled.
{{Anchor|Sound Output Control}}
=== Sound Output Control ($91) ===
<pre>
7 bit 0
---- ----
H... hrrs
| ||||
| |||+- Internal speaker output enable
| |++-- Internal speaker shift/volume:
| | 0 = 100% 1 = 50%
| | 2 = 25% 3 = 12.5%
| +---- Headphone output enable
+--------- Headphones connected, 1 if true
</pre>
For correct playback on the internal speaker, it is important to set the shift/volume correctly, to match the peak summed output of the first four channels. If the value is too low, music using multiple loud channels will wrap, causing audible distortion. If the value is too high, single-channel PCM sample playback will be very quiet.
{{Anchor|Sound Channel 4 LFSR Register}}
=== Sound Channel 4 LFSR Register ($92, $93 read) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
.rrr rrrr rrrr rrrr
||| |||| |||| ||||
+++-++++--++++-++++- Shift register value
</pre>
{{Anchor|Sound Channel 2 Voice Volume}}
=== Sound Channel 2 Voice Volume ($94) ===
<pre>
7 bit 0
---- ----
.... lLrR
||||
|||+- Right channel 100% volume
||+-- Right channel 50% volume
|+--- Left channel 100% volume
+---- Left channel 50% volume
</pre>
This port is used for voice output.
The <code>50% volume</code> have no effect if their respective <code>100% volume</code> bits are set.
{{Anchor|Sound Test}}
=== Sound Test ($95) ===
<pre>
7 bit 0
---- ----
??5? llsh
| ||||
| |||+- Hold Ch1-4 output updates
| ||+-- Use 3072000 Hz CPU clock for sweep
| ++--- Hold noise LFSR output
| (Differences between bit 2/3
| behavior are unknown)
+------- Force L10/R10 outputs to (channel 2 voice output * 5) & 0x3FF
</pre>
{{Anchor|Sound Channel Output Right}}
=== Sound Channel Output Right ($96, $97 read) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
.... ..ss ssss ssss
|| |||| ||||
++--++++-++++- Unsigned 10-bit sample
</pre>
{{Anchor|Sound Channel Output Left}}
=== Sound Channel Output Left ($98, $99 read) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
.... ..ss ssss ssss
|| |||| ||||
++--++++-++++- Unsigned 10-bit sample
</pre>
{{Anchor|Sound Channel Output Sum}}
=== Sound Channel Output Sum ($9A, $9B read) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
.... .sss ssss ssss
||| |||| ||||
+++--++++-++++- Unsigned 11-bit sample
</pre>
{{Anchor|Sound Speaker Main Volume}}
=== Sound Speaker Main Volume ($9E) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
.... .... .... ..vv
||
++- Built-in speaker output volume
</pre>
Writing to this port changes the output volume of the built-in speaker.
While it functions the same way as the SOUND button (and affects the same internal register), pressing the SOUND button does ''not'' update this port's value. However, manual writes do, and those values can be read out.
This port does not affect the headphone output in any way, just like the SOUND button.
TODO: The exact volume levels have not been verified; it's probably either 0, 25, 50, 100% or 0, ~33, ~67, 100%.
d6b191e7088bc82b3d596a34c0719c1522c7442d
559
558
2025-03-09T20:29:25Z
Asie
351
wikitext
text/x-wiki
The WonderSwan features the following sound hardware:
* Four audio channels:
** channel 1 - wavetable (32 x 4-bit samples),
** channel 2 - wavetable or 8-bit unsigned PCM sample,
** channel 3 - wavetable with optional hardware sweep,
** channel 4 - wavetable or LFSR noise,
* [[Hyper Voice]]<sup>(color)</sup> - headphone output exclusive 16-bit stereo PCM output,
* 24000 Hz output:
** internal speaker - 8-bit, mono,
** headphone output - 16-bit, stereo.
[[Hyper Voice]] functionality is documented on its own sub-page.
== Mixing diagram ==
The sound is mixed as follows:
<pre>
Ch1 Ch2 Ch3 Ch4 Glossary: L = left, R = right, M = mono
| | | | Mnn = nn-bit mono
8 8 8 8 port $98 port $nn = value port
| | | | /
_V___V___V___V_ / _____ _____
| |--L10------+----->| | | |
| + | | | + |--M11-->| >>r |--M8--> Speaker output
|_______________|--R10------|-+--->|_____| / |_____|
/ _|_|_ / (r=0...3)
/ | | / \
port $96 | <<5 | port $9A \
|_____| \
| | port $91
| |
port $68 port $64 | |
/ _______________ \ __V_V__ _____
L8-->| (Color only) |--L16-->| |----------L16-->| |
| Hyper Voice | | + + | | I2S |------> Headphone output
R8-->|_______________|--R16-->|_______|----------R16-->|_____|
\ /
port $69 port $66
</pre>
== Wavetable RAM ==
The wavetable RAM is an user-configurable 64-byte area of memory which stores four 16-byte waveforms. Each waveform contains 32 4-bit samples for the respective channel (from 1 to 4):
<pre>
Address $00 $01 $02 $03 $04 $05 $06 $07 $08 $09 $0A $0B $0C $0D $0E $0F
98 CB ED FF FF EF BD 8A 57 24 01 00 00 21 43 76
Sample
15 .. .. .. ## ## #. .. .. .. .. .. .. .. .. .. ..
14 .. .. .# || || |# .. .. .. .. .. .. .. .. .. ..
13 .. .. #| || || || #. .. .. .. .. .. .. .. .. ..
12 .. .# || || || || |. .. .. .. .. .. .. .. .. ..
11 .. #| || || || || |# .. .. .. .. .. .. .. .. ..
10 .. || || || || || || #. .. .. .. .. .. .. .. ..
9 .# || || || || || || |. .. .. .. .. .. .. .. ..
8 #| || || || || || || |# .. .. .. .. .. .. .. ..
7 || || || || || || || || #. .. .. .. .. .. .. .#
6 || || || || || || || || |. .. .. .. .. .. .. #|
5 || || || || || || || || |# .. .. .. .. .. .. ||
4 || || || || || || || || || #. .. .. .. .. .# ||
3 || || || || || || || || || |. .. .. .. .. #| ||
2 || || || || || || || || || |# .. .. .. .# || ||
1 || || || || || || || || || || #. .. .. #| || ||
0 || || || || || || || || || || |# ## ## || || ||
</pre>
Note that the ''higher'' bits - the first hexadecimal number - specify the ''later'' samples; that is to say, the nybbles of each sample are swapped relative to the wave drawing.
The current sample to be played (from 0 to 31) is selected by an internal sample index counter; there is no known way to reset this counter.
== I/O Ports ==
{{Anchor|Sound Channel Frequency}}
=== Sound Channel Frequency ($80, $81; $82, $83; $84, $85; $86, $87) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
.... .ddd dddd dddd
||| |||| ||||
+++--++++-++++- Frequency divisor
</pre>
This value controls the sample period counters. Every <code>2048 - divisor</code> cycles, the index of the sample to be fetched from the wavetable is incremented; in addition, if noise is enabled, the state of the noise LFSR is advanced.
The resulting frequency is calculated as follows: <code>sample rate = 3072000 Hz / (2048 - divisor)</code>.
Note that this refers to the sample rate of each sample in the ''wavetable'', and needs to be scaled accordingly for a given waveform. For example, a 50% duty square wave (16 samples of <tt>0</tt> followed by 16 samples of <tt>15</tt>) will have an effective sample rate of <code>(3072000 / 32) Hz / (2048 - divisor)</code>, or <code> 96000 Hz / (2048 - divisor)</code>.
{{Anchor|Sound Channel Volume}}
=== Sound Channel Volume ($88; $89; $8A; $8B) ===
<pre>
7 bit 0
---------
llll rrrr
|||| ||||
|||| ++++- Right channel volume (0-15)
++++------ Left channel volume (0-15)
</pre>
This volume is used for wavetable output.
The calculation to get an unsigned 8-bit sample out of a 4-bit wavetable sample / 4-bit volume pair is simple: <code>out_sample = sample * volume</code>. This means that the maximum sample in wavetable output mode is <code>15 * 15 = 225</code>.
{{Anchor|Sound Channel 2 Voice Sample}}
=== Sound Channel 2 Voice Sample ($89) ===
<pre>
7 bit 0
---- ----
ssss ssss
|||| ||||
++++-++++- Unsigned 8-bit PCM sample (0-255)
</pre>
This sample is used for voice output.
{{Anchor|Sound Channel 3 Sweep Amount}}
=== Sound Channel 3 Sweep Amount ($8C) ===
<pre>
7 bit 0
---- ----
vvvv vvvv
|||| ||||
++++-++++- Value; 8-bit, signed.
</pre>
This port is used for wavetable output with sweep enabled.
The signed value in this port will be added to the frequency divider for channel 3 every sweep step (as determined by the Sweep Ticks port). Wraparound is present - adding 1 to a frequency divider value of 2047 will cause it to roll over back to 0.
{{Anchor|Sound Channel 3 Sweep Ticks}}
=== Sound Channel 3 Sweep Ticks ($8D) ===
<pre>
7 bit 0
---- ----
...t tttt
| ||||
+-++++- Ticks per step - 1
</pre>
This port is used for wavetable output with sweep enabled.
Every <code>ttttt + 1</code> ticks, clocked at 375 Hz, the value in the Sweep Amount port will be added to the frequency divider for channel 3.
{{Anchor|Sound Channel 4 Noise Control}}
=== Sound Channel 4 Noise Control ($8E) ===
<pre>
7 bit 0
---- ----
...e rttt
| ||||
| |+++- LFSR tap mode
| +---- LFSR reset: 1 = reset shift register
+------ LFSR enabled: 0 = off, 1 = on
</pre>
This port is used for noise output.
{| class="wikitable"
|+ List of LFSR tap modes
! Tap mode
! Tap bit
! Sequence length
|-
| 0
| 14
| 32767
|-
| 1
| 10
| 1953
|-
| 2
| 13
| 254
|-
| 3
| 4
| 217
|-
| 4
| 8
| 73
|-
| 5
| 6
| 63
|-
| 6
| 9
| 42
|-
| 7
| 11
| 28
|}
Noise output works using the following algorithm, performed once per sample generated:
# Create a new bit by inverting the XOR of bit 7 with the tap bit.
# Shift the LFSR register one bit to the left.
# Write the new bit as bit 0.
# Use the new bit as if it were a wavetable sample: 0 = 0, 1 = 15.
Note that, for the LFSR register to advance, all three of: the channel 4 enable bit, the channel 4 noise mode bit, and the LFSR enable bit have to be set.
{{Anchor|Sound Wavetable Address}}
=== Sound Wavetable Address ($8F) ===
<pre>
7 bit 0
---- ----
wwww wwww
|||| ||||
++++-++++- Wavetable address (bits 6-13)
</pre>
{{Anchor|Sound Channel Control}}
=== Sound Channel Control ($90) ===
<pre>
7 bit 0
---- ----
nsv. 4321
||| ||||
||| |||+- Channel 1 enable
||| ||+-- Channel 2 enable
||| |+--- Channel 3 enable
||| +---- Channel 4 enable
||+------- Channel 2 mode: 0 = wavetable, 1 = voice
|+-------- Channel 3 sweep: 0 = disable, 1 = enable
+--------- Channel 4 mode: 0 = wavetable, 1 = noise
</pre>
Note that:
* Channel 1-4 enable bits also control whether or not the sample period counters are active.
* Channel 2's voice mode (bit 5) does not require channel 2's wavetable mode (bit 1) to be enabled.
* Conversely, Channel 4's noise mode (bit 7) ''does'' require channel 4's wavetable mode (bit 3) to be enabled.
{{Anchor|Sound Output Control}}
=== Sound Output Control ($91) ===
<pre>
7 bit 0
---- ----
H... hrrs
| ||||
| |||+- Internal speaker output enable
| |++-- Internal speaker shift/volume:
| | 0 = 100% 1 = 50%
| | 2 = 25% 3 = 12.5%
| +---- Headphone output enable
+--------- Headphones connected, 1 if true
</pre>
For correct playback on the internal speaker, it is important to set the shift/volume correctly, to match the peak summed output of the first four channels. If the value is too low, music using multiple loud channels will wrap, causing audible distortion. If the value is too high, single-channel PCM sample playback will be very quiet.
{{Anchor|Sound Channel 4 LFSR Register}}
=== Sound Channel 4 LFSR Register ($92, $93 read) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
.rrr rrrr rrrr rrrr
||| |||| |||| ||||
+++-++++--++++-++++- Shift register value
</pre>
{{Anchor|Sound Channel 2 Voice Volume}}
=== Sound Channel 2 Voice Volume ($94) ===
<pre>
7 bit 0
---- ----
.... lLrR
||||
|||+- Right channel 100% volume
||+-- Right channel 50% volume
|+--- Left channel 100% volume
+---- Left channel 50% volume
</pre>
This port is used for voice output.
The <code>50% volume</code> have no effect if their respective <code>100% volume</code> bits are set.
{{Anchor|Sound Test}}
=== Sound Test ($95) ===
<pre>
7 bit 0
---- ----
??5? llsh
| ||||
| |||+- Hold Ch1-4 output updates
| ||+-- Use 3072000 Hz CPU clock for sweep
| ++--- Hold noise LFSR output
| (Differences between bit 2/3
| behavior are unknown)
+------- Force L10/R10 outputs to (channel 2 voice output * 5) & 0x3FF
</pre>
{{Anchor|Sound Channel Output Right}}
=== Sound Channel Output Right ($96, $97 read) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
.... ..ss ssss ssss
|| |||| ||||
++--++++-++++- Unsigned 10-bit sample
</pre>
{{Anchor|Sound Channel Output Left}}
=== Sound Channel Output Left ($98, $99 read) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
.... ..ss ssss ssss
|| |||| ||||
++--++++-++++- Unsigned 10-bit sample
</pre>
{{Anchor|Sound Channel Output Sum}}
=== Sound Channel Output Sum ($9A, $9B read) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
.... .sss ssss ssss
||| |||| ||||
+++--++++-++++- Unsigned 11-bit sample
</pre>
{{Anchor|Sound Speaker Main Volume}}
=== Sound Speaker Main Volume ($9E) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
.... .... .... ..vv
||
++- Built-in speaker output volume
</pre>
Writing to this port changes the output volume of the built-in speaker.
While it functions the same way as the SOUND button (and affects the same internal register), pressing the SOUND button does ''not'' update this port's value. However, manual writes do, and those values can be read out.
This port does not affect the headphone output in any way, just like the SOUND button.
TODO: The exact volume levels have not been verified; it's probably either 0, 25, 50, 100% or 0, ~33, ~67, 100%.
4f91785701333edd4979836fadbca8f2b760b3f3
560
559
2025-03-09T20:31:39Z
Asie
351
/* Sound Channel 2 Voice Sample ($89) */
wikitext
text/x-wiki
The WonderSwan features the following sound hardware:
* Four audio channels:
** channel 1 - wavetable (32 x 4-bit samples),
** channel 2 - wavetable or 8-bit unsigned PCM sample,
** channel 3 - wavetable with optional hardware sweep,
** channel 4 - wavetable or LFSR noise,
* [[Hyper Voice]]<sup>(color)</sup> - headphone output exclusive 16-bit stereo PCM output,
* 24000 Hz output:
** internal speaker - 8-bit, mono,
** headphone output - 16-bit, stereo.
[[Hyper Voice]] functionality is documented on its own sub-page.
== Mixing diagram ==
The sound is mixed as follows:
<pre>
Ch1 Ch2 Ch3 Ch4 Glossary: L = left, R = right, M = mono
| | | | Mnn = nn-bit mono
8 8 8 8 port $98 port $nn = value port
| | | | /
_V___V___V___V_ / _____ _____
| |--L10------+----->| | | |
| + | | | + |--M11-->| >>r |--M8--> Speaker output
|_______________|--R10------|-+--->|_____| / |_____|
/ _|_|_ / (r=0...3)
/ | | / \
port $96 | <<5 | port $9A \
|_____| \
| | port $91
| |
port $68 port $64 | |
/ _______________ \ __V_V__ _____
L8-->| (Color only) |--L16-->| |----------L16-->| |
| Hyper Voice | | + + | | I2S |------> Headphone output
R8-->|_______________|--R16-->|_______|----------R16-->|_____|
\ /
port $69 port $66
</pre>
== Wavetable RAM ==
The wavetable RAM is an user-configurable 64-byte area of memory which stores four 16-byte waveforms. Each waveform contains 32 4-bit samples for the respective channel (from 1 to 4):
<pre>
Address $00 $01 $02 $03 $04 $05 $06 $07 $08 $09 $0A $0B $0C $0D $0E $0F
98 CB ED FF FF EF BD 8A 57 24 01 00 00 21 43 76
Sample
15 .. .. .. ## ## #. .. .. .. .. .. .. .. .. .. ..
14 .. .. .# || || |# .. .. .. .. .. .. .. .. .. ..
13 .. .. #| || || || #. .. .. .. .. .. .. .. .. ..
12 .. .# || || || || |. .. .. .. .. .. .. .. .. ..
11 .. #| || || || || |# .. .. .. .. .. .. .. .. ..
10 .. || || || || || || #. .. .. .. .. .. .. .. ..
9 .# || || || || || || |. .. .. .. .. .. .. .. ..
8 #| || || || || || || |# .. .. .. .. .. .. .. ..
7 || || || || || || || || #. .. .. .. .. .. .. .#
6 || || || || || || || || |. .. .. .. .. .. .. #|
5 || || || || || || || || |# .. .. .. .. .. .. ||
4 || || || || || || || || || #. .. .. .. .. .# ||
3 || || || || || || || || || |. .. .. .. .. #| ||
2 || || || || || || || || || |# .. .. .. .# || ||
1 || || || || || || || || || || #. .. .. #| || ||
0 || || || || || || || || || || |# ## ## || || ||
</pre>
Note that the ''higher'' bits - the first hexadecimal number - specify the ''later'' samples; that is to say, the nybbles of each sample are swapped relative to the wave drawing.
The current sample to be played (from 0 to 31) is selected by an internal sample index counter; there is no known way to reset this counter.
== I/O Ports ==
{{Anchor|Sound Channel Frequency}}
=== Sound Channel Frequency ($80, $81; $82, $83; $84, $85; $86, $87) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
.... .ddd dddd dddd
||| |||| ||||
+++--++++-++++- Frequency divisor
</pre>
This value controls the sample period counters. Every <code>2048 - divisor</code> cycles, the index of the sample to be fetched from the wavetable is incremented; in addition, if noise is enabled, the state of the noise LFSR is advanced.
The resulting frequency is calculated as follows: <code>sample rate = 3072000 Hz / (2048 - divisor)</code>.
Note that this refers to the sample rate of each sample in the ''wavetable'', and needs to be scaled accordingly for a given waveform. For example, a 50% duty square wave (16 samples of <tt>0</tt> followed by 16 samples of <tt>15</tt>) will have an effective sample rate of <code>(3072000 / 32) Hz / (2048 - divisor)</code>, or <code> 96000 Hz / (2048 - divisor)</code>.
{{Anchor|Sound Channel Volume}}
=== Sound Channel Volume ($88; $89; $8A; $8B) ===
<pre>
7 bit 0
---------
llll rrrr
|||| ||||
|||| ++++- Right channel volume (0-15)
++++------ Left channel volume (0-15)
</pre>
This volume is used for wavetable output.
The calculation to get an unsigned 8-bit sample out of a 4-bit wavetable sample / 4-bit volume pair is simple: <code>out_sample = sample * volume</code>. This means that the maximum sample in wavetable output mode is <code>15 * 15 = 225</code>.
{{Anchor|Sound Channel 2 Voice Sample}}
=== Sound Channel 2 Voice Sample ($89) ===
<pre>
7 bit 0
---- ----
ssss ssss
|||| ||||
++++-++++- Unsigned 8-bit PCM sample (0-255)
</pre>
This sample is used for channel 2's voice output mode.
{{Anchor|Sound Channel 3 Sweep Amount}}
=== Sound Channel 3 Sweep Amount ($8C) ===
<pre>
7 bit 0
---- ----
vvvv vvvv
|||| ||||
++++-++++- Value; 8-bit, signed.
</pre>
This port is used for wavetable output with sweep enabled.
The signed value in this port will be added to the frequency divider for channel 3 every sweep step (as determined by the Sweep Ticks port). Wraparound is present - adding 1 to a frequency divider value of 2047 will cause it to roll over back to 0.
{{Anchor|Sound Channel 3 Sweep Ticks}}
=== Sound Channel 3 Sweep Ticks ($8D) ===
<pre>
7 bit 0
---- ----
...t tttt
| ||||
+-++++- Ticks per step - 1
</pre>
This port is used for wavetable output with sweep enabled.
Every <code>ttttt + 1</code> ticks, clocked at 375 Hz, the value in the Sweep Amount port will be added to the frequency divider for channel 3.
{{Anchor|Sound Channel 4 Noise Control}}
=== Sound Channel 4 Noise Control ($8E) ===
<pre>
7 bit 0
---- ----
...e rttt
| ||||
| |+++- LFSR tap mode
| +---- LFSR reset: 1 = reset shift register
+------ LFSR enabled: 0 = off, 1 = on
</pre>
This port is used for noise output.
{| class="wikitable"
|+ List of LFSR tap modes
! Tap mode
! Tap bit
! Sequence length
|-
| 0
| 14
| 32767
|-
| 1
| 10
| 1953
|-
| 2
| 13
| 254
|-
| 3
| 4
| 217
|-
| 4
| 8
| 73
|-
| 5
| 6
| 63
|-
| 6
| 9
| 42
|-
| 7
| 11
| 28
|}
Noise output works using the following algorithm, performed once per sample generated:
# Create a new bit by inverting the XOR of bit 7 with the tap bit.
# Shift the LFSR register one bit to the left.
# Write the new bit as bit 0.
# Use the new bit as if it were a wavetable sample: 0 = 0, 1 = 15.
Note that, for the LFSR register to advance, all three of: the channel 4 enable bit, the channel 4 noise mode bit, and the LFSR enable bit have to be set.
{{Anchor|Sound Wavetable Address}}
=== Sound Wavetable Address ($8F) ===
<pre>
7 bit 0
---- ----
wwww wwww
|||| ||||
++++-++++- Wavetable address (bits 6-13)
</pre>
{{Anchor|Sound Channel Control}}
=== Sound Channel Control ($90) ===
<pre>
7 bit 0
---- ----
nsv. 4321
||| ||||
||| |||+- Channel 1 enable
||| ||+-- Channel 2 enable
||| |+--- Channel 3 enable
||| +---- Channel 4 enable
||+------- Channel 2 mode: 0 = wavetable, 1 = voice
|+-------- Channel 3 sweep: 0 = disable, 1 = enable
+--------- Channel 4 mode: 0 = wavetable, 1 = noise
</pre>
Note that:
* Channel 1-4 enable bits also control whether or not the sample period counters are active.
* Channel 2's voice mode (bit 5) does not require channel 2's wavetable mode (bit 1) to be enabled.
* Conversely, Channel 4's noise mode (bit 7) ''does'' require channel 4's wavetable mode (bit 3) to be enabled.
{{Anchor|Sound Output Control}}
=== Sound Output Control ($91) ===
<pre>
7 bit 0
---- ----
H... hrrs
| ||||
| |||+- Internal speaker output enable
| |++-- Internal speaker shift/volume:
| | 0 = 100% 1 = 50%
| | 2 = 25% 3 = 12.5%
| +---- Headphone output enable
+--------- Headphones connected, 1 if true
</pre>
For correct playback on the internal speaker, it is important to set the shift/volume correctly, to match the peak summed output of the first four channels. If the value is too low, music using multiple loud channels will wrap, causing audible distortion. If the value is too high, single-channel PCM sample playback will be very quiet.
{{Anchor|Sound Channel 4 LFSR Register}}
=== Sound Channel 4 LFSR Register ($92, $93 read) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
.rrr rrrr rrrr rrrr
||| |||| |||| ||||
+++-++++--++++-++++- Shift register value
</pre>
{{Anchor|Sound Channel 2 Voice Volume}}
=== Sound Channel 2 Voice Volume ($94) ===
<pre>
7 bit 0
---- ----
.... lLrR
||||
|||+- Right channel 100% volume
||+-- Right channel 50% volume
|+--- Left channel 100% volume
+---- Left channel 50% volume
</pre>
This port is used for voice output.
The <code>50% volume</code> have no effect if their respective <code>100% volume</code> bits are set.
{{Anchor|Sound Test}}
=== Sound Test ($95) ===
<pre>
7 bit 0
---- ----
??5? llsh
| ||||
| |||+- Hold Ch1-4 output updates
| ||+-- Use 3072000 Hz CPU clock for sweep
| ++--- Hold noise LFSR output
| (Differences between bit 2/3
| behavior are unknown)
+------- Force L10/R10 outputs to (channel 2 voice output * 5) & 0x3FF
</pre>
{{Anchor|Sound Channel Output Right}}
=== Sound Channel Output Right ($96, $97 read) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
.... ..ss ssss ssss
|| |||| ||||
++--++++-++++- Unsigned 10-bit sample
</pre>
{{Anchor|Sound Channel Output Left}}
=== Sound Channel Output Left ($98, $99 read) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
.... ..ss ssss ssss
|| |||| ||||
++--++++-++++- Unsigned 10-bit sample
</pre>
{{Anchor|Sound Channel Output Sum}}
=== Sound Channel Output Sum ($9A, $9B read) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
.... .sss ssss ssss
||| |||| ||||
+++--++++-++++- Unsigned 11-bit sample
</pre>
{{Anchor|Sound Speaker Main Volume}}
=== Sound Speaker Main Volume ($9E) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
.... .... .... ..vv
||
++- Built-in speaker output volume
</pre>
Writing to this port changes the output volume of the built-in speaker.
While it functions the same way as the SOUND button (and affects the same internal register), pressing the SOUND button does ''not'' update this port's value. However, manual writes do, and those values can be read out.
This port does not affect the headphone output in any way, just like the SOUND button.
TODO: The exact volume levels have not been verified; it's probably either 0, 25, 50, 100% or 0, ~33, ~67, 100%.
712b769bc0069fc7bbacb8a78dd3a305d69e7c2d
561
560
2025-03-09T20:32:22Z
Asie
351
/* Sound Channel Control ($90) */
wikitext
text/x-wiki
The WonderSwan features the following sound hardware:
* Four audio channels:
** channel 1 - wavetable (32 x 4-bit samples),
** channel 2 - wavetable or 8-bit unsigned PCM sample,
** channel 3 - wavetable with optional hardware sweep,
** channel 4 - wavetable or LFSR noise,
* [[Hyper Voice]]<sup>(color)</sup> - headphone output exclusive 16-bit stereo PCM output,
* 24000 Hz output:
** internal speaker - 8-bit, mono,
** headphone output - 16-bit, stereo.
[[Hyper Voice]] functionality is documented on its own sub-page.
== Mixing diagram ==
The sound is mixed as follows:
<pre>
Ch1 Ch2 Ch3 Ch4 Glossary: L = left, R = right, M = mono
| | | | Mnn = nn-bit mono
8 8 8 8 port $98 port $nn = value port
| | | | /
_V___V___V___V_ / _____ _____
| |--L10------+----->| | | |
| + | | | + |--M11-->| >>r |--M8--> Speaker output
|_______________|--R10------|-+--->|_____| / |_____|
/ _|_|_ / (r=0...3)
/ | | / \
port $96 | <<5 | port $9A \
|_____| \
| | port $91
| |
port $68 port $64 | |
/ _______________ \ __V_V__ _____
L8-->| (Color only) |--L16-->| |----------L16-->| |
| Hyper Voice | | + + | | I2S |------> Headphone output
R8-->|_______________|--R16-->|_______|----------R16-->|_____|
\ /
port $69 port $66
</pre>
== Wavetable RAM ==
The wavetable RAM is an user-configurable 64-byte area of memory which stores four 16-byte waveforms. Each waveform contains 32 4-bit samples for the respective channel (from 1 to 4):
<pre>
Address $00 $01 $02 $03 $04 $05 $06 $07 $08 $09 $0A $0B $0C $0D $0E $0F
98 CB ED FF FF EF BD 8A 57 24 01 00 00 21 43 76
Sample
15 .. .. .. ## ## #. .. .. .. .. .. .. .. .. .. ..
14 .. .. .# || || |# .. .. .. .. .. .. .. .. .. ..
13 .. .. #| || || || #. .. .. .. .. .. .. .. .. ..
12 .. .# || || || || |. .. .. .. .. .. .. .. .. ..
11 .. #| || || || || |# .. .. .. .. .. .. .. .. ..
10 .. || || || || || || #. .. .. .. .. .. .. .. ..
9 .# || || || || || || |. .. .. .. .. .. .. .. ..
8 #| || || || || || || |# .. .. .. .. .. .. .. ..
7 || || || || || || || || #. .. .. .. .. .. .. .#
6 || || || || || || || || |. .. .. .. .. .. .. #|
5 || || || || || || || || |# .. .. .. .. .. .. ||
4 || || || || || || || || || #. .. .. .. .. .# ||
3 || || || || || || || || || |. .. .. .. .. #| ||
2 || || || || || || || || || |# .. .. .. .# || ||
1 || || || || || || || || || || #. .. .. #| || ||
0 || || || || || || || || || || |# ## ## || || ||
</pre>
Note that the ''higher'' bits - the first hexadecimal number - specify the ''later'' samples; that is to say, the nybbles of each sample are swapped relative to the wave drawing.
The current sample to be played (from 0 to 31) is selected by an internal sample index counter; there is no known way to reset this counter.
== I/O Ports ==
{{Anchor|Sound Channel Frequency}}
=== Sound Channel Frequency ($80, $81; $82, $83; $84, $85; $86, $87) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
.... .ddd dddd dddd
||| |||| ||||
+++--++++-++++- Frequency divisor
</pre>
This value controls the sample period counters. Every <code>2048 - divisor</code> cycles, the index of the sample to be fetched from the wavetable is incremented; in addition, if noise is enabled, the state of the noise LFSR is advanced.
The resulting frequency is calculated as follows: <code>sample rate = 3072000 Hz / (2048 - divisor)</code>.
Note that this refers to the sample rate of each sample in the ''wavetable'', and needs to be scaled accordingly for a given waveform. For example, a 50% duty square wave (16 samples of <tt>0</tt> followed by 16 samples of <tt>15</tt>) will have an effective sample rate of <code>(3072000 / 32) Hz / (2048 - divisor)</code>, or <code> 96000 Hz / (2048 - divisor)</code>.
{{Anchor|Sound Channel Volume}}
=== Sound Channel Volume ($88; $89; $8A; $8B) ===
<pre>
7 bit 0
---------
llll rrrr
|||| ||||
|||| ++++- Right channel volume (0-15)
++++------ Left channel volume (0-15)
</pre>
This volume is used for wavetable output.
The calculation to get an unsigned 8-bit sample out of a 4-bit wavetable sample / 4-bit volume pair is simple: <code>out_sample = sample * volume</code>. This means that the maximum sample in wavetable output mode is <code>15 * 15 = 225</code>.
{{Anchor|Sound Channel 2 Voice Sample}}
=== Sound Channel 2 Voice Sample ($89) ===
<pre>
7 bit 0
---- ----
ssss ssss
|||| ||||
++++-++++- Unsigned 8-bit PCM sample (0-255)
</pre>
This sample is used for channel 2's voice output mode.
{{Anchor|Sound Channel 3 Sweep Amount}}
=== Sound Channel 3 Sweep Amount ($8C) ===
<pre>
7 bit 0
---- ----
vvvv vvvv
|||| ||||
++++-++++- Value; 8-bit, signed.
</pre>
This port is used for wavetable output with sweep enabled.
The signed value in this port will be added to the frequency divider for channel 3 every sweep step (as determined by the Sweep Ticks port). Wraparound is present - adding 1 to a frequency divider value of 2047 will cause it to roll over back to 0.
{{Anchor|Sound Channel 3 Sweep Ticks}}
=== Sound Channel 3 Sweep Ticks ($8D) ===
<pre>
7 bit 0
---- ----
...t tttt
| ||||
+-++++- Ticks per step - 1
</pre>
This port is used for wavetable output with sweep enabled.
Every <code>ttttt + 1</code> ticks, clocked at 375 Hz, the value in the Sweep Amount port will be added to the frequency divider for channel 3.
{{Anchor|Sound Channel 4 Noise Control}}
=== Sound Channel 4 Noise Control ($8E) ===
<pre>
7 bit 0
---- ----
...e rttt
| ||||
| |+++- LFSR tap mode
| +---- LFSR reset: 1 = reset shift register
+------ LFSR enabled: 0 = off, 1 = on
</pre>
This port is used for noise output.
{| class="wikitable"
|+ List of LFSR tap modes
! Tap mode
! Tap bit
! Sequence length
|-
| 0
| 14
| 32767
|-
| 1
| 10
| 1953
|-
| 2
| 13
| 254
|-
| 3
| 4
| 217
|-
| 4
| 8
| 73
|-
| 5
| 6
| 63
|-
| 6
| 9
| 42
|-
| 7
| 11
| 28
|}
Noise output works using the following algorithm, performed once per sample generated:
# Create a new bit by inverting the XOR of bit 7 with the tap bit.
# Shift the LFSR register one bit to the left.
# Write the new bit as bit 0.
# Use the new bit as if it were a wavetable sample: 0 = 0, 1 = 15.
Note that, for the LFSR register to advance, all three of: the channel 4 enable bit, the channel 4 noise mode bit, and the LFSR enable bit have to be set.
{{Anchor|Sound Wavetable Address}}
=== Sound Wavetable Address ($8F) ===
<pre>
7 bit 0
---- ----
wwww wwww
|||| ||||
++++-++++- Wavetable address (bits 6-13)
</pre>
{{Anchor|Sound Channel Control}}
=== Sound Channel Control ($90) ===
<pre>
7 bit 0
---- ----
nsv. 4321
||| ||||
||| |||+- Channel 1 enable
||| ||+-- Channel 2 enable
||| |+--- Channel 3 enable
||| +---- Channel 4 enable
||+------- Channel 2 voice enable (overrides wavetable enable)
|+-------- Channel 3 sweep: 0 = disable, 1 = enable
+--------- Channel 4 mode: 0 = wavetable, 1 = noise
</pre>
Note that:
* Channel 1-4 enable bits also control whether or not the sample period counters are active.
* Channel 2's voice mode (bit 5) does not require channel 2's wavetable mode (bit 1) to be enabled.
* Conversely, Channel 4's noise mode (bit 7) ''does'' require channel 4's wavetable mode (bit 3) to be enabled.
{{Anchor|Sound Output Control}}
=== Sound Output Control ($91) ===
<pre>
7 bit 0
---- ----
H... hrrs
| ||||
| |||+- Internal speaker output enable
| |++-- Internal speaker shift/volume:
| | 0 = 100% 1 = 50%
| | 2 = 25% 3 = 12.5%
| +---- Headphone output enable
+--------- Headphones connected, 1 if true
</pre>
For correct playback on the internal speaker, it is important to set the shift/volume correctly, to match the peak summed output of the first four channels. If the value is too low, music using multiple loud channels will wrap, causing audible distortion. If the value is too high, single-channel PCM sample playback will be very quiet.
{{Anchor|Sound Channel 4 LFSR Register}}
=== Sound Channel 4 LFSR Register ($92, $93 read) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
.rrr rrrr rrrr rrrr
||| |||| |||| ||||
+++-++++--++++-++++- Shift register value
</pre>
{{Anchor|Sound Channel 2 Voice Volume}}
=== Sound Channel 2 Voice Volume ($94) ===
<pre>
7 bit 0
---- ----
.... lLrR
||||
|||+- Right channel 100% volume
||+-- Right channel 50% volume
|+--- Left channel 100% volume
+---- Left channel 50% volume
</pre>
This port is used for voice output.
The <code>50% volume</code> have no effect if their respective <code>100% volume</code> bits are set.
{{Anchor|Sound Test}}
=== Sound Test ($95) ===
<pre>
7 bit 0
---- ----
??5? llsh
| ||||
| |||+- Hold Ch1-4 output updates
| ||+-- Use 3072000 Hz CPU clock for sweep
| ++--- Hold noise LFSR output
| (Differences between bit 2/3
| behavior are unknown)
+------- Force L10/R10 outputs to (channel 2 voice output * 5) & 0x3FF
</pre>
{{Anchor|Sound Channel Output Right}}
=== Sound Channel Output Right ($96, $97 read) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
.... ..ss ssss ssss
|| |||| ||||
++--++++-++++- Unsigned 10-bit sample
</pre>
{{Anchor|Sound Channel Output Left}}
=== Sound Channel Output Left ($98, $99 read) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
.... ..ss ssss ssss
|| |||| ||||
++--++++-++++- Unsigned 10-bit sample
</pre>
{{Anchor|Sound Channel Output Sum}}
=== Sound Channel Output Sum ($9A, $9B read) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
.... .sss ssss ssss
||| |||| ||||
+++--++++-++++- Unsigned 11-bit sample
</pre>
{{Anchor|Sound Speaker Main Volume}}
=== Sound Speaker Main Volume ($9E) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
.... .... .... ..vv
||
++- Built-in speaker output volume
</pre>
Writing to this port changes the output volume of the built-in speaker.
While it functions the same way as the SOUND button (and affects the same internal register), pressing the SOUND button does ''not'' update this port's value. However, manual writes do, and those values can be read out.
This port does not affect the headphone output in any way, just like the SOUND button.
TODO: The exact volume levels have not been verified; it's probably either 0, 25, 50, 100% or 0, ~33, ~67, 100%.
0e4228265dedc14bf3dbcf5de50eefb199856fac
572
561
2025-03-16T17:22:43Z
Asie
351
/* Sound Channel 4 Noise Control ($8E) */
wikitext
text/x-wiki
The WonderSwan features the following sound hardware:
* Four audio channels:
** channel 1 - wavetable (32 x 4-bit samples),
** channel 2 - wavetable or 8-bit unsigned PCM sample,
** channel 3 - wavetable with optional hardware sweep,
** channel 4 - wavetable or LFSR noise,
* [[Hyper Voice]]<sup>(color)</sup> - headphone output exclusive 16-bit stereo PCM output,
* 24000 Hz output:
** internal speaker - 8-bit, mono,
** headphone output - 16-bit, stereo.
[[Hyper Voice]] functionality is documented on its own sub-page.
== Mixing diagram ==
The sound is mixed as follows:
<pre>
Ch1 Ch2 Ch3 Ch4 Glossary: L = left, R = right, M = mono
| | | | Mnn = nn-bit mono
8 8 8 8 port $98 port $nn = value port
| | | | /
_V___V___V___V_ / _____ _____
| |--L10------+----->| | | |
| + | | | + |--M11-->| >>r |--M8--> Speaker output
|_______________|--R10------|-+--->|_____| / |_____|
/ _|_|_ / (r=0...3)
/ | | / \
port $96 | <<5 | port $9A \
|_____| \
| | port $91
| |
port $68 port $64 | |
/ _______________ \ __V_V__ _____
L8-->| (Color only) |--L16-->| |----------L16-->| |
| Hyper Voice | | + + | | I2S |------> Headphone output
R8-->|_______________|--R16-->|_______|----------R16-->|_____|
\ /
port $69 port $66
</pre>
== Wavetable RAM ==
The wavetable RAM is an user-configurable 64-byte area of memory which stores four 16-byte waveforms. Each waveform contains 32 4-bit samples for the respective channel (from 1 to 4):
<pre>
Address $00 $01 $02 $03 $04 $05 $06 $07 $08 $09 $0A $0B $0C $0D $0E $0F
98 CB ED FF FF EF BD 8A 57 24 01 00 00 21 43 76
Sample
15 .. .. .. ## ## #. .. .. .. .. .. .. .. .. .. ..
14 .. .. .# || || |# .. .. .. .. .. .. .. .. .. ..
13 .. .. #| || || || #. .. .. .. .. .. .. .. .. ..
12 .. .# || || || || |. .. .. .. .. .. .. .. .. ..
11 .. #| || || || || |# .. .. .. .. .. .. .. .. ..
10 .. || || || || || || #. .. .. .. .. .. .. .. ..
9 .# || || || || || || |. .. .. .. .. .. .. .. ..
8 #| || || || || || || |# .. .. .. .. .. .. .. ..
7 || || || || || || || || #. .. .. .. .. .. .. .#
6 || || || || || || || || |. .. .. .. .. .. .. #|
5 || || || || || || || || |# .. .. .. .. .. .. ||
4 || || || || || || || || || #. .. .. .. .. .# ||
3 || || || || || || || || || |. .. .. .. .. #| ||
2 || || || || || || || || || |# .. .. .. .# || ||
1 || || || || || || || || || || #. .. .. #| || ||
0 || || || || || || || || || || |# ## ## || || ||
</pre>
Note that the ''higher'' bits - the first hexadecimal number - specify the ''later'' samples; that is to say, the nybbles of each sample are swapped relative to the wave drawing.
The current sample to be played (from 0 to 31) is selected by an internal sample index counter; there is no known way to reset this counter.
== I/O Ports ==
{{Anchor|Sound Channel Frequency}}
=== Sound Channel Frequency ($80, $81; $82, $83; $84, $85; $86, $87) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
.... .ddd dddd dddd
||| |||| ||||
+++--++++-++++- Frequency divisor
</pre>
This value controls the sample period counters. Every <code>2048 - divisor</code> cycles, the index of the sample to be fetched from the wavetable is incremented; in addition, if noise is enabled, the state of the noise LFSR is advanced.
The resulting frequency is calculated as follows: <code>sample rate = 3072000 Hz / (2048 - divisor)</code>.
Note that this refers to the sample rate of each sample in the ''wavetable'', and needs to be scaled accordingly for a given waveform. For example, a 50% duty square wave (16 samples of <tt>0</tt> followed by 16 samples of <tt>15</tt>) will have an effective sample rate of <code>(3072000 / 32) Hz / (2048 - divisor)</code>, or <code> 96000 Hz / (2048 - divisor)</code>.
{{Anchor|Sound Channel Volume}}
=== Sound Channel Volume ($88; $89; $8A; $8B) ===
<pre>
7 bit 0
---------
llll rrrr
|||| ||||
|||| ++++- Right channel volume (0-15)
++++------ Left channel volume (0-15)
</pre>
This volume is used for wavetable output.
The calculation to get an unsigned 8-bit sample out of a 4-bit wavetable sample / 4-bit volume pair is simple: <code>out_sample = sample * volume</code>. This means that the maximum sample in wavetable output mode is <code>15 * 15 = 225</code>.
{{Anchor|Sound Channel 2 Voice Sample}}
=== Sound Channel 2 Voice Sample ($89) ===
<pre>
7 bit 0
---- ----
ssss ssss
|||| ||||
++++-++++- Unsigned 8-bit PCM sample (0-255)
</pre>
This sample is used for channel 2's voice output mode.
{{Anchor|Sound Channel 3 Sweep Amount}}
=== Sound Channel 3 Sweep Amount ($8C) ===
<pre>
7 bit 0
---- ----
vvvv vvvv
|||| ||||
++++-++++- Value; 8-bit, signed.
</pre>
This port is used for wavetable output with sweep enabled.
The signed value in this port will be added to the frequency divider for channel 3 every sweep step (as determined by the Sweep Ticks port). Wraparound is present - adding 1 to a frequency divider value of 2047 will cause it to roll over back to 0.
{{Anchor|Sound Channel 3 Sweep Ticks}}
=== Sound Channel 3 Sweep Ticks ($8D) ===
<pre>
7 bit 0
---- ----
...t tttt
| ||||
+-++++- Ticks per step - 1
</pre>
This port is used for wavetable output with sweep enabled.
Every <code>ttttt + 1</code> ticks, clocked at 375 Hz, the value in the Sweep Amount port will be added to the frequency divider for channel 3.
{{Anchor|Sound Channel 4 Noise Control}}
=== Sound Channel 4 Noise Control ($8E) ===
<pre>
7 bit 0
---- ----
...e rttt
| ||||
| |+++- LFSR tap mode
| +---- LFSR reset: 1 = reset shift register
+------ LFSR enabled: 0 = off, 1 = on
</pre>
This port is used for noise output.
{| class="wikitable"
|+ List of LFSR tap modes
! Tap mode
! Tap bit
! Sequence length
|-
| 0
| 14
| 32767
|-
| 1
| 10
| 1953
|-
| 2
| 13
| 254
|-
| 3
| 4
| 217
|-
| 4
| 8
| 73
|-
| 5
| 6
| 63
|-
| 6
| 9
| 42
|-
| 7
| 11
| 28
|}
Noise output works using the following algorithm, performed once per sample generated:
# Create a new bit by inverting the XOR of bit 7 with the tap bit.
# Shift the LFSR register one bit to the left.
# Write the new bit as bit 0.
# Use the new bit as if it were a wavetable sample: 0 = 0, 1 = 15.
Note that, for the LFSR register to advance, two of: the channel 4 enable bit and the LFSR enable bit have to be set.
{{Anchor|Sound Wavetable Address}}
=== Sound Wavetable Address ($8F) ===
<pre>
7 bit 0
---- ----
wwww wwww
|||| ||||
++++-++++- Wavetable address (bits 6-13)
</pre>
{{Anchor|Sound Channel Control}}
=== Sound Channel Control ($90) ===
<pre>
7 bit 0
---- ----
nsv. 4321
||| ||||
||| |||+- Channel 1 enable
||| ||+-- Channel 2 enable
||| |+--- Channel 3 enable
||| +---- Channel 4 enable
||+------- Channel 2 voice enable (overrides wavetable enable)
|+-------- Channel 3 sweep: 0 = disable, 1 = enable
+--------- Channel 4 mode: 0 = wavetable, 1 = noise
</pre>
Note that:
* Channel 1-4 enable bits also control whether or not the sample period counters are active.
* Channel 2's voice mode (bit 5) does not require channel 2's wavetable mode (bit 1) to be enabled.
* Conversely, Channel 4's noise mode (bit 7) ''does'' require channel 4's wavetable mode (bit 3) to be enabled.
{{Anchor|Sound Output Control}}
=== Sound Output Control ($91) ===
<pre>
7 bit 0
---- ----
H... hrrs
| ||||
| |||+- Internal speaker output enable
| |++-- Internal speaker shift/volume:
| | 0 = 100% 1 = 50%
| | 2 = 25% 3 = 12.5%
| +---- Headphone output enable
+--------- Headphones connected, 1 if true
</pre>
For correct playback on the internal speaker, it is important to set the shift/volume correctly, to match the peak summed output of the first four channels. If the value is too low, music using multiple loud channels will wrap, causing audible distortion. If the value is too high, single-channel PCM sample playback will be very quiet.
{{Anchor|Sound Channel 4 LFSR Register}}
=== Sound Channel 4 LFSR Register ($92, $93 read) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
.rrr rrrr rrrr rrrr
||| |||| |||| ||||
+++-++++--++++-++++- Shift register value
</pre>
{{Anchor|Sound Channel 2 Voice Volume}}
=== Sound Channel 2 Voice Volume ($94) ===
<pre>
7 bit 0
---- ----
.... lLrR
||||
|||+- Right channel 100% volume
||+-- Right channel 50% volume
|+--- Left channel 100% volume
+---- Left channel 50% volume
</pre>
This port is used for voice output.
The <code>50% volume</code> have no effect if their respective <code>100% volume</code> bits are set.
{{Anchor|Sound Test}}
=== Sound Test ($95) ===
<pre>
7 bit 0
---- ----
??5? llsh
| ||||
| |||+- Hold Ch1-4 output updates
| ||+-- Use 3072000 Hz CPU clock for sweep
| ++--- Hold noise LFSR output
| (Differences between bit 2/3
| behavior are unknown)
+------- Force L10/R10 outputs to (channel 2 voice output * 5) & 0x3FF
</pre>
{{Anchor|Sound Channel Output Right}}
=== Sound Channel Output Right ($96, $97 read) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
.... ..ss ssss ssss
|| |||| ||||
++--++++-++++- Unsigned 10-bit sample
</pre>
{{Anchor|Sound Channel Output Left}}
=== Sound Channel Output Left ($98, $99 read) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
.... ..ss ssss ssss
|| |||| ||||
++--++++-++++- Unsigned 10-bit sample
</pre>
{{Anchor|Sound Channel Output Sum}}
=== Sound Channel Output Sum ($9A, $9B read) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
.... .sss ssss ssss
||| |||| ||||
+++--++++-++++- Unsigned 11-bit sample
</pre>
{{Anchor|Sound Speaker Main Volume}}
=== Sound Speaker Main Volume ($9E) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
.... .... .... ..vv
||
++- Built-in speaker output volume
</pre>
Writing to this port changes the output volume of the built-in speaker.
While it functions the same way as the SOUND button (and affects the same internal register), pressing the SOUND button does ''not'' update this port's value. However, manual writes do, and those values can be read out.
This port does not affect the headphone output in any way, just like the SOUND button.
TODO: The exact volume levels have not been verified; it's probably either 0, 25, 50, 100% or 0, ~33, ~67, 100%.
0f0ebf690689202908dfccf7c4083ed3e7d713ee
596
572
2025-04-20T18:15:06Z
Asie
351
/* Sound Test ($95) */ bits 6-7
wikitext
text/x-wiki
The WonderSwan features the following sound hardware:
* Four audio channels:
** channel 1 - wavetable (32 x 4-bit samples),
** channel 2 - wavetable or 8-bit unsigned PCM sample,
** channel 3 - wavetable with optional hardware sweep,
** channel 4 - wavetable or LFSR noise,
* [[Hyper Voice]]<sup>(color)</sup> - headphone output exclusive 16-bit stereo PCM output,
* 24000 Hz output:
** internal speaker - 8-bit, mono,
** headphone output - 16-bit, stereo.
[[Hyper Voice]] functionality is documented on its own sub-page.
== Mixing diagram ==
The sound is mixed as follows:
<pre>
Ch1 Ch2 Ch3 Ch4 Glossary: L = left, R = right, M = mono
| | | | Mnn = nn-bit mono
8 8 8 8 port $98 port $nn = value port
| | | | /
_V___V___V___V_ / _____ _____
| |--L10------+----->| | | |
| + | | | + |--M11-->| >>r |--M8--> Speaker output
|_______________|--R10------|-+--->|_____| / |_____|
/ _|_|_ / (r=0...3)
/ | | / \
port $96 | <<5 | port $9A \
|_____| \
| | port $91
| |
port $68 port $64 | |
/ _______________ \ __V_V__ _____
L8-->| (Color only) |--L16-->| |----------L16-->| |
| Hyper Voice | | + + | | I2S |------> Headphone output
R8-->|_______________|--R16-->|_______|----------R16-->|_____|
\ /
port $69 port $66
</pre>
== Wavetable RAM ==
The wavetable RAM is an user-configurable 64-byte area of memory which stores four 16-byte waveforms. Each waveform contains 32 4-bit samples for the respective channel (from 1 to 4):
<pre>
Address $00 $01 $02 $03 $04 $05 $06 $07 $08 $09 $0A $0B $0C $0D $0E $0F
98 CB ED FF FF EF BD 8A 57 24 01 00 00 21 43 76
Sample
15 .. .. .. ## ## #. .. .. .. .. .. .. .. .. .. ..
14 .. .. .# || || |# .. .. .. .. .. .. .. .. .. ..
13 .. .. #| || || || #. .. .. .. .. .. .. .. .. ..
12 .. .# || || || || |. .. .. .. .. .. .. .. .. ..
11 .. #| || || || || |# .. .. .. .. .. .. .. .. ..
10 .. || || || || || || #. .. .. .. .. .. .. .. ..
9 .# || || || || || || |. .. .. .. .. .. .. .. ..
8 #| || || || || || || |# .. .. .. .. .. .. .. ..
7 || || || || || || || || #. .. .. .. .. .. .. .#
6 || || || || || || || || |. .. .. .. .. .. .. #|
5 || || || || || || || || |# .. .. .. .. .. .. ||
4 || || || || || || || || || #. .. .. .. .. .# ||
3 || || || || || || || || || |. .. .. .. .. #| ||
2 || || || || || || || || || |# .. .. .. .# || ||
1 || || || || || || || || || || #. .. .. #| || ||
0 || || || || || || || || || || |# ## ## || || ||
</pre>
Note that the ''higher'' bits - the first hexadecimal number - specify the ''later'' samples; that is to say, the nybbles of each sample are swapped relative to the wave drawing.
The current sample to be played (from 0 to 31) is selected by an internal sample index counter; there is no known way to reset this counter.
== I/O Ports ==
{{Anchor|Sound Channel Frequency}}
=== Sound Channel Frequency ($80, $81; $82, $83; $84, $85; $86, $87) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
.... .ddd dddd dddd
||| |||| ||||
+++--++++-++++- Frequency divisor
</pre>
This value controls the sample period counters. Every <code>2048 - divisor</code> cycles, the index of the sample to be fetched from the wavetable is incremented; in addition, if noise is enabled, the state of the noise LFSR is advanced.
The resulting frequency is calculated as follows: <code>sample rate = 3072000 Hz / (2048 - divisor)</code>.
Note that this refers to the sample rate of each sample in the ''wavetable'', and needs to be scaled accordingly for a given waveform. For example, a 50% duty square wave (16 samples of <tt>0</tt> followed by 16 samples of <tt>15</tt>) will have an effective sample rate of <code>(3072000 / 32) Hz / (2048 - divisor)</code>, or <code> 96000 Hz / (2048 - divisor)</code>.
{{Anchor|Sound Channel Volume}}
=== Sound Channel Volume ($88; $89; $8A; $8B) ===
<pre>
7 bit 0
---------
llll rrrr
|||| ||||
|||| ++++- Right channel volume (0-15)
++++------ Left channel volume (0-15)
</pre>
This volume is used for wavetable output.
The calculation to get an unsigned 8-bit sample out of a 4-bit wavetable sample / 4-bit volume pair is simple: <code>out_sample = sample * volume</code>. This means that the maximum sample in wavetable output mode is <code>15 * 15 = 225</code>.
{{Anchor|Sound Channel 2 Voice Sample}}
=== Sound Channel 2 Voice Sample ($89) ===
<pre>
7 bit 0
---- ----
ssss ssss
|||| ||||
++++-++++- Unsigned 8-bit PCM sample (0-255)
</pre>
This sample is used for channel 2's voice output mode.
{{Anchor|Sound Channel 3 Sweep Amount}}
=== Sound Channel 3 Sweep Amount ($8C) ===
<pre>
7 bit 0
---- ----
vvvv vvvv
|||| ||||
++++-++++- Value; 8-bit, signed.
</pre>
This port is used for wavetable output with sweep enabled.
The signed value in this port will be added to the frequency divider for channel 3 every sweep step (as determined by the Sweep Ticks port). Wraparound is present - adding 1 to a frequency divider value of 2047 will cause it to roll over back to 0.
{{Anchor|Sound Channel 3 Sweep Ticks}}
=== Sound Channel 3 Sweep Ticks ($8D) ===
<pre>
7 bit 0
---- ----
...t tttt
| ||||
+-++++- Ticks per step - 1
</pre>
This port is used for wavetable output with sweep enabled.
Every <code>ttttt + 1</code> ticks, clocked at 375 Hz, the value in the Sweep Amount port will be added to the frequency divider for channel 3.
{{Anchor|Sound Channel 4 Noise Control}}
=== Sound Channel 4 Noise Control ($8E) ===
<pre>
7 bit 0
---- ----
...e rttt
| ||||
| |+++- LFSR tap mode
| +---- LFSR reset: 1 = reset shift register
+------ LFSR enabled: 0 = off, 1 = on
</pre>
This port is used for noise output.
{| class="wikitable"
|+ List of LFSR tap modes
! Tap mode
! Tap bit
! Sequence length
|-
| 0
| 14
| 32767
|-
| 1
| 10
| 1953
|-
| 2
| 13
| 254
|-
| 3
| 4
| 217
|-
| 4
| 8
| 73
|-
| 5
| 6
| 63
|-
| 6
| 9
| 42
|-
| 7
| 11
| 28
|}
Noise output works using the following algorithm, performed once per sample generated:
# Create a new bit by inverting the XOR of bit 7 with the tap bit.
# Shift the LFSR register one bit to the left.
# Write the new bit as bit 0.
# Use the new bit as if it were a wavetable sample: 0 = 0, 1 = 15.
Note that, for the LFSR register to advance, two of: the channel 4 enable bit and the LFSR enable bit have to be set.
{{Anchor|Sound Wavetable Address}}
=== Sound Wavetable Address ($8F) ===
<pre>
7 bit 0
---- ----
wwww wwww
|||| ||||
++++-++++- Wavetable address (bits 6-13)
</pre>
{{Anchor|Sound Channel Control}}
=== Sound Channel Control ($90) ===
<pre>
7 bit 0
---- ----
nsv. 4321
||| ||||
||| |||+- Channel 1 enable
||| ||+-- Channel 2 enable
||| |+--- Channel 3 enable
||| +---- Channel 4 enable
||+------- Channel 2 voice enable (overrides wavetable enable)
|+-------- Channel 3 sweep: 0 = disable, 1 = enable
+--------- Channel 4 mode: 0 = wavetable, 1 = noise
</pre>
Note that:
* Channel 1-4 enable bits also control whether or not the sample period counters are active.
* Channel 2's voice mode (bit 5) does not require channel 2's wavetable mode (bit 1) to be enabled.
* Conversely, Channel 4's noise mode (bit 7) ''does'' require channel 4's wavetable mode (bit 3) to be enabled.
{{Anchor|Sound Output Control}}
=== Sound Output Control ($91) ===
<pre>
7 bit 0
---- ----
H... hrrs
| ||||
| |||+- Internal speaker output enable
| |++-- Internal speaker shift/volume:
| | 0 = 100% 1 = 50%
| | 2 = 25% 3 = 12.5%
| +---- Headphone output enable
+--------- Headphones connected, 1 if true
</pre>
For correct playback on the internal speaker, it is important to set the shift/volume correctly, to match the peak summed output of the first four channels. If the value is too low, music using multiple loud channels will wrap, causing audible distortion. If the value is too high, single-channel PCM sample playback will be very quiet.
{{Anchor|Sound Channel 4 LFSR Register}}
=== Sound Channel 4 LFSR Register ($92, $93 read) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
.rrr rrrr rrrr rrrr
||| |||| |||| ||||
+++-++++--++++-++++- Shift register value
</pre>
{{Anchor|Sound Channel 2 Voice Volume}}
=== Sound Channel 2 Voice Volume ($94) ===
<pre>
7 bit 0
---- ----
.... lLrR
||||
|||+- Right channel 100% volume
||+-- Right channel 50% volume
|+--- Left channel 100% volume
+---- Left channel 50% volume
</pre>
This port is used for voice output.
The <code>50% volume</code> have no effect if their respective <code>100% volume</code> bits are set.
{{Anchor|Sound Test}}
=== Sound Test ($95) ===
<pre>
7 bit 0
---- ----
cc5? llsh
||| ||||
||| |||+- Hold Ch1-4 output updates
||| ||+-- Use 3072000 Hz CPU clock for sweep
||| ++--- Hold noise LFSR output
||| (Differences between bit 2/3
||| behavior are unknown)
||+------- Force L10/R10 outputs to (channel 2 voice output * 5) & 0x3FF
++-------- Force wavetable for all wavetable inputs:
00 - normal operation
01 - Ch2 wavetable
10 - Ch3 wavetable
11 - Ch4 wavetable
</pre>
{{Anchor|Sound Channel Output Right}}
=== Sound Channel Output Right ($96, $97 read) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
.... ..ss ssss ssss
|| |||| ||||
++--++++-++++- Unsigned 10-bit sample
</pre>
{{Anchor|Sound Channel Output Left}}
=== Sound Channel Output Left ($98, $99 read) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
.... ..ss ssss ssss
|| |||| ||||
++--++++-++++- Unsigned 10-bit sample
</pre>
{{Anchor|Sound Channel Output Sum}}
=== Sound Channel Output Sum ($9A, $9B read) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
.... .sss ssss ssss
||| |||| ||||
+++--++++-++++- Unsigned 11-bit sample
</pre>
{{Anchor|Sound Speaker Main Volume}}
=== Sound Speaker Main Volume ($9E) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
.... .... .... ..vv
||
++- Built-in speaker output volume
</pre>
Writing to this port changes the output volume of the built-in speaker.
While it functions the same way as the SOUND button (and affects the same internal register), pressing the SOUND button does ''not'' update this port's value. However, manual writes do, and those values can be read out.
This port does not affect the headphone output in any way, just like the SOUND button.
TODO: The exact volume levels have not been verified; it's probably either 0, 25, 50, 100% or 0, ~33, ~67, 100%.
e1c200db16d798bf7c82a693addc15f943bea333
DMA
0
31
562
355
2025-03-11T17:04:59Z
Asie
351
/* Sound DMA */
wikitext
text/x-wiki
The WonderSwan Color introduced two DMA blocks:
* General DMA (GDMA) - allowing for fast IRAM/ROM -> IRAM transfers,
* Sound DMA (SDMA) - allowing for IRAM/ROM -> sound transfers in a much less CPU-intensive way than an interrupt.
== General DMA ==
The CPU is stalled immediately after General DMA is enabled; the enable bit is cleared after a completed GDMA operation.
General DMA takes <code>(5 + 2 * words)</code> cycles to complete, where <code>words</code> is the number of words (2-bytes) transferred.
General DMA allows source addresses which can be accessed with a 16-bit width and without waitstates; any attempt to access SRAM (8-bit width) or "slow" ROM ($A0 bit 3 set) will cause DMA to immediately return, even if in the middle of processing a transfer.
Note that the 5-cycle cost is not spent for DMA requests for invalid addresses or of length zero; such scenarios take up no cycles.
{{Anchor|GDMA Source Address Low}}
{{Anchor|GDMA Source Address High}}
=== GDMA Source Address ($40, $41, $42) ===
<pre>
23 bit 16 15 bit 8 7 bit 0
---- ---- ---- ---- ---- ----
.... hhhh llll llll llll lll.
|||| |||| |||| |||| |||
++++---++++-++++---++++-++++- Linear source address
($00000 - $FFFFE)
</pre>
{{Anchor|GDMA Destination Address}}
=== GDMA Destination Address ($44, $45) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
aaaa aaaa aaaa aaa.
|||| |||| |||| |||
++++-++++--++++-+++-- Destination address in IRAM
</pre>
GDMA allows destination addresses in IRAM.
{{Anchor|GDMA Length}}
=== GDMA Length ($46, $47) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
bbbb bbbb bbbb bbb.
|||| |||| |||| |||
++++-++++--++++-+++-- Transfer length, in words
(if including bit 0: in bytes)
</pre>
{{Anchor|GDMA Control}}
=== GDMA Control ($48) ===
<pre>
7 bit 0
---- ----
ed.. ....
||
|+-------- Direction: 0 = increment, 1 = decrement
+--------- Enable DMA: 0 = off, 1 = on
</pre>
== Sound DMA ==
Sound DMA allows copying sample data to either Channel 2 or Hyper Voice automatically while incurring a much lower cost than that of a CPU interrupt.
Features:
* 4000, 6000, 12000, 24000 Hz sample rates.
* '''Auto-repeat''': If enabled, every time the length counter reaches 0, a shadowed copy of the offset and length as written to the I/O ports will be restored. If disabled, bit 7 will automatically clear on transfer completion, same as with General DMA.
* '''Holding''': If enabled, the offset/length counters will be paused, and $00 will be written on every Sound DMA tick as opposed to the value in memory. This does not impact the timing of Sound DMA.
When playing back sound, the visible ports ($4A-$4C, $4E-$50) are the ones updated live; any edits to them are reflected immediately, as well as written to the shadow copy used for auto-repeat.
The enable/disable bit of Sound DMA does not affect the offset/length counters in any way; for example, if a sample is stopped mid-playthrough, then started again, it will pick up right where it left off.
Unlike General DMA, Sound DMA copies data per byte. This means that SRAM is supported as an input source. Also unlike General DMA, streaming from "slow" (>1 cycle) locations is supported; doing so lengthens the duration of Sound DMA. Due to its need to access the external cartridge bus, Sound DMA must use cycles normally reserved for the CPU; it uses <code>6 + N</code> cycles every 128 cycles, always starting from cycle <code>117 mod 128</code>. <code>N</code> refers to the access time of the area from which audio is being streamed from, and is typically 1 cycle.
However, sound DMA enable will fail if the length is set to 0.
{{Anchor|SDMA Source Address Low}}
{{Anchor|SDMA Source Address High}}
=== SDMA Source Address ($4A, $4B, $4C) ===
<pre>
23 bit 16 15 bit 8 7 bit 0
---- ---- ---- ---- ---- ----
.... hhhh llll llll llll llll
|||| |||| |||| |||| ||||
++++---++++-++++---++++-++++- Linear source address
($00000 - $FFFFF)
</pre>
Upon writing to any of the bytes, said byte (and only said byte) is copied to a shadow register, used for restoring the offset/length counter when auto-repeat is enabled.
{{Anchor|SDMA Length}}
=== SDMA Length ($4E, $4F, $50) ===
<pre>
23 bit 16 15 bit 8 7 bit 0
---- ---- ---- ---- ---- ----
.... hhhh llll llll llll llll
|||| |||| |||| |||| ||||
++++---++++-++++---++++-++++- Transfer length, in bytes
</pre>
Upon writing to any of the bytes, said byte (and only said byte) is copied to a shadow register, used for restoring the offset/length counter when auto-repeat is enabled.
{{Anchor|SDMA Control}}
=== SDMA Control ($52) ===
<pre>
7 bit 0
---- ----
ed.t rhff
|| | ||||
|| | ||++- Frequency/Rate:
|| | || 0 = 24000/6 = 4000 Hz
|| | || 1 = 24000/4 = 6000 Hz
|| | || 2 = 24000/2 = 12000 Hz
|| | || 3 = 24000/1 = 24000 Hz
|| | |+--- Hold: 0 = normal playback, 1 = hold
|| | +---- Repeat: 0 = one-shot, 1 = auto-repeat
|| +------ Target:
|| 0 = Channel 2 (port $89)
|| 1 = Hyper Voice
|+-------- Direction: 0 = increment, 1 = decrement
+--------- Enable DMA: 0 = off, 1 = on
</pre>
9cc3aaab0e383c22a5054709b363a587cd90f995
ROM header
0
5
563
499
2025-03-15T08:15:18Z
Asie
351
/* Flags ($C) */ I was very wrong
wikitext
text/x-wiki
Every WonderSwan ROM contains a header. It is stored at the end - final sixteen bytes - of the ROM image.
== ROM header ==
Parts of this header are validated or otherwise used by the console's [[boot ROM]] - they are marked in '''bold'''.
{| class="wikitable"
|+ Header contents
|-
! Offset !! Length !! Contents
|-
| '''$0''' || '''5''' || Far jump instruction: '''0xEA''', offset, segment.
|-
| '''$5''' || '''1''' || '''Maintenance'''
|-
| $6 || 1 || Developer/Publisher ID
|-
| $7 || 1 || Color
|-
| $8 || 1 || Game ID (binary-coded decimal)
|-
| '''$9''' || '''1''' || '''Game version? / Safe mode'''
|-
| $A || 1 || ROM size
|-
| $B || 1 || Save type/size
|-
| '''$C''' || '''1''' || '''Flags'''
|-
| $D || 1 || Mapper
|-
| $E || 2 || Checksum (sum of all ROM bytes excluding the checksum)
|}
=== Maintenance ($5) ===
----
<pre>
7 bit 0
---- ----
s... 0000
| ||||
| ++++- Must be zero; otherwise the console will prohibit execution.
| Purpose unknown.
+--------- (Color) Splash bypass: 0 = Disable, 1 = Enable.
Bypasses the custom boot splash stored in the console's
internal EEPROM; presumably used for bricked console recovery.
</pre>
=== Developer/Publisher ID ($6) ===
----
{| class="wikitable"
|+ Known official developer/publisher IDs
|-
! ID !! Publisher code !! Publisher
|-
| $01 || BAN || Bandai
|-
| $02 || TAT || Taito
|-
| $03 || TMY || Tomy
|-
| $04 || KEX || Koei
|-
| $05 || DTE || Data East
|-
| $06 || AAE || Asmik Ace
|-
| $07 || MDE || Media Entertainment
|-
| $08 || NHB || Nichibutsu
|-
| $0A || CCJ || Coconuts Japan
|-
| $0B || SUM || Sammy
|-
| $0C || SUN || Sunsoft
|-
| $0D || PAW || Mebius
|-
| $0E || BPR || Banpresto
|-
| $10 || JLC || Jaleco
|-
| $11 || MGA || Imagineer
|-
| $12 || KNM || Konami
|-
| $16 || KBS || Kobunsha
|-
| $17 || BTM || Bottom Up
|-
| $18 || KGT || Kaga Tech
|-
| $19 || SRV || Sunrise
|-
| $1A || CFT || Cyber Front
|-
| $1B || MGH || Megahouse
|-
| $1D || BEC || Interbec
|-
| $1E || NAP || Nihon Application
|-
| $1F || BVL || Bandai Visual
|-
| $20 || ATN || Athena
|-
| $21 || KDX || KID
|-
| $22 || HAL || HAL Corporation
|-
| $23 || YKE || Yuki Enterprise
|-
| $24 || OMN || Omega Micott
|-
| $25 || LAY || Layup
|-
| $26 || KDK || Kadokawa Shoten
|-
| $27 || SHL || Shall Luck
|-
| $28 || SQR || Squaresoft
|-
| $2A || SCC || ? (SUNCORPORATION?)
|-
| $2B || TMC || Tom Create
|-
| $2D || NMC || Namco
|-
| $2E || SES || Soeishinsha
|-
| $2F || HTR || Hearty Robin
|-
| $31 || VGD || Vanguard
|-
| $32 || MGT || Megatron
|-
| $33 || WIZ || Wiz
|-
| $35 || TAN || Tanita
|-
| $36 || CPC || Capcom
|}
Note that IDs $00 and $01 are used across a variety of commercial games. Homebrew is known to use arbitrary values in this field.
=== Color ($7) ===
----
<pre>
7 bit 0
---- ----
???? ???c
|
+- 0 = Monochrome only, 1 = Supports Color mode.
</pre>
=== Game version? / Safe mode ($9) ===
----
<pre>
7 bit 0
---- ----
pvvv vvvv
|||| ||||
|+++ ++++- Game version?
+--------- Internal EEPROM write protect: 0 = Enable, 1 = Disable.
This prohibits writing to the internal EEPROM for addresses
0x60 and above (user settings, custom splash screen).
Games are expected to enable write protection; however, the
WonderWitch is factory configured with it disabled.
</pre>
=== ROM size ($A) ===
----
Unofficial/inferred ROM size values are marked in ''italic''.
{| class="wikitable"
|+ ROM size values
|-
! ID !! Size
|-
| ''$00'' || ''1 Mbit (128 KiB)''
|-
| ''$01'' || ''2 Mbit (256 KiB)''
|-
| $02 || 4 Mbit (512 KiB)
|-
| $03 || 8 Mbit (1 MiB)
|-
| $04 || 16 Mbit (2 MiB)
|-
| ''$05'' || ''24 Mbit (3 MiB)''
|-
| $06 || 32 Mbit (4 MiB)
|-
| ''$07'' || ''48 Mbit (6 MiB)''
|-
| $08 || 64 Mbit (8 MiB)
|-
| $09 || 128 Mbit (16 MiB)
|-
| ''$0A'' || ''256 Mbit (32 MiB)''
|-
| ''$0B'' || ''512 Mbit (64 MiB)''
|}
Note that ROM sizes over 16 MiB are not supported by the [[Bandai 2001]] mapper. The [[Bandai 2003]] mapper is limited to 64 MiB.
=== Save type/size ($B) ===
----
{| class="wikitable"
|+ Save type values
|-
! ID !! Type !! Size
|-
| $00 || colspan="2" style="text-align:center;" | None
|-
| $01 || rowspan="5" | SRAM || rowspan="2" | 256 Kbit (32 KiB)
|-
| $02
|-
| $03 || 1 Mbit (128 KiB)
|-
| $04 || 2 Mbit (256 KiB)
|-
| $05 || 4 Mbit (512 KiB)
|-
| $10 || rowspan="3" | EEPROM || 1 Kbit (128 B)
|-
| $20 || 16 Kbit (2 KiB)
|-
| $50 || 8 Kbit (1 KiB)
|}
Note that while ID <code>$01</code> is commonly documented as <code>64 Kbit</code>, all known cartridges using that value come with <code>256 Kbit</code> SRAM chips. This requires further investigation.
=== Flags ($C) ===
----
<pre>
7 bit 0
---- ----
???? SB?v
|| |
|| +- Starting screen orientation: 0 = horizontal, 1 = vertical
|| Controls the splash screen's orientation.
|+--- Cartridge ROM width: 0 = 8-bit, 1 = 16-bit
+---- Cartridge ROM wait state: 0 = +0 cycles, 1 = +1
</pre>
Flag bits 2 and 3 correspond to [[SoC#System Control|System Control]] bits 2 and 3.
=== Mapper ($D) ===
----
{| class="wikitable"
|+ Known mapper types
|-
! ID !! Mapper
|-
| $00 || [[Bandai 2001]] or [[KARNAK]]
|-
| $01 || [[Bandai 2003]]
|}
8bdfdd21764033cb4dcef9ab4ddd71a39b2a47a1
564
563
2025-03-15T08:17:44Z
Asie
351
/* Flags ($C) */
wikitext
text/x-wiki
Every WonderSwan ROM contains a header. It is stored at the end - final sixteen bytes - of the ROM image.
== ROM header ==
Parts of this header are validated or otherwise used by the console's [[boot ROM]] - they are marked in '''bold'''.
{| class="wikitable"
|+ Header contents
|-
! Offset !! Length !! Contents
|-
| '''$0''' || '''5''' || Far jump instruction: '''0xEA''', offset, segment.
|-
| '''$5''' || '''1''' || '''Maintenance'''
|-
| $6 || 1 || Developer/Publisher ID
|-
| $7 || 1 || Color
|-
| $8 || 1 || Game ID (binary-coded decimal)
|-
| '''$9''' || '''1''' || '''Game version? / Safe mode'''
|-
| $A || 1 || ROM size
|-
| $B || 1 || Save type/size
|-
| '''$C''' || '''1''' || '''Flags'''
|-
| $D || 1 || Mapper
|-
| $E || 2 || Checksum (sum of all ROM bytes excluding the checksum)
|}
=== Maintenance ($5) ===
----
<pre>
7 bit 0
---- ----
s... 0000
| ||||
| ++++- Must be zero; otherwise the console will prohibit execution.
| Purpose unknown.
+--------- (Color) Splash bypass: 0 = Disable, 1 = Enable.
Bypasses the custom boot splash stored in the console's
internal EEPROM; presumably used for bricked console recovery.
</pre>
=== Developer/Publisher ID ($6) ===
----
{| class="wikitable"
|+ Known official developer/publisher IDs
|-
! ID !! Publisher code !! Publisher
|-
| $01 || BAN || Bandai
|-
| $02 || TAT || Taito
|-
| $03 || TMY || Tomy
|-
| $04 || KEX || Koei
|-
| $05 || DTE || Data East
|-
| $06 || AAE || Asmik Ace
|-
| $07 || MDE || Media Entertainment
|-
| $08 || NHB || Nichibutsu
|-
| $0A || CCJ || Coconuts Japan
|-
| $0B || SUM || Sammy
|-
| $0C || SUN || Sunsoft
|-
| $0D || PAW || Mebius
|-
| $0E || BPR || Banpresto
|-
| $10 || JLC || Jaleco
|-
| $11 || MGA || Imagineer
|-
| $12 || KNM || Konami
|-
| $16 || KBS || Kobunsha
|-
| $17 || BTM || Bottom Up
|-
| $18 || KGT || Kaga Tech
|-
| $19 || SRV || Sunrise
|-
| $1A || CFT || Cyber Front
|-
| $1B || MGH || Megahouse
|-
| $1D || BEC || Interbec
|-
| $1E || NAP || Nihon Application
|-
| $1F || BVL || Bandai Visual
|-
| $20 || ATN || Athena
|-
| $21 || KDX || KID
|-
| $22 || HAL || HAL Corporation
|-
| $23 || YKE || Yuki Enterprise
|-
| $24 || OMN || Omega Micott
|-
| $25 || LAY || Layup
|-
| $26 || KDK || Kadokawa Shoten
|-
| $27 || SHL || Shall Luck
|-
| $28 || SQR || Squaresoft
|-
| $2A || SCC || ? (SUNCORPORATION?)
|-
| $2B || TMC || Tom Create
|-
| $2D || NMC || Namco
|-
| $2E || SES || Soeishinsha
|-
| $2F || HTR || Hearty Robin
|-
| $31 || VGD || Vanguard
|-
| $32 || MGT || Megatron
|-
| $33 || WIZ || Wiz
|-
| $35 || TAN || Tanita
|-
| $36 || CPC || Capcom
|}
Note that IDs $00 and $01 are used across a variety of commercial games. Homebrew is known to use arbitrary values in this field.
=== Color ($7) ===
----
<pre>
7 bit 0
---- ----
???? ???c
|
+- 0 = Monochrome only, 1 = Supports Color mode.
</pre>
=== Game version? / Safe mode ($9) ===
----
<pre>
7 bit 0
---- ----
pvvv vvvv
|||| ||||
|+++ ++++- Game version?
+--------- Internal EEPROM write protect: 0 = Enable, 1 = Disable.
This prohibits writing to the internal EEPROM for addresses
0x60 and above (user settings, custom splash screen).
Games are expected to enable write protection; however, the
WonderWitch is factory configured with it disabled.
</pre>
=== ROM size ($A) ===
----
Unofficial/inferred ROM size values are marked in ''italic''.
{| class="wikitable"
|+ ROM size values
|-
! ID !! Size
|-
| ''$00'' || ''1 Mbit (128 KiB)''
|-
| ''$01'' || ''2 Mbit (256 KiB)''
|-
| $02 || 4 Mbit (512 KiB)
|-
| $03 || 8 Mbit (1 MiB)
|-
| $04 || 16 Mbit (2 MiB)
|-
| ''$05'' || ''24 Mbit (3 MiB)''
|-
| $06 || 32 Mbit (4 MiB)
|-
| ''$07'' || ''48 Mbit (6 MiB)''
|-
| $08 || 64 Mbit (8 MiB)
|-
| $09 || 128 Mbit (16 MiB)
|-
| ''$0A'' || ''256 Mbit (32 MiB)''
|-
| ''$0B'' || ''512 Mbit (64 MiB)''
|}
Note that ROM sizes over 16 MiB are not supported by the [[Bandai 2001]] mapper. The [[Bandai 2003]] mapper is limited to 64 MiB.
=== Save type/size ($B) ===
----
{| class="wikitable"
|+ Save type values
|-
! ID !! Type !! Size
|-
| $00 || colspan="2" style="text-align:center;" | None
|-
| $01 || rowspan="5" | SRAM || rowspan="2" | 256 Kbit (32 KiB)
|-
| $02
|-
| $03 || 1 Mbit (128 KiB)
|-
| $04 || 2 Mbit (256 KiB)
|-
| $05 || 4 Mbit (512 KiB)
|-
| $10 || rowspan="3" | EEPROM || 1 Kbit (128 B)
|-
| $20 || 16 Kbit (2 KiB)
|-
| $50 || 8 Kbit (1 KiB)
|}
Note that while ID <code>$01</code> is commonly documented as <code>64 Kbit</code>, all known cartridges using that value come with <code>256 Kbit</code> SRAM chips. This requires further investigation.
=== Flags ($C) ===
----
<pre>
7 bit 0
---- ----
???? SB?v
|| |
|| +- Starting orientation: 0 = horizontal, 1 = vertical
|+--- Cartridge ROM width: 0 = 8-bit, 1 = 16-bit
+---- Cartridge ROM wait state: 0 = +0 cycles, 1 = +1
</pre>
Flag bits 2 and 3 correspond to [[SoC#System Control|System Control]] bits 2 and 3.
Bit 0 controls the splash screen's orientation, as well as the LCD segment (horizontal or vertical orientation) displayed during the first 128 ticks of the splash screen.
=== Mapper ($D) ===
----
{| class="wikitable"
|+ Known mapper types
|-
! ID !! Mapper
|-
| $00 || [[Bandai 2001]] or [[KARNAK]]
|-
| $01 || [[Bandai 2003]]
|}
3ba9a19ccd43e29dcb916def3f20cd578dc561e0
600
564
2025-04-23T14:05:47Z
Asie
351
the ROM padding is still not obvious if it's not written anywhere, and at least two emulators got it wrong already
wikitext
text/x-wiki
Every WonderSwan cartridge ROM contains a header.
The header is stored at the end (the final sixteen bytes) of the ROM image. For this reason, it is also sometimes called a "footer".
A notable consequence of this is that, unlike most other platforms, non-power-of-two ROM images are expected to be padded to the last bank downwards, rather than the first bank upwards; for example, a 768 KiB ROM image will be padded to 1 MiB by appending 256 KiB of padding data to the ''beginning'', rather than the ''end'' of the ROM.
== ROM header ==
Parts of this header are validated or otherwise used by the console's [[boot ROM]] - they are marked in '''bold'''.
{| class="wikitable"
|+ Header contents
|-
! Offset !! Length !! Contents
|-
| '''$0''' || '''5''' || Far jump instruction: '''0xEA''', offset, segment.
|-
| '''$5''' || '''1''' || '''Maintenance'''
|-
| $6 || 1 || Developer/Publisher ID
|-
| $7 || 1 || Color
|-
| $8 || 1 || Game ID (binary-coded decimal)
|-
| '''$9''' || '''1''' || '''Game version? / Safe mode'''
|-
| $A || 1 || ROM size
|-
| $B || 1 || Save type/size
|-
| '''$C''' || '''1''' || '''Flags'''
|-
| $D || 1 || Mapper
|-
| $E || 2 || Checksum (sum of all ROM bytes excluding the checksum)
|}
=== Maintenance ($5) ===
----
<pre>
7 bit 0
---- ----
s... 0000
| ||||
| ++++- Must be zero; otherwise the console will prohibit execution.
| Purpose unknown.
+--------- (Color) Splash bypass: 0 = Disable, 1 = Enable.
Bypasses the custom boot splash stored in the console's
internal EEPROM; presumably used for bricked console recovery.
</pre>
=== Developer/Publisher ID ($6) ===
----
{| class="wikitable"
|+ Known official developer/publisher IDs
|-
! ID !! Publisher code !! Publisher
|-
| $01 || BAN || Bandai
|-
| $02 || TAT || Taito
|-
| $03 || TMY || Tomy
|-
| $04 || KEX || Koei
|-
| $05 || DTE || Data East
|-
| $06 || AAE || Asmik Ace
|-
| $07 || MDE || Media Entertainment
|-
| $08 || NHB || Nichibutsu
|-
| $0A || CCJ || Coconuts Japan
|-
| $0B || SUM || Sammy
|-
| $0C || SUN || Sunsoft
|-
| $0D || PAW || Mebius
|-
| $0E || BPR || Banpresto
|-
| $10 || JLC || Jaleco
|-
| $11 || MGA || Imagineer
|-
| $12 || KNM || Konami
|-
| $16 || KBS || Kobunsha
|-
| $17 || BTM || Bottom Up
|-
| $18 || KGT || Kaga Tech
|-
| $19 || SRV || Sunrise
|-
| $1A || CFT || Cyber Front
|-
| $1B || MGH || Megahouse
|-
| $1D || BEC || Interbec
|-
| $1E || NAP || Nihon Application
|-
| $1F || BVL || Bandai Visual
|-
| $20 || ATN || Athena
|-
| $21 || KDX || KID
|-
| $22 || HAL || HAL Corporation
|-
| $23 || YKE || Yuki Enterprise
|-
| $24 || OMN || Omega Micott
|-
| $25 || LAY || Layup
|-
| $26 || KDK || Kadokawa Shoten
|-
| $27 || SHL || Shall Luck
|-
| $28 || SQR || Squaresoft
|-
| $2A || SCC || ? (SUNCORPORATION?)
|-
| $2B || TMC || Tom Create
|-
| $2D || NMC || Namco
|-
| $2E || SES || Soeishinsha
|-
| $2F || HTR || Hearty Robin
|-
| $31 || VGD || Vanguard
|-
| $32 || MGT || Megatron
|-
| $33 || WIZ || Wiz
|-
| $35 || TAN || Tanita
|-
| $36 || CPC || Capcom
|}
Note that IDs $00 and $01 are used across a variety of commercial games. Homebrew is known to use arbitrary values in this field.
=== Color ($7) ===
----
<pre>
7 bit 0
---- ----
???? ???c
|
+- 0 = Monochrome only, 1 = Supports Color mode.
</pre>
=== Game version? / Safe mode ($9) ===
----
<pre>
7 bit 0
---- ----
pvvv vvvv
|||| ||||
|+++ ++++- Game version?
+--------- Internal EEPROM write protect: 0 = Enable, 1 = Disable.
This prohibits writing to the internal EEPROM for addresses
0x60 and above (user settings, custom splash screen).
Games are expected to enable write protection; however, the
WonderWitch is factory configured with it disabled.
</pre>
=== ROM size ($A) ===
----
Unofficial/inferred ROM size values are marked in ''italic''.
{| class="wikitable"
|+ ROM size values
|-
! ID !! Size
|-
| ''$00'' || ''1 Mbit (128 KiB)''
|-
| ''$01'' || ''2 Mbit (256 KiB)''
|-
| $02 || 4 Mbit (512 KiB)
|-
| $03 || 8 Mbit (1 MiB)
|-
| $04 || 16 Mbit (2 MiB)
|-
| ''$05'' || ''24 Mbit (3 MiB)''
|-
| $06 || 32 Mbit (4 MiB)
|-
| ''$07'' || ''48 Mbit (6 MiB)''
|-
| $08 || 64 Mbit (8 MiB)
|-
| $09 || 128 Mbit (16 MiB)
|-
| ''$0A'' || ''256 Mbit (32 MiB)''
|-
| ''$0B'' || ''512 Mbit (64 MiB)''
|}
Note that ROM sizes over 16 MiB are not supported by the [[Bandai 2001]] mapper. The [[Bandai 2003]] mapper is limited to 64 MiB.
=== Save type/size ($B) ===
----
{| class="wikitable"
|+ Save type values
|-
! ID !! Type !! Size
|-
| $00 || colspan="2" style="text-align:center;" | None
|-
| $01 || rowspan="5" | SRAM || rowspan="2" | 256 Kbit (32 KiB)
|-
| $02
|-
| $03 || 1 Mbit (128 KiB)
|-
| $04 || 2 Mbit (256 KiB)
|-
| $05 || 4 Mbit (512 KiB)
|-
| $10 || rowspan="3" | EEPROM || 1 Kbit (128 B)
|-
| $20 || 16 Kbit (2 KiB)
|-
| $50 || 8 Kbit (1 KiB)
|}
Note that while ID <code>$01</code> is commonly documented as <code>64 Kbit</code>, all known cartridges using that value come with <code>256 Kbit</code> SRAM chips. This requires further investigation.
=== Flags ($C) ===
----
<pre>
7 bit 0
---- ----
???? SB?v
|| |
|| +- Starting orientation: 0 = horizontal, 1 = vertical
|+--- Cartridge ROM width: 0 = 8-bit, 1 = 16-bit
+---- Cartridge ROM wait state: 0 = +0 cycles, 1 = +1
</pre>
Flag bits 2 and 3 correspond to [[SoC#System Control|System Control]] bits 2 and 3.
Bit 0 controls the splash screen's orientation, as well as the LCD segment (horizontal or vertical orientation) displayed during the first 128 ticks of the splash screen.
=== Mapper ($D) ===
----
{| class="wikitable"
|+ Known mapper types
|-
! ID !! Mapper
|-
| $00 || [[Bandai 2001]] or [[KARNAK]]
|-
| $01 || [[Bandai 2003]]
|}
1c4dfe0e03c24b47514afc800930c1233221d557
Bandai 2003
0
13
565
396
2025-03-15T16:40:58Z
Asie
351
split out usage information from command notes, more compact command representation
wikitext
text/x-wiki
The Bandai 2003 (LUXSOR2) is one of the two mappers used in WonderSwan cartridges.
In addition to the normal [[Mapper]] banking interface, Bandai's 2003 adds registers for an RTC interface, GPO pins, self flashing, and accessing more than 16MiB of ROM.
{| class="wikitable"
! Category
! Port
! Description
! Bits
! Type
! Notes
|-
! rowspan="3" | RTC
! rowspan="2" | $CA
| RTC Command
| style="text-align: right" | <tt style="white-space: nowrap">...1 CCCC</tt>
| W8
| Command (C)
|-
| RTC Status
| style="text-align: right" | <tt style="white-space: nowrap">D00B CCCC</tt>
| R8
| Busy (B), Command (C), Ready (R)
|-
! $CB
| RTC Payload
| style="text-align: right" | <tt style="white-space: nowrap">dddd dddd</tt>
| RW8
| Data (d)
|-
! rowspan="2" | GPO
! $CC
| GPO Data Direction
| style="text-align: right" | <tt style="white-space: nowrap">0000 oooo</tt>
| RW8
| 1 = output, 0 = high-impedance (weak pull-down)
|-
! $CD
| GPO Data
| style="text-align: right" | <tt style="white-space: nowrap">0000 dddd</tt>
| RW8
| 1 = 3V, if enabled by data direction
|-
! Self-Flash
! $CE
| Self-Flash Control
| style="text-align: right" | <tt style="white-space: nowrap">0000 000r</tt>
| RW8
| 1 = ROM is accessed via the 0x10000 - 0x1FFFF memory region.
0 = RAM is accessed via the region.
|-
! rowspan="4" | Extended bankswitching
! $CF
| ROM Linear (EX) Bank
| style="text-align: right" | <tt style="white-space: nowrap">00bb bbbb</tt>
| RW8
| Selects a 1MiB bank accessed via memory addresses 0x40000 - 0xFFFFF.
Identical to the $C0 port.
|-
! $D0
| RAM(/ROM) Bank
| style="text-align: right" | <tt style="white-space: nowrap">0000 00bb bbbb bbbb</tt>
| RW16
| Selects a 64KiB bank accessed via memory addresses 0x10000 - 0x1FFFF.
Lower 8 bits are identical to the $C1 port.
|-
! $D2
| ROM0 Bank
| style="text-align: right" | <tt style="white-space: nowrap">0000 00bb bbbb bbbb</tt>
| RW16
| Selects a 64KiB bank accessed via memory addresses 0x20000 - 0x2FFFF.
Lower 8 bits are identical to the $C2 port.
|-
! $D4
| ROM1 Bank
| style="text-align: right" | <tt style="white-space: nowrap">0000 00bb bbbb bbbb</tt>
| RW16
| Selects a 64KiB bank accessed via memory addresses 0x30000 - 0x3FFFF.
Lower 8 bits are identical to the $C3 port.
|}
== Real-Time Clock ==
The 2003's RTC interface is a simple half-duplex SPI-like protocol.
For specifics of what the S-3511A expects to be done with these bytes, see [[Real-Time Clock]].
=== Usage ===
Writing a valid command to port <tt>$CA</tt> will start a transaction.
The Busy bit is set for the duration of a command transaction being processed, including when payload bytes are expected to be written or read.
The Ready bit is set when <tt>$CB</tt> is ready for access. It is cleared when a payload byte is written (for commands which expect writes), read (for commands which expect reads), or either written or read (when the Busy bit is clear).
For commands which require bytes to be sent, the first byte should be written to port <tt>$CB</tt> before starting the command with a port <tt>$CA</tt> write. The 2003 will pause for subsequent bytes and set bit 7, if necessary.
For commands which return bytes to be read, they can be accessed through port <tt>$CB</tt> after the Ready bit is set or if the Busy bit is clear.
If there is no external S-3511A, all bytes will read back as $FF due to a weak pull-up inside the 2003.
=== Commands ===
Each valid command sends its command byte, followed by a fixed number of payload bytes to be sent or received.
Invalid commands immediately stop the transaction. This cannot be safely used to abort an ongoing transaction, because the 2003 still relays the 384kHz clock. In contrast, normal termination stops relaying that clock.
{| class="wikitable"
! Command
! Command byte
! Bytes sent
! Bytes received
|-
| <tt>$00</tt> - <tt>$0F</tt>
| colspan="3" style="text-align:center;" | N/A
|-
| <tt>$10</tt>
| <tt>$60</tt>
| colspan="2" | None
|-
| <tt>$11</tt>
| <tt>$61</tt>
| colspan="2" | None
|-
| <tt>$12</tt>
| <tt>$62</tt>
| style="text-align:right;" | 1
|
|-
| <tt>$13</tt>
| <tt>$63</tt>
|
| style="text-align:right;" | 1
|-
| <tt>$14</tt>
| <tt>$64</tt>
| style="text-align:right;" | 7
|
|-
| <tt>$15</tt>
| <tt>$65</tt>
|
| style="text-align:right;" | 7
|-
| <tt>$16</tt>
| <tt>$66</tt>
| style="text-align:right;" | 3
|
|-
| <tt>$17</tt>
| <tt>$67</tt>
|
| style="text-align:right;" | 3
|-
| <tt>$18</tt>
| <tt>$68</tt>
| style="text-align:right;" | 2
|
|-
| <tt>$19</tt>
| <tt>$69</tt>
|
| style="text-align:right;" | 2
|-
| <tt>$1A</tt>
| <tt>$6A</tt>
| style="text-align:right;" | 2
|
|-
| <tt>$1B</tt>
| <tt>$6B</tt>
|
| style="text-align:right;" | 2
|-
| <tt>$1C</tt> - <tt>$1F</tt>
| colspan="3" style="text-align:center;" | N/A
|}
== Self-flashing ==
The 2003 mapper allows mapping the ROM chip in the PSRAM area using the <tt>$CE</tt> port. This can be used for writing to a NOR flash chip acting as the cartridge's ROM.
Note that the SRAM memory area is always accessed in byte as opposed to word mode. This means that, if the ROM/flash chip is normally accessed in word mode, the $CE port will only work correctly with the /BYTE pin connected to the mapper.
== Lockout ==
Unlike the 2001 mapper, the 2003 mapper checks for the address line changes which are part of the authentication handshake after power-up. Until this handshake occurs, ROM access is inhibited. (TODO: How exactly?)
7e935263ba9095575ea1b58e4ef281536ee44f41
566
565
2025-03-15T16:55:06Z
Asie
351
wikitext
text/x-wiki
The Bandai 2003 (LUXSOR2) is one of the two mappers used in WonderSwan cartridges.
In addition to the normal [[Mapper]] banking interface, Bandai's 2003 adds registers for an RTC interface, GPO pins, self flashing, and accessing more than 16MiB of ROM.
{| class="wikitable"
! Category
! Port
! Description
! Bits
! Type
! Notes
|-
! rowspan="3" | RTC
! rowspan="2" | $CA
| RTC Command
| style="text-align: right" | <tt style="white-space: nowrap">...1 CCCC</tt>
| W8
| Command (C)
|-
| RTC Status
| style="text-align: right" | <tt style="white-space: nowrap">R00B CCCC</tt>
| R8
| Busy (B), Command (C), Ready (R)
|-
! $CB
| RTC Payload
| style="text-align: right" | <tt style="white-space: nowrap">dddd dddd</tt>
| RW8
| Data (d)
|-
! rowspan="2" | GPO
! $CC
| GPO Data Direction
| style="text-align: right" | <tt style="white-space: nowrap">0000 oooo</tt>
| RW8
| 1 = output, 0 = high-impedance (weak pull-down)
|-
! $CD
| GPO Data
| style="text-align: right" | <tt style="white-space: nowrap">0000 dddd</tt>
| RW8
| 1 = 3V, if enabled by data direction
|-
! Self-Flash
! $CE
| Self-Flash Control
| style="text-align: right" | <tt style="white-space: nowrap">0000 000r</tt>
| RW8
| 1 = ROM is accessed via the 0x10000 - 0x1FFFF memory region.
0 = RAM is accessed via the region.
|-
! rowspan="4" | Extended bankswitching
! $CF
| ROM Linear (EX) Bank
| style="text-align: right" | <tt style="white-space: nowrap">00bb bbbb</tt>
| RW8
| Selects a 1MiB bank accessed via memory addresses 0x40000 - 0xFFFFF.
Identical to the $C0 port.
|-
! $D0
| RAM(/ROM) Bank
| style="text-align: right" | <tt style="white-space: nowrap">0000 00bb bbbb bbbb</tt>
| RW16
| Selects a 64KiB bank accessed via memory addresses 0x10000 - 0x1FFFF.
Lower 8 bits are identical to the $C1 port.
|-
! $D2
| ROM0 Bank
| style="text-align: right" | <tt style="white-space: nowrap">0000 00bb bbbb bbbb</tt>
| RW16
| Selects a 64KiB bank accessed via memory addresses 0x20000 - 0x2FFFF.
Lower 8 bits are identical to the $C2 port.
|-
! $D4
| ROM1 Bank
| style="text-align: right" | <tt style="white-space: nowrap">0000 00bb bbbb bbbb</tt>
| RW16
| Selects a 64KiB bank accessed via memory addresses 0x30000 - 0x3FFFF.
Lower 8 bits are identical to the $C3 port.
|}
== Real-Time Clock ==
The 2003's RTC interface is a simple half-duplex SPI-like protocol.
For specifics of what the S-3511A expects to be done with these bytes, see [[Real-Time Clock]].
=== Usage ===
Writing a valid command to port <tt>$CA</tt> will start a transaction.
The Busy bit is set for the duration of a command transaction being processed, including when payload bytes are expected to be written or read.
The Ready bit is set when <tt>$CB</tt> is ready for access. It is cleared when a payload byte is written (for commands which expect writes), read (for commands which expect reads), or either written or read (when the Busy bit is clear).
For commands which require bytes to be sent, the first byte should be written to port <tt>$CB</tt> before starting the command with a port <tt>$CA</tt> write. The 2003 will pause for subsequent bytes and set bit 7, if necessary.
For commands which return bytes to be read, they can be accessed through port <tt>$CB</tt> after the Ready bit is set or if the Busy bit is clear.
If there is no external S-3511A, all bytes will read back as $FF due to a weak pull-up inside the 2003.
=== Commands ===
Each valid command sends its command byte, followed by a fixed number of payload bytes to be sent or received.
Invalid commands immediately stop the transaction. This cannot be safely used to abort an ongoing transaction, because the 2003 still relays the 384kHz clock. In contrast, normal termination stops relaying that clock.
{| class="wikitable"
! Command
! Command byte
! Bytes sent
! Bytes received
|-
| <tt>$00</tt> - <tt>$0F</tt>
| colspan="3" style="text-align:center;" | N/A
|-
| <tt>$10</tt>
| <tt>$60</tt>
| colspan="2" | None
|-
| <tt>$11</tt>
| <tt>$61</tt>
| colspan="2" | None
|-
| <tt>$12</tt>
| <tt>$62</tt>
| style="text-align:right;" | 1
|
|-
| <tt>$13</tt>
| <tt>$63</tt>
|
| style="text-align:right;" | 1
|-
| <tt>$14</tt>
| <tt>$64</tt>
| style="text-align:right;" | 7
|
|-
| <tt>$15</tt>
| <tt>$65</tt>
|
| style="text-align:right;" | 7
|-
| <tt>$16</tt>
| <tt>$66</tt>
| style="text-align:right;" | 3
|
|-
| <tt>$17</tt>
| <tt>$67</tt>
|
| style="text-align:right;" | 3
|-
| <tt>$18</tt>
| <tt>$68</tt>
| style="text-align:right;" | 2
|
|-
| <tt>$19</tt>
| <tt>$69</tt>
|
| style="text-align:right;" | 2
|-
| <tt>$1A</tt>
| <tt>$6A</tt>
| style="text-align:right;" | 2
|
|-
| <tt>$1B</tt>
| <tt>$6B</tt>
|
| style="text-align:right;" | 2
|-
| <tt>$1C</tt> - <tt>$1F</tt>
| colspan="3" style="text-align:center;" | N/A
|}
== Self-flashing ==
The 2003 mapper allows mapping the ROM chip in the PSRAM area using the <tt>$CE</tt> port. This can be used for writing to a NOR flash chip acting as the cartridge's ROM.
Note that the SRAM memory area is always accessed in byte as opposed to word mode. This means that, if the ROM/flash chip is normally accessed in word mode, the $CE port will only work correctly with the /BYTE pin connected to the mapper.
== Lockout ==
Unlike the 2001 mapper, the 2003 mapper checks for the address line changes which are part of the authentication handshake after power-up. Until this handshake occurs, ROM access is inhibited. (TODO: How exactly?)
2cea834eb759cd7bc3d7d6aa2b3220cec98df414
567
566
2025-03-15T17:42:46Z
Asie
351
wikitext
text/x-wiki
The Bandai 2003 (LUXSOR2) is one of the two mappers used in WonderSwan cartridges.
In addition to the normal [[Mapper]] banking interface, Bandai's 2003 adds registers for an RTC interface, GPO pins, self flashing, and accessing more than 16MiB of ROM.
{| class="wikitable"
! Category
! Port
! Description
! Bits
! Type
! Notes
|-
! rowspan="3" | RTC
! rowspan="2" | $CA
| RTC Command
| style="text-align: right" | <tt style="white-space: nowrap">...1 CCCC</tt>
| W8
| Command (C)
|-
| RTC Status
| style="text-align: right" | <tt style="white-space: nowrap">R00B CCCC</tt>
| R8
| Busy (B), Command (C), Ready (R)
|-
! $CB
| RTC Payload
| style="text-align: right" | <tt style="white-space: nowrap">dddd dddd</tt>
| RW8
| Data (d)
|-
! rowspan="2" | GPO
! $CC
| GPO Data Direction
| style="text-align: right" | <tt style="white-space: nowrap">0000 oooo</tt>
| RW8
| 1 = output, 0 = high-impedance (weak pull-down)
|-
! $CD
| GPO Data
| style="text-align: right" | <tt style="white-space: nowrap">0000 dddd</tt>
| RW8
| 1 = 3V, if enabled by data direction
|-
! Self-Flash
! $CE
| Self-Flash Control
| style="text-align: right" | <tt style="white-space: nowrap">0000 000r</tt>
| RW8
| 1 = ROM is accessed via the 0x10000 - 0x1FFFF memory region.
0 = RAM is accessed via the region.
|-
! rowspan="4" | Extended bankswitching
! $CF
| ROM Linear (EX) Bank
| style="text-align: right" | <tt style="white-space: nowrap">00bb bbbb</tt>
| RW8
| Selects a 1MiB bank accessed via memory addresses 0x40000 - 0xFFFFF.
Identical to the $C0 port.
|-
! $D0
| RAM(/ROM) Bank
| style="text-align: right" | <tt style="white-space: nowrap">0000 00bb bbbb bbbb</tt>
| RW16
| Selects a 64KiB bank accessed via memory addresses 0x10000 - 0x1FFFF.
Lower 8 bits are identical to the $C1 port.
|-
! $D2
| ROM0 Bank
| style="text-align: right" | <tt style="white-space: nowrap">0000 00bb bbbb bbbb</tt>
| RW16
| Selects a 64KiB bank accessed via memory addresses 0x20000 - 0x2FFFF.
Lower 8 bits are identical to the $C2 port.
|-
! $D4
| ROM1 Bank
| style="text-align: right" | <tt style="white-space: nowrap">0000 00bb bbbb bbbb</tt>
| RW16
| Selects a 64KiB bank accessed via memory addresses 0x30000 - 0x3FFFF.
Lower 8 bits are identical to the $C3 port.
|}
== Real-Time Clock ==
The 2003's RTC interface is a simple half-duplex SPI-like protocol.
For specifics of what the S-3511A expects to be done with these bytes, see [[Real-Time Clock]].
=== Usage ===
Writing a valid command (see below) to port <tt>$CA</tt> will start a command transaction.
The Busy bit is set for the duration of a command transaction being processed, including when payload bytes are expected to be written or read.
The Ready bit is set when <tt>$CB</tt> is ready for access. It is cleared when a payload byte is written (for commands which expect writes), read (for commands which expect reads), or either written or read (when the Busy bit is clear). Notably, this also means that the bit is set after the final byte is written, despite not requiring another write at that point.
For commands which require bytes to be sent, the first byte should be written to port <tt>$CB</tt> before starting the command with a port <tt>$CA</tt> write. The 2003 will pause for subsequent bytes and set bit 7, if necessary.
For commands which return bytes to be read, they can be accessed through port <tt>$CB</tt> after the Ready bit is set or if the Busy bit is clear.
If there is no external S-3511A, all bytes will read back as $FF due to a weak pull-up inside the 2003.
=== Commands ===
Each valid command sends its command byte, followed by a fixed number of payload bytes to be sent or received.
Invalid commands immediately stop the transaction. This cannot be safely used to abort an ongoing transaction, because the 2003 still relays the 384kHz clock. In contrast, normal termination stops relaying that clock.
{| class="wikitable"
! Command
! Command byte
! Bytes sent
! Bytes received
|-
| <tt>$00</tt> - <tt>$0F</tt>
| colspan="3" style="text-align:center;" | N/A
|-
| <tt>$10</tt>
| <tt>$60</tt>
| colspan="2" | None
|-
| <tt>$11</tt>
| <tt>$61</tt>
| colspan="2" | None
|-
| <tt>$12</tt>
| <tt>$62</tt>
| style="text-align:right;" | 1
|
|-
| <tt>$13</tt>
| <tt>$63</tt>
|
| style="text-align:right;" | 1
|-
| <tt>$14</tt>
| <tt>$64</tt>
| style="text-align:right;" | 7
|
|-
| <tt>$15</tt>
| <tt>$65</tt>
|
| style="text-align:right;" | 7
|-
| <tt>$16</tt>
| <tt>$66</tt>
| style="text-align:right;" | 3
|
|-
| <tt>$17</tt>
| <tt>$67</tt>
|
| style="text-align:right;" | 3
|-
| <tt>$18</tt>
| <tt>$68</tt>
| style="text-align:right;" | 2
|
|-
| <tt>$19</tt>
| <tt>$69</tt>
|
| style="text-align:right;" | 2
|-
| <tt>$1A</tt>
| <tt>$6A</tt>
| style="text-align:right;" | 2
|
|-
| <tt>$1B</tt>
| <tt>$6B</tt>
|
| style="text-align:right;" | 2
|-
| <tt>$1C</tt> - <tt>$1F</tt>
| colspan="3" style="text-align:center;" | N/A
|}
== Self-flashing ==
The 2003 mapper allows mapping the ROM chip in the PSRAM area using the <tt>$CE</tt> port. This can be used for writing to a NOR flash chip acting as the cartridge's ROM.
Note that the SRAM memory area is always accessed in byte as opposed to word mode. This means that, if the ROM/flash chip is normally accessed in word mode, the $CE port will only work correctly with the /BYTE pin connected to the mapper.
== Lockout ==
Unlike the 2001 mapper, the 2003 mapper checks for the address line changes which are part of the authentication handshake after power-up. Until this handshake occurs, ROM access is inhibited. (TODO: How exactly?)
768fe8b88453637530be6f0790dd1389ea850f90
569
567
2025-03-16T07:13:49Z
Asie
351
/* Commands */
wikitext
text/x-wiki
The Bandai 2003 (LUXSOR2) is one of the two mappers used in WonderSwan cartridges.
In addition to the normal [[Mapper]] banking interface, Bandai's 2003 adds registers for an RTC interface, GPO pins, self flashing, and accessing more than 16MiB of ROM.
{| class="wikitable"
! Category
! Port
! Description
! Bits
! Type
! Notes
|-
! rowspan="3" | RTC
! rowspan="2" | $CA
| RTC Command
| style="text-align: right" | <tt style="white-space: nowrap">...1 CCCC</tt>
| W8
| Command (C)
|-
| RTC Status
| style="text-align: right" | <tt style="white-space: nowrap">R00B CCCC</tt>
| R8
| Busy (B), Command (C), Ready (R)
|-
! $CB
| RTC Payload
| style="text-align: right" | <tt style="white-space: nowrap">dddd dddd</tt>
| RW8
| Data (d)
|-
! rowspan="2" | GPO
! $CC
| GPO Data Direction
| style="text-align: right" | <tt style="white-space: nowrap">0000 oooo</tt>
| RW8
| 1 = output, 0 = high-impedance (weak pull-down)
|-
! $CD
| GPO Data
| style="text-align: right" | <tt style="white-space: nowrap">0000 dddd</tt>
| RW8
| 1 = 3V, if enabled by data direction
|-
! Self-Flash
! $CE
| Self-Flash Control
| style="text-align: right" | <tt style="white-space: nowrap">0000 000r</tt>
| RW8
| 1 = ROM is accessed via the 0x10000 - 0x1FFFF memory region.
0 = RAM is accessed via the region.
|-
! rowspan="4" | Extended bankswitching
! $CF
| ROM Linear (EX) Bank
| style="text-align: right" | <tt style="white-space: nowrap">00bb bbbb</tt>
| RW8
| Selects a 1MiB bank accessed via memory addresses 0x40000 - 0xFFFFF.
Identical to the $C0 port.
|-
! $D0
| RAM(/ROM) Bank
| style="text-align: right" | <tt style="white-space: nowrap">0000 00bb bbbb bbbb</tt>
| RW16
| Selects a 64KiB bank accessed via memory addresses 0x10000 - 0x1FFFF.
Lower 8 bits are identical to the $C1 port.
|-
! $D2
| ROM0 Bank
| style="text-align: right" | <tt style="white-space: nowrap">0000 00bb bbbb bbbb</tt>
| RW16
| Selects a 64KiB bank accessed via memory addresses 0x20000 - 0x2FFFF.
Lower 8 bits are identical to the $C2 port.
|-
! $D4
| ROM1 Bank
| style="text-align: right" | <tt style="white-space: nowrap">0000 00bb bbbb bbbb</tt>
| RW16
| Selects a 64KiB bank accessed via memory addresses 0x30000 - 0x3FFFF.
Lower 8 bits are identical to the $C3 port.
|}
== Real-Time Clock ==
The 2003's RTC interface is a simple half-duplex SPI-like protocol.
For specifics of what the S-3511A expects to be done with these bytes, see [[Real-Time Clock]].
=== Usage ===
Writing a valid command (see below) to port <tt>$CA</tt> will start a command transaction.
The Busy bit is set for the duration of a command transaction being processed, including when payload bytes are expected to be written or read.
The Ready bit is set when <tt>$CB</tt> is ready for access. It is cleared when a payload byte is written (for commands which expect writes), read (for commands which expect reads), or either written or read (when the Busy bit is clear). Notably, this also means that the bit is set after the final byte is written, despite not requiring another write at that point.
For commands which require bytes to be sent, the first byte should be written to port <tt>$CB</tt> before starting the command with a port <tt>$CA</tt> write. The 2003 will pause for subsequent bytes and set bit 7, if necessary.
For commands which return bytes to be read, they can be accessed through port <tt>$CB</tt> after the Ready bit is set or if the Busy bit is clear.
If there is no external S-3511A, all bytes will read back as $FF due to a weak pull-up inside the 2003.
=== Commands ===
Each valid command sends its command byte, followed by a fixed number of payload bytes to be sent or received.
Invalid commands immediately stop the transaction. This cannot be safely used to abort an ongoing transaction, because the 2003 still relays the 384kHz clock. In contrast, normal termination stops relaying that clock.
{| class="wikitable"
! Command
! Command byte
! Bytes to RTC
! Bytes from RTC
|-
| <tt>$00</tt> - <tt>$0F</tt>
| colspan="3" style="text-align:center;" | N/A
|-
| <tt>$10</tt>
| <tt>$60</tt>
| colspan="2" | None
|-
| <tt>$11</tt>
| <tt>$61</tt>
| colspan="2" | None
|-
| <tt>$12</tt>
| <tt>$62</tt>
| style="text-align:right;" | 1
|
|-
| <tt>$13</tt>
| <tt>$63</tt>
|
| style="text-align:right;" | 1
|-
| <tt>$14</tt>
| <tt>$64</tt>
| style="text-align:right;" | 7
|
|-
| <tt>$15</tt>
| <tt>$65</tt>
|
| style="text-align:right;" | 7
|-
| <tt>$16</tt>
| <tt>$66</tt>
| style="text-align:right;" | 3
|
|-
| <tt>$17</tt>
| <tt>$67</tt>
|
| style="text-align:right;" | 3
|-
| <tt>$18</tt>
| <tt>$68</tt>
| style="text-align:right;" | 2
|
|-
| <tt>$19</tt>
| <tt>$69</tt>
|
| style="text-align:right;" | 2
|-
| <tt>$1A</tt>
| <tt>$6A</tt>
| style="text-align:right;" | 2
|
|-
| <tt>$1B</tt>
| <tt>$6B</tt>
|
| style="text-align:right;" | 2
|-
| <tt>$1C</tt> - <tt>$1F</tt>
| colspan="3" style="text-align:center;" | N/A
|}
== Self-flashing ==
The 2003 mapper allows mapping the ROM chip in the PSRAM area using the <tt>$CE</tt> port. This can be used for writing to a NOR flash chip acting as the cartridge's ROM.
Note that the SRAM memory area is always accessed in byte as opposed to word mode. This means that, if the ROM/flash chip is normally accessed in word mode, the $CE port will only work correctly with the /BYTE pin connected to the mapper.
== Lockout ==
Unlike the 2001 mapper, the 2003 mapper checks for the address line changes which are part of the authentication handshake after power-up. Until this handshake occurs, ROM access is inhibited. (TODO: How exactly?)
3715d52040d2d80fe668793ad09932eb70cb9ad0
570
569
2025-03-16T07:32:42Z
Asie
351
/* Real-Time Clock */
wikitext
text/x-wiki
The Bandai 2003 (LUXSOR2) is one of the two mappers used in WonderSwan cartridges.
In addition to the normal [[Mapper]] banking interface, Bandai's 2003 adds registers for an RTC interface, GPO pins, self flashing, and accessing more than 16MiB of ROM.
{| class="wikitable"
! Category
! Port
! Description
! Bits
! Type
! Notes
|-
! rowspan="3" | RTC
! rowspan="2" | $CA
| RTC Command
| style="text-align: right" | <tt style="white-space: nowrap">...1 CCCC</tt>
| W8
| Command (C)
|-
| RTC Status
| style="text-align: right" | <tt style="white-space: nowrap">R00B CCCC</tt>
| R8
| Busy (B), Command (C), Ready (R)
|-
! $CB
| RTC Payload
| style="text-align: right" | <tt style="white-space: nowrap">dddd dddd</tt>
| RW8
| Data (d)
|-
! rowspan="2" | GPO
! $CC
| GPO Data Direction
| style="text-align: right" | <tt style="white-space: nowrap">0000 oooo</tt>
| RW8
| 1 = output, 0 = high-impedance (weak pull-down)
|-
! $CD
| GPO Data
| style="text-align: right" | <tt style="white-space: nowrap">0000 dddd</tt>
| RW8
| 1 = 3V, if enabled by data direction
|-
! Self-Flash
! $CE
| Self-Flash Control
| style="text-align: right" | <tt style="white-space: nowrap">0000 000r</tt>
| RW8
| 1 = ROM is accessed via the 0x10000 - 0x1FFFF memory region.
0 = RAM is accessed via the region.
|-
! rowspan="4" | Extended bankswitching
! $CF
| ROM Linear (EX) Bank
| style="text-align: right" | <tt style="white-space: nowrap">00bb bbbb</tt>
| RW8
| Selects a 1MiB bank accessed via memory addresses 0x40000 - 0xFFFFF.
Identical to the $C0 port.
|-
! $D0
| RAM(/ROM) Bank
| style="text-align: right" | <tt style="white-space: nowrap">0000 00bb bbbb bbbb</tt>
| RW16
| Selects a 64KiB bank accessed via memory addresses 0x10000 - 0x1FFFF.
Lower 8 bits are identical to the $C1 port.
|-
! $D2
| ROM0 Bank
| style="text-align: right" | <tt style="white-space: nowrap">0000 00bb bbbb bbbb</tt>
| RW16
| Selects a 64KiB bank accessed via memory addresses 0x20000 - 0x2FFFF.
Lower 8 bits are identical to the $C2 port.
|-
! $D4
| ROM1 Bank
| style="text-align: right" | <tt style="white-space: nowrap">0000 00bb bbbb bbbb</tt>
| RW16
| Selects a 64KiB bank accessed via memory addresses 0x30000 - 0x3FFFF.
Lower 8 bits are identical to the $C3 port.
|}
== Real-Time Clock ==
The 2003's RTC interface is a simple half-duplex SPI-like protocol.
For specifics of what the S-3511A expects to be done with these bytes, see [[Real-Time Clock]].
=== Usage ===
Writing a valid command (see below) to port <tt>$CA</tt> will start a command transaction. The value of the command can be read from <tt>$CA</tt>; for valid commands, bit 4 will be cleared once the command is completed; for invalid commands, bit 4 will remain as written.
The Busy bit is set for the duration of a command transaction being processed, including when payload bytes are expected to be written or read.
The Ready bit is set when <tt>$CB</tt> is ready for access - both after each byte written or read, as well as at the end of a command (including zero-byte commands like <tt>$10</tt>). It is cleared when a payload byte is written (for commands which expect writes), read (for commands which expect reads), or either written or read (when the Busy bit is clear).
For commands which require bytes to be sent, the first byte should be written to port <tt>$CB</tt> before starting the command with a port <tt>$CA</tt> write. The 2003 will pause for subsequent bytes and set bit 7, if necessary.
For commands which return bytes to be read, they can be accessed through port <tt>$CB</tt> after the Ready bit is set or if the Busy bit is clear.
If there is no external S-3511A, all bytes will read back as $FF due to a weak pull-up inside the 2003.
=== Commands ===
Each valid command sends its command byte, followed by a fixed number of payload bytes to be sent or received.
Invalid commands immediately stop the transaction. This cannot be safely used to abort an ongoing transaction, because the 2003 still relays the 384kHz clock. In contrast, normal termination stops relaying that clock.
{| class="wikitable"
! Command
! Command byte
! Bytes to RTC
! Bytes from RTC
|-
| <tt>$00</tt> - <tt>$0F</tt>
| colspan="3" style="text-align:center;" | N/A
|-
| <tt>$10</tt>
| <tt>$60</tt>
| colspan="2" | None
|-
| <tt>$11</tt>
| <tt>$61</tt>
| colspan="2" | None
|-
| <tt>$12</tt>
| <tt>$62</tt>
| style="text-align:right;" | 1
|
|-
| <tt>$13</tt>
| <tt>$63</tt>
|
| style="text-align:right;" | 1
|-
| <tt>$14</tt>
| <tt>$64</tt>
| style="text-align:right;" | 7
|
|-
| <tt>$15</tt>
| <tt>$65</tt>
|
| style="text-align:right;" | 7
|-
| <tt>$16</tt>
| <tt>$66</tt>
| style="text-align:right;" | 3
|
|-
| <tt>$17</tt>
| <tt>$67</tt>
|
| style="text-align:right;" | 3
|-
| <tt>$18</tt>
| <tt>$68</tt>
| style="text-align:right;" | 2
|
|-
| <tt>$19</tt>
| <tt>$69</tt>
|
| style="text-align:right;" | 2
|-
| <tt>$1A</tt>
| <tt>$6A</tt>
| style="text-align:right;" | 2
|
|-
| <tt>$1B</tt>
| <tt>$6B</tt>
|
| style="text-align:right;" | 2
|-
| <tt>$1C</tt> - <tt>$1F</tt>
| colspan="3" style="text-align:center;" | N/A
|}
== Self-flashing ==
The 2003 mapper allows mapping the ROM chip in the PSRAM area using the <tt>$CE</tt> port. This can be used for writing to a NOR flash chip acting as the cartridge's ROM.
Note that the SRAM memory area is always accessed in byte as opposed to word mode. This means that, if the ROM/flash chip is normally accessed in word mode, the $CE port will only work correctly with the /BYTE pin connected to the mapper.
== Lockout ==
Unlike the 2001 mapper, the 2003 mapper checks for the address line changes which are part of the authentication handshake after power-up. Until this handshake occurs, ROM access is inhibited. (TODO: How exactly?)
7485a84ebf82c05f0778a8405accd690678eb5f7
576
570
2025-03-29T11:19:43Z
Generic
362
SRAM instead of PSRAM area (too much nileswan :) )
wikitext
text/x-wiki
The Bandai 2003 (LUXSOR2) is one of the two mappers used in WonderSwan cartridges.
In addition to the normal [[Mapper]] banking interface, Bandai's 2003 adds registers for an RTC interface, GPO pins, self flashing, and accessing more than 16MiB of ROM.
{| class="wikitable"
! Category
! Port
! Description
! Bits
! Type
! Notes
|-
! rowspan="3" | RTC
! rowspan="2" | $CA
| RTC Command
| style="text-align: right" | <tt style="white-space: nowrap">...1 CCCC</tt>
| W8
| Command (C)
|-
| RTC Status
| style="text-align: right" | <tt style="white-space: nowrap">R00B CCCC</tt>
| R8
| Busy (B), Command (C), Ready (R)
|-
! $CB
| RTC Payload
| style="text-align: right" | <tt style="white-space: nowrap">dddd dddd</tt>
| RW8
| Data (d)
|-
! rowspan="2" | GPO
! $CC
| GPO Data Direction
| style="text-align: right" | <tt style="white-space: nowrap">0000 oooo</tt>
| RW8
| 1 = output, 0 = high-impedance (weak pull-down)
|-
! $CD
| GPO Data
| style="text-align: right" | <tt style="white-space: nowrap">0000 dddd</tt>
| RW8
| 1 = 3V, if enabled by data direction
|-
! Self-Flash
! $CE
| Self-Flash Control
| style="text-align: right" | <tt style="white-space: nowrap">0000 000r</tt>
| RW8
| 1 = ROM is accessed via the 0x10000 - 0x1FFFF memory region.
0 = RAM is accessed via the region.
|-
! rowspan="4" | Extended bankswitching
! $CF
| ROM Linear (EX) Bank
| style="text-align: right" | <tt style="white-space: nowrap">00bb bbbb</tt>
| RW8
| Selects a 1MiB bank accessed via memory addresses 0x40000 - 0xFFFFF.
Identical to the $C0 port.
|-
! $D0
| RAM(/ROM) Bank
| style="text-align: right" | <tt style="white-space: nowrap">0000 00bb bbbb bbbb</tt>
| RW16
| Selects a 64KiB bank accessed via memory addresses 0x10000 - 0x1FFFF.
Lower 8 bits are identical to the $C1 port.
|-
! $D2
| ROM0 Bank
| style="text-align: right" | <tt style="white-space: nowrap">0000 00bb bbbb bbbb</tt>
| RW16
| Selects a 64KiB bank accessed via memory addresses 0x20000 - 0x2FFFF.
Lower 8 bits are identical to the $C2 port.
|-
! $D4
| ROM1 Bank
| style="text-align: right" | <tt style="white-space: nowrap">0000 00bb bbbb bbbb</tt>
| RW16
| Selects a 64KiB bank accessed via memory addresses 0x30000 - 0x3FFFF.
Lower 8 bits are identical to the $C3 port.
|}
== Real-Time Clock ==
The 2003's RTC interface is a simple half-duplex SPI-like protocol.
For specifics of what the S-3511A expects to be done with these bytes, see [[Real-Time Clock]].
=== Usage ===
Writing a valid command (see below) to port <tt>$CA</tt> will start a command transaction. The value of the command can be read from <tt>$CA</tt>; for valid commands, bit 4 will be cleared once the command is completed; for invalid commands, bit 4 will remain as written.
The Busy bit is set for the duration of a command transaction being processed, including when payload bytes are expected to be written or read.
The Ready bit is set when <tt>$CB</tt> is ready for access - both after each byte written or read, as well as at the end of a command (including zero-byte commands like <tt>$10</tt>). It is cleared when a payload byte is written (for commands which expect writes), read (for commands which expect reads), or either written or read (when the Busy bit is clear).
For commands which require bytes to be sent, the first byte should be written to port <tt>$CB</tt> before starting the command with a port <tt>$CA</tt> write. The 2003 will pause for subsequent bytes and set bit 7, if necessary.
For commands which return bytes to be read, they can be accessed through port <tt>$CB</tt> after the Ready bit is set or if the Busy bit is clear.
If there is no external S-3511A, all bytes will read back as $FF due to a weak pull-up inside the 2003.
=== Commands ===
Each valid command sends its command byte, followed by a fixed number of payload bytes to be sent or received.
Invalid commands immediately stop the transaction. This cannot be safely used to abort an ongoing transaction, because the 2003 still relays the 384kHz clock. In contrast, normal termination stops relaying that clock.
{| class="wikitable"
! Command
! Command byte
! Bytes to RTC
! Bytes from RTC
|-
| <tt>$00</tt> - <tt>$0F</tt>
| colspan="3" style="text-align:center;" | N/A
|-
| <tt>$10</tt>
| <tt>$60</tt>
| colspan="2" | None
|-
| <tt>$11</tt>
| <tt>$61</tt>
| colspan="2" | None
|-
| <tt>$12</tt>
| <tt>$62</tt>
| style="text-align:right;" | 1
|
|-
| <tt>$13</tt>
| <tt>$63</tt>
|
| style="text-align:right;" | 1
|-
| <tt>$14</tt>
| <tt>$64</tt>
| style="text-align:right;" | 7
|
|-
| <tt>$15</tt>
| <tt>$65</tt>
|
| style="text-align:right;" | 7
|-
| <tt>$16</tt>
| <tt>$66</tt>
| style="text-align:right;" | 3
|
|-
| <tt>$17</tt>
| <tt>$67</tt>
|
| style="text-align:right;" | 3
|-
| <tt>$18</tt>
| <tt>$68</tt>
| style="text-align:right;" | 2
|
|-
| <tt>$19</tt>
| <tt>$69</tt>
|
| style="text-align:right;" | 2
|-
| <tt>$1A</tt>
| <tt>$6A</tt>
| style="text-align:right;" | 2
|
|-
| <tt>$1B</tt>
| <tt>$6B</tt>
|
| style="text-align:right;" | 2
|-
| <tt>$1C</tt> - <tt>$1F</tt>
| colspan="3" style="text-align:center;" | N/A
|}
== Self-flashing ==
The 2003 mapper allows mapping the ROM chip in the SRAM area using the <tt>$CE</tt> port. This can be used for writing to a NOR flash chip acting as the cartridge's ROM.
Note that the SRAM memory area is always accessed in byte as opposed to word mode. This means that, if the ROM/flash chip is normally accessed in word mode, the $CE port will only work correctly with the /BYTE pin connected to the mapper.
== Lockout ==
Unlike the 2001 mapper, the 2003 mapper checks for the address line changes which are part of the authentication handshake after power-up. Until this handshake occurs, ROM access is inhibited. (TODO: How exactly?)
f64cb4c92f5c5b2c81dc8c8c92440c5be7812077
578
576
2025-04-03T16:47:02Z
Asie
351
/* Usage */
wikitext
text/x-wiki
The Bandai 2003 (LUXSOR2) is one of the two mappers used in WonderSwan cartridges.
In addition to the normal [[Mapper]] banking interface, Bandai's 2003 adds registers for an RTC interface, GPO pins, self flashing, and accessing more than 16MiB of ROM.
{| class="wikitable"
! Category
! Port
! Description
! Bits
! Type
! Notes
|-
! rowspan="3" | RTC
! rowspan="2" | $CA
| RTC Command
| style="text-align: right" | <tt style="white-space: nowrap">...1 CCCC</tt>
| W8
| Command (C)
|-
| RTC Status
| style="text-align: right" | <tt style="white-space: nowrap">R00B CCCC</tt>
| R8
| Busy (B), Command (C), Ready (R)
|-
! $CB
| RTC Payload
| style="text-align: right" | <tt style="white-space: nowrap">dddd dddd</tt>
| RW8
| Data (d)
|-
! rowspan="2" | GPO
! $CC
| GPO Data Direction
| style="text-align: right" | <tt style="white-space: nowrap">0000 oooo</tt>
| RW8
| 1 = output, 0 = high-impedance (weak pull-down)
|-
! $CD
| GPO Data
| style="text-align: right" | <tt style="white-space: nowrap">0000 dddd</tt>
| RW8
| 1 = 3V, if enabled by data direction
|-
! Self-Flash
! $CE
| Self-Flash Control
| style="text-align: right" | <tt style="white-space: nowrap">0000 000r</tt>
| RW8
| 1 = ROM is accessed via the 0x10000 - 0x1FFFF memory region.
0 = RAM is accessed via the region.
|-
! rowspan="4" | Extended bankswitching
! $CF
| ROM Linear (EX) Bank
| style="text-align: right" | <tt style="white-space: nowrap">00bb bbbb</tt>
| RW8
| Selects a 1MiB bank accessed via memory addresses 0x40000 - 0xFFFFF.
Identical to the $C0 port.
|-
! $D0
| RAM(/ROM) Bank
| style="text-align: right" | <tt style="white-space: nowrap">0000 00bb bbbb bbbb</tt>
| RW16
| Selects a 64KiB bank accessed via memory addresses 0x10000 - 0x1FFFF.
Lower 8 bits are identical to the $C1 port.
|-
! $D2
| ROM0 Bank
| style="text-align: right" | <tt style="white-space: nowrap">0000 00bb bbbb bbbb</tt>
| RW16
| Selects a 64KiB bank accessed via memory addresses 0x20000 - 0x2FFFF.
Lower 8 bits are identical to the $C2 port.
|-
! $D4
| ROM1 Bank
| style="text-align: right" | <tt style="white-space: nowrap">0000 00bb bbbb bbbb</tt>
| RW16
| Selects a 64KiB bank accessed via memory addresses 0x30000 - 0x3FFFF.
Lower 8 bits are identical to the $C3 port.
|}
== Real-Time Clock ==
The 2003's RTC interface is a simple half-duplex SPI-like protocol.
For specifics of what the S-3511A expects to be done with these bytes, see [[Real-Time Clock]].
=== Usage ===
Writing a valid command (see below) to port <tt>$CA</tt> will start a command transaction. The value of the command can be read from <tt>$CA</tt>; for valid commands, bit 4 will be cleared once the command is completed; for invalid commands, bit 4 will remain as written.
The Busy bit is set for the duration of a command transaction being processed, including when payload bytes are expected to be written or read.
The Ready bit is set when <tt>$CB</tt> is ready for access - both after each byte written or read, as well as at the end of a command (including zero-byte commands like <tt>$10</tt>). It is cleared when a payload byte is written (for commands which expect writes), read (for commands which expect reads), or either written or read (when the Busy bit is clear). Writing a new command to port <tt>$CA</tt> also clears the Ready bit.
For commands which require bytes to be sent, the first byte should be written to port <tt>$CB</tt> before starting the command with a port <tt>$CA</tt> write. The 2003 will pause for subsequent bytes and set bit 7, if necessary.
For commands which return bytes to be read, they can be accessed through port <tt>$CB</tt> after the Ready bit is set or if the Busy bit is clear.
If there is no external S-3511A, all bytes will read back as $FF due to a weak pull-up inside the 2003.
=== Commands ===
Each valid command sends its command byte, followed by a fixed number of payload bytes to be sent or received.
Invalid commands immediately stop the transaction. This cannot be safely used to abort an ongoing transaction, because the 2003 still relays the 384kHz clock. In contrast, normal termination stops relaying that clock.
{| class="wikitable"
! Command
! Command byte
! Bytes to RTC
! Bytes from RTC
|-
| <tt>$00</tt> - <tt>$0F</tt>
| colspan="3" style="text-align:center;" | N/A
|-
| <tt>$10</tt>
| <tt>$60</tt>
| colspan="2" | None
|-
| <tt>$11</tt>
| <tt>$61</tt>
| colspan="2" | None
|-
| <tt>$12</tt>
| <tt>$62</tt>
| style="text-align:right;" | 1
|
|-
| <tt>$13</tt>
| <tt>$63</tt>
|
| style="text-align:right;" | 1
|-
| <tt>$14</tt>
| <tt>$64</tt>
| style="text-align:right;" | 7
|
|-
| <tt>$15</tt>
| <tt>$65</tt>
|
| style="text-align:right;" | 7
|-
| <tt>$16</tt>
| <tt>$66</tt>
| style="text-align:right;" | 3
|
|-
| <tt>$17</tt>
| <tt>$67</tt>
|
| style="text-align:right;" | 3
|-
| <tt>$18</tt>
| <tt>$68</tt>
| style="text-align:right;" | 2
|
|-
| <tt>$19</tt>
| <tt>$69</tt>
|
| style="text-align:right;" | 2
|-
| <tt>$1A</tt>
| <tt>$6A</tt>
| style="text-align:right;" | 2
|
|-
| <tt>$1B</tt>
| <tt>$6B</tt>
|
| style="text-align:right;" | 2
|-
| <tt>$1C</tt> - <tt>$1F</tt>
| colspan="3" style="text-align:center;" | N/A
|}
== Self-flashing ==
The 2003 mapper allows mapping the ROM chip in the SRAM area using the <tt>$CE</tt> port. This can be used for writing to a NOR flash chip acting as the cartridge's ROM.
Note that the SRAM memory area is always accessed in byte as opposed to word mode. This means that, if the ROM/flash chip is normally accessed in word mode, the $CE port will only work correctly with the /BYTE pin connected to the mapper.
== Lockout ==
Unlike the 2001 mapper, the 2003 mapper checks for the address line changes which are part of the authentication handshake after power-up. Until this handshake occurs, ROM access is inhibited. (TODO: How exactly?)
2740b30b5a2b4270325af5c85851e78ac18d74c5
Bandai 2001
0
12
568
407
2025-03-15T17:48:47Z
Asie
351
$C4 is separate for read and write
wikitext
text/x-wiki
The Bandai 2001 (LUXSOR) is one of the two mappers used in WonderSwan cartridges.
In addition to the normal [[Mapper]] banking interface, Bandai's 2001 adds three registers for interacting with a Microwire EEPROM:
{| class="wikitable"
! Category
! Port
! Description
! Bits
! Type
! Notes
|-
! rowspan="4" | External EEPROM
! rowspan="2" | $C4
| rowspan="2" | External EEPROM Data
| rowspan="2" style="text-align: right" | <tt style="white-space: nowrap">dddd dddd dddd dddd</tt>
| R16
| Data read (d)
|-
| W16
| Data to write (d)
|-
! $C6
| External EEPROM Command
| style="text-align: right" | <tt style="white-space: nowrap">0001 CCaa aaaa aaaa</tt><br/>or <tt style="white-space: nowrap">0000 01CC aaaa aaaa</tt><br/> or <tt style="white-space: nowrap">0000 0001 CCaa aaaa</tt>
| RW16
| Command and address
|-
! rowspan=2|$C8
| External EEPROM Control
| style="text-align: right" | <tt style="white-space: nowrap">ASWR ....</tt>
| W8
| Abort (A), Short (S), Write (W), Read (R)
|-
| External EEPROM Status
| style="text-align: right" | <tt style="white-space: nowrap">.... ..rd</tt>
| R8
| Ready (r), Done (d)
|-
|}
== EEPROM ==
The 2001's EEPROM interface is similar to the internal EEPROM interface, as documented on [[EEPROM#I/O_ports|the EEPROM page]]. Differences include:
* Instead of the internal EEPROM interface's P(rotect) bit, the A(bort) bit is provided. When the A bit is set, the transaction immediately stops.
* The EEPROM "done" bit is buggy and doesn't have useful information. It's set when a Read completes, but is only cleared when a Command or Write is started. (To be useful it would need to also be cleared when a Read is started).
(Upload logic analyzer traces here)
d483574f7c004b3fd1f53432b89ecb121c9a953c
571
568
2025-03-16T08:24:07Z
Lidnariq
7
forgot this
wikitext
text/x-wiki
The Bandai 2001 (LUXSOR) is one of the two mappers used in WonderSwan cartridges.
In addition to the normal [[Mapper]] banking interface, Bandai's 2001 adds three registers for interacting with a Microwire EEPROM:
{| class="wikitable"
! Category
! Port
! Description
! Bits
! Type
! Notes
|-
! rowspan="5" | External EEPROM
! rowspan="2" | $C4
| rowspan="2" | External EEPROM Data
| rowspan="2" style="text-align: right" | <tt style="white-space: nowrap">dddd dddd dddd dddd</tt>
| R16
| Data read (d)
|-
| W16
| Data to write (d)
|-
! $C6
| External EEPROM Command
| style="text-align: right" | <tt style="white-space: nowrap">0001 CCaa aaaa aaaa</tt><br/>or <tt style="white-space: nowrap">0000 01CC aaaa aaaa</tt><br/> or <tt style="white-space: nowrap">0000 0001 CCaa aaaa</tt>
| RW16
| Command and address
|-
! rowspan=2|$C8
| External EEPROM Control
| style="text-align: right" | <tt style="white-space: nowrap">ASWR ....</tt>
| W8
| Abort (A), Short (S), Write (W), Read (R)
|-
| External EEPROM Status
| style="text-align: right" | <tt style="white-space: nowrap">.... ..rd</tt>
| R8
| Ready (r), Done (d)
|-
|}
== EEPROM ==
The 2001's EEPROM interface is similar to the internal EEPROM interface, as documented on [[EEPROM#I/O_ports|the EEPROM page]]. Differences include:
* Instead of the internal EEPROM interface's P(rotect) bit, the A(bort) bit is provided. When the A bit is set, the transaction immediately stops.
* The EEPROM "done" bit is buggy and doesn't have useful information. It's set when a Read completes, but is only cleared when a Command or Write is started. (To be useful it would need to also be cleared when a Read is started).
(Upload logic analyzer traces here)
f6ce0674399d0e5074cb484a759092e82983baf7
Splash animation
0
34
573
165
2025-03-23T12:52:02Z
Asie
351
/* Format */ Name color is not part of splash data; it's user-editable
wikitext
text/x-wiki
The WonderSwan Color upgraded the [[EEPROM|internal EEPROM]] from 128 bytes to 2 kilobytes; most of the additional space is utilized to allow for branding consoles in the form of unique, custom splash animations on console startup.
== Format ==
{| class="wikitable"
|-
! Offset !! Length !! Contents
|-
| $85 || 1 || Must be $00
|-
| $86 || 1 || Size; 0 = ends at <= $3FF, 1 = ends at <= $7FF
|-
| $87 || 1 || First frame
|-
| $88 || 1 || Last frame
|-
| $89 || 1 || Sprite count
|-
| $8A || 1 || Palette flags
|-
| $8B || 1 || Tile count
|-
| $8C || 2 || Palette location - $80
|-
| $8E || 2 || Tile data location - $80
|-
| $90 || 2 || Tilemap location - $80
|-
| $92 || 2 || Screen offset (Horizontal)
|-
| $94 || 2 || Screen offset (Vertical)
|-
| $96 || 1 || Tilemap width
|-
| $97 || 1 || Tilemap height
|-
| $98 || 2 || VBlank IRQ handler offset
|-
| $9A || 2 || VBlank IRQ handler segment, must be $0600
|-
| $9C || 1 || Owner name X (horizontal)
|-
| $9D || 1 || Owner name Y (horizontal)
|-
| $9E || 1 || Owner name X (vertical)
|-
| $9F || 1 || Owner name Y (vertical)
|-
| $A0 || 2 || Padding, unused
|-
| $A2 || 2 || Sound wavetable location - $80
|-
| $A4 || 2 || Sound channel 1 data offset - $80
|-
| $A6 || 2 || Sound channel 2 data offset - $80
|-
| $A8 || 2 || Sound channel 3 data offset - $80
|-
| $AA || 2 || Sound channel 4 data offset - $80
|-
| $AC || 10 || SwanCrystal TFT LCD configuration
|-
| $B6 || 10 || Padding, unused
|-
| $C0 || ... || Arbitrary data - palettes, tilemaps, etc.
|}
=== Palette flags ===
<pre>
7 bit 0
---- ----
b..p pppp
| +-++++- Palette count (0-16)
+--------- Tile/palette bits per pixel:
0 = 1 bit per pixel
1 = 2 bits per pixel
</pre>
=== Name colors ===
{| class="wikitable"
|-
! Value !! RGB code
|-
| 0 || #000
|-
| 1 || #f00
|-
| 2 || #f70
|-
| 3 || #ff0
|-
| 4 || #7f0
|-
| 5 || #0f0
|-
| 6 || #0f7
|-
| 7 || #0ff
|-
| 8 || #07f
|-
| 9 || #00f
|-
| 10 || #70f
|-
| 11 || #f0f
|-
| 12 || #f07
|}
=== VBlank IRQ handler ===
A custom splash animation ''must'' provide a valid VBlank IRQ handler, with the following rules:
* The segment must be ''0x0600''; the offset is provided relative to ''$80'', as with other data offsets.
* The code must end with a ''retf'' opcode, or equivalent.
=== Horizontal/Vertical orientation handling ===
The splash animation loader will automatically rotate the tile data and tilemap when booting a cartridge whose [[ROM header|header]] declares vertical orientation as its startup orientation.
=== Sound channel data format ===
TODO
4b652cb09cdf4d0c2ea0dce11eb0d39d2563c0e9
574
573
2025-03-23T12:52:53Z
Asie
351
/* Format */
wikitext
text/x-wiki
The WonderSwan Color upgraded the [[EEPROM|internal EEPROM]] from 128 bytes to 2 kilobytes; most of the additional space is utilized to allow for branding consoles in the form of unique, custom splash animations on console startup.
== Format ==
{| class="wikitable"
|-
! Offset !! Length !! Contents
|-
| $85 || 1 || Must be $00
|-
| $86 || 1 || Size; 0 = ends at <= $3FF, 1 = ends at <= $7FF
|-
| $87 || 1 || First frame
|-
| $88 || 1 || Last frame
|-
| $89 || 1 || Sprite count
|-
| $8A || 1 || Palette flags
|-
| $8B || 1 || Tile count
|-
| $8C || 2 || Palette location - $80
|-
| $8E || 2 || Tile data location - $80
|-
| $90 || 2 || Tilemap location - $80
|-
| $92 || 2 || Screen offset (Horizontal)
|-
| $94 || 2 || Screen offset (Vertical)
|-
| $96 || 1 || Tilemap width
|-
| $97 || 1 || Tilemap height
|-
| $98 || 2 || VBlank IRQ handler offset
|-
| $9A || 2 || VBlank IRQ handler segment, must be $0600
|-
| $9C || 1 || Owner name X (horizontal)
|-
| $9D || 1 || Owner name Y (horizontal)
|-
| $9E || 1 || Owner name X (vertical)
|-
| $9F || 1 || Owner name Y (vertical)
|-
| $A0 || 2 || Padding, unused
|-
| $A2 || 2 || Sound wavetable location - $80
|-
| $A4 || 2 || Sound channel 1 data offset - $80
|-
| $A6 || 2 || Sound channel 2 data offset - $80
|-
| $A8 || 2 || Sound channel 3 data offset - $80
|-
| $AA || 2 || Sound channel 4 data offset - $80
|-
| $AC || 10 || SwanCrystal TFT LCD configuration
|-
| $B6 || 10 || Padding, unused
|-
| $C0 || ... || Arbitrary data - palettes, tilemaps, etc.
|}
=== Palette flags ===
<pre>
7 bit 0
---- ----
b..p pppp
| +-++++- Palette count (0-16)
+--------- Tile/palette bits per pixel:
0 = 1 bit per pixel
1 = 2 bits per pixel
</pre>
=== VBlank IRQ handler ===
A custom splash animation ''must'' provide a valid VBlank IRQ handler, with the following rules:
* The segment must be ''0x0600''; the offset is provided relative to ''$80'', as with other data offsets.
* The code must end with a ''retf'' opcode, or equivalent.
=== Horizontal/Vertical orientation handling ===
The splash animation loader will automatically rotate the tile data and tilemap when booting a cartridge whose [[ROM header|header]] declares vertical orientation as its startup orientation.
=== Sound channel data format ===
TODO
39a6f2560d6dea6ce50c52e602a45dce6aba957b
EEPROM
0
35
575
408
2025-03-23T12:55:37Z
Asie
351
/* Internal EEPROM Layout */ Move name color information, add missing color 13
wikitext
text/x-wiki
The WonderSwan utilizes M93LCx6-compatible EEPROMs:
* in the SoC:
** 1 Kbit internal EEPROM (M93LC46-compatible) on the WonderSwan,
** 16 Kbit internal EEPROM (M93LC86-compatible) on the WonderSwan Color,
* on cartridges:
** 1 Kbit cartridge EEPROM (M93LC46-compatible)
** 8 Kbit cartridge EEPROM (M93LC76-compatible)
** 16 Kbit cartridge EEPROM (M93LC86-compatible)
Additional variants exists which were not seen on any production cartridge:
* 256 bit EEPROM (M93LC06-compatible)
* 2 Kbit EEPROM (M93LC56-compatible)
* 4 Kbit EEPROM (M93LC66-compatible)
== Commands ==
=== READ - Read Word ===
The READ command takes an address of a word (address 0 => bytes 0, 1; address 1 => bytes 2, 3; ...) and returns the word at that address.
=== WRITE - Write Word ===
The WRITE command takes an address of a word (address 0 => bytes 0, 1; address 1 => bytes 2, 3; ...) and the word to write to it, then writes the word.
=== ERASE - Erase Word ===
The ERASE command takes an address of a word (address 0 => bytes 0, 1; address 1 => bytes 2, 3; ...) and erases the word at that address, setting it to 0xFFFF.
=== WDS - Write Disable ===
The WDS command prevents issued write and erase commands from having an effect on the EEPROM.
=== WRAL - Write All ===
The WRAL command erases the word at all address of the EEPROM, setting them to 0xFFFF.
This command is not guaranteed to be present on all EEPROMs.
=== ERAL - Erase All ===
The WRAL command takes a word and writes it to all addresses of the EEPROM.
This command is not guaranteed to be present on all EEPROMs.
=== WEN - Write Enable ===
The WEN command restores the effect of issued write and erase commands on the EEPROM disabled using WDS.
== I/O ports ==
The I/O ports listed refer to the internal EEPROM; for the cartridge EEPROM port numbers, refer to the [[Bandai 2001|mapper documentation]].
It is recommended to only access the data and command ports with aligned word reads/writes; see the ''Errata'' section for more information.
{{Anchor|Internal EEPROM Data}}
=== Internal EEPROM Data ($BA, $BB read) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
dddd dddd dddd dddd
|||| |||| |||| ||||
++++-++++--++++-++++- Data read from the EEPROM.
</pre>
The read buffer's value changes only once the Read command is completed.
=== Internal EEPROM Data ($BA, $BB write) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
dddd dddd dddd dddd
|||| |||| |||| ||||
++++-++++--++++-++++- Data to write to the EEPROM.
</pre>
The write buffer is latched when a Write command is initiated; further writes to it do not affect the value written by that specific command.
The two EEPROM data buffers are not shared; neither writes to the write buffer nor the execution of non-read commands affect the contents of the read buffer.
{{Anchor|Internal EEPROM Command}}
=== Internal EEPROM Command ($BC, $BD) ===
<pre>
Command Pattern 1
15 bit 8 7 bit 0
---- ---- ---- ----
0000 0001 ooaa aaaa (¼, 1 Kbit - M93LC06/46)
0000 01oo aaaa aaaa (2, 4 Kbit - M93LC56/66)
0001 ooaa aaaa aaaa (8, 16 Kbit - M93LC76/86)
|||| |||| ||||
||++--++++-++++- Address (MSb .. LSb)
++-------------- Opcode:
01 - WRITE
10 - READ
11 - ERASE
</pre>
<pre>
Command Pattern 2
15 bit 8 7 bit 0
---- ---- ---- ----
0000 0001 00ss .... (¼, 1 Kbit - M93LC06/46)
0000 0100 ss.. .... (2, 4 Kbit - M93LC56/66)
0001 00ss .... .... (8, 16 Kbit - M93LC76/86)
||||
||++------------ Sub-Opcode:
|| 00 - WDS
|| 01 - WRAL
|| 10 - ERAL
|| 11 - WEN
++-------------- Opcode:
00
</pre>
The value written to this port can be read back; it is not affected by ''EEPROM Control''.
{{Anchor|Internal EEPROM Control}}
=== Internal EEPROM Control ($BE, $BF write) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
.... .... PSWR ....
||||
|||+------ Read operation: 1 for READ command, 0 otherwise
||+------- Write operation: 1 for WRITE and WRAL command, 0 otherwise
|+-------- Short operation: 1 for ERASE, WDS, ERAL and WEN command, 0 otherwise
+--------- Protection: 1 to enable internal EEPROM write protection.
Cannot be cleared once set.
</pre>
* Read operation: Sends 16 bits from Command, then reads 16 bits to Data.
* Write operation: Sends 16 bits from Command, then 16 bits from Data. De-asserts Microwire chip select, then re-asserts it and waits for the EEPROM to confirm command completion.
* Short operation: Sends 16 bits from Command, de-asserts Microwire chip select.
* Protection: Enables internal EEPROM write protection (addresses >= 0x30, or anything after the first 96 bytes, can no longer be written to).
If more than one of the Read, Write, Short, Protect bits are set, the operation is treated as invalid (all four operation bits are cleared and no communication is done with the EEPROM). Notably, this means that writing, for example, 0x90 does not protect the internal EEPROM if it wasn't already protected, but writing 0x80 does.
The command requested here should match the command sent to the EEPROM in port ''$BC''.
{{Anchor|Internal EEPROM Status}}
=== Internal EEPROM Status ($BE, $BF read) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
.... .... P... ..rd
| ||
| |+- 0 after a Read command is initiated,
| | 1 once a Read command is completed.
| | Unaffected by Write/Erase commands.
| +-- 0 if the EEPROM is busy,
| 1 if a command can be accepted (idle).
+--------- Internal EEPROM write protection:
0 = disabled, 1 = enabled
</pre>
== Internal EEPROM Layout ==
{| class="wikitable"
|-
! Offset !! Length !! Contents
|-
| $00 || 96 || Program data. Can be written by programs even if write protection has been enabled.
|-
| $60 || 16 || Owner name, custom character set.
|-
| $70 || 1 || Owner birthday year, BCD, first/higher two digits
|-
| $71 || 1 || Owner birthday year, BCD, last/lower two digits
|-
| $72 || 1 || Owner birthday month, BCD
|-
| $73 || 1 || Owner birthday day, BCD
|-
| $74 || 1 || Owner gender:<br/>
0 - ?<br/>
1 - Male<br/>
2 - Female
|-
| $75 || 1 || Owner blood type:<br/>
0 - ?<br/>
1 - A<br/>
2 - B<br/>
3 - 0<br/>
4 - AB
|-
| $76 || 1 || Last booted [[ROM header]] byte 6 (developer/publisher ID)
|-
| $77 || 1 || Last booted [[ROM header]] byte 7 (color)
|-
| $78 || 1 || Last booted [[ROM header]] byte 8 (game ID)
|-
| $7C || 1 || Stored cartridge ID/version change counter
|-
| $7D || 1 || Owner name change counter
|-
| $7E || 2 || System startup counter
|-
| $80 || 1 || Last booted [[ROM header]] byte 6 (developer/publisher ID) - only changed if byte 7 (color) != 0
|-
| $81 || 1 || Last booted [[ROM header]] byte 7 (color) - only changed if byte 7 (color) != 0
|-
| $82 || 1 || Last booted [[ROM header]] byte 8 (game ID) - only changed if byte 7 (color) != 0
|-
| $83 || 1 || Color model configuration
|-
| $84 || 1 || Name color
|-
| $85 || ? || [[Splash animation|Custom splash animation]], if present
|}
=== Owner name character set ===
{| class="wikitable"
|-
!
! <code>.0</code>
! <code>.1</code>
! <code>.2</code>
! <code>.3</code>
! <code>.4</code>
! <code>.5</code>
! <code>.6</code>
! <code>.7</code>
! <code>.8</code>
! <code>.9</code>
! <code>.A</code>
! <code>.B</code>
! <code>.C</code>
! <code>.D</code>
! <code>.E</code>
! <code>.F</code>
|-
! <code>0.</code>
| || 0 || 1 || 2 || 3 || 4 || 5 || 6 || 7 || 8 || 9 || A || B || C || D || E
|-
! <code>1.</code>
| F || G || H || I || J || K || L || M || N || O || P || Q || R || S || T || U
|-
! <code>2.</code>
| V || W || X || Y || Z || ♥ || ♪ || + || - || ? || .
!
!
!
!
!
|}
=== Color model configuration ===
<pre>
7 bit 0
---- ----
sc.. ..vv
|| ||
|| ++- Volume level
|+-------- Contrast (WSC): 0 = Low, 1 = High
+--------- Custom splash animation enabled
</pre>
=== Name colors ===
{| class="wikitable"
|-
! Value !! RGB code
|-
| 0 || #000
|-
| 1 || #f00
|-
| 2 || #f70
|-
| 3 || #ff0
|-
| 4 || #7f0
|-
| 5 || #0f0
|-
| 6 || #0f7
|-
| 7 || #0ff
|-
| 8 || #07f
|-
| 9 || #00f
|-
| 10 || #70f
|-
| 11 || #f0f
|-
| 12 || #f07
|-
| 13 || #fff
|}
== Hardware notes ==
EEPROM command bits are shifted out starting from the ''most'' significant bit of the port.
<pre>
+----> EEPROM Serial Data
|
[0] <= [0000 0001 ooaa aaaa]
EEPROM Command Port
</pre>
While the M93LCx6 family supports byte organization, the WonderSwan always uses word organization. As such, this implementation detail is omitted in this documentation.
The SPHINX SoC family emulates a 93C46 in ASWAN compatibility mode by manipulating the shifted out command value when sending it to the EEPROM (TODO: How exactly?).
== Errata ==
=== Non-word access on ASWAN ===
On the ASWAN SoC, accessing the internal EEPROM command ports as bytes only works correctly for even addresses. For odd addresses, these accesses return open bus; this means that unaligned word accesses also don't work, as they are converted to one odd and one even byte access internally.
It is recommended to only use aligned word port accesses to talk to the internal EEPROM.
This issue is not present on the SPHINX and newer SoCs, including in "mono" emulation mode, as well as the cartridge bus (which is always forced to be accessed per byte).
== Links ==
* [https://www.st.com/resource/en/datasheet/m93c46-w.pdf STMicroelectronics M93LCx6 datasheet]
a92da19fd6123c51381f5e4e7468811f1fc7cdd0
SoC
0
46
577
536
2025-03-30T10:58:40Z
Asie
351
/* System Control 3 ($62, color) */
wikitext
text/x-wiki
The WonderSwan SoC is a single-chip solution powering the entirety of the system's hardware - containing the CPU, most peripheral logic, as well as the internal RAM.
There exist three variants of the SoC:
* ASWAN, used in the WonderSwan,
* SPHINX, used in the WonderSwan Color,
* SPHINX2, used in the SwanCrystal.
A fourth variant, CAIRO, was planned<ref>[https://web.archive.org/web/20071023111112/http://www.koto.co.jp/products/mono_sp.html CAIRO グラフィックス機能内蔵ローコストSoC - Wayback Machine]</ref>. It was designed as an ASWAN with a doubled clock speed and a built-in ADPCM decoder, but is not known to have been licensed for any commercial product.
== I/O ports ==
{{Anchor|System Control}}
=== System Control ($A0) ===
<pre>
7 bit 0
---- ----
C??? swcl
| ||||
| |||+- Boot ROM lockout: 0 = off, 1 = on
| ||+-- Color model: 0 = no, 1 = yes
| |+--- Cartridge ROM width: 0 = 8-bit, 1 = 16-bit
| +---- Cartridge ROM wait state: 0 = +0 cycles, 1 = +1
+--------- Cartridge bus test OK
</pre>
{{Anchor|System Control 2}}
=== System Control 2 ($60, color) ===
<pre>
7 bit 0
---- ----
c4C. i?sl
||| | ||
||| | |+- Cartridge clock speed?
||| | +-- Cartridge SRAM wait state: 0 = +0 cycles, 1 = +1
||| +---- Cartridge I/O wait state: 0 = +0 cycles, 1 = +1
||+------- 1 = 4bpp "chunky"; requires all previous
|+-------- 1 = 4bpp; requires all previous
+--------- 0 = mono, 1 = color; also controls access
to WSC-specific features (extra RAM, DMA, etc.)
</pre>
{{Anchor|System Control 3}}
=== System Control 3 ($62, color) ===
<pre>
7 bit 0
---- ----
S... ...p
| |
| +- 1 = Request power off
+--------- 0 = WonderSwan Color (SPHINX)
1 = SwanCrystal (SPHINX2)
</pre>
After setting the "request power off" bit to 1, halting the CPU will cause the console to shut down.
TODO: <tt>$AC</tt> bit 0 seems to also shut down the console.
== Notes ==
<references />
1bb73bcf72d3dd12d046bc365cbe176c3b2d5632
586
577
2025-04-08T19:51:08Z
Asie
351
/* I/O ports */
wikitext
text/x-wiki
The WonderSwan SoC is a single-chip solution powering the entirety of the system's hardware - containing the CPU, most peripheral logic, as well as the internal RAM.
There exist three variants of the SoC:
* ASWAN, used in the WonderSwan,
* SPHINX, used in the WonderSwan Color,
* SPHINX2, used in the SwanCrystal.
A fourth variant, CAIRO, was planned<ref>[https://web.archive.org/web/20071023111112/http://www.koto.co.jp/products/mono_sp.html CAIRO グラフィックス機能内蔵ローコストSoC - Wayback Machine]</ref>. It was designed as an ASWAN with a doubled clock speed and a built-in ADPCM decoder, but is not known to have been licensed for any commercial product.
== I/O ports ==
{{Anchor|System Control}}
=== System Control ($A0) ===
<pre>
7 bit 0
---- ----
C??? swcl
| ||||
| |||+- Boot ROM lockout: 0 = off, 1 = on
| ||+-- Color model: 0 = no, 1 = yes
| |+--- Cartridge ROM width: 0 = 8-bit, 1 = 16-bit
| +---- Cartridge ROM wait state: 0 = +0 cycles, 1 = +1
+--------- Cartridge bus test OK
</pre>
{{Anchor|System Control 2}}
=== System Control 2 ($60, color) ===
<pre>
7 bit 0
---- ----
c4C. i?sl
||| | ||
||| | |+- Cartridge clock speed?
||| | +-- Cartridge SRAM wait state: 0 = +0 cycles, 1 = +1
||| +---- Cartridge I/O wait state: 0 = +0 cycles, 1 = +1
||+------- 1 = 4bpp "chunky"; requires all previous
|+-------- 1 = 4bpp; requires all previous
+--------- 0 = mono, 1 = color; also controls access
to WSC-specific features (extra RAM, DMA, etc.)
</pre>
{{Anchor|System Control 3}}
=== System Control 3 ($62, color) ===
<pre>
7 bit 0
---- ----
S... ...p
| |
| +- 1 = Request power off
+--------- 0 = WonderSwan Color (SPHINX)
1 = SwanCrystal (SPHINX2)
</pre>
After setting the "request power off" bit to 1, halting the CPU will cause the console to shut down.
TODO: <tt>$AC</tt> bit 0 seems to also shut down the console.
{{Anchor|System Test}}
=== System Test ($A3) ===
Note that this port is only writable as a byte - writing a word to <tt>$A2</tt> does not write to this byte.
<pre>
7 bit 0
---- ----
.... u?vh
| |+- Enable HBlank Timer test
| +-- Enable VBlank Timer test
+---- Enable UART test
</pre>
The timer tests ignore the reload value and clock the timers at 3072000? Hz. The enable bit is still respected.
The UART test disables the 9600/38400 baud clock divider, instead operating the EXT port's UART lines at 192000 baud.
== Notes ==
<references />
882227f0af58d4bdad1977deb018a75002bbe342
587
586
2025-04-09T15:53:19Z
Asie
351
/* System Control 2 ($60, color) */
wikitext
text/x-wiki
The WonderSwan SoC is a single-chip solution powering the entirety of the system's hardware - containing the CPU, most peripheral logic, as well as the internal RAM.
There exist three variants of the SoC:
* ASWAN, used in the WonderSwan,
* SPHINX, used in the WonderSwan Color,
* SPHINX2, used in the SwanCrystal.
A fourth variant, CAIRO, was planned<ref>[https://web.archive.org/web/20071023111112/http://www.koto.co.jp/products/mono_sp.html CAIRO グラフィックス機能内蔵ローコストSoC - Wayback Machine]</ref>. It was designed as an ASWAN with a doubled clock speed and a built-in ADPCM decoder, but is not known to have been licensed for any commercial product.
== I/O ports ==
{{Anchor|System Control}}
=== System Control ($A0) ===
<pre>
7 bit 0
---- ----
C??? swcl
| ||||
| |||+- Boot ROM lockout: 0 = off, 1 = on
| ||+-- Color model: 0 = no, 1 = yes
| |+--- Cartridge ROM width: 0 = 8-bit, 1 = 16-bit
| +---- Cartridge ROM wait state: 0 = +0 cycles, 1 = +1
+--------- Cartridge bus test OK
</pre>
{{Anchor|System Control 2}}
=== System Control 2 ($60, color) ===
<pre>
7 bit 0
---- ----
c4C. i.sl
||| | ||
||| | |+- Cartridge clock speed?
||| | +-- Cartridge SRAM wait state: 0 = +0 cycles, 1 = +1
||| +---- Cartridge I/O wait state: 0 = +0 cycles, 1 = +1
||+------- 1 = 4bpp "chunky"; requires all previous
|+-------- 1 = 4bpp; requires all previous
+--------- 0 = mono, 1 = color; also controls access
to WSC-specific features (extra RAM, DMA, etc.)
</pre>
{{Anchor|System Control 3}}
=== System Control 3 ($62, color) ===
<pre>
7 bit 0
---- ----
S... ...p
| |
| +- 1 = Request power off
+--------- 0 = WonderSwan Color (SPHINX)
1 = SwanCrystal (SPHINX2)
</pre>
After setting the "request power off" bit to 1, halting the CPU will cause the console to shut down.
TODO: <tt>$AC</tt> bit 0 seems to also shut down the console.
{{Anchor|System Test}}
=== System Test ($A3) ===
Note that this port is only writable as a byte - writing a word to <tt>$A2</tt> does not write to this byte.
<pre>
7 bit 0
---- ----
.... u?vh
| |+- Enable HBlank Timer test
| +-- Enable VBlank Timer test
+---- Enable UART test
</pre>
The timer tests ignore the reload value and clock the timers at 3072000? Hz. The enable bit is still respected.
The UART test disables the 9600/38400 baud clock divider, instead operating the EXT port's UART lines at 192000 baud.
== Notes ==
<references />
1a6546b17338d56187e46ca85e1b974452052127
Real-Time Clock
0
40
579
548
2025-04-07T13:54:24Z
Asie
351
/* Time */
wikitext
text/x-wiki
The [[Bandai 2003|2003]] mapper provides a special-purpose interface to interact with Seiko's S-3511A RTC chip.
This page will cover how games expect to interact with it; not the low-level protocol specifics. (For that see the datasheet and the Timing section of this wiki)
== Registers ==
=== Configuration ===
7 bit 0
---- ----
p2a0 m0f0
||| | |
||+--+-+-- Interrupt mode; see below
|+-------- 12/24 hour mode
| - 0: 12 hour mode
| - 1: 24 hour mode
+--------- Power failure occurred
Note that sending the Reset or Read Configuration commands clears the "power failure" bit.
==== Interrupt mode ====
{| class="wikitable"
! A
! M
! F
! Name
! Description
|-
| 0
| 0
| 0
| Disabled
| Continuously deasserts /IRQ pin.
|-
| 1
| 0
| 0
| Alarm
| Asserts /IRQ during the hour and minute set in the alarm configuration register.
|-
| rowspan="3" | x
| 0
| 1
| Frequency
| Subsecond prescaler is bitwise inverted, bitwise ANDed with the lower 15 bits of the "alarm configuration" register, then all fifteen bits are NORed together. This signal directly drives the /IRQ pin.
|-
| 1
| 0
| Per-minute edge
| Asserts /IRQ during the first 10 ms of each minute. During the following 990 ms, /IRQ can be deasserted by reading the configuration register.
|-
| 1
| 1
| Per-minute steady
| Asserts /IRQ during the first 10 ms of each minute. De-asserts /IRQ at the 30th second.
|}
=== Date/Time ===
The date and time is stored using seven bytes, of which the latter three correspond to the time.
==== Date ====
7 bit 0
---- ---- Byte 0
yyyy yyyy
|||| ||||
++++-++++- Year (00 - 99, BCD)
7 bit 0
---- ---- Byte 1
...m mmmm
| ||||
+-++++- Month (01 - 12, BCD)
7 bit 0
---- ---- Byte 2
..dd dddd
|| ||||
++-++++- Day of month (01 - 31, BCD)
7 bit 0
---- ---- Byte 3
.... .www
|||
+++- Day of week (0 - 6)
While this convention does not have to be followed, [[WonderWitch/FreyaBIOS|FreyaBIOS]] assumes that the first day of the week (0) is a Sunday, (1) is a Monday, ... (6) is a Saturday.
==== Time ====
7 bit 0
---- ---- Byte 4
p.hh hhhh
| || ||||
| ++-++++- Hour (00 - 11 or 23, BCD)
+--------- 0 = AM, 1 = PM
In the 24-hour mode, reading the AM/PM bit returns correct values; however, writes to the bit are ignored.
Writing invalid hour values (larger than <tt>$11</tt> or <tt>$23</tt>, or with an invalid low digit) writes <tt>$00</tt> instead.
7 bit 0
---- ---- Byte 5
.mmm mmmm
||| ||||
+++-++++- Minute (00 - 59, BCD)
Writing invalid minute values (larger than <tt>$59</tt>, or with an invalid low digit) writes <tt>$00</tt> instead.
7 bit 0
---- ---- Byte 6
.sss ssss
||| ||||
+++-++++- Second (00 - 59, BCD)
Writing invalid second values (larger than <tt>$59</tt>, or with an invalid low digit) stores the value, but forces a rollover after one second has passed.
=== Alarm configuration ===
The alarm configuration register is two bytes in size; its interpretation depends on the configured interrupt mode.
==== Interrupt mode: Alarm ====
7 bit 0
---- ---- Byte 0
p.hh hhhh
| || ||||
| ++-++++- Hour to match for the alarm (BCD)
+--------- AM/PM bit to match for the alarm
7 bit 0
---- ---- Byte 1
.mmm mmmm
||| ||||
+++-++++- Minute to match for the alarm (BCD)
Note that the hour encoding of the alarm must match the hour encoding used by the clock itself.
==== Interrupt mode: Frequency ====
7 bit 0
---- ---- Byte 0
abcd efgh
|||| ||||
|||| |||+- 32768 Hz
|||| ||+-- 16384 Hz
|||| |+--- 8192 Hz
|||| +---- 4096 Hz
|||+------ 2048 Hz
||+------- 1024 Hz
|+-------- 512 Hz
+--------- 256 Hz
7 bit 0
---- ---- Byte 1
abcd efgh
|||| ||||
|||| |||+- 128 Hz
|||| ||+-- 64 Hz
|||| |+--- 32 Hz
|||| +---- 16 Hz
|||+------ 8 Hz
||+------- 4 Hz
|+-------- 2 Hz
+--------- 1 Hz
=== Initial power on state ===
* Year = <tt>$00</tt>
* Month = <tt>$01</tt>
* Day of month = <tt>$01</tt>
* Day of week = <tt>$00</tt>
* Hour = <tt>$00</tt>
* Minute = <tt>$00</tt>
* Second = <tt>$00</tt>
* Configuration = <tt>$82</tt>
* Alarm = <tt>$8000</tt>
== Commands ==
=== Reset RTC ($10, $11) ===
Writing $10 or $11 to port $CA will send the "reset" command to the RTC. The S-3511A will then reset the following registers:
* Year = <tt>$00</tt>
* Month = <tt>$01</tt>
* Day of month = <tt>$01</tt>
* Day of week = <tt>$00</tt>
* Hour = <tt>$00</tt>
* Minute = <tt>$00</tt>
* Second = <tt>$00</tt>
* Configuration = <tt>$00</tt>
* Alarm = <tt>$0000</tt>
It is unknown if it resets the sub-second prescaler.
=== Write Configuration ($12) ===
Writing $12 to port $CA will send the "set configuration" command to the RTC. The 2003 expects that $CB contains valid contents by the time the 2003 sends that register's contents.
=== Read Configuration ($13) ===
Writing $13 to port $CA will send the "get configuration" command to the RTC.
=== Write current YMDdHMS ($14) ===
Writing $14 will set the current Year, Month, Day-of-Month, Day-of-Week, Hour, Minute, and Second.
=== Read current YMDdHMS ($15) ===
Writing $15 will get the current Year, Month, Day-of-Month, Day-of-Week, Hour, Minute, and Second.
=== Write current HMS ($16) ===
Writing $16 will set the current Hour, Minute, and Second.
These are the same as command $14.
=== Read current HMS ($17) ===
Writing $17 will get the current Hour, Minute, and Second.
=== Write alarm configuration ($18) ===
Writing $18 will set the current alarm configuration. The interpretation of these two bytes depend on the Configuration register
=== Nonsense alarm configuration ($19) ===
Writing $19 will set the current alarm configuration to $FFFF. The 2003 thinks it's reading from the S-3511A, but the S-3511A disagrees.
$FFFF will be read back by the 2003.
=== Write nonsense ($1A) ===
Writing $1A expects to send 2 bytes to the RTC. The S-3511A ignores them.
=== Read nonsense ($1B) ===
Writing $1B expects to read 2 bytes from the RTC. The S-3511A leaves its output high, returning $FFFF.
== Interrupts ==
The 2003 and S-3511A do not provide a thread-safe way to acknowledge the IRQ. Since the 2003 only holds one byte at a time, an interrupt can be fired in the middle of a multi-byte read or write without knowing what needs to be done for the rest of the command, nor how to safely restart that command when exiting the interrupt.
As such, the only choices are:
* all communication to the 2003 happens while cartridge IRQs are disabled, or
* the only thing the interrupt handler can do is [[Interrupts#Interrupt_Enable|mask]] the interrupt and then [[Interrupts#Interrupt_Acknowledge|acknowledge]] it, and only afterwards handle any subsequent communication.
c2f4b4c7489a97946375f405796527dd7c91f4fd
580
579
2025-04-07T13:54:48Z
Asie
351
/* Time */
wikitext
text/x-wiki
The [[Bandai 2003|2003]] mapper provides a special-purpose interface to interact with Seiko's S-3511A RTC chip.
This page will cover how games expect to interact with it; not the low-level protocol specifics. (For that see the datasheet and the Timing section of this wiki)
== Registers ==
=== Configuration ===
7 bit 0
---- ----
p2a0 m0f0
||| | |
||+--+-+-- Interrupt mode; see below
|+-------- 12/24 hour mode
| - 0: 12 hour mode
| - 1: 24 hour mode
+--------- Power failure occurred
Note that sending the Reset or Read Configuration commands clears the "power failure" bit.
==== Interrupt mode ====
{| class="wikitable"
! A
! M
! F
! Name
! Description
|-
| 0
| 0
| 0
| Disabled
| Continuously deasserts /IRQ pin.
|-
| 1
| 0
| 0
| Alarm
| Asserts /IRQ during the hour and minute set in the alarm configuration register.
|-
| rowspan="3" | x
| 0
| 1
| Frequency
| Subsecond prescaler is bitwise inverted, bitwise ANDed with the lower 15 bits of the "alarm configuration" register, then all fifteen bits are NORed together. This signal directly drives the /IRQ pin.
|-
| 1
| 0
| Per-minute edge
| Asserts /IRQ during the first 10 ms of each minute. During the following 990 ms, /IRQ can be deasserted by reading the configuration register.
|-
| 1
| 1
| Per-minute steady
| Asserts /IRQ during the first 10 ms of each minute. De-asserts /IRQ at the 30th second.
|}
=== Date/Time ===
The date and time is stored using seven bytes, of which the latter three correspond to the time.
==== Date ====
7 bit 0
---- ---- Byte 0
yyyy yyyy
|||| ||||
++++-++++- Year (00 - 99, BCD)
7 bit 0
---- ---- Byte 1
...m mmmm
| ||||
+-++++- Month (01 - 12, BCD)
7 bit 0
---- ---- Byte 2
..dd dddd
|| ||||
++-++++- Day of month (01 - 31, BCD)
7 bit 0
---- ---- Byte 3
.... .www
|||
+++- Day of week (0 - 6)
While this convention does not have to be followed, [[WonderWitch/FreyaBIOS|FreyaBIOS]] assumes that the first day of the week (0) is a Sunday, (1) is a Monday, ... (6) is a Saturday.
==== Time ====
7 bit 0
---- ---- Byte 4
p.hh hhhh
| || ||||
| ++-++++- Hour (00 - 11 or 23, BCD)
+--------- 0 = AM, 1 = PM
In the 24-hour mode, the AM/PM bit is set for values larger than or equal to <tt>$12</tt>. Writes to the bit are ignored.
Writing invalid hour values (larger than <tt>$11</tt> or <tt>$23</tt>, or with an invalid low digit) writes <tt>$00</tt> instead.
7 bit 0
---- ---- Byte 5
.mmm mmmm
||| ||||
+++-++++- Minute (00 - 59, BCD)
Writing invalid minute values (larger than <tt>$59</tt>, or with an invalid low digit) writes <tt>$00</tt> instead.
7 bit 0
---- ---- Byte 6
.sss ssss
||| ||||
+++-++++- Second (00 - 59, BCD)
Writing invalid second values (larger than <tt>$59</tt>, or with an invalid low digit) stores the value, but forces a rollover after one second has passed.
=== Alarm configuration ===
The alarm configuration register is two bytes in size; its interpretation depends on the configured interrupt mode.
==== Interrupt mode: Alarm ====
7 bit 0
---- ---- Byte 0
p.hh hhhh
| || ||||
| ++-++++- Hour to match for the alarm (BCD)
+--------- AM/PM bit to match for the alarm
7 bit 0
---- ---- Byte 1
.mmm mmmm
||| ||||
+++-++++- Minute to match for the alarm (BCD)
Note that the hour encoding of the alarm must match the hour encoding used by the clock itself.
==== Interrupt mode: Frequency ====
7 bit 0
---- ---- Byte 0
abcd efgh
|||| ||||
|||| |||+- 32768 Hz
|||| ||+-- 16384 Hz
|||| |+--- 8192 Hz
|||| +---- 4096 Hz
|||+------ 2048 Hz
||+------- 1024 Hz
|+-------- 512 Hz
+--------- 256 Hz
7 bit 0
---- ---- Byte 1
abcd efgh
|||| ||||
|||| |||+- 128 Hz
|||| ||+-- 64 Hz
|||| |+--- 32 Hz
|||| +---- 16 Hz
|||+------ 8 Hz
||+------- 4 Hz
|+-------- 2 Hz
+--------- 1 Hz
=== Initial power on state ===
* Year = <tt>$00</tt>
* Month = <tt>$01</tt>
* Day of month = <tt>$01</tt>
* Day of week = <tt>$00</tt>
* Hour = <tt>$00</tt>
* Minute = <tt>$00</tt>
* Second = <tt>$00</tt>
* Configuration = <tt>$82</tt>
* Alarm = <tt>$8000</tt>
== Commands ==
=== Reset RTC ($10, $11) ===
Writing $10 or $11 to port $CA will send the "reset" command to the RTC. The S-3511A will then reset the following registers:
* Year = <tt>$00</tt>
* Month = <tt>$01</tt>
* Day of month = <tt>$01</tt>
* Day of week = <tt>$00</tt>
* Hour = <tt>$00</tt>
* Minute = <tt>$00</tt>
* Second = <tt>$00</tt>
* Configuration = <tt>$00</tt>
* Alarm = <tt>$0000</tt>
It is unknown if it resets the sub-second prescaler.
=== Write Configuration ($12) ===
Writing $12 to port $CA will send the "set configuration" command to the RTC. The 2003 expects that $CB contains valid contents by the time the 2003 sends that register's contents.
=== Read Configuration ($13) ===
Writing $13 to port $CA will send the "get configuration" command to the RTC.
=== Write current YMDdHMS ($14) ===
Writing $14 will set the current Year, Month, Day-of-Month, Day-of-Week, Hour, Minute, and Second.
=== Read current YMDdHMS ($15) ===
Writing $15 will get the current Year, Month, Day-of-Month, Day-of-Week, Hour, Minute, and Second.
=== Write current HMS ($16) ===
Writing $16 will set the current Hour, Minute, and Second.
These are the same as command $14.
=== Read current HMS ($17) ===
Writing $17 will get the current Hour, Minute, and Second.
=== Write alarm configuration ($18) ===
Writing $18 will set the current alarm configuration. The interpretation of these two bytes depend on the Configuration register
=== Nonsense alarm configuration ($19) ===
Writing $19 will set the current alarm configuration to $FFFF. The 2003 thinks it's reading from the S-3511A, but the S-3511A disagrees.
$FFFF will be read back by the 2003.
=== Write nonsense ($1A) ===
Writing $1A expects to send 2 bytes to the RTC. The S-3511A ignores them.
=== Read nonsense ($1B) ===
Writing $1B expects to read 2 bytes from the RTC. The S-3511A leaves its output high, returning $FFFF.
== Interrupts ==
The 2003 and S-3511A do not provide a thread-safe way to acknowledge the IRQ. Since the 2003 only holds one byte at a time, an interrupt can be fired in the middle of a multi-byte read or write without knowing what needs to be done for the rest of the command, nor how to safely restart that command when exiting the interrupt.
As such, the only choices are:
* all communication to the 2003 happens while cartridge IRQs are disabled, or
* the only thing the interrupt handler can do is [[Interrupts#Interrupt_Enable|mask]] the interrupt and then [[Interrupts#Interrupt_Acknowledge|acknowledge]] it, and only afterwards handle any subsequent communication.
a66307d77a442be79dd3c038e6a6c5e76cd47471
583
580
2025-04-08T18:50:15Z
Asie
351
/* Interrupt mode: Alarm */
wikitext
text/x-wiki
The [[Bandai 2003|2003]] mapper provides a special-purpose interface to interact with Seiko's S-3511A RTC chip.
This page will cover how games expect to interact with it; not the low-level protocol specifics. (For that see the datasheet and the Timing section of this wiki)
== Registers ==
=== Configuration ===
7 bit 0
---- ----
p2a0 m0f0
||| | |
||+--+-+-- Interrupt mode; see below
|+-------- 12/24 hour mode
| - 0: 12 hour mode
| - 1: 24 hour mode
+--------- Power failure occurred
Note that sending the Reset or Read Configuration commands clears the "power failure" bit.
==== Interrupt mode ====
{| class="wikitable"
! A
! M
! F
! Name
! Description
|-
| 0
| 0
| 0
| Disabled
| Continuously deasserts /IRQ pin.
|-
| 1
| 0
| 0
| Alarm
| Asserts /IRQ during the hour and minute set in the alarm configuration register.
|-
| rowspan="3" | x
| 0
| 1
| Frequency
| Subsecond prescaler is bitwise inverted, bitwise ANDed with the lower 15 bits of the "alarm configuration" register, then all fifteen bits are NORed together. This signal directly drives the /IRQ pin.
|-
| 1
| 0
| Per-minute edge
| Asserts /IRQ during the first 10 ms of each minute. During the following 990 ms, /IRQ can be deasserted by reading the configuration register.
|-
| 1
| 1
| Per-minute steady
| Asserts /IRQ during the first 10 ms of each minute. De-asserts /IRQ at the 30th second.
|}
=== Date/Time ===
The date and time is stored using seven bytes, of which the latter three correspond to the time.
==== Date ====
7 bit 0
---- ---- Byte 0
yyyy yyyy
|||| ||||
++++-++++- Year (00 - 99, BCD)
7 bit 0
---- ---- Byte 1
...m mmmm
| ||||
+-++++- Month (01 - 12, BCD)
7 bit 0
---- ---- Byte 2
..dd dddd
|| ||||
++-++++- Day of month (01 - 31, BCD)
7 bit 0
---- ---- Byte 3
.... .www
|||
+++- Day of week (0 - 6)
While this convention does not have to be followed, [[WonderWitch/FreyaBIOS|FreyaBIOS]] assumes that the first day of the week (0) is a Sunday, (1) is a Monday, ... (6) is a Saturday.
==== Time ====
7 bit 0
---- ---- Byte 4
p.hh hhhh
| || ||||
| ++-++++- Hour (00 - 11 or 23, BCD)
+--------- 0 = AM, 1 = PM
In the 24-hour mode, the AM/PM bit is set for values larger than or equal to <tt>$12</tt>. Writes to the bit are ignored.
Writing invalid hour values (larger than <tt>$11</tt> or <tt>$23</tt>, or with an invalid low digit) writes <tt>$00</tt> instead.
7 bit 0
---- ---- Byte 5
.mmm mmmm
||| ||||
+++-++++- Minute (00 - 59, BCD)
Writing invalid minute values (larger than <tt>$59</tt>, or with an invalid low digit) writes <tt>$00</tt> instead.
7 bit 0
---- ---- Byte 6
.sss ssss
||| ||||
+++-++++- Second (00 - 59, BCD)
Writing invalid second values (larger than <tt>$59</tt>, or with an invalid low digit) stores the value, but forces a rollover after one second has passed.
=== Alarm configuration ===
The alarm configuration register is two bytes in size; its interpretation depends on the configured interrupt mode.
==== Interrupt mode: Alarm ====
7 bit 0
---- ---- Byte 0
p.hh hhhh
| || ||||
| ++-++++- Hour to match for the alarm (BCD)
+--------- AM/PM bit to match for the alarm
7 bit 0
---- ---- Byte 1
.mmm mmmm
||| ||||
+++-++++- Minute to match for the alarm (BCD)
Note that the hour encoding of the alarm must have the AM/PM bit set correctly, even in 24-hour mode.
==== Interrupt mode: Frequency ====
7 bit 0
---- ---- Byte 0
abcd efgh
|||| ||||
|||| |||+- 32768 Hz
|||| ||+-- 16384 Hz
|||| |+--- 8192 Hz
|||| +---- 4096 Hz
|||+------ 2048 Hz
||+------- 1024 Hz
|+-------- 512 Hz
+--------- 256 Hz
7 bit 0
---- ---- Byte 1
abcd efgh
|||| ||||
|||| |||+- 128 Hz
|||| ||+-- 64 Hz
|||| |+--- 32 Hz
|||| +---- 16 Hz
|||+------ 8 Hz
||+------- 4 Hz
|+-------- 2 Hz
+--------- 1 Hz
=== Initial power on state ===
* Year = <tt>$00</tt>
* Month = <tt>$01</tt>
* Day of month = <tt>$01</tt>
* Day of week = <tt>$00</tt>
* Hour = <tt>$00</tt>
* Minute = <tt>$00</tt>
* Second = <tt>$00</tt>
* Configuration = <tt>$82</tt>
* Alarm = <tt>$8000</tt>
== Commands ==
=== Reset RTC ($10, $11) ===
Writing $10 or $11 to port $CA will send the "reset" command to the RTC. The S-3511A will then reset the following registers:
* Year = <tt>$00</tt>
* Month = <tt>$01</tt>
* Day of month = <tt>$01</tt>
* Day of week = <tt>$00</tt>
* Hour = <tt>$00</tt>
* Minute = <tt>$00</tt>
* Second = <tt>$00</tt>
* Configuration = <tt>$00</tt>
* Alarm = <tt>$0000</tt>
It is unknown if it resets the sub-second prescaler.
=== Write Configuration ($12) ===
Writing $12 to port $CA will send the "set configuration" command to the RTC. The 2003 expects that $CB contains valid contents by the time the 2003 sends that register's contents.
=== Read Configuration ($13) ===
Writing $13 to port $CA will send the "get configuration" command to the RTC.
=== Write current YMDdHMS ($14) ===
Writing $14 will set the current Year, Month, Day-of-Month, Day-of-Week, Hour, Minute, and Second.
=== Read current YMDdHMS ($15) ===
Writing $15 will get the current Year, Month, Day-of-Month, Day-of-Week, Hour, Minute, and Second.
=== Write current HMS ($16) ===
Writing $16 will set the current Hour, Minute, and Second.
These are the same as command $14.
=== Read current HMS ($17) ===
Writing $17 will get the current Hour, Minute, and Second.
=== Write alarm configuration ($18) ===
Writing $18 will set the current alarm configuration. The interpretation of these two bytes depend on the Configuration register
=== Nonsense alarm configuration ($19) ===
Writing $19 will set the current alarm configuration to $FFFF. The 2003 thinks it's reading from the S-3511A, but the S-3511A disagrees.
$FFFF will be read back by the 2003.
=== Write nonsense ($1A) ===
Writing $1A expects to send 2 bytes to the RTC. The S-3511A ignores them.
=== Read nonsense ($1B) ===
Writing $1B expects to read 2 bytes from the RTC. The S-3511A leaves its output high, returning $FFFF.
== Interrupts ==
The 2003 and S-3511A do not provide a thread-safe way to acknowledge the IRQ. Since the 2003 only holds one byte at a time, an interrupt can be fired in the middle of a multi-byte read or write without knowing what needs to be done for the rest of the command, nor how to safely restart that command when exiting the interrupt.
As such, the only choices are:
* all communication to the 2003 happens while cartridge IRQs are disabled, or
* the only thing the interrupt handler can do is [[Interrupts#Interrupt_Enable|mask]] the interrupt and then [[Interrupts#Interrupt_Acknowledge|acknowledge]] it, and only afterwards handle any subsequent communication.
18e53acbace084e1d118a51793425bb62cc70da9
598
583
2025-04-21T09:58:52Z
Asie
351
/* Registers */ document date boundary conditions
wikitext
text/x-wiki
The [[Bandai 2003|2003]] mapper provides a special-purpose interface to interact with Seiko's S-3511A RTC chip.
This page will cover how games expect to interact with it; not the low-level protocol specifics. (For that see the datasheet and the Timing section of this wiki)
== Registers ==
=== Configuration ===
7 bit 0
---- ----
p2a0 m0f0
||| | |
||+--+-+-- Interrupt mode; see below
|+-------- 12/24 hour mode
| - 0: 12 hour mode
| - 1: 24 hour mode
+--------- Power failure occurred
Note that sending the Reset or Read Configuration commands clears the "power failure" bit.
==== Interrupt mode ====
{| class="wikitable"
! A
! M
! F
! Name
! Description
|-
| 0
| 0
| 0
| Disabled
| Continuously deasserts /IRQ pin.
|-
| 1
| 0
| 0
| Alarm
| Asserts /IRQ during the hour and minute set in the alarm configuration register.
|-
| rowspan="3" | x
| 0
| 1
| Frequency
| Subsecond prescaler is bitwise inverted, bitwise ANDed with the lower 15 bits of the "alarm configuration" register, then all fifteen bits are NORed together. This signal directly drives the /IRQ pin.
|-
| 1
| 0
| Per-minute edge
| Asserts /IRQ during the first 10 ms of each minute. During the following 990 ms, /IRQ can be deasserted by reading the configuration register.
|-
| 1
| 1
| Per-minute steady
| Asserts /IRQ during the first 10 ms of each minute. De-asserts /IRQ at the 30th second.
|}
=== Date/Time ===
The date and time is stored using seven bytes, of which the latter three correspond to the time.
==== Date ====
7 bit 0
---- ---- Byte 0
yyyy yyyy
|||| ||||
++++-++++- Year (00 - 99, BCD)
Writing invalid year values (non-BCD) writes <tt>$00</tt> instead.
7 bit 0
---- ---- Byte 1
...m mmmm
| ||||
+-++++- Month (01 - 12, BCD)
Writing invalid month values (non-BCD, <tt>$00</tt>, or larger than <tt>$12</tt>) writes <tt>$01</tt> instead.
7 bit 0
---- ---- Byte 2
..dd dddd
|| ||||
++-++++- Day of month (01 - 31, BCD)
Writing invalid day of month values (non-BCD, <tt>$00</tt>, or larger than <tt>$31</tt>) writes <tt>$01</tt> instead.
If the day of month is smaller than or equal to <tt>$31</tt>, but larger than the maximum day of month in a given year/month pair, the year/month is automatically incremented and the month is set to <tt>$01</tt>
7 bit 0
---- ---- Byte 3
.... .www
|||
+++- Day of week (0 - 6)
Writing invalid day of week values (non-BCD or larger than <tt>$06</tt>) writes <tt>$00</tt> instead.
While this convention does not have to be followed, [[WonderWitch/FreyaBIOS|FreyaBIOS]] assumes that the first day of the week (0) is a Sunday, (1) is a Monday, ... (6) is a Saturday.
==== Time ====
7 bit 0
---- ---- Byte 4
p.hh hhhh
| || ||||
| ++-++++- Hour (00 - 11 or 23, BCD)
+--------- 0 = AM, 1 = PM
In the 24-hour mode, the AM/PM bit is set for values larger than or equal to <tt>$12</tt>. Writes to the bit are ignored.
Writing invalid hour values (non-BCD or larger than <tt>$11 & $1F</tt> in 12-hour mode, or <tt>$23 & $3F</tt> in 24-hour mode, or with an invalid low digit) writes <tt>$00</tt> instead.
7 bit 0
---- ---- Byte 5
.mmm mmmm
||| ||||
+++-++++- Minute (00 - 59, BCD)
Writing invalid minute values (non-BCD or larger than <tt>$59</tt>, or with an invalid low digit) writes <tt>$00</tt> instead.
7 bit 0
---- ---- Byte 6
.sss ssss
||| ||||
+++-++++- Second (00 - 59, BCD)
Writing invalid second values (non-BCD or larger than <tt>$59</tt>, or with an invalid low digit) stores the value, but forces a rollover after one second has passed.
=== Alarm configuration ===
The alarm configuration register is two bytes in size; its interpretation depends on the configured interrupt mode.
==== Interrupt mode: Alarm ====
7 bit 0
---- ---- Byte 0
p.hh hhhh
| || ||||
| ++-++++- Hour to match for the alarm (BCD)
+--------- AM/PM bit to match for the alarm
7 bit 0
---- ---- Byte 1
.mmm mmmm
||| ||||
+++-++++- Minute to match for the alarm (BCD)
Note that the hour encoding of the alarm must have the AM/PM bit set correctly, even in 24-hour mode.
==== Interrupt mode: Frequency ====
7 bit 0
---- ---- Byte 0
abcd efgh
|||| ||||
|||| |||+- 32768 Hz
|||| ||+-- 16384 Hz
|||| |+--- 8192 Hz
|||| +---- 4096 Hz
|||+------ 2048 Hz
||+------- 1024 Hz
|+-------- 512 Hz
+--------- 256 Hz
7 bit 0
---- ---- Byte 1
abcd efgh
|||| ||||
|||| |||+- 128 Hz
|||| ||+-- 64 Hz
|||| |+--- 32 Hz
|||| +---- 16 Hz
|||+------ 8 Hz
||+------- 4 Hz
|+-------- 2 Hz
+--------- 1 Hz
=== Initial power on state ===
* Year = <tt>$00</tt>
* Month = <tt>$01</tt>
* Day of month = <tt>$01</tt>
* Day of week = <tt>$00</tt>
* Hour = <tt>$00</tt>
* Minute = <tt>$00</tt>
* Second = <tt>$00</tt>
* Configuration = <tt>$82</tt>
* Alarm = <tt>$8000</tt>
== Commands ==
=== Reset RTC ($10, $11) ===
Writing $10 or $11 to port $CA will send the "reset" command to the RTC. The S-3511A will then reset the following registers:
* Year = <tt>$00</tt>
* Month = <tt>$01</tt>
* Day of month = <tt>$01</tt>
* Day of week = <tt>$00</tt>
* Hour = <tt>$00</tt>
* Minute = <tt>$00</tt>
* Second = <tt>$00</tt>
* Configuration = <tt>$00</tt>
* Alarm = <tt>$0000</tt>
It is unknown if it resets the sub-second prescaler.
=== Write Configuration ($12) ===
Writing $12 to port $CA will send the "set configuration" command to the RTC. The 2003 expects that $CB contains valid contents by the time the 2003 sends that register's contents.
=== Read Configuration ($13) ===
Writing $13 to port $CA will send the "get configuration" command to the RTC.
=== Write current YMDdHMS ($14) ===
Writing $14 will set the current Year, Month, Day-of-Month, Day-of-Week, Hour, Minute, and Second.
=== Read current YMDdHMS ($15) ===
Writing $15 will get the current Year, Month, Day-of-Month, Day-of-Week, Hour, Minute, and Second.
=== Write current HMS ($16) ===
Writing $16 will set the current Hour, Minute, and Second.
These are the same as command $14.
=== Read current HMS ($17) ===
Writing $17 will get the current Hour, Minute, and Second.
=== Write alarm configuration ($18) ===
Writing $18 will set the current alarm configuration. The interpretation of these two bytes depend on the Configuration register
=== Nonsense alarm configuration ($19) ===
Writing $19 will set the current alarm configuration to $FFFF. The 2003 thinks it's reading from the S-3511A, but the S-3511A disagrees.
$FFFF will be read back by the 2003.
=== Write nonsense ($1A) ===
Writing $1A expects to send 2 bytes to the RTC. The S-3511A ignores them.
=== Read nonsense ($1B) ===
Writing $1B expects to read 2 bytes from the RTC. The S-3511A leaves its output high, returning $FFFF.
== Interrupts ==
The 2003 and S-3511A do not provide a thread-safe way to acknowledge the IRQ. Since the 2003 only holds one byte at a time, an interrupt can be fired in the middle of a multi-byte read or write without knowing what needs to be done for the rest of the command, nor how to safely restart that command when exiting the interrupt.
As such, the only choices are:
* all communication to the 2003 happens while cartridge IRQs are disabled, or
* the only thing the interrupt handler can do is [[Interrupts#Interrupt_Enable|mask]] the interrupt and then [[Interrupts#Interrupt_Acknowledge|acknowledge]] it, and only afterwards handle any subsequent communication.
d9929b306e2af96fd36e57fc4d482c80d82f43e0
I/O port map
0
8
581
533
2025-04-08T15:33:05Z
Asie
351
/* I/O port map */ bits 0-2 on translucent mono palettes are always 0 - thanks, FluBBa!
wikitext
text/x-wiki
The WonderSwan SoC has three general blocks of I/O port accesses:
{| class="wikitable"
! From !! To !! Holder !! Width !! Speed
|-
| $00 || $B7 || WonderSwan SoC || 16-bit || 1 cycle
|-
| $B8 || $BF || Internal EEPROM control || 16-bit || 1 cycle
|-
| $C0 || $FF || Cartridge bus || 8-bit || 1<sup>(color)</sup>/2 cycles (configurable)
|}
With the exception of internal EEPROM on the ASWAN, all unaligned 16-bit accesses can be converted to two 8-bit accesses with a 1-cycle penalty.
== I/O port map ==
* Superscripts are used to mark ports specific to a given mode or platform:
** Color mode: <sup>(color)</sup>. Such ports are only accessible when color mode is enabled through port <code>$60</code>.
** WS/WSC/SC console: <sup>(WS)</sup>, <sup>(WSC)</sup>, <sup>(SC)</sup>.
* If two Bits rows are provided, the second one refers to the "Color" mode.
* The Type can be: R - readable, W - writable, L - writable before boot ROM lockout, 8/16 - width (byte/word).
{| class="wikitable"
! Category
! Port
! Description
! Bits
! Type
! Notes
|-
! rowspan="47" | [[Display]]
! $00
| [[Display/IO Ports#Display Control|Display Control]]
| style="text-align: right" | <tt style="white-space: nowrap">..wo Ws21</tt>
| RW8
|
|-
! $01
| [[Display/IO Ports#Display Background|Display Background]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .sss</tt>
<tt style="white-space: nowrap">pppp iiii</tt>
| RW8
| Shade (s)
Palette (p), Index (i)
|-
! $02
| [[Display/IO Ports#Current Line|Display Current Line]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll</tt>
| R8
| Line (l)
|-
! $03
| [[Display/IO Ports#Interrupt Line|Display Interrupt Line]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll</tt>
| RW8
| Line (l)
|-
! $04
| [[Display/IO Ports#Sprite Table Address|Sprite Table Address]]
| style="text-align: right" | <tt style="white-space: nowrap">...a aaaa</tt>
<tt style="white-space: nowrap">..aa aaaa</tt>
| RW8
| Address >> 9 (a)
|-
! $05
| [[Display/IO Ports#Sprite Table First|Sprite Table First]]
| style="text-align: right" | <tt style="white-space: nowrap">.iii iiii</tt>
| RW8
| Index (i)
|-
! $06
| [[Display/IO Ports#Sprite Table Count|Sprite Table Count]]
| style="text-align: right" | <tt style="white-space: nowrap">cccc cccc</tt>
| RW8
| Count (c)
|-
! $07
| [[Display/IO Ports#Screen Address|Screen Address]]
| style="text-align: right" | <tt style="white-space: nowrap">.222 .111</tt>
<tt style="white-space: nowrap">2222 1111</tt>
| RW8
| Screen 1 address >> 11 (1)
Screen 2 address >> 11 (2)
|-
! $08
| [[Display/IO Ports#Screen 2 Window|Screen 2 Window Left]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $09
| [[Display/IO Ports#Screen 2 Window|Screen 2 Window Top]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $0A
| [[Display/IO Ports#Screen 2 Window|Screen 2 Window Right]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $0B
| [[Display/IO Ports#Screen 2 Window|Screen 2 Window Bottom]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $0C
| [[Display/IO Ports#Sprite Window|Sprite Window Left]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $0D
| [[Display/IO Ports#Sprite Window|Sprite Window Top]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $0E
| [[Display/IO Ports#Sprite Window|Sprite Window Right]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $0F
| [[Display/IO Ports#Sprite Window|Sprite Window Bottom]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $10
| [[Display/IO Ports#Screen Scroll|Screen 1 Scroll X]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $11
| [[Display/IO Ports#Screen Scroll|Screen 1 Scroll Y]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $12
| [[Display/IO Ports#Screen Scroll|Screen 2 Scroll X]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $13
| [[Display/IO Ports#Screen Scroll|Screen 2 Scroll Y]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $14
| [[Display/IO Ports#LCD Control|LCD Control]]
| style="text-align: right" | <tt style="white-space: nowrap">.... ..Ce</tt>
| RW8
| Contrast (C)<sup>(WSC)</sup>, Enable (e)
|-
! $15
| [[Display/IO Ports#LCD Icon Control|LCD Icon Control]]
| style="text-align: right" | <tt style="white-space: nowrap">..32 1hvs</tt>
| RW8
| Etc. 3 (3), Etc. 2 (2), Etc. 1 (1),
Horizontal (h), Vertical (v), Sleep (s)
|-
! $16
| [[Display/IO Ports#LCD Final Line|LCD Final Line]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll</tt>
| RW8
| Line (l)
|-
! $17
| [[Display/IO Ports#LCD Back Porch Line|LCD Back Porch Line]]<sup>(WSC)</sup>
| style="text-align: right" | <tt style="white-space: nowrap">llll llll</tt>
| RW8
| Line (l)
|-
! $18
| [[Display/IO Ports#LCD Line Counter|LCD Line Counter]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll</tt>
| W8
| Line (l)
|-
! $1A
| [[Display/IO Ports#LCD Status|LCD Latched Icon Status]]
| style="text-align: right" | <tt style="white-space: nowrap">..cv vvhs</tt>
| R8
| Cartridge icon (c), Volume icons (v),
Headphone icon (h), Latch override (l)
|-
! $1A
| [[Display/IO Ports#LCD Status|LCD Latched Icon Control]]
| style="text-align: right" | <tt style="white-space: nowrap">..cv vvhs</tt>
| W8
| Cartridge (c), Sound (s), Latch override (l)
|-
! $1C
| [[Display/IO Ports#LCD Mono Shade LUT|LCD Mono Shade LUT 0/1]]
| style="text-align: right" | <tt style="white-space: nowrap">1111 0000</tt>
| RW8
| Shade index
|-
! $1D
| [[Display/IO Ports#LCD Mono Shade LUT|LCD Mono Shade LUT 2/3]]
| style="text-align: right" | <tt style="white-space: nowrap">3333 2222</tt>
| RW8
| Shade index
|-
! $1E
| [[Display/IO Ports#LCD Mono Shade LUT|LCD Mono Shade LUT 4/5]]
| style="text-align: right" | <tt style="white-space: nowrap">5555 4444</tt>
| RW8
| Shade index
|-
! $1F
| [[Display/IO Ports#LCD Mono Shade LUT|LCD Mono Shade LUT 6/7]]
| style="text-align: right" | <tt style="white-space: nowrap">7777 6666</tt>
| RW8
| Shade index
|-
! $20
| [[Display/IO Ports#LCD Mono Palette|LCD Mono Palette 0]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $22
| [[Display/IO Ports#LCD Mono Palette|LCD Mono Palette 1]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $24
| [[Display/IO Ports#LCD Mono Palette|LCD Mono Palette 2]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $26
| [[Display/IO Ports#LCD Mono Palette|LCD Mono Palette 3]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $28
| [[Display/IO Ports#LCD Mono Palette|LCD Mono Palette 4]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 ....</tt>
| RW16
| Shade LUT index
|-
! $2A
| [[Display/IO Ports#LCD Mono Palette|LCD Mono Palette 5]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 ....</tt>
| RW16
| Shade LUT index
|-
! $2C
| [[Display/IO Ports#LCD Mono Palette|LCD Mono Palette 6]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 ....</tt>
| RW16
| Shade LUT index
|-
! $2E
| [[Display/IO Ports#LCD Mono Palette|LCD Mono Palette 7]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 ....</tt>
| RW16
| Shade LUT index
|-
! $30
| [[Display/IO Ports#LCD Mono Palette|LCD Mono Palette 8]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $32
| [[Display/IO Ports#LCD Mono Palette|LCD Mono Palette 9]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $34
| [[Display/IO Ports#LCD Mono Palette|LCD Mono Palette 10]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $36
| [[Display/IO Ports#LCD Mono Palette|LCD Mono Palette 11]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $38
| [[Display/IO Ports#LCD Mono Palette|LCD Mono Palette 12]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 ....</tt>
| RW16
| Shade LUT index
|-
! $3A
| [[Display/IO Ports#LCD Mono Palette|LCD Mono Palette 13]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 ....</tt>
| RW16
| Shade LUT index
|-
! $3C
| [[Display/IO Ports#LCD Mono Palette|LCD Mono Palette 14]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 ....</tt>
| RW16
| Shade LUT index
|-
! $3E
| [[Display/IO Ports#LCD Mono Palette|LCD Mono Palette 15]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 ....</tt>
| RW16
| Shade LUT index
|-
! rowspan="10" | [[DMA]]<sup>(color)</sup>
! $40
| [[DMA#General DMA|GDMA Source Address Low]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll llll lll.</tt>
| RW16
| Linear address, low 16 bits (l)
|-
! $42
| [[DMA#General DMA|GDMA Source Address High]]
| style="text-align: right" | <tt style="white-space: nowrap">.... hhhh</tt>
| RW8
| Linear address, high 4 bits (h)
|-
! $44
| [[DMA#General DMA|GDMA Destination Address]]
| style="text-align: right" | <tt style="white-space: nowrap">aaaa aaaa aaaa aaa.</tt>
| RW16
| IRAM address (a)
|-
! $46
| [[DMA#General DMA|GDMA Length]]
| style="text-align: right" | <tt style="white-space: nowrap">bbbb bbbb bbbb bbb.</tt>
| RW16
| Bytes (b)
|-
! $48
| [[DMA#General DMA|GDMA Control]]
| style="text-align: right" | <tt style="white-space: nowrap">ed.. ....</tt>
| RW8
| Enable (e), Decrement (d)
|-
! $4A
| [[DMA#Sound DMA|SDMA Source Address Low]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll llll llll</tt>
| RW16
| Linear address, low 16 bits (l)
|-
! $4C
| [[DMA#Sound DMA|SDMA Source Address High]]
| style="text-align: right" | <tt style="white-space: nowrap">.... hhhh</tt>
| RW8
| Linear address, high 4 bits (h)
|-
! $4E
| [[DMA#Sound DMA|SDMA Length Low]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll llll llll</tt>
| RW16
| Length, low 16 bits (l)
|-
! $50
| [[DMA#Sound DMA|SDMA Length High]]
| style="text-align: right" | <tt style="white-space: nowrap">.... hhhh</tt>
| RW8
| Length, high 4 bits (h)
|-
! $52
| [[DMA#Sound DMA|SDMA Control]]
| style="text-align: right" | <tt style="white-space: nowrap">ed.t rhff</tt>
| RW8
| Enable (e), Decrement (d), Target (t),
Repeat (r), Hold (h), Frequency (f)
|-
! rowspan="2" | [[SoC]]<sup>(color)</sup>
! $60
| [[SoC#System Control 2|System Control 2]]
| style="text-align: right" | <tt style="white-space: nowrap">c4C. i?sl</tt>
| RW8
| Color (c), 4BPP (4), Chunky (C),<br/>
Cart I/O wait state (i), SRAM wait state (s),<br/>
Cart clock speed (l).
|-
! $62
| [[SoC#System Control 3|System Control 3]]
| style="text-align: right" | <tt style="white-space: nowrap">S... ...p</tt>
| RW8
| SwanCrystal (S), Power off (p)
|-
! rowspan="4" | [[Hyper Voice]]<sup>(color)</sup>
! $64
| [[Hyper Voice#Hyper Voice Output|Hyper Voice Left Output]]
| style="text-align: right" | <tt style="white-space: nowrap">ssss ssss ssss ssss</tt>
| W16
| Raw sample (s)
|-
! $66
| [[Hyper Voice#Hyper Voice Output|Hyper Voice Right Output]]
| style="text-align: right" | <tt style="white-space: nowrap">ssss ssss ssss ssss</tt>
| W16
| Raw sample (s)
|-
! $69
| [[Hyper Voice#Hyper Voice Input|Hyper Voice Right Input]]
| style="text-align: right" | <tt style="white-space: nowrap">ssss ssss</tt>
| W8
| Sample (s)
|-
! $6A
| [[Hyper Voice#Hyper Voice Control|Hyper Voice Control]]
| style="text-align: right" | <tt style="white-space: nowrap">.mmc ???? errr ffss</tt>
| RW16
| Mask (m), Channel reset (c), Enable (e),
Rate (r), Format (f), Shift (s)
|-
! rowspan="8" | [[Display]]<sup>(SC)</sup>
! $70
| LCD Timing Configuration 1?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $71
| LCD Timing Configuration 2?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $72
| LCD Timing Configuration 3?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $73
| LCD Timing Configuration 4?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $74
| LCD Timing Configuration 5?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $75
| LCD Timing Configuration 6?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $76
| LCD Timing Configuration 7?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $77
| LCD Timing Configuration 8?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! rowspan="22" | [[Sound]]
! $80
| [[Sound#Sound Channel Frequency|Sound Channel 1 Frequency]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .ddd dddd dddd</tt>
| RW16
| Divider (d)
|-
! $82
| [[Sound#Sound Channel Frequency|Sound Channel 2 Frequency]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .ddd dddd dddd</tt>
| RW16
| Divider (d)
|-
! $84
| [[Sound#Sound Channel Frequency|Sound Channel 3 Frequency]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .ddd dddd dddd</tt>
| RW16
| Divider (d)
|-
! $86
| [[Sound#Sound Channel Frequency|Sound Channel 4 Frequency]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .ddd dddd dddd</tt>
| RW16
| Divider (d)
|-
! $88
| [[Sound#Sound Channel Volume|Sound Channel 1 Volume]]
| style="text-align: right" | <tt style="white-space: nowrap">llll rrrr</tt>
| RW8
| Left (l), Right (r)
|-
! rowspan="2" | $89
| [[Sound#Sound Channel Volume|Sound Channel 2 Volume]]
| style="text-align: right" | <tt style="white-space: nowrap">llll rrrr</tt>
| RW8
| Left (l), Right (r)
|-
| [[Sound#Sound Channel 2 Voice Sample|Sound Channel 2 Voice Sample]]
| style="text-align: right" | <tt style="white-space: nowrap">ssss ssss</tt>
| RW8
| Sample (s)
|-
! $8A
| [[Sound#Sound Channel Volume|Sound Channel 3 Volume]]
| style="text-align: right" | <tt style="white-space: nowrap">llll rrrr</tt>
| RW8
| Left (l), Right (r)
|-
! $8B
| [[Sound#Sound Channel Volume|Sound Channel 4 Volume]]
| style="text-align: right" | <tt style="white-space: nowrap">llll rrrr</tt>
| RW8
| Left (l), Right (r)
|-
! $8C
| [[Sound#Sound Channel 3 Sweep Amount|Sound Channel 3 Sweep Amount]]
| style="text-align: right" | <tt style="white-space: nowrap">vvvv vvvv</tt>
| RW8
| Value (v)
|-
! $8D
| [[Sound#Sound Channel 3 Sweep Ticks|Sound Channel 3 Sweep Ticks]]
| style="text-align: right" | <tt style="white-space: nowrap">...t tttt</tt>
| RW8
| Ticks (t)
|-
! $8E
| [[Sound#Sound Channel 4 Noise Control|Sound Channel 4 Noise Control]]
| style="text-align: right" | <tt style="white-space: nowrap">...e rttt</tt>
| RW8
| Enable (e), Reset (r), Tap (t)
|-
! $8F
| [[Sound#Sound Wavetable Address|Sound Wavetable Address]]
| style="text-align: right" | <tt style="white-space: nowrap">wwww wwww</tt>
| RW8
| Address >> 6 (w)
|-
! $90
| [[Sound#Sound Channel Control|Sound Channel Control]]
| style="text-align: right" | <tt style="white-space: nowrap">nsv. 4321</tt>
| RW8
| Channel enable (1234)
Noise (n), Sweep (s), Voice (v)
|-
! $91
| [[Sound#Sound Output Control|Sound Output Control]]
| style="text-align: right" | <tt style="white-space: nowrap">H... hrrs</tt>
| RW8
| Headphones connected (H)
Headphone output (h)
Speaker output (s), range (r)
|-
! $92
| [[Sound#Sound Channel 4 LFSR Register|Sound Channel 4 LFSR Register]]
| style="text-align: right" | <tt style="white-space: nowrap">.rrr rrrr rrrr rrrr</tt>
| R16
| PRNG state (r)
|-
! $94
| [[Sound#Sound Channel 2 Voice Volume|Sound Channel 2 Voice Volume]]
| style="text-align: right" | <tt style="white-space: nowrap">.... lLrR</tt>
| RW8
| Left Half (l), Full (L)
Right Half (r), Full (R)
|-
! $95
| [[Sound#Sound Test|Sound Test]]
| style="text-align: right" | <tt style="white-space: nowrap">425? ???h</tt>
| RW8
|
|-
! $96
| [[Sound#Sound Channel Output Right|Sound Channel Output Right]]
| style="text-align: right" | <tt style="white-space: nowrap">.... ..ss ssss ssss</tt>
| R16
| Sample (s)
|-
! $98
| [[Sound#Sound Channel Output Left|Sound Channel Output Left]]
| style="text-align: right" | <tt style="white-space: nowrap">.... ..ss ssss ssss</tt>
| R16
| Sample (s)
|-
! $9A
| [[Sound#Sound Channel Output Sum|Sound Channel Output Sum]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .sss ssss ssss</tt>
| R16
| Sample (s)
|-
! $9E
| [[Sound#Sound Speaker Main Volume|Sound Speaker Main Volume]]<sup>(color)</sup>
| style="text-align: right" | <tt style="white-space: nowrap">.... ..vv</tt>
| RW8
| Main volume (v)
|-
! [[SoC]]
! $A0
| [[SoC#System Control|System Control]]
| style="text-align: right" | <tt style="white-space: nowrap">C??? swcl</tt>
| RW8
| Cartridge OK (C), ROM wait state (s), ROM width (w),
Color system (c), Boot ROM lockout (l)
|-
! rowspan="5" | [[Timers]]
! $A2
| [[Timers#Timer Control|Timer Control]]
| style="text-align: right" | <tt style="white-space: nowrap">.... VvHh</tt>
| RW8
| Horizontal enable (h), auto reload (H)
Vertical enable (v), auto reload (V)
|-
! $A4
| [[Timers#Timer Reload|Horizontal Blank Timer Reload]]
| style="text-align: right" | <tt style="white-space: nowrap">tttt tttt tttt tttt</tt>
| RW16
| Ticks (t)
|-
! $A6
| [[Timers#Timer Reload|Vertical Blank Timer Reload]]
| style="text-align: right" | <tt style="white-space: nowrap">tttt tttt tttt tttt</tt>
| RW16
| Ticks (t)
|-
! $A8
| [[Timers#Timer Counter|Horizontal Blank Timer Counter]]
| style="text-align: right" | <tt style="white-space: nowrap">tttt tttt tttt tttt</tt>
| R16
| Ticks (t)
|-
! $AA
| [[Timers#Timer Counter|Vertical Blank Timer Counter]]
| style="text-align: right" | <tt style="white-space: nowrap">tttt tttt tttt tttt</tt>
| R16
| Ticks (t)
|-
! ?
! $AC
| ?
| style="text-align: right" | <tt style="white-space: nowrap">.... ...p</tt>
| W8?
| Power off (p)
|-
! rowspan="2" | [[Interrupts]]
! rowspan="2" | $B0
| [[Interrupts#Interrupt Vector Offset|Interrupt Vector Offset]]
| style="text-align: right" | <tt style="white-space: nowrap">VVVV V...</tt>
| W8
| Vector offset (V)
|-
| [[Interrupts#Interrupt Vector Request|Interrupt Vector Request]]
| style="text-align: right" | <tt style="white-space: nowrap">vvvv vvvv</tt>
| R8
| Requested vector offset (v)
|-
! rowspan="2" | [[UART]]
! $B1
| [[UART#Serial Receive Data|Serial Receive Data]]
| style="text-align: right" | <tt style="white-space: nowrap">dddd dddd</tt>
| R8
| Receive buffer data (d)
|-
! $B1
| [[UART#Serial Transmit Data|Serial Transmit Data]]
| style="text-align: right" | <tt style="white-space: nowrap">dddd dddd</tt>
| W8
| Transmit buffer data (d)
|-
! [[Interrupts]]
! $B2
| [[Interrupts#Interrupt Enable|Interrupt Enable]]
| style="text-align: right" | <tt style="white-space: nowrap">iiii iiii</tt>
| RW8
| Interrupt index (i)
|-
! rowspan="2" | [[UART]]
! $B3
| [[UART#Serial Status|Serial Status]]
| style="text-align: right" | <tt style="white-space: nowrap">eb.. .tor</tt>
| R8
| Enable (e), Baud rate (b),
Transfer ready (t), Overrun (o), Receive ready (r)
|-
! $B3
| [[UART#Serial Control|Serial Control]]
| style="text-align: right" | <tt style="white-space: nowrap">ebO. ....</tt>
| W8
| Enable (e), Baud rate (b), Reset Overrun (O)
|-
! [[Interrupts]]
! $B4
| [[Interrupts#Interrupt Status|Interrupt Status]]
| style="text-align: right" | <tt style="white-space: nowrap">iiii iiii</tt>
| R8
| Interrupt index (i)
|-
! [[Keypad]]
! $B5
| [[Keypad|Keypad Scan]]
| style="text-align: right" | <tt style="white-space: nowrap">.iii oooo</tt>
| RW8
| Input row (i), Output column (o)
|-
! rowspan="2" | [[Interrupts]]
! $B6
| [[Interrupts#Interrupt Acknowledge|Interrupt Acknowledge]]
| style="text-align: right" | <tt style="white-space: nowrap">iiii iiii</tt>
| W8
| Interrupt index (i)
|-
! $B7
| [[Interrupts#Interrupt NMI Control|Interrupt NMI Control]]
| style="text-align: right" | <tt style="white-space: nowrap">...b ....</tt>
| RW8
| Low battery (b)
|-
! rowspan="4" | [[EEPROM|Internal EEPROM]]
! $BA
| [[EEPROM#Internal EEPROM Data|Internal EEPROM Data]]
| style="text-align: right" | <tt style="white-space: nowrap">dddd dddd dddd dddd</tt>
| RW16
| Data (d)
|-
! $BC
| [[EEPROM#Internal EEPROM Command|Internal EEPROM Command]]
|
| RW16
|
|-
! rowspan="2" | $BE
| [[EEPROM#Internal EEPROM Status|Internal EEPROM Status]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .... p... ..RD</tt>
| R16
| Protected (p), Ready (R), Done (D)
|-
| [[EEPROM#Internal EEPROM Control|Internal EEPROM Control]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .... pewr ....</tt>
| W16
| Protect (p), Erase (e), Write (w), Read (r)
|-
! [[Mapper|Cartridge]]
! $C0<br />...<br />
$FF
| Cartridge I/O
|
| RW8
| Forwarded by the SoC
|}
== I/O port routing ==
The [[NEC V30MZ]] supports 16-bit I/O port addresses. The WonderSwan SoC routes them using the following algorithm:
* If an address is between <code>$00B8</code> and <code>$00BF</code> inclusive, it is routed to the internal EEPROM control block.
* If an address is between <code>$00C0</code> and <code>$00FF</code> inclusive, it is routed to the cartride bus.
* If an address's bits <code>0</code> through <code>8</code> inclusive are between <code>$000</code> and <code>$0B7</code> inclusive, they are routed to the SoC block.
* If none of these conditions are reached, open bus is read.
On the monochrome models, as well as color models in mono emulation, open bus is always <code>0x90</code>.
cd1b703f0f763ddee3531a7048ced3449f43c1ec
584
581
2025-04-08T19:49:04Z
Asie
351
/* I/O port map */
wikitext
text/x-wiki
The WonderSwan SoC has three general blocks of I/O port accesses:
{| class="wikitable"
! From !! To !! Holder !! Width !! Speed
|-
| $00 || $B7 || WonderSwan SoC || 16-bit || 1 cycle
|-
| $B8 || $BF || Internal EEPROM control || 16-bit || 1 cycle
|-
| $C0 || $FF || Cartridge bus || 8-bit || 1<sup>(color)</sup>/2 cycles (configurable)
|}
With the exception of internal EEPROM on the ASWAN, all unaligned 16-bit accesses can be converted to two 8-bit accesses with a 1-cycle penalty.
== I/O port map ==
* Superscripts are used to mark ports specific to a given mode or platform:
** Color mode: <sup>(color)</sup>. Such ports are only accessible when color mode is enabled through port <code>$60</code>.
** WS/WSC/SC console: <sup>(WS)</sup>, <sup>(WSC)</sup>, <sup>(SC)</sup>.
* If two Bits rows are provided, the second one refers to the "Color" mode.
* The Type can be: R - readable, W - writable, L - writable before boot ROM lockout, 8/16 - width (byte/word).
{| class="wikitable"
! Category
! Port
! Description
! Bits
! Type
! Notes
|-
! rowspan="47" | [[Display]]
! $00
| [[Display/IO Ports#Display Control|Display Control]]
| style="text-align: right" | <tt style="white-space: nowrap">..wo Ws21</tt>
| RW8
|
|-
! $01
| [[Display/IO Ports#Display Background|Display Background]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .sss</tt>
<tt style="white-space: nowrap">pppp iiii</tt>
| RW8
| Shade (s)
Palette (p), Index (i)
|-
! $02
| [[Display/IO Ports#Current Line|Display Current Line]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll</tt>
| R8
| Line (l)
|-
! $03
| [[Display/IO Ports#Interrupt Line|Display Interrupt Line]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll</tt>
| RW8
| Line (l)
|-
! $04
| [[Display/IO Ports#Sprite Table Address|Sprite Table Address]]
| style="text-align: right" | <tt style="white-space: nowrap">...a aaaa</tt>
<tt style="white-space: nowrap">..aa aaaa</tt>
| RW8
| Address >> 9 (a)
|-
! $05
| [[Display/IO Ports#Sprite Table First|Sprite Table First]]
| style="text-align: right" | <tt style="white-space: nowrap">.iii iiii</tt>
| RW8
| Index (i)
|-
! $06
| [[Display/IO Ports#Sprite Table Count|Sprite Table Count]]
| style="text-align: right" | <tt style="white-space: nowrap">cccc cccc</tt>
| RW8
| Count (c)
|-
! $07
| [[Display/IO Ports#Screen Address|Screen Address]]
| style="text-align: right" | <tt style="white-space: nowrap">.222 .111</tt>
<tt style="white-space: nowrap">2222 1111</tt>
| RW8
| Screen 1 address >> 11 (1)
Screen 2 address >> 11 (2)
|-
! $08
| [[Display/IO Ports#Screen 2 Window|Screen 2 Window Left]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $09
| [[Display/IO Ports#Screen 2 Window|Screen 2 Window Top]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $0A
| [[Display/IO Ports#Screen 2 Window|Screen 2 Window Right]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $0B
| [[Display/IO Ports#Screen 2 Window|Screen 2 Window Bottom]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $0C
| [[Display/IO Ports#Sprite Window|Sprite Window Left]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $0D
| [[Display/IO Ports#Sprite Window|Sprite Window Top]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $0E
| [[Display/IO Ports#Sprite Window|Sprite Window Right]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $0F
| [[Display/IO Ports#Sprite Window|Sprite Window Bottom]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $10
| [[Display/IO Ports#Screen Scroll|Screen 1 Scroll X]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $11
| [[Display/IO Ports#Screen Scroll|Screen 1 Scroll Y]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $12
| [[Display/IO Ports#Screen Scroll|Screen 2 Scroll X]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $13
| [[Display/IO Ports#Screen Scroll|Screen 2 Scroll Y]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $14
| [[Display/IO Ports#LCD Control|LCD Control]]
| style="text-align: right" | <tt style="white-space: nowrap">.... ..Ce</tt>
| RW8
| Contrast (C)<sup>(WSC)</sup>, Enable (e)
|-
! $15
| [[Display/IO Ports#LCD Icon Control|LCD Icon Control]]
| style="text-align: right" | <tt style="white-space: nowrap">..32 1hvs</tt>
| RW8
| Etc. 3 (3), Etc. 2 (2), Etc. 1 (1),
Horizontal (h), Vertical (v), Sleep (s)
|-
! $16
| [[Display/IO Ports#LCD Final Line|LCD Final Line]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll</tt>
| RW8
| Line (l)
|-
! $17
| [[Display/IO Ports#LCD Back Porch Line|LCD Back Porch Line]]<sup>(WSC)</sup>
| style="text-align: right" | <tt style="white-space: nowrap">llll llll</tt>
| RW8
| Line (l)
|-
! $18
| [[Display/IO Ports#LCD Line Counter|LCD Line Counter]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll</tt>
| W8
| Line (l)
|-
! $1A
| [[Display/IO Ports#LCD Status|LCD Latched Icon Status]]
| style="text-align: right" | <tt style="white-space: nowrap">..cv vvhs</tt>
| R8
| Cartridge icon (c), Volume icons (v),
Headphone icon (h), Latch override (l)
|-
! $1A
| [[Display/IO Ports#LCD Status|LCD Latched Icon Control]]
| style="text-align: right" | <tt style="white-space: nowrap">..cv vvhs</tt>
| W8
| Cartridge (c), Sound (s), Latch override (l)
|-
! $1C
| [[Display/IO Ports#LCD Mono Shade LUT|LCD Mono Shade LUT 0/1]]
| style="text-align: right" | <tt style="white-space: nowrap">1111 0000</tt>
| RW8
| Shade index
|-
! $1D
| [[Display/IO Ports#LCD Mono Shade LUT|LCD Mono Shade LUT 2/3]]
| style="text-align: right" | <tt style="white-space: nowrap">3333 2222</tt>
| RW8
| Shade index
|-
! $1E
| [[Display/IO Ports#LCD Mono Shade LUT|LCD Mono Shade LUT 4/5]]
| style="text-align: right" | <tt style="white-space: nowrap">5555 4444</tt>
| RW8
| Shade index
|-
! $1F
| [[Display/IO Ports#LCD Mono Shade LUT|LCD Mono Shade LUT 6/7]]
| style="text-align: right" | <tt style="white-space: nowrap">7777 6666</tt>
| RW8
| Shade index
|-
! $20
| [[Display/IO Ports#LCD Mono Palette|LCD Mono Palette 0]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $22
| [[Display/IO Ports#LCD Mono Palette|LCD Mono Palette 1]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $24
| [[Display/IO Ports#LCD Mono Palette|LCD Mono Palette 2]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $26
| [[Display/IO Ports#LCD Mono Palette|LCD Mono Palette 3]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $28
| [[Display/IO Ports#LCD Mono Palette|LCD Mono Palette 4]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 ....</tt>
| RW16
| Shade LUT index
|-
! $2A
| [[Display/IO Ports#LCD Mono Palette|LCD Mono Palette 5]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 ....</tt>
| RW16
| Shade LUT index
|-
! $2C
| [[Display/IO Ports#LCD Mono Palette|LCD Mono Palette 6]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 ....</tt>
| RW16
| Shade LUT index
|-
! $2E
| [[Display/IO Ports#LCD Mono Palette|LCD Mono Palette 7]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 ....</tt>
| RW16
| Shade LUT index
|-
! $30
| [[Display/IO Ports#LCD Mono Palette|LCD Mono Palette 8]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $32
| [[Display/IO Ports#LCD Mono Palette|LCD Mono Palette 9]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $34
| [[Display/IO Ports#LCD Mono Palette|LCD Mono Palette 10]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $36
| [[Display/IO Ports#LCD Mono Palette|LCD Mono Palette 11]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $38
| [[Display/IO Ports#LCD Mono Palette|LCD Mono Palette 12]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 ....</tt>
| RW16
| Shade LUT index
|-
! $3A
| [[Display/IO Ports#LCD Mono Palette|LCD Mono Palette 13]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 ....</tt>
| RW16
| Shade LUT index
|-
! $3C
| [[Display/IO Ports#LCD Mono Palette|LCD Mono Palette 14]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 ....</tt>
| RW16
| Shade LUT index
|-
! $3E
| [[Display/IO Ports#LCD Mono Palette|LCD Mono Palette 15]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 ....</tt>
| RW16
| Shade LUT index
|-
! rowspan="10" | [[DMA]]<sup>(color)</sup>
! $40
| [[DMA#General DMA|GDMA Source Address Low]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll llll lll.</tt>
| RW16
| Linear address, low 16 bits (l)
|-
! $42
| [[DMA#General DMA|GDMA Source Address High]]
| style="text-align: right" | <tt style="white-space: nowrap">.... hhhh</tt>
| RW8
| Linear address, high 4 bits (h)
|-
! $44
| [[DMA#General DMA|GDMA Destination Address]]
| style="text-align: right" | <tt style="white-space: nowrap">aaaa aaaa aaaa aaa.</tt>
| RW16
| IRAM address (a)
|-
! $46
| [[DMA#General DMA|GDMA Length]]
| style="text-align: right" | <tt style="white-space: nowrap">bbbb bbbb bbbb bbb.</tt>
| RW16
| Bytes (b)
|-
! $48
| [[DMA#General DMA|GDMA Control]]
| style="text-align: right" | <tt style="white-space: nowrap">ed.. ....</tt>
| RW8
| Enable (e), Decrement (d)
|-
! $4A
| [[DMA#Sound DMA|SDMA Source Address Low]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll llll llll</tt>
| RW16
| Linear address, low 16 bits (l)
|-
! $4C
| [[DMA#Sound DMA|SDMA Source Address High]]
| style="text-align: right" | <tt style="white-space: nowrap">.... hhhh</tt>
| RW8
| Linear address, high 4 bits (h)
|-
! $4E
| [[DMA#Sound DMA|SDMA Length Low]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll llll llll</tt>
| RW16
| Length, low 16 bits (l)
|-
! $50
| [[DMA#Sound DMA|SDMA Length High]]
| style="text-align: right" | <tt style="white-space: nowrap">.... hhhh</tt>
| RW8
| Length, high 4 bits (h)
|-
! $52
| [[DMA#Sound DMA|SDMA Control]]
| style="text-align: right" | <tt style="white-space: nowrap">ed.t rhff</tt>
| RW8
| Enable (e), Decrement (d), Target (t),
Repeat (r), Hold (h), Frequency (f)
|-
! rowspan="2" | [[SoC]]<sup>(color)</sup>
! $60
| [[SoC#System Control 2|System Control 2]]
| style="text-align: right" | <tt style="white-space: nowrap">c4C. i?sl</tt>
| RW8
| Color (c), 4BPP (4), Chunky (C),<br/>
Cart I/O wait state (i), SRAM wait state (s),<br/>
Cart clock speed (l).
|-
! $62
| [[SoC#System Control 3|System Control 3]]
| style="text-align: right" | <tt style="white-space: nowrap">S... ...p</tt>
| RW8
| SwanCrystal (S), Power off (p)
|-
! rowspan="4" | [[Hyper Voice]]<sup>(color)</sup>
! $64
| [[Hyper Voice#Hyper Voice Output|Hyper Voice Left Output]]
| style="text-align: right" | <tt style="white-space: nowrap">ssss ssss ssss ssss</tt>
| W16
| Raw sample (s)
|-
! $66
| [[Hyper Voice#Hyper Voice Output|Hyper Voice Right Output]]
| style="text-align: right" | <tt style="white-space: nowrap">ssss ssss ssss ssss</tt>
| W16
| Raw sample (s)
|-
! $69
| [[Hyper Voice#Hyper Voice Input|Hyper Voice Right Input]]
| style="text-align: right" | <tt style="white-space: nowrap">ssss ssss</tt>
| W8
| Sample (s)
|-
! $6A
| [[Hyper Voice#Hyper Voice Control|Hyper Voice Control]]
| style="text-align: right" | <tt style="white-space: nowrap">.mmc ???? errr ffss</tt>
| RW16
| Mask (m), Channel reset (c), Enable (e),
Rate (r), Format (f), Shift (s)
|-
! rowspan="8" | [[Display]]<sup>(SC)</sup>
! $70
| LCD Timing Configuration 1?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $71
| LCD Timing Configuration 2?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $72
| LCD Timing Configuration 3?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $73
| LCD Timing Configuration 4?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $74
| LCD Timing Configuration 5?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $75
| LCD Timing Configuration 6?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $76
| LCD Timing Configuration 7?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $77
| LCD Timing Configuration 8?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! rowspan="22" | [[Sound]]
! $80
| [[Sound#Sound Channel Frequency|Sound Channel 1 Frequency]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .ddd dddd dddd</tt>
| RW16
| Divider (d)
|-
! $82
| [[Sound#Sound Channel Frequency|Sound Channel 2 Frequency]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .ddd dddd dddd</tt>
| RW16
| Divider (d)
|-
! $84
| [[Sound#Sound Channel Frequency|Sound Channel 3 Frequency]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .ddd dddd dddd</tt>
| RW16
| Divider (d)
|-
! $86
| [[Sound#Sound Channel Frequency|Sound Channel 4 Frequency]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .ddd dddd dddd</tt>
| RW16
| Divider (d)
|-
! $88
| [[Sound#Sound Channel Volume|Sound Channel 1 Volume]]
| style="text-align: right" | <tt style="white-space: nowrap">llll rrrr</tt>
| RW8
| Left (l), Right (r)
|-
! rowspan="2" | $89
| [[Sound#Sound Channel Volume|Sound Channel 2 Volume]]
| style="text-align: right" | <tt style="white-space: nowrap">llll rrrr</tt>
| RW8
| Left (l), Right (r)
|-
| [[Sound#Sound Channel 2 Voice Sample|Sound Channel 2 Voice Sample]]
| style="text-align: right" | <tt style="white-space: nowrap">ssss ssss</tt>
| RW8
| Sample (s)
|-
! $8A
| [[Sound#Sound Channel Volume|Sound Channel 3 Volume]]
| style="text-align: right" | <tt style="white-space: nowrap">llll rrrr</tt>
| RW8
| Left (l), Right (r)
|-
! $8B
| [[Sound#Sound Channel Volume|Sound Channel 4 Volume]]
| style="text-align: right" | <tt style="white-space: nowrap">llll rrrr</tt>
| RW8
| Left (l), Right (r)
|-
! $8C
| [[Sound#Sound Channel 3 Sweep Amount|Sound Channel 3 Sweep Amount]]
| style="text-align: right" | <tt style="white-space: nowrap">vvvv vvvv</tt>
| RW8
| Value (v)
|-
! $8D
| [[Sound#Sound Channel 3 Sweep Ticks|Sound Channel 3 Sweep Ticks]]
| style="text-align: right" | <tt style="white-space: nowrap">...t tttt</tt>
| RW8
| Ticks (t)
|-
! $8E
| [[Sound#Sound Channel 4 Noise Control|Sound Channel 4 Noise Control]]
| style="text-align: right" | <tt style="white-space: nowrap">...e rttt</tt>
| RW8
| Enable (e), Reset (r), Tap (t)
|-
! $8F
| [[Sound#Sound Wavetable Address|Sound Wavetable Address]]
| style="text-align: right" | <tt style="white-space: nowrap">wwww wwww</tt>
| RW8
| Address >> 6 (w)
|-
! $90
| [[Sound#Sound Channel Control|Sound Channel Control]]
| style="text-align: right" | <tt style="white-space: nowrap">nsv. 4321</tt>
| RW8
| Channel enable (1234)
Noise (n), Sweep (s), Voice (v)
|-
! $91
| [[Sound#Sound Output Control|Sound Output Control]]
| style="text-align: right" | <tt style="white-space: nowrap">H... hrrs</tt>
| RW8
| Headphones connected (H)
Headphone output (h)
Speaker output (s), range (r)
|-
! $92
| [[Sound#Sound Channel 4 LFSR Register|Sound Channel 4 LFSR Register]]
| style="text-align: right" | <tt style="white-space: nowrap">.rrr rrrr rrrr rrrr</tt>
| R16
| PRNG state (r)
|-
! $94
| [[Sound#Sound Channel 2 Voice Volume|Sound Channel 2 Voice Volume]]
| style="text-align: right" | <tt style="white-space: nowrap">.... lLrR</tt>
| RW8
| Left Half (l), Full (L)
Right Half (r), Full (R)
|-
! $95
| [[Sound#Sound Test|Sound Test]]
| style="text-align: right" | <tt style="white-space: nowrap">425? ???h</tt>
| RW8
|
|-
! $96
| [[Sound#Sound Channel Output Right|Sound Channel Output Right]]
| style="text-align: right" | <tt style="white-space: nowrap">.... ..ss ssss ssss</tt>
| R16
| Sample (s)
|-
! $98
| [[Sound#Sound Channel Output Left|Sound Channel Output Left]]
| style="text-align: right" | <tt style="white-space: nowrap">.... ..ss ssss ssss</tt>
| R16
| Sample (s)
|-
! $9A
| [[Sound#Sound Channel Output Sum|Sound Channel Output Sum]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .sss ssss ssss</tt>
| R16
| Sample (s)
|-
! $9E
| [[Sound#Sound Speaker Main Volume|Sound Speaker Main Volume]]<sup>(color)</sup>
| style="text-align: right" | <tt style="white-space: nowrap">.... ..vv</tt>
| RW8
| Main volume (v)
|-
! [[SoC]]
! $A0
| [[SoC#System Control|System Control]]
| style="text-align: right" | <tt style="white-space: nowrap">C??? swcl</tt>
| RW8
| Cartridge OK (C), ROM wait state (s), ROM width (w),
Color system (c), Boot ROM lockout (l)
|-
! [[Timers]]
! $A2
| [[Timers#Timer Control|Timer Control]]
| style="text-align: right" | <tt style="white-space: nowrap">.... VvHh</tt>
| RW8
| Horizontal enable (h), auto reload (H)
Vertical enable (v), auto reload (V)
|-
! [[SoC]]
! $A3
| [[SoC#System Test|System Test]]
| style="text-align: right" | <tt style="white-space: nowrap">.... u?vh</tt>
| RW8
| UART test (u), VBlank Timer test (v), HBlank Timer test (h)
|-
! rowspan="4" | [[Timers]]
! $A4
| [[Timers#Timer Reload|Horizontal Blank Timer Reload]]
| style="text-align: right" | <tt style="white-space: nowrap">tttt tttt tttt tttt</tt>
| RW16
| Ticks (t)
|-
! $A6
| [[Timers#Timer Reload|Vertical Blank Timer Reload]]
| style="text-align: right" | <tt style="white-space: nowrap">tttt tttt tttt tttt</tt>
| RW16
| Ticks (t)
|-
! $A8
| [[Timers#Timer Counter|Horizontal Blank Timer Counter]]
| style="text-align: right" | <tt style="white-space: nowrap">tttt tttt tttt tttt</tt>
| R16
| Ticks (t)
|-
! $AA
| [[Timers#Timer Counter|Vertical Blank Timer Counter]]
| style="text-align: right" | <tt style="white-space: nowrap">tttt tttt tttt tttt</tt>
| R16
| Ticks (t)
|-
! ?
! $AC
| ?
| style="text-align: right" | <tt style="white-space: nowrap">.... ...p</tt>
| W8?
| Power off (p)
|-
! rowspan="2" | [[Interrupts]]
! rowspan="2" | $B0
| [[Interrupts#Interrupt Vector Offset|Interrupt Vector Offset]]
| style="text-align: right" | <tt style="white-space: nowrap">VVVV V...</tt>
| W8
| Vector offset (V)
|-
| [[Interrupts#Interrupt Vector Request|Interrupt Vector Request]]
| style="text-align: right" | <tt style="white-space: nowrap">vvvv vvvv</tt>
| R8
| Requested vector offset (v)
|-
! rowspan="2" | [[UART]]
! $B1
| [[UART#Serial Receive Data|Serial Receive Data]]
| style="text-align: right" | <tt style="white-space: nowrap">dddd dddd</tt>
| R8
| Receive buffer data (d)
|-
! $B1
| [[UART#Serial Transmit Data|Serial Transmit Data]]
| style="text-align: right" | <tt style="white-space: nowrap">dddd dddd</tt>
| W8
| Transmit buffer data (d)
|-
! [[Interrupts]]
! $B2
| [[Interrupts#Interrupt Enable|Interrupt Enable]]
| style="text-align: right" | <tt style="white-space: nowrap">iiii iiii</tt>
| RW8
| Interrupt index (i)
|-
! rowspan="2" | [[UART]]
! $B3
| [[UART#Serial Status|Serial Status]]
| style="text-align: right" | <tt style="white-space: nowrap">eb.. .tor</tt>
| R8
| Enable (e), Baud rate (b),
Transfer ready (t), Overrun (o), Receive ready (r)
|-
! $B3
| [[UART#Serial Control|Serial Control]]
| style="text-align: right" | <tt style="white-space: nowrap">ebO. ....</tt>
| W8
| Enable (e), Baud rate (b), Reset Overrun (O)
|-
! [[Interrupts]]
! $B4
| [[Interrupts#Interrupt Status|Interrupt Status]]
| style="text-align: right" | <tt style="white-space: nowrap">iiii iiii</tt>
| R8
| Interrupt index (i)
|-
! [[Keypad]]
! $B5
| [[Keypad|Keypad Scan]]
| style="text-align: right" | <tt style="white-space: nowrap">.iii oooo</tt>
| RW8
| Input row (i), Output column (o)
|-
! rowspan="2" | [[Interrupts]]
! $B6
| [[Interrupts#Interrupt Acknowledge|Interrupt Acknowledge]]
| style="text-align: right" | <tt style="white-space: nowrap">iiii iiii</tt>
| W8
| Interrupt index (i)
|-
! $B7
| [[Interrupts#Interrupt NMI Control|Interrupt NMI Control]]
| style="text-align: right" | <tt style="white-space: nowrap">...b ....</tt>
| RW8
| Low battery (b)
|-
! rowspan="4" | [[EEPROM|Internal EEPROM]]
! $BA
| [[EEPROM#Internal EEPROM Data|Internal EEPROM Data]]
| style="text-align: right" | <tt style="white-space: nowrap">dddd dddd dddd dddd</tt>
| RW16
| Data (d)
|-
! $BC
| [[EEPROM#Internal EEPROM Command|Internal EEPROM Command]]
|
| RW16
|
|-
! rowspan="2" | $BE
| [[EEPROM#Internal EEPROM Status|Internal EEPROM Status]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .... p... ..RD</tt>
| R16
| Protected (p), Ready (R), Done (D)
|-
| [[EEPROM#Internal EEPROM Control|Internal EEPROM Control]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .... pewr ....</tt>
| W16
| Protect (p), Erase (e), Write (w), Read (r)
|-
! [[Mapper|Cartridge]]
! $C0<br />...<br />
$FF
| Cartridge I/O
|
| RW8
| Forwarded by the SoC
|}
== I/O port routing ==
The [[NEC V30MZ]] supports 16-bit I/O port addresses. The WonderSwan SoC routes them using the following algorithm:
* If an address is between <code>$00B8</code> and <code>$00BF</code> inclusive, it is routed to the internal EEPROM control block.
* If an address is between <code>$00C0</code> and <code>$00FF</code> inclusive, it is routed to the cartride bus.
* If an address's bits <code>0</code> through <code>8</code> inclusive are between <code>$000</code> and <code>$0B7</code> inclusive, they are routed to the SoC block.
* If none of these conditions are reached, open bus is read.
On the monochrome models, as well as color models in mono emulation, open bus is always <code>0x90</code>.
c4485579c02dc8a21e66eb6f95ffb5acd99eb17e
585
584
2025-04-08T19:49:21Z
Asie
351
/* I/O port map */
wikitext
text/x-wiki
The WonderSwan SoC has three general blocks of I/O port accesses:
{| class="wikitable"
! From !! To !! Holder !! Width !! Speed
|-
| $00 || $B7 || WonderSwan SoC || 16-bit || 1 cycle
|-
| $B8 || $BF || Internal EEPROM control || 16-bit || 1 cycle
|-
| $C0 || $FF || Cartridge bus || 8-bit || 1<sup>(color)</sup>/2 cycles (configurable)
|}
With the exception of internal EEPROM on the ASWAN, all unaligned 16-bit accesses can be converted to two 8-bit accesses with a 1-cycle penalty.
== I/O port map ==
* Superscripts are used to mark ports specific to a given mode or platform:
** Color mode: <sup>(color)</sup>. Such ports are only accessible when color mode is enabled through port <code>$60</code>.
** WS/WSC/SC console: <sup>(WS)</sup>, <sup>(WSC)</sup>, <sup>(SC)</sup>.
* If two Bits rows are provided, the second one refers to the "Color" mode.
* The Type can be: R - readable, W - writable, L - writable before boot ROM lockout, 8/16 - width (byte/word).
{| class="wikitable"
! Category
! Port
! Description
! Bits
! Type
! Notes
|-
! rowspan="47" | [[Display]]
! $00
| [[Display/IO Ports#Display Control|Display Control]]
| style="text-align: right" | <tt style="white-space: nowrap">..wo Ws21</tt>
| RW8
|
|-
! $01
| [[Display/IO Ports#Display Background|Display Background]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .sss</tt>
<tt style="white-space: nowrap">pppp iiii</tt>
| RW8
| Shade (s)
Palette (p), Index (i)
|-
! $02
| [[Display/IO Ports#Current Line|Display Current Line]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll</tt>
| R8
| Line (l)
|-
! $03
| [[Display/IO Ports#Interrupt Line|Display Interrupt Line]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll</tt>
| RW8
| Line (l)
|-
! $04
| [[Display/IO Ports#Sprite Table Address|Sprite Table Address]]
| style="text-align: right" | <tt style="white-space: nowrap">...a aaaa</tt>
<tt style="white-space: nowrap">..aa aaaa</tt>
| RW8
| Address >> 9 (a)
|-
! $05
| [[Display/IO Ports#Sprite Table First|Sprite Table First]]
| style="text-align: right" | <tt style="white-space: nowrap">.iii iiii</tt>
| RW8
| Index (i)
|-
! $06
| [[Display/IO Ports#Sprite Table Count|Sprite Table Count]]
| style="text-align: right" | <tt style="white-space: nowrap">cccc cccc</tt>
| RW8
| Count (c)
|-
! $07
| [[Display/IO Ports#Screen Address|Screen Address]]
| style="text-align: right" | <tt style="white-space: nowrap">.222 .111</tt>
<tt style="white-space: nowrap">2222 1111</tt>
| RW8
| Screen 1 address >> 11 (1)
Screen 2 address >> 11 (2)
|-
! $08
| [[Display/IO Ports#Screen 2 Window|Screen 2 Window Left]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $09
| [[Display/IO Ports#Screen 2 Window|Screen 2 Window Top]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $0A
| [[Display/IO Ports#Screen 2 Window|Screen 2 Window Right]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $0B
| [[Display/IO Ports#Screen 2 Window|Screen 2 Window Bottom]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $0C
| [[Display/IO Ports#Sprite Window|Sprite Window Left]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $0D
| [[Display/IO Ports#Sprite Window|Sprite Window Top]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $0E
| [[Display/IO Ports#Sprite Window|Sprite Window Right]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $0F
| [[Display/IO Ports#Sprite Window|Sprite Window Bottom]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $10
| [[Display/IO Ports#Screen Scroll|Screen 1 Scroll X]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $11
| [[Display/IO Ports#Screen Scroll|Screen 1 Scroll Y]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $12
| [[Display/IO Ports#Screen Scroll|Screen 2 Scroll X]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $13
| [[Display/IO Ports#Screen Scroll|Screen 2 Scroll Y]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $14
| [[Display/IO Ports#LCD Control|LCD Control]]
| style="text-align: right" | <tt style="white-space: nowrap">.... ..Ce</tt>
| RW8
| Contrast (C)<sup>(WSC)</sup>, Enable (e)
|-
! $15
| [[Display/IO Ports#LCD Icon Control|LCD Icon Control]]
| style="text-align: right" | <tt style="white-space: nowrap">..32 1hvs</tt>
| RW8
| Etc. 3 (3), Etc. 2 (2), Etc. 1 (1),
Horizontal (h), Vertical (v), Sleep (s)
|-
! $16
| [[Display/IO Ports#LCD Final Line|LCD Final Line]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll</tt>
| RW8
| Line (l)
|-
! $17
| [[Display/IO Ports#LCD Back Porch Line|LCD Back Porch Line]]<sup>(WSC)</sup>
| style="text-align: right" | <tt style="white-space: nowrap">llll llll</tt>
| RW8
| Line (l)
|-
! $18
| [[Display/IO Ports#LCD Line Counter|LCD Line Counter]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll</tt>
| W8
| Line (l)
|-
! $1A
| [[Display/IO Ports#LCD Status|LCD Latched Icon Status]]
| style="text-align: right" | <tt style="white-space: nowrap">..cv vvhs</tt>
| R8
| Cartridge icon (c), Volume icons (v),
Headphone icon (h), Latch override (l)
|-
! $1A
| [[Display/IO Ports#LCD Status|LCD Latched Icon Control]]
| style="text-align: right" | <tt style="white-space: nowrap">..cv vvhs</tt>
| W8
| Cartridge (c), Sound (s), Latch override (l)
|-
! $1C
| [[Display/IO Ports#LCD Mono Shade LUT|LCD Mono Shade LUT 0/1]]
| style="text-align: right" | <tt style="white-space: nowrap">1111 0000</tt>
| RW8
| Shade index
|-
! $1D
| [[Display/IO Ports#LCD Mono Shade LUT|LCD Mono Shade LUT 2/3]]
| style="text-align: right" | <tt style="white-space: nowrap">3333 2222</tt>
| RW8
| Shade index
|-
! $1E
| [[Display/IO Ports#LCD Mono Shade LUT|LCD Mono Shade LUT 4/5]]
| style="text-align: right" | <tt style="white-space: nowrap">5555 4444</tt>
| RW8
| Shade index
|-
! $1F
| [[Display/IO Ports#LCD Mono Shade LUT|LCD Mono Shade LUT 6/7]]
| style="text-align: right" | <tt style="white-space: nowrap">7777 6666</tt>
| RW8
| Shade index
|-
! $20
| [[Display/IO Ports#LCD Mono Palette|LCD Mono Palette 0]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $22
| [[Display/IO Ports#LCD Mono Palette|LCD Mono Palette 1]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $24
| [[Display/IO Ports#LCD Mono Palette|LCD Mono Palette 2]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $26
| [[Display/IO Ports#LCD Mono Palette|LCD Mono Palette 3]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $28
| [[Display/IO Ports#LCD Mono Palette|LCD Mono Palette 4]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 ....</tt>
| RW16
| Shade LUT index
|-
! $2A
| [[Display/IO Ports#LCD Mono Palette|LCD Mono Palette 5]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 ....</tt>
| RW16
| Shade LUT index
|-
! $2C
| [[Display/IO Ports#LCD Mono Palette|LCD Mono Palette 6]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 ....</tt>
| RW16
| Shade LUT index
|-
! $2E
| [[Display/IO Ports#LCD Mono Palette|LCD Mono Palette 7]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 ....</tt>
| RW16
| Shade LUT index
|-
! $30
| [[Display/IO Ports#LCD Mono Palette|LCD Mono Palette 8]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $32
| [[Display/IO Ports#LCD Mono Palette|LCD Mono Palette 9]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $34
| [[Display/IO Ports#LCD Mono Palette|LCD Mono Palette 10]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $36
| [[Display/IO Ports#LCD Mono Palette|LCD Mono Palette 11]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $38
| [[Display/IO Ports#LCD Mono Palette|LCD Mono Palette 12]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 ....</tt>
| RW16
| Shade LUT index
|-
! $3A
| [[Display/IO Ports#LCD Mono Palette|LCD Mono Palette 13]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 ....</tt>
| RW16
| Shade LUT index
|-
! $3C
| [[Display/IO Ports#LCD Mono Palette|LCD Mono Palette 14]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 ....</tt>
| RW16
| Shade LUT index
|-
! $3E
| [[Display/IO Ports#LCD Mono Palette|LCD Mono Palette 15]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 ....</tt>
| RW16
| Shade LUT index
|-
! rowspan="10" | [[DMA]]<sup>(color)</sup>
! $40
| [[DMA#General DMA|GDMA Source Address Low]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll llll lll.</tt>
| RW16
| Linear address, low 16 bits (l)
|-
! $42
| [[DMA#General DMA|GDMA Source Address High]]
| style="text-align: right" | <tt style="white-space: nowrap">.... hhhh</tt>
| RW8
| Linear address, high 4 bits (h)
|-
! $44
| [[DMA#General DMA|GDMA Destination Address]]
| style="text-align: right" | <tt style="white-space: nowrap">aaaa aaaa aaaa aaa.</tt>
| RW16
| IRAM address (a)
|-
! $46
| [[DMA#General DMA|GDMA Length]]
| style="text-align: right" | <tt style="white-space: nowrap">bbbb bbbb bbbb bbb.</tt>
| RW16
| Bytes (b)
|-
! $48
| [[DMA#General DMA|GDMA Control]]
| style="text-align: right" | <tt style="white-space: nowrap">ed.. ....</tt>
| RW8
| Enable (e), Decrement (d)
|-
! $4A
| [[DMA#Sound DMA|SDMA Source Address Low]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll llll llll</tt>
| RW16
| Linear address, low 16 bits (l)
|-
! $4C
| [[DMA#Sound DMA|SDMA Source Address High]]
| style="text-align: right" | <tt style="white-space: nowrap">.... hhhh</tt>
| RW8
| Linear address, high 4 bits (h)
|-
! $4E
| [[DMA#Sound DMA|SDMA Length Low]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll llll llll</tt>
| RW16
| Length, low 16 bits (l)
|-
! $50
| [[DMA#Sound DMA|SDMA Length High]]
| style="text-align: right" | <tt style="white-space: nowrap">.... hhhh</tt>
| RW8
| Length, high 4 bits (h)
|-
! $52
| [[DMA#Sound DMA|SDMA Control]]
| style="text-align: right" | <tt style="white-space: nowrap">ed.t rhff</tt>
| RW8
| Enable (e), Decrement (d), Target (t),
Repeat (r), Hold (h), Frequency (f)
|-
! rowspan="2" | [[SoC]]<sup>(color)</sup>
! $60
| [[SoC#System Control 2|System Control 2]]
| style="text-align: right" | <tt style="white-space: nowrap">c4C. i?sl</tt>
| RW8
| Color (c), 4BPP (4), Chunky (C),<br/>
Cart I/O wait state (i), SRAM wait state (s),<br/>
Cart clock speed (l).
|-
! $62
| [[SoC#System Control 3|System Control 3]]
| style="text-align: right" | <tt style="white-space: nowrap">S... ...p</tt>
| RW8
| SwanCrystal (S), Power off (p)
|-
! rowspan="4" | [[Hyper Voice]]<sup>(color)</sup>
! $64
| [[Hyper Voice#Hyper Voice Output|Hyper Voice Left Output]]
| style="text-align: right" | <tt style="white-space: nowrap">ssss ssss ssss ssss</tt>
| W16
| Raw sample (s)
|-
! $66
| [[Hyper Voice#Hyper Voice Output|Hyper Voice Right Output]]
| style="text-align: right" | <tt style="white-space: nowrap">ssss ssss ssss ssss</tt>
| W16
| Raw sample (s)
|-
! $69
| [[Hyper Voice#Hyper Voice Input|Hyper Voice Right Input]]
| style="text-align: right" | <tt style="white-space: nowrap">ssss ssss</tt>
| W8
| Sample (s)
|-
! $6A
| [[Hyper Voice#Hyper Voice Control|Hyper Voice Control]]
| style="text-align: right" | <tt style="white-space: nowrap">.mmc ???? errr ffss</tt>
| RW16
| Mask (m), Channel reset (c), Enable (e),
Rate (r), Format (f), Shift (s)
|-
! rowspan="8" | [[Display]]<sup>(SC)</sup>
! $70
| LCD Timing Configuration 1?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $71
| LCD Timing Configuration 2?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $72
| LCD Timing Configuration 3?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $73
| LCD Timing Configuration 4?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $74
| LCD Timing Configuration 5?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $75
| LCD Timing Configuration 6?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $76
| LCD Timing Configuration 7?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $77
| LCD Timing Configuration 8?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! rowspan="22" | [[Sound]]
! $80
| [[Sound#Sound Channel Frequency|Sound Channel 1 Frequency]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .ddd dddd dddd</tt>
| RW16
| Divider (d)
|-
! $82
| [[Sound#Sound Channel Frequency|Sound Channel 2 Frequency]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .ddd dddd dddd</tt>
| RW16
| Divider (d)
|-
! $84
| [[Sound#Sound Channel Frequency|Sound Channel 3 Frequency]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .ddd dddd dddd</tt>
| RW16
| Divider (d)
|-
! $86
| [[Sound#Sound Channel Frequency|Sound Channel 4 Frequency]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .ddd dddd dddd</tt>
| RW16
| Divider (d)
|-
! $88
| [[Sound#Sound Channel Volume|Sound Channel 1 Volume]]
| style="text-align: right" | <tt style="white-space: nowrap">llll rrrr</tt>
| RW8
| Left (l), Right (r)
|-
! rowspan="2" | $89
| [[Sound#Sound Channel Volume|Sound Channel 2 Volume]]
| style="text-align: right" | <tt style="white-space: nowrap">llll rrrr</tt>
| RW8
| Left (l), Right (r)
|-
| [[Sound#Sound Channel 2 Voice Sample|Sound Channel 2 Voice Sample]]
| style="text-align: right" | <tt style="white-space: nowrap">ssss ssss</tt>
| RW8
| Sample (s)
|-
! $8A
| [[Sound#Sound Channel Volume|Sound Channel 3 Volume]]
| style="text-align: right" | <tt style="white-space: nowrap">llll rrrr</tt>
| RW8
| Left (l), Right (r)
|-
! $8B
| [[Sound#Sound Channel Volume|Sound Channel 4 Volume]]
| style="text-align: right" | <tt style="white-space: nowrap">llll rrrr</tt>
| RW8
| Left (l), Right (r)
|-
! $8C
| [[Sound#Sound Channel 3 Sweep Amount|Sound Channel 3 Sweep Amount]]
| style="text-align: right" | <tt style="white-space: nowrap">vvvv vvvv</tt>
| RW8
| Value (v)
|-
! $8D
| [[Sound#Sound Channel 3 Sweep Ticks|Sound Channel 3 Sweep Ticks]]
| style="text-align: right" | <tt style="white-space: nowrap">...t tttt</tt>
| RW8
| Ticks (t)
|-
! $8E
| [[Sound#Sound Channel 4 Noise Control|Sound Channel 4 Noise Control]]
| style="text-align: right" | <tt style="white-space: nowrap">...e rttt</tt>
| RW8
| Enable (e), Reset (r), Tap (t)
|-
! $8F
| [[Sound#Sound Wavetable Address|Sound Wavetable Address]]
| style="text-align: right" | <tt style="white-space: nowrap">wwww wwww</tt>
| RW8
| Address >> 6 (w)
|-
! $90
| [[Sound#Sound Channel Control|Sound Channel Control]]
| style="text-align: right" | <tt style="white-space: nowrap">nsv. 4321</tt>
| RW8
| Channel enable (1234)
Noise (n), Sweep (s), Voice (v)
|-
! $91
| [[Sound#Sound Output Control|Sound Output Control]]
| style="text-align: right" | <tt style="white-space: nowrap">H... hrrs</tt>
| RW8
| Headphones connected (H)
Headphone output (h)
Speaker output (s), range (r)
|-
! $92
| [[Sound#Sound Channel 4 LFSR Register|Sound Channel 4 LFSR Register]]
| style="text-align: right" | <tt style="white-space: nowrap">.rrr rrrr rrrr rrrr</tt>
| R16
| PRNG state (r)
|-
! $94
| [[Sound#Sound Channel 2 Voice Volume|Sound Channel 2 Voice Volume]]
| style="text-align: right" | <tt style="white-space: nowrap">.... lLrR</tt>
| RW8
| Left Half (l), Full (L)
Right Half (r), Full (R)
|-
! $95
| [[Sound#Sound Test|Sound Test]]
| style="text-align: right" | <tt style="white-space: nowrap">425? ???h</tt>
| RW8
|
|-
! $96
| [[Sound#Sound Channel Output Right|Sound Channel Output Right]]
| style="text-align: right" | <tt style="white-space: nowrap">.... ..ss ssss ssss</tt>
| R16
| Sample (s)
|-
! $98
| [[Sound#Sound Channel Output Left|Sound Channel Output Left]]
| style="text-align: right" | <tt style="white-space: nowrap">.... ..ss ssss ssss</tt>
| R16
| Sample (s)
|-
! $9A
| [[Sound#Sound Channel Output Sum|Sound Channel Output Sum]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .sss ssss ssss</tt>
| R16
| Sample (s)
|-
! $9E
| [[Sound#Sound Speaker Main Volume|Sound Speaker Main Volume]]<sup>(color)</sup>
| style="text-align: right" | <tt style="white-space: nowrap">.... ..vv</tt>
| RW8
| Main volume (v)
|-
! [[SoC]]
! $A0
| [[SoC#System Control|System Control]]
| style="text-align: right" | <tt style="white-space: nowrap">C??? swcl</tt>
| RW8
| Cartridge OK (C), ROM wait state (s), ROM width (w),
Color system (c), Boot ROM lockout (l)
|-
! [[Timers]]
! $A2
| [[Timers#Timer Control|Timer Control]]
| style="text-align: right" | <tt style="white-space: nowrap">.... VvHh</tt>
| RW8
| Horizontal enable (h), auto reload (H)
Vertical enable (v), auto reload (V)
|-
! [[SoC]]
! $A3
| [[SoC#System Test|System Test]]
| style="text-align: right" | <tt style="white-space: nowrap">.... u?vh</tt>
| RW8
| UART test (u), VBlank Timer test (v), HBlank Timer test (h)
|-
! rowspan="4" | [[Timers]]
! $A4
| [[Timers#Timer Reload|Horizontal Blank Timer Reload]]
| style="text-align: right" | <tt style="white-space: nowrap">tttt tttt tttt tttt</tt>
| RW16
| Ticks (t)
|-
! $A6
| [[Timers#Timer Reload|Vertical Blank Timer Reload]]
| style="text-align: right" | <tt style="white-space: nowrap">tttt tttt tttt tttt</tt>
| RW16
| Ticks (t)
|-
! $A8
| [[Timers#Timer Counter|Horizontal Blank Timer Counter]]
| style="text-align: right" | <tt style="white-space: nowrap">tttt tttt tttt tttt</tt>
| R16
| Ticks (t)
|-
! $AA
| [[Timers#Timer Counter|Vertical Blank Timer Counter]]
| style="text-align: right" | <tt style="white-space: nowrap">tttt tttt tttt tttt</tt>
| R16
| Ticks (t)
|-
! [[SoC]]
! $AC
| ?
| style="text-align: right" | <tt style="white-space: nowrap">.... ...p</tt>
| W8?
| Power off (p)
|-
! rowspan="2" | [[Interrupts]]
! rowspan="2" | $B0
| [[Interrupts#Interrupt Vector Offset|Interrupt Vector Offset]]
| style="text-align: right" | <tt style="white-space: nowrap">VVVV V...</tt>
| W8
| Vector offset (V)
|-
| [[Interrupts#Interrupt Vector Request|Interrupt Vector Request]]
| style="text-align: right" | <tt style="white-space: nowrap">vvvv vvvv</tt>
| R8
| Requested vector offset (v)
|-
! rowspan="2" | [[UART]]
! $B1
| [[UART#Serial Receive Data|Serial Receive Data]]
| style="text-align: right" | <tt style="white-space: nowrap">dddd dddd</tt>
| R8
| Receive buffer data (d)
|-
! $B1
| [[UART#Serial Transmit Data|Serial Transmit Data]]
| style="text-align: right" | <tt style="white-space: nowrap">dddd dddd</tt>
| W8
| Transmit buffer data (d)
|-
! [[Interrupts]]
! $B2
| [[Interrupts#Interrupt Enable|Interrupt Enable]]
| style="text-align: right" | <tt style="white-space: nowrap">iiii iiii</tt>
| RW8
| Interrupt index (i)
|-
! rowspan="2" | [[UART]]
! $B3
| [[UART#Serial Status|Serial Status]]
| style="text-align: right" | <tt style="white-space: nowrap">eb.. .tor</tt>
| R8
| Enable (e), Baud rate (b),
Transfer ready (t), Overrun (o), Receive ready (r)
|-
! $B3
| [[UART#Serial Control|Serial Control]]
| style="text-align: right" | <tt style="white-space: nowrap">ebO. ....</tt>
| W8
| Enable (e), Baud rate (b), Reset Overrun (O)
|-
! [[Interrupts]]
! $B4
| [[Interrupts#Interrupt Status|Interrupt Status]]
| style="text-align: right" | <tt style="white-space: nowrap">iiii iiii</tt>
| R8
| Interrupt index (i)
|-
! [[Keypad]]
! $B5
| [[Keypad|Keypad Scan]]
| style="text-align: right" | <tt style="white-space: nowrap">.iii oooo</tt>
| RW8
| Input row (i), Output column (o)
|-
! rowspan="2" | [[Interrupts]]
! $B6
| [[Interrupts#Interrupt Acknowledge|Interrupt Acknowledge]]
| style="text-align: right" | <tt style="white-space: nowrap">iiii iiii</tt>
| W8
| Interrupt index (i)
|-
! $B7
| [[Interrupts#Interrupt NMI Control|Interrupt NMI Control]]
| style="text-align: right" | <tt style="white-space: nowrap">...b ....</tt>
| RW8
| Low battery (b)
|-
! rowspan="4" | [[EEPROM|Internal EEPROM]]
! $BA
| [[EEPROM#Internal EEPROM Data|Internal EEPROM Data]]
| style="text-align: right" | <tt style="white-space: nowrap">dddd dddd dddd dddd</tt>
| RW16
| Data (d)
|-
! $BC
| [[EEPROM#Internal EEPROM Command|Internal EEPROM Command]]
|
| RW16
|
|-
! rowspan="2" | $BE
| [[EEPROM#Internal EEPROM Status|Internal EEPROM Status]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .... p... ..RD</tt>
| R16
| Protected (p), Ready (R), Done (D)
|-
| [[EEPROM#Internal EEPROM Control|Internal EEPROM Control]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .... pewr ....</tt>
| W16
| Protect (p), Erase (e), Write (w), Read (r)
|-
! [[Mapper|Cartridge]]
! $C0<br />...<br />
$FF
| Cartridge I/O
|
| RW8
| Forwarded by the SoC
|}
== I/O port routing ==
The [[NEC V30MZ]] supports 16-bit I/O port addresses. The WonderSwan SoC routes them using the following algorithm:
* If an address is between <code>$00B8</code> and <code>$00BF</code> inclusive, it is routed to the internal EEPROM control block.
* If an address is between <code>$00C0</code> and <code>$00FF</code> inclusive, it is routed to the cartride bus.
* If an address's bits <code>0</code> through <code>8</code> inclusive are between <code>$000</code> and <code>$0B7</code> inclusive, they are routed to the SoC block.
* If none of these conditions are reached, open bus is read.
On the monochrome models, as well as color models in mono emulation, open bus is always <code>0x90</code>.
e4242fa517af23ae9cb649598cf0f0ab3ddfcdc2
588
585
2025-04-09T15:53:41Z
Asie
351
wikitext
text/x-wiki
The WonderSwan SoC has three general blocks of I/O port accesses:
{| class="wikitable"
! From !! To !! Holder !! Width !! Speed
|-
| $00 || $B7 || WonderSwan SoC || 16-bit || 1 cycle
|-
| $B8 || $BF || Internal EEPROM control || 16-bit || 1 cycle
|-
| $C0 || $FF || Cartridge bus || 8-bit || 1<sup>(color)</sup>/2 cycles (configurable)
|}
With the exception of internal EEPROM on the ASWAN, all unaligned 16-bit accesses can be converted to two 8-bit accesses with a 1-cycle penalty.
== I/O port map ==
* Superscripts are used to mark ports specific to a given mode or platform:
** Color mode: <sup>(color)</sup>. Such ports are only accessible when color mode is enabled through port <code>$60</code>.
** WS/WSC/SC console: <sup>(WS)</sup>, <sup>(WSC)</sup>, <sup>(SC)</sup>.
* If two Bits rows are provided, the second one refers to the "Color" mode.
* The Type can be: R - readable, W - writable, L - writable before boot ROM lockout, 8/16 - width (byte/word).
{| class="wikitable"
! Category
! Port
! Description
! Bits
! Type
! Notes
|-
! rowspan="47" | [[Display]]
! $00
| [[Display/IO Ports#Display Control|Display Control]]
| style="text-align: right" | <tt style="white-space: nowrap">..wo Ws21</tt>
| RW8
|
|-
! $01
| [[Display/IO Ports#Display Background|Display Background]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .sss</tt>
<tt style="white-space: nowrap">pppp iiii</tt>
| RW8
| Shade (s)
Palette (p), Index (i)
|-
! $02
| [[Display/IO Ports#Current Line|Display Current Line]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll</tt>
| R8
| Line (l)
|-
! $03
| [[Display/IO Ports#Interrupt Line|Display Interrupt Line]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll</tt>
| RW8
| Line (l)
|-
! $04
| [[Display/IO Ports#Sprite Table Address|Sprite Table Address]]
| style="text-align: right" | <tt style="white-space: nowrap">...a aaaa</tt>
<tt style="white-space: nowrap">..aa aaaa</tt>
| RW8
| Address >> 9 (a)
|-
! $05
| [[Display/IO Ports#Sprite Table First|Sprite Table First]]
| style="text-align: right" | <tt style="white-space: nowrap">.iii iiii</tt>
| RW8
| Index (i)
|-
! $06
| [[Display/IO Ports#Sprite Table Count|Sprite Table Count]]
| style="text-align: right" | <tt style="white-space: nowrap">cccc cccc</tt>
| RW8
| Count (c)
|-
! $07
| [[Display/IO Ports#Screen Address|Screen Address]]
| style="text-align: right" | <tt style="white-space: nowrap">.222 .111</tt>
<tt style="white-space: nowrap">2222 1111</tt>
| RW8
| Screen 1 address >> 11 (1)
Screen 2 address >> 11 (2)
|-
! $08
| [[Display/IO Ports#Screen 2 Window|Screen 2 Window Left]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $09
| [[Display/IO Ports#Screen 2 Window|Screen 2 Window Top]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $0A
| [[Display/IO Ports#Screen 2 Window|Screen 2 Window Right]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $0B
| [[Display/IO Ports#Screen 2 Window|Screen 2 Window Bottom]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $0C
| [[Display/IO Ports#Sprite Window|Sprite Window Left]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $0D
| [[Display/IO Ports#Sprite Window|Sprite Window Top]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $0E
| [[Display/IO Ports#Sprite Window|Sprite Window Right]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $0F
| [[Display/IO Ports#Sprite Window|Sprite Window Bottom]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $10
| [[Display/IO Ports#Screen Scroll|Screen 1 Scroll X]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $11
| [[Display/IO Ports#Screen Scroll|Screen 1 Scroll Y]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $12
| [[Display/IO Ports#Screen Scroll|Screen 2 Scroll X]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $13
| [[Display/IO Ports#Screen Scroll|Screen 2 Scroll Y]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $14
| [[Display/IO Ports#LCD Control|LCD Control]]
| style="text-align: right" | <tt style="white-space: nowrap">.... ..Ce</tt>
| RW8
| Contrast (C)<sup>(WSC)</sup>, Enable (e)
|-
! $15
| [[Display/IO Ports#LCD Icon Control|LCD Icon Control]]
| style="text-align: right" | <tt style="white-space: nowrap">..32 1hvs</tt>
| RW8
| Etc. 3 (3), Etc. 2 (2), Etc. 1 (1),
Horizontal (h), Vertical (v), Sleep (s)
|-
! $16
| [[Display/IO Ports#LCD Final Line|LCD Final Line]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll</tt>
| RW8
| Line (l)
|-
! $17
| [[Display/IO Ports#LCD Back Porch Line|LCD Back Porch Line]]<sup>(WSC)</sup>
| style="text-align: right" | <tt style="white-space: nowrap">llll llll</tt>
| RW8
| Line (l)
|-
! $18
| [[Display/IO Ports#LCD Line Counter|LCD Line Counter]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll</tt>
| W8
| Line (l)
|-
! $1A
| [[Display/IO Ports#LCD Status|LCD Latched Icon Status]]
| style="text-align: right" | <tt style="white-space: nowrap">..cv vvhs</tt>
| R8
| Cartridge icon (c), Volume icons (v),
Headphone icon (h), Latch override (l)
|-
! $1A
| [[Display/IO Ports#LCD Status|LCD Latched Icon Control]]
| style="text-align: right" | <tt style="white-space: nowrap">..cv vvhs</tt>
| W8
| Cartridge (c), Sound (s), Latch override (l)
|-
! $1C
| [[Display/IO Ports#LCD Mono Shade LUT|LCD Mono Shade LUT 0/1]]
| style="text-align: right" | <tt style="white-space: nowrap">1111 0000</tt>
| RW8
| Shade index
|-
! $1D
| [[Display/IO Ports#LCD Mono Shade LUT|LCD Mono Shade LUT 2/3]]
| style="text-align: right" | <tt style="white-space: nowrap">3333 2222</tt>
| RW8
| Shade index
|-
! $1E
| [[Display/IO Ports#LCD Mono Shade LUT|LCD Mono Shade LUT 4/5]]
| style="text-align: right" | <tt style="white-space: nowrap">5555 4444</tt>
| RW8
| Shade index
|-
! $1F
| [[Display/IO Ports#LCD Mono Shade LUT|LCD Mono Shade LUT 6/7]]
| style="text-align: right" | <tt style="white-space: nowrap">7777 6666</tt>
| RW8
| Shade index
|-
! $20
| [[Display/IO Ports#LCD Mono Palette|LCD Mono Palette 0]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $22
| [[Display/IO Ports#LCD Mono Palette|LCD Mono Palette 1]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $24
| [[Display/IO Ports#LCD Mono Palette|LCD Mono Palette 2]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $26
| [[Display/IO Ports#LCD Mono Palette|LCD Mono Palette 3]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $28
| [[Display/IO Ports#LCD Mono Palette|LCD Mono Palette 4]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 ....</tt>
| RW16
| Shade LUT index
|-
! $2A
| [[Display/IO Ports#LCD Mono Palette|LCD Mono Palette 5]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 ....</tt>
| RW16
| Shade LUT index
|-
! $2C
| [[Display/IO Ports#LCD Mono Palette|LCD Mono Palette 6]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 ....</tt>
| RW16
| Shade LUT index
|-
! $2E
| [[Display/IO Ports#LCD Mono Palette|LCD Mono Palette 7]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 ....</tt>
| RW16
| Shade LUT index
|-
! $30
| [[Display/IO Ports#LCD Mono Palette|LCD Mono Palette 8]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $32
| [[Display/IO Ports#LCD Mono Palette|LCD Mono Palette 9]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $34
| [[Display/IO Ports#LCD Mono Palette|LCD Mono Palette 10]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $36
| [[Display/IO Ports#LCD Mono Palette|LCD Mono Palette 11]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $38
| [[Display/IO Ports#LCD Mono Palette|LCD Mono Palette 12]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 ....</tt>
| RW16
| Shade LUT index
|-
! $3A
| [[Display/IO Ports#LCD Mono Palette|LCD Mono Palette 13]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 ....</tt>
| RW16
| Shade LUT index
|-
! $3C
| [[Display/IO Ports#LCD Mono Palette|LCD Mono Palette 14]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 ....</tt>
| RW16
| Shade LUT index
|-
! $3E
| [[Display/IO Ports#LCD Mono Palette|LCD Mono Palette 15]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 ....</tt>
| RW16
| Shade LUT index
|-
! rowspan="10" | [[DMA]]<sup>(color)</sup>
! $40
| [[DMA#General DMA|GDMA Source Address Low]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll llll lll.</tt>
| RW16
| Linear address, low 16 bits (l)
|-
! $42
| [[DMA#General DMA|GDMA Source Address High]]
| style="text-align: right" | <tt style="white-space: nowrap">.... hhhh</tt>
| RW8
| Linear address, high 4 bits (h)
|-
! $44
| [[DMA#General DMA|GDMA Destination Address]]
| style="text-align: right" | <tt style="white-space: nowrap">aaaa aaaa aaaa aaa.</tt>
| RW16
| IRAM address (a)
|-
! $46
| [[DMA#General DMA|GDMA Length]]
| style="text-align: right" | <tt style="white-space: nowrap">bbbb bbbb bbbb bbb.</tt>
| RW16
| Bytes (b)
|-
! $48
| [[DMA#General DMA|GDMA Control]]
| style="text-align: right" | <tt style="white-space: nowrap">ed.. ....</tt>
| RW8
| Enable (e), Decrement (d)
|-
! $4A
| [[DMA#Sound DMA|SDMA Source Address Low]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll llll llll</tt>
| RW16
| Linear address, low 16 bits (l)
|-
! $4C
| [[DMA#Sound DMA|SDMA Source Address High]]
| style="text-align: right" | <tt style="white-space: nowrap">.... hhhh</tt>
| RW8
| Linear address, high 4 bits (h)
|-
! $4E
| [[DMA#Sound DMA|SDMA Length Low]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll llll llll</tt>
| RW16
| Length, low 16 bits (l)
|-
! $50
| [[DMA#Sound DMA|SDMA Length High]]
| style="text-align: right" | <tt style="white-space: nowrap">.... hhhh</tt>
| RW8
| Length, high 4 bits (h)
|-
! $52
| [[DMA#Sound DMA|SDMA Control]]
| style="text-align: right" | <tt style="white-space: nowrap">ed.t rhff</tt>
| RW8
| Enable (e), Decrement (d), Target (t),
Repeat (r), Hold (h), Frequency (f)
|-
! rowspan="2" | [[SoC]]<sup>(color)</sup>
! $60
| [[SoC#System Control 2|System Control 2]]
| style="text-align: right" | <tt style="white-space: nowrap">c4C. i.sl</tt>
| RW8
| Color (c), 4BPP (4), Chunky (C),<br/>
Cart I/O wait state (i), SRAM wait state (s),<br/>
Cart clock speed (l).
|-
! $62
| [[SoC#System Control 3|System Control 3]]
| style="text-align: right" | <tt style="white-space: nowrap">S... ...p</tt>
| RW8
| SwanCrystal (S), Power off (p)
|-
! rowspan="4" | [[Hyper Voice]]<sup>(color)</sup>
! $64
| [[Hyper Voice#Hyper Voice Output|Hyper Voice Left Output]]
| style="text-align: right" | <tt style="white-space: nowrap">ssss ssss ssss ssss</tt>
| W16
| Raw sample (s)
|-
! $66
| [[Hyper Voice#Hyper Voice Output|Hyper Voice Right Output]]
| style="text-align: right" | <tt style="white-space: nowrap">ssss ssss ssss ssss</tt>
| W16
| Raw sample (s)
|-
! $69
| [[Hyper Voice#Hyper Voice Input|Hyper Voice Right Input]]
| style="text-align: right" | <tt style="white-space: nowrap">ssss ssss</tt>
| W8
| Sample (s)
|-
! $6A
| [[Hyper Voice#Hyper Voice Control|Hyper Voice Control]]
| style="text-align: right" | <tt style="white-space: nowrap">.mmc ???? errr ffss</tt>
| RW16
| Mask (m), Channel reset (c), Enable (e),
Rate (r), Format (f), Shift (s)
|-
! rowspan="8" | [[Display]]<sup>(SC)</sup>
! $70
| LCD Timing Configuration 1?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $71
| LCD Timing Configuration 2?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $72
| LCD Timing Configuration 3?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $73
| LCD Timing Configuration 4?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $74
| LCD Timing Configuration 5?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $75
| LCD Timing Configuration 6?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $76
| LCD Timing Configuration 7?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $77
| LCD Timing Configuration 8?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! rowspan="22" | [[Sound]]
! $80
| [[Sound#Sound Channel Frequency|Sound Channel 1 Frequency]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .ddd dddd dddd</tt>
| RW16
| Divider (d)
|-
! $82
| [[Sound#Sound Channel Frequency|Sound Channel 2 Frequency]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .ddd dddd dddd</tt>
| RW16
| Divider (d)
|-
! $84
| [[Sound#Sound Channel Frequency|Sound Channel 3 Frequency]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .ddd dddd dddd</tt>
| RW16
| Divider (d)
|-
! $86
| [[Sound#Sound Channel Frequency|Sound Channel 4 Frequency]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .ddd dddd dddd</tt>
| RW16
| Divider (d)
|-
! $88
| [[Sound#Sound Channel Volume|Sound Channel 1 Volume]]
| style="text-align: right" | <tt style="white-space: nowrap">llll rrrr</tt>
| RW8
| Left (l), Right (r)
|-
! rowspan="2" | $89
| [[Sound#Sound Channel Volume|Sound Channel 2 Volume]]
| style="text-align: right" | <tt style="white-space: nowrap">llll rrrr</tt>
| RW8
| Left (l), Right (r)
|-
| [[Sound#Sound Channel 2 Voice Sample|Sound Channel 2 Voice Sample]]
| style="text-align: right" | <tt style="white-space: nowrap">ssss ssss</tt>
| RW8
| Sample (s)
|-
! $8A
| [[Sound#Sound Channel Volume|Sound Channel 3 Volume]]
| style="text-align: right" | <tt style="white-space: nowrap">llll rrrr</tt>
| RW8
| Left (l), Right (r)
|-
! $8B
| [[Sound#Sound Channel Volume|Sound Channel 4 Volume]]
| style="text-align: right" | <tt style="white-space: nowrap">llll rrrr</tt>
| RW8
| Left (l), Right (r)
|-
! $8C
| [[Sound#Sound Channel 3 Sweep Amount|Sound Channel 3 Sweep Amount]]
| style="text-align: right" | <tt style="white-space: nowrap">vvvv vvvv</tt>
| RW8
| Value (v)
|-
! $8D
| [[Sound#Sound Channel 3 Sweep Ticks|Sound Channel 3 Sweep Ticks]]
| style="text-align: right" | <tt style="white-space: nowrap">...t tttt</tt>
| RW8
| Ticks (t)
|-
! $8E
| [[Sound#Sound Channel 4 Noise Control|Sound Channel 4 Noise Control]]
| style="text-align: right" | <tt style="white-space: nowrap">...e rttt</tt>
| RW8
| Enable (e), Reset (r), Tap (t)
|-
! $8F
| [[Sound#Sound Wavetable Address|Sound Wavetable Address]]
| style="text-align: right" | <tt style="white-space: nowrap">wwww wwww</tt>
| RW8
| Address >> 6 (w)
|-
! $90
| [[Sound#Sound Channel Control|Sound Channel Control]]
| style="text-align: right" | <tt style="white-space: nowrap">nsv. 4321</tt>
| RW8
| Channel enable (1234)
Noise (n), Sweep (s), Voice (v)
|-
! $91
| [[Sound#Sound Output Control|Sound Output Control]]
| style="text-align: right" | <tt style="white-space: nowrap">H... hrrs</tt>
| RW8
| Headphones connected (H)
Headphone output (h)
Speaker output (s), range (r)
|-
! $92
| [[Sound#Sound Channel 4 LFSR Register|Sound Channel 4 LFSR Register]]
| style="text-align: right" | <tt style="white-space: nowrap">.rrr rrrr rrrr rrrr</tt>
| R16
| PRNG state (r)
|-
! $94
| [[Sound#Sound Channel 2 Voice Volume|Sound Channel 2 Voice Volume]]
| style="text-align: right" | <tt style="white-space: nowrap">.... lLrR</tt>
| RW8
| Left Half (l), Full (L)
Right Half (r), Full (R)
|-
! $95
| [[Sound#Sound Test|Sound Test]]
| style="text-align: right" | <tt style="white-space: nowrap">425? ???h</tt>
| RW8
|
|-
! $96
| [[Sound#Sound Channel Output Right|Sound Channel Output Right]]
| style="text-align: right" | <tt style="white-space: nowrap">.... ..ss ssss ssss</tt>
| R16
| Sample (s)
|-
! $98
| [[Sound#Sound Channel Output Left|Sound Channel Output Left]]
| style="text-align: right" | <tt style="white-space: nowrap">.... ..ss ssss ssss</tt>
| R16
| Sample (s)
|-
! $9A
| [[Sound#Sound Channel Output Sum|Sound Channel Output Sum]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .sss ssss ssss</tt>
| R16
| Sample (s)
|-
! $9E
| [[Sound#Sound Speaker Main Volume|Sound Speaker Main Volume]]<sup>(color)</sup>
| style="text-align: right" | <tt style="white-space: nowrap">.... ..vv</tt>
| RW8
| Main volume (v)
|-
! [[SoC]]
! $A0
| [[SoC#System Control|System Control]]
| style="text-align: right" | <tt style="white-space: nowrap">C??? swcl</tt>
| RW8
| Cartridge OK (C), ROM wait state (s), ROM width (w),
Color system (c), Boot ROM lockout (l)
|-
! [[Timers]]
! $A2
| [[Timers#Timer Control|Timer Control]]
| style="text-align: right" | <tt style="white-space: nowrap">.... VvHh</tt>
| RW8
| Horizontal enable (h), auto reload (H)
Vertical enable (v), auto reload (V)
|-
! [[SoC]]
! $A3
| [[SoC#System Test|System Test]]
| style="text-align: right" | <tt style="white-space: nowrap">.... u?vh</tt>
| RW8
| UART test (u), VBlank Timer test (v), HBlank Timer test (h)
|-
! rowspan="4" | [[Timers]]
! $A4
| [[Timers#Timer Reload|Horizontal Blank Timer Reload]]
| style="text-align: right" | <tt style="white-space: nowrap">tttt tttt tttt tttt</tt>
| RW16
| Ticks (t)
|-
! $A6
| [[Timers#Timer Reload|Vertical Blank Timer Reload]]
| style="text-align: right" | <tt style="white-space: nowrap">tttt tttt tttt tttt</tt>
| RW16
| Ticks (t)
|-
! $A8
| [[Timers#Timer Counter|Horizontal Blank Timer Counter]]
| style="text-align: right" | <tt style="white-space: nowrap">tttt tttt tttt tttt</tt>
| R16
| Ticks (t)
|-
! $AA
| [[Timers#Timer Counter|Vertical Blank Timer Counter]]
| style="text-align: right" | <tt style="white-space: nowrap">tttt tttt tttt tttt</tt>
| R16
| Ticks (t)
|-
! [[SoC]]
! $AC
| ?
| style="text-align: right" | <tt style="white-space: nowrap">.... ...p</tt>
| W8?
| Power off (p)
|-
! rowspan="2" | [[Interrupts]]
! rowspan="2" | $B0
| [[Interrupts#Interrupt Vector Offset|Interrupt Vector Offset]]
| style="text-align: right" | <tt style="white-space: nowrap">VVVV V...</tt>
| W8
| Vector offset (V)
|-
| [[Interrupts#Interrupt Vector Request|Interrupt Vector Request]]
| style="text-align: right" | <tt style="white-space: nowrap">vvvv vvvv</tt>
| R8
| Requested vector offset (v)
|-
! rowspan="2" | [[UART]]
! $B1
| [[UART#Serial Receive Data|Serial Receive Data]]
| style="text-align: right" | <tt style="white-space: nowrap">dddd dddd</tt>
| R8
| Receive buffer data (d)
|-
! $B1
| [[UART#Serial Transmit Data|Serial Transmit Data]]
| style="text-align: right" | <tt style="white-space: nowrap">dddd dddd</tt>
| W8
| Transmit buffer data (d)
|-
! [[Interrupts]]
! $B2
| [[Interrupts#Interrupt Enable|Interrupt Enable]]
| style="text-align: right" | <tt style="white-space: nowrap">iiii iiii</tt>
| RW8
| Interrupt index (i)
|-
! rowspan="2" | [[UART]]
! $B3
| [[UART#Serial Status|Serial Status]]
| style="text-align: right" | <tt style="white-space: nowrap">eb.. .tor</tt>
| R8
| Enable (e), Baud rate (b),
Transfer ready (t), Overrun (o), Receive ready (r)
|-
! $B3
| [[UART#Serial Control|Serial Control]]
| style="text-align: right" | <tt style="white-space: nowrap">ebO. ....</tt>
| W8
| Enable (e), Baud rate (b), Reset Overrun (O)
|-
! [[Interrupts]]
! $B4
| [[Interrupts#Interrupt Status|Interrupt Status]]
| style="text-align: right" | <tt style="white-space: nowrap">iiii iiii</tt>
| R8
| Interrupt index (i)
|-
! [[Keypad]]
! $B5
| [[Keypad|Keypad Scan]]
| style="text-align: right" | <tt style="white-space: nowrap">.iii oooo</tt>
| RW8
| Input row (i), Output column (o)
|-
! rowspan="2" | [[Interrupts]]
! $B6
| [[Interrupts#Interrupt Acknowledge|Interrupt Acknowledge]]
| style="text-align: right" | <tt style="white-space: nowrap">iiii iiii</tt>
| W8
| Interrupt index (i)
|-
! $B7
| [[Interrupts#Interrupt NMI Control|Interrupt NMI Control]]
| style="text-align: right" | <tt style="white-space: nowrap">...b ....</tt>
| RW8
| Low battery (b)
|-
! rowspan="4" | [[EEPROM|Internal EEPROM]]
! $BA
| [[EEPROM#Internal EEPROM Data|Internal EEPROM Data]]
| style="text-align: right" | <tt style="white-space: nowrap">dddd dddd dddd dddd</tt>
| RW16
| Data (d)
|-
! $BC
| [[EEPROM#Internal EEPROM Command|Internal EEPROM Command]]
|
| RW16
|
|-
! rowspan="2" | $BE
| [[EEPROM#Internal EEPROM Status|Internal EEPROM Status]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .... p... ..RD</tt>
| R16
| Protected (p), Ready (R), Done (D)
|-
| [[EEPROM#Internal EEPROM Control|Internal EEPROM Control]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .... pewr ....</tt>
| W16
| Protect (p), Erase (e), Write (w), Read (r)
|-
! [[Mapper|Cartridge]]
! $C0<br />...<br />
$FF
| Cartridge I/O
|
| RW8
| Forwarded by the SoC
|}
== I/O port routing ==
The [[NEC V30MZ]] supports 16-bit I/O port addresses. The WonderSwan SoC routes them using the following algorithm:
* If an address is between <code>$00B8</code> and <code>$00BF</code> inclusive, it is routed to the internal EEPROM control block.
* If an address is between <code>$00C0</code> and <code>$00FF</code> inclusive, it is routed to the cartride bus.
* If an address's bits <code>0</code> through <code>8</code> inclusive are between <code>$000</code> and <code>$0B7</code> inclusive, they are routed to the SoC block.
* If none of these conditions are reached, open bus is read.
On the monochrome models, as well as color models in mono emulation, open bus is always <code>0x90</code>.
a7b2424416f99e50d10425815c41ba3f8e4a96bf
597
588
2025-04-20T18:16:51Z
Asie
351
/* I/O port map */
wikitext
text/x-wiki
The WonderSwan SoC has three general blocks of I/O port accesses:
{| class="wikitable"
! From !! To !! Holder !! Width !! Speed
|-
| $00 || $B7 || WonderSwan SoC || 16-bit || 1 cycle
|-
| $B8 || $BF || Internal EEPROM control || 16-bit || 1 cycle
|-
| $C0 || $FF || Cartridge bus || 8-bit || 1<sup>(color)</sup>/2 cycles (configurable)
|}
With the exception of internal EEPROM on the ASWAN, all unaligned 16-bit accesses can be converted to two 8-bit accesses with a 1-cycle penalty.
== I/O port map ==
* Superscripts are used to mark ports specific to a given mode or platform:
** Color mode: <sup>(color)</sup>. Such ports are only accessible when color mode is enabled through port <code>$60</code>.
** WS/WSC/SC console: <sup>(WS)</sup>, <sup>(WSC)</sup>, <sup>(SC)</sup>.
* If two Bits rows are provided, the second one refers to the "Color" mode.
* The Type can be: R - readable, W - writable, L - writable before boot ROM lockout, 8/16 - width (byte/word).
{| class="wikitable"
! Category
! Port
! Description
! Bits
! Type
! Notes
|-
! rowspan="47" | [[Display]]
! $00
| [[Display/IO Ports#Display Control|Display Control]]
| style="text-align: right" | <tt style="white-space: nowrap">..wo Ws21</tt>
| RW8
|
|-
! $01
| [[Display/IO Ports#Display Background|Display Background]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .sss</tt>
<tt style="white-space: nowrap">pppp iiii</tt>
| RW8
| Shade (s)
Palette (p), Index (i)
|-
! $02
| [[Display/IO Ports#Current Line|Display Current Line]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll</tt>
| R8
| Line (l)
|-
! $03
| [[Display/IO Ports#Interrupt Line|Display Interrupt Line]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll</tt>
| RW8
| Line (l)
|-
! $04
| [[Display/IO Ports#Sprite Table Address|Sprite Table Address]]
| style="text-align: right" | <tt style="white-space: nowrap">...a aaaa</tt>
<tt style="white-space: nowrap">..aa aaaa</tt>
| RW8
| Address >> 9 (a)
|-
! $05
| [[Display/IO Ports#Sprite Table First|Sprite Table First]]
| style="text-align: right" | <tt style="white-space: nowrap">.iii iiii</tt>
| RW8
| Index (i)
|-
! $06
| [[Display/IO Ports#Sprite Table Count|Sprite Table Count]]
| style="text-align: right" | <tt style="white-space: nowrap">cccc cccc</tt>
| RW8
| Count (c)
|-
! $07
| [[Display/IO Ports#Screen Address|Screen Address]]
| style="text-align: right" | <tt style="white-space: nowrap">.222 .111</tt>
<tt style="white-space: nowrap">2222 1111</tt>
| RW8
| Screen 1 address >> 11 (1)
Screen 2 address >> 11 (2)
|-
! $08
| [[Display/IO Ports#Screen 2 Window|Screen 2 Window Left]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $09
| [[Display/IO Ports#Screen 2 Window|Screen 2 Window Top]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $0A
| [[Display/IO Ports#Screen 2 Window|Screen 2 Window Right]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $0B
| [[Display/IO Ports#Screen 2 Window|Screen 2 Window Bottom]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $0C
| [[Display/IO Ports#Sprite Window|Sprite Window Left]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $0D
| [[Display/IO Ports#Sprite Window|Sprite Window Top]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $0E
| [[Display/IO Ports#Sprite Window|Sprite Window Right]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $0F
| [[Display/IO Ports#Sprite Window|Sprite Window Bottom]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $10
| [[Display/IO Ports#Screen Scroll|Screen 1 Scroll X]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $11
| [[Display/IO Ports#Screen Scroll|Screen 1 Scroll Y]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $12
| [[Display/IO Ports#Screen Scroll|Screen 2 Scroll X]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $13
| [[Display/IO Ports#Screen Scroll|Screen 2 Scroll Y]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $14
| [[Display/IO Ports#LCD Control|LCD Control]]
| style="text-align: right" | <tt style="white-space: nowrap">.... ..Ce</tt>
| RW8
| Contrast (C)<sup>(WSC)</sup>, Enable (e)
|-
! $15
| [[Display/IO Ports#LCD Icon Control|LCD Icon Control]]
| style="text-align: right" | <tt style="white-space: nowrap">..32 1hvs</tt>
| RW8
| Etc. 3 (3), Etc. 2 (2), Etc. 1 (1),
Horizontal (h), Vertical (v), Sleep (s)
|-
! $16
| [[Display/IO Ports#LCD Final Line|LCD Final Line]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll</tt>
| RW8
| Line (l)
|-
! $17
| [[Display/IO Ports#LCD Back Porch Line|LCD Back Porch Line]]<sup>(WSC)</sup>
| style="text-align: right" | <tt style="white-space: nowrap">llll llll</tt>
| RW8
| Line (l)
|-
! $18
| [[Display/IO Ports#LCD Line Counter|LCD Line Counter]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll</tt>
| W8
| Line (l)
|-
! $1A
| [[Display/IO Ports#LCD Status|LCD Latched Icon Status]]
| style="text-align: right" | <tt style="white-space: nowrap">..cv vvhs</tt>
| R8
| Cartridge icon (c), Volume icons (v),
Headphone icon (h), Latch override (l)
|-
! $1A
| [[Display/IO Ports#LCD Status|LCD Latched Icon Control]]
| style="text-align: right" | <tt style="white-space: nowrap">..cv vvhs</tt>
| W8
| Cartridge (c), Sound (s), Latch override (l)
|-
! $1C
| [[Display/IO Ports#LCD Mono Shade LUT|LCD Mono Shade LUT 0/1]]
| style="text-align: right" | <tt style="white-space: nowrap">1111 0000</tt>
| RW8
| Shade index
|-
! $1D
| [[Display/IO Ports#LCD Mono Shade LUT|LCD Mono Shade LUT 2/3]]
| style="text-align: right" | <tt style="white-space: nowrap">3333 2222</tt>
| RW8
| Shade index
|-
! $1E
| [[Display/IO Ports#LCD Mono Shade LUT|LCD Mono Shade LUT 4/5]]
| style="text-align: right" | <tt style="white-space: nowrap">5555 4444</tt>
| RW8
| Shade index
|-
! $1F
| [[Display/IO Ports#LCD Mono Shade LUT|LCD Mono Shade LUT 6/7]]
| style="text-align: right" | <tt style="white-space: nowrap">7777 6666</tt>
| RW8
| Shade index
|-
! $20
| [[Display/IO Ports#LCD Mono Palette|LCD Mono Palette 0]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $22
| [[Display/IO Ports#LCD Mono Palette|LCD Mono Palette 1]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $24
| [[Display/IO Ports#LCD Mono Palette|LCD Mono Palette 2]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $26
| [[Display/IO Ports#LCD Mono Palette|LCD Mono Palette 3]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $28
| [[Display/IO Ports#LCD Mono Palette|LCD Mono Palette 4]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 ....</tt>
| RW16
| Shade LUT index
|-
! $2A
| [[Display/IO Ports#LCD Mono Palette|LCD Mono Palette 5]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 ....</tt>
| RW16
| Shade LUT index
|-
! $2C
| [[Display/IO Ports#LCD Mono Palette|LCD Mono Palette 6]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 ....</tt>
| RW16
| Shade LUT index
|-
! $2E
| [[Display/IO Ports#LCD Mono Palette|LCD Mono Palette 7]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 ....</tt>
| RW16
| Shade LUT index
|-
! $30
| [[Display/IO Ports#LCD Mono Palette|LCD Mono Palette 8]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $32
| [[Display/IO Ports#LCD Mono Palette|LCD Mono Palette 9]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $34
| [[Display/IO Ports#LCD Mono Palette|LCD Mono Palette 10]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $36
| [[Display/IO Ports#LCD Mono Palette|LCD Mono Palette 11]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $38
| [[Display/IO Ports#LCD Mono Palette|LCD Mono Palette 12]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 ....</tt>
| RW16
| Shade LUT index
|-
! $3A
| [[Display/IO Ports#LCD Mono Palette|LCD Mono Palette 13]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 ....</tt>
| RW16
| Shade LUT index
|-
! $3C
| [[Display/IO Ports#LCD Mono Palette|LCD Mono Palette 14]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 ....</tt>
| RW16
| Shade LUT index
|-
! $3E
| [[Display/IO Ports#LCD Mono Palette|LCD Mono Palette 15]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 ....</tt>
| RW16
| Shade LUT index
|-
! rowspan="10" | [[DMA]]<sup>(color)</sup>
! $40
| [[DMA#General DMA|GDMA Source Address Low]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll llll lll.</tt>
| RW16
| Linear address, low 16 bits (l)
|-
! $42
| [[DMA#General DMA|GDMA Source Address High]]
| style="text-align: right" | <tt style="white-space: nowrap">.... hhhh</tt>
| RW8
| Linear address, high 4 bits (h)
|-
! $44
| [[DMA#General DMA|GDMA Destination Address]]
| style="text-align: right" | <tt style="white-space: nowrap">aaaa aaaa aaaa aaa.</tt>
| RW16
| IRAM address (a)
|-
! $46
| [[DMA#General DMA|GDMA Length]]
| style="text-align: right" | <tt style="white-space: nowrap">bbbb bbbb bbbb bbb.</tt>
| RW16
| Bytes (b)
|-
! $48
| [[DMA#General DMA|GDMA Control]]
| style="text-align: right" | <tt style="white-space: nowrap">ed.. ....</tt>
| RW8
| Enable (e), Decrement (d)
|-
! $4A
| [[DMA#Sound DMA|SDMA Source Address Low]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll llll llll</tt>
| RW16
| Linear address, low 16 bits (l)
|-
! $4C
| [[DMA#Sound DMA|SDMA Source Address High]]
| style="text-align: right" | <tt style="white-space: nowrap">.... hhhh</tt>
| RW8
| Linear address, high 4 bits (h)
|-
! $4E
| [[DMA#Sound DMA|SDMA Length Low]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll llll llll</tt>
| RW16
| Length, low 16 bits (l)
|-
! $50
| [[DMA#Sound DMA|SDMA Length High]]
| style="text-align: right" | <tt style="white-space: nowrap">.... hhhh</tt>
| RW8
| Length, high 4 bits (h)
|-
! $52
| [[DMA#Sound DMA|SDMA Control]]
| style="text-align: right" | <tt style="white-space: nowrap">ed.t rhff</tt>
| RW8
| Enable (e), Decrement (d), Target (t),
Repeat (r), Hold (h), Frequency (f)
|-
! rowspan="2" | [[SoC]]<sup>(color)</sup>
! $60
| [[SoC#System Control 2|System Control 2]]
| style="text-align: right" | <tt style="white-space: nowrap">c4C. i.sl</tt>
| RW8
| Color (c), 4BPP (4), Chunky (C),<br/>
Cart I/O wait state (i), SRAM wait state (s),<br/>
Cart clock speed (l).
|-
! $62
| [[SoC#System Control 3|System Control 3]]
| style="text-align: right" | <tt style="white-space: nowrap">S... ...p</tt>
| RW8
| SwanCrystal (S), Power off (p)
|-
! rowspan="4" | [[Hyper Voice]]<sup>(color)</sup>
! $64
| [[Hyper Voice#Hyper Voice Output|Hyper Voice Left Output]]
| style="text-align: right" | <tt style="white-space: nowrap">ssss ssss ssss ssss</tt>
| W16
| Raw sample (s)
|-
! $66
| [[Hyper Voice#Hyper Voice Output|Hyper Voice Right Output]]
| style="text-align: right" | <tt style="white-space: nowrap">ssss ssss ssss ssss</tt>
| W16
| Raw sample (s)
|-
! $69
| [[Hyper Voice#Hyper Voice Input|Hyper Voice Right Input]]
| style="text-align: right" | <tt style="white-space: nowrap">ssss ssss</tt>
| W8
| Sample (s)
|-
! $6A
| [[Hyper Voice#Hyper Voice Control|Hyper Voice Control]]
| style="text-align: right" | <tt style="white-space: nowrap">.mmc ???? errr ffss</tt>
| RW16
| Mask (m), Channel reset (c), Enable (e),
Rate (r), Format (f), Shift (s)
|-
! rowspan="8" | [[Display]]<sup>(SC)</sup>
! $70
| LCD Timing Configuration 1?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $71
| LCD Timing Configuration 2?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $72
| LCD Timing Configuration 3?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $73
| LCD Timing Configuration 4?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $74
| LCD Timing Configuration 5?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $75
| LCD Timing Configuration 6?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $76
| LCD Timing Configuration 7?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $77
| LCD Timing Configuration 8?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! rowspan="22" | [[Sound]]
! $80
| [[Sound#Sound Channel Frequency|Sound Channel 1 Frequency]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .ddd dddd dddd</tt>
| RW16
| Divider (d)
|-
! $82
| [[Sound#Sound Channel Frequency|Sound Channel 2 Frequency]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .ddd dddd dddd</tt>
| RW16
| Divider (d)
|-
! $84
| [[Sound#Sound Channel Frequency|Sound Channel 3 Frequency]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .ddd dddd dddd</tt>
| RW16
| Divider (d)
|-
! $86
| [[Sound#Sound Channel Frequency|Sound Channel 4 Frequency]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .ddd dddd dddd</tt>
| RW16
| Divider (d)
|-
! $88
| [[Sound#Sound Channel Volume|Sound Channel 1 Volume]]
| style="text-align: right" | <tt style="white-space: nowrap">llll rrrr</tt>
| RW8
| Left (l), Right (r)
|-
! rowspan="2" | $89
| [[Sound#Sound Channel Volume|Sound Channel 2 Volume]]
| style="text-align: right" | <tt style="white-space: nowrap">llll rrrr</tt>
| RW8
| Left (l), Right (r)
|-
| [[Sound#Sound Channel 2 Voice Sample|Sound Channel 2 Voice Sample]]
| style="text-align: right" | <tt style="white-space: nowrap">ssss ssss</tt>
| RW8
| Sample (s)
|-
! $8A
| [[Sound#Sound Channel Volume|Sound Channel 3 Volume]]
| style="text-align: right" | <tt style="white-space: nowrap">llll rrrr</tt>
| RW8
| Left (l), Right (r)
|-
! $8B
| [[Sound#Sound Channel Volume|Sound Channel 4 Volume]]
| style="text-align: right" | <tt style="white-space: nowrap">llll rrrr</tt>
| RW8
| Left (l), Right (r)
|-
! $8C
| [[Sound#Sound Channel 3 Sweep Amount|Sound Channel 3 Sweep Amount]]
| style="text-align: right" | <tt style="white-space: nowrap">vvvv vvvv</tt>
| RW8
| Value (v)
|-
! $8D
| [[Sound#Sound Channel 3 Sweep Ticks|Sound Channel 3 Sweep Ticks]]
| style="text-align: right" | <tt style="white-space: nowrap">...t tttt</tt>
| RW8
| Ticks (t)
|-
! $8E
| [[Sound#Sound Channel 4 Noise Control|Sound Channel 4 Noise Control]]
| style="text-align: right" | <tt style="white-space: nowrap">...e rttt</tt>
| RW8
| Enable (e), Reset (r), Tap (t)
|-
! $8F
| [[Sound#Sound Wavetable Address|Sound Wavetable Address]]
| style="text-align: right" | <tt style="white-space: nowrap">wwww wwww</tt>
| RW8
| Address >> 6 (w)
|-
! $90
| [[Sound#Sound Channel Control|Sound Channel Control]]
| style="text-align: right" | <tt style="white-space: nowrap">nsv. 4321</tt>
| RW8
| Channel enable (1234)
Noise (n), Sweep (s), Voice (v)
|-
! $91
| [[Sound#Sound Output Control|Sound Output Control]]
| style="text-align: right" | <tt style="white-space: nowrap">H... hrrs</tt>
| RW8
| Headphones connected (H)
Headphone output (h)
Speaker output (s), range (r)
|-
! $92
| [[Sound#Sound Channel 4 LFSR Register|Sound Channel 4 LFSR Register]]
| style="text-align: right" | <tt style="white-space: nowrap">.rrr rrrr rrrr rrrr</tt>
| R16
| PRNG state (r)
|-
! $94
| [[Sound#Sound Channel 2 Voice Volume|Sound Channel 2 Voice Volume]]
| style="text-align: right" | <tt style="white-space: nowrap">.... lLrR</tt>
| RW8
| Left Half (l), Full (L)
Right Half (r), Full (R)
|-
! $95
| [[Sound#Sound Test|Sound Test]]
| style="text-align: right" | <tt style="white-space: nowrap">cc5? ??sh</tt>
| RW8
|
|-
! $96
| [[Sound#Sound Channel Output Right|Sound Channel Output Right]]
| style="text-align: right" | <tt style="white-space: nowrap">.... ..ss ssss ssss</tt>
| R16
| Sample (s)
|-
! $98
| [[Sound#Sound Channel Output Left|Sound Channel Output Left]]
| style="text-align: right" | <tt style="white-space: nowrap">.... ..ss ssss ssss</tt>
| R16
| Sample (s)
|-
! $9A
| [[Sound#Sound Channel Output Sum|Sound Channel Output Sum]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .sss ssss ssss</tt>
| R16
| Sample (s)
|-
! $9E
| [[Sound#Sound Speaker Main Volume|Sound Speaker Main Volume]]<sup>(color)</sup>
| style="text-align: right" | <tt style="white-space: nowrap">.... ..vv</tt>
| RW8
| Main volume (v)
|-
! [[SoC]]
! $A0
| [[SoC#System Control|System Control]]
| style="text-align: right" | <tt style="white-space: nowrap">C??? swcl</tt>
| RW8
| Cartridge OK (C), ROM wait state (s), ROM width (w),
Color system (c), Boot ROM lockout (l)
|-
! [[Timers]]
! $A2
| [[Timers#Timer Control|Timer Control]]
| style="text-align: right" | <tt style="white-space: nowrap">.... VvHh</tt>
| RW8
| Horizontal enable (h), auto reload (H)
Vertical enable (v), auto reload (V)
|-
! [[SoC]]
! $A3
| [[SoC#System Test|System Test]]
| style="text-align: right" | <tt style="white-space: nowrap">.... u?vh</tt>
| RW8
| UART test (u), VBlank Timer test (v), HBlank Timer test (h)
|-
! rowspan="4" | [[Timers]]
! $A4
| [[Timers#Timer Reload|Horizontal Blank Timer Reload]]
| style="text-align: right" | <tt style="white-space: nowrap">tttt tttt tttt tttt</tt>
| RW16
| Ticks (t)
|-
! $A6
| [[Timers#Timer Reload|Vertical Blank Timer Reload]]
| style="text-align: right" | <tt style="white-space: nowrap">tttt tttt tttt tttt</tt>
| RW16
| Ticks (t)
|-
! $A8
| [[Timers#Timer Counter|Horizontal Blank Timer Counter]]
| style="text-align: right" | <tt style="white-space: nowrap">tttt tttt tttt tttt</tt>
| R16
| Ticks (t)
|-
! $AA
| [[Timers#Timer Counter|Vertical Blank Timer Counter]]
| style="text-align: right" | <tt style="white-space: nowrap">tttt tttt tttt tttt</tt>
| R16
| Ticks (t)
|-
! [[SoC]]
! $AC
| ?
| style="text-align: right" | <tt style="white-space: nowrap">.... ...p</tt>
| W8?
| Power off (p)
|-
! rowspan="2" | [[Interrupts]]
! rowspan="2" | $B0
| [[Interrupts#Interrupt Vector Offset|Interrupt Vector Offset]]
| style="text-align: right" | <tt style="white-space: nowrap">VVVV V...</tt>
| W8
| Vector offset (V)
|-
| [[Interrupts#Interrupt Vector Request|Interrupt Vector Request]]
| style="text-align: right" | <tt style="white-space: nowrap">vvvv vvvv</tt>
| R8
| Requested vector offset (v)
|-
! rowspan="2" | [[UART]]
! $B1
| [[UART#Serial Receive Data|Serial Receive Data]]
| style="text-align: right" | <tt style="white-space: nowrap">dddd dddd</tt>
| R8
| Receive buffer data (d)
|-
! $B1
| [[UART#Serial Transmit Data|Serial Transmit Data]]
| style="text-align: right" | <tt style="white-space: nowrap">dddd dddd</tt>
| W8
| Transmit buffer data (d)
|-
! [[Interrupts]]
! $B2
| [[Interrupts#Interrupt Enable|Interrupt Enable]]
| style="text-align: right" | <tt style="white-space: nowrap">iiii iiii</tt>
| RW8
| Interrupt index (i)
|-
! rowspan="2" | [[UART]]
! $B3
| [[UART#Serial Status|Serial Status]]
| style="text-align: right" | <tt style="white-space: nowrap">eb.. .tor</tt>
| R8
| Enable (e), Baud rate (b),
Transfer ready (t), Overrun (o), Receive ready (r)
|-
! $B3
| [[UART#Serial Control|Serial Control]]
| style="text-align: right" | <tt style="white-space: nowrap">ebO. ....</tt>
| W8
| Enable (e), Baud rate (b), Reset Overrun (O)
|-
! [[Interrupts]]
! $B4
| [[Interrupts#Interrupt Status|Interrupt Status]]
| style="text-align: right" | <tt style="white-space: nowrap">iiii iiii</tt>
| R8
| Interrupt index (i)
|-
! [[Keypad]]
! $B5
| [[Keypad|Keypad Scan]]
| style="text-align: right" | <tt style="white-space: nowrap">.iii oooo</tt>
| RW8
| Input row (i), Output column (o)
|-
! rowspan="2" | [[Interrupts]]
! $B6
| [[Interrupts#Interrupt Acknowledge|Interrupt Acknowledge]]
| style="text-align: right" | <tt style="white-space: nowrap">iiii iiii</tt>
| W8
| Interrupt index (i)
|-
! $B7
| [[Interrupts#Interrupt NMI Control|Interrupt NMI Control]]
| style="text-align: right" | <tt style="white-space: nowrap">...b ....</tt>
| RW8
| Low battery (b)
|-
! rowspan="4" | [[EEPROM|Internal EEPROM]]
! $BA
| [[EEPROM#Internal EEPROM Data|Internal EEPROM Data]]
| style="text-align: right" | <tt style="white-space: nowrap">dddd dddd dddd dddd</tt>
| RW16
| Data (d)
|-
! $BC
| [[EEPROM#Internal EEPROM Command|Internal EEPROM Command]]
|
| RW16
|
|-
! rowspan="2" | $BE
| [[EEPROM#Internal EEPROM Status|Internal EEPROM Status]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .... p... ..RD</tt>
| R16
| Protected (p), Ready (R), Done (D)
|-
| [[EEPROM#Internal EEPROM Control|Internal EEPROM Control]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .... pewr ....</tt>
| W16
| Protect (p), Erase (e), Write (w), Read (r)
|-
! [[Mapper|Cartridge]]
! $C0<br />...<br />
$FF
| Cartridge I/O
|
| RW8
| Forwarded by the SoC
|}
== I/O port routing ==
The [[NEC V30MZ]] supports 16-bit I/O port addresses. The WonderSwan SoC routes them using the following algorithm:
* If an address is between <code>$00B8</code> and <code>$00BF</code> inclusive, it is routed to the internal EEPROM control block.
* If an address is between <code>$00C0</code> and <code>$00FF</code> inclusive, it is routed to the cartride bus.
* If an address's bits <code>0</code> through <code>8</code> inclusive are between <code>$000</code> and <code>$0B7</code> inclusive, they are routed to the SoC block.
* If none of these conditions are reached, open bus is read.
On the monochrome models, as well as color models in mono emulation, open bus is always <code>0x90</code>.
43c3c8ad0999a682ba5994e11de3947205661e2f
Display/IO Ports
0
74
582
545
2025-04-08T15:33:29Z
Asie
351
/* Mono Palette 0..15 ($20, $21 .. $3E, $3F) */
wikitext
text/x-wiki
== Graphics I/O ports ==
{{Anchor|Display Control}}
=== Display Control ($00) ===
<pre>
7 bit 0
---- ----
..wo Ws21
|| ||||
|| |||+- Enable Screen 1 layer
|| ||+-- Enable Screen 2 layer
|| |+--- Enable Sprite layer
|| +---- Enable Sprite window
|+------ Screen 2 tiles are drawn (if window enabled):
| 0 = inside window,
| 1 = outside window.
+------- Enable Screen 2 window
</pre>
{{Anchor|Display Background}}
=== Display Background Color ($01) ===
<pre>
(mono) (color)
7 bit 0 7 bit 0
---- ---- ---- ----
.... .sss pppp iiii
||| |||| ||||
+++- Value |||| ++++- Index in palette (0-15)
(0-7) ++++------ Color palette (0-15)
</pre>
{{Anchor|Display Current Line}}
=== Display Current Line ($02 read) ===
The current line being drawn by the display.
Note that lines are sent to the display with a one-line delay. This matters for color palette or shade LUT manipulation; changing these values when <code>current line == 1</code> will actually affect line 0.
{{Anchor|Display Interrupt Line}}
=== Display Interrupt Line ($03) ===
The line to emit an interrupt on.
{{Anchor|Sprite Table Address}}
=== Sprite Table Address ($04) ===
<pre>
7 bit 0
---- ----
..Aa aaaa
|| ||||
|+-++++- Address (bits 9-13)
+------- Address (bit 14) - color only
</pre>
{{Anchor|Sprite Table First}}
=== Sprite Table First ($05) ===
<pre>
7 bit 0
---- ----
.iii iiii
||| ||||
+++-++++- Index of first sprite entry to draw (0-127)
</pre>
{{Anchor|Sprite Table Count}}
=== Sprite Table Count ($06) ===
<pre>
7 bit 0
---- ----
cccc cccc
|||| ||||
++++-++++- Count of sprite entries to draw (1-128)
</pre>
{{Anchor|Screen Address}}
=== Screen Address ($07) ===
<pre>
7 bit 0
---- ----
2222 1111
|||| ||||
|||| |+++- Screen 1 address (bits 11-13)
|||| +---- Screen 1 address (bit 14) - color only
|+++------ Screen 2 address (bits 11-13)
+--------- Screen 2 address (bit 14) - color only
</pre>
{{Anchor|Screen 2 Window}}
=== Screen 2 Window Left ($08) ===
=== Screen 2 Window Top ($09) ===
=== Screen 2 Window Right ($0A) ===
=== Screen 2 Window Bottom ($0B) ===
The X and Y coordinates of the Screen 2 window.
Note that all coordinates are inclusive; for example, for a 200x100 window in the top-left corner, the values should be set as follows:
* Left - 0,
* Top - 0,
* Right - 199,
* Bottom - 99.
{{Anchor|Sprite Window}}
=== Sprite Window Left ($0C) ===
=== Sprite Window Top ($0D) ===
=== Sprite Window Right ($0E) ===
=== Sprite Window Bottom ($0F) ===
The X and Y coordinates of the Sprite window.
Note that all coordinates are inclusive.
{{Anchor|Screen Scroll}}
=== Screen 1 Scroll X ($10) ===
=== Screen 1 Scroll Y ($11) ===
The X and Y coordinates that Screen 1 is scrolled by.
For example, setting Scroll X to 24 and Scroll Y to 8 will omit, in 8x8 tile units, the first three rows and the first two columns of the 32x32 screen.
=== Screen 2 Scroll X ($12) ===
=== Screen 2 Scroll Y ($13) ===
The X and Y coordinates that Screen 2 is scrolled by.
== Palette I/O ports ==
These I/O ports are only used in the monochrome display mode. Color display modes use the memory locations <tt>$FE00</tt> - <tt>$FFFF</tt> to store the color palette.
{{Anchor|LCD Mono Shade LUT}}
=== Mono Shade LUT ($1C, $1D, $1E, $1F) ===
<pre>
$1C $1D $1E $1F
7 bit 0 7 bit 0 7 bit 0 7 bit 0
---- ---- ---- ---- ---- ---- ---- ----
1111 0000 3333 2222 5555 4444 7777 6666
|||| |||| |||| |||| |||| |||| |||| ||||
|||| |||| |||| |||| |||| |||| |||| ++++- Shade for LUT index 6
|||| |||| |||| |||| |||| |||| ++++------ Shade for LUT index 7
|||| |||| |||| |||| |||| ++++------------- Shade for LUT index 4
|||| |||| |||| |||| ++++------------------ Shade for LUT index 5
|||| |||| |||| ++++------------------------- Shade for LUT index 2
|||| |||| ++++------------------------------ Shade for LUT index 3
|||| ++++------------------------------------- Shade for LUT index 0
++++------------------------------------------ Shade for LUT index 1
</pre>
{{Anchor|LCD Mono Palette}}
=== Mono Palette 0..15 ($20, $21 .. $3E, $3F) ===
The monochrome palette is laid out as sixteen words:
<pre>
N+1 N
15 bit 8 7 bit 0
---- ---- ---- ----
.333 .222 .111 .000
||| ||| ||| |||
||| ||| ||| +++- Shade LUT index for color 0
||| ||| ||| (non-writable/always zero for palettes 4-7, 12-15)
||| ||| +++------ Shade LUT index for color 1
||| +++------------ Shade LUT index for color 2
+++----------------- Shade LUT index for color 3
</pre>
== LCD I/O ports ==
{{Anchor|LCD Control}}
=== LCD Control ($14) ===
<pre>
7 bit 0
---- ----
.... ..Ce
||
|+- LCD enable: 0 = sleep, 1 = enabled
+-- Contrast (WSC): 0 = low, 1 = high
</pre>
The enable bit controls whether or not the LCD screen is displaying graphics. When it is cleared, the pixel area acts as if it was powered off, but the segment area continues functioning as normal.
The contrast bit allows enabling a "high contrast" mode: this works by having the LCD drive two lines with data received from the SoC - so the first line of the LCD is driven by the first line from the SoC, then additionally by the second line from the SoC.
TODO: Bits 4-7 are writable, but only on WS and WSC. Their effect is unknown.
{{Anchor|LCD Icon Control}}
=== LCD Icon Control ($15) ===
<pre>
7 bit 0
---- ----
..32 1hvs
|| ||||
|| |||+- Sleep (Star)
|| ||+-- Vertical orientation
|| |+--- Horizontal orientation
|| +---- Etc. 1 (Small circle)
|+------ Etc. 2 (Medium circle)
+------- Etc. 3 (Large circle)
</pre>
== LCD internal I/O ports ==
These I/O ports are not used and most likely not intended for use by commercial games.
{{Anchor|LCD Final Line}}
=== LCD Final Line ($16) ===
The final line preceding line counter restart and the beginning of active display. By default, this is set to 158, which equals 159 total lines per frame.
It is said setting this register to an odd value on SwanCrystal has an adverse effect to the LCD panel,<ref>[http://daifukkat.su/docs/wsman/#REG_LCD_VTOTAL REG_LCD_VTOTAL - WSMan]</ref> but the exact mechanism is unknown. A starting point for research is that an even value, or odd total line count, is needed to balance positive and negative charges on the LCD.<ref>W.A. Steer. "[http://www.techmind.org/lcd/ LCD monitor technology and tests]". Techmind, 2011-12-03. Accessed 2024-11-19.</ref>
{{Anchor|LCD Back Porch Line}}
=== LCD Back Porch Line ($17, WSC only) ===
This port is available on the WonderSwan Color only - not the SwanCrystal!
The final line preceding the vertical back porch; by default, this should be set to 155.
The vertical back porch of the LCD is assumed to be 4 lines by some hardware, including IPS mods, as well as the official "TV Swan" capture device. Given that the first visible line is sent to the LCD on the display's line 1, this should be generally set to <code>LCD Final Line - 3</code>.
Conversely, it is said moving this value closer to vertical blank improves LCD visibility<ref>[http://daifukkat.su/docs/wsman/#REG_LCD_VSYNC REG_LCD_VSYNC - WSMan]</ref>, but the exact mechanism is unknown.
{{Anchor|LCD Line Counter}}
=== LCD Line Counter ($18) ===
This write-only port can be written to in order to change the next line to be drawn on the LCD.
For out of range values (higher than the final line), the LCD panel is not driven, but the line counter continues increasing until it rolls over to <tt>$00</tt>.
{{Anchor|LCD Status}}
=== LCD Latched Icon Status ($1A read) ===
<pre>
7 bit 0
---- ----
..cv vvhl
|| ||||
|| |||+- LCD block disable: 0 = no, 1 = yes
|| ||+-- Headphone icon
|| ||
|| || Volume icons:
|| |+--- - Volume B (medium, high)
|| +---- - Volume A (low, high)
|+------ - Speaker
|
+------- Cartridge icon
</pre>
This port shows the state of latched LCD icons; these are displayed for an additional 128 ticks, counting from the last time they were enabled.
Bit 0 (LCD block disable) reflects the value written to the port.
TODO: This documents the WonderSwan Color. The specifics may work differently on the mono WonderSwan.
=== LCD Latched Icon Control ($1A write) ===
<pre>
7 bit 0
---- ----
..cs ...l
|| |
|| +- LCD block disable: 0 = no, 1 = yes
|| (disables LCD panel, including all segments)
|+------ Latch sound segments
+------- Latch cartridge segment
</pre>
This port allows disabling the full LCD IP block; if bit 0 is set, all LCD panel control (including segments and sound/cartridge segment display timers) is disabled.
This port also allows manually latching the sound/cartridge segment display with their respective timers; however, this can only be done if bit 0 is set. For example, to latch the cartridge segment timer, one can write <tt>$21</tt> to the port to disable the LCD block and latch the cartridge segment. Next, after re-enabling the LCD block by clearing bit 0, the cartridge segment will be shown for 128 vertical blanks.
=== TFT LCD Configuration ($70, $71, $72, $73, $74, $75, $76, $77 SwanCrystal only) ===
These eight bytes are read from internal EEPROM and configure unknown aspects of the console's TFT LCD panel.
They are only writable while the [[Boot ROM]] is unlocked - locking has the side effect of making them read-only.
== Notes ==
<references />
5d70fcbed1a864a3f3b52151094f652ce20a0626
WonderWitch/IL/ProcIL
0
82
589
2025-04-11T18:24:36Z
Asie
351
Created page with "ProcIL is a library used to manage processes on the system. The Freya environment supports up to three concurrent processes at once, of which the first one is typically the operating system. == Functions == === load === <code>void __far* load(const char far *cmdline);</code> Runs the load routine of the program specified on the command line, returning its entrypoint. === run === <code>int run(void far *entrypoint, int argc, const char far * far *argv);</code> Run..."
wikitext
text/x-wiki
ProcIL is a library used to manage processes on the system.
The Freya environment supports up to three concurrent processes at once, of which the first one is typically the operating system.
== Functions ==
=== load ===
<code>void __far* load(const char far *cmdline);</code>
Runs the load routine of the program specified on the command line, returning its entrypoint.
=== run ===
<code>int run(void far *entrypoint, int argc, const char far * far *argv);</code>
Runs the passed entrypoint of the program.
=== exec ===
<code>int exec(const char far *cmdline, int argc, const char far * far *argv);</code>
Combines <tt>load(...)</tt> and <tt>run(...)</tt>.
=== exit ===
<code>void exit(int code);</code>
Exits the program, returning the specified code; finishes with a <tt>$10</tt> interrupt call.
=== yield ===
<code>void yield(void);</code>
=== suspend ===
TODO
=== resume ===
TODO
=== swap ===
TODO
fa00fde68f0f265dcfd91782dce4620acbf193b0
WSdev Wiki
0
1
599
519
2025-04-23T14:03:59Z
Asie
351
/* Reference */
wikitext
text/x-wiki
'''WonderSwan Development Wiki'''
== Reference ==
=== General ===
* [[Memory map]]
* [[I/O port map]]
* [[ROM header|ROM format]]
* [[NEC V30MZ]] - the WonderSwan CPU (80186-compatible)
* [[Timing]]
=== Console components ===
* [[SoC]]
** [[Display]]
*** [[Display/Tile Data|Tile data]]
*** [[Display/Palette|Color palette]]
*** [[Display/Screens|Screen format]]
*** [[Display/Sprites|Sprite format]]
*** [[Display/Windows|Windows]]
*** [[Display/LCD Icons|LCD icons]]
*** [[Display/IO Ports|I/O ports]]
** [[Sound]]
*** [[DMA#Sound_DMA|Sound DMA]]<sup>(color)</sup>
*** [[Hyper Voice]]<sup>(color)</sup>
** [[Keypad]]
** [[Timers]]
** [[Interrupts]]
** [[UART]]
** [[DMA]]<sup>(color)</sup>
* [[Boot ROM]]
* [[EEPROM|Internal EEPROM]]
** [[Splash animation]]<sup>(color)</sup>
=== Cartridge components ===
* [[Cartridge connector]]
* [[Mapper]]
** [[Bandai 2001]]
** [[Bandai 2003]]
** [[KARNAK]]
* Mapper-specific components
** [[EEPROM]] (2001)
** [[Real-Time Clock]] (2003)
* Cartridge-specific components
** [[WonderWitch/Flash|WonderWitch NOR flash]]
** [[Handy Sonar]]
** [[mama Mitte]] (IR transceiver)
** [[Robot Works]] (IR transmitter)
=== Pinouts ===
* [[Cartridge connector#Pinout|Cartridge pinout]]
* [[Accessory port pinout]]
* [[2001 Mapper pinout]]
* [[2003 Mapper pinout]]
* [[KARNAK pinout]]
* [[GIZA pinout]]
* [[S-3511A pinout]]
=== Accessories ===
* [[WonderBeat 9480]] headphone adapter
* [[WonderBorg]] robot
* [[WonderGate]] mobile adapter
* [[WonderWave]] infrared adapter
=== WonderWitch ===
* [[WonderWitch]]
** [[WonderWitch/Flash|NOR flash]]
** [[WonderWitch/Memory map|Memory map]]
** [[WonderWitch/FreyaBIOS|FreyaBIOS]]
** [[WonderWitch/FreyaOS|FreyaOS]]
** [[WonderWitch/Filesystem|File system]]
** [[WonderWitch/Process|Process]]
** [[WonderWitch/IL|Indirect Library (IL)]]
** [[WonderWitch .fx files|.fx file format]]
== Links ==
* [https://wonderful.asie.pl/wiki/doku.php?id=wswan:index#guides Wonderful Toolchain Wiki] - gcc-ia16-based homebrew toolchain guides and documentation
* [https://github.com/WonderfulToolchain/awesome-wsdev awesome-wsdev] - curated documentation/tools/source code link list
== MediaWiki ==
* [https://www.mediawiki.org/wiki/Special:MyLanguage/Help:Contents User's Guide]
* [https://www.mediawiki.org/wiki/Special:MyLanguage/Manual:FAQ MediaWiki FAQ]
* [[:Category:Deletion requests|Deletion requests]]
1d3f959f6c17340bd0182d09e720a5ac9aa91838
Internal EEPROM
0
83
601
2025-04-23T18:38:22Z
Asie
351
Created page with "The internal EEPROM is 128 bytes on the mono model, and 2048 bytes on Color models. It is absent on the Pocket Challenge V2. The first 96 bytes are used for software data, and can be written to even after the protection bit has been enabled. This is intended for transferring save data between cartridges. == Contents == {| class="wikitable" |- ! Offset !! Length !! Contents |- | $00 || 96 || Program data. Can be written by programs even if write protection has been ena..."
wikitext
text/x-wiki
The internal EEPROM is 128 bytes on the mono model, and 2048 bytes on Color models. It is absent on the Pocket Challenge V2.
The first 96 bytes are used for software data, and can be written to even after the protection bit has been enabled. This is intended for transferring save data between cartridges.
== Contents ==
{| class="wikitable"
|-
! Offset !! Length !! Contents
|-
| $00 || 96 || Program data. Can be written by programs even if write protection has been enabled.
|-
| $60 || 16 || Owner name, custom character set.
|-
| $70 || 1 || Owner birthday year, BCD, first/higher two digits
|-
| $71 || 1 || Owner birthday year, BCD, last/lower two digits
|-
| $72 || 1 || Owner birthday month, BCD
|-
| $73 || 1 || Owner birthday day, BCD
|-
| $74 || 1 || Owner gender:<br/>
0 - ?<br/>
1 - Male<br/>
2 - Female
|-
| $75 || 1 || Owner blood type:<br/>
0 - ?<br/>
1 - A<br/>
2 - B<br/>
3 - 0<br/>
4 - AB
|-
| $76 || 1 || Last booted [[ROM header]] byte 6 (developer/publisher ID)
|-
| $77 || 1 || Last booted [[ROM header]] byte 7 (color)
|-
| $78 || 1 || Last booted [[ROM header]] byte 8 (game ID)
|-
| $7C || 1 || Stored cartridge ID/version change counter
|-
| $7D || 1 || Owner name change counter
|-
| $7E || 2 || System startup counter
|-
| $80 || 1 || Last booted [[ROM header]] byte 6 (developer/publisher ID) - only changed if byte 7 (color) != 0
|-
| $81 || 1 || Last booted [[ROM header]] byte 7 (color) - only changed if byte 7 (color) != 0
|-
| $82 || 1 || Last booted [[ROM header]] byte 8 (game ID) - only changed if byte 7 (color) != 0
|-
| $83 || 1 || Color model configuration
|-
| $84 || 1 || Name color
|-
| $85 || ? || [[Splash animation|Custom splash animation]], if present
|}
=== Owner name character set ===
{| class="wikitable"
|-
!
! <code>.0</code>
! <code>.1</code>
! <code>.2</code>
! <code>.3</code>
! <code>.4</code>
! <code>.5</code>
! <code>.6</code>
! <code>.7</code>
! <code>.8</code>
! <code>.9</code>
! <code>.A</code>
! <code>.B</code>
! <code>.C</code>
! <code>.D</code>
! <code>.E</code>
! <code>.F</code>
|-
! <code>0.</code>
| || 0 || 1 || 2 || 3 || 4 || 5 || 6 || 7 || 8 || 9 || A || B || C || D || E
|-
! <code>1.</code>
| F || G || H || I || J || K || L || M || N || O || P || Q || R || S || T || U
|-
! <code>2.</code>
| V || W || X || Y || Z || ♥ || ♪ || + || - || ? || .
!
!
!
!
!
|}
=== Color model configuration ===
<pre>
7 bit 0
---- ----
sc.. ..vv
|| ||
|| ++- Volume level
|+-------- Contrast (WSC): 0 = Low, 1 = High
+--------- Custom splash animation enabled
</pre>
=== Name colors ===
{| class="wikitable"
|-
! Value !! RGB code
|-
| 0 || #000
|-
| 1 || #f00
|-
| 2 || #f70
|-
| 3 || #ff0
|-
| 4 || #7f0
|-
| 5 || #0f0
|-
| 6 || #0f7
|-
| 7 || #0ff
|-
| 8 || #07f
|-
| 9 || #00f
|-
| 10 || #70f
|-
| 11 || #f0f
|-
| 12 || #f07
|-
| 13 || #fff
|}
a154a3282b3c81e83f67358b34505ff40e8213eb
WSdev Wiki
0
1
602
599
2025-04-23T18:38:52Z
Asie
351
/* Console components */
wikitext
text/x-wiki
'''WonderSwan Development Wiki'''
== Reference ==
=== General ===
* [[Memory map]]
* [[I/O port map]]
* [[ROM header|ROM format]]
* [[NEC V30MZ]] - the WonderSwan CPU (80186-compatible)
* [[Timing]]
=== Console components ===
* [[SoC]]
** [[Display]]
*** [[Display/Tile Data|Tile data]]
*** [[Display/Palette|Color palette]]
*** [[Display/Screens|Screen format]]
*** [[Display/Sprites|Sprite format]]
*** [[Display/Windows|Windows]]
*** [[Display/LCD Icons|LCD icons]]
*** [[Display/IO Ports|I/O ports]]
** [[Sound]]
*** [[DMA#Sound_DMA|Sound DMA]]<sup>(color)</sup>
*** [[Hyper Voice]]<sup>(color)</sup>
** [[Keypad]]
** [[Timers]]
** [[Interrupts]]
** [[UART]]
** [[DMA]]<sup>(color)</sup>
* [[Boot ROM]]
* [[Internal EEPROM]]
** [[EEPROM|EEPROM interface]]
** [[Splash animation]]<sup>(color)</sup>
=== Cartridge components ===
* [[Cartridge connector]]
* [[Mapper]]
** [[Bandai 2001]]
** [[Bandai 2003]]
** [[KARNAK]]
* Mapper-specific components
** [[EEPROM]] (2001)
** [[Real-Time Clock]] (2003)
* Cartridge-specific components
** [[WonderWitch/Flash|WonderWitch NOR flash]]
** [[Handy Sonar]]
** [[mama Mitte]] (IR transceiver)
** [[Robot Works]] (IR transmitter)
=== Pinouts ===
* [[Cartridge connector#Pinout|Cartridge pinout]]
* [[Accessory port pinout]]
* [[2001 Mapper pinout]]
* [[2003 Mapper pinout]]
* [[KARNAK pinout]]
* [[GIZA pinout]]
* [[S-3511A pinout]]
=== Accessories ===
* [[WonderBeat 9480]] headphone adapter
* [[WonderBorg]] robot
* [[WonderGate]] mobile adapter
* [[WonderWave]] infrared adapter
=== WonderWitch ===
* [[WonderWitch]]
** [[WonderWitch/Flash|NOR flash]]
** [[WonderWitch/Memory map|Memory map]]
** [[WonderWitch/FreyaBIOS|FreyaBIOS]]
** [[WonderWitch/FreyaOS|FreyaOS]]
** [[WonderWitch/Filesystem|File system]]
** [[WonderWitch/Process|Process]]
** [[WonderWitch/IL|Indirect Library (IL)]]
** [[WonderWitch .fx files|.fx file format]]
== Links ==
* [https://wonderful.asie.pl/wiki/doku.php?id=wswan:index#guides Wonderful Toolchain Wiki] - gcc-ia16-based homebrew toolchain guides and documentation
* [https://github.com/WonderfulToolchain/awesome-wsdev awesome-wsdev] - curated documentation/tools/source code link list
== MediaWiki ==
* [https://www.mediawiki.org/wiki/Special:MyLanguage/Help:Contents User's Guide]
* [https://www.mediawiki.org/wiki/Special:MyLanguage/Manual:FAQ MediaWiki FAQ]
* [[:Category:Deletion requests|Deletion requests]]
c09fc7df46410423d0c7eeeb96460c473b177054
605
602
2025-04-23T18:51:33Z
Asie
351
/* General */
wikitext
text/x-wiki
'''WonderSwan Development Wiki'''
== Reference ==
=== General ===
* [[Memory map]]
* [[I/O port map]]
* [[NEC V30MZ]] - the WonderSwan CPU (80186-compatible)
* [[Timing]]
=== File formats ===
* [[ROM header|ROM images]]
* [[WSR|WSR]]
=== Console components ===
* [[SoC]]
** [[Display]]
*** [[Display/Tile Data|Tile data]]
*** [[Display/Palette|Color palette]]
*** [[Display/Screens|Screen format]]
*** [[Display/Sprites|Sprite format]]
*** [[Display/Windows|Windows]]
*** [[Display/LCD Icons|LCD icons]]
*** [[Display/IO Ports|I/O ports]]
** [[Sound]]
*** [[DMA#Sound_DMA|Sound DMA]]<sup>(color)</sup>
*** [[Hyper Voice]]<sup>(color)</sup>
** [[Keypad]]
** [[Timers]]
** [[Interrupts]]
** [[UART]]
** [[DMA]]<sup>(color)</sup>
* [[Boot ROM]]
* [[Internal EEPROM]]
** [[EEPROM|EEPROM interface]]
** [[Splash animation]]<sup>(color)</sup>
=== Cartridge components ===
* [[Cartridge connector]]
* [[Mapper]]
** [[Bandai 2001]]
** [[Bandai 2003]]
** [[KARNAK]]
* Mapper-specific components
** [[EEPROM]] (2001)
** [[Real-Time Clock]] (2003)
* Cartridge-specific components
** [[WonderWitch/Flash|WonderWitch NOR flash]]
** [[Handy Sonar]]
** [[mama Mitte]] (IR transceiver)
** [[Robot Works]] (IR transmitter)
=== Pinouts ===
* [[Cartridge connector#Pinout|Cartridge pinout]]
* [[Accessory port pinout]]
* [[2001 Mapper pinout]]
* [[2003 Mapper pinout]]
* [[KARNAK pinout]]
* [[GIZA pinout]]
* [[S-3511A pinout]]
=== Accessories ===
* [[WonderBeat 9480]] headphone adapter
* [[WonderBorg]] robot
* [[WonderGate]] mobile adapter
* [[WonderWave]] infrared adapter
=== WonderWitch ===
* [[WonderWitch]]
** [[WonderWitch/Flash|NOR flash]]
** [[WonderWitch/Memory map|Memory map]]
** [[WonderWitch/FreyaBIOS|FreyaBIOS]]
** [[WonderWitch/FreyaOS|FreyaOS]]
** [[WonderWitch/Filesystem|File system]]
** [[WonderWitch/Process|Process]]
** [[WonderWitch/IL|Indirect Library (IL)]]
** [[WonderWitch .fx files|.fx file format]]
== Links ==
* [https://wonderful.asie.pl/wiki/doku.php?id=wswan:index#guides Wonderful Toolchain Wiki] - gcc-ia16-based homebrew toolchain guides and documentation
* [https://github.com/WonderfulToolchain/awesome-wsdev awesome-wsdev] - curated documentation/tools/source code link list
== MediaWiki ==
* [https://www.mediawiki.org/wiki/Special:MyLanguage/Help:Contents User's Guide]
* [https://www.mediawiki.org/wiki/Special:MyLanguage/Manual:FAQ MediaWiki FAQ]
* [[:Category:Deletion requests|Deletion requests]]
c23ff6cc211c432f1a9ec162eb0d4f0f527f9ef2
EEPROM
0
35
603
575
2025-04-23T18:42:48Z
Asie
351
wikitext
text/x-wiki
The WonderSwan utilizes M93LCx6-compatible EEPROMs:
* in the SoC:
** 1 Kbit internal EEPROM (M93LC46-compatible) on the WonderSwan,
** 16 Kbit internal EEPROM (M93LC86-compatible) on the WonderSwan Color,
* on cartridges:
** 1 Kbit cartridge EEPROM (M93LC46-compatible)
** 8 Kbit cartridge EEPROM (M93LC76-compatible)
** 16 Kbit cartridge EEPROM (M93LC86-compatible)
Additional variants exists which were not seen on any production cartridge:
* 256 bit EEPROM (M93LC06-compatible)
* 2 Kbit EEPROM (M93LC56-compatible)
* 4 Kbit EEPROM (M93LC66-compatible)
== Commands ==
=== READ - Read Word ===
The READ command takes an address of a word (address 0 => bytes 0, 1; address 1 => bytes 2, 3; ...) and returns the word at that address.
=== WRITE - Write Word ===
The WRITE command takes an address of a word (address 0 => bytes 0, 1; address 1 => bytes 2, 3; ...) and the word to write to it, then writes the word.
=== ERASE - Erase Word ===
The ERASE command takes an address of a word (address 0 => bytes 0, 1; address 1 => bytes 2, 3; ...) and erases the word at that address, setting it to 0xFFFF.
=== WDS - Write Disable ===
The WDS command prevents issued write and erase commands from having an effect on the EEPROM.
=== WRAL - Write All ===
The WRAL command erases the word at all address of the EEPROM, setting them to 0xFFFF.
This command is not guaranteed to be present on all EEPROMs.
=== ERAL - Erase All ===
The WRAL command takes a word and writes it to all addresses of the EEPROM.
This command is not guaranteed to be present on all EEPROMs.
=== WEN - Write Enable ===
The WEN command restores the effect of issued write and erase commands on the EEPROM disabled using WDS.
== I/O ports ==
The I/O ports listed refer to the internal EEPROM; for the cartridge EEPROM port numbers, refer to the [[Bandai 2001|mapper documentation]].
It is recommended to only access the data and command ports with aligned word reads/writes; see the ''Errata'' section for more information.
{{Anchor|Internal EEPROM Data}}
=== Internal EEPROM Data ($BA, $BB read) ===
{{Anchor|Cartridge EEPROM Data}}
=== Cartridge EEPROM Data ($C4, $C5 read) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
dddd dddd dddd dddd
|||| |||| |||| ||||
++++-++++--++++-++++- Data read from the EEPROM.
</pre>
The read buffer's value changes only once the Read command is completed.
=== Internal EEPROM Data ($BA, $BB write) ===
=== Cartridge EEPROM Data ($C4, $C5 write) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
dddd dddd dddd dddd
|||| |||| |||| ||||
++++-++++--++++-++++- Data to write to the EEPROM.
</pre>
The write buffer is latched when a Write command is initiated; further writes to it do not affect the value written by that specific command.
The two EEPROM data buffers are not shared; neither writes to the write buffer nor the execution of non-read commands affect the contents of the read buffer.
{{Anchor|Internal EEPROM Command}}
=== Internal EEPROM Command ($BC, $BD) ===
{{Anchor|Cartridge EEPROM Command}}
=== Cartridge EEPROM Command ($C6, $C7) ===
<pre>
Command Pattern 1
15 bit 8 7 bit 0
---- ---- ---- ----
0000 0001 ooaa aaaa (¼, 1 Kbit - M93LC06/46)
0000 01oo aaaa aaaa (2, 4 Kbit - M93LC56/66)
0001 ooaa aaaa aaaa (8, 16 Kbit - M93LC76/86)
|||| |||| ||||
||++--++++-++++- Address (MSb .. LSb)
++-------------- Opcode:
01 - WRITE
10 - READ
11 - ERASE
</pre>
<pre>
Command Pattern 2
15 bit 8 7 bit 0
---- ---- ---- ----
0000 0001 00ss .... (¼, 1 Kbit - M93LC06/46)
0000 0100 ss.. .... (2, 4 Kbit - M93LC56/66)
0001 00ss .... .... (8, 16 Kbit - M93LC76/86)
||||
||++------------ Sub-Opcode:
|| 00 - WDS
|| 01 - WRAL
|| 10 - ERAL
|| 11 - WEN
++-------------- Opcode:
00
</pre>
The value written to this port can be read back; it is not affected by ''EEPROM Control''.
{{Anchor|Internal EEPROM Control}}
=== Internal EEPROM Control ($BE, $BF write) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
.... .... PSWR ....
||||
|||+------ Read operation: 1 for READ command, 0 otherwise
||+------- Write operation: 1 for WRITE and WRAL command, 0 otherwise
|+-------- Short operation: 1 for ERASE, WDS, ERAL and WEN command, 0 otherwise
+--------- Protection: 1 to enable internal EEPROM write protection.
Cannot be cleared once set.
</pre>
* Read operation: Sends 16 bits from Command, then reads 16 bits to Data.
* Write operation: Sends 16 bits from Command, then 16 bits from Data. De-asserts Microwire chip select, then re-asserts it and waits for the EEPROM to confirm command completion.
* Short operation: Sends 16 bits from Command, de-asserts Microwire chip select.
* Protection: Enables internal EEPROM write protection (addresses >= 0x30, or anything after the first 96 bytes, can no longer be written to).
If more than one of the Read, Write, Short, Protect bits are set, the operation is treated as invalid (all four operation bits are cleared and no communication is done with the EEPROM). Notably, this means that writing, for example, 0x90 does not protect the internal EEPROM if it wasn't already protected, but writing 0x80 does.
The command requested here should match the command sent to the EEPROM in port ''$BC''.
{{Anchor|Cartridge EEPROM Control}}
=== Cartridge EEPROM Control ($C8, $C9 write) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
.... .... ASWR ....
||||
|||+------ Read operation: 1 for READ command, 0 otherwise
||+------- Write operation: 1 for WRITE and WRAL command, 0 otherwise
|+-------- Short operation: 1 for ERASE, WDS, ERAL and WEN command, 0 otherwise
+--------- Abort operation
</pre>
* Read operation: Sends 16 bits from Command, then reads 16 bits to Data.
* Write operation: Sends 16 bits from Command, then 16 bits from Data. De-asserts Microwire chip select, then re-asserts it and waits for the EEPROM to confirm command completion.
* Short operation: Sends 16 bits from Command, de-asserts Microwire chip select.
If more than one of the Read, Write, Short bits are set, or if the Abort bit is set, the operation is treated as invalid (all four operation bits are cleared and no communication is done with the EEPROM).
{{Anchor|Internal EEPROM Status}}
=== Internal EEPROM Status ($BE, $BF read) ===
{{Anchor|Cartridge EEPROM Status}}
=== Cartridge EEPROM Status ($C8, $C9 read) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
.... .... P... ..rd
| ||
| |+- 0 after a Read command is initiated,
| | 1 once a Read command is completed.
| | Unaffected by Write/Erase commands.
| +-- 0 if the EEPROM is busy,
| 1 if a command can be accepted (idle).
+--------- Internal EEPROM write protection:
0 = disabled, 1 = enabled
</pre>
== Hardware notes ==
EEPROM command bits are shifted out starting from the ''most'' significant bit of the port.
<pre>
+----> EEPROM Serial Data
|
[0] <= [0000 0001 ooaa aaaa]
EEPROM Command Port
</pre>
While the M93LCx6 family supports byte organization, the WonderSwan always uses word organization. As such, this implementation detail is omitted in this documentation.
The SPHINX SoC family emulates a 93C46 in ASWAN compatibility mode by manipulating the shifted out command value when sending it to the EEPROM (TODO: How exactly?).
== Errata ==
=== Cartridge: Buggy Done bit ===
On the cartridge implementation in the 2001 mapper, the EEPROM "done" bit is buggy and doesn't have useful information. It's set when a Read completes, but is only cleared when a Command or Write is started. (To be useful it would need to also be cleared when a Read is started.)
=== Internal: Non-word access on ASWAN ===
On the ASWAN SoC, accessing the internal EEPROM command ports as bytes only works correctly for even addresses. For odd addresses, these accesses return open bus; this means that unaligned word accesses also don't work, as they are converted to one odd and one even byte access internally.
It is recommended to only use aligned word port accesses to talk to the internal EEPROM.
This issue is not present on the SPHINX and newer SoCs, including in "mono" emulation mode. It is also not present on the cartridge impelmentation in the 2001 mapper.
== Links ==
* [https://www.st.com/resource/en/datasheet/m93c46-w.pdf STMicroelectronics M93LCx6 datasheet]
ca62018f72b26d6efe11a190e9f973b037782a52
Bandai 2001
0
12
604
571
2025-04-23T18:44:07Z
Asie
351
wikitext
text/x-wiki
The Bandai 2001 (LUXSOR) is one of the two mappers used in WonderSwan cartridges.
In addition to the normal [[Mapper]] banking interface, the 2001 adds three registers for interacting with a Microwire [[EEPROM]] which may optionally be present on the cartridge board:
{| class="wikitable"
! Category
! Port
! Description
! Bits
! Type
! Notes
|-
! rowspan="5" | External EEPROM
! rowspan="2" | $C4
| rowspan="2" | [[EEPROM#Cartridge EEPROM Data|External EEPROM Data]]
| rowspan="2" style="text-align: right" | <tt style="white-space: nowrap">dddd dddd dddd dddd</tt>
| R16
| Data read (d)
|-
| W16
| Data to write (d)
|-
! $C6
| [[EEPROM#Cartridge EEPROM Command|External EEPROM Command]]
| style="text-align: right" | <tt style="white-space: nowrap">0001 CCaa aaaa aaaa</tt><br/>or <tt style="white-space: nowrap">0000 01CC aaaa aaaa</tt><br/> or <tt style="white-space: nowrap">0000 0001 CCaa aaaa</tt>
| RW16
| Command and address
|-
! rowspan=2|$C8
| [[EEPROM#Cartridge EEPROM Control|External EEPROM Control]]
| style="text-align: right" | <tt style="white-space: nowrap">ASWR ....</tt>
| W8
| Abort (A), Short (S), Write (W), Read (R)
|-
| [[EEPROM#Cartridge EEPROM Status|External EEPROM Status]]
| style="text-align: right" | <tt style="white-space: nowrap">.... ..rd</tt>
| R8
| Ready (r), Done (d)
|-
|}
1c48f389f97ae1e82f6ea47b0ee18a4b0a11400f
ROM header
0
5
606
600
2025-04-23T18:52:25Z
Asie
351
wikitext
text/x-wiki
The file extensions used to mark WS cartridge files are typically:
* ''.ws'' - "mono" WonderSwan,
* ''.wsc'' - WonderSwan Color,
* ''.pc2'' - Pocket Challenge V2.
== ROM header ==
Every WonderSwan cartridge ROM contains a header.
The header is stored at the end (the final sixteen bytes) of the ROM image. For this reason, it is also sometimes called a "footer".
A notable consequence of this is that, unlike most other platforms, non-power-of-two ROM images are expected to be padded to the last bank downwards, rather than the first bank upwards; for example, a 768 KiB ROM image will be padded to 1 MiB by appending 256 KiB of padding data to the ''beginning'', rather than the ''end'' of the ROM.
Parts of this header are validated or otherwise used by the console's [[boot ROM]] - they are marked in '''bold'''.
{| class="wikitable"
|+ Header contents
|-
! Offset !! Length !! Contents
|-
| '''$0''' || '''5''' || Far jump instruction: '''0xEA''', offset, segment.
|-
| '''$5''' || '''1''' || '''Maintenance'''
|-
| $6 || 1 || Developer/Publisher ID
|-
| $7 || 1 || Color
|-
| $8 || 1 || Game ID (binary-coded decimal)
|-
| '''$9''' || '''1''' || '''Game version? / Safe mode'''
|-
| $A || 1 || ROM size
|-
| $B || 1 || Save type/size
|-
| '''$C''' || '''1''' || '''Flags'''
|-
| $D || 1 || Mapper
|-
| $E || 2 || Checksum (sum of all ROM bytes excluding the checksum)
|}
=== Maintenance ($5) ===
----
<pre>
7 bit 0
---- ----
s... 0000
| ||||
| ++++- Must be zero; otherwise the console will prohibit execution.
| Purpose unknown.
+--------- (Color) Splash bypass: 0 = Disable, 1 = Enable.
Bypasses the custom boot splash stored in the console's
internal EEPROM; presumably used for bricked console recovery.
</pre>
=== Developer/Publisher ID ($6) ===
----
{| class="wikitable"
|+ Known official developer/publisher IDs
|-
! ID !! Publisher code !! Publisher
|-
| $01 || BAN || Bandai
|-
| $02 || TAT || Taito
|-
| $03 || TMY || Tomy
|-
| $04 || KEX || Koei
|-
| $05 || DTE || Data East
|-
| $06 || AAE || Asmik Ace
|-
| $07 || MDE || Media Entertainment
|-
| $08 || NHB || Nichibutsu
|-
| $0A || CCJ || Coconuts Japan
|-
| $0B || SUM || Sammy
|-
| $0C || SUN || Sunsoft
|-
| $0D || PAW || Mebius
|-
| $0E || BPR || Banpresto
|-
| $10 || JLC || Jaleco
|-
| $11 || MGA || Imagineer
|-
| $12 || KNM || Konami
|-
| $16 || KBS || Kobunsha
|-
| $17 || BTM || Bottom Up
|-
| $18 || KGT || Kaga Tech
|-
| $19 || SRV || Sunrise
|-
| $1A || CFT || Cyber Front
|-
| $1B || MGH || Megahouse
|-
| $1D || BEC || Interbec
|-
| $1E || NAP || Nihon Application
|-
| $1F || BVL || Bandai Visual
|-
| $20 || ATN || Athena
|-
| $21 || KDX || KID
|-
| $22 || HAL || HAL Corporation
|-
| $23 || YKE || Yuki Enterprise
|-
| $24 || OMN || Omega Micott
|-
| $25 || LAY || Layup
|-
| $26 || KDK || Kadokawa Shoten
|-
| $27 || SHL || Shall Luck
|-
| $28 || SQR || Squaresoft
|-
| $2A || SCC || ? (SUNCORPORATION?)
|-
| $2B || TMC || Tom Create
|-
| $2D || NMC || Namco
|-
| $2E || SES || Soeishinsha
|-
| $2F || HTR || Hearty Robin
|-
| $31 || VGD || Vanguard
|-
| $32 || MGT || Megatron
|-
| $33 || WIZ || Wiz
|-
| $35 || TAN || Tanita
|-
| $36 || CPC || Capcom
|}
Note that IDs $00 and $01 are used across a variety of commercial games. Homebrew is known to use arbitrary values in this field.
=== Color ($7) ===
----
<pre>
7 bit 0
---- ----
???? ???c
|
+- 0 = Monochrome only, 1 = Supports Color mode.
</pre>
=== Game version? / Safe mode ($9) ===
----
<pre>
7 bit 0
---- ----
pvvv vvvv
|||| ||||
|+++ ++++- Game version?
+--------- Internal EEPROM write protect: 0 = Enable, 1 = Disable.
This prohibits writing to the internal EEPROM for addresses
0x60 and above (user settings, custom splash screen).
Games are expected to enable write protection; however, the
WonderWitch is factory configured with it disabled.
</pre>
=== ROM size ($A) ===
----
Unofficial/inferred ROM size values are marked in ''italic''.
{| class="wikitable"
|+ ROM size values
|-
! ID !! Size
|-
| ''$00'' || ''1 Mbit (128 KiB)''
|-
| ''$01'' || ''2 Mbit (256 KiB)''
|-
| $02 || 4 Mbit (512 KiB)
|-
| $03 || 8 Mbit (1 MiB)
|-
| $04 || 16 Mbit (2 MiB)
|-
| ''$05'' || ''24 Mbit (3 MiB)''
|-
| $06 || 32 Mbit (4 MiB)
|-
| ''$07'' || ''48 Mbit (6 MiB)''
|-
| $08 || 64 Mbit (8 MiB)
|-
| $09 || 128 Mbit (16 MiB)
|-
| ''$0A'' || ''256 Mbit (32 MiB)''
|-
| ''$0B'' || ''512 Mbit (64 MiB)''
|}
Note that ROM sizes over 16 MiB are not supported by the [[Bandai 2001]] mapper. The [[Bandai 2003]] mapper is limited to 64 MiB.
=== Save type/size ($B) ===
----
{| class="wikitable"
|+ Save type values
|-
! ID !! Type !! Size
|-
| $00 || colspan="2" style="text-align:center;" | None
|-
| $01 || rowspan="5" | SRAM || rowspan="2" | 256 Kbit (32 KiB)
|-
| $02
|-
| $03 || 1 Mbit (128 KiB)
|-
| $04 || 2 Mbit (256 KiB)
|-
| $05 || 4 Mbit (512 KiB)
|-
| $10 || rowspan="3" | EEPROM || 1 Kbit (128 B)
|-
| $20 || 16 Kbit (2 KiB)
|-
| $50 || 8 Kbit (1 KiB)
|}
Note that while ID <code>$01</code> is commonly documented as <code>64 Kbit</code>, all known cartridges using that value come with <code>256 Kbit</code> SRAM chips. This requires further investigation.
=== Flags ($C) ===
----
<pre>
7 bit 0
---- ----
???? SB?v
|| |
|| +- Starting orientation: 0 = horizontal, 1 = vertical
|+--- Cartridge ROM width: 0 = 8-bit, 1 = 16-bit
+---- Cartridge ROM wait state: 0 = +0 cycles, 1 = +1
</pre>
Flag bits 2 and 3 correspond to [[SoC#System Control|System Control]] bits 2 and 3.
Bit 0 controls the splash screen's orientation, as well as the LCD segment (horizontal or vertical orientation) displayed during the first 128 ticks of the splash screen.
=== Mapper ($D) ===
----
{| class="wikitable"
|+ Known mapper types
|-
! ID !! Mapper
|-
| $00 || [[Bandai 2001]] or [[KARNAK]]
|-
| $01 || [[Bandai 2003]]
|}
dac0f384a2e4398bd89b202296b972614de82923
607
606
2025-04-23T18:52:40Z
Asie
351
wikitext
text/x-wiki
The file extensions used to mark WS cartridge files are typically:
* <tt>.ws</tt> - "mono" WonderSwan,
* <tt>.wsc</tt> - WonderSwan Color,
* <tt>.pc2</tt> - Pocket Challenge V2.
== ROM header ==
Every WonderSwan cartridge ROM contains a header.
The header is stored at the end (the final sixteen bytes) of the ROM image. For this reason, it is also sometimes called a "footer".
A notable consequence of this is that, unlike most other platforms, non-power-of-two ROM images are expected to be padded to the last bank downwards, rather than the first bank upwards; for example, a 768 KiB ROM image will be padded to 1 MiB by appending 256 KiB of padding data to the ''beginning'', rather than the ''end'' of the ROM.
Parts of this header are validated or otherwise used by the console's [[boot ROM]] - they are marked in '''bold'''.
{| class="wikitable"
|+ Header contents
|-
! Offset !! Length !! Contents
|-
| '''$0''' || '''5''' || Far jump instruction: '''0xEA''', offset, segment.
|-
| '''$5''' || '''1''' || '''Maintenance'''
|-
| $6 || 1 || Developer/Publisher ID
|-
| $7 || 1 || Color
|-
| $8 || 1 || Game ID (binary-coded decimal)
|-
| '''$9''' || '''1''' || '''Game version? / Safe mode'''
|-
| $A || 1 || ROM size
|-
| $B || 1 || Save type/size
|-
| '''$C''' || '''1''' || '''Flags'''
|-
| $D || 1 || Mapper
|-
| $E || 2 || Checksum (sum of all ROM bytes excluding the checksum)
|}
=== Maintenance ($5) ===
----
<pre>
7 bit 0
---- ----
s... 0000
| ||||
| ++++- Must be zero; otherwise the console will prohibit execution.
| Purpose unknown.
+--------- (Color) Splash bypass: 0 = Disable, 1 = Enable.
Bypasses the custom boot splash stored in the console's
internal EEPROM; presumably used for bricked console recovery.
</pre>
=== Developer/Publisher ID ($6) ===
----
{| class="wikitable"
|+ Known official developer/publisher IDs
|-
! ID !! Publisher code !! Publisher
|-
| $01 || BAN || Bandai
|-
| $02 || TAT || Taito
|-
| $03 || TMY || Tomy
|-
| $04 || KEX || Koei
|-
| $05 || DTE || Data East
|-
| $06 || AAE || Asmik Ace
|-
| $07 || MDE || Media Entertainment
|-
| $08 || NHB || Nichibutsu
|-
| $0A || CCJ || Coconuts Japan
|-
| $0B || SUM || Sammy
|-
| $0C || SUN || Sunsoft
|-
| $0D || PAW || Mebius
|-
| $0E || BPR || Banpresto
|-
| $10 || JLC || Jaleco
|-
| $11 || MGA || Imagineer
|-
| $12 || KNM || Konami
|-
| $16 || KBS || Kobunsha
|-
| $17 || BTM || Bottom Up
|-
| $18 || KGT || Kaga Tech
|-
| $19 || SRV || Sunrise
|-
| $1A || CFT || Cyber Front
|-
| $1B || MGH || Megahouse
|-
| $1D || BEC || Interbec
|-
| $1E || NAP || Nihon Application
|-
| $1F || BVL || Bandai Visual
|-
| $20 || ATN || Athena
|-
| $21 || KDX || KID
|-
| $22 || HAL || HAL Corporation
|-
| $23 || YKE || Yuki Enterprise
|-
| $24 || OMN || Omega Micott
|-
| $25 || LAY || Layup
|-
| $26 || KDK || Kadokawa Shoten
|-
| $27 || SHL || Shall Luck
|-
| $28 || SQR || Squaresoft
|-
| $2A || SCC || ? (SUNCORPORATION?)
|-
| $2B || TMC || Tom Create
|-
| $2D || NMC || Namco
|-
| $2E || SES || Soeishinsha
|-
| $2F || HTR || Hearty Robin
|-
| $31 || VGD || Vanguard
|-
| $32 || MGT || Megatron
|-
| $33 || WIZ || Wiz
|-
| $35 || TAN || Tanita
|-
| $36 || CPC || Capcom
|}
Note that IDs $00 and $01 are used across a variety of commercial games. Homebrew is known to use arbitrary values in this field.
=== Color ($7) ===
----
<pre>
7 bit 0
---- ----
???? ???c
|
+- 0 = Monochrome only, 1 = Supports Color mode.
</pre>
=== Game version? / Safe mode ($9) ===
----
<pre>
7 bit 0
---- ----
pvvv vvvv
|||| ||||
|+++ ++++- Game version?
+--------- Internal EEPROM write protect: 0 = Enable, 1 = Disable.
This prohibits writing to the internal EEPROM for addresses
0x60 and above (user settings, custom splash screen).
Games are expected to enable write protection; however, the
WonderWitch is factory configured with it disabled.
</pre>
=== ROM size ($A) ===
----
Unofficial/inferred ROM size values are marked in ''italic''.
{| class="wikitable"
|+ ROM size values
|-
! ID !! Size
|-
| ''$00'' || ''1 Mbit (128 KiB)''
|-
| ''$01'' || ''2 Mbit (256 KiB)''
|-
| $02 || 4 Mbit (512 KiB)
|-
| $03 || 8 Mbit (1 MiB)
|-
| $04 || 16 Mbit (2 MiB)
|-
| ''$05'' || ''24 Mbit (3 MiB)''
|-
| $06 || 32 Mbit (4 MiB)
|-
| ''$07'' || ''48 Mbit (6 MiB)''
|-
| $08 || 64 Mbit (8 MiB)
|-
| $09 || 128 Mbit (16 MiB)
|-
| ''$0A'' || ''256 Mbit (32 MiB)''
|-
| ''$0B'' || ''512 Mbit (64 MiB)''
|}
Note that ROM sizes over 16 MiB are not supported by the [[Bandai 2001]] mapper. The [[Bandai 2003]] mapper is limited to 64 MiB.
=== Save type/size ($B) ===
----
{| class="wikitable"
|+ Save type values
|-
! ID !! Type !! Size
|-
| $00 || colspan="2" style="text-align:center;" | None
|-
| $01 || rowspan="5" | SRAM || rowspan="2" | 256 Kbit (32 KiB)
|-
| $02
|-
| $03 || 1 Mbit (128 KiB)
|-
| $04 || 2 Mbit (256 KiB)
|-
| $05 || 4 Mbit (512 KiB)
|-
| $10 || rowspan="3" | EEPROM || 1 Kbit (128 B)
|-
| $20 || 16 Kbit (2 KiB)
|-
| $50 || 8 Kbit (1 KiB)
|}
Note that while ID <code>$01</code> is commonly documented as <code>64 Kbit</code>, all known cartridges using that value come with <code>256 Kbit</code> SRAM chips. This requires further investigation.
=== Flags ($C) ===
----
<pre>
7 bit 0
---- ----
???? SB?v
|| |
|| +- Starting orientation: 0 = horizontal, 1 = vertical
|+--- Cartridge ROM width: 0 = 8-bit, 1 = 16-bit
+---- Cartridge ROM wait state: 0 = +0 cycles, 1 = +1
</pre>
Flag bits 2 and 3 correspond to [[SoC#System Control|System Control]] bits 2 and 3.
Bit 0 controls the splash screen's orientation, as well as the LCD segment (horizontal or vertical orientation) displayed during the first 128 ticks of the splash screen.
=== Mapper ($D) ===
----
{| class="wikitable"
|+ Known mapper types
|-
! ID !! Mapper
|-
| $00 || [[Bandai 2001]] or [[KARNAK]]
|-
| $01 || [[Bandai 2003]]
|}
1a64a91ef75b58d5cf8ae838e960260e71585760
610
607
2025-04-26T16:09:45Z
Asie
351
wikitext
text/x-wiki
The file extensions used to mark WS cartridge files are typically:
* <tt>.ws</tt> - "mono" WonderSwan,
* <tt>.wsc</tt> - WonderSwan Color,
* <tt>.pc2</tt> - Pocket Challenge V2.
== ROM header ==
Every WonderSwan cartridge ROM contains a header.
The header is stored at the end (the final sixteen bytes) of the ROM image. For this reason, it is also sometimes called a "footer".
A notable consequence of this is that, unlike most other platforms, non-power-of-two ROM images are expected to be padded to the last bank downwards, rather than the first bank upwards; for example, a 768 KiB ROM image will be padded to 1 MiB by appending 256 KiB of padding data to the ''beginning'', rather than the ''end'' of the ROM.
Parts of this header are validated or otherwise used by the [[boot ROM]] on Color models - they are marked in '''bold'''.
{| class="wikitable"
|+ Header contents
|-
! Offset !! Length !! Contents
|-
| '''$0''' || '''5''' || Far jump instruction: '''0xEA''', offset, segment.
|-
| '''$5''' || '''1''' || '''Maintenance'''
|-
| $6 || 1 || Developer/Publisher ID
|-
| $7 || 1 || Color
|-
| $8 || 1 || Game ID (binary-coded decimal)
|-
| '''$9''' || '''1''' || '''Game version? / Safe mode'''
|-
| $A || 1 || ROM size
|-
| $B || 1 || Save type/size
|-
| '''$C''' || '''1''' || '''Flags'''
|-
| '''$D''' || '''1''' || '''Mapper'''
|-
| $E || 2 || Checksum (sum of all ROM bytes excluding the checksum)
|}
=== Maintenance ($5) ===
----
<pre>
7 bit 0
---- ----
s... 0000
| ||||
| ++++- Must be zero; otherwise the console will prohibit execution.
| Purpose unknown.
+--------- (Color) Splash bypass: 0 = Disable, 1 = Enable.
Bypasses the custom boot splash stored in the console's
internal EEPROM; presumably used for bricked console recovery.
</pre>
=== Developer/Publisher ID ($6) ===
----
{| class="wikitable"
|+ Known official developer/publisher IDs
|-
! ID !! Publisher code !! Publisher
|-
| $01 || BAN || Bandai
|-
| $02 || TAT || Taito
|-
| $03 || TMY || Tomy
|-
| $04 || KEX || Koei
|-
| $05 || DTE || Data East
|-
| $06 || AAE || Asmik Ace
|-
| $07 || MDE || Media Entertainment
|-
| $08 || NHB || Nichibutsu
|-
| $0A || CCJ || Coconuts Japan
|-
| $0B || SUM || Sammy
|-
| $0C || SUN || Sunsoft
|-
| $0D || PAW || Mebius
|-
| $0E || BPR || Banpresto
|-
| $10 || JLC || Jaleco
|-
| $11 || MGA || Imagineer
|-
| $12 || KNM || Konami
|-
| $16 || KBS || Kobunsha
|-
| $17 || BTM || Bottom Up
|-
| $18 || KGT || Kaga Tech
|-
| $19 || SRV || Sunrise
|-
| $1A || CFT || Cyber Front
|-
| $1B || MGH || Megahouse
|-
| $1D || BEC || Interbec
|-
| $1E || NAP || Nihon Application
|-
| $1F || BVL || Bandai Visual
|-
| $20 || ATN || Athena
|-
| $21 || KDX || KID
|-
| $22 || HAL || HAL Corporation
|-
| $23 || YKE || Yuki Enterprise
|-
| $24 || OMN || Omega Micott
|-
| $25 || LAY || Layup
|-
| $26 || KDK || Kadokawa Shoten
|-
| $27 || SHL || Shall Luck
|-
| $28 || SQR || Squaresoft
|-
| $2A || SCC || ? (SUNCORPORATION?)
|-
| $2B || TMC || Tom Create
|-
| $2D || NMC || Namco
|-
| $2E || SES || Soeishinsha
|-
| $2F || HTR || Hearty Robin
|-
| $31 || VGD || Vanguard
|-
| $32 || MGT || Megatron
|-
| $33 || WIZ || Wiz
|-
| $35 || TAN || Tanita
|-
| $36 || CPC || Capcom
|}
Note that IDs $00 and $01 are used across a variety of commercial games. Homebrew is known to use arbitrary values in this field.
=== Color ($7) ===
----
<pre>
7 bit 0
---- ----
???? ???c
|
+- 0 = Monochrome only, 1 = Supports Color mode.
</pre>
=== Game version? / Safe mode ($9) ===
----
<pre>
7 bit 0
---- ----
pvvv vvvv
|||| ||||
|+++ ++++- Game version?
+--------- Internal EEPROM write protect: 0 = Enable, 1 = Disable.
This prohibits writing to the internal EEPROM for addresses
0x60 and above (user settings, custom splash screen).
Games are expected to enable write protection; however, the
WonderWitch is factory configured with it disabled.
</pre>
=== ROM size ($A) ===
----
Unofficial/inferred ROM size values are marked in ''italic''.
{| class="wikitable"
|+ ROM size values
|-
! ID !! Size
|-
| ''$00'' || ''1 Mbit (128 KiB)''
|-
| ''$01'' || ''2 Mbit (256 KiB)''
|-
| $02 || 4 Mbit (512 KiB)
|-
| $03 || 8 Mbit (1 MiB)
|-
| $04 || 16 Mbit (2 MiB)
|-
| ''$05'' || ''24 Mbit (3 MiB)''
|-
| $06 || 32 Mbit (4 MiB)
|-
| ''$07'' || ''48 Mbit (6 MiB)''
|-
| $08 || 64 Mbit (8 MiB)
|-
| $09 || 128 Mbit (16 MiB)
|-
| ''$0A'' || ''256 Mbit (32 MiB)''
|-
| ''$0B'' || ''512 Mbit (64 MiB)''
|}
Note that ROM sizes over 16 MiB are not supported by the [[Bandai 2001]] mapper. The [[Bandai 2003]] mapper is limited to 64 MiB.
=== Save type/size ($B) ===
----
{| class="wikitable"
|+ Save type values
|-
! ID !! Type !! Size
|-
| $00 || colspan="2" style="text-align:center;" | None
|-
| $01 || rowspan="5" | SRAM || rowspan="2" | 256 Kbit (32 KiB)
|-
| $02
|-
| $03 || 1 Mbit (128 KiB)
|-
| $04 || 2 Mbit (256 KiB)
|-
| $05 || 4 Mbit (512 KiB)
|-
| $10 || rowspan="3" | EEPROM || 1 Kbit (128 B)
|-
| $20 || 16 Kbit (2 KiB)
|-
| $50 || 8 Kbit (1 KiB)
|}
Note that while ID <code>$01</code> is commonly documented as <code>64 Kbit</code>, all known cartridges using that value come with <code>256 Kbit</code> SRAM chips. This requires further investigation.
=== Flags ($C) ===
----
<pre>
7 bit 0
---- ----
???? SB?v
|| |
|| +- Starting orientation: 0 = horizontal, 1 = vertical
|+--- Cartridge ROM width: 0 = 8-bit, 1 = 16-bit
+---- Cartridge ROM wait state: 0 = +0 cycles, 1 = +1
</pre>
Flag bits 2 and 3 correspond to [[SoC#System Control|System Control]] bits 2 and 3.
Bit 0 controls the splash screen's orientation, as well as the LCD segment (horizontal or vertical orientation) displayed during the first 128 ticks of the splash screen.
=== Mapper ($D) ===
----
<pre>
7 bit 0
---- ----
0000 mmmm
|||| ||||
|||| ++++- Mapper type; see below.
++++------ Must be zero; otherwise the console will prohibit execution.
</pre>
{| class="wikitable"
|+ Known mapper types
|-
! ID !! Mapper
|-
| $00 || [[Bandai 2001]] or [[KARNAK]]
|-
| $01 || [[Bandai 2003]]
|}
58314ca6a4fd8dd5fdcc9f225da64b66a0dd6fad
WSR
0
84
608
2025-04-23T18:56:57Z
Asie
351
Created page with "The WSR file format is used for storing music routines from WonderSwan software, not unlike the NSF format. It was initally defined and implemented by the <tt>in_wsr</tt> Winamp plugin. Its format is based on the [[ROM header]] format, with files expected to be a multiple of 64 KiB in size. However, the footer at the end of the file is 32 bytes long, not 16: {| class="wikitable" |+ Header contents |- ! Offset !! Length !! Contents |- | $00 || 4 || Magic string: <tt>WSR..."
wikitext
text/x-wiki
The WSR file format is used for storing music routines from WonderSwan software, not unlike the NSF format. It was initally defined and implemented by the <tt>in_wsr</tt> Winamp plugin.
Its format is based on the [[ROM header]] format, with files expected to be a multiple of 64 KiB in size. However, the footer at the end of the file is 32 bytes long, not 16:
{| class="wikitable"
|+ Header contents
|-
! Offset !! Length !! Contents
|-
| $00 || 4 || Magic string: <tt>WSRF</tt>
|-
| $04 || 1 || Version number; currently <tt>$00</tt>
|-
| $05 || 1 || Starting song number
|-
| $06 || 10 || Reserved
|-
| $10 || 16 || [[ROM header]]
|}
The <tt>JMP</tt> instruction in the ROM header points to the song playback routine; <tt>AX</tt> is set to the song number.
1b412673debb207a58cee9530b5f6aeacb59465a
609
608
2025-04-23T18:57:45Z
Asie
351
wikitext
text/x-wiki
The WSR file format is used for storing music routines from WonderSwan software, not unlike the NSF format. It was initally defined and implemented by the <tt>in_wsr</tt> Winamp plugin.
Its format is based on the [[ROM header]] format, with files expected to be a multiple of 64 KiB in size. However, the footer at the end of the file is 32 bytes long, not 16:
{| class="wikitable"
|+ Header contents
|-
! Offset !! Length !! Contents
|-Q
| $00 || 4 || Magic string: <tt>WSRF</tt>
|-
| $04 || 1 || Version number; currently <tt>$00</tt>
|-
| $05 || 1 || Starting song number
|-
| $06 || 10 || Reserved
|-
| $10 || 16 || [[ROM header]]
|}
The <tt>JMP</tt> instruction in the ROM header points to the song playback routine; <tt>AX</tt> is set to the song number.
== References ==
* [https://github.com/WonderfulToolchain/awesome-wsdev/blob/main/archive/in_wsr.txt in_wsr.txt] - the original specification
<references/>
5959647a12399e9cf9c6c5b3e7c923cdecf017d1
Boot ROM
0
81
611
520
2025-04-26T17:01:42Z
Lidnariq
7
only color model validates the footer
wikitext
text/x-wiki
The WonderSwan boot ROM is where the console begins execution on power on.
* On the "mono" model, it occupies an area from <tt>$FF000</tt> to <tt>$FFFFF</tt>, for a total of 4 KiB.
* On the Color model, it occupies an area from <tt>$FE000</tt> to <tt>$FFFFF</tt>, for a total of 8 KiB.
It performs the following activities:
* checks if the cartridge self-test passed;
* If the color model, checks if the cartridge footer is valid;
* if START is held when the console is turned on, enters the boot ROM menu;
* updates telemetry/diagnostics information in the internal EEPROM;
* displays the splash screen (optionally, a custom splash screen on Color models);
* jumps to the cartridge.
5bcf659214acd96cdb5eae9d07d309e71be6a10c
I/O port map
0
8
612
597
2025-05-04T08:46:48Z
Asie
351
wikitext
text/x-wiki
The WonderSwan SoC has three general blocks of I/O port accesses:
{| class="wikitable"
! From !! To !! Holder !! Width !! Speed
|-
| $00 || $B7 || WonderSwan SoC || 16-bit || 1 cycle
|-
| $B8 || $BF || Internal EEPROM control || 16-bit || 1 cycle
|-
| $C0 || $FF || Cartridge bus || 8-bit || 1<sup>(color)</sup>/2 cycles (configurable)
|}
With the exception of internal EEPROM on the ASWAN, all unaligned 16-bit accesses can be converted to two 8-bit accesses with a 1-cycle penalty.
== I/O port map ==
* Superscripts are used to mark ports specific to a given mode or platform:
** Color mode: <sup>(color)</sup>. Such ports are only accessible when color mode is enabled through port <code>$60</code>.
** WS/WSC/SC console: <sup>(WS)</sup>, <sup>(WSC)</sup>, <sup>(SC)</sup>.
* If two Bits rows are provided, the second one refers to the "Color" mode.
* The Type can be: R - readable, W - writable, L - writable before boot ROM lockout, 8/16 - width (byte/word).
{| class="wikitable"
! Category
! Port
! Description
! Bits
! Type
! Notes
|-
! rowspan="47" | [[Display]]
! $00
| [[Display/IO Ports#Display Control|Display Control]]
| style="text-align: right" | <tt style="white-space: nowrap">..wo Ws21</tt>
| RW8
|
|-
! $01
| [[Display/IO Ports#Display Background|Display Background]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .sss</tt>
<tt style="white-space: nowrap">pppp iiii</tt>
| RW8
| Shade (s)
Palette (p), Index (i)
|-
! $02
| [[Display/IO Ports#Current Line|Display Current Line]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll</tt>
| R8
| Line (l)
|-
! $03
| [[Display/IO Ports#Interrupt Line|Display Interrupt Line]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll</tt>
| RW8
| Line (l)
|-
! $04
| [[Display/IO Ports#Sprite Table Address|Sprite Table Address]]
| style="text-align: right" | <tt style="white-space: nowrap">...a aaaa</tt>
<tt style="white-space: nowrap">..aa aaaa</tt>
| RW8
| Address >> 9 (a)
|-
! $05
| [[Display/IO Ports#Sprite Table First|Sprite Table First]]
| style="text-align: right" | <tt style="white-space: nowrap">.iii iiii</tt>
| RW8
| Index (i)
|-
! $06
| [[Display/IO Ports#Sprite Table Count|Sprite Table Count]]
| style="text-align: right" | <tt style="white-space: nowrap">cccc cccc</tt>
| RW8
| Count (c)
|-
! $07
| [[Display/IO Ports#Screen Address|Screen Address]]
| style="text-align: right" | <tt style="white-space: nowrap">.222 .111</tt>
<tt style="white-space: nowrap">2222 1111</tt>
| RW8
| Screen 1 address >> 11 (1)
Screen 2 address >> 11 (2)
|-
! $08
| [[Display/IO Ports#Screen 2 Window|Screen 2 Window Left]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $09
| [[Display/IO Ports#Screen 2 Window|Screen 2 Window Top]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $0A
| [[Display/IO Ports#Screen 2 Window|Screen 2 Window Right]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $0B
| [[Display/IO Ports#Screen 2 Window|Screen 2 Window Bottom]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $0C
| [[Display/IO Ports#Sprite Window|Sprite Window Left]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $0D
| [[Display/IO Ports#Sprite Window|Sprite Window Top]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $0E
| [[Display/IO Ports#Sprite Window|Sprite Window Right]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $0F
| [[Display/IO Ports#Sprite Window|Sprite Window Bottom]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $10
| [[Display/IO Ports#Screen Scroll|Screen 1 Scroll X]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $11
| [[Display/IO Ports#Screen Scroll|Screen 1 Scroll Y]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $12
| [[Display/IO Ports#Screen Scroll|Screen 2 Scroll X]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $13
| [[Display/IO Ports#Screen Scroll|Screen 2 Scroll Y]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $14
| [[Display/IO Ports#LCD Control|LCD Control]]
| style="text-align: right" | <tt style="white-space: nowrap">.... ..Ce</tt>
| RW8
| Contrast (C)<sup>(WSC)</sup>, Enable (e)
|-
! $15
| [[Display/IO Ports#LCD Icon Control|LCD Icon Control]]
| style="text-align: right" | <tt style="white-space: nowrap">..32 1hvs</tt>
| RW8
| Etc. 3 (3), Etc. 2 (2), Etc. 1 (1),
Horizontal (h), Vertical (v), Sleep (s)
|-
! $16
| [[Display/IO Ports#LCD Final Line|LCD Final Line]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll</tt>
| RW8
| Line (l)
|-
! $17
| [[Display/IO Ports#LCD Back Porch Line|LCD Back Porch Line]]<sup>(WSC)</sup>
| style="text-align: right" | <tt style="white-space: nowrap">llll llll</tt>
| RW8
| Line (l)
|-
! $18
| [[Display/IO Ports#LCD Line Counter|LCD Line Counter]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll</tt>
| W8
| Line (l)
|-
! $1A
| [[Display/IO Ports#LCD Status|LCD Latched Icon Status]]
| style="text-align: right" | <tt style="white-space: nowrap">..cv vvhs</tt>
| R8
| Cartridge icon (c), Volume icons (v),
Headphone icon (h), Latch override (l)
|-
! $1A
| [[Display/IO Ports#LCD Status|LCD Latched Icon Control]]
| style="text-align: right" | <tt style="white-space: nowrap">..cv vvhs</tt>
| W8
| Cartridge (c), Sound (s), Latch override (l)
|-
! $1C
| [[Display/IO Ports#LCD Mono Shade LUT|LCD Mono Shade LUT 0/1]]
| style="text-align: right" | <tt style="white-space: nowrap">1111 0000</tt>
| RW8
| Shade index
|-
! $1D
| [[Display/IO Ports#LCD Mono Shade LUT|LCD Mono Shade LUT 2/3]]
| style="text-align: right" | <tt style="white-space: nowrap">3333 2222</tt>
| RW8
| Shade index
|-
! $1E
| [[Display/IO Ports#LCD Mono Shade LUT|LCD Mono Shade LUT 4/5]]
| style="text-align: right" | <tt style="white-space: nowrap">5555 4444</tt>
| RW8
| Shade index
|-
! $1F
| [[Display/IO Ports#LCD Mono Shade LUT|LCD Mono Shade LUT 6/7]]
| style="text-align: right" | <tt style="white-space: nowrap">7777 6666</tt>
| RW8
| Shade index
|-
! $20
| [[Display/IO Ports#LCD Mono Palette|LCD Mono Palette 0]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $22
| [[Display/IO Ports#LCD Mono Palette|LCD Mono Palette 1]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $24
| [[Display/IO Ports#LCD Mono Palette|LCD Mono Palette 2]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $26
| [[Display/IO Ports#LCD Mono Palette|LCD Mono Palette 3]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $28
| [[Display/IO Ports#LCD Mono Palette|LCD Mono Palette 4]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 ....</tt>
| RW16
| Shade LUT index
|-
! $2A
| [[Display/IO Ports#LCD Mono Palette|LCD Mono Palette 5]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 ....</tt>
| RW16
| Shade LUT index
|-
! $2C
| [[Display/IO Ports#LCD Mono Palette|LCD Mono Palette 6]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 ....</tt>
| RW16
| Shade LUT index
|-
! $2E
| [[Display/IO Ports#LCD Mono Palette|LCD Mono Palette 7]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 ....</tt>
| RW16
| Shade LUT index
|-
! $30
| [[Display/IO Ports#LCD Mono Palette|LCD Mono Palette 8]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $32
| [[Display/IO Ports#LCD Mono Palette|LCD Mono Palette 9]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $34
| [[Display/IO Ports#LCD Mono Palette|LCD Mono Palette 10]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $36
| [[Display/IO Ports#LCD Mono Palette|LCD Mono Palette 11]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $38
| [[Display/IO Ports#LCD Mono Palette|LCD Mono Palette 12]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 ....</tt>
| RW16
| Shade LUT index
|-
! $3A
| [[Display/IO Ports#LCD Mono Palette|LCD Mono Palette 13]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 ....</tt>
| RW16
| Shade LUT index
|-
! $3C
| [[Display/IO Ports#LCD Mono Palette|LCD Mono Palette 14]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 ....</tt>
| RW16
| Shade LUT index
|-
! $3E
| [[Display/IO Ports#LCD Mono Palette|LCD Mono Palette 15]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 ....</tt>
| RW16
| Shade LUT index
|-
! rowspan="10" | [[DMA]]<sup>(color)</sup>
! $40
| [[DMA#General DMA|GDMA Source Address Low]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll llll lll.</tt>
| RW16
| Linear address, low 16 bits (l)
|-
! $42
| [[DMA#General DMA|GDMA Source Address High]]
| style="text-align: right" | <tt style="white-space: nowrap">.... hhhh</tt>
| RW8
| Linear address, high 4 bits (h)
|-
! $44
| [[DMA#General DMA|GDMA Destination Address]]
| style="text-align: right" | <tt style="white-space: nowrap">aaaa aaaa aaaa aaa.</tt>
| RW16
| IRAM address (a)
|-
! $46
| [[DMA#General DMA|GDMA Length]]
| style="text-align: right" | <tt style="white-space: nowrap">bbbb bbbb bbbb bbb.</tt>
| RW16
| Bytes (b)
|-
! $48
| [[DMA#General DMA|GDMA Control]]
| style="text-align: right" | <tt style="white-space: nowrap">ed.. ....</tt>
| RW8
| Enable (e), Decrement (d)
|-
! $4A
| [[DMA#Sound DMA|SDMA Source Address Low]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll llll llll</tt>
| RW16
| Linear address, low 16 bits (l)
|-
! $4C
| [[DMA#Sound DMA|SDMA Source Address High]]
| style="text-align: right" | <tt style="white-space: nowrap">.... hhhh</tt>
| RW8
| Linear address, high 4 bits (h)
|-
! $4E
| [[DMA#Sound DMA|SDMA Length Low]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll llll llll</tt>
| RW16
| Length, low 16 bits (l)
|-
! $50
| [[DMA#Sound DMA|SDMA Length High]]
| style="text-align: right" | <tt style="white-space: nowrap">.... hhhh</tt>
| RW8
| Length, high 4 bits (h)
|-
! $52
| [[DMA#Sound DMA|SDMA Control]]
| style="text-align: right" | <tt style="white-space: nowrap">ed.t rhff</tt>
| RW8
| Enable (e), Decrement (d), Target (t),
Repeat (r), Hold (h), Frequency (f)
|-
! rowspan="2" | [[SoC]]<sup>(color)</sup>
! $60
| [[SoC#System Control 2|System Control 2]]
| style="text-align: right" | <tt style="white-space: nowrap">c4C. i.sl</tt>
| RW8
| Color (c), 4BPP (4), Chunky (C),<br/>
Cart I/O wait state (i), SRAM wait state (s),<br/>
Cart clock speed (l).
|-
! $62
| [[SoC#System Control 3|System Control 3]]
| style="text-align: right" | <tt style="white-space: nowrap">S... ...p</tt>
| RW8
| SwanCrystal (S), Power off (p)
|-
! rowspan="4" | [[Hyper Voice]]<sup>(color)</sup>
! $64
| [[Hyper Voice#Hyper Voice Output|Hyper Voice Left Output]]
| style="text-align: right" | <tt style="white-space: nowrap">ssss ssss ssss ssss</tt>
| W16
| Raw sample (s)
|-
! $66
| [[Hyper Voice#Hyper Voice Output|Hyper Voice Right Output]]
| style="text-align: right" | <tt style="white-space: nowrap">ssss ssss ssss ssss</tt>
| W16
| Raw sample (s)
|-
! $69
| [[Hyper Voice#Hyper Voice Input|Hyper Voice Right Input]]
| style="text-align: right" | <tt style="white-space: nowrap">ssss ssss</tt>
| W8
| Sample (s)
|-
! $6A
| [[Hyper Voice#Hyper Voice Control|Hyper Voice Control]]
| style="text-align: right" | <tt style="white-space: nowrap">.mmc ???? errr ffss</tt>
| RW16
| Mode (m), Channel reset (c), Enable (e),
Rate (r), Format (f), Shift (s)
|-
! rowspan="8" | [[Display]]<sup>(SC)</sup>
! $70
| LCD Timing Configuration 1?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $71
| LCD Timing Configuration 2?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $72
| LCD Timing Configuration 3?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $73
| LCD Timing Configuration 4?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $74
| LCD Timing Configuration 5?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $75
| LCD Timing Configuration 6?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $76
| LCD Timing Configuration 7?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $77
| LCD Timing Configuration 8?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! rowspan="22" | [[Sound]]
! $80
| [[Sound#Sound Channel Frequency|Sound Channel 1 Frequency]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .ddd dddd dddd</tt>
| RW16
| Divider (d)
|-
! $82
| [[Sound#Sound Channel Frequency|Sound Channel 2 Frequency]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .ddd dddd dddd</tt>
| RW16
| Divider (d)
|-
! $84
| [[Sound#Sound Channel Frequency|Sound Channel 3 Frequency]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .ddd dddd dddd</tt>
| RW16
| Divider (d)
|-
! $86
| [[Sound#Sound Channel Frequency|Sound Channel 4 Frequency]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .ddd dddd dddd</tt>
| RW16
| Divider (d)
|-
! $88
| [[Sound#Sound Channel Volume|Sound Channel 1 Volume]]
| style="text-align: right" | <tt style="white-space: nowrap">llll rrrr</tt>
| RW8
| Left (l), Right (r)
|-
! rowspan="2" | $89
| [[Sound#Sound Channel Volume|Sound Channel 2 Volume]]
| style="text-align: right" | <tt style="white-space: nowrap">llll rrrr</tt>
| RW8
| Left (l), Right (r)
|-
| [[Sound#Sound Channel 2 Voice Sample|Sound Channel 2 Voice Sample]]
| style="text-align: right" | <tt style="white-space: nowrap">ssss ssss</tt>
| RW8
| Sample (s)
|-
! $8A
| [[Sound#Sound Channel Volume|Sound Channel 3 Volume]]
| style="text-align: right" | <tt style="white-space: nowrap">llll rrrr</tt>
| RW8
| Left (l), Right (r)
|-
! $8B
| [[Sound#Sound Channel Volume|Sound Channel 4 Volume]]
| style="text-align: right" | <tt style="white-space: nowrap">llll rrrr</tt>
| RW8
| Left (l), Right (r)
|-
! $8C
| [[Sound#Sound Channel 3 Sweep Amount|Sound Channel 3 Sweep Amount]]
| style="text-align: right" | <tt style="white-space: nowrap">vvvv vvvv</tt>
| RW8
| Value (v)
|-
! $8D
| [[Sound#Sound Channel 3 Sweep Ticks|Sound Channel 3 Sweep Ticks]]
| style="text-align: right" | <tt style="white-space: nowrap">...t tttt</tt>
| RW8
| Ticks (t)
|-
! $8E
| [[Sound#Sound Channel 4 Noise Control|Sound Channel 4 Noise Control]]
| style="text-align: right" | <tt style="white-space: nowrap">...e rttt</tt>
| RW8
| Enable (e), Reset (r), Tap (t)
|-
! $8F
| [[Sound#Sound Wavetable Address|Sound Wavetable Address]]
| style="text-align: right" | <tt style="white-space: nowrap">wwww wwww</tt>
| RW8
| Address >> 6 (w)
|-
! $90
| [[Sound#Sound Channel Control|Sound Channel Control]]
| style="text-align: right" | <tt style="white-space: nowrap">nsv. 4321</tt>
| RW8
| Channel enable (1234)
Noise (n), Sweep (s), Voice (v)
|-
! $91
| [[Sound#Sound Output Control|Sound Output Control]]
| style="text-align: right" | <tt style="white-space: nowrap">H... hrrs</tt>
| RW8
| Headphones connected (H)
Headphone output (h)
Speaker output (s), range (r)
|-
! $92
| [[Sound#Sound Channel 4 LFSR Register|Sound Channel 4 LFSR Register]]
| style="text-align: right" | <tt style="white-space: nowrap">.rrr rrrr rrrr rrrr</tt>
| R16
| PRNG state (r)
|-
! $94
| [[Sound#Sound Channel 2 Voice Volume|Sound Channel 2 Voice Volume]]
| style="text-align: right" | <tt style="white-space: nowrap">.... lLrR</tt>
| RW8
| Left Half (l), Full (L)
Right Half (r), Full (R)
|-
! $95
| [[Sound#Sound Test|Sound Test]]
| style="text-align: right" | <tt style="white-space: nowrap">cc5? ??sh</tt>
| RW8
|
|-
! $96
| [[Sound#Sound Channel Output Right|Sound Channel Output Right]]
| style="text-align: right" | <tt style="white-space: nowrap">.... ..ss ssss ssss</tt>
| R16
| Sample (s)
|-
! $98
| [[Sound#Sound Channel Output Left|Sound Channel Output Left]]
| style="text-align: right" | <tt style="white-space: nowrap">.... ..ss ssss ssss</tt>
| R16
| Sample (s)
|-
! $9A
| [[Sound#Sound Channel Output Sum|Sound Channel Output Sum]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .sss ssss ssss</tt>
| R16
| Sample (s)
|-
! $9E
| [[Sound#Sound Speaker Main Volume|Sound Speaker Main Volume]]<sup>(color)</sup>
| style="text-align: right" | <tt style="white-space: nowrap">.... ..vv</tt>
| RW8
| Main volume (v)
|-
! [[SoC]]
! $A0
| [[SoC#System Control|System Control]]
| style="text-align: right" | <tt style="white-space: nowrap">C??? swcl</tt>
| RW8
| Cartridge OK (C), ROM wait state (s), ROM width (w),
Color system (c), Boot ROM lockout (l)
|-
! [[Timers]]
! $A2
| [[Timers#Timer Control|Timer Control]]
| style="text-align: right" | <tt style="white-space: nowrap">.... VvHh</tt>
| RW8
| Horizontal enable (h), auto reload (H)
Vertical enable (v), auto reload (V)
|-
! [[SoC]]
! $A3
| [[SoC#System Test|System Test]]
| style="text-align: right" | <tt style="white-space: nowrap">.... u?vh</tt>
| RW8
| UART test (u), VBlank Timer test (v), HBlank Timer test (h)
|-
! rowspan="4" | [[Timers]]
! $A4
| [[Timers#Timer Reload|Horizontal Blank Timer Reload]]
| style="text-align: right" | <tt style="white-space: nowrap">tttt tttt tttt tttt</tt>
| RW16
| Ticks (t)
|-
! $A6
| [[Timers#Timer Reload|Vertical Blank Timer Reload]]
| style="text-align: right" | <tt style="white-space: nowrap">tttt tttt tttt tttt</tt>
| RW16
| Ticks (t)
|-
! $A8
| [[Timers#Timer Counter|Horizontal Blank Timer Counter]]
| style="text-align: right" | <tt style="white-space: nowrap">tttt tttt tttt tttt</tt>
| R16
| Ticks (t)
|-
! $AA
| [[Timers#Timer Counter|Vertical Blank Timer Counter]]
| style="text-align: right" | <tt style="white-space: nowrap">tttt tttt tttt tttt</tt>
| R16
| Ticks (t)
|-
! [[SoC]]
! $AC
| ?
| style="text-align: right" | <tt style="white-space: nowrap">.... ...p</tt>
| W8?
| Power off (p)
|-
! rowspan="2" | [[Interrupts]]
! rowspan="2" | $B0
| [[Interrupts#Interrupt Vector Offset|Interrupt Vector Offset]]
| style="text-align: right" | <tt style="white-space: nowrap">VVVV V...</tt>
| W8
| Vector offset (V)
|-
| [[Interrupts#Interrupt Vector Request|Interrupt Vector Request]]
| style="text-align: right" | <tt style="white-space: nowrap">vvvv vvvv</tt>
| R8
| Requested vector offset (v)
|-
! rowspan="2" | [[UART]]
! $B1
| [[UART#Serial Receive Data|Serial Receive Data]]
| style="text-align: right" | <tt style="white-space: nowrap">dddd dddd</tt>
| R8
| Receive buffer data (d)
|-
! $B1
| [[UART#Serial Transmit Data|Serial Transmit Data]]
| style="text-align: right" | <tt style="white-space: nowrap">dddd dddd</tt>
| W8
| Transmit buffer data (d)
|-
! [[Interrupts]]
! $B2
| [[Interrupts#Interrupt Enable|Interrupt Enable]]
| style="text-align: right" | <tt style="white-space: nowrap">iiii iiii</tt>
| RW8
| Interrupt index (i)
|-
! rowspan="2" | [[UART]]
! $B3
| [[UART#Serial Status|Serial Status]]
| style="text-align: right" | <tt style="white-space: nowrap">eb.. .tor</tt>
| R8
| Enable (e), Baud rate (b),
Transfer ready (t), Overrun (o), Receive ready (r)
|-
! $B3
| [[UART#Serial Control|Serial Control]]
| style="text-align: right" | <tt style="white-space: nowrap">ebO. ....</tt>
| W8
| Enable (e), Baud rate (b), Reset Overrun (O)
|-
! [[Interrupts]]
! $B4
| [[Interrupts#Interrupt Status|Interrupt Status]]
| style="text-align: right" | <tt style="white-space: nowrap">iiii iiii</tt>
| R8
| Interrupt index (i)
|-
! [[Keypad]]
! $B5
| [[Keypad|Keypad Scan]]
| style="text-align: right" | <tt style="white-space: nowrap">.iii oooo</tt>
| RW8
| Input row (i), Output column (o)
|-
! rowspan="2" | [[Interrupts]]
! $B6
| [[Interrupts#Interrupt Acknowledge|Interrupt Acknowledge]]
| style="text-align: right" | <tt style="white-space: nowrap">iiii iiii</tt>
| W8
| Interrupt index (i)
|-
! $B7
| [[Interrupts#Interrupt NMI Control|Interrupt NMI Control]]
| style="text-align: right" | <tt style="white-space: nowrap">...b ....</tt>
| RW8
| Low battery (b)
|-
! rowspan="4" | [[EEPROM|Internal EEPROM]]
! $BA
| [[EEPROM#Internal EEPROM Data|Internal EEPROM Data]]
| style="text-align: right" | <tt style="white-space: nowrap">dddd dddd dddd dddd</tt>
| RW16
| Data (d)
|-
! $BC
| [[EEPROM#Internal EEPROM Command|Internal EEPROM Command]]
|
| RW16
|
|-
! rowspan="2" | $BE
| [[EEPROM#Internal EEPROM Status|Internal EEPROM Status]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .... p... ..RD</tt>
| R16
| Protected (p), Ready (R), Done (D)
|-
| [[EEPROM#Internal EEPROM Control|Internal EEPROM Control]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .... pewr ....</tt>
| W16
| Protect (p), Erase (e), Write (w), Read (r)
|-
! [[Mapper|Cartridge]]
! $C0<br />...<br />
$FF
| Cartridge I/O
|
| RW8
| Forwarded by the SoC
|}
== I/O port routing ==
The [[NEC V30MZ]] supports 16-bit I/O port addresses. The WonderSwan SoC routes them using the following algorithm:
* If an address is between <code>$00B8</code> and <code>$00BF</code> inclusive, it is routed to the internal EEPROM control block.
* If an address is between <code>$00C0</code> and <code>$00FF</code> inclusive, it is routed to the cartride bus.
* If an address's bits <code>0</code> through <code>8</code> inclusive are between <code>$000</code> and <code>$0B7</code> inclusive, they are routed to the SoC block.
* If none of these conditions are reached, open bus is read.
On the monochrome models, as well as color models in mono emulation, open bus is always <code>0x90</code>.
666b0e36fe29ef4049a489332cded28246595ff8
614
612
2025-05-04T08:50:00Z
Asie
351
/* I/O port map */
wikitext
text/x-wiki
The WonderSwan SoC has three general blocks of I/O port accesses:
{| class="wikitable"
! From !! To !! Holder !! Width !! Speed
|-
| $00 || $B7 || WonderSwan SoC || 16-bit || 1 cycle
|-
| $B8 || $BF || Internal EEPROM control || 16-bit || 1 cycle
|-
| $C0 || $FF || Cartridge bus || 8-bit || 1<sup>(color)</sup>/2 cycles (configurable)
|}
With the exception of internal EEPROM on the ASWAN, all unaligned 16-bit accesses can be converted to two 8-bit accesses with a 1-cycle penalty.
== I/O port map ==
* Superscripts are used to mark ports specific to a given mode or platform:
** Color mode: <sup>(color)</sup>. Such ports are only accessible when color mode is enabled through port <code>$60</code>.
** WS/WSC/SC console: <sup>(WS)</sup>, <sup>(WSC)</sup>, <sup>(SC)</sup>.
* If two Bits rows are provided, the second one refers to the "Color" mode.
* The Type can be: R - readable, W - writable, L - writable before boot ROM lockout, 8/16 - width (byte/word).
{| class="wikitable"
! Category
! Port
! Description
! Bits
! Type
! Notes
|-
! rowspan="47" | [[Display]]
! $00
| [[Display/IO Ports#Display Control|Display Control]]
| style="text-align: right" | <tt style="white-space: nowrap">..wo Ws21</tt>
| RW8
|
|-
! $01
| [[Display/IO Ports#Display Background|Display Background]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .sss</tt>
<tt style="white-space: nowrap">pppp iiii</tt>
| RW8
| Shade (s)
Palette (p), Index (i)
|-
! $02
| [[Display/IO Ports#Current Line|Display Current Line]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll</tt>
| R8
| Line (l)
|-
! $03
| [[Display/IO Ports#Interrupt Line|Display Interrupt Line]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll</tt>
| RW8
| Line (l)
|-
! $04
| [[Display/IO Ports#Sprite Table Address|Sprite Table Address]]
| style="text-align: right" | <tt style="white-space: nowrap">...a aaaa</tt>
<tt style="white-space: nowrap">..aa aaaa</tt>
| RW8
| Address >> 9 (a)
|-
! $05
| [[Display/IO Ports#Sprite Table First|Sprite Table First]]
| style="text-align: right" | <tt style="white-space: nowrap">.iii iiii</tt>
| RW8
| Index (i)
|-
! $06
| [[Display/IO Ports#Sprite Table Count|Sprite Table Count]]
| style="text-align: right" | <tt style="white-space: nowrap">cccc cccc</tt>
| RW8
| Count (c)
|-
! $07
| [[Display/IO Ports#Screen Address|Screen Address]]
| style="text-align: right" | <tt style="white-space: nowrap">.222 .111</tt>
<tt style="white-space: nowrap">2222 1111</tt>
| RW8
| Screen 1 address >> 11 (1)
Screen 2 address >> 11 (2)
|-
! $08
| [[Display/IO Ports#Screen 2 Window|Screen 2 Window Left]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $09
| [[Display/IO Ports#Screen 2 Window|Screen 2 Window Top]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $0A
| [[Display/IO Ports#Screen 2 Window|Screen 2 Window Right]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $0B
| [[Display/IO Ports#Screen 2 Window|Screen 2 Window Bottom]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $0C
| [[Display/IO Ports#Sprite Window|Sprite Window Left]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $0D
| [[Display/IO Ports#Sprite Window|Sprite Window Top]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $0E
| [[Display/IO Ports#Sprite Window|Sprite Window Right]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $0F
| [[Display/IO Ports#Sprite Window|Sprite Window Bottom]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $10
| [[Display/IO Ports#Screen Scroll|Screen 1 Scroll X]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $11
| [[Display/IO Ports#Screen Scroll|Screen 1 Scroll Y]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $12
| [[Display/IO Ports#Screen Scroll|Screen 2 Scroll X]]
| style="text-align: right" | <tt style="white-space: nowrap">xxxx xxxx</tt>
| RW8
| Coordinate (x)
|-
! $13
| [[Display/IO Ports#Screen Scroll|Screen 2 Scroll Y]]
| style="text-align: right" | <tt style="white-space: nowrap">yyyy yyyy</tt>
| RW8
| Coordinate (y)
|-
! $14
| [[Display/IO Ports#LCD Control|LCD Control]]
| style="text-align: right" | <tt style="white-space: nowrap">.... ..Ce</tt>
| RW8
| Contrast (C)<sup>(WSC)</sup>, Enable (e)
|-
! $15
| [[Display/IO Ports#LCD Icon Control|LCD Icon Control]]
| style="text-align: right" | <tt style="white-space: nowrap">..32 1hvs</tt>
| RW8
| Etc. 3 (3), Etc. 2 (2), Etc. 1 (1),
Horizontal (h), Vertical (v), Sleep (s)
|-
! $16
| [[Display/IO Ports#LCD Final Line|LCD Final Line]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll</tt>
| RW8
| Line (l)
|-
! $17
| [[Display/IO Ports#LCD Back Porch Line|LCD Back Porch Line]]<sup>(WSC)</sup>
| style="text-align: right" | <tt style="white-space: nowrap">llll llll</tt>
| RW8
| Line (l)
|-
! $18
| [[Display/IO Ports#LCD Line Counter|LCD Line Counter]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll</tt>
| W8
| Line (l)
|-
! $1A
| [[Display/IO Ports#LCD Status|LCD Latched Icon Status]]
| style="text-align: right" | <tt style="white-space: nowrap">..cv vvhs</tt>
| R8
| Cartridge icon (c), Volume icons (v),
Headphone icon (h), Latch override (l)
|-
! $1A
| [[Display/IO Ports#LCD Status|LCD Latched Icon Control]]
| style="text-align: right" | <tt style="white-space: nowrap">..cv vvhs</tt>
| W8
| Cartridge (c), Sound (s), Latch override (l)
|-
! $1C
| [[Display/IO Ports#LCD Mono Shade LUT|LCD Mono Shade LUT 0/1]]
| style="text-align: right" | <tt style="white-space: nowrap">1111 0000</tt>
| RW8
| Shade index
|-
! $1D
| [[Display/IO Ports#LCD Mono Shade LUT|LCD Mono Shade LUT 2/3]]
| style="text-align: right" | <tt style="white-space: nowrap">3333 2222</tt>
| RW8
| Shade index
|-
! $1E
| [[Display/IO Ports#LCD Mono Shade LUT|LCD Mono Shade LUT 4/5]]
| style="text-align: right" | <tt style="white-space: nowrap">5555 4444</tt>
| RW8
| Shade index
|-
! $1F
| [[Display/IO Ports#LCD Mono Shade LUT|LCD Mono Shade LUT 6/7]]
| style="text-align: right" | <tt style="white-space: nowrap">7777 6666</tt>
| RW8
| Shade index
|-
! $20
| [[Display/IO Ports#LCD Mono Palette|LCD Mono Palette 0]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $22
| [[Display/IO Ports#LCD Mono Palette|LCD Mono Palette 1]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $24
| [[Display/IO Ports#LCD Mono Palette|LCD Mono Palette 2]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $26
| [[Display/IO Ports#LCD Mono Palette|LCD Mono Palette 3]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $28
| [[Display/IO Ports#LCD Mono Palette|LCD Mono Palette 4]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 ....</tt>
| RW16
| Shade LUT index
|-
! $2A
| [[Display/IO Ports#LCD Mono Palette|LCD Mono Palette 5]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 ....</tt>
| RW16
| Shade LUT index
|-
! $2C
| [[Display/IO Ports#LCD Mono Palette|LCD Mono Palette 6]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 ....</tt>
| RW16
| Shade LUT index
|-
! $2E
| [[Display/IO Ports#LCD Mono Palette|LCD Mono Palette 7]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 ....</tt>
| RW16
| Shade LUT index
|-
! $30
| [[Display/IO Ports#LCD Mono Palette|LCD Mono Palette 8]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $32
| [[Display/IO Ports#LCD Mono Palette|LCD Mono Palette 9]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $34
| [[Display/IO Ports#LCD Mono Palette|LCD Mono Palette 10]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $36
| [[Display/IO Ports#LCD Mono Palette|LCD Mono Palette 11]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 .000</tt>
| RW16
| Shade LUT index
|-
! $38
| [[Display/IO Ports#LCD Mono Palette|LCD Mono Palette 12]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 ....</tt>
| RW16
| Shade LUT index
|-
! $3A
| [[Display/IO Ports#LCD Mono Palette|LCD Mono Palette 13]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 ....</tt>
| RW16
| Shade LUT index
|-
! $3C
| [[Display/IO Ports#LCD Mono Palette|LCD Mono Palette 14]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 ....</tt>
| RW16
| Shade LUT index
|-
! $3E
| [[Display/IO Ports#LCD Mono Palette|LCD Mono Palette 15]]
| style="text-align: right" | <tt style="white-space: nowrap">.333 .222 .111 ....</tt>
| RW16
| Shade LUT index
|-
! rowspan="10" | [[DMA]]<sup>(color)</sup>
! $40
| [[DMA#General DMA|GDMA Source Address Low]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll llll lll.</tt>
| RW16
| Linear address, low 16 bits (l)
|-
! $42
| [[DMA#General DMA|GDMA Source Address High]]
| style="text-align: right" | <tt style="white-space: nowrap">.... hhhh</tt>
| RW8
| Linear address, high 4 bits (h)
|-
! $44
| [[DMA#General DMA|GDMA Destination Address]]
| style="text-align: right" | <tt style="white-space: nowrap">aaaa aaaa aaaa aaa.</tt>
| RW16
| IRAM address (a)
|-
! $46
| [[DMA#General DMA|GDMA Length]]
| style="text-align: right" | <tt style="white-space: nowrap">bbbb bbbb bbbb bbb.</tt>
| RW16
| Bytes (b)
|-
! $48
| [[DMA#General DMA|GDMA Control]]
| style="text-align: right" | <tt style="white-space: nowrap">ed.. ....</tt>
| RW8
| Enable (e), Decrement (d)
|-
! $4A
| [[DMA#Sound DMA|SDMA Source Address Low]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll llll llll</tt>
| RW16
| Linear address, low 16 bits (l)
|-
! $4C
| [[DMA#Sound DMA|SDMA Source Address High]]
| style="text-align: right" | <tt style="white-space: nowrap">.... hhhh</tt>
| RW8
| Linear address, high 4 bits (h)
|-
! $4E
| [[DMA#Sound DMA|SDMA Length Low]]
| style="text-align: right" | <tt style="white-space: nowrap">llll llll llll llll</tt>
| RW16
| Length, low 16 bits (l)
|-
! $50
| [[DMA#Sound DMA|SDMA Length High]]
| style="text-align: right" | <tt style="white-space: nowrap">.... hhhh</tt>
| RW8
| Length, high 4 bits (h)
|-
! $52
| [[DMA#Sound DMA|SDMA Control]]
| style="text-align: right" | <tt style="white-space: nowrap">ed.t rhff</tt>
| RW8
| Enable (e), Decrement (d), Target (t),
Repeat (r), Hold (h), Frequency (f)
|-
! rowspan="2" | [[SoC]]<sup>(color)</sup>
! $60
| [[SoC#System Control 2|System Control 2]]
| style="text-align: right" | <tt style="white-space: nowrap">c4C. i.sl</tt>
| RW8
| Color (c), 4BPP (4), Chunky (C),<br/>
Cart I/O wait state (i), SRAM wait state (s),<br/>
Cart clock speed (l).
|-
! $62
| [[SoC#System Control 3|System Control 3]]
| style="text-align: right" | <tt style="white-space: nowrap">S... ...p</tt>
| RW8
| SwanCrystal (S), Power off (p)
|-
! rowspan="4" | [[Hyper Voice]]<sup>(color)</sup>
! $64
| [[Hyper Voice#Hyper Voice Output|Hyper Voice Left Output]]
| style="text-align: right" | <tt style="white-space: nowrap">ssss ssss ssss ssss</tt>
| W16
| Raw sample (s)
|-
! $66
| [[Hyper Voice#Hyper Voice Output|Hyper Voice Right Output]]
| style="text-align: right" | <tt style="white-space: nowrap">ssss ssss ssss ssss</tt>
| W16
| Raw sample (s)
|-
! $69
| [[Hyper Voice#Hyper Voice Input|Hyper Voice Right Input]]
| style="text-align: right" | <tt style="white-space: nowrap">ssss ssss</tt>
| W8
| Sample (s)
|-
! $6A
| [[Hyper Voice#Hyper Voice Control|Hyper Voice Control]]
| style="text-align: right" | <tt style="white-space: nowrap">.ttc ???? errr ssvv</tt>
| RW16
| Target (t), Channel reset (c), Enable (e),
Rate (r), Sample (s), Shift (v)
|-
! rowspan="8" | [[Display]]<sup>(SC)</sup>
! $70
| LCD Timing Configuration 1?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $71
| LCD Timing Configuration 2?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $72
| LCD Timing Configuration 3?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $73
| LCD Timing Configuration 4?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $74
| LCD Timing Configuration 5?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $75
| LCD Timing Configuration 6?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $76
| LCD Timing Configuration 7?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! $77
| LCD Timing Configuration 8?
| style="text-align: right" | <tt style="white-space: nowrap">???? ????</tt>
| RL8
|
|-
! rowspan="22" | [[Sound]]
! $80
| [[Sound#Sound Channel Frequency|Sound Channel 1 Frequency]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .ddd dddd dddd</tt>
| RW16
| Divider (d)
|-
! $82
| [[Sound#Sound Channel Frequency|Sound Channel 2 Frequency]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .ddd dddd dddd</tt>
| RW16
| Divider (d)
|-
! $84
| [[Sound#Sound Channel Frequency|Sound Channel 3 Frequency]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .ddd dddd dddd</tt>
| RW16
| Divider (d)
|-
! $86
| [[Sound#Sound Channel Frequency|Sound Channel 4 Frequency]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .ddd dddd dddd</tt>
| RW16
| Divider (d)
|-
! $88
| [[Sound#Sound Channel Volume|Sound Channel 1 Volume]]
| style="text-align: right" | <tt style="white-space: nowrap">llll rrrr</tt>
| RW8
| Left (l), Right (r)
|-
! rowspan="2" | $89
| [[Sound#Sound Channel Volume|Sound Channel 2 Volume]]
| style="text-align: right" | <tt style="white-space: nowrap">llll rrrr</tt>
| RW8
| Left (l), Right (r)
|-
| [[Sound#Sound Channel 2 Voice Sample|Sound Channel 2 Voice Sample]]
| style="text-align: right" | <tt style="white-space: nowrap">ssss ssss</tt>
| RW8
| Sample (s)
|-
! $8A
| [[Sound#Sound Channel Volume|Sound Channel 3 Volume]]
| style="text-align: right" | <tt style="white-space: nowrap">llll rrrr</tt>
| RW8
| Left (l), Right (r)
|-
! $8B
| [[Sound#Sound Channel Volume|Sound Channel 4 Volume]]
| style="text-align: right" | <tt style="white-space: nowrap">llll rrrr</tt>
| RW8
| Left (l), Right (r)
|-
! $8C
| [[Sound#Sound Channel 3 Sweep Amount|Sound Channel 3 Sweep Amount]]
| style="text-align: right" | <tt style="white-space: nowrap">vvvv vvvv</tt>
| RW8
| Value (v)
|-
! $8D
| [[Sound#Sound Channel 3 Sweep Ticks|Sound Channel 3 Sweep Ticks]]
| style="text-align: right" | <tt style="white-space: nowrap">...t tttt</tt>
| RW8
| Ticks (t)
|-
! $8E
| [[Sound#Sound Channel 4 Noise Control|Sound Channel 4 Noise Control]]
| style="text-align: right" | <tt style="white-space: nowrap">...e rttt</tt>
| RW8
| Enable (e), Reset (r), Tap (t)
|-
! $8F
| [[Sound#Sound Wavetable Address|Sound Wavetable Address]]
| style="text-align: right" | <tt style="white-space: nowrap">wwww wwww</tt>
| RW8
| Address >> 6 (w)
|-
! $90
| [[Sound#Sound Channel Control|Sound Channel Control]]
| style="text-align: right" | <tt style="white-space: nowrap">nsv. 4321</tt>
| RW8
| Channel enable (1234)
Noise (n), Sweep (s), Voice (v)
|-
! $91
| [[Sound#Sound Output Control|Sound Output Control]]
| style="text-align: right" | <tt style="white-space: nowrap">H... hrrs</tt>
| RW8
| Headphones connected (H)
Headphone output (h)
Speaker output (s), range (r)
|-
! $92
| [[Sound#Sound Channel 4 LFSR Register|Sound Channel 4 LFSR Register]]
| style="text-align: right" | <tt style="white-space: nowrap">.rrr rrrr rrrr rrrr</tt>
| R16
| PRNG state (r)
|-
! $94
| [[Sound#Sound Channel 2 Voice Volume|Sound Channel 2 Voice Volume]]
| style="text-align: right" | <tt style="white-space: nowrap">.... lLrR</tt>
| RW8
| Left Half (l), Full (L)
Right Half (r), Full (R)
|-
! $95
| [[Sound#Sound Test|Sound Test]]
| style="text-align: right" | <tt style="white-space: nowrap">cc5? ??sh</tt>
| RW8
|
|-
! $96
| [[Sound#Sound Channel Output Right|Sound Channel Output Right]]
| style="text-align: right" | <tt style="white-space: nowrap">.... ..ss ssss ssss</tt>
| R16
| Sample (s)
|-
! $98
| [[Sound#Sound Channel Output Left|Sound Channel Output Left]]
| style="text-align: right" | <tt style="white-space: nowrap">.... ..ss ssss ssss</tt>
| R16
| Sample (s)
|-
! $9A
| [[Sound#Sound Channel Output Sum|Sound Channel Output Sum]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .sss ssss ssss</tt>
| R16
| Sample (s)
|-
! $9E
| [[Sound#Sound Speaker Main Volume|Sound Speaker Main Volume]]<sup>(color)</sup>
| style="text-align: right" | <tt style="white-space: nowrap">.... ..vv</tt>
| RW8
| Main volume (v)
|-
! [[SoC]]
! $A0
| [[SoC#System Control|System Control]]
| style="text-align: right" | <tt style="white-space: nowrap">C??? swcl</tt>
| RW8
| Cartridge OK (C), ROM wait state (s), ROM width (w),
Color system (c), Boot ROM lockout (l)
|-
! [[Timers]]
! $A2
| [[Timers#Timer Control|Timer Control]]
| style="text-align: right" | <tt style="white-space: nowrap">.... VvHh</tt>
| RW8
| Horizontal enable (h), auto reload (H)
Vertical enable (v), auto reload (V)
|-
! [[SoC]]
! $A3
| [[SoC#System Test|System Test]]
| style="text-align: right" | <tt style="white-space: nowrap">.... u?vh</tt>
| RW8
| UART test (u), VBlank Timer test (v), HBlank Timer test (h)
|-
! rowspan="4" | [[Timers]]
! $A4
| [[Timers#Timer Reload|Horizontal Blank Timer Reload]]
| style="text-align: right" | <tt style="white-space: nowrap">tttt tttt tttt tttt</tt>
| RW16
| Ticks (t)
|-
! $A6
| [[Timers#Timer Reload|Vertical Blank Timer Reload]]
| style="text-align: right" | <tt style="white-space: nowrap">tttt tttt tttt tttt</tt>
| RW16
| Ticks (t)
|-
! $A8
| [[Timers#Timer Counter|Horizontal Blank Timer Counter]]
| style="text-align: right" | <tt style="white-space: nowrap">tttt tttt tttt tttt</tt>
| R16
| Ticks (t)
|-
! $AA
| [[Timers#Timer Counter|Vertical Blank Timer Counter]]
| style="text-align: right" | <tt style="white-space: nowrap">tttt tttt tttt tttt</tt>
| R16
| Ticks (t)
|-
! [[SoC]]
! $AC
| ?
| style="text-align: right" | <tt style="white-space: nowrap">.... ...p</tt>
| W8?
| Power off (p)
|-
! rowspan="2" | [[Interrupts]]
! rowspan="2" | $B0
| [[Interrupts#Interrupt Vector Offset|Interrupt Vector Offset]]
| style="text-align: right" | <tt style="white-space: nowrap">VVVV V...</tt>
| W8
| Vector offset (V)
|-
| [[Interrupts#Interrupt Vector Request|Interrupt Vector Request]]
| style="text-align: right" | <tt style="white-space: nowrap">vvvv vvvv</tt>
| R8
| Requested vector offset (v)
|-
! rowspan="2" | [[UART]]
! $B1
| [[UART#Serial Receive Data|Serial Receive Data]]
| style="text-align: right" | <tt style="white-space: nowrap">dddd dddd</tt>
| R8
| Receive buffer data (d)
|-
! $B1
| [[UART#Serial Transmit Data|Serial Transmit Data]]
| style="text-align: right" | <tt style="white-space: nowrap">dddd dddd</tt>
| W8
| Transmit buffer data (d)
|-
! [[Interrupts]]
! $B2
| [[Interrupts#Interrupt Enable|Interrupt Enable]]
| style="text-align: right" | <tt style="white-space: nowrap">iiii iiii</tt>
| RW8
| Interrupt index (i)
|-
! rowspan="2" | [[UART]]
! $B3
| [[UART#Serial Status|Serial Status]]
| style="text-align: right" | <tt style="white-space: nowrap">eb.. .tor</tt>
| R8
| Enable (e), Baud rate (b),
Transfer ready (t), Overrun (o), Receive ready (r)
|-
! $B3
| [[UART#Serial Control|Serial Control]]
| style="text-align: right" | <tt style="white-space: nowrap">ebO. ....</tt>
| W8
| Enable (e), Baud rate (b), Reset Overrun (O)
|-
! [[Interrupts]]
! $B4
| [[Interrupts#Interrupt Status|Interrupt Status]]
| style="text-align: right" | <tt style="white-space: nowrap">iiii iiii</tt>
| R8
| Interrupt index (i)
|-
! [[Keypad]]
! $B5
| [[Keypad|Keypad Scan]]
| style="text-align: right" | <tt style="white-space: nowrap">.iii oooo</tt>
| RW8
| Input row (i), Output column (o)
|-
! rowspan="2" | [[Interrupts]]
! $B6
| [[Interrupts#Interrupt Acknowledge|Interrupt Acknowledge]]
| style="text-align: right" | <tt style="white-space: nowrap">iiii iiii</tt>
| W8
| Interrupt index (i)
|-
! $B7
| [[Interrupts#Interrupt NMI Control|Interrupt NMI Control]]
| style="text-align: right" | <tt style="white-space: nowrap">...b ....</tt>
| RW8
| Low battery (b)
|-
! rowspan="4" | [[EEPROM|Internal EEPROM]]
! $BA
| [[EEPROM#Internal EEPROM Data|Internal EEPROM Data]]
| style="text-align: right" | <tt style="white-space: nowrap">dddd dddd dddd dddd</tt>
| RW16
| Data (d)
|-
! $BC
| [[EEPROM#Internal EEPROM Command|Internal EEPROM Command]]
|
| RW16
|
|-
! rowspan="2" | $BE
| [[EEPROM#Internal EEPROM Status|Internal EEPROM Status]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .... p... ..RD</tt>
| R16
| Protected (p), Ready (R), Done (D)
|-
| [[EEPROM#Internal EEPROM Control|Internal EEPROM Control]]
| style="text-align: right" | <tt style="white-space: nowrap">.... .... pewr ....</tt>
| W16
| Protect (p), Erase (e), Write (w), Read (r)
|-
! [[Mapper|Cartridge]]
! $C0<br />...<br />
$FF
| Cartridge I/O
|
| RW8
| Forwarded by the SoC
|}
== I/O port routing ==
The [[NEC V30MZ]] supports 16-bit I/O port addresses. The WonderSwan SoC routes them using the following algorithm:
* If an address is between <code>$00B8</code> and <code>$00BF</code> inclusive, it is routed to the internal EEPROM control block.
* If an address is between <code>$00C0</code> and <code>$00FF</code> inclusive, it is routed to the cartride bus.
* If an address's bits <code>0</code> through <code>8</code> inclusive are between <code>$000</code> and <code>$0B7</code> inclusive, they are routed to the SoC block.
* If none of these conditions are reached, open bus is read.
On the monochrome models, as well as color models in mono emulation, open bus is always <code>0x90</code>.
a23779a0257bca9e3dc3e6722358fbbf069ae7d8
Hyper Voice
0
30
613
272
2025-05-04T08:49:29Z
Asie
351
/* Hyper Voice Control ($6A, $6B) */
wikitext
text/x-wiki
Hyper Voice is a headphone-only sample output channel introduced with the WonderSwan Color. It allows converting 8-bit signed and unsigned, mono and stereo samples into 16-bit signed PCM sent directly to the headphone output, after mixing with the traditional four channels.
== I/O Ports ==
{{Anchor|Hyper Voice Output}}
=== Hyper Voice Left Output ($64, $65 write) ===
=== Hyper Voice Right Output ($66, $67 write) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
ssss ssss ssss ssss
|||| |||| |||| ||||
++++-++++--++++-++++- Signed 16-bit sample.
</pre>
Unlike the [[Sound]] sample output registers, these can be written to - allowing for direct 16-bit sample output.
{{Anchor|Hyper Voice Input}}
=== Hyper Voice Input ($69 write) ===
<pre>
7 bit 0
---- ----
ssss ssss
|||| ||||
++++-++++- Signed 8-bit sample.
</pre>
Hyper Voice samples are typically written by [[DMA|Sound DMA]], but can also be written manually by the user. In the latter case, the "channel mode" setting is ignored - it always behaves as if it were in "stereo" mode, writing one channel after the other in sequence.
{{Anchor|Hyper Voice Control}}
=== Hyper Voice Control ($6A, $6B) ===
<pre>
15 bit 8 7 bit 0
---- ---- ---- ----
.ttc ???? errr ssvv
||| |||| ||||
||| |||| ||++- Volume/Shift:
||| |||| || 0 = 100% 1 = 50%
||| |||| || 2 = 25% 3 = 12.5%
||| |||| ++--- Sample extension mode:
||| |||| 0 = Unsigned
||| |||| 1 = Unsigned, negated
||| |||| 2 = Signed
||| |||| 3 = Ignored
||| |+++------ Update sample rate/Divisor:
||| | 0 = 24000/1 = 24000 Hz
||| | 1 = 24000/2 = 12000 Hz
||| | 2 = 24000/3 = 8000 Hz
||| | 3 = 24000/4 = 6000 Hz
||| | 4 = 24000/5 = 4800 Hz
||| | 5 = 24000/6 = 4000 Hz
||| | 6 = 24000/8 = 3000 Hz
||| | 7 = 24000/12 = 2000 Hz
||| +--------- Enable: 0 = off, 1 = on
||+----------------- Reset: When 1 is written, the following DMA sample
|| will be used for the left channel.
++------------------ Target channel layout:
0 = Stereo
1 = Mono, left channel only
2 = Mono, right channel only
3 = Mono, both channels
</pre>
Internally, 8-bit values of the form <tt style="white-space: nowrap">Vvvv vvvv</tt> are transformed to signed 16-bit samples based on the scaling mode as follows, where <code>V</code> represents the highest, 7th bit of the input value:
{| class="wikitable"
! Sample extension mode
! Bit representation
|-
| Unsigned
| <tt style="white-space: nowrap">000 Vvvv vvvv 0000 0000</tt>
|-
| Unsigned, negated
| <tt style="white-space: nowrap">111 Vvvv vvvv 0000 0000</tt>
|-
| Signed
| <tt style="white-space: nowrap">VVV Vvvv vvvv 0000 0000</tt>
|-
| Ignored
| <tt style="white-space: nowrap">___ Vvvv vvvv 0000 0000</tt>
|}
With the exception of the Ignored mode, the resulting value is shifted right by <code>Shift</code> bits, and the result's bottom 16 bits are used as the sample.
00e178c78daa9cbee53e5b32c94512cb48572ddb
MediaWiki:Sidebar
8
4
615
7
2025-05-07T01:43:36Z
Fiskbit
37
Adds a link to the offline wiki snapshot on archive.org to the sidebar.
wikitext
text/x-wiki
* navigation
** mainpage|Wiki main page
** https://archive.org/details/WSDevWiki | Offline wiki snapshot
** https://forums.nesdev.org/ | NESdev Forums
** https://discord.gg/JSG4kuF8EK | NESdev Discord
** https://discord.gg/7rmX2QJ | WS Discord
** recentchanges-url|recentchanges
* SEARCH
* TOOLBOX
* LANGUAGES
d7fc551bb290963aa84df289d5736570d6239e80
UART
0
23
616
554
2025-06-01T18:30:26Z
Asie
351
wikitext
text/x-wiki
The WonderSwan's EXT port features an UART serial port operating with the following configuration:
* 9,600 or 38,400 bps (bauds per second),
* 8N1 (8 data bits followed by 1 stop bit, no parity).
This allows for effective maximum transfer speeds of 960 or 3840 bytes per second, respectively.
The hardware also features one-byte transmit and receive buffers, which allow for a slight delay in code when handling data to/from the console.
== Interrupts ==
The UART features two interrupts:
* UART Send Ready - constantly triggering (level interrupt) as long as the transmit buffer is empty (Serial Status bit 2),
* UART Receive Ready - constantly triggering (level interrupt) as long as the receive buffer contains a byte (Serial Status bit 0).
These interrupts are only triggering if the UART block is enabled.
== I/O ports ==
{{Anchor|Serial Receive Data}}
=== Serial Receive Data ($B1 read) ===
<pre>
7 bit 0
---- ----
dddd dddd
|||| ||||
++++-++++- Receive buffer value
</pre>
{{Anchor|Serial Transmit Data}}
=== Serial Transmit Data ($B1 write) ===
<pre>
7 bit 0
---- ----
dddd dddd
|||| ||||
++++-++++- Transmit buffer value
</pre>
{{Anchor|Serial Status}}
=== Serial Status ($B3 read) ===
<pre>
7 bit 0
---- ----
eb.. .tor
|| |||
|| ||+- 1 if the receive buffer contains a byte
|| |+-- 1 on overrun (receive buffer overflow)
|| +--- 1 if the transmit buffer is empty (can transmit another byte)
|+-------- UART speed: 0 = 9600 bps, 1 = 38400 bps
+--------- UART enable: 0 = off, 1 = on
</pre>
{{Anchor|Serial Control}}
=== Serial Control ($B3 write) ===
<pre>
7 bit 0
---- ----
ebO. ....
|||
||+------- Write 1 to reset overrun
|+-------- UART speed: 0 = 9600 bps, 1 = 38400 bps
+--------- UART enable: 0 = off, 1 = on
</pre>
189815041aa8761555885752dafa3c435b87c7af
WonderWitch/FreyaBIOS/Sound
0
50
617
317
2025-06-14T10:49:25Z
Asie
351
/* INT $15/AH=$00 - sound_init */ document
wikitext
text/x-wiki
The Sound interrupt provides an abstraction layer for the WonderSwan's [[Sound|sound hardware]].
== Interrupts ==
=== INT $15/AH=$00 - sound_init ===
* AH = $00
Initializes the sound system, by:
* setting the sound wavetable address to 0x180,
* clearing the sound channel control (0x90) and output control (0x91) ports,
* clearing all other writable sound-related ports (0x80-0x8E, 0x94).
=== INT $15/AH=$01 - sound_set_channel ===
* AH = $01
* BL = [[Sound#Sound Channel Control|Channel Control]] value
=== INT $15/AH=$02 - sound_get_channel ===
* AH = $02
Return:
* AL = [[Sound#Sound Channel Control|Channel Control]] value
=== INT $15/AH=$03 - sound_set_output ===
* AH = $03
* BL = [[Sound#Sound Output Control|Output Control]] value
=== INT $15/AH=$04 - sound_get_output ===
* AH = $04
Return:
* AL = [[Sound#Sound Output Control|Output Control]] value
=== INT $15/AH=$05 - sound_set_wave ===
* AH = $05
* AL = Channel (0, 1, 2, 3)
* DS:DX = Pointer to waveform data (16 bytes)
=== INT $15/AH=$06 - sound_set_pitch ===
* AH = $06
* AL = Channel (0, 1, 2, 3)
* BX = Frequency divider (0 - 2047)
=== INT $15/AH=$07 - sound_get_pitch ===
* AH = $07
* AL = Channel (0, 1, 2, 3)
Return:
* AX = Frequency divider (0 - 2047)
=== INT $15/AH=$08 - sound_set_volume ===
* AH = $08
* AL = Channel (0, 1, 2, 3)
* BL = [[Sound#Sound Channel Volume|Channel Volume]] value
=== INT $15/AH=$09 - sound_get_volume ===
* AH = $09
* AL = Channel (0, 1, 2, 3)
Return:
* AL = [[Sound#Sound Channel Volume|Channel Volume]] value
=== INT $15/AH=$0A - sound_set_sweep ===
* AH = $0A
* BL = [[Sound#Sound Channel 3 Sweep Amount|Sweep Amount]]
* CL = [[Sound#Sound Channel 3 Sweep Ticks|Sweep Ticks]]
=== INT $15/AH=$0B - sound_get_sweep ===
* AH = $0B
Return:
* AL = [[Sound#Sound Channel 3 Sweep Amount|Sweep Amount]]
* AH = [[Sound#Sound Channel 3 Sweep Ticks|Sweep Ticks]]
=== INT $15/AH=$0C - sound_set_noise ===
* AH = $0C
* BL = [[Sound#Sound Channel 4 Noise Control|Channel 4 Noise Control]] value
=== INT $15/AH=$0D - sound_get_noise ===
* AH = $0D
Return:
* AL = [[Sound#Sound Channel 4 Noise Control|Channel 4 Noise Control]] value
=== INT $15/AH=$0E - sound_get_random ===
* AH = $0E
Return:
* AX = [[Sound#Sound Channel 4 LFSR Register|Channel 4 LFSR Register]] value
97b78b4561b0581e8fa65801491de0edda9960b0